From 4ca5e9c8c6406e4e175896cbf4947c3ea3d52811 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Sat, 22 Nov 2025 17:08:13 +0100 Subject: [PATCH] rules.h: Add ENV_RAMSTAGE_LOADER Define ENV_RAMSTAGE_LOADER in rules.h similar to ENV_PAYLOAD_LOADER to simplify the current code and avoid code duplication when adding zstd support. Change-Id: I8c049c640b11c6f0b51e37dd2c368bb786ca9b0f Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/c/coreboot/+/90153 Reviewed-by: Matt DeVillier Reviewed-by: Julius Werner Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel --- src/include/rules.h | 8 ++++++++ src/lib/cbfs.c | 14 +++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/include/rules.h b/src/include/rules.h index 673138bfe6..053cd6bc09 100644 --- a/src/include/rules.h +++ b/src/include/rules.h @@ -267,6 +267,14 @@ #define ENV_PAYLOAD_LOADER ENV_RAMSTAGE #endif +#if CONFIG(POSTCAR_STAGE) +#define ENV_RAMSTAGE_LOADER ENV_POSTCAR +#elif CONFIG(SEPARATE_ROMSTAGE) +#define ENV_RAMSTAGE_LOADER ENV_SEPARATE_ROMSTAGE +#else +#define ENV_RAMSTAGE_LOADER ENV_BOOTBLOCK +#endif + #define ENV_ROMSTAGE_OR_BEFORE \ (ENV_DECOMPRESSOR || ENV_BOOTBLOCK || ENV_SEPARATE_ROMSTAGE || \ (ENV_SEPARATE_VERSTAGE && !CONFIG(VBOOT_STARTS_IN_ROMSTAGE))) diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c index 0c47359260..4ec65a864c 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -150,17 +150,9 @@ static inline bool cbfs_lzma_enabled(void) /* Payload loader (ramstage) always needs LZMA. */ if (ENV_PAYLOAD_LOADER) return true; - /* Only other use of LZMA is ramstage compression. */ - if (!CONFIG(COMPRESS_RAMSTAGE_LZMA)) - return false; - /* If there is a postcar, it loads the ramstage. */ - if (CONFIG(POSTCAR_STAGE)) - return ENV_POSTCAR; - /* If there is no postcar but a separate romstage, it loads the ramstage. */ - if (CONFIG(SEPARATE_ROMSTAGE)) - return ENV_SEPARATE_ROMSTAGE; - /* Otherwise, the combined bootblock+romstage loads the ramstage. */ - return ENV_BOOTBLOCK; + if (ENV_RAMSTAGE_LOADER && CONFIG(COMPRESS_RAMSTAGE_LZMA)) + return true; + return false; } static bool cbfs_file_hash_mismatch(const void *buffer, size_t size,