Martin L Roth has submitted this change. ( https://review.coreboot.org/c/coreboot/+/79904?usp=email )
Change subject: tree: Use accessor functions for struct region fields ......................................................................
tree: Use accessor functions for struct region fields
Always use the high-level API region_offset() and region_sz() functions. This excludes the internal `region.c` code as well as unit tests. FIT payload support was also skipped, as it seems it never tried to use the API and would need a bigger overhaul.
Change-Id: Iaae116a1ab2da3b2ea2a5ebcd0c300b238582834 Signed-off-by: Nico Huber nico.h@gmx.de Reviewed-on: https://review.coreboot.org/c/coreboot/+/79904 Reviewed-by: Arthur Heymans arthur@aheymans.xyz Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Felix Singer service+coreboot-gerrit@felixsinger.de --- M src/cpu/x86/smm/smm_module_loader.c M src/lib/fmap.c M util/cbfstool/bpdt_formats/bpdt_1_6.c M util/cbfstool/bpdt_formats/bpdt_1_7.c 4 files changed, 23 insertions(+), 23 deletions(-)
Approvals: build bot (Jenkins): Verified Arthur Heymans: Looks good to me, approved Felix Singer: Looks good to me, approved
diff --git a/src/cpu/x86/smm/smm_module_loader.c b/src/cpu/x86/smm/smm_module_loader.c index f827e7b..d965593 100644 --- a/src/cpu/x86/smm/smm_module_loader.c +++ b/src/cpu/x86/smm/smm_module_loader.c @@ -363,7 +363,7 @@ { unsigned int region_counter = 0; for (; region_counter < SMM_REGIONS_ARRAY_SIZE; region_counter++) - if (region_list[region_counter].size == 0) + if (region_sz(®ion_list[region_counter]) == 0) break;
if (region_counter >= SMM_REGIONS_ARRAY_SIZE) { diff --git a/src/lib/fmap.c b/src/lib/fmap.c index 8901ff7..75c5a9f 100644 --- a/src/lib/fmap.c +++ b/src/lib/fmap.c @@ -235,15 +235,15 @@ if (area == NULL) return -1;
- if ((ar->offset != le32toh(area->offset)) || - (ar->size != le32toh(area->size))) { + if (region_offset(ar) != le32toh(area->offset) || + region_sz(ar) != le32toh(area->size)) { rdev_munmap(&fmrd, area); offset += sizeof(struct fmap_area); continue; }
printk(BIOS_DEBUG, "FMAP: area (%zx, %zx) found, named %s\n", - ar->offset, ar->size, area->name); + region_offset(ar), region_sz(ar), area->name);
memcpy(name, area->name, FMAP_STRLEN);
@@ -253,7 +253,7 @@ }
printk(BIOS_DEBUG, "FMAP: area (%zx, %zx) not found\n", - ar->offset, ar->size); + region_offset(ar), region_sz(ar));
return -1; } diff --git a/util/cbfstool/bpdt_formats/bpdt_1_6.c b/util/cbfstool/bpdt_formats/bpdt_1_6.c index c5cedd3..477a58c 100644 --- a/util/cbfstool/bpdt_formats/bpdt_1_6.c +++ b/util/cbfstool/bpdt_formats/bpdt_1_6.c @@ -149,14 +149,14 @@ if (!l) return NULL;
- l->data_offset = r[DP].offset; - l->data_size = r[DP].size; - l->bp1_offset = r[BP1].offset; - l->bp1_size = r[BP1].size; - l->bp2_offset = r[BP2].offset; - l->bp2_size = r[BP2].size; - l->bp3_offset = r[BP3].offset; - l->bp3_size = r[BP3].size; + l->data_offset = region_offset(&r[DP]); + l->data_size = region_sz(&r[DP]); + l->bp1_offset = region_offset(&r[BP1]); + l->bp1_size = region_sz(&r[BP1]); + l->bp2_offset = region_offset(&r[BP2]); + l->bp2_size = region_sz(&r[BP2]); + l->bp3_offset = region_offset(&r[BP3]); + l->bp3_size = region_sz(&r[BP3]); l->checksum = 0; /* unused */
return l; diff --git a/util/cbfstool/bpdt_formats/bpdt_1_7.c b/util/cbfstool/bpdt_formats/bpdt_1_7.c index 9badc82..7e42a7b 100644 --- a/util/cbfstool/bpdt_formats/bpdt_1_7.c +++ b/util/cbfstool/bpdt_formats/bpdt_1_7.c @@ -196,16 +196,16 @@ l->size = sizeof(struct cse_layout) - sizeof(l->rom_bypass); l->redundancy = 0; l->checksum = 0; - l->data_offset = r[DP].offset; - l->data_size = r[DP].size; - l->bp1_offset = r[BP1].offset; - l->bp1_size = r[BP1].size; - l->bp2_offset = r[BP2].offset; - l->bp2_size = r[BP2].size; - l->bp3_offset = r[BP3].offset; - l->bp3_size = r[BP3].size; - l->bp4_offset = r[BP4].offset; - l->bp4_size = r[BP4].size; + l->data_offset = region_offset(&r[DP]); + l->data_size = region_sz(&r[DP]); + l->bp1_offset = region_offset(&r[BP1]); + l->bp1_size = region_sz(&r[BP1]); + l->bp2_offset = region_offset(&r[BP2]); + l->bp2_size = region_sz(&r[BP2]); + l->bp3_offset = region_offset(&r[BP3]); + l->bp3_size = region_sz(&r[BP3]); + l->bp4_offset = region_offset(&r[BP4]); + l->bp4_size = region_sz(&r[BP4]); l->bp5_offset = 0; l->bp5_size = 0; l->temp_base_addr = 0;