From 657e0be46495bb54ddf5a0fbad786fe352c2847f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Tue, 4 Feb 2014 19:03:57 +0200 Subject: console: Move newline translation outside console_tx_byte MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This gives us completely transparent low-level function to transmit data. Change-Id: I706791ff43d80a36a7252a4da0e6f3af92520db7 Signed-off-by: Kyösti Mälkki Reviewed-on: http://review.coreboot.org/5336 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- src/arch/armv7/early_console.c | 3 --- src/arch/x86/lib/romstage_console.c | 3 --- src/console/console.c | 9 +-------- src/console/printk.c | 12 ++++++++++-- src/cpu/x86/smm/smiutil.c | 3 --- src/include/console/console.h | 15 ++++++++------- src/northbridge/intel/haswell/raminit.c | 2 +- src/northbridge/intel/sandybridge/raminit.c | 2 +- src/soc/intel/baytrail/romstage/raminit.c | 2 +- 9 files changed, 22 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/arch/armv7/early_console.c b/src/arch/armv7/early_console.c index a85f554310..599cbc76e3 100644 --- a/src/arch/armv7/early_console.c +++ b/src/arch/armv7/early_console.c @@ -24,9 +24,6 @@ /* FIXME: need to make console driver more generic */ void console_tx_byte(unsigned char byte) { - if (byte == '\n') - console_tx_byte('\r'); - #if CONFIG_CONSOLE_SERIAL uart_tx_byte(byte); #endif diff --git a/src/arch/x86/lib/romstage_console.c b/src/arch/x86/lib/romstage_console.c index c80cf8c3ff..4971f018c0 100644 --- a/src/arch/x86/lib/romstage_console.c +++ b/src/arch/x86/lib/romstage_console.c @@ -26,9 +26,6 @@ void console_tx_byte(unsigned char byte) { - if (byte == '\n') - console_tx_byte('\r'); - #if CONFIG_CONSOLE_SERIAL uart_tx_byte(byte); #endif diff --git a/src/console/console.c b/src/console/console.c index 1712877801..d5aadf6f32 100644 --- a/src/console/console.c +++ b/src/console/console.c @@ -48,7 +48,7 @@ void console_tx_flush(void) } } -static void __console_tx_byte(unsigned char byte) +void console_tx_byte(unsigned char byte) { struct console_driver *driver; for(driver = console_drivers; driver < econsole_drivers; driver++) { @@ -56,13 +56,6 @@ static void __console_tx_byte(unsigned char byte) } } -void console_tx_byte(unsigned char byte) -{ - if (byte == '\n') - __console_tx_byte('\r'); - __console_tx_byte(byte); -} - unsigned char console_rx_byte(void) { struct console_driver *driver; diff --git a/src/console/printk.c b/src/console/printk.c index c61f63e6a6..63d37cc044 100644 --- a/src/console/printk.c +++ b/src/console/printk.c @@ -13,6 +13,13 @@ DECLARE_SPIN_LOCK(console_lock) +void do_putchar(unsigned char byte) +{ + if (byte == '\n') + console_tx_byte('\r'); + console_tx_byte(byte); +} + int do_printk(int msg_level, const char *fmt, ...) { va_list args; @@ -30,7 +37,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(do_putchar, fmt, args); va_end(args); console_tx_flush(); @@ -44,7 +51,8 @@ int do_printk(int msg_level, const char *fmt, ...) #if CONFIG_CHROMEOS void do_vtxprintf(const char *fmt, va_list args) { - vtxprintf(console_tx_byte, fmt, args); + vtxprintf(do_putchar, fmt, args); console_tx_flush(); } #endif + diff --git a/src/cpu/x86/smm/smiutil.c b/src/cpu/x86/smm/smiutil.c index 6e9822e091..644cab7386 100644 --- a/src/cpu/x86/smm/smiutil.c +++ b/src/cpu/x86/smm/smiutil.c @@ -29,9 +29,6 @@ void console_tx_flush(void) void console_tx_byte(unsigned char byte) { - if (byte == '\n') - console_tx_byte('\r'); - #if CONFIG_CONSOLE_SERIAL uart_tx_byte(byte); #endif diff --git a/src/include/console/console.h b/src/include/console/console.h index e7b4253c32..c184f83e20 100644 --- a/src/include/console/console.h +++ b/src/include/console/console.h @@ -62,25 +62,26 @@ 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))); #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_putchar(unsigned char byte) {} -#else /* defined(__PRE_RAM__) && !CONFIG_EARLY_CONSOLE */ +#else + +int do_printk(int msg_level, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +void do_putchar(unsigned char byte); #define printk(LEVEL, fmt, args...) \ do { \ do_printk(LEVEL, fmt, ##args); \ } while(0) -#endif /* defined(__PRE_RAM__) && !CONFIG_EARLY_CONSOLE */ +#endif #if CONFIG_CHROMEOS /* FIXME: Collision of varargs with AMD headers without guard. */ diff --git a/src/northbridge/intel/haswell/raminit.c b/src/northbridge/intel/haswell/raminit.c index 316f7fdf2a..1e020f95b5 100644 --- a/src/northbridge/intel/haswell/raminit.c +++ b/src/northbridge/intel/haswell/raminit.c @@ -166,7 +166,7 @@ void sdram_initialize(struct pei_data *pei_data) } /* Pass console handler in pei_data */ - pei_data->tx_byte = console_tx_byte; + pei_data->tx_byte = do_putchar; /* Locate and call UEFI System Agent binary. */ entry = (unsigned long)cbfs_get_file_content( diff --git a/src/northbridge/intel/sandybridge/raminit.c b/src/northbridge/intel/sandybridge/raminit.c index bfb403317a..61e15450f0 100644 --- a/src/northbridge/intel/sandybridge/raminit.c +++ b/src/northbridge/intel/sandybridge/raminit.c @@ -248,7 +248,7 @@ void sdram_initialize(struct pei_data *pei_data) } /* Pass console handler in pei_data */ - pei_data->tx_byte = console_tx_byte; + pei_data->tx_byte = do_putchar; /* Locate and call UEFI System Agent binary. */ /* TODO make MRC blob (0xab?) defined in cbfs_core.h. */ diff --git a/src/soc/intel/baytrail/romstage/raminit.c b/src/soc/intel/baytrail/romstage/raminit.c index 7bcd54fe01..98d389eb2c 100644 --- a/src/soc/intel/baytrail/romstage/raminit.c +++ b/src/soc/intel/baytrail/romstage/raminit.c @@ -55,7 +55,7 @@ static void enable_smbus(void) static void ABI_X86 send_to_console(unsigned char b) { - console_tx_byte(b); + do_putchar(b); } static void print_dram_info(void) -- cgit v1.2.3