mail.coreboot.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
List overview
Download
coreboot-gerrit
March 2014
----- 2024 -----
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
coreboot-gerrit@coreboot.org
1 participants
584 discussions
Start a n
N
ew thread
New patch to review for coreboot: 2684832 console: Add printk helper for ChromeOS
by Kyösti Mälkki
06 Mar '14
06 Mar '14
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at
http://review.coreboot.org/5347
-gerrit commit 2684832d5903d3f4ccd38e0b51c6c08af00ced7f Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com> Date: Thu Mar 6 16:55:05 2014 +0200 console: Add printk helper for ChromeOS Do not expose console_tx_flush() to ChromeOS. Change-Id: I1e31662da88a60e83f8e5d307a4b53441c130aab Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com> --- src/console/printk.c | 8 ++++++++ src/include/console/console.h | 10 ++++++++++ src/vendorcode/google/chromeos/vboot_loader.c | 3 +-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/console/printk.c b/src/console/printk.c index a3b91ad..f60af61 100644 --- a/src/console/printk.c +++ b/src/console/printk.c @@ -40,3 +40,11 @@ int do_printk(int msg_level, const char *fmt, ...) return i; } + +#if CONFIG_CHROMEOS +void do_vtxprintf(const char *fmt, va_list args) +{ + vtxprintf(console_tx_byte, fmt, args, NULL); + console_tx_flush(); +} +#endif diff --git a/src/include/console/console.h b/src/include/console/console.h index f4b3c46..ee7f885 100644 --- a/src/include/console/console.h +++ b/src/include/console/console.h @@ -82,6 +82,16 @@ static inline void printk(int LEVEL, const char *fmt, ...) { #endif /* defined(__PRE_RAM__) && !CONFIG_EARLY_CONSOLE */ +#if CONFIG_CHROMEOS +/* FIXME: Collision of varargs with AMD headers without guard. */ +#include <console/vtxprintf.h> +#if !defined(__PRE_RAM__) || CONFIG_EARLY_CONSOLE +void do_vtxprintf(const char *fmt, va_list args); +#else +static inline void do_vtxprintf(const char *fmt, va_list args) {}; +#endif +#endif + #define print_emerg(STR) printk(BIOS_EMERG, "%s", (STR)) #define print_alert(STR) printk(BIOS_ALERT, "%s", (STR)) #define print_crit(STR) printk(BIOS_CRIT, "%s", (STR)) 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)
1
0
0
0
Patch set updated for coreboot: 3059a14 console: Move newline translation outside console_tx_byte
by Kyösti Mälkki
06 Mar '14
06 Mar '14
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at
http://review.coreboot.org/5336
-gerrit commit 3059a1490348a97be44ece457facf322058bfb7e Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com> Date: Tue Feb 4 19:03:57 2014 +0200 console: Move newline translation outside console_tx_byte This gives us completely transparent low-level function to transmit data. Change-Id: I706791ff43d80a36a7252a4da0e6f3af92520db7 Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com> --- 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 | 14 ++++++++------ 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(+), 28 deletions(-) diff --git a/src/arch/armv7/early_console.c b/src/arch/armv7/early_console.c index a85f554..599cbc7 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 c80cf8c..4971f01 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 1712877..d5aadf6 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 f60af61..c7c6117 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, NULL); + vtxprintf(do_putchar, fmt, args, NULL); console_tx_flush(); } #endif + diff --git a/src/cpu/x86/smm/smiutil.c b/src/cpu/x86/smm/smiutil.c index 6e9822e..644cab7 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 ee7f885..69734e0 100644 --- a/src/include/console/console.h +++ b/src/include/console/console.h @@ -68,19 +68,21 @@ int do_printk(int msg_level, const char *fmt, ...) __attribute__((format(printf, 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 316f7fd..1e020f9 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 bfb4033..61e1545 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 7bcd54f..98d389e 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)
1
0
0
0
Patch set updated for coreboot: 9d042a6 console: Simplify vtxprintf
by Kyösti Mälkki
06 Mar '14
06 Mar '14
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at
http://review.coreboot.org/5334
-gerrit commit 9d042a6e5b12bb894fb3cc642ac706727fe51c9b Author: Kyösti Mälkki <kyosti.malkki(a)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(a)gmail.com> --- src/console/printk.c | 10 ++++++++-- src/console/vsprintf.c | 2 +- src/console/vtxprintf.c | 42 ++++++++--------------------------------- src/include/console/console.h | 2 +- src/include/console/vtxprintf.h | 7 ++----- 5 files changed, 20 insertions(+), 43 deletions(-) diff --git a/src/console/printk.c b/src/console/printk.c index c7c6117..4fc66ab 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> @@ -20,6 +21,11 @@ void do_putchar(unsigned char byte) console_tx_byte(byte); } +void wrap_putchar(unsigned char byte, void *data) +{ + do_putchar(byte); +} + int do_printk(int msg_level, const char *fmt, ...) { va_list args; @@ -37,7 +43,7 @@ int do_printk(int msg_level, const char *fmt, ...) spin_lock(&console_lock); va_start(args, fmt); - i = vtxprintf(do_putchar, fmt, args); + i = vtxprintf(wrap_putchar, fmt, args, NULL); va_end(args); console_tx_flush(); @@ -51,7 +57,7 @@ int do_printk(int msg_level, const char *fmt, ...) #if CONFIG_CHROMEOS void do_vtxprintf(const char *fmt, va_list args) { - vtxprintf(do_putchar, fmt, args, NULL); + vtxprintf(wrap_putchar, fmt, args, NULL); console_tx_flush(); } #endif 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 69734e0..ad605d0 100644 --- a/src/include/console/console.h +++ b/src/include/console/console.h @@ -62,7 +62,6 @@ 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 || \ @@ -76,6 +75,7 @@ static inline void do_putchar(unsigned char byte) {} int do_printk(int msg_level, const char *fmt, ...) __attribute__((format(printf, 2, 3))); void do_putchar(unsigned char byte); +void wrap_putchar(unsigned char byte, void *data); #define printk(LEVEL, fmt, args...) \ do { \ 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
1
0
0
0
Patch set updated for coreboot: c6342f8 console: Move newline translation outside console_tx_byte
by Kyösti Mälkki
05 Mar '14
05 Mar '14
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at
http://review.coreboot.org/5336
-gerrit commit c6342f811b41e8156ee760091c40183919daa184 Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com> Date: Tue Feb 4 19:03:57 2014 +0200 console: Move newline translation outside console_tx_byte Change-Id: I706791ff43d80a36a7252a4da0e6f3af92520db7 Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com> --- src/arch/armv7/early_console.c | 3 --- src/arch/x86/lib/romstage_console.c | 3 --- src/console/console.c | 9 +-------- src/console/printk.c | 8 ++++++++ src/cpu/x86/smm/smiutil.c | 3 --- src/include/console/console.h | 2 ++ 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, 14 insertions(+), 20 deletions(-) diff --git a/src/arch/armv7/early_console.c b/src/arch/armv7/early_console.c index a85f554..599cbc7 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 c80cf8c..4971f01 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 1712877..d5aadf6 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 e86c930..a937094 100644 --- a/src/console/printk.c +++ b/src/console/printk.c @@ -16,6 +16,8 @@ DECLARE_SPIN_LOCK(console_lock) static void wrap_putchar(unsigned char byte, void *data) { + if (byte == '\n') + console_tx_byte('\r'); console_tx_byte(byte); } @@ -53,3 +55,9 @@ void do_vtxprintf(const char *fmt, va_list args) console_tx_flush(); } +void do_putchar(unsigned char byte) +{ + if (byte == '\n') + console_tx_byte('\r'); + console_tx_byte(byte); +} diff --git a/src/cpu/x86/smm/smiutil.c b/src/cpu/x86/smm/smiutil.c index 6e9822e..644cab7 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 4dd14e5..6b32cb9 100644 --- a/src/include/console/console.h +++ b/src/include/console/console.h @@ -72,11 +72,13 @@ void __attribute__ ((noreturn)) die(const char *msg); /* Do nothing. */ static inline void printk(int LEVEL, const char *fmt, ...) {} static inline void do_vtxprintf(const char *fmt, va_list args) {} +static inline void do_putchar(unsigned char byte) {} #else int do_printk(int msg_level, const char *fmt, ...) __attribute__((format(printf, 2, 3))); void do_vtxprintf(const char *fmt, va_list args); +void do_putchar(unsigned char byte); #define printk(LEVEL, fmt, args...) \ do { \ diff --git a/src/northbridge/intel/haswell/raminit.c b/src/northbridge/intel/haswell/raminit.c index 316f7fd..1e020f9 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 bfb4033..61e1545 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 7bcd54f..98d389e 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)
1
0
0
0
Patch set updated for coreboot: 7e72768 console: Simplify vtxprintf
by Kyösti Mälkki
05 Mar '14
05 Mar '14
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at
http://review.coreboot.org/5334
-gerrit commit 7e72768cd8fe771026996875c71419c5933e6e50 Author: Kyösti Mälkki <kyosti.malkki(a)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(a)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)
1
0
0
0
Patch set updated for coreboot: ea59e0a console: Remove old fix for DEBUG_SMI
by Kyösti Mälkki
05 Mar '14
05 Mar '14
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at
http://review.coreboot.org/5335
-gerrit commit ea59e0ab00668904daca46ec43b320f1d6e3d7e1 Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com> Date: Tue Feb 4 19:50:07 2014 +0200 console: Remove old fix for DEBUG_SMI No longer needed as wrap_putchar() survives SMM relocation to TSEG. Change-Id: I6143844b0b9902ef63baf3e5781a5dc4f54234be Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com> --- src/console/printk.c | 2 +- src/console/vtxprintf.c | 5 ----- src/include/console/console.h | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/console/printk.c b/src/console/printk.c index be16c7b..e86c930 100644 --- a/src/console/printk.c +++ b/src/console/printk.c @@ -14,7 +14,7 @@ DECLARE_SPIN_LOCK(console_lock) -void wrap_putchar(unsigned char byte, void *data) +static void wrap_putchar(unsigned char byte, void *data) { console_tx_byte(byte); } diff --git a/src/console/vtxprintf.c b/src/console/vtxprintf.c index d4d70b6..23db037 100644 --- a/src/console/vtxprintf.c +++ b/src/console/vtxprintf.c @@ -121,11 +121,6 @@ int vtxprintf(void (*tx_byte)(unsigned char byte, void *data), int count; -#if defined(__SMM__) && CONFIG_SMM_TSEG - /* Fix pointer in TSEG */ - tx_byte = wrap_putchar; -#endif - for (count=0; *fmt ; ++fmt) { if (*fmt != '%') { call_tx(*fmt), count++; diff --git a/src/include/console/console.h b/src/include/console/console.h index d8681e1..4dd14e5 100644 --- a/src/include/console/console.h +++ b/src/include/console/console.h @@ -77,7 +77,6 @@ static inline void do_vtxprintf(const char *fmt, va_list args) {} 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 { \
1
0
0
0
Patch set updated for coreboot: 7faf370 console: Unify do_printk()
by Kyösti Mälkki
05 Mar '14
05 Mar '14
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at
http://review.coreboot.org/5332
-gerrit commit 7faf370cf686ea24e735e18a9364f6ec86d1519c Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com> Date: Mon Jan 27 15:09:13 2014 +0200 console: Unify do_printk() Change-Id: I6c50e47d9d2d0d1f42beee477e49b2a0054d1786 Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com> --- src/arch/armv7/early_console.c | 21 +-------------------- src/arch/x86/lib/romstage_console.c | 25 ------------------------- src/console/Makefile.inc | 8 +++----- src/console/init.c | 4 ++++ src/console/printk.c | 9 ++++++--- 5 files changed, 14 insertions(+), 53 deletions(-) diff --git a/src/arch/armv7/early_console.c b/src/arch/armv7/early_console.c index 7614531..a85f554 100644 --- a/src/arch/armv7/early_console.c +++ b/src/arch/armv7/early_console.c @@ -20,7 +20,6 @@ #include <console/console.h> #include <console/cbmem_console.h> #include <console/uart.h> -#include <console/vtxprintf.h> /* FIXME: need to make console driver more generic */ void console_tx_byte(unsigned char byte) @@ -36,27 +35,9 @@ void console_tx_byte(unsigned char byte) #endif } -static void _console_tx_flush(void) +void console_tx_flush(void) { #if CONFIG_CONSOLE_SERIAL uart_tx_flush(); #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 0337245..c80cf8c 100644 --- a/src/arch/x86/lib/romstage_console.c +++ b/src/arch/x86/lib/romstage_console.c @@ -17,14 +17,12 @@ * MA 02110-1301 USA */ -#include <smp/node.h> #include <console/console.h> #include <console/cbmem_console.h> #include <console/uart.h> #include <console/usb.h> #include <console/ne2k.h> #include <console/spkmodem.h> -#include <console/vtxprintf.h> void console_tx_byte(unsigned char byte) { @@ -60,26 +58,3 @@ void console_tx_flush(void) usb_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; - } - -#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; -} diff --git a/src/console/Makefile.inc b/src/console/Makefile.inc index f8bbf22..ef917da 100644 --- a/src/console/Makefile.inc +++ b/src/console/Makefile.inc @@ -1,19 +1,17 @@ -ramstage-y += printk.c +ramstage-y += vtxprintf.c printk.c vsprintf.c ramstage-y += init.c console.c -ramstage-y += vtxprintf.c -ramstage-y += vsprintf.c ramstage-y += post.c ramstage-y += die.c smm-$(CONFIG_DEBUG_SMI) += vtxprintf.c printk.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-y += post.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-y += die.c diff --git a/src/console/init.c b/src/console/init.c index 28934e7..c6ceab5 100644 --- a/src/console/init.c +++ b/src/console/init.c @@ -29,6 +29,10 @@ #include <device/pci.h> #endif +#if !defined(__PRE_RAM__) +int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL; +#endif + void console_init(void) { #if !defined(__PRE_RAM__) diff --git a/src/console/printk.c b/src/console/printk.c index e24c752..7ea8c06 100644 --- a/src/console/printk.c +++ b/src/console/printk.c @@ -5,14 +5,12 @@ * */ +#include <smp/node.h> #include <smp/spinlock.h> #include <console/vtxprintf.h> #include <console/console.h> #include <trace.h> -int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL; -int default_console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL; - DECLARE_SPIN_LOCK(console_lock) int do_printk(int msg_level, const char *fmt, ...) @@ -24,6 +22,11 @@ int do_printk(int msg_level, const char *fmt, ...) return 0; } +#if CONFIG_SQUELCH_EARLY_SMP && defined(__PRE_RAM__) + if (!boot_cpu()) + return 0; +#endif + DISABLE_TRACE; spin_lock(&console_lock);
1
0
0
0
Patch set updated for coreboot: 7c35d27 console: Hide global console_loglevel
by Kyösti Mälkki
05 Mar '14
05 Mar '14
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at
http://review.coreboot.org/5333
-gerrit commit 7c35d27edaaffe7c627d8c0809c01c8cc9b370fe Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com> Date: Fri Feb 28 14:37:27 2014 +0200 console: Hide global console_loglevel Change-Id: I7bdc468bc3f74516abb2c583bdb5b6d7555d987c Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com> --- src/arch/x86/lib/romcc_console.c | 21 +++++++-------------- src/console/init.c | 10 ++++++++-- src/console/printk.c | 3 +-- src/include/console/console.h | 10 +--------- 4 files changed, 17 insertions(+), 27 deletions(-) diff --git a/src/arch/x86/lib/romcc_console.c b/src/arch/x86/lib/romcc_console.c index 3f8f62f..7d2fa5c 100644 --- a/src/arch/x86/lib/romcc_console.c +++ b/src/arch/x86/lib/romcc_console.c @@ -17,18 +17,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <stdint.h> -#include <console/loglevel.h> -#include <console/post_codes.h> #include <console/uart.h> #include <console/ne2k.h> -/* __PRE_RAM__ */ -/* Using a global varible can cause problems when we reset the stack - * from cache as ram to ram. If we make this a define USE_SHARED_STACK - * we could use the same code on all architectures. - */ -#define console_loglevel CONFIG_DEFAULT_CONSOLE_LOGLEVEL +/* While in romstage, console loglevel is built-time constant. */ +#define console_show(msg_level) (CONFIG_DEFAULT_CONSOLE_LOGLEVEL >= msg_level) #if CONFIG_CONSOLE_SERIAL && CONFIG_DRIVERS_UART_8250IO #include "drivers/uart/util.c" @@ -60,7 +53,7 @@ static void __console_tx_nibble(unsigned nibble) static void __console_tx_char(int loglevel, unsigned char byte) { - if (console_loglevel >= loglevel) { + if (console_show(loglevel)) { #if CONFIG_CONSOLE_SERIAL uart_tx_byte(byte); #endif @@ -73,7 +66,7 @@ static void __console_tx_char(int loglevel, unsigned char byte) static void __console_tx_hex8(int loglevel, unsigned char value) { - if (console_loglevel >= loglevel) { + if (console_show(loglevel)) { __console_tx_nibble((value >> 4U) & 0x0fU); __console_tx_nibble(value & 0x0fU); } @@ -84,7 +77,7 @@ static void __console_tx_hex8(int loglevel, unsigned char value) static void __console_tx_hex16(int loglevel, unsigned short value) { - if (console_loglevel >= loglevel) { + if (console_show(loglevel)) { __console_tx_nibble((value >> 12U) & 0x0fU); __console_tx_nibble((value >> 8U) & 0x0fU); __console_tx_nibble((value >> 4U) & 0x0fU); @@ -97,7 +90,7 @@ static void __console_tx_hex16(int loglevel, unsigned short value) static void __console_tx_hex32(int loglevel, unsigned int value) { - if (console_loglevel >= loglevel) { + if (console_show(loglevel)) { __console_tx_nibble((value >> 28U) & 0x0fU); __console_tx_nibble((value >> 24U) & 0x0fU); __console_tx_nibble((value >> 20U) & 0x0fU); @@ -114,7 +107,7 @@ static void __console_tx_hex32(int loglevel, unsigned int value) static void __console_tx_string(int loglevel, const char *str) { - if (console_loglevel >= loglevel) { + if (console_show(loglevel)) { unsigned char ch; while((ch = *str++) != '\0') { if (ch == '\n') diff --git a/src/console/init.c b/src/console/init.c index c6ceab5..d2a5121 100644 --- a/src/console/init.c +++ b/src/console/init.c @@ -29,8 +29,14 @@ #include <device/pci.h> #endif -#if !defined(__PRE_RAM__) -int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL; +#if !defined(__ROMCC__) +/* While in romstage, console loglevel is built-time constant. */ +static ROMSTAGE_CONST int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL; + +int console_show(int msg_level) +{ + return (console_loglevel >= msg_level); +} #endif void console_init(void) diff --git a/src/console/printk.c b/src/console/printk.c index 7ea8c06..a3b91ad 100644 --- a/src/console/printk.c +++ b/src/console/printk.c @@ -18,9 +18,8 @@ int do_printk(int msg_level, const char *fmt, ...) va_list args; int i; - if (msg_level > console_loglevel) { + if (!console_show(msg_level)) return 0; - } #if CONFIG_SQUELCH_EARLY_SMP && defined(__PRE_RAM__) if (!boot_cpu()) diff --git a/src/include/console/console.h b/src/include/console/console.h index 6d1b01a..f4b3c46 100644 --- a/src/include/console/console.h +++ b/src/include/console/console.h @@ -40,18 +40,10 @@ struct console_driver { /* Defined by the linker... */ extern struct console_driver console_drivers[]; extern struct console_driver econsole_drivers[]; - -extern int console_loglevel; -#else -/* __PRE_RAM__ */ -/* Using a global variable can cause problems when we reset the stack - * from cache as ram to ram. If we make this a define USE_SHARED_STACK - * we could use the same code on all architectures. - */ -#define console_loglevel CONFIG_DEFAULT_CONSOLE_LOGLEVEL #endif #ifndef __ROMCC__ +int console_show(int msg_level); void console_init(void); void console_hw_init(void); void console_tx_byte(unsigned char byte);
1
0
0
0
Patch set updated for coreboot: f39c66b console: Split console_init()
by Kyösti Mälkki
05 Mar '14
05 Mar '14
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at
http://review.coreboot.org/5331
-gerrit commit f39c66b1603db669a1fe89e0b14941585daa6ad5 Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com> Date: Fri Feb 14 10:04:31 2014 +0200 console: Split console_init() Splitting the version prompt satisfies some requirements ROMCC sets for the order in which we include source files. Also GDB stub will need console hardware before entering main(). Change-Id: Ibb445a2f8cfb440d9dd69cade5f0ea41fb606f50 Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com> --- src/arch/armv7/bootblock_simple.c | 2 +- src/arch/x86/lib/Makefile.inc | 2 -- src/arch/x86/lib/romcc_console.c | 3 +-- src/console/Makefile.inc | 12 ++++----- src/console/console.c | 35 ++---------------------- src/console/init.c | 56 +++++++++++++++++++++++++++++++++++++++ src/include/console/console.h | 1 + 7 files changed, 67 insertions(+), 44 deletions(-) diff --git a/src/arch/armv7/bootblock_simple.c b/src/arch/armv7/bootblock_simple.c index 2c8e053..bc3ef53 100644 --- a/src/arch/armv7/bootblock_simple.c +++ b/src/arch/armv7/bootblock_simple.c @@ -56,7 +56,7 @@ void main(void) bootblock_mainboard_init(); } -#ifdef CONFIG_BOOTBLOCK_CONSOLE +#if CONFIG_BOOTBLOCK_CONSOLE console_init(); #endif diff --git a/src/arch/x86/lib/Makefile.inc b/src/arch/x86/lib/Makefile.inc index 8588c76..c173011 100644 --- a/src/arch/x86/lib/Makefile.inc +++ b/src/arch/x86/lib/Makefile.inc @@ -27,5 +27,3 @@ smm-y += rom_media.c rmodules-y += memset.c rmodules-y += memcpy.c rmodules-y += memmove.c - -$(obj)/arch/x86/lib/console.ramstage.o :: $(obj)/build.h diff --git a/src/arch/x86/lib/romcc_console.c b/src/arch/x86/lib/romcc_console.c index 4bd3ad4..3f8f62f 100644 --- a/src/arch/x86/lib/romcc_console.c +++ b/src/arch/x86/lib/romcc_console.c @@ -129,7 +129,6 @@ static void __console_tx_string(int loglevel, const char *str) /* if included by romcc, include the sources, too. romcc can't use prototypes */ #include <console/console.c> +#include <console/init.c> #include <console/post.c> #include <console/die.c> - - diff --git a/src/console/Makefile.inc b/src/console/Makefile.inc index df08e80..f8bbf22 100644 --- a/src/console/Makefile.inc +++ b/src/console/Makefile.inc @@ -1,5 +1,5 @@ ramstage-y += printk.c -ramstage-y += console.c +ramstage-y += init.c console.c ramstage-y += vtxprintf.c ramstage-y += vsprintf.c ramstage-y += post.c @@ -9,12 +9,12 @@ smm-$(CONFIG_DEBUG_SMI) += vtxprintf.c printk.c smm-$(CONFIG_SMM_TSEG) += die.c romstage-$(CONFIG_EARLY_CONSOLE) += vtxprintf.c -romstage-y += console.c +romstage-$(CONFIG_EARLY_CONSOLE) += init.c console.c romstage-y += post.c romstage-y += die.c bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += vtxprintf.c -bootblock-y += console.c +bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += init.c console.c bootblock-y += die.c ramstage-$(CONFIG_CONSOLE_SERIAL) += uart_console.c @@ -25,6 +25,6 @@ ramstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c ramstage-$(CONFIG_CONSOLE_QEMU_DEBUGCON) += qemu_debugcon_console.c -$(obj)/console/console.ramstage.o : $(obj)/build.h -$(obj)/console/console.romstage.o : $(obj)/build.h -$(obj)/console/console.bootblock.o : $(obj)/build.h +$(obj)/console/init.ramstage.o : $(obj)/build.h +$(obj)/console/init.romstage.o : $(obj)/build.h +$(obj)/console/init.bootblock.o : $(obj)/build.h diff --git a/src/console/console.c b/src/console/console.c index c46d996..1712877 100644 --- a/src/console/console.c +++ b/src/console/console.c @@ -24,26 +24,12 @@ #include <console/ne2k.h> #include <console/spkmodem.h> -#include <build.h> -#include <arch/hlt.h> -#include <arch/io.h> - -#if CONFIG_EARLY_PCI_BRIDGE -/* FIXME: ROMCC chokes on PCI headers. */ -#include <device/pci.h> -#endif - #ifndef __PRE_RAM__ -#include <string.h> -#include <types.h> -#include <option.h> /* initialize the console */ -void console_init(void) +void console_hw_init(void) { struct console_driver *driver; - if(get_option(&console_loglevel, "debug_level") != CB_SUCCESS) - console_loglevel=CONFIG_DEFAULT_CONSOLE_LOGLEVEL; for(driver = console_drivers; driver < econsole_drivers; driver++) { if (!driver->init) @@ -101,14 +87,8 @@ int console_tst_byte(void) #else // __PRE_RAM__ ^^^ NOT defined vvv defined -void console_init(void) +void console_hw_init(void) { -#if defined(__BOOT_BLOCK__) && CONFIG_BOOTBLOCK_CONSOLE || \ - !defined(__BOOT_BLOCK__) && CONFIG_EARLY_CONSOLE - -#if CONFIG_EARLY_PCI_BRIDGE - pci_early_bridge_init(); -#endif #if CONFIG_CONSOLE_SERIAL uart_init(); #endif @@ -124,16 +104,5 @@ void console_init(void) #if CONFIG_CONSOLE_USB && CONFIG_USBDEBUG_IN_ROMSTAGE && !defined(__BOOT_BLOCK__) usbdebug_init(); #endif - - static const char console_test[] = - "\n\ncoreboot-" - COREBOOT_VERSION - COREBOOT_EXTRA_VERSION - " " - COREBOOT_BUILD - " starting...\n"; - print_info(console_test); - -#endif /* CONFIG_EARLY_CONSOLE */ } #endif diff --git a/src/console/init.c b/src/console/init.c new file mode 100644 index 0000000..28934e7 --- /dev/null +++ b/src/console/init.c @@ -0,0 +1,56 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2003 Eric Biederman + * + * 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 <build.h> +#include <console/console.h> +#include <console/uart.h> +#include <option.h> + +#if CONFIG_EARLY_PCI_BRIDGE +/* FIXME: ROMCC chokes on PCI headers. */ +#include <device/pci.h> +#endif + +void console_init(void) +{ +#if !defined(__PRE_RAM__) + if(get_option(&console_loglevel, "debug_level") != CB_SUCCESS) + console_loglevel=CONFIG_DEFAULT_CONSOLE_LOGLEVEL; +#endif + +#if CONFIG_EARLY_PCI_BRIDGE + pci_early_bridge_init(); +#endif + + console_hw_init(); + +#if defined(__PRE_RAM__) + static const char console_test[] = + "\n\ncoreboot-" + COREBOOT_VERSION + COREBOOT_EXTRA_VERSION + " " + COREBOOT_BUILD + " starting...\n"; + + print_info(console_test); +#endif +} diff --git a/src/include/console/console.h b/src/include/console/console.h index a089729..6d1b01a 100644 --- a/src/include/console/console.h +++ b/src/include/console/console.h @@ -53,6 +53,7 @@ extern int console_loglevel; #ifndef __ROMCC__ void console_init(void); +void console_hw_init(void); void console_tx_byte(unsigned char byte); void console_tx_flush(void); void post_code(u8 value);
1
0
0
0
Patch set updated for coreboot: 5a0aff2 console: Unify do_printk()
by Kyösti Mälkki
05 Mar '14
05 Mar '14
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at
http://review.coreboot.org/5332
-gerrit commit 5a0aff2ed422d392c577b67dd253c19bd709ecf6 Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com> Date: Mon Jan 27 15:09:13 2014 +0200 console: Unify do_printk() Change-Id: I6c50e47d9d2d0d1f42beee477e49b2a0054d1786 Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com> --- src/arch/armv7/early_console.c | 21 +-------------------- src/arch/x86/lib/romstage_console.c | 25 ------------------------- src/console/Makefile.inc | 8 +++----- src/console/printk.c | 6 ++++++ 4 files changed, 10 insertions(+), 50 deletions(-) diff --git a/src/arch/armv7/early_console.c b/src/arch/armv7/early_console.c index 7614531..a85f554 100644 --- a/src/arch/armv7/early_console.c +++ b/src/arch/armv7/early_console.c @@ -20,7 +20,6 @@ #include <console/console.h> #include <console/cbmem_console.h> #include <console/uart.h> -#include <console/vtxprintf.h> /* FIXME: need to make console driver more generic */ void console_tx_byte(unsigned char byte) @@ -36,27 +35,9 @@ void console_tx_byte(unsigned char byte) #endif } -static void _console_tx_flush(void) +void console_tx_flush(void) { #if CONFIG_CONSOLE_SERIAL uart_tx_flush(); #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 0337245..c80cf8c 100644 --- a/src/arch/x86/lib/romstage_console.c +++ b/src/arch/x86/lib/romstage_console.c @@ -17,14 +17,12 @@ * MA 02110-1301 USA */ -#include <smp/node.h> #include <console/console.h> #include <console/cbmem_console.h> #include <console/uart.h> #include <console/usb.h> #include <console/ne2k.h> #include <console/spkmodem.h> -#include <console/vtxprintf.h> void console_tx_byte(unsigned char byte) { @@ -60,26 +58,3 @@ void console_tx_flush(void) usb_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; - } - -#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; -} diff --git a/src/console/Makefile.inc b/src/console/Makefile.inc index f8bbf22..ef917da 100644 --- a/src/console/Makefile.inc +++ b/src/console/Makefile.inc @@ -1,19 +1,17 @@ -ramstage-y += printk.c +ramstage-y += vtxprintf.c printk.c vsprintf.c ramstage-y += init.c console.c -ramstage-y += vtxprintf.c -ramstage-y += vsprintf.c ramstage-y += post.c ramstage-y += die.c smm-$(CONFIG_DEBUG_SMI) += vtxprintf.c printk.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-y += post.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-y += die.c diff --git a/src/console/printk.c b/src/console/printk.c index e24c752..6c2e6e4 100644 --- a/src/console/printk.c +++ b/src/console/printk.c @@ -5,6 +5,7 @@ * */ +#include <smp/node.h> #include <smp/spinlock.h> #include <console/vtxprintf.h> #include <console/console.h> @@ -24,6 +25,11 @@ int do_printk(int msg_level, const char *fmt, ...) return 0; } +#if CONFIG_SQUELCH_EARLY_SMP && defined(__PRE_RAM__) + if (!boot_cpu()) + return 0; +#endif + DISABLE_TRACE; spin_lock(&console_lock);
1
0
0
0
← Newer
1
...
37
38
39
40
41
42
43
...
59
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Results per page:
10
25
50
100
200