treewide: Assume FMAP_SECTION_FLASH_START = 0

Now that we require the FMAP to start at offset 0 in the flash, we can
assume this across the entire codebase and therefore simplify it on
several ends.

Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com>
Change-Id: Ieb1a23f9c0ae8c0e1c91287d7eb6f7f0abbf0c2c
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86771
Reviewed-by: Erik van den Bogaert <ebogaert@eltan.com>
Reviewed-by: Frans Hendriks <fhendriks@eltan.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Shuo Liu <shuo.liu@intel.com>
This commit is contained in:
Maximilian Brune 2025-03-09 00:02:00 +01:00 committed by Matt DeVillier
commit 2efe4df522
9 changed files with 6 additions and 33 deletions

View file

@ -17,11 +17,7 @@
#define CBFS_FILE_STRUCTSIZE (CBFS_FILE_OFFSET + 4) #define CBFS_FILE_STRUCTSIZE (CBFS_FILE_OFFSET + 4)
#if FMAP_SECTION_COREBOOT_START < (0xffffffff - CONFIG_ROM_SIZE + 1)
#define COREBOOT_CBFS_START (0xffffffff - CONFIG_ROM_SIZE + 1 + FMAP_SECTION_COREBOOT_START) #define COREBOOT_CBFS_START (0xffffffff - CONFIG_ROM_SIZE + 1 + FMAP_SECTION_COREBOOT_START)
#else
#define COREBOOT_CBFS_START FMAP_SECTION_COREBOOT_START
#endif
.code32 .code32
.section .init .section .init

View file

@ -14,8 +14,7 @@ struct cbfs_header header = {
* representing the CBFS region's size is added to the offset of * representing the CBFS region's size is added to the offset of
* the region within a larger image. * the region within a larger image.
*/ */
.romsize = cpu_to_be32(FMAP_SECTION_COREBOOT_START + FMAP_SECTION_COREBOOT_SIZE .romsize = cpu_to_be32(FMAP_SECTION_COREBOOT_START + FMAP_SECTION_COREBOOT_SIZE),
- FMAP_SECTION_FLASH_START),
/* /*
* The 4 bytes are left out for two reasons: * The 4 bytes are left out for two reasons:
* 1. the cbfs master header pointer resides there * 1. the cbfs master header pointer resides there
@ -25,6 +24,6 @@ struct cbfs_header header = {
*/ */
.bootblocksize = cpu_to_be32(4), .bootblocksize = cpu_to_be32(4),
.align = cpu_to_be32(CBFS_ALIGNMENT), .align = cpu_to_be32(CBFS_ALIGNMENT),
.offset = cpu_to_be32(FMAP_SECTION_COREBOOT_START - FMAP_SECTION_FLASH_START), .offset = cpu_to_be32(FMAP_SECTION_COREBOOT_START),
.architecture = cpu_to_be32(CBFS_ARCHITECTURE_UNKNOWN), .architecture = cpu_to_be32(CBFS_ARCHITECTURE_UNKNOWN),
}; };

View file

