Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 7 | #include <spinlock.h> |
| 8 | #include <stdarg.h> |
| 9 | #include <stdio.h> |
| 10 | |
| 11 | /* Lock to avoid concurrent accesses to the serial console */ |
| 12 | static spinlock_t printf_lock; |
| 13 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 14 | void mp_printf(const char *fmt, ...) |
| 15 | { |
Sandrine Bailleux | 750b7cc | 2018-11-08 14:10:18 +0100 | [diff] [blame^] | 16 | va_list args; |
| 17 | va_start(args, fmt); |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 18 | |
| 19 | spin_lock(&printf_lock); |
Sandrine Bailleux | 750b7cc | 2018-11-08 14:10:18 +0100 | [diff] [blame^] | 20 | vprintf(fmt, args); |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 21 | spin_unlock(&printf_lock); |
Sandrine Bailleux | 411a6b2 | 2018-11-08 14:08:09 +0100 | [diff] [blame] | 22 | |
Sandrine Bailleux | 750b7cc | 2018-11-08 14:10:18 +0100 | [diff] [blame^] | 23 | va_end(args); |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 24 | } |