cbfs: Replace more instances of cbfs_boot_locate() with newer APIs

In pursuit of the eventual goal of removing cbfs_boot_locate() (and
direct rdev access) from CBFS APIs, this patch replaces all remaining
"simple" uses of the function call that can easily be replaced by the
newer APIs (like cbfs_load() or cbfs_map()). Some cases of
cbfs_boot_locate() remain that will be more complicated to solve.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Change-Id: Icd0f21e2fa49c7cc834523578b7b45b5482cb1a8
Reviewed-on: https://review.coreboot.org/c/coreboot/+/50348
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Julius Werner
2021-02-05 16:51:25 -08:00
committed by Patrick Georgi
parent 81dc20e744
commit 77639e4537
12 changed files with 40 additions and 171 deletions

View File

@@ -321,42 +321,17 @@ void paging_set_default_pat(void)
paging_set_pat(pat);
}
static int read_from_cbfs(const char *name, void *buf, size_t size)
{
struct cbfsf fh;
struct region_device rdev;
size_t rdev_sz;
if (cbfs_boot_locate(&fh, name, NULL))
return -1;
cbfs_file_data(&rdev, &fh);
rdev_sz = region_device_sz(&rdev);
if (size < rdev_sz) {
printk(BIOS_ERR, "%s region too small to load: %zx < %zx\n",
name, size, rdev_sz);
return -1;
}
if (rdev_readat(&rdev, buf, 0, rdev_sz) != rdev_sz)
return -1;
return 0;
}
int paging_enable_for_car(const char *pdpt_name, const char *pt_name)
{
if (!preram_symbols_available())
return -1;
if (read_from_cbfs(pdpt_name, _pdpt, REGION_SIZE(pdpt))) {
if (!cbfs_load(pdpt_name, _pdpt, REGION_SIZE(pdpt))) {
printk(BIOS_ERR, "Couldn't load pdpt\n");
return -1;
}
if (read_from_cbfs(pt_name, _pagetables, REGION_SIZE(pagetables))) {
if (!cbfs_load(pt_name, _pagetables, REGION_SIZE(pagetables))) {
printk(BIOS_ERR, "Couldn't load page tables\n");
return -1;
}