@ -9,11 +9,7 @@
__attribute__((used, __section__(".header_pointer"))) __attribute__((used, __section__(".header_pointer")))
#endif #endif
#if FMAP_SECTION_COREBOOT_START < (0xffffffff - CONFIG_ROM_SIZE + 1)
#define COREBOOT_CBFS_START (0xffffffff - CONFIG_ROM_SIZE + 1 + FMAP_SECTION_COREBOOT_START) #define COREBOOT_CBFS_START (0xffffffff - CONFIG_ROM_SIZE + 1 + FMAP_SECTION_COREBOOT_START)
#else
#define COREBOOT_CBFS_START FMAP_SECTION_COREBOOT_START
#endif
uint32_t header_pointer = uint32_t header_pointer =
cpu_to_le32(COREBOOT_CBFS_START + ALIGN_UP(sizeof(struct cbfs_file) cpu_to_le32(COREBOOT_CBFS_START + ALIGN_UP(sizeof(struct cbfs_file)

View file

@ -45,9 +45,7 @@ $(objcbfs)/bootblock.bin: $(obj)/amdfw.rom $(obj)/fmap_config.h
amdfw_region_start=$(subst $(spc),,FMAP_SECTION_$(call regions-for-file,apu/amdfw)_START) amdfw_region_start=$(subst $(spc),,FMAP_SECTION_$(call regions-for-file,apu/amdfw)_START)
amdfw_offset=$(call int-subtract, \ amdfw_offset=$(call int-subtract, \
$(CONFIG_AMD_FWM_POSITION) \ $(CONFIG_AMD_FWM_POSITION) \
$(call int-subtract, \ $(call get_fmap_value,$(amdfw_region_start)))
$(call get_fmap_value,$(amdfw_region_start)) \
$(call get_fmap_value,FMAP_SECTION_FLASH_START)))
add_bootblock = \ add_bootblock = \
$(CBFSTOOL) $(1) add -f $(2) -n apu/amdfw -t amdfw \ $(CBFSTOOL) $(1) add -f $(2) -n apu/amdfw -t amdfw \

View file

@ -45,7 +45,6 @@ smm-y += mmap_boot.c
$(call add_intermediate, check-fmap-16mib-crossing, $(obj)/fmap_config.h) $(call add_intermediate, check-fmap-16mib-crossing, $(obj)/fmap_config.h)
fmap_get() { awk "/$$1/ { print \$$NF }" < $<; }; \ fmap_get() { awk "/$$1/ { print \$$NF }" < $<; }; \
\ \
flash_offset=$$(fmap_get FMAP_SECTION_FLASH_START); \
flash_size=$$(fmap_get FMAP_SECTION_FLASH_SIZE); \ flash_size=$$(fmap_get FMAP_SECTION_FLASH_SIZE); \
if [ $$((flash_size)) -le $$((0x1000000)) ]; then \ if [ $$((flash_size)) -le $$((0x1000000)) ]; then \
exit; \ exit; \
@ -55,7 +54,6 @@ $(call add_intermediate, check-fmap-16mib-crossing, $(obj)/fmap_config.h)
do \ do \
start=$$(fmap_get "FMAP_SECTION_$${x}_START"); \ start=$$(fmap_get "FMAP_SECTION_$${x}_START"); \
size=$$(fmap_get "FMAP_SECTION_$${x}_SIZE"); \ size=$$(fmap_get "FMAP_SECTION_$${x}_SIZE"); \
start=$$((start-flash_offset)); \
end=$$((start+size-1)); \ end=$$((start+size-1)); \
if [ $$((start)) -lt $$((bios_16M_boundary)) ] && \ if [ $$((start)) -lt $$((bios_16M_boundary)) ] && \
[ $$((end)) -ge $$((bios_16M_boundary)) ]; \ [ $$((end)) -ge $$((bios_16M_boundary)) ]; \

View file

@ -48,9 +48,9 @@ CPPFLAGS_common += -I$(src)/southbridge/amd/pi/hudson/include
# EC ROM should be 64K aligned. # EC ROM should be 64K aligned.
ifeq ($(CONFIG_AMDFW_OUTSIDE_CBFS),y) ifeq ($(CONFIG_AMDFW_OUTSIDE_CBFS),y)
HUDSON_FWM_POSITION=$(call int-add, $(call int-subtract, 0xffffffff $(CONFIG_ROM_SIZE)) 0x20000 1) HUDSON_FWM_POSITION=0x20000
else else
HUDSON_FWM_POSITION=0xfff20000 HUDSON_FWM_POSITION=0x720000
endif endif
ifeq ($(CONFIG_HUDSON_PSP), y) ifeq ($(CONFIG_HUDSON_PSP), y)

View file

@ -184,11 +184,7 @@ static void verified_boot_check_buffer(const char *name, void *start, size_t siz
} }
} }
#if FMAP_SECTION_COREBOOT_START < (0xffffffff - CONFIG_ROM_SIZE + 1)
#define COREBOOT_CBFS_START (0xffffffff - CONFIG_ROM_SIZE + 1 + FMAP_SECTION_COREBOOT_START) #define COREBOOT_CBFS_START (0xffffffff - CONFIG_ROM_SIZE + 1 + FMAP_SECTION_COREBOOT_START)
#else
#define COREBOOT_CBFS_START FMAP_SECTION_COREBOOT_START
#endif
void verified_boot_check_cbfsfile(const char *name, uint32_t type, uint32_t hash_index, void verified_boot_check_cbfsfile(const char *name, uint32_t type, uint32_t hash_index,
void **buffer, uint32_t *filesize, int32_t pcr) void **buffer, uint32_t *filesize, int32_t pcr)

View file

@ -204,7 +204,7 @@ static void test_fmap_find_region_name(void **state)
assert_int_equal(-1, fmap_find_region_name(NULL, found_area_name)); assert_int_equal(-1, fmap_find_region_name(NULL, found_area_name));
/* Try to find area outside of flash region */ /* Try to find area outside of flash region */
ar.offset = FMAP_SECTION_FLASH_START + FMAP_SECTION_FLASH_SIZE + 0x100; ar.offset = FMAP_SECTION_FLASH_SIZE + 0x100;
ar.size = 0x1000; ar.size = 0x1000;
assert_int_equal(-1, fmap_find_region_name(&ar, found_area_name)); assert_int_equal(-1, fmap_find_region_name(&ar, found_area_name));

View file

@ -639,16 +639,6 @@ int amdfwtool_getopt(int argc, char *argv[], amd_cb_config *cb_config, context *
printf(" AMDFWTOOL Using ROM size of %dKB\n", ctx->rom_size / 1024); printf(" AMDFWTOOL Using ROM size of %dKB\n", ctx->rom_size / 1024);
if (ctx->rom_size <= MAX_MAPPED_WINDOW) {
uint32_t rom_base_address;
rom_base_address = 0xFFFFFFFF - ctx->rom_size + 1;
if (cb_config->efs_location & ~MAX_MAPPED_WINDOW_MASK)
cb_config->efs_location = cb_config->efs_location - rom_base_address;
if (cb_config->body_location & ~MAX_MAPPED_WINDOW_MASK)
cb_config->body_location = cb_config->body_location - rom_base_address;
}
/* If the flash size is larger than 16M, we assume the given /* If the flash size is larger than 16M, we assume the given
addresses are already relative ones. Otherwise we print error.*/ addresses are already relative ones. Otherwise we print error.*/
if (cb_config->efs_location && cb_config->efs_location > ctx->rom_size) { if (cb_config->efs_location && cb_config->efs_location > ctx->rom_size) {