console: Refactor printk() varargs prototypes

Change-Id: I816641c2223c3079ad9c95c1380d4b250898ef93
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/31491
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
Kyösti Mälkki 2019-02-14 23:08:29 +02:00 committed by Patrick Georgi
parent 40f65425e4
commit 7132f259bf
3 changed files with 16 additions and 23 deletions

View file

@ -39,9 +39,8 @@ static void wrap_putchar(unsigned char byte, void *data)
do_putchar(byte); do_putchar(byte);
} }
int do_printk(int msg_level, const char *fmt, ...) int vprintk(int msg_level, const char *fmt, va_list args)
{ {
va_list args;
int i; int i;
if (IS_ENABLED(CONFIG_SQUELCH_EARLY_SMP) && ENV_CACHE_AS_RAM && if (IS_ENABLED(CONFIG_SQUELCH_EARLY_SMP) && ENV_CACHE_AS_RAM &&
@ -60,9 +59,7 @@ int do_printk(int msg_level, const char *fmt, ...)
spin_lock(&console_lock); spin_lock(&console_lock);
#endif #endif
va_start(args, fmt);
i = vtxprintf(wrap_putchar, fmt, args, NULL); i = vtxprintf(wrap_putchar, fmt, args, NULL);
va_end(args);
console_tx_flush(); console_tx_flush();
@ -78,12 +75,14 @@ int do_printk(int msg_level, const char *fmt, ...)
return i; return i;
} }
#if IS_ENABLED(CONFIG_VBOOT) int do_printk(int msg_level, const char *fmt, ...)
void do_printk_va_list(int msg_level, const char *fmt, va_list args)
{ {
if (!console_log_level(msg_level)) va_list args;
return; int i;
vtxprintf(wrap_putchar, fmt, args, NULL);
console_tx_flush(); va_start(args, fmt);
i = vprintk(msg_level, fmt, args);
va_end(args);
return i;
} }
#endif /* CONFIG_VBOOT */

View file

@ -19,6 +19,7 @@
#include <stdint.h> #include <stdint.h>
#include <arch/cpu.h> #include <arch/cpu.h>
#include <console/post_codes.h> #include <console/post_codes.h>
#include <console/vtxprintf.h>
#include <commonlib/loglevel.h> #include <commonlib/loglevel.h>
#define RAM_DEBUG (IS_ENABLED(CONFIG_DEBUG_RAM_SETUP) ? BIOS_DEBUG : BIOS_NEVER) #define RAM_DEBUG (IS_ENABLED(CONFIG_DEBUG_RAM_SETUP) ? BIOS_DEBUG : BIOS_NEVER)
@ -56,8 +57,6 @@ void die_notify(void);
#if __CONSOLE_ENABLE__ #if __CONSOLE_ENABLE__
asmlinkage void console_init(void); asmlinkage void console_init(void);
int console_log_level(int msg_level); int console_log_level(int msg_level);
int do_printk(int msg_level, const char *fmt, ...)
__attribute__((format(printf, 2, 3)));
void do_putchar(unsigned char byte); void do_putchar(unsigned char byte);
#define printk(LEVEL, fmt, args...) \ #define printk(LEVEL, fmt, args...) \
@ -82,15 +81,10 @@ static inline void printk(int LEVEL, const char *fmt, ...) {}
static inline void do_putchar(unsigned char byte) {} static inline void do_putchar(unsigned char byte) {}
#endif #endif
#if IS_ENABLED(CONFIG_VBOOT) int vprintk(int msg_level, const char *fmt, va_list args);
/* FIXME: Collision of varargs with AMD headers without guard. */
#include <console/vtxprintf.h> int do_printk(int msg_level, const char *fmt, ...)
#if __CONSOLE_ENABLE__ __attribute__((format(printf, 2, 3)));
void do_printk_va_list(int msg_level, const char *fmt, va_list args);
#else
static inline void do_printk_va_list(int l, const char *fmt, va_list args) {}
#endif
#endif
#endif /* !__ROMCC__ */ #endif /* !__ROMCC__ */

View file

@ -48,7 +48,7 @@ void vb2ex_printf(const char *func, const char *fmt, ...)
printk(BIOS_INFO, "VB2:%s() ", func); printk(BIOS_INFO, "VB2:%s() ", func);
va_start(args, fmt); va_start(args, fmt);
do_printk_va_list(BIOS_INFO, fmt, args); vprintk(BIOS_INFO, fmt, args);
va_end(args); va_end(args);
return; return;