From e13c79a31e95796f1eea1f5900f0e2201d51e1f3 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Thu, 29 Jan 2026 22:41:12 +0530 Subject: [PATCH] arch/x86: Add pre- and post-memory platform hooks to romstage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce platform_romstage_pre_mem() and platform_romstage_post_mem() as weak symbols in the x86 romstage cycle. These hooks allow SoCs and mainboards to execute low-level setup or instrumentation immediately before and after memory initialization without modifying the core romstage.c flow. - platform_romstage_pre_mem: Called before mainboard_romstage_entry. - platform_romstage_post_mem: Called after memory is up but while still running on the Cache-as-RAM (CAR) stack. Change-Id: I59cb115de0d512106d9a029d683c10b025076893 Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/90999 Reviewed-by: Jérémy Compostella Reviewed-by: Pranava Y N Tested-by: build bot (Jenkins) --- src/arch/x86/include/arch/romstage.h | 13 +++++++++++++ src/cpu/intel/car/romstage.c | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/arch/x86/include/arch/romstage.h b/src/arch/x86/include/arch/romstage.h index 063d4edd6b..e0e82fd96e 100644 --- a/src/arch/x86/include/arch/romstage.h +++ b/src/arch/x86/include/arch/romstage.h @@ -7,6 +7,19 @@ #include #include +/* + * Platform-specific hooks for logic surrounding memory initialization. + * + * platform_romstage_pre_mem() is invoked before memory training. + * + * platform_romstage_post_mem() is invoked after DRAM is initialized but + * before the transition to the RAM-based stack (Post-CAR). + * + * Default: No-op. These are weak symbols to be overridden by SoC or mainboard. + */ +void platform_romstage_pre_mem(void); +void platform_romstage_post_mem(void); + void mainboard_romstage_entry(void); /* diff --git a/src/cpu/intel/car/romstage.c b/src/cpu/intel/car/romstage.c index 285c2f48b2..f0a55f14b3 100644 --- a/src/cpu/intel/car/romstage.c +++ b/src/cpu/intel/car/romstage.c @@ -16,6 +16,19 @@ following as a guideline for acceptable stack usage. */ #define DCACHE_RAM_ROMSTAGE_STACK_SIZE 0x2000 +/* + * Platform-specific hooks for logic surrounding memory initialization. + * + * platform_romstage_pre_mem() is invoked before memory training. + * + * platform_romstage_post_mem() is invoked after DRAM is initialized but + * before the transition to the RAM-based stack (Post-CAR). + * + * Default: No-op. These are weak symbols to be overridden by SoC or mainboard. + */ +__weak void platform_romstage_pre_mem(void) { /* no-op */ } +__weak void platform_romstage_post_mem(void) { /* no-op */ } + void __noreturn romstage_main(void) { int i; @@ -71,7 +84,9 @@ void __noreturn romstage_main(void) */ romstage_adainit(); + platform_romstage_pre_mem(); mainboard_romstage_entry(); + platform_romstage_post_mem(); /* Check the stack. */ for (i = 0; i < num_guards; i++) {