diff --git a/src/arch/arm/early_console.c b/src/arch/arm/early_console.c index b03e6d9d0a..59748eee72 100644 --- a/src/arch/arm/early_console.c +++ b/src/arch/arm/early_console.c @@ -61,21 +61,3 @@ void console_tx_flush(void) usbdebug_tx_flush(0); #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; -} diff --git a/src/arch/arm64/early_console.c b/src/arch/arm64/early_console.c index aa287a3009..11ac717aa9 100644 --- a/src/arch/arm64/early_console.c +++ b/src/arch/arm64/early_console.c @@ -55,21 +55,3 @@ void console_tx_flush(void) usbdebug_tx_flush(0); #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; -} diff --git a/src/arch/x86/lib/romstage_console.c b/src/arch/x86/lib/romstage_console.c index f53f5a9d75..a3e8be82ae 100644 --- a/src/arch/x86/lib/romstage_console.c +++ b/src/arch/x86/lib/romstage_console.c @@ -69,21 +69,3 @@ void console_tx_flush(void) usbdebug_tx_flush(0); #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; -} diff --git a/src/console/Makefile.inc b/src/console/Makefile.inc index db6604339c..3536eaf2c6 100644 --- a/src/console/Makefile.inc +++ b/src/console/Makefile.inc @@ -9,16 +9,16 @@ smm-y += printk.c smm-y += vtxprintf.c smm-$(CONFIG_SMM_TSEG) += die.c -verstage-$(CONFIG_EARLY_CONSOLE) += vtxprintf.c +verstage-$(CONFIG_EARLY_CONSOLE) += vtxprintf.c early_console.c verstage-y += console.c verstage-y += die.c -romstage-$(CONFIG_EARLY_CONSOLE) += vtxprintf.c +romstage-$(CONFIG_EARLY_CONSOLE) += vtxprintf.c early_console.c romstage-y += console.c romstage-y += post.c romstage-y += die.c -bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += vtxprintf.c +bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += vtxprintf.c early_console.c bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += console.c bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += die.c diff --git a/src/console/early_console.c b/src/console/early_console.c new file mode 100644 index 0000000000..db46a4c644 --- /dev/null +++ b/src/console/early_console.c @@ -0,0 +1,47 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2014 Google, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +int vprintk(int msg_level, const char *fmt, va_list args) +{ + int i; + + if (msg_level > console_loglevel) + return 0; + + i = vtxprintf(console_tx_byte, fmt, args); + + console_tx_flush(); + + return i; +} + +int do_printk(int msg_level, const char *fmt, ...) +{ + va_list args; + int i; + + va_start(args, fmt); + i = vprintk(msg_level, fmt, args); + va_end(args); + + return i; +} diff --git a/src/console/printk.c b/src/console/printk.c index 75490881f6..a8998eef82 100644 --- a/src/console/printk.c +++ b/src/console/printk.c @@ -15,21 +15,17 @@ int default_console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL; DECLARE_SPIN_LOCK(console_lock) -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; - if (msg_level > console_loglevel) { + if (msg_level > console_loglevel) return 0; - } DISABLE_TRACE; spin_lock(&console_lock); - va_start(args, fmt); i = vtxprintf(console_tx_byte, fmt, args); - va_end(args); console_tx_flush(); @@ -38,3 +34,15 @@ int do_printk(int msg_level, const char *fmt, ...) return i; } + +int do_printk(int msg_level, const char *fmt, ...) +{ + va_list args; + int i; + + va_start(args, fmt); + i = vprintk(msg_level, fmt, args); + va_end(args); + + return i; +} diff --git a/src/include/console/console.h b/src/include/console/console.h index 4f6e15ab32..7c87438bfe 100644 --- a/src/include/console/console.h +++ b/src/include/console/console.h @@ -23,6 +23,7 @@ #include #include #include +#include #if CONFIG_CONSOLE_SERIAL #include @@ -81,6 +82,7 @@ void post_log_clear(void); 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))); +int vprintk(int msg_level, const char *fmt, va_list args); #if defined(__BOOT_BLOCK__) && !CONFIG_BOOTBLOCK_CONSOLE || \ (defined(__PRE_RAM__) && !defined(__BOOT_BLOCK__)) && !CONFIG_EARLY_CONSOLE