blob: 777c736ad320d1f79f373d96f5537332cde22453 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02007#include <spinlock.h>
8#include <stdarg.h>
9#include <stdio.h>
10
11/* Lock to avoid concurrent accesses to the serial console */
12static spinlock_t printf_lock;
13
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020014void mp_printf(const char *fmt, ...)
15{
Sandrine Bailleux750b7cc2018-11-08 14:10:18 +010016 va_list args;
17 va_start(args, fmt);
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020018
19 spin_lock(&printf_lock);
Sandrine Bailleux750b7cc2018-11-08 14:10:18 +010020 vprintf(fmt, args);
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020021 spin_unlock(&printf_lock);
Sandrine Bailleux411a6b22018-11-08 14:08:09 +010022
Sandrine Bailleux750b7cc2018-11-08 14:10:18 +010023 va_end(args);
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020024}