From b4347f11d908e5ec9c8f810047a0acdf7b201f49 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Wed, 13 Aug 2025 09:19:10 +0530 Subject: [PATCH] include: Make DRAM an explicit region This patch makes DRAM an explicit region by introducing DECLARE_OPTIONAL_REGION(dram) and DRAM_END(). Note: many SoC platforms determine DRAM size and layout dynamically during boot, making a static compile-time value is not feasible always. Attempting to use REGION_SIZE(dram) in this scenario would result in a missing symbol `_dram_size` error. By making dram an optional region, we allow its size and address to be defined only when available, preventing build failures on platforms that configure DRAM dynamically. The old extern u8 _dram[] is removed, as it's now covered by the new region definition. This is a preparatory step for future changes that will make use of the new DRAM_END() macro. This symbol is necessary for systems that require the DRAM size to be known and accessible from the linker script or other parts of the build system. Additionally, a new macro DRAM_END(addr) is defined in memlayout.h. This macro provides a consistent way to mark the end of the DRAM region, similar to how REGION_END and other start/end macros are used throughout the codebase. TEST=Able to build and boot google/quenbi. Change-Id: Ib98ec4b991eed56385c83be6a9ca39ff1380ff1b Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/88751 Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner Reviewed-by: Kapil Porwal --- src/include/memlayout.h | 2 ++ src/include/symbols.h | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/include/memlayout.h b/src/include/memlayout.h index 6280b200eb..07addbbcde 100644 --- a/src/include/memlayout.h +++ b/src/include/memlayout.h @@ -60,6 +60,8 @@ #define SRAM_END(addr) REGION_END(sram, addr) #define DRAM_START(addr) REGION_START(dram, addr) +/* This should rarely be used because DRAM-size is usually not compile-time constant. */ +#define DRAM_END(addr) REGION_END(dram, addr) #define TIMESTAMP(addr, size) \ REGION(timestamp, addr, size, 8) \ diff --git a/src/include/symbols.h b/src/include/symbols.h index 36e4c109cf..48ff832afd 100644 --- a/src/include/symbols.h +++ b/src/include/symbols.h @@ -5,8 +5,6 @@ #include -extern u8 _dram[]; - #define REGION_SIZE(name) ((size_t)_##name##_size) #define DECLARE_REGION(name) \ @@ -28,6 +26,7 @@ extern u8 _dram[]; __maybe_unused __weak extern u8 _##name##_size[]; DECLARE_REGION(sram) +DECLARE_OPTIONAL_REGION(dram) DECLARE_OPTIONAL_REGION(timestamp) DECLARE_REGION(preram_cbmem_console) DECLARE_REGION(cbmem_init_hooks)