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>
This commit is contained in:
committed by
Raul Rangel
parent
5dd7602d20
commit
ce63dc4daa
@ -62,9 +62,9 @@ static void *get_apob_dram_address(void)
|
|||||||
return apob_src_ram;
|
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");
|
printk(BIOS_ERR, "Error: No APOB NV region is found in flash\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -72,17 +72,11 @@ static int get_nv_region(struct region *r)
|
|||||||
return 0;
|
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;
|
struct apob_base_header apob_header;
|
||||||
|
|
||||||
if (boot_device_ro_subregion(region, &read_rdev) < 0) {
|
if (rdev_readat(read_rdev, &apob_header, 0, sizeof(apob_header)) < 0) {
|
||||||
printk(BIOS_ERR, "Failed boot_device_ro_subregion\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rdev_readat(&read_rdev, &apob_header, 0, sizeof(apob_header)) < 0) {
|
|
||||||
printk(BIOS_ERR, "Couldn't read APOB header!\n");
|
printk(BIOS_ERR, "Couldn't read APOB header!\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -93,15 +87,14 @@ static void *get_apob_from_nv_region(struct region *region)
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert(CONFIG(BOOT_DEVICE_MEMORY_MAPPED));
|
assert(CONFIG(BOOT_DEVICE_MEMORY_MAPPED));
|
||||||
return rdev_mmap_full(&read_rdev);
|
return rdev_mmap_full(read_rdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save APOB buffer to flash */
|
/* Save APOB buffer to flash */
|
||||||
static void soc_update_apob_cache(void *unused)
|
static void soc_update_apob_cache(void *unused)
|
||||||
{
|
{
|
||||||
struct apob_base_header *apob_rom;
|
struct apob_base_header *apob_rom;
|
||||||
struct region_device write_rdev;
|
struct region_device read_rdev, write_rdev;
|
||||||
struct region region;
|
|
||||||
bool update_needed = false;
|
bool update_needed = false;
|
||||||
const struct apob_base_header *apob_src_ram;
|
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)
|
if (apob_src_ram == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (get_nv_region(®ion) != 0)
|
if (get_nv_rdev(&read_rdev) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
timestamp_add_now(TS_AMD_APOB_READ_START);
|
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) {
|
if (apob_rom == NULL) {
|
||||||
update_needed = true;
|
update_needed = true;
|
||||||
} else if (memcmp(apob_src_ram, apob_rom, apob_src_ram->size)) {
|
} 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",
|
printk(BIOS_SPEW, "Copy APOB from RAM %p/%#x to flash %#zx/%#zx\n",
|
||||||
apob_src_ram, apob_src_ram->size,
|
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) {
|
if (fmap_locate_area_as_rdev_rw(DEFAULT_MRC_CACHE, &write_rdev) < 0) {
|
||||||
printk(BIOS_ERR, "Failed boot_device_rw_subregion\n");
|
printk(BIOS_ERR, "Error: No RW APOB NV region is found in flash\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,12 +156,12 @@ static void soc_update_apob_cache(void *unused)
|
|||||||
|
|
||||||
static void *get_apob_nv_address(void)
|
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 NULL;
|
||||||
|
|
||||||
return get_apob_from_nv_region(®ion);
|
return get_apob_from_nv_rdev(&rdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *soc_fill_apob_cache(void)
|
void *soc_fill_apob_cache(void)
|
||||||
|
Reference in New Issue
Block a user