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>
This commit is contained in:
Sean Rhodes 2023-04-18 21:18:30 +01:00 committed by Lean Sheng Tan
parent 0cf2674087
commit 579e03a13e
1 changed files with 11 additions and 8 deletions

View File

@ -11,8 +11,6 @@
#define RAMTOP_SIGNATURE 0x52544F50 /* 'RTOP' */ #define RAMTOP_SIGNATURE 0x52544F50 /* 'RTOP' */
#define RAMTOP_CMOS_OFFSET 0x64
/* /*
* Address of the ramtop byte in CMOS. Should be reserved * Address of the ramtop byte in CMOS. Should be reserved
* in mainboards' cmos.layout and not covered by checksum. * in mainboards' cmos.layout and not covered by checksum.
@ -20,13 +18,18 @@
#if CONFIG(USE_OPTION_TABLE) #if CONFIG(USE_OPTION_TABLE)
#include "option_table.h" #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" #if CMOS_VSTART_ramtop % 8 != 0
#endif #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 #if CMOS_VLEN_ramtop != 12
#error "CMOS length for RAMTOP_CMOS bytes are not correct, check your cmos.layout" #error "CMOS length for RAMTOP_CMOS bytes are not correct, check your cmos.layout"
#endif #endif
#endif
#else
#define CMOS_VSTART_ramtop 800
#endif // CONFIG(USE_OPTION_TABLE)
struct ramtop_table { struct ramtop_table {
uint32_t signature; uint32_t signature;
@ -41,7 +44,7 @@ static int ramtop_cmos_read(struct ramtop_table *ramtop)
u16 csum; u16 csum;
for (p = (u8 *)ramtop, i = 0; i < sizeof(*ramtop); i++, p++) 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 */ /* Verify signature */
if (ramtop->signature != RAMTOP_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)); ramtop, offsetof(struct ramtop_table, checksum));
for (p = (u8 *)ramtop, i = 0; i < sizeof(*ramtop); i++, p++) 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 */ /* Update the RAMTOP if required based on the input top_of_ram address */