From 6871aa315100c94cd3989aefbf17dd3285a08f1f Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 3 Apr 2014 18:50:12 -0700 Subject: [PATCH] cbmem console: Make cbmem console usable on ARM. The current CBMEM console implementation can work in two different ways, one that requires CAR migration which doesn't make sense on ARM and will break the build, and a second which assumes 0x600 is a valid memory address which can be used to keep track of the current location of the console. Neither of those work on ARM. To get around that problem, this change adds yet another flavor of behavior to the cbmem console driver where it assumes the console is in a fixed place before RAM is initialized (bootblock and ROM stage) and in CBMEM afterwards (RAM stage). More specifically, the location of the console is always fixed in a particular stage, attempts to set it are ignored, it's only initialized in the earliest stage it's enabled, and cbmem reinitialization and migration is ignored in RAM stage. We really need to rework all the twisted paths through this code and reduce it to one implementation that makes sense and works in all the situations it needs to without all the extra complexity. BUG=None TEST=Built and booted on nyan with other changes that enable the console. Ran cbmem -c and verified that output was preserved. Did the same on falco. BRANCH=None Change-Id: I05e75448be8572e2736d4d0e04997e536fb69396 Signed-off-by: Gabe Black Reviewed-on: https://chromium-review.googlesource.com/193166 Reviewed-by: Aaron Durbin Commit-Queue: Gabe Black Tested-by: Gabe Black --- src/console/Kconfig | 5 +++++ src/lib/cbmem_console.c | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/console/Kconfig b/src/console/Kconfig index 25110042b0..20812c7430 100644 --- a/src/console/Kconfig +++ b/src/console/Kconfig @@ -229,6 +229,11 @@ config CONSOLE_CBMEM Enable this to save the console output in a CBMEM buffer. This would allow to see coreboot console output from Linux space. +config CONSOLE_FIXED_PRERAM_CBMEM_BUFFER + default n if ARCH_X86 + default y if !ARCH_X86 + bool "Assume the preram CBMEM console buffer is in a fixed location" + config CONSOLE_CBMEM_BUFFER_SIZE depends on CONSOLE_CBMEM hex "Room allocated for console output in CBMEM" diff --git a/src/lib/cbmem_console.c b/src/lib/cbmem_console.c index 8d6520640e..9fd5e07dc5 100644 --- a/src/lib/cbmem_console.c +++ b/src/lib/cbmem_console.c @@ -75,7 +75,8 @@ static u8 static_console[STATIC_CONSOLE_SIZE]; static inline struct cbmem_console *current_console(void) { -#if CONFIG_CAR_MIGRATION || !defined(__PRE_RAM__) +#if CONFIG_CAR_MIGRATION || !defined(__PRE_RAM__) || \ + CONFIG_CONSOLE_FIXED_PRERAM_CBMEM_BUFFER return car_get_var(cbmem_console_p); #else /* @@ -94,7 +95,8 @@ static inline struct cbmem_console *current_console(void) static inline void current_console_set(struct cbmem_console *new_console_p) { -#if CONFIG_CAR_MIGRATION || !defined(__PRE_RAM__) +#if CONFIG_CAR_MIGRATION || !defined(__PRE_RAM__) || \ + CONFIG_CONSOLE_FIXED_PRERAM_CBMEM_BUFFER car_set_var(cbmem_console_p, new_console_p); #else CBMEM_CONSOLE_REDIRECT = new_console_p; @@ -108,7 +110,12 @@ static inline void init_console_ptr(void *storage, u32 total_space) /* Initialize the cache-as-ram pointer and underlying structure. */ car_set_var(cbmem_console_p, cbm_cons_p); cbm_cons_p->buffer_size = total_space - sizeof(struct cbmem_console); +#if !CONFIG_CONSOLE_FIXED_PRERAM_CBMEM_BUFFER || \ + ((defined __BOOT_BLOCK__ && CONFIG_BOOTBLOCK_CONSOLE) || \ + (defined __PRE_RAM__ && !defined __BOOTBLOCK__ && \ + CONFIG_EARLY_CONSOLE && !CONFIG_BOOTBLOCK_CONSOLE)) cbm_cons_p->buffer_cursor = 0; +#endif } void cbmemc_init(void)