console: Unify do_printk()

Change-Id: I6c50e47d9d2d0d1f42beee477e49b2a0054d1786
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: http://review.coreboot.org/5332
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
This commit is contained in:
Kyösti Mälkki 2014-01-27 15:09:13 +02:00 committed by Patrick Georgi
parent 21333f96c7
commit b2d2596714
5 changed files with 14 additions and 53 deletions

View File

@ -20,7 +20,6 @@
#include <console/console.h> #include <console/console.h>
#include <console/cbmem_console.h> #include <console/cbmem_console.h>
#include <console/uart.h> #include <console/uart.h>
#include <console/vtxprintf.h>
/* FIXME: need to make console driver more generic */ /* FIXME: need to make console driver more generic */
void console_tx_byte(unsigned char byte) void console_tx_byte(unsigned char byte)
@ -36,27 +35,9 @@ void console_tx_byte(unsigned char byte)
#endif #endif
} }
static void _console_tx_flush(void) void console_tx_flush(void)
{ {
#if CONFIG_CONSOLE_SERIAL #if CONFIG_CONSOLE_SERIAL
uart_tx_flush(); uart_tx_flush();
#endif #endif
} }
int do_printk(int msg_level, const char *fmt, ...)
{
va_list args;
int i;
if (msg_level > console_loglevel) {
return 0;
}
va_start(args, fmt);
i = vtxprintf(console_tx_byte, fmt, args);
va_end(args);
_console_tx_flush();
return i;
}

View File

@ -17,14 +17,12 @@
* MA 02110-1301 USA * MA 02110-1301 USA
*/ */
#include <smp/node.h>
#include <console/console.h> #include <console/console.h>
#include <console/cbmem_console.h> #include <console/cbmem_console.h>
#include <console/uart.h> #include <console/uart.h>
#include <console/usb.h> #include <console/usb.h>
#include <console/ne2k.h> #include <console/ne2k.h>
#include <console/spkmodem.h> #include <console/spkmodem.h>
#include <console/vtxprintf.h>
void console_tx_byte(unsigned char byte) void console_tx_byte(unsigned char byte)
{ {
@ -60,26 +58,3 @@ void console_tx_flush(void)
usb_tx_flush(0); usb_tx_flush(0);
#endif #endif
} }
int do_printk(int msg_level, const char *fmt, ...)
{
va_list args;
int i;
if (msg_level > console_loglevel) {
return 0;
}
#if CONFIG_SQUELCH_EARLY_SMP
if (!boot_cpu())
return 0;
#endif
va_start(args, fmt);
i = vtxprintf(console_tx_byte, fmt, args);
va_end(args);
console_tx_flush();
return i;
}

View File

@ -1,19 +1,17 @@
ramstage-y += printk.c ramstage-y += vtxprintf.c printk.c vsprintf.c
ramstage-y += init.c console.c ramstage-y += init.c console.c
ramstage-y += vtxprintf.c
ramstage-y += vsprintf.c
ramstage-y += post.c ramstage-y += post.c
ramstage-y += die.c ramstage-y += die.c
smm-$(CONFIG_DEBUG_SMI) += vtxprintf.c printk.c smm-$(CONFIG_DEBUG_SMI) += vtxprintf.c printk.c
smm-$(CONFIG_SMM_TSEG) += die.c smm-$(CONFIG_SMM_TSEG) += die.c
romstage-$(CONFIG_EARLY_CONSOLE) += vtxprintf.c romstage-$(CONFIG_EARLY_CONSOLE) += vtxprintf.c printk.c
romstage-$(CONFIG_EARLY_CONSOLE) += init.c console.c romstage-$(CONFIG_EARLY_CONSOLE) += init.c console.c
romstage-y += post.c romstage-y += post.c
romstage-y += die.c romstage-y += die.c
bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += vtxprintf.c bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += vtxprintf.c printk.c
bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += init.c console.c bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += init.c console.c
bootblock-y += die.c bootblock-y += die.c

View File

@ -29,6 +29,10 @@
#include <device/pci.h> #include <device/pci.h>
#endif #endif
#if !defined(__PRE_RAM__)
int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
#endif
void console_init(void) void console_init(void)
{ {
#if !defined(__PRE_RAM__) #if !defined(__PRE_RAM__)

View File

@ -5,14 +5,12 @@
* *
*/ */
#include <smp/node.h>
#include <smp/spinlock.h> #include <smp/spinlock.h>
#include <console/vtxprintf.h> #include <console/vtxprintf.h>
#include <console/console.h> #include <console/console.h>
#include <trace.h> #include <trace.h>
int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
int default_console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
DECLARE_SPIN_LOCK(console_lock) DECLARE_SPIN_LOCK(console_lock)
int do_printk(int msg_level, const char *fmt, ...) int do_printk(int msg_level, const char *fmt, ...)
@ -24,6 +22,11 @@ int do_printk(int msg_level, const char *fmt, ...)
return 0; return 0;
} }
#if CONFIG_SQUELCH_EARLY_SMP && defined(__PRE_RAM__)
if (!boot_cpu())
return 0;
#endif
DISABLE_TRACE; DISABLE_TRACE;
spin_lock(&console_lock); spin_lock(&console_lock);