console: Add compile-time fast path when only CBMEM console is used
A common use case when running coreboot on production systems is that only the CBMEM console (the one with the least impact on boot speed) is enabled. In this case, some of the code in the console subsystem has no effect. Due to the way it's all genericized over multiple consoles and tied together with function pointers, not all of this can be compile-time eliminated automatically, so this patch adds a little helper to facilitate that. This results in roughly 200 (compressed) bytes of savings per stage on an arm64 system. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I1d5b8bda80d02a13ee0b7835e0805c4319fd21d8 Reviewed-on: https://review.coreboot.org/c/coreboot/+/61613 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Raul Rangel <rrangel@chromium.org>
This commit is contained in:
parent
984d03c492
commit
266041f0e6
|
@ -11,6 +11,8 @@
|
|||
#include <console/flash.h>
|
||||
#include <console/system76_ec.h>
|
||||
|
||||
/* Note: when adding a new console, make sure you update the definition of
|
||||
HAS_ONLY_FAST_CONSOLES in <console.h>! */
|
||||
void console_hw_init(void)
|
||||
{
|
||||
__cbmemc_init();
|
||||
|
|
|
@ -67,6 +67,8 @@ union log_state {
|
|||
};
|
||||
};
|
||||
|
||||
#define LOG_FAST(state) (HAS_ONLY_FAST_CONSOLES || ((state).level == CONSOLE_LOG_FAST))
|
||||
|
||||
static void wrap_interactive_printf(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
@ -83,7 +85,7 @@ static void line_start(union log_state state)
|
|||
LOG_FAST mode, just write the marker to CBMC and exit -- the rest of this function
|
||||
implements the LOG_ALL case. */
|
||||
unsigned char marker = BIOS_LOG_LEVEL_TO_MARKER(state.level);
|
||||
if (state.speed == CONSOLE_LOG_FAST) {
|
||||
if (LOG_FAST(state)) {
|
||||
__cbmemc_tx_byte(marker);
|
||||
return;
|
||||
}
|
||||
|
@ -98,7 +100,7 @@ static void line_start(union log_state state)
|
|||
|
||||
static void line_end(union log_state state)
|
||||
{
|
||||
if (CONFIG(CONSOLE_USE_ANSI_ESCAPES) && state.speed != CONSOLE_LOG_FAST)
|
||||
if (CONFIG(CONSOLE_USE_ANSI_ESCAPES) && !LOG_FAST(state))
|
||||
wrap_interactive_printf(BIOS_LOG_ESCAPE_RESET);
|
||||
}
|
||||
|
||||
|
@ -115,7 +117,7 @@ static void wrap_putchar(unsigned char byte, void *data)
|
|||
line_started = true;
|
||||
}
|
||||
|
||||
if (state.speed == CONSOLE_LOG_FAST)
|
||||
if (LOG_FAST(state))
|
||||
__cbmemc_tx_byte(byte);
|
||||
else
|
||||
console_tx_byte(byte);
|
||||
|
@ -138,7 +140,7 @@ int vprintk(int msg_level, const char *fmt, va_list args)
|
|||
console_time_run();
|
||||
|
||||
i = vtxprintf(wrap_putchar, fmt, args, state.as_ptr);
|
||||
if (state.speed != CONSOLE_LOG_FAST)
|
||||
if (LOG_FAST(state))
|
||||
console_tx_flush();
|
||||
|
||||
console_time_stop();
|
||||
|
|
|
@ -61,7 +61,18 @@ void do_putchar(unsigned char byte);
|
|||
long console_time_get_and_reset(void);
|
||||
void console_time_report(void);
|
||||
|
||||
/*
|
||||
* "Fast" basically means only the CBMEM console right now. This is used to still
|
||||
* print debug messages there when loglevel disables the other consoles. It is also
|
||||
* used to compile-time eliminate code paths that only affect "interactive" consoles
|
||||
* (which are all "slow") when none of those are enabled.
|
||||
*/
|
||||
enum { CONSOLE_LOG_NONE = 0, CONSOLE_LOG_FAST, CONSOLE_LOG_ALL };
|
||||
#define HAS_ONLY_FAST_CONSOLES !(CONFIG(SPKMODEM) || CONFIG(CONSOLE_QEMU_DEBUGCON) || \
|
||||
CONFIG(CONSOLE_SERIAL) || CONFIG(CONSOLE_NE2K) || CONFIG(CONSOLE_USB) || \
|
||||
CONFIG(EM100PRO_SPI_CONSOLE) || CONFIG(CONSOLE_SPI_FLASH) || \
|
||||
CONFIG(CONSOLE_SYSTEM76_EC))
|
||||
|
||||
#else
|
||||
static inline int get_log_level(void) { return -1; }
|
||||
static inline void console_init(void) {}
|
||||
|
|
Loading…
Reference in New Issue