From 4734da172bcd68dfdb7dfff379bbc397e0e97497 Mon Sep 17 00:00:00 2001 From: Venkateshwar S Date: Tue, 17 Feb 2026 23:04:48 -0800 Subject: [PATCH] memlayout: Introduce PRERAM and POSTRAM TTB regions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactor the TTB memory region definition to support stage-specific usage. Certain boot modes require separate TTB regions for early stages (such as bootblock or romstage) and for later ramstage usage. On Bluey, the off-mode/low-battery charging path requires this separation because the boot IMEM, where the early-stage TTB resides, becomes unavailable once the ADSP comes out of reset. This change ensures that the correct TTB region is selected for each stage and prevents early‑stage memory constraints from impacting the ramstage boot flow. BUG=b:436391478 TEST=Able to build and boot google/bluey. Change-Id: I8cedab8c744220599527de1c303a777f9ff8b1da Signed-off-by: Venkateshwar S Reviewed-on: https://review.coreboot.org/c/coreboot/+/91361 Tested-by: build bot (Jenkins) Reviewed-by: Subrata Banik --- src/arch/arm64/include/arch/memlayout.h | 18 ++++++++++++++++++ src/include/symbols.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/arch/arm64/include/arch/memlayout.h b/src/arch/arm64/include/arch/memlayout.h index d84e7714fc..5c938517be 100644 --- a/src/arch/arm64/include/arch/memlayout.h +++ b/src/arch/arm64/include/arch/memlayout.h @@ -9,6 +9,24 @@ REGION(ttb, addr, size, 4K) \ _ = ASSERT(size % 4K == 0, "TTB size must be divisible by 4K!"); +#if ENV_ROMSTAGE_OR_BEFORE + #define PRERAM_TTB(addr, size) \ + REGION(preram_ttb, addr, size, 4K) \ + _ = ASSERT(size % 4K == 0, "preram_ttb size must be divisible by 4K!"); \ + ALIAS_REGION(preram_ttb, ttb) + #define POSTRAM_TTB(addr, size) \ + REGION(postram_ttb, addr, size, 4K) \ + _ = ASSERT(size >= _preram_ttb_size, "The postram_ttb size cannot be smaller than the preram_ttb size."); +#else + #define PRERAM_TTB(addr, size) \ + REGION(preram_ttb, addr, size, 4K) + #define POSTRAM_TTB(addr, size) \ + REGION(postram_ttb, addr, size, 4K) \ + _ = ASSERT(size % 4K == 0, "postram_ttb size must be divisible by 4K!"); \ + _ = ASSERT(size >= _preram_ttb_size, "The postram_ttb size cannot be smaller than the preram_ttb size."); \ + ALIAS_REGION(postram_ttb, ttb) +#endif + #define FRAMEBUFFER(addr, size) \ REGION(framebuffer, addr, size, 1M) \ _ = ASSERT(size % 1M == 0, \ diff --git a/src/include/symbols.h b/src/include/symbols.h index 53dbfb94a3..b9bde838fc 100644 --- a/src/include/symbols.h +++ b/src/include/symbols.h @@ -74,6 +74,8 @@ DECLARE_REGION(ramstage) DECLARE_REGION(pagetables) DECLARE_REGION(ttb) +DECLARE_OPTIONAL_REGION(preram_ttb) +DECLARE_OPTIONAL_REGION(postram_ttb) DECLARE_OPTIONAL_REGION(ttb_subtables) DECLARE_OPTIONAL_REGION(preram_dma_coherent) DECLARE_OPTIONAL_REGION(postram_dma_coherent)