diff options
author | Sandrine Bailleux <sandrine.bailleux@arm.com> | 2018-12-21 09:48:17 +0000 |
---|---|---|
committer | TrustedFirmware Code Review <review@review.trustedfirmware.org> | 2018-12-21 09:48:17 +0000 |
commit | 485cee0e136763febc859b8eddd5c54520987725 (patch) | |
tree | c578ab7cb2a16dd3f7687c98d5ce62ad8732a9ae /lib | |
parent | ba7695b39bb82d5ceba093b0c18dd38cc9af61c3 (diff) | |
parent | dfa5ed9fc80f7aad9a0b284a1844aae3251fe75e (diff) | |
download | tf-a-tests-485cee0e136763febc859b8eddd5c54520987725.tar.gz |
Merge changes from topic "sb/terse-output"
* changes:
Remove redundant error message in tftf_initialise_timer()
Remove prints from VExpress NOR flash driver
Remove prints in get_overall_test_result()
Remove SHELL_COLOR build flag
Do not print CPU MPID in mp_printf()
Use vprintf() inside mp_printf()
Add vprintf() in standard C library
Diffstat (limited to 'lib')
-rw-r--r-- | lib/stdlib/printf.c | 30 | ||||
-rw-r--r-- | lib/utils/mp_printf.c | 58 |
2 files changed, 23 insertions, 65 deletions
diff --git a/lib/stdlib/printf.c b/lib/stdlib/printf.c index 6329157d0..8ae7c2635 100644 --- a/lib/stdlib/printf.c +++ b/lib/stdlib/printf.c @@ -9,28 +9,34 @@ /* Choose max of 512 chars for now. */ #define PRINT_BUFFER_SIZE 512 -int printf(const char *fmt, ...) + +int vprintf(const char *fmt, va_list args) { - va_list args; char buf[PRINT_BUFFER_SIZE]; int count; - va_start(args, fmt); vsnprintf(buf, sizeof(buf) - 1, fmt, args); - va_end(args); + buf[PRINT_BUFFER_SIZE - 1] = '\0'; /* Use putchar directly as 'puts()' adds a newline. */ - buf[PRINT_BUFFER_SIZE - 1] = '\0'; count = 0; - while (buf[count]) - { - if (putchar(buf[count]) != EOF) { - count++; - } else { - count = EOF; - break; + while (buf[count] != 0) { + if (putchar(buf[count]) == EOF) { + return EOF; } + count++; } return count; } + +int printf(const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + int count = vprintf(fmt, args); + va_end(args); + + return count; +} diff --git a/lib/utils/mp_printf.c b/lib/utils/mp_printf.c index d1eb780ea..777c736ad 100644 --- a/lib/utils/mp_printf.c +++ b/lib/utils/mp_printf.c @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include <arch_helpers.h> -#include <platform.h> #include <spinlock.h> #include <stdarg.h> #include <stdio.h> @@ -13,60 +11,14 @@ /* Lock to avoid concurrent accesses to the serial console */ static spinlock_t printf_lock; -/* - * Print the MPID header, e.g.: [cpu 0x0100] - * - * If SHELL_COLOR == 1, this also prints shell's color escape sequences to ease - * identifying which CPU displays the message. There are 8 standard colors so - * if the platform has more than 8 CPUs, some colors will be reused. - */ -#if SHELL_COLOR -#define PRINT_MPID_HDR(_mpid) \ - do { \ - unsigned int linear_id = platform_get_core_pos(_mpid); \ - printf("\033[1;%u;40m", 30 + (linear_id & 0x7)); \ - printf("[cpu 0x%.4x] ", _mpid); \ - printf("\033[0m"); \ - } while (0) -#else -#define PRINT_MPID_HDR(_mpid) \ - printf("[cpu 0x%.4x] ", _mpid) -#endif /* SHELL_COLOR */ - void mp_printf(const char *fmt, ...) { - va_list ap; - char str[256]; - /* - * As part of testing Firmware Update feature on Cortex-A57 CPU, an - * issue was discovered while printing in NS_BL1U stage. The issue - * appears when the second call to `NOTICE()` is made in the - * `ns_bl1u_main()`. As a result of this issue the CPU hangs and the - * debugger is also not able to connect anymore. - * - * After further debugging and experiments it was found that if - * `read_mpidr_el1()` is avoided or volatile qualifier is used for - * reading the mpidr, this issue gets resolved. - * - * NOTE: The actual/real reason why this happens is still not known. - * Moreover this problem is not encountered on Cortex-A53 CPU. - */ - volatile unsigned int mpid = read_mpidr_el1() & 0xFFFF; - - /* - * TODO: It would be simpler to use vprintf() instead of - * vsnprintf() + printf(), we wouldn't need to declare a static buffer - * for storing the product of vsnprintf(). Unfortunately our C library - * doesn't provide vprintf() at the moment. - * Import vprintf() code from FreeBSD C library to our local C library. - */ - va_start(ap, fmt); - vsnprintf(str, sizeof(str), fmt, ap); - str[sizeof(str) - 1] = 0; - va_end(ap); + va_list args; + va_start(args, fmt); spin_lock(&printf_lock); - PRINT_MPID_HDR(mpid); - printf("%s", str); + vprintf(fmt, args); spin_unlock(&printf_lock); + + va_end(args); } |