Kyösti Mälkki (kyosti.malkki@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5334
-gerrit
commit 36499558ab53ca284410bebe29ecce824b47cc7d Author: Kyösti Mälkki kyosti.malkki@gmail.com Date: Tue Feb 4 14:28:17 2014 +0200
console: Simplify vtxprintf
We do not need ROMCC support here and using wrappers for console_tx_byte we can simplify this code.
Change-Id: I7f3b5acdfd0bde1d832b16418339dd5e232627e7 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- src/console/printk.c | 15 +++++++++- src/console/vsprintf.c | 2 +- src/console/vtxprintf.c | 42 +++++---------------------- src/include/console/console.h | 18 +++++++----- src/include/console/vtxprintf.h | 7 ++--- src/vendorcode/google/chromeos/vboot_loader.c | 3 +- 6 files changed, 37 insertions(+), 50 deletions(-)
diff --git a/src/console/printk.c b/src/console/printk.c index a3b91ad..be16c7b 100644 --- a/src/console/printk.c +++ b/src/console/printk.c @@ -5,6 +5,7 @@ * */
+#include <stddef.h> #include <smp/node.h> #include <smp/spinlock.h> #include <console/vtxprintf.h> @@ -13,6 +14,11 @@
DECLARE_SPIN_LOCK(console_lock)
+void wrap_putchar(unsigned char byte, void *data) +{ + console_tx_byte(byte); +} + int do_printk(int msg_level, const char *fmt, ...) { va_list args; @@ -30,7 +36,7 @@ int do_printk(int msg_level, const char *fmt, ...) spin_lock(&console_lock);
va_start(args, fmt); - i = vtxprintf(console_tx_byte, fmt, args); + i = vtxprintf(wrap_putchar, fmt, args, NULL); va_end(args);
console_tx_flush(); @@ -40,3 +46,10 @@ int do_printk(int msg_level, const char *fmt, ...)
return i; } + +void do_vtxprintf(const char *fmt, va_list args) +{ + vtxprintf(wrap_putchar, fmt, args, NULL); + console_tx_flush(); +} + diff --git a/src/console/vsprintf.c b/src/console/vsprintf.c index 1fb834f..fd6646b 100644 --- a/src/console/vsprintf.c +++ b/src/console/vsprintf.c @@ -48,7 +48,7 @@ static int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
ctx.str_buf = buf; ctx.buf_limit = size ? size - 1 : 0; - i = vtxdprintf(str_tx_byte, fmt, args, &ctx); + i = vtxprintf(str_tx_byte, fmt, args, &ctx); if (size) *ctx.str_buf = '\0';
diff --git a/src/console/vtxprintf.c b/src/console/vtxprintf.c index 502d53e..d4d70b6 100644 --- a/src/console/vtxprintf.c +++ b/src/console/vtxprintf.c @@ -8,15 +8,7 @@ #include <console/console.h> #include <console/vtxprintf.h>
-#if !defined (__ROMCC__) && !defined(__SMM__) -#define DATA_ARG , data -#define DATA_ARG_DECL , void *data -#else -#define DATA_ARG -#define DATA_ARG_DECL -#endif - -#define call_tx(x) tx_byte(x DATA_ARG) +#define call_tx(x) tx_byte(x, data)
/* haha, don't need ctype.c */ #define isdigit(c) ((c) >= '0' && (c) <= '9') @@ -40,9 +32,9 @@ static int skip_atoi(const char **s) #define SPECIAL 32 /* 0x */ #define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
-static int number(void (*tx_byte)(unsigned char byte DATA_ARG_DECL), - unsigned long long num, int base, int size, int precision, int type - DATA_ARG_DECL) +static int number(void (*tx_byte)(unsigned char byte, void *data), + unsigned long long num, int base, int size, int precision, int type, + void *data) { char c,sign,tmp[66]; const char *digits="0123456789abcdefghijklmnopqrstuvwxyz"; @@ -112,12 +104,8 @@ static int number(void (*tx_byte)(unsigned char byte DATA_ARG_DECL), }
-#if !defined (__ROMCC__) && !defined(__SMM__) -int vtxdprintf(void (*tx_byte)(unsigned char byte, void *data), +int vtxprintf(void (*tx_byte)(unsigned char byte, void *data), const char *fmt, va_list args, void *data) -#else -int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args) -#endif { int len; unsigned long long num; @@ -135,7 +123,7 @@ int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args
#if defined(__SMM__) && CONFIG_SMM_TSEG /* Fix pointer in TSEG */ - tx_byte = console_tx_byte; + tx_byte = wrap_putchar; #endif
for (count=0; *fmt ; ++fmt) { @@ -236,7 +224,7 @@ repeat: } count += number(tx_byte, (unsigned long) va_arg(args, void *), 16, - field_width, precision, flags DATA_ARG); + field_width, precision, flags, data); continue;
case 'n': @@ -300,21 +288,7 @@ repeat: } else { num = va_arg(args, unsigned int); } - count += number(tx_byte, num, base, field_width, precision, flags DATA_ARG); + count += number(tx_byte, num, base, field_width, precision, flags, data); } return count; } - - -#if !defined (__ROMCC__) && !defined(__SMM__) -static void wrap_tx_byte (unsigned char byte, void *data) -{ - void (*tx_byte)(unsigned char byte) = data; - tx_byte (byte); -} - -int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args) -{ - return vtxdprintf(wrap_tx_byte, fmt, args, tx_byte); -} -#endif diff --git a/src/include/console/console.h b/src/include/console/console.h index f4b3c46..d8681e1 100644 --- a/src/include/console/console.h +++ b/src/include/console/console.h @@ -62,25 +62,29 @@ void post_log_clear(void); /* this function is weak and can be overridden by a mainboard function. */ void mainboard_post(u8 value); void __attribute__ ((noreturn)) die(const char *msg); -int do_printk(int msg_level, const char *fmt, ...) __attribute__((format(printf, 2, 3))); + +#include <console/vtxprintf.h>
#if defined(__BOOT_BLOCK__) && !CONFIG_BOOTBLOCK_CONSOLE || \ defined(__SMM__) && !CONFIG_DEBUG_SMI || \ (defined(__PRE_RAM__) && !defined(__BOOT_BLOCK__)) && !CONFIG_EARLY_CONSOLE
-static inline void printk(int LEVEL, const char *fmt, ...); -static inline void printk(int LEVEL, const char *fmt, ...) { - /* Do nothing. */ -} +/* Do nothing. */ +static inline void printk(int LEVEL, const char *fmt, ...) {} +static inline void do_vtxprintf(const char *fmt, va_list args) {} + +#else
-#else /* defined(__PRE_RAM__) && !CONFIG_EARLY_CONSOLE */ +int do_printk(int msg_level, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +void do_vtxprintf(const char *fmt, va_list args); +void wrap_putchar(char byte, void *data);
#define printk(LEVEL, fmt, args...) \ do { \ do_printk(LEVEL, fmt, ##args); \ } while(0)
-#endif /* defined(__PRE_RAM__) && !CONFIG_EARLY_CONSOLE */ +#endif
#define print_emerg(STR) printk(BIOS_EMERG, "%s", (STR)) #define print_alert(STR) printk(BIOS_ALERT, "%s", (STR)) diff --git a/src/include/console/vtxprintf.h b/src/include/console/vtxprintf.h index c5daf9d..3f0c63e 100644 --- a/src/include/console/vtxprintf.h +++ b/src/include/console/vtxprintf.h @@ -34,10 +34,7 @@ typedef __builtin_va_list va_list; #include <stdarg.h> #endif
-int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args); - -#if !defined (__ROMCC__) && !defined (__SMM__) -int vtxdprintf(void (*tx_byte)(unsigned char byte, void *data), const char *fmt, va_list args, void *data); -#endif +int vtxprintf(void (*tx_byte)(unsigned char byte, void *data), + const char *fmt, va_list args, void *data);
#endif diff --git a/src/vendorcode/google/chromeos/vboot_loader.c b/src/vendorcode/google/chromeos/vboot_loader.c index 0c5220a..943ad17 100644 --- a/src/vendorcode/google/chromeos/vboot_loader.c +++ b/src/vendorcode/google/chromeos/vboot_loader.c @@ -64,8 +64,7 @@ out: /* Helper routines for the vboot stub. */ static void log_msg(const char *fmt, va_list args) { - vtxprintf(console_tx_byte, fmt, args); - console_tx_flush(); + do_vtxprintf(fmt, args); }
static void fatal_error(void)