diff options
author | Raul E Rangel <rrangel@chromium.org> | 2021-07-16 10:37:58 -0600 |
---|---|---|
committer | Raul Rangel <rrangel@chromium.org> | 2021-07-18 15:17:05 +0000 |
commit | ce63dc4daab539b3c4b6d860145f1541854e6d3d (patch) | |
tree | d62a34ac12ba5c66c41f4241f89fc185806309f4 /src | |
parent | 5dd7602d20a647cd30db4842820fdc9f211be009 (diff) |
soc/amd/common/apob: Switch to using fmap_locate_area_as_rdev
Using fmap_locate_area is discouraged.
BUG=b:179699789
TEST=Boot guybrush and verify APOB got updated, then reboot and verify
APOB was valid.
Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Change-Id: I7f58eace8adb4b7ddaf9047d9b8153405d3941a1
Reviewed-on: https://review.coreboot.org/c/coreboot/+/56390
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/soc/amd/common/block/apob/apob_cache.c | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/src/soc/amd/common/block/apob/apob_cache.c b/src/soc/amd/common/block/apob/apob_cache.c index c41627b7ac..c2c4908a31 100644 --- a/src/soc/amd/common/block/apob/apob_cache.c +++ b/src/soc/amd/common/block/apob/apob_cache.c @@ -62,9 +62,9 @@ static void *get_apob_dram_address(void) return apob_src_ram; } -static int get_nv_region(struct region *r) +static int get_nv_rdev(struct region_device *r) { - if (fmap_locate_area(DEFAULT_MRC_CACHE, r) < 0) { + if (fmap_locate_area_as_rdev(DEFAULT_MRC_CACHE, r) < 0) { printk(BIOS_ERR, "Error: No APOB NV region is found in flash\n"); return -1; } @@ -72,17 +72,11 @@ static int get_nv_region(struct region *r) return 0; } -static void *get_apob_from_nv_region(struct region *region) +static void *get_apob_from_nv_rdev(struct region_device *read_rdev) { - struct region_device read_rdev; struct apob_base_header apob_header; - if (boot_device_ro_subregion(region, &read_rdev) < 0) { - printk(BIOS_ERR, "Failed boot_device_ro_subregion\n"); - return NULL; - } - - if (rdev_readat(&read_rdev, &apob_header, 0, sizeof(apob_header)) < 0) { + if (rdev_readat(read_rdev, &apob_header, 0, sizeof(apob_header)) < 0) { printk(BIOS_ERR, "Couldn't read APOB header!\n"); return NULL; } @@ -93,15 +87,14 @@ static void *get_apob_from_nv_region(struct region *region) } assert(CONFIG(BOOT_DEVICE_MEMORY_MAPPED)); - return rdev_mmap_full(&read_rdev); + return rdev_mmap_full(read_rdev); } /* Save APOB buffer to flash */ static void soc_update_apob_cache(void *unused) { struct apob_base_header *apob_rom; - struct region_device write_rdev; - struct region region; + struct region_device read_rdev, write_rdev; bool update_needed = false; const struct apob_base_header *apob_src_ram; @@ -113,12 +106,12 @@ static void soc_update_apob_cache(void *unused) if (apob_src_ram == NULL) return; - if (get_nv_region(®ion) != 0) + if (get_nv_rdev(&read_rdev) != 0) return; timestamp_add_now(TS_AMD_APOB_READ_START); - apob_rom = get_apob_from_nv_region(®ion); + apob_rom = get_apob_from_nv_rdev(&read_rdev); if (apob_rom == NULL) { update_needed = true; } else if (memcmp(apob_src_ram, apob_rom, apob_src_ram->size)) { @@ -134,10 +127,10 @@ static void soc_update_apob_cache(void *unused) printk(BIOS_SPEW, "Copy APOB from RAM %p/%#x to flash %#zx/%#zx\n", apob_src_ram, apob_src_ram->size, - region_offset(®ion), region_sz(®ion)); + region_device_offset(&read_rdev), region_device_sz(&read_rdev)); - if (boot_device_rw_subregion(®ion, &write_rdev) < 0) { - printk(BIOS_ERR, "Failed boot_device_rw_subregion\n"); + if (fmap_locate_area_as_rdev_rw(DEFAULT_MRC_CACHE, &write_rdev) < 0) { + printk(BIOS_ERR, "Error: No RW APOB NV region is found in flash\n"); return; } @@ -163,12 +156,12 @@ static void soc_update_apob_cache(void *unused) static void *get_apob_nv_address(void) { - struct region region; + struct region_device rdev; - if (get_nv_region(®ion) != 0) + if (get_nv_rdev(&rdev) != 0) return NULL; - return get_apob_from_nv_region(®ion); + return get_apob_from_nv_rdev(&rdev); } void *soc_fill_apob_cache(void) |