diff options
author | Sean Rhodes <sean@starlabs.systems> | 2023-04-18 21:18:30 +0100 |
---|---|---|
committer | Lean Sheng Tan <sheng.tan@9elements.com> | 2023-05-17 09:23:26 +0000 |
commit | 579e03a13ee0ed11dfdf47493deb3a9d9ab672c4 (patch) | |
tree | 4d09dbe54e35473d40d41c12618b83940c59209c /src/soc/intel/common | |
parent | 0cf267408719a870f9d8818ed95ce2742cb689c5 (diff) |
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 <sean@starlabs.systems>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/74511
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
Reviewed-by: Subrata Banik <subratabanik@google.com>
Diffstat (limited to 'src/soc/intel/common')
-rw-r--r-- | src/soc/intel/common/basecode/ramtop/ramtop.c | 19 |
1 files 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 */ |