From 579e03a13ee0ed11dfdf47493deb3a9d9ab672c4 Mon Sep 17 00:00:00 2001 From: Sean Rhodes Date: Tue, 18 Apr 2023 21:18:30 +0100 Subject: [PATCH] soc/intel/common: Don't hardcode ramtop offset The `ramtop` can be obtained from the `option.h`, so remove the hardcoded value. Keep the check for the value being byte aligned. Change-Id: I5327b5d4e78b715a85072e5d9a62cf8fd2ae92c0 Signed-off-by: Sean Rhodes Reviewed-on: https://review.coreboot.org/c/coreboot/+/74511 Reviewed-by: Nico Huber Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons Reviewed-by: Lean Sheng Tan Reviewed-by: Subrata Banik --- src/soc/intel/common/basecode/ramtop/ramtop.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/soc/intel/common/basecode/ramtop/ramtop.c b/src/soc/intel/common/basecode/ramtop/ramtop.c index 568526f44e..bf85fa8efc 100644 --- a/src/soc/intel/common/basecode/ramtop/ramtop.c +++ b/src/soc/intel/common/basecode/ramtop/ramtop.c @@ -11,8 +11,6 @@ #define RAMTOP_SIGNATURE 0x52544F50 /* 'RTOP' */ -#define RAMTOP_CMOS_OFFSET 0x64 - /* * Address of the ramtop byte in CMOS. Should be reserved * in mainboards' cmos.layout and not covered by checksum. @@ -20,13 +18,18 @@ #if CONFIG(USE_OPTION_TABLE) #include "option_table.h" -#if CMOS_VSTART_ramtop != RAMTOP_CMOS_OFFSET * 8 -#error "CMOS start for RAMTOP_CMOS is not correct, check your cmos.layout" -#endif + +#if CMOS_VSTART_ramtop % 8 != 0 +#error "The `ramtop` CMOS entry needs to be byte aligned, check your cmos.layout." +#endif // CMOS_VSTART_ramtop % 8 != 0 + #if CMOS_VLEN_ramtop != 12 #error "CMOS length for RAMTOP_CMOS bytes are not correct, check your cmos.layout" #endif -#endif + +#else +#define CMOS_VSTART_ramtop 800 +#endif // CONFIG(USE_OPTION_TABLE) struct ramtop_table { uint32_t signature; @@ -41,7 +44,7 @@ static int ramtop_cmos_read(struct ramtop_table *ramtop) u16 csum; for (p = (u8 *)ramtop, i = 0; i < sizeof(*ramtop); i++, p++) - *p = cmos_read(RAMTOP_CMOS_OFFSET + i); + *p = cmos_read((CMOS_VSTART_ramtop / 8) + i); /* Verify signature */ if (ramtop->signature != RAMTOP_SIGNATURE) { @@ -70,7 +73,7 @@ static void ramtop_cmos_write(struct ramtop_table *ramtop) ramtop, offsetof(struct ramtop_table, checksum)); for (p = (u8 *)ramtop, i = 0; i < sizeof(*ramtop); i++, p++) - cmos_write(*p, RAMTOP_CMOS_OFFSET + i); + cmos_write(*p, (CMOS_VSTART_ramtop / 8) + i); } /* Update the RAMTOP if required based on the input top_of_ram address */