Aaron Durbin (adurbin@chromium.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/16619
-gerrit
commit 195323d6e4c7d60ba219703191ac0c60c97d957c Author: Aaron Durbin adurbin@chromium.org Date: Fri Sep 16 16:23:21 2016 -0500
arch/x86,lib: make cbmem console work in postcar stage
Implement postcar stage cbmem console support. The postcar stage is more like ramstage in that RAM is already up. Therefore, in order make the cbmem console reinit flow work one needs the cbmem init hook infrastructure in place and the cbmem recovery called. This call is added to x86/postcar.c to achieve that. Additionally, one needs to provide postcar stage cbmem init hook callbacks for the cbmem console library to use. A few other places needed to become postcar stage aware so that the code paths were taken. Lastly, since postcar is backed by ram indicate that to the cbmem backing store.
BUG=chrome-os-partner:57513
Change-Id: I51db65d8502c456b08f291fd1b59f6ea72059dfd Signed-off-by: Aaron Durbin adurbin@chromium.org --- src/arch/x86/postcar.c | 4 ++++ src/include/cbmem.h | 14 ++++++++++++++ src/include/console/cbmem_console.h | 2 +- src/lib/Makefile.inc | 1 + src/lib/cbmem_console.c | 3 ++- src/lib/imd_cbmem.c | 3 ++- src/lib/program.ld | 2 +- 7 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/src/arch/x86/postcar.c b/src/arch/x86/postcar.c index 8c3ea43..b6ae09a 100644 --- a/src/arch/x86/postcar.c +++ b/src/arch/x86/postcar.c @@ -13,6 +13,7 @@ * GNU General Public License for more details. */
+#include <cbmem.h> #include <console/console.h> #include <main_decl.h> #include <program_loading.h> @@ -22,6 +23,9 @@ void main(void) { console_init();
+ /* Recover cbmem so infrastruture using it is functional. */ + cbmem_initialize(); + /* Display the MTRRs */ if (IS_ENABLED(CONFIG_DISPLAY_MTRRS)) soc_display_mtrrs(); diff --git a/src/include/cbmem.h b/src/include/cbmem.h index 6a41ec7..5c4b7c71 100644 --- a/src/include/cbmem.h +++ b/src/include/cbmem.h @@ -117,17 +117,31 @@ void cbmem_add_records_to_cbtable(struct lb_header *header); #define RAMSTAGE_CBMEM_INIT_HOOK(init_fn_) \ static cbmem_init_hook_t init_fn_ ## _ptr_ __attribute__((used, \ section(".rodata.cbmem_init_hooks"))) = init_fn_; +#define POSTCAR_CBMEM_INIT_HOOK(init_fn_) static cbmem_init_hook_t \ + init_fn_ ## _unused2_ __attribute__((unused)) = init_fn_; #elif ENV_ROMSTAGE #define ROMSTAGE_CBMEM_INIT_HOOK(init_fn_) \ static cbmem_init_hook_t init_fn_ ## _ptr_ __attribute__((used, \ section(".rodata.cbmem_init_hooks"))) = init_fn_; #define RAMSTAGE_CBMEM_INIT_HOOK(init_fn_) static cbmem_init_hook_t \ init_fn_ ## _unused_ __attribute__((unused)) = init_fn_; +#define POSTCAR_CBMEM_INIT_HOOK(init_fn_) static cbmem_init_hook_t \ + init_fn_ ## _unused2_ __attribute__((unused)) = init_fn_; +#elif ENV_POSTCAR +#define ROMSTAGE_CBMEM_INIT_HOOK(init_fn_) static cbmem_init_hook_t \ + init_fn_ ## _unused2_ __attribute__((unused)) = init_fn_; +#define RAMSTAGE_CBMEM_INIT_HOOK(init_fn_) static cbmem_init_hook_t \ + init_fn_ ## _unused_ __attribute__((unused)) = init_fn_; +#define POSTCAR_CBMEM_INIT_HOOK(init_fn_) \ + static cbmem_init_hook_t init_fn_ ## _ptr_ __attribute__((used, \ + section(".rodata.cbmem_init_hooks"))) = init_fn_; #else #define ROMSTAGE_CBMEM_INIT_HOOK(init_fn_) static cbmem_init_hook_t \ init_fn_ ## _unused_ __attribute__((unused)) = init_fn_; #define RAMSTAGE_CBMEM_INIT_HOOK(init_fn_) static cbmem_init_hook_t \ init_fn_ ## _unused2_ __attribute__((unused)) = init_fn_; +#define POSTCAR_CBMEM_INIT_HOOK(init_fn_) static cbmem_init_hook_t \ + init_fn_ ## _unused3_ __attribute__((unused)) = init_fn_; #endif /* ENV_RAMSTAGE */
diff --git a/src/include/console/cbmem_console.h b/src/include/console/cbmem_console.h index e8b4d3a..de1144b 100644 --- a/src/include/console/cbmem_console.h +++ b/src/include/console/cbmem_console.h @@ -22,7 +22,7 @@ void cbmemc_init(void); void cbmemc_tx_byte(unsigned char data);
#define __CBMEM_CONSOLE_ENABLE__ CONFIG_CONSOLE_CBMEM && \ - (ENV_RAMSTAGE || ENV_VERSTAGE || \ + (ENV_RAMSTAGE || ENV_VERSTAGE || ENV_POSTCAR || \ (IS_ENABLED(CONFIG_EARLY_CBMEM_INIT) && \ (ENV_ROMSTAGE || (ENV_BOOTBLOCK && CONFIG_BOOTBLOCK_CONSOLE)))\ ) diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc index 355734a..c4b9da8 100644 --- a/src/lib/Makefile.inc +++ b/src/lib/Makefile.inc @@ -141,6 +141,7 @@ ramstage-y += imd_cbmem.c ramstage-y += imd.c
postcar-y += cbmem_common.c +postcar-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c postcar-y += imd_cbmem.c postcar-y += imd.c
diff --git a/src/lib/cbmem_console.c b/src/lib/cbmem_console.c index 49c11eb..06f34af 100644 --- a/src/lib/cbmem_console.c +++ b/src/lib/cbmem_console.c @@ -228,7 +228,7 @@ static void cbmemc_reinit(int is_recovery)
/* No appending when no preram console available and adding for * the first time. */ - if (!ENV_RAMSTAGE && _preram_cbmem_console_size == 0) + if (!ENV_RAMSTAGE && !ENV_POSTCAR && _preram_cbmem_console_size == 0) flags = CBMEMC_RESET;
/* Need to reset the newly added cbmem console in romstage. */ @@ -247,6 +247,7 @@ static void cbmemc_reinit(int is_recovery) } ROMSTAGE_CBMEM_INIT_HOOK(cbmemc_reinit) RAMSTAGE_CBMEM_INIT_HOOK(cbmemc_reinit) +POSTCAR_CBMEM_INIT_HOOK(cbmemc_reinit)
#if IS_ENABLED(CONFIG_CONSOLE_CBMEM_DUMP_TO_UART) void cbmem_dump_console(void) diff --git a/src/lib/imd_cbmem.c b/src/lib/imd_cbmem.c index d72f0b0..b0273f4 100644 --- a/src/lib/imd_cbmem.c +++ b/src/lib/imd_cbmem.c @@ -38,7 +38,8 @@ * burden on board or chipset code to tell us by returning NULL from cbmem_top() * before that point. */ -#define CAN_USE_GLOBALS (!IS_ENABLED(CONFIG_ARCH_X86) || ENV_RAMSTAGE) +#define CAN_USE_GLOBALS \ + (!IS_ENABLED(CONFIG_ARCH_X86) || ENV_RAMSTAGE || ENV_POSTCAR)
static inline struct imd *cbmem_get_imd(void) { diff --git a/src/lib/program.ld b/src/lib/program.ld index 77adb3c..4668aea 100644 --- a/src/lib/program.ld +++ b/src/lib/program.ld @@ -38,7 +38,7 @@ *(.text); *(.text.*);
-#if ENV_RAMSTAGE || ENV_ROMSTAGE +#if ENV_RAMSTAGE || ENV_ROMSTAGE || ENV_POSTCAR . = ALIGN(ARCH_POINTER_ALIGN_SIZE); _cbmem_init_hooks = .; KEEP(*(.rodata.cbmem_init_hooks));