Hello Aaron Durbin,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/39304
to review the following change.
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
cbfs: Simplify load/map API names, remove type arguments
This patch renames cbfs_boot_map_with_leak() and cbfs_boot_load_file() to cbfs_map() and cbfs_load() respectively. This is supposed to be the start of a new, better organized CBFS API where the most common operations have the most simple and straight-forward names. Less commonly used variants of these operations (e.g. cbfs_ro_load() or cbfs_region_load()) can be introduced later. It seems unnecessary to keep carrying around "boot" in the names of most CBFS APIs if the vast majority of accesses go to the boot CBFS (instead, more unusual operations should have longer names that describe how they diverge from the common ones).
cbfs_map() is paired with a new cbfs_unmap() to allow callers to cleanly reap mappings when desired. A few new cbfs_unmap() calls are added to generic code where it makes sense, but it seems unnecessary to introduce this everywhere in platform or architecture specific code where the boot medium is known to be memory-mapped anyway. In fact, even for non-memory-mapped platforms, sometimes leaking a mapping to the CBFS cache is a much cleaner solution than jumping through hoops to provide some other storage for some long-lived file object, and it shouldn't be outright forbidden when it makes sense.
Additionally, remove the type arguments from these function signatures. The goal is to eventually remove type arguments for lookup from the whole CBFS API. Filenames already uniquely identify CBFS files. The type field is just informational, and there should be APIs to allow callers to check it when desired, but it's not clear what we gain from forcing this as a parameter into every single CBFS access when the vast majority of the time it provides no additional value and is just clutter.
Signed-off-by: Julius Werner jwerner@chromium.org Change-Id: Ib24325400815a9c3d25f66c61829a24a239bb88e --- M src/arch/x86/acpi.c M src/arch/x86/bootblock_normal.c M src/cpu/amd/pi/00730F01/microcode_fam16h.c M src/cpu/intel/microcode/microcode.c M src/drivers/amd/agesa/def_callouts.c M src/drivers/amd/agesa/state_machine.c M src/drivers/intel/fsp1_1/logo.c M src/drivers/intel/fsp2_0/logo.c M src/drivers/intel/gma/opregion.c M src/drivers/pc80/rtc/option.c M src/include/cbfs.h M src/lib/bootsplash.c M src/lib/cbfs.c M src/lib/coreboot_table.c M src/lib/spd_bin.c M src/mainboard/apple/macbookair4_2/early_init.c M src/mainboard/google/auron/variants/auron_paine/spd/spd.c M src/mainboard/google/auron/variants/auron_yuna/spd/spd.c M src/mainboard/google/auron/variants/buddy/variant.c M src/mainboard/google/auron/variants/gandof/spd/spd.c M src/mainboard/google/auron/variants/lulu/spd/spd.c M src/mainboard/google/auron/variants/samus/spd/spd.c M src/mainboard/google/beltino/lan.c M src/mainboard/google/butterfly/mainboard.c M src/mainboard/google/cyan/spd/spd.c M src/mainboard/google/dragonegg/romstage_fsp_params.c M src/mainboard/google/eve/spd/spd.c M src/mainboard/google/glados/spd/spd.c M src/mainboard/google/gru/sdram_configs.c M src/mainboard/google/jecht/lan.c M src/mainboard/google/kahlee/variants/baseboard/mainboard.c M src/mainboard/google/kahlee/variants/treeya/mainboard.c M src/mainboard/google/kukui/mainboard.c M src/mainboard/google/kukui/sdram_configs.c M src/mainboard/google/link/early_init.c M src/mainboard/google/poppy/romstage.c M src/mainboard/google/poppy/variants/nami/mainboard.c M src/mainboard/google/rambi/romstage.c M src/mainboard/google/rambi/variants/ninja/lan.c M src/mainboard/google/rambi/variants/sumo/lan.c M src/mainboard/google/slippy/variants/falco/romstage.c M src/mainboard/google/slippy/variants/leon/romstage.c M src/mainboard/google/slippy/variants/peppy/romstage.c M src/mainboard/google/slippy/variants/wolf/romstage.c M src/mainboard/hp/snb_ivb_laptops/variants/revolve_810_g1/early_init.c M src/mainboard/intel/harcuvar/spd/spd.c M src/mainboard/intel/kunimitsu/spd/spd_util.c M src/mainboard/lenovo/s230u/early_init.c M src/mainboard/lenovo/t430s/variants/t431s/romstage.c M src/mainboard/lenovo/x1_carbon_gen1/early_init.c M src/mainboard/samsung/lumpy/early_init.c M src/mainboard/sifive/hifive-unleashed/fixup_fdt.c M src/northbridge/intel/sandybridge/raminit_mrc.c M src/security/intel/stm/StmPlatformSmm.c M src/security/vboot/ec_sync.c M src/soc/amd/common/block/pi/def_callouts.c M src/soc/cavium/cn81xx/soc.c M src/soc/intel/baytrail/romstage/raminit.c M src/soc/intel/common/mma.c M src/soc/intel/denverton_ns/chip.c M src/soc/mediatek/mt8183/spm.c M src/soc/mediatek/mt8183/sspm.c M src/soc/qualcomm/ipq40xx/blobs_init.c M src/soc/qualcomm/ipq806x/blobs_init.c M src/soc/qualcomm/sc7180/qclib.c M src/soc/qualcomm/sdm845/qclib.c M src/vendorcode/eltan/security/mboot/mboot.c M src/vendorcode/eltan/security/verified_boot/vboot_check.c M src/vendorcode/google/chromeos/sar.c M src/vendorcode/siemens/hwilib/hwilib.c 70 files changed, 112 insertions(+), 166 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/04/39304/1
diff --git a/src/arch/x86/acpi.c b/src/arch/x86/acpi.c index b9e896f..d96edb1 100644 --- a/src/arch/x86/acpi.c +++ b/src/arch/x86/acpi.c @@ -1308,9 +1308,7 @@ return fw; }
- dsdt_file = cbfs_boot_map_with_leak( - CONFIG_CBFS_PREFIX "/dsdt.aml", - CBFS_TYPE_RAW, &dsdt_size); + dsdt_file = cbfs_map(CONFIG_CBFS_PREFIX "/dsdt.aml", &dsdt_size); if (!dsdt_file) { printk(BIOS_ERR, "No DSDT file, skipping ACPI tables\n"); return current; @@ -1323,8 +1321,7 @@ return current; }
- slic_file = cbfs_boot_map_with_leak(CONFIG_CBFS_PREFIX "/slic", - CBFS_TYPE_RAW, &slic_size); + slic_file = cbfs_map(CONFIG_CBFS_PREFIX "/slic", &slic_size); if (slic_file && (slic_file->length > slic_size || slic_file->length < sizeof(acpi_header_t) diff --git a/src/arch/x86/bootblock_normal.c b/src/arch/x86/bootblock_normal.c index b6b31af..f92237e 100644 --- a/src/arch/x86/bootblock_normal.c +++ b/src/arch/x86/bootblock_normal.c @@ -30,7 +30,7 @@ const char *boot_candidate; size_t stages_len;
- boot_candidate = cbfs_boot_map_with_leak("coreboot-stages", CBFS_TYPE_RAW, &stages_len); + boot_candidate = cbfs_map("coreboot-stages", &stages_len); if (!boot_candidate) boot_candidate = default_filenames;
diff --git a/src/cpu/amd/pi/00730F01/microcode_fam16h.c b/src/cpu/amd/pi/00730F01/microcode_fam16h.c index 1f1dbd9..88546f5 100644 --- a/src/cpu/amd/pi/00730F01/microcode_fam16h.c +++ b/src/cpu/amd/pi/00730F01/microcode_fam16h.c @@ -120,9 +120,7 @@ "Skipping microcode patch!\n"); return; } - ucode = cbfs_boot_map_with_leak("cpu_microcode_blob.bin", - CBFS_TYPE_MICROCODE, - &ucode_len); + ucode = cbfs_map("cpu_microcode_blob.bin", &ucode_len); if (!ucode) { printk(BIOS_DEBUG, "cpu_microcode_blob.bin not found. " "Skipping updates.\n"); diff --git a/src/cpu/intel/microcode/microcode.c b/src/cpu/intel/microcode/microcode.c index 90138be..ae17d71 100644 --- a/src/cpu/intel/microcode/microcode.c +++ b/src/cpu/intel/microcode/microcode.c @@ -137,9 +137,7 @@ unsigned int x86_model, x86_family; msr_t msr;
- ucode_updates = cbfs_boot_map_with_leak(MICROCODE_CBFS_FILE, - CBFS_TYPE_MICROCODE, - µcode_len); + ucode_updates = cbfs_map(MICROCODE_CBFS_FILE, µcode_len); if (ucode_updates == NULL) return NULL;
diff --git a/src/drivers/amd/agesa/def_callouts.c b/src/drivers/amd/agesa/def_callouts.c index bce90d9..e9f1689 100644 --- a/src/drivers/amd/agesa/def_callouts.c +++ b/src/drivers/amd/agesa/def_callouts.c @@ -135,9 +135,7 @@ AGESA_STATUS agesa_GfxGetVbiosImage(UINT32 Func, UINTN FchData, VOID *ConfigPrt) { GFX_VBIOS_IMAGE_INFO *pVbiosImageInfo = (GFX_VBIOS_IMAGE_INFO *)ConfigPrt; - pVbiosImageInfo->ImagePtr = cbfs_boot_map_with_leak( - "pci"CONFIG_VGA_BIOS_ID".rom", - CBFS_TYPE_OPTIONROM, NULL); + pVbiosImageInfo->ImagePtr = cbfs_map("pci"CONFIG_VGA_BIOS_ID".rom", NULL); /* printk(BIOS_DEBUG, "IMGptr=%x\n", pVbiosImageInfo->ImagePtr); */ return pVbiosImageInfo->ImagePtr == NULL ? AGESA_WARNING : AGESA_SUCCESS; } diff --git a/src/drivers/amd/agesa/state_machine.c b/src/drivers/amd/agesa/state_machine.c index 1678f84..7297ba4 100644 --- a/src/drivers/amd/agesa/state_machine.c +++ b/src/drivers/amd/agesa/state_machine.c @@ -42,8 +42,7 @@ const void *agesa, *image; size_t file_size;
- agesa = cbfs_boot_map_with_leak((const char *)CONFIG_AGESA_CBFS_NAME, - CBFS_TYPE_RAW, &file_size); + agesa = cbfs_map((const char *)CONFIG_AGESA_CBFS_NAME, &file_size); if (agesa == NULL) return;
diff --git a/src/drivers/intel/fsp1_1/logo.c b/src/drivers/intel/fsp1_1/logo.c index b00406d..5dd8202 100644 --- a/src/drivers/intel/fsp1_1/logo.c +++ b/src/drivers/intel/fsp1_1/logo.c @@ -24,8 +24,8 @@ if (logo_entry) { logo_buffer = cbmem_entry_start(logo_entry); if (logo_buffer) { - *logo_size = cbfs_boot_load_file("logo.bmp", (void *)logo_buffer, - 1 * MiB, CBFS_TYPE_RAW); + *logo_size = cbfs_load("logo.bmp", (void *)logo_buffer, + 1 * MiB); if (*logo_size) *logo_ptr = (UINT32)logo_buffer; } diff --git a/src/drivers/intel/fsp2_0/logo.c b/src/drivers/intel/fsp2_0/logo.c index 1a9152f..3c95fef 100644 --- a/src/drivers/intel/fsp2_0/logo.c +++ b/src/drivers/intel/fsp2_0/logo.c @@ -24,8 +24,8 @@ if (logo_entry) { logo_buffer = cbmem_entry_start(logo_entry); if (logo_buffer) { - *logo_size = cbfs_boot_load_file("logo.bmp", (void *)logo_buffer, - 1 * MiB, CBFS_TYPE_RAW); + *logo_size = cbfs_load("logo.bmp", (void *)logo_buffer, + 1 * MiB); if (*logo_size) *logo_ptr = (UINT32)logo_buffer; } diff --git a/src/drivers/intel/gma/opregion.c b/src/drivers/intel/gma/opregion.c index 56449d0..8cb7fcd 100644 --- a/src/drivers/intel/gma/opregion.c +++ b/src/drivers/intel/gma/opregion.c @@ -46,8 +46,7 @@
const char *filename = mainboard_vbt_filename();
- size_t file_size = cbfs_boot_load_file(filename, - vbt_data, sizeof(vbt_data), CBFS_TYPE_RAW); + size_t file_size = cbfs_load(filename, vbt_data, sizeof(vbt_data));
if (file_size == 0) return NULL; diff --git a/src/drivers/pc80/rtc/option.c b/src/drivers/pc80/rtc/option.c index bb697df..4789b15 100644 --- a/src/drivers/pc80/rtc/option.c +++ b/src/drivers/pc80/rtc/option.c @@ -244,9 +244,7 @@ size_t length = 128; size_t i;
- const unsigned char *cmos_default = - cbfs_boot_map_with_leak("cmos.default", - CBFS_COMPONENT_CMOS_DEFAULT, &length); + const unsigned char *cmos_default = cbfs_map("cmos.default", &length); if (!cmos_default) return;
diff --git a/src/include/cbfs.h b/src/include/cbfs.h index 82c92d7..cc61b16 100644 --- a/src/include/cbfs.h +++ b/src/include/cbfs.h @@ -31,19 +31,22 @@ void *cbfs_boot_load_stage_by_name(const char *name); /* Locate file by name and optional type. Return 0 on success. < 0 on error. */ int cbfs_boot_locate(struct cbfsf *fh, const char *name, uint32_t *type); -/* Map file into memory leaking the mapping. Only should be used when - * leaking mappings are a no-op. Returns NULL on error, else returns - * the mapping and sets the size of the file. */ -void *cbfs_boot_map_with_leak(const char *name, uint32_t type, size_t *size); +/* Map file into memory, returning a pointer to the mapping or NULL on error. + If |size| is not NULL, it will pass out the size of the mapped file. + NOTE: Since this may return a direct pointer to memory-mapped hardware, + compressed files are NOT transparently decompressed (unlike cbfs_load()). */ +void *cbfs_map(const char *name, size_t *size); +/* Removes a mapping previously allocated with cbfs_map(). Should try to unmap + mappings in strict LIFO order where possible, since mapping backends often + don't support more complicated cases. */ +int cbfs_unmap(void *mapping); /* Locate file in a specific region of fmap. Return 0 on success. < 0 on error*/ int cbfs_locate_file_in_region(struct cbfsf *fh, const char *region_name, const char *name, uint32_t *type); -/* Load an arbitrary type file from CBFS into a buffer. Returns amount of - * loaded bytes on success or 0 on error. File will get decompressed as - * necessary. Same decompression requirements as - * cbfs_load_and_decompress(). */ -size_t cbfs_boot_load_file(const char *name, void *buf, size_t buf_size, - uint32_t type); +/* Load a file from CBFS into a buffer. Returns amount of loaded bytes on + success or 0 on error. File will get decompressed as necessary. Same + decompression requirements as cbfs_load_and_decompress(). */ +size_t cbfs_load(const char *name, void *buf, size_t buf_size); /* Load |in_size| bytes from |rdev| at |offset| to the |buffer_size| bytes * large |buffer|, decompressing it according to |compression| in the process. * Returns the decompressed file size, or 0 on error. diff --git a/src/lib/bootsplash.c b/src/lib/bootsplash.c index 8364afa..3f96907 100644 --- a/src/lib/bootsplash.c +++ b/src/lib/bootsplash.c @@ -29,8 +29,7 @@ printk(BIOS_INFO, "Setting up bootsplash in %dx%d@%d\n", x_resolution, y_resolution, fb_resolution); struct jpeg_decdata *decdata; - unsigned char *jpeg = - cbfs_boot_map_with_leak("bootsplash.jpg", CBFS_TYPE_BOOTSPLASH, NULL); + unsigned char *jpeg = cbfs_map("bootsplash.jpg", NULL); if (!jpeg) { printk(BIOS_ERR, "Could not find bootsplash.jpg\n"); return; @@ -44,6 +43,7 @@ decdata = malloc(sizeof(*decdata)); int ret = jpeg_decode(jpeg, framebuffer, x_resolution, y_resolution, fb_resolution, decdata); + cbfs_unmap(jpeg); if (ret != 0) { printk(BIOS_ERR, "Bootsplash could not be decoded. jpeg_decode returned %d.\n", ret); diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c index 39db97a..bece4d0 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -79,12 +79,12 @@ return 0; }
-void *cbfs_boot_map_with_leak(const char *name, uint32_t type, size_t *size) +void *cbfs_map(const char *name, size_t *size) { struct cbfsf fh; size_t fsize;
- if (cbfs_boot_locate(&fh, name, &type)) + if (cbfs_boot_locate(&fh, name, NULL)) return NULL;
fsize = region_device_sz(&fh.data); @@ -95,6 +95,13 @@ return rdev_mmap(&fh.data, 0, fsize); }
+int cbfs_unmap(void *mapping) +{ + /* This works because munmap() only works on the root rdev and never + cares about which chained subregion something was mapped from. */ + return rdev_munmap(boot_device_ro(), mapping); +} + int cbfs_locate_file_in_region(struct cbfsf *fh, const char *region_name, const char *name, uint32_t *type) { @@ -187,16 +194,15 @@ tohex16(vendor, name + 3); tohex16(device, name + 8);
- return cbfs_boot_map_with_leak(name, CBFS_TYPE_OPTIONROM, NULL); + return cbfs_map(name, NULL); }
void *cbfs_boot_load_stage_by_name(const char *name) { struct cbfsf fh; struct prog stage = PROG_INIT(PROG_UNKNOWN, name); - uint32_t type = CBFS_TYPE_STAGE;
- if (cbfs_boot_locate(&fh, name, &type)) + if (cbfs_boot_locate(&fh, name, NULL)) return NULL;
/* Chain data portion in the prog. */ @@ -208,14 +214,13 @@ return prog_entry(&stage); }
-size_t cbfs_boot_load_file(const char *name, void *buf, size_t buf_size, - uint32_t type) +size_t cbfs_load(const char *name, void *buf, size_t buf_size) { struct cbfsf fh; uint32_t compression_algo; size_t decompressed_size;
- if (cbfs_boot_locate(&fh, name, &type) < 0) + if (cbfs_boot_locate(&fh, name, NULL) < 0) return 0;
if (cbfsf_decompression_info(&fh, &compression_algo, diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c index 91e0247..78ecb5a 100644 --- a/src/lib/coreboot_table.c +++ b/src/lib/coreboot_table.c @@ -494,8 +494,7 @@ #if CONFIG(USE_OPTION_TABLE) { struct cmos_option_table *option_table = - cbfs_boot_map_with_leak("cmos_layout.bin", - CBFS_COMPONENT_CMOS_LAYOUT, NULL); + cbfs_map("cmos_layout.bin", NULL); if (option_table) { struct lb_record *rec_dest = lb_new_record(head); /* Copy the option config table, it's already a diff --git a/src/lib/spd_bin.c b/src/lib/spd_bin.c index 9e625b5..41588d7 100644 --- a/src/lib/spd_bin.c +++ b/src/lib/spd_bin.c @@ -209,8 +209,7 @@ size_t spd_file_len = 0; size_t min_len = (idx + 1) * CONFIG_DIMM_SPD_SIZE;
- spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) printk(BIOS_EMERG, "file [spd.bin] not found in CBFS"); if (spd_file_len < min_len) @@ -220,6 +219,7 @@
memcpy(buf, spd_file + (idx * CONFIG_DIMM_SPD_SIZE), CONFIG_DIMM_SPD_SIZE); + cbfs_unmap(spd_file);
u16 crc = spd_ddr3_calc_crc(buf, CONFIG_DIMM_SPD_SIZE);
diff --git a/src/mainboard/apple/macbookair4_2/early_init.c b/src/mainboard/apple/macbookair4_2/early_init.c index 29a2977..69e26f0 100644 --- a/src/mainboard/apple/macbookair4_2/early_init.c +++ b/src/mainboard/apple/macbookair4_2/early_init.c @@ -39,8 +39,7 @@ { void *spd_file; size_t spd_file_len = 0; - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (spd_file && spd_file_len >= 1024) { int i; for (i = 0; i < 4; i++) diff --git a/src/mainboard/google/auron/variants/auron_paine/spd/spd.c b/src/mainboard/google/auron/variants/auron_paine/spd/spd.c index 2991d15..f08e0a4 100644 --- a/src/mainboard/google/auron/variants/auron_paine/spd/spd.c +++ b/src/mainboard/google/auron/variants/auron_paine/spd/spd.c @@ -101,7 +101,7 @@ spd_bits[1], spd_gpio[1], spd_bits[0], spd_gpio[0]);
- spd_file = cbfs_boot_map_with_leak("spd.bin", 0xab, &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/auron/variants/auron_yuna/spd/spd.c b/src/mainboard/google/auron/variants/auron_yuna/spd/spd.c index 2991d15..f08e0a4 100644 --- a/src/mainboard/google/auron/variants/auron_yuna/spd/spd.c +++ b/src/mainboard/google/auron/variants/auron_yuna/spd/spd.c @@ -101,7 +101,7 @@ spd_bits[1], spd_gpio[1], spd_bits[0], spd_gpio[0]);
- spd_file = cbfs_boot_map_with_leak("spd.bin", 0xab, &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/auron/variants/buddy/variant.c b/src/mainboard/google/auron/variants/buddy/variant.c index 4e05711..31f4cc1 100644 --- a/src/mainboard/google/auron/variants/buddy/variant.c +++ b/src/mainboard/google/auron/variants/buddy/variant.c @@ -140,9 +140,7 @@ search_length = region_device_sz(&rdev); } } else { - search_address = cbfs_boot_map_with_leak("vpd.bin", - CBFS_TYPE_RAW, - &search_length); + search_address = cbfs_map("vpd.bin", &search_length); }
if (search_address == NULL) diff --git a/src/mainboard/google/auron/variants/gandof/spd/spd.c b/src/mainboard/google/auron/variants/gandof/spd/spd.c index 2991d15..f08e0a4 100644 --- a/src/mainboard/google/auron/variants/gandof/spd/spd.c +++ b/src/mainboard/google/auron/variants/gandof/spd/spd.c @@ -101,7 +101,7 @@ spd_bits[1], spd_gpio[1], spd_bits[0], spd_gpio[0]);
- spd_file = cbfs_boot_map_with_leak("spd.bin", 0xab, &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/auron/variants/lulu/spd/spd.c b/src/mainboard/google/auron/variants/lulu/spd/spd.c index bd76947..94f9346 100644 --- a/src/mainboard/google/auron/variants/lulu/spd/spd.c +++ b/src/mainboard/google/auron/variants/lulu/spd/spd.c @@ -106,7 +106,7 @@ spd_bits[1], spd_gpio[1], spd_bits[0], spd_gpio[0]);
- spd_file = cbfs_boot_map_with_leak("spd.bin", 0xab, &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/auron/variants/samus/spd/spd.c b/src/mainboard/google/auron/variants/samus/spd/spd.c index ffb90f9..6ff6d77 100644 --- a/src/mainboard/google/auron/variants/samus/spd/spd.c +++ b/src/mainboard/google/auron/variants/samus/spd/spd.c @@ -101,7 +101,7 @@ spd_bits[3], spd_gpio[3], spd_bits[2], spd_gpio[2], spd_bits[1], spd_gpio[1], spd_bits[0], spd_gpio[0]);
- spd_file = cbfs_boot_map_with_leak("spd.bin", 0xab, &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/beltino/lan.c b/src/mainboard/google/beltino/lan.c index 1c38e45..8e8b44d 100644 --- a/src/mainboard/google/beltino/lan.c +++ b/src/mainboard/google/beltino/lan.c @@ -123,9 +123,7 @@ search_length = region_device_sz(&rdev); } } else { - search_address = cbfs_boot_map_with_leak("vpd.bin", - CBFS_TYPE_RAW, - &search_length); + search_address = cbfs_map("vpd.bin", &search_length); }
if (search_address == NULL) diff --git a/src/mainboard/google/butterfly/mainboard.c b/src/mainboard/google/butterfly/mainboard.c index eb4d15b..9bbb700 100644 --- a/src/mainboard/google/butterfly/mainboard.c +++ b/src/mainboard/google/butterfly/mainboard.c @@ -195,8 +195,7 @@ } } } else { - vpd_file = cbfs_boot_map_with_leak("vpd.bin", CBFS_TYPE_RAW, - &search_length); + vpd_file = cbfs_map("vpd.bin", &search_length); if (vpd_file) { search_address = (unsigned long)vpd_file; } else { diff --git a/src/mainboard/google/cyan/spd/spd.c b/src/mainboard/google/cyan/spd/spd.c index 8dd4366..e08234a 100644 --- a/src/mainboard/google/cyan/spd/spd.c +++ b/src/mainboard/google/cyan/spd/spd.c @@ -49,8 +49,7 @@ int spd_index = 0;
/* Find the SPD data in CBFS. */ - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/dragonegg/romstage_fsp_params.c b/src/mainboard/google/dragonegg/romstage_fsp_params.c index f1f5143..e6573ad 100644 --- a/src/mainboard/google/dragonegg/romstage_fsp_params.c +++ b/src/mainboard/google/dragonegg/romstage_fsp_params.c @@ -32,8 +32,7 @@ printk(BIOS_INFO, "SPD index %d\n", spd_index);
/* Load SPD data from CBFS */ - spd_file = cbfs_boot_map_with_leak(spd_bin, CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map(spd_bin, &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/eve/spd/spd.c b/src/mainboard/google/eve/spd/spd.c index fca670c..a03d077 100644 --- a/src/mainboard/google/eve/spd/spd.c +++ b/src/mainboard/google/eve/spd/spd.c @@ -96,8 +96,7 @@ printk(BIOS_INFO, "SPD index %d\n", spd_index);
/* Load SPD data from CBFS */ - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/glados/spd/spd.c b/src/mainboard/google/glados/spd/spd.c index 324d3be..68d840d 100644 --- a/src/mainboard/google/glados/spd/spd.c +++ b/src/mainboard/google/glados/spd/spd.c @@ -93,8 +93,7 @@ printk(BIOS_INFO, "SPD index %d\n", spd_index);
/* Load SPD data from CBFS */ - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/gru/sdram_configs.c b/src/mainboard/google/gru/sdram_configs.c index 5e9e15f..25719bc 100644 --- a/src/mainboard/google/gru/sdram_configs.c +++ b/src/mainboard/google/gru/sdram_configs.c @@ -66,8 +66,7 @@ if (ramcode >= ARRAY_SIZE(sdram_configs) || !snprintf(config_file, sizeof(config_file), "%s-%d", sdram_configs[ramcode], get_sdram_target_mhz()) || - (cbfs_boot_load_file(config_file, ¶ms, sizeof(params), - CBFS_TYPE_STRUCT) != sizeof(params))) + (cbfs_load(config_file, ¶ms, sizeof(params)) != sizeof(params))) die("Cannot load SDRAM parameter file!");
return ¶ms; diff --git a/src/mainboard/google/jecht/lan.c b/src/mainboard/google/jecht/lan.c index bd08b09..fde59a7 100644 --- a/src/mainboard/google/jecht/lan.c +++ b/src/mainboard/google/jecht/lan.c @@ -123,9 +123,7 @@ search_length = region_device_sz(&rdev); } } else { - search_address = cbfs_boot_map_with_leak("vpd.bin", - CBFS_TYPE_RAW, - &search_length); + search_address = cbfs_map("vpd.bin", &search_length); }
if (search_address == NULL) diff --git a/src/mainboard/google/kahlee/variants/baseboard/mainboard.c b/src/mainboard/google/kahlee/variants/baseboard/mainboard.c index 69b9b40..2bada6e 100644 --- a/src/mainboard/google/kahlee/variants/baseboard/mainboard.c +++ b/src/mainboard/google/kahlee/variants/baseboard/mainboard.c @@ -103,9 +103,7 @@ if (manuf) return manuf;
- if (cbfs_boot_load_file("oem.bin", oem_bin_data, - sizeof(oem_bin_data) - 1, - CBFS_TYPE_RAW)) + if (cbfs_load("oem.bin", oem_bin_data, sizeof(oem_bin_data) - 1)) manuf = &oem_bin_data[0]; else manuf = CONFIG_MAINBOARD_SMBIOS_MANUFACTURER; diff --git a/src/mainboard/google/kahlee/variants/treeya/mainboard.c b/src/mainboard/google/kahlee/variants/treeya/mainboard.c index cd42b56..9639977 100644 --- a/src/mainboard/google/kahlee/variants/treeya/mainboard.c +++ b/src/mainboard/google/kahlee/variants/treeya/mainboard.c @@ -115,9 +115,7 @@ if (manuf) return manuf;
- if (cbfs_boot_load_file("oem.bin", oem_bin_data, - sizeof(oem_bin_data) - 1, - CBFS_TYPE_RAW)) + if (cbfs_load("oem.bin", oem_bin_data, sizeof(oem_bin_data) - 1)) manuf = &oem_bin_data[0]; else manuf = CONFIG_MAINBOARD_SMBIOS_MANUFACTURER; diff --git a/src/mainboard/google/kukui/mainboard.c b/src/mainboard/google/kukui/mainboard.c index 844496d..c64bc98 100644 --- a/src/mainboard/google/kukui/mainboard.c +++ b/src/mainboard/google/kukui/mainboard.c @@ -117,8 +117,7 @@ return NULL;
snprintf(cbfs_name, sizeof(cbfs_name), "panel-%s", desc->name); - if (cbfs_boot_load_file(cbfs_name, buffer.raw, sizeof(buffer), - CBFS_TYPE_STRUCT)) + if (cbfs_load(cbfs_name, buffer.raw, sizeof(buffer))) desc->s = &buffer.s; else printk(BIOS_ERR, "Missing %s in CBFS.\n", cbfs_name); diff --git a/src/mainboard/google/kukui/sdram_configs.c b/src/mainboard/google/kukui/sdram_configs.c index b6277ea..8ce455d 100644 --- a/src/mainboard/google/kukui/sdram_configs.c +++ b/src/mainboard/google/kukui/sdram_configs.c @@ -36,8 +36,8 @@ uint32_t ramcode = ram_code();
if (ramcode >= ARRAY_SIZE(sdram_configs) || - cbfs_boot_load_file(sdram_configs[ramcode], ¶ms, sizeof(params), - CBFS_TYPE_STRUCT) != sizeof(params)) + cbfs_load(sdram_configs[ramcode], ¶ms, sizeof(params)) + != sizeof(params)) die("Cannot load SDRAM parameter file!");
return ¶ms; diff --git a/src/mainboard/google/link/early_init.c b/src/mainboard/google/link/early_init.c index 7d1c177..5fd56cf 100644 --- a/src/mainboard/google/link/early_init.c +++ b/src/mainboard/google/link/early_init.c @@ -81,8 +81,7 @@ int spd_index = get_gpios(gpio_vector);
printk(BIOS_DEBUG, "spd index %d\n", spd_index); - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/poppy/romstage.c b/src/mainboard/google/poppy/romstage.c index 9de1602..08d21f6 100644 --- a/src/mainboard/google/poppy/romstage.c +++ b/src/mainboard/google/poppy/romstage.c @@ -125,8 +125,7 @@ printk(BIOS_INFO, "SPD index %d\n", spd_index);
/* Load SPD data from CBFS */ - spd_file = cbfs_boot_map_with_leak(spd_bin, CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map(spd_bin, &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/poppy/variants/nami/mainboard.c b/src/mainboard/google/poppy/variants/nami/mainboard.c index 6d54e17..71cade7 100644 --- a/src/mainboard/google/poppy/variants/nami/mainboard.c +++ b/src/mainboard/google/poppy/variants/nami/mainboard.c @@ -167,9 +167,8 @@ if (oem_id == OEM_UNKNOWN) return CONFIG_MAINBOARD_SMBIOS_MANUFACTURER;
- oem_data_size = cbfs_boot_load_file("oem.bin", oem_bin_data, - sizeof(oem_bin_data), - CBFS_TYPE_RAW); + oem_data_size = cbfs_load("oem.bin", oem_bin_data, + sizeof(oem_bin_data));
while ((curr < oem_data_size) && ((oem_data_size - curr) >= sizeof(*oem_entry))) { diff --git a/src/mainboard/google/rambi/romstage.c b/src/mainboard/google/rambi/romstage.c index f74d77d..542d996 100644 --- a/src/mainboard/google/rambi/romstage.c +++ b/src/mainboard/google/rambi/romstage.c @@ -62,8 +62,7 @@ void *spd_file; size_t spd_fsize;
- spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_fsize); + spd_file = cbfs_map("spd.bin", &spd_fsize); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/rambi/variants/ninja/lan.c b/src/mainboard/google/rambi/variants/ninja/lan.c index 5b220e0..bd22fe9 100644 --- a/src/mainboard/google/rambi/variants/ninja/lan.c +++ b/src/mainboard/google/rambi/variants/ninja/lan.c @@ -122,9 +122,7 @@ search_length = region_device_sz(&rdev); } } else { - search_address = cbfs_boot_map_with_leak("vpd.bin", - CBFS_TYPE_RAW, - &search_length); + search_address = cbfs_map("vpd.bin", &search_length); }
if (search_address == NULL) diff --git a/src/mainboard/google/rambi/variants/sumo/lan.c b/src/mainboard/google/rambi/variants/sumo/lan.c index d6cd580..27e5c9f 100644 --- a/src/mainboard/google/rambi/variants/sumo/lan.c +++ b/src/mainboard/google/rambi/variants/sumo/lan.c @@ -122,9 +122,7 @@ search_length = region_device_sz(&rdev); } } else { - search_address = cbfs_boot_map_with_leak("vpd.bin", - CBFS_TYPE_RAW, - &search_length); + search_address = cbfs_map("vpd.bin", &search_length); }
if (search_address == NULL) diff --git a/src/mainboard/google/slippy/variants/falco/romstage.c b/src/mainboard/google/slippy/variants/falco/romstage.c index c193d20..11e1d59 100644 --- a/src/mainboard/google/slippy/variants/falco/romstage.c +++ b/src/mainboard/google/slippy/variants/falco/romstage.c @@ -77,8 +77,7 @@ size_t spd_len = sizeof(peid->spd_data[0]);
printk(BIOS_DEBUG, "SPD index %d\n", spd_index); - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/slippy/variants/leon/romstage.c b/src/mainboard/google/slippy/variants/leon/romstage.c index 9e9cf73..5ea13f4 100644 --- a/src/mainboard/google/slippy/variants/leon/romstage.c +++ b/src/mainboard/google/slippy/variants/leon/romstage.c @@ -76,8 +76,7 @@ size_t spd_len = sizeof(peid->spd_data[0]);
printk(BIOS_DEBUG, "SPD index %d\n", spd_index); - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/slippy/variants/peppy/romstage.c b/src/mainboard/google/slippy/variants/peppy/romstage.c index 8adf4b2..c67ffef 100644 --- a/src/mainboard/google/slippy/variants/peppy/romstage.c +++ b/src/mainboard/google/slippy/variants/peppy/romstage.c @@ -79,8 +79,7 @@ uint32_t board_version = PEPPY_BOARD_VERSION_PROTO;
printk(BIOS_DEBUG, "SPD index %d\n", spd_index); - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/slippy/variants/wolf/romstage.c b/src/mainboard/google/slippy/variants/wolf/romstage.c index 651d8b1..cdc8f90 100644 --- a/src/mainboard/google/slippy/variants/wolf/romstage.c +++ b/src/mainboard/google/slippy/variants/wolf/romstage.c @@ -77,8 +77,7 @@ size_t spd_len = sizeof(peid->spd_data[0]);
printk(BIOS_DEBUG, "SPD index %d\n", spd_index); - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/hp/snb_ivb_laptops/variants/revolve_810_g1/early_init.c b/src/mainboard/hp/snb_ivb_laptops/variants/revolve_810_g1/early_init.c index 29be074..9ef3174 100644 --- a/src/mainboard/hp/snb_ivb_laptops/variants/revolve_810_g1/early_init.c +++ b/src/mainboard/hp/snb_ivb_laptops/variants/revolve_810_g1/early_init.c @@ -55,8 +55,7 @@ { /* C1S0 is a soldered RAM with no real SPD. Use stored SPD. */ size_t spd_file_len = 0; - void *spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + void *spd_file = cbfs_map("spd.bin", &spd_file_len);
if (!spd_file || spd_file_len < sizeof(spd_raw_data)) die("SPD data for C1S0 not found."); diff --git a/src/mainboard/intel/harcuvar/spd/spd.c b/src/mainboard/intel/harcuvar/spd/spd.c index 61bf2e5..75a95c4 100644 --- a/src/mainboard/intel/harcuvar/spd/spd.c +++ b/src/mainboard/intel/harcuvar/spd/spd.c @@ -30,8 +30,7 @@
spd_index = 0;
- spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/intel/kunimitsu/spd/spd_util.c b/src/mainboard/intel/kunimitsu/spd/spd_util.c index 2fe4596..bab5f53 100644 --- a/src/mainboard/intel/kunimitsu/spd/spd_util.c +++ b/src/mainboard/intel/kunimitsu/spd/spd_util.c @@ -82,8 +82,7 @@ printk(BIOS_INFO, "SPD index %d\n", spd_index);
/* Load SPD data from CBFS */ - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/lenovo/s230u/early_init.c b/src/mainboard/lenovo/s230u/early_init.c index a0fc2ec..5222f99 100644 --- a/src/mainboard/lenovo/s230u/early_init.c +++ b/src/mainboard/lenovo/s230u/early_init.c @@ -84,8 +84,7 @@ spd_index, mainboard_spd_names[spd_index]);
/* C0S0 is a soldered RAM with no real SPD. Use stored SPD. */ - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len);
if (!spd_file || spd_file_len < SPD_LEN * spd_index + SPD_LEN) die("SPD data not found."); diff --git a/src/mainboard/lenovo/t430s/variants/t431s/romstage.c b/src/mainboard/lenovo/t430s/variants/t431s/romstage.c index 7da2c55..2db7fc6 100644 --- a/src/mainboard/lenovo/t430s/variants/t431s/romstage.c +++ b/src/mainboard/lenovo/t430s/variants/t431s/romstage.c @@ -44,8 +44,7 @@ { /* C1S0 is a soldered RAM with no real SPD. Use stored SPD. */ size_t spd_file_len = 0; - void *spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + void *spd_file = cbfs_map("spd.bin", &spd_file_len);
if (!spd_file || spd_file_len < sizeof(spd_raw_data)) die("SPD data for C1S0 not found."); diff --git a/src/mainboard/lenovo/x1_carbon_gen1/early_init.c b/src/mainboard/lenovo/x1_carbon_gen1/early_init.c index 859148a..a56d024 100644 --- a/src/mainboard/lenovo/x1_carbon_gen1/early_init.c +++ b/src/mainboard/lenovo/x1_carbon_gen1/early_init.c @@ -50,8 +50,7 @@ size_t spd_file_len;
printk(BIOS_DEBUG, "spd index %d\n", spd_index); - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/samsung/lumpy/early_init.c b/src/mainboard/samsung/lumpy/early_init.c index 0249c3b..add76b5 100644 --- a/src/mainboard/samsung/lumpy/early_init.c +++ b/src/mainboard/samsung/lumpy/early_init.c @@ -119,8 +119,7 @@ break; }
- spd_data = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_data = cbfs_map("spd.bin", &spd_file_len); if (!spd_data) die("SPD data not found."); if (spd_file_len < (spd_index + 1) * 256) diff --git a/src/mainboard/sifive/hifive-unleashed/fixup_fdt.c b/src/mainboard/sifive/hifive-unleashed/fixup_fdt.c index 3d43181..6ef7c1c 100644 --- a/src/mainboard/sifive/hifive-unleashed/fixup_fdt.c +++ b/src/mainboard/sifive/hifive-unleashed/fixup_fdt.c @@ -86,7 +86,7 @@ struct device_tree *tree;
/* load flat dt from cbfs */ - fdt_rom = cbfs_boot_map_with_leak("fallback/DTB", CBFS_TYPE_RAW, NULL); + fdt_rom = cbfs_map("fallback/DTB", NULL);
if (fdt_rom == NULL) { printk(BIOS_ERR, "Unable to load fallback/DTB from CBFS\n"); diff --git a/src/northbridge/intel/sandybridge/raminit_mrc.c b/src/northbridge/intel/sandybridge/raminit_mrc.c index 8daa9aa..a0753aa 100644 --- a/src/northbridge/intel/sandybridge/raminit_mrc.c +++ b/src/northbridge/intel/sandybridge/raminit_mrc.c @@ -220,7 +220,7 @@ pei_data->tx_byte = do_putchar;
/* Locate and call UEFI System Agent binary. */ - entry = cbfs_boot_map_with_leak("mrc.bin", CBFS_TYPE_MRC, NULL); + entry = cbfs_map("mrc.bin", NULL); if (entry) { int rv; rv = entry (pei_data); diff --git a/src/security/intel/stm/StmPlatformSmm.c b/src/security/intel/stm/StmPlatformSmm.c index 45db0e0..6eae9b0 100644 --- a/src/security/intel/stm/StmPlatformSmm.c +++ b/src/security/intel/stm/StmPlatformSmm.c @@ -49,8 +49,7 @@
memset((void *)mseg_base, 0, CONFIG_MSEG_SIZE); // clear the mseg
- stm_image_size = cbfs_boot_load_file("stm.bin", mseg_base, - stm_buffer_size, CBFS_TYPE_RAW); + stm_image_size = cbfs_load("stm.bin", mseg_base, stm_buffer_size); printk(BIOS_DEBUG, "STM:loaded into mseg: 0x%p size: %u\n", mseg_base, stm_image_size); /* status is number of bytes loaded */ diff --git a/src/security/vboot/ec_sync.c b/src/security/vboot/ec_sync.c index e7b64b2..3d14e14 100644 --- a/src/security/vboot/ec_sync.c +++ b/src/security/vboot/ec_sync.c @@ -397,7 +397,7 @@ { size_t size; const char *filename = EC_HASH_FILENAME(select); - const uint8_t *file = cbfs_boot_map_with_leak(filename, CBFS_TYPE_RAW, &size); + const uint8_t *file = cbfs_map(filename, &size);
if (file == NULL) return VB2_ERROR_UNKNOWN; diff --git a/src/soc/amd/common/block/pi/def_callouts.c b/src/soc/amd/common/block/pi/def_callouts.c index facd5f8..b671b55 100644 --- a/src/soc/amd/common/block/pi/def_callouts.c +++ b/src/soc/amd/common/block/pi/def_callouts.c @@ -150,9 +150,8 @@ GFX_VBIOS_IMAGE_INFO *pVbiosImageInfo;
pVbiosImageInfo = (GFX_VBIOS_IMAGE_INFO *)ConfigPrt; - pVbiosImageInfo->ImagePtr = cbfs_boot_map_with_leak( - "pci"CONFIG_VGA_BIOS_ID".rom", - CBFS_TYPE_OPTIONROM, NULL); + pVbiosImageInfo->ImagePtr = cbfs_map( + "pci"CONFIG_VGA_BIOS_ID".rom", NULL); printk(BIOS_DEBUG, "%s: IMGptr=%p\n", __func__, pVbiosImageInfo->ImagePtr); return pVbiosImageInfo->ImagePtr ? AGESA_SUCCESS : AGESA_WARNING; diff --git a/src/soc/cavium/cn81xx/soc.c b/src/soc/cavium/cn81xx/soc.c index 8abb328..18a7b3f 100644 --- a/src/soc/cavium/cn81xx/soc.c +++ b/src/soc/cavium/cn81xx/soc.c @@ -347,8 +347,7 @@
size_t size = 0;
- void *ptr = cbfs_boot_map_with_leak("sff8104-linux.dtb", - CBFS_TYPE_RAW, &size); + void *ptr = cbfs_map("sff8104-linux.dtb", &size); if (ptr) memcpy(_sff8104, ptr, size); /* Point to devicetree in secure memory */ diff --git a/src/soc/intel/baytrail/romstage/raminit.c b/src/soc/intel/baytrail/romstage/raminit.c index c21a0c4..d6f26cd 100644 --- a/src/soc/intel/baytrail/romstage/raminit.c +++ b/src/soc/intel/baytrail/romstage/raminit.c @@ -142,7 +142,7 @@ }
/* Determine if mrc.bin is in the cbfs. */ - if (cbfs_boot_map_with_leak("mrc.bin", CBFS_TYPE_MRC, NULL) == NULL) { + if (cbfs_map("mrc.bin", NULL) == NULL) { printk(BIOS_DEBUG, "Couldn't find mrc.bin\n"); return; } diff --git a/src/soc/intel/common/mma.c b/src/soc/intel/common/mma.c index 2cd35ea..b5c8a78 100644 --- a/src/soc/intel/common/mma.c +++ b/src/soc/intel/common/mma.c @@ -126,7 +126,7 @@ printk(BIOS_DEBUG, "MMA: Entry %s\n", __func__);
if (cbfs_locate_file_in_region(&metadata_fh, MMA_CBFS_REGION, - MMA_TEST_METADATA_FILENAME, &mma_type)) { + MMA_TEST_METADATA_FILENAME)) { printk(BIOS_DEBUG, "MMA: Failed to locate %s\n", MMA_TEST_METADATA_FILENAME); return -1; @@ -167,7 +167,7 @@ test_filename, test_param_filename);
if (cbfs_locate_file_in_region(&test_content_fh, MMA_CBFS_REGION, - test_filename, &efi_type)) { + test_filename)) { printk(BIOS_DEBUG, "MMA: Failed to locate %s\n", test_filename); return -1; @@ -176,7 +176,7 @@ cbfs_file_data(&mma_cfg->test_content, &test_content_fh);
if (cbfs_locate_file_in_region(&test_param_fh, MMA_CBFS_REGION, - test_param_filename, &mma_type)) { + test_param_filename)) { printk(BIOS_DEBUG, "MMA: Failed to locate %s\n", test_param_filename); return -1; diff --git a/src/soc/intel/denverton_ns/chip.c b/src/soc/intel/denverton_ns/chip.c index c21a2a7..2d9ec23 100644 --- a/src/soc/intel/denverton_ns/chip.c +++ b/src/soc/intel/denverton_ns/chip.c @@ -106,8 +106,7 @@ const struct microcode *microcode_file; size_t microcode_len;
- microcode_file = cbfs_boot_map_with_leak("cpu_microcode_blob.bin", - CBFS_TYPE_MICROCODE, µcode_len); + microcode_file = cbfs_map("cpu_microcode_blob.bin", µcode_len);
if ((microcode_file != NULL) && (microcode_len != 0)) { /* Update CPU Microcode patch base address/size */ diff --git a/src/soc/mediatek/mt8183/spm.c b/src/soc/mediatek/mt8183/spm.c index 020da93..b275422 100644 --- a/src/soc/mediatek/mt8183/spm.c +++ b/src/soc/mediatek/mt8183/spm.c @@ -245,8 +245,7 @@
stopwatch_init(&sw);
- size_t file_size = cbfs_boot_load_file(file_name, spm_bin, - sizeof(spm_bin), CBFS_TYPE_RAW); + size_t file_size = cbfs_load(file_name, spm_bin, sizeof(spm_bin));
if (file_size == 0) { printk(BIOS_ERR, "SPM binary %s not found\n", file_name); diff --git a/src/soc/mediatek/mt8183/sspm.c b/src/soc/mediatek/mt8183/sspm.c index 857d3dc..2e1065b 100644 --- a/src/soc/mediatek/mt8183/sspm.c +++ b/src/soc/mediatek/mt8183/sspm.c @@ -26,10 +26,7 @@ void sspm_init(void) { const char *file_name = "sspm.bin"; - size_t fw_size = cbfs_boot_load_file(file_name, - sspm_bin, - sizeof(sspm_bin), - CBFS_TYPE_RAW); + size_t fw_size = cbfs_load(file_name, sspm_bin, sizeof(sspm_bin));
if (fw_size == 0) die("SSPM file :sspm.bin not found."); diff --git a/src/soc/qualcomm/ipq40xx/blobs_init.c b/src/soc/qualcomm/ipq40xx/blobs_init.c index 9d608fa..ceecdf2 100644 --- a/src/soc/qualcomm/ipq40xx/blobs_init.c +++ b/src/soc/qualcomm/ipq40xx/blobs_init.c @@ -36,8 +36,7 @@ void *blob_dest; size_t blob_size;
- blob_mbn = cbfs_boot_map_with_leak(file_name, CBFS_TYPE_RAW, - &blob_size); + blob_mbn = cbfs_map(file_name, &blob_size); if (!blob_mbn) return NULL;
diff --git a/src/soc/qualcomm/ipq806x/blobs_init.c b/src/soc/qualcomm/ipq806x/blobs_init.c index 2da868b..0d783eb 100644 --- a/src/soc/qualcomm/ipq806x/blobs_init.c +++ b/src/soc/qualcomm/ipq806x/blobs_init.c @@ -32,8 +32,7 @@ void *blob_dest; size_t blob_size;
- blob_mbn = cbfs_boot_map_with_leak(file_name, CBFS_TYPE_RAW, - &blob_size); + blob_mbn = cbfs_map(file_name, &blob_size); if (!blob_mbn) return NULL;
diff --git a/src/soc/qualcomm/sc7180/qclib.c b/src/soc/qualcomm/sc7180/qclib.c index 9c05452..653a90f 100644 --- a/src/soc/qualcomm/sc7180/qclib.c +++ b/src/soc/qualcomm/sc7180/qclib.c @@ -25,15 +25,15 @@ ssize_t ssize;
/* Attempt to load PMICCFG Blob */ - size = cbfs_boot_load_file(CONFIG_CBFS_PREFIX "/pmiccfg", - _pmic, REGION_SIZE(pmic), CBFS_TYPE_RAW); + size = cbfs_load(CONFIG_CBFS_PREFIX "/pmiccfg", + _pmic, REGION_SIZE(pmic)); if (!size) return -1; qclib_add_if_table_entry(QCLIB_TE_PMIC_SETTINGS, _pmic, size, 0);
/* Attempt to load DCB Blob */ - size = cbfs_boot_load_file(CONFIG_CBFS_PREFIX "/dcb", - _dcb, REGION_SIZE(dcb), CBFS_TYPE_RAW); + size = cbfs_load(CONFIG_CBFS_PREFIX "/dcb", + _dcb, REGION_SIZE(dcb)); if (!size) return -1; qclib_add_if_table_entry(QCLIB_TE_DCB_SETTINGS, _dcb, size, 0); diff --git a/src/soc/qualcomm/sdm845/qclib.c b/src/soc/qualcomm/sdm845/qclib.c index ae7251a..eb0fa20 100644 --- a/src/soc/qualcomm/sdm845/qclib.c +++ b/src/soc/qualcomm/sdm845/qclib.c @@ -24,15 +24,15 @@ ssize_t ssize;
/* Attempt to load PMICCFG Blob */ - size = cbfs_boot_load_file(CONFIG_CBFS_PREFIX "/pmiccfg", - _pmic, REGION_SIZE(pmic), CBFS_TYPE_RAW); + size = cbfs_load(CONFIG_CBFS_PREFIX "/pmiccfg", + _pmic, REGION_SIZE(pmic)); if (!size) return -1; qclib_add_if_table_entry(QCLIB_TE_PMIC_SETTINGS, _pmic, size, 0);
/* Attempt to load DCB Blob */ - size = cbfs_boot_load_file(CONFIG_CBFS_PREFIX "/dcb", - _dcb, REGION_SIZE(dcb), CBFS_TYPE_RAW); + size = cbfs_load(CONFIG_CBFS_PREFIX "/dcb", + _dcb, REGION_SIZE(dcb)); if (!size) return -1; qclib_add_if_table_entry(QCLIB_TE_DCB_SETTINGS, _dcb, size, 0); diff --git a/src/vendorcode/eltan/security/mboot/mboot.c b/src/vendorcode/eltan/security/mboot/mboot.c index 4429c1f..70a6332 100644 --- a/src/vendorcode/eltan/security/mboot/mboot.c +++ b/src/vendorcode/eltan/security/mboot/mboot.c @@ -248,7 +248,7 @@ size_t size;
printk(BIOS_DEBUG, "%s: Measure %s\n", __func__, name); - base = cbfs_boot_map_with_leak(name, type, &size); + base = cbfs_map(name, &size);
if (base == NULL) { printk(BIOS_DEBUG, "%s: CBFS locate fail: %s\n", __func__, name); diff --git a/src/vendorcode/eltan/security/verified_boot/vboot_check.c b/src/vendorcode/eltan/security/verified_boot/vboot_check.c index 9d99e02..69d8ade 100644 --- a/src/vendorcode/eltan/security/verified_boot/vboot_check.c +++ b/src/vendorcode/eltan/security/verified_boot/vboot_check.c @@ -46,7 +46,7 @@
sd = vb2_get_sd(ctx);
- buffer = cbfs_boot_map_with_leak(RSA_PUBLICKEY_FILE_NAME, CBFS_TYPE_RAW, &size); + buffer = cbfs_map(RSA_PUBLICKEY_FILE_NAME, &size); if (!buffer || !size) { printk(BIOS_ERR, "ERROR: Public key not found!\n"); goto fail; @@ -84,7 +84,7 @@ pre->flags = VB2_FIRMWARE_PREAMBLE_DISALLOW_HWCRYPTO;
/* Fill body_signature (vb2_structure). RSA2048 key is used */ - cbfs_boot_map_with_leak("oemmanifest.bin", CBFS_TYPE_RAW, &size); + cbfs_map("oemmanifest.bin", &size); if (size != ((CONFIG_VENDORCODE_ELTAN_OEM_MANIFEST_ITEMS * DIGEST_SIZE) + (2048/8))) { printk(BIOS_ERR, "ERROR: Incorrect manifest size!\n"); goto fail; @@ -195,7 +195,7 @@ void *start; size_t size;
- start = cbfs_boot_map_with_leak(name, type & ~VERIFIED_BOOT_COPY_BLOCK, &size); + start = cbfs_map(name, &size); if (start && size) { /* Speed up processing by copying the file content to memory first */ if (!ENV_ROMSTAGE_OR_BEFORE && (type & VERIFIED_BOOT_COPY_BLOCK)) { diff --git a/src/vendorcode/google/chromeos/sar.c b/src/vendorcode/google/chromeos/sar.c index 01de60c..d597d3e 100644 --- a/src/vendorcode/google/chromeos/sar.c +++ b/src/vendorcode/google/chromeos/sar.c @@ -29,8 +29,7 @@ const char *filename = get_wifi_sar_cbfs_filename(); if (filename == NULL) filename = WIFI_SAR_CBFS_FILENAME; - return cbfs_boot_load_file(filename, buf, - buffer_size, CBFS_TYPE_RAW); + return cbfs_load(filename, buf, buffer_size); }
/* Retrieve the wifi SAR limits data from VPD and decode it diff --git a/src/vendorcode/siemens/hwilib/hwilib.c b/src/vendorcode/siemens/hwilib/hwilib.c index a4b8e54..e155404 100644 --- a/src/vendorcode/siemens/hwilib/hwilib.c +++ b/src/vendorcode/siemens/hwilib/hwilib.c @@ -482,7 +482,7 @@ return CB_SUCCESS; }
- ptr = cbfs_boot_map_with_leak(hwi_filename, CBFS_TYPE_RAW, &filesize); + ptr = cbfs_map(hwi_filename, &filesize); if (!ptr) { printk(BIOS_ERR,"HWILIB: Missing file "%s" in cbfs.\n", hwi_filename);
Hello build bot (Jenkins), Philipp Hug, David Guckian, Lee Leahy, Vanessa Eusebio, Huang Jin, Andrey Petrov, Alexander Couzens, Evgeny Zinoviev, Patrick Rudolph, Aaron Durbin, ron minnich,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/39304
to look at the new patch set (#3).
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
cbfs: Simplify load/map API names, remove type arguments
This patch renames cbfs_boot_map_with_leak() and cbfs_boot_load_file() to cbfs_map() and cbfs_load() respectively. This is supposed to be the start of a new, better organized CBFS API where the most common operations have the most simple and straight-forward names. Less commonly used variants of these operations (e.g. cbfs_ro_load() or cbfs_region_load()) can be introduced later. It seems unnecessary to keep carrying around "boot" in the names of most CBFS APIs if the vast majority of accesses go to the boot CBFS (instead, more unusual operations should have longer names that describe how they diverge from the common ones).
cbfs_map() is paired with a new cbfs_unmap() to allow callers to cleanly reap mappings when desired. A few new cbfs_unmap() calls are added to generic code where it makes sense, but it seems unnecessary to introduce this everywhere in platform or architecture specific code where the boot medium is known to be memory-mapped anyway. In fact, even for non-memory-mapped platforms, sometimes leaking a mapping to the CBFS cache is a much cleaner solution than jumping through hoops to provide some other storage for some long-lived file object, and it shouldn't be outright forbidden when it makes sense.
Additionally, remove the type arguments from these function signatures. The goal is to eventually remove type arguments for lookup from the whole CBFS API. Filenames already uniquely identify CBFS files. The type field is just informational, and there should be APIs to allow callers to check it when desired, but it's not clear what we gain from forcing this as a parameter into every single CBFS access when the vast majority of the time it provides no additional value and is just clutter.
Signed-off-by: Julius Werner jwerner@chromium.org Change-Id: Ib24325400815a9c3d25f66c61829a24a239bb88e --- M src/arch/x86/acpi.c M src/arch/x86/bootblock_normal.c M src/cpu/amd/pi/00730F01/microcode_fam16h.c M src/cpu/intel/microcode/microcode.c M src/drivers/amd/agesa/def_callouts.c M src/drivers/amd/agesa/state_machine.c M src/drivers/intel/fsp1_1/logo.c M src/drivers/intel/fsp2_0/logo.c M src/drivers/intel/gma/opregion.c M src/drivers/pc80/rtc/option.c M src/include/cbfs.h M src/lib/bootsplash.c M src/lib/cbfs.c M src/lib/coreboot_table.c M src/lib/spd_bin.c M src/mainboard/apple/macbookair4_2/early_init.c M src/mainboard/google/auron/variants/auron_paine/spd/spd.c M src/mainboard/google/auron/variants/auron_yuna/spd/spd.c M src/mainboard/google/auron/variants/buddy/variant.c M src/mainboard/google/auron/variants/gandof/spd/spd.c M src/mainboard/google/auron/variants/lulu/spd/spd.c M src/mainboard/google/auron/variants/samus/spd/spd.c M src/mainboard/google/beltino/lan.c M src/mainboard/google/butterfly/mainboard.c M src/mainboard/google/cyan/spd/spd.c M src/mainboard/google/dragonegg/romstage_fsp_params.c M src/mainboard/google/eve/spd/spd.c M src/mainboard/google/glados/spd/spd.c M src/mainboard/google/gru/sdram_configs.c M src/mainboard/google/jecht/lan.c M src/mainboard/google/kahlee/variants/baseboard/mainboard.c M src/mainboard/google/kahlee/variants/treeya/mainboard.c M src/mainboard/google/kukui/mainboard.c M src/mainboard/google/kukui/sdram_configs.c M src/mainboard/google/link/early_init.c M src/mainboard/google/poppy/romstage.c M src/mainboard/google/poppy/variants/nami/mainboard.c M src/mainboard/google/rambi/romstage.c M src/mainboard/google/rambi/variants/ninja/lan.c M src/mainboard/google/rambi/variants/sumo/lan.c M src/mainboard/google/slippy/variants/falco/romstage.c M src/mainboard/google/slippy/variants/leon/romstage.c M src/mainboard/google/slippy/variants/peppy/romstage.c M src/mainboard/google/slippy/variants/wolf/romstage.c M src/mainboard/hp/snb_ivb_laptops/variants/revolve_810_g1/early_init.c M src/mainboard/intel/harcuvar/spd/spd.c M src/mainboard/intel/kunimitsu/spd/spd_util.c M src/mainboard/lenovo/s230u/early_init.c M src/mainboard/lenovo/t430s/variants/t431s/romstage.c M src/mainboard/lenovo/x1_carbon_gen1/early_init.c M src/mainboard/samsung/lumpy/early_init.c M src/mainboard/sifive/hifive-unleashed/fixup_fdt.c M src/northbridge/intel/sandybridge/raminit_mrc.c M src/security/intel/stm/StmPlatformSmm.c M src/security/vboot/ec_sync.c M src/soc/amd/common/block/pi/def_callouts.c M src/soc/cavium/cn81xx/soc.c M src/soc/intel/baytrail/romstage/raminit.c M src/soc/intel/common/mma.c M src/soc/intel/denverton_ns/chip.c M src/soc/mediatek/mt8183/spm.c M src/soc/mediatek/mt8183/sspm.c M src/soc/qualcomm/ipq40xx/blobs_init.c M src/soc/qualcomm/ipq806x/blobs_init.c M src/soc/qualcomm/sc7180/qclib.c M src/soc/qualcomm/sdm845/qclib.c M src/vendorcode/eltan/security/mboot/mboot.c M src/vendorcode/eltan/security/verified_boot/vboot_check.c M src/vendorcode/google/chromeos/sar.c M src/vendorcode/siemens/hwilib/hwilib.c 70 files changed, 112 insertions(+), 164 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/04/39304/3
Hello build bot (Jenkins), Philipp Hug, Patrick Georgi, Andrey Petrov, Patrick Rudolph, Aaron Durbin, David Guckian, Lee Leahy, Vanessa Eusebio, Huang Jin, Alexander Couzens, Evgeny Zinoviev, ron minnich,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/39304
to look at the new patch set (#4).
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
cbfs: Simplify load/map API names, remove type arguments
This patch renames cbfs_boot_map_with_leak() and cbfs_boot_load_file() to cbfs_map() and cbfs_load() respectively. This is supposed to be the start of a new, better organized CBFS API where the most common operations have the most simple and straight-forward names. Less commonly used variants of these operations (e.g. cbfs_ro_load() or cbfs_region_load()) can be introduced later. It seems unnecessary to keep carrying around "boot" in the names of most CBFS APIs if the vast majority of accesses go to the boot CBFS (instead, more unusual operations should have longer names that describe how they diverge from the common ones).
cbfs_map() is paired with a new cbfs_unmap() to allow callers to cleanly reap mappings when desired. A few new cbfs_unmap() calls are added to generic code where it makes sense, but it seems unnecessary to introduce this everywhere in platform or architecture specific code where the boot medium is known to be memory-mapped anyway. In fact, even for non-memory-mapped platforms, sometimes leaking a mapping to the CBFS cache is a much cleaner solution than jumping through hoops to provide some other storage for some long-lived file object, and it shouldn't be outright forbidden when it makes sense.
Additionally, remove the type arguments from these function signatures. The goal is to eventually remove type arguments for lookup from the whole CBFS API. Filenames already uniquely identify CBFS files. The type field is just informational, and there should be APIs to allow callers to check it when desired, but it's not clear what we gain from forcing this as a parameter into every single CBFS access when the vast majority of the time it provides no additional value and is just clutter.
Signed-off-by: Julius Werner jwerner@chromium.org Change-Id: Ib24325400815a9c3d25f66c61829a24a239bb88e --- M src/acpi/acpi.c M src/arch/x86/bootblock_normal.c M src/cpu/amd/pi/00730F01/microcode_fam16h.c M src/cpu/intel/microcode/microcode.c M src/drivers/amd/agesa/def_callouts.c M src/drivers/amd/agesa/state_machine.c M src/drivers/intel/fsp1_1/logo.c M src/drivers/intel/fsp2_0/logo.c M src/drivers/intel/gma/opregion.c M src/drivers/pc80/rtc/option.c M src/include/cbfs.h M src/lib/bootsplash.c M src/lib/cbfs.c M src/lib/coreboot_table.c M src/lib/spd_bin.c M src/mainboard/apple/macbookair4_2/early_init.c M src/mainboard/google/auron/variants/auron_paine/spd/spd.c M src/mainboard/google/auron/variants/auron_yuna/spd/spd.c M src/mainboard/google/auron/variants/buddy/variant.c M src/mainboard/google/auron/variants/gandof/spd/spd.c M src/mainboard/google/auron/variants/lulu/spd/spd.c M src/mainboard/google/auron/variants/samus/spd/spd.c M src/mainboard/google/beltino/lan.c M src/mainboard/google/butterfly/mainboard.c M src/mainboard/google/cyan/spd/spd.c M src/mainboard/google/dragonegg/romstage_fsp_params.c M src/mainboard/google/eve/spd/spd.c M src/mainboard/google/glados/spd/spd.c M src/mainboard/google/gru/sdram_configs.c M src/mainboard/google/jecht/lan.c M src/mainboard/google/kahlee/variants/baseboard/mainboard.c M src/mainboard/google/kahlee/variants/treeya/mainboard.c M src/mainboard/google/kukui/mainboard.c M src/mainboard/google/kukui/sdram_configs.c M src/mainboard/google/link/early_init.c M src/mainboard/google/poppy/romstage.c M src/mainboard/google/poppy/variants/nami/mainboard.c M src/mainboard/google/rambi/romstage.c M src/mainboard/google/rambi/variants/ninja/lan.c M src/mainboard/google/rambi/variants/sumo/lan.c M src/mainboard/google/slippy/variants/falco/romstage.c M src/mainboard/google/slippy/variants/leon/romstage.c M src/mainboard/google/slippy/variants/peppy/romstage.c M src/mainboard/google/slippy/variants/wolf/romstage.c M src/mainboard/hp/snb_ivb_laptops/variants/revolve_810_g1/early_init.c M src/mainboard/intel/harcuvar/spd/spd.c M src/mainboard/intel/kunimitsu/spd/spd_util.c M src/mainboard/lenovo/s230u/early_init.c M src/mainboard/lenovo/t430s/variants/t431s/romstage.c M src/mainboard/lenovo/x1_carbon_gen1/early_init.c M src/mainboard/samsung/lumpy/early_init.c M src/mainboard/sifive/hifive-unleashed/fixup_fdt.c M src/northbridge/intel/sandybridge/raminit_mrc.c M src/security/intel/stm/StmPlatformSmm.c M src/security/vboot/ec_sync.c M src/soc/amd/common/block/pi/def_callouts.c M src/soc/cavium/cn81xx/soc.c M src/soc/intel/baytrail/romstage/raminit.c M src/soc/intel/common/mma.c M src/soc/intel/denverton_ns/chip.c M src/soc/mediatek/mt8183/spm.c M src/soc/mediatek/mt8183/sspm.c M src/soc/qualcomm/ipq40xx/blobs_init.c M src/soc/qualcomm/ipq806x/blobs_init.c M src/soc/qualcomm/sc7180/qclib.c M src/soc/qualcomm/sdm845/qclib.c M src/vendorcode/eltan/security/mboot/mboot.c M src/vendorcode/eltan/security/verified_boot/vboot_check.c M src/vendorcode/google/chromeos/sar.c M src/vendorcode/siemens/hwilib/hwilib.c 70 files changed, 112 insertions(+), 164 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/04/39304/4
Aaron Durbin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39304 )
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
Patch Set 4:
(4 comments)
https://review.coreboot.org/c/coreboot/+/39304/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/39304/4//COMMIT_MSG@24 PS4, Line 24: known Some of those are only known by way of Kconfig check. I also think allowing leaking all over because the API is not clear of the semantics allows for abuse. The omission of stranded cbfs_map() calls w/o a cbfs_unmap() pairing will likely be copy/pasted which leads to truly leaking resources.
https://review.coreboot.org/c/coreboot/+/39304/4/src/include/cbfs.h File src/include/cbfs.h:
https://review.coreboot.org/c/coreboot/+/39304/4/src/include/cbfs.h@27 PS4, Line 27: often "can't". Without knowing which rdev the mapping is connected to then things fall over. Remember you have an ro as well as rw cbfs_boot_device objects.
https://review.coreboot.org/c/coreboot/+/39304/4/src/lib/cbfs.c File src/lib/cbfs.c:
https://review.coreboot.org/c/coreboot/+/39304/4/src/lib/cbfs.c@96 PS4, Line 96: cares about which chained subregion something was mapped from. */ I don't think this is always true in practice. I think more commentary covering the diligence of this assumption is warranted.
e.g. src/drivers/spi/boot_device_rw_nommap.c provides rdev ops which do not allow any mmap()ing, but boot_device_ro() using src/arch/x86/mmap_boot.c does allow it. I believe that's the only combination that is potentially problematic, but the assumption above still holds.
https://review.coreboot.org/c/coreboot/+/39304/4/src/security/vboot/ec_sync.... File src/security/vboot/ec_sync.c:
https://review.coreboot.org/c/coreboot/+/39304/4/src/security/vboot/ec_sync.... PS4, Line 397: Why wouldn't we unamp here?
Hello build bot (Jenkins), Patrick Georgi, Philipp Hug, Andrey Petrov, Aaron Durbin, Patrick Rudolph, David Guckian, Lee Leahy, Vanessa Eusebio, Huang Jin, Alexander Couzens, Evgeny Zinoviev, ron minnich,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/39304
to look at the new patch set (#5).
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
cbfs: Simplify load/map API names, remove type arguments
This patch renames cbfs_boot_map_with_leak() and cbfs_boot_load_file() to cbfs_map() and cbfs_load() respectively. This is supposed to be the start of a new, better organized CBFS API where the most common operations have the most simple and straight-forward names. Less commonly used variants of these operations (e.g. cbfs_ro_load() or cbfs_region_load()) can be introduced later. It seems unnecessary to keep carrying around "boot" in the names of most CBFS APIs if the vast majority of accesses go to the boot CBFS (instead, more unusual operations should have longer names that describe how they diverge from the common ones).
cbfs_map() is paired with a new cbfs_unmap() to allow callers to cleanly reap mappings when desired. A few new cbfs_unmap() calls are added to generic code where it makes sense, but it seems unnecessary to introduce this everywhere in platform or architecture specific code where the boot medium is known to be memory-mapped anyway. In fact, even for non-memory-mapped platforms, sometimes leaking a mapping to the CBFS cache is a much cleaner solution than jumping through hoops to provide some other storage for some long-lived file object, and it shouldn't be outright forbidden when it makes sense.
Additionally, remove the type arguments from these function signatures. The goal is to eventually remove type arguments for lookup from the whole CBFS API. Filenames already uniquely identify CBFS files. The type field is just informational, and there should be APIs to allow callers to check it when desired, but it's not clear what we gain from forcing this as a parameter into every single CBFS access when the vast majority of the time it provides no additional value and is just clutter.
Signed-off-by: Julius Werner jwerner@chromium.org Change-Id: Ib24325400815a9c3d25f66c61829a24a239bb88e --- M src/acpi/acpi.c M src/arch/x86/bootblock_normal.c A src/cpu/amd/pi/00730F01/microcode_fam16h.c M src/cpu/amd/pi/00730F01/update_microcode.c M src/cpu/intel/microcode/microcode.c M src/drivers/amd/agesa/def_callouts.c M src/drivers/amd/agesa/state_machine.c M src/drivers/intel/fsp1_1/logo.c M src/drivers/intel/fsp2_0/logo.c M src/drivers/intel/gma/opregion.c M src/drivers/pc80/rtc/option.c M src/include/cbfs.h M src/lib/bootsplash.c M src/lib/cbfs.c M src/lib/coreboot_table.c M src/lib/fw_config.c M src/lib/spd_bin.c M src/mainboard/apple/macbookair4_2/early_init.c M src/mainboard/dell/optiplex_9010/sch5545_ec.c M src/mainboard/google/asurada/sdram_configs.c M src/mainboard/google/auron/variants/auron_paine/spd/spd.c M src/mainboard/google/auron/variants/auron_yuna/spd/spd.c M src/mainboard/google/auron/variants/buddy/variant.c M src/mainboard/google/auron/variants/gandof/spd/spd.c M src/mainboard/google/auron/variants/lulu/spd/spd.c M src/mainboard/google/auron/variants/samus/spd/spd.c M src/mainboard/google/beltino/lan.c M src/mainboard/google/butterfly/mainboard.c M src/mainboard/google/cyan/spd/spd.c M src/mainboard/google/eve/spd/spd.c M src/mainboard/google/glados/spd/spd.c M src/mainboard/google/gru/sdram_configs.c M src/mainboard/google/jecht/lan.c M src/mainboard/google/kahlee/variants/baseboard/mainboard.c M src/mainboard/google/kahlee/variants/nuwani/mainboard.c M src/mainboard/google/kahlee/variants/treeya/mainboard.c M src/mainboard/google/kukui/mainboard.c M src/mainboard/google/kukui/sdram_configs.c M src/mainboard/google/link/early_init.c M src/mainboard/google/poppy/romstage.c M src/mainboard/google/poppy/variants/nami/mainboard.c M src/mainboard/google/rambi/romstage.c M src/mainboard/google/rambi/variants/ninja/lan.c M src/mainboard/google/rambi/variants/sumo/lan.c M src/mainboard/google/slippy/variants/falco/romstage.c M src/mainboard/google/slippy/variants/leon/romstage.c M src/mainboard/google/slippy/variants/peppy/romstage.c M src/mainboard/google/slippy/variants/wolf/romstage.c M src/mainboard/hp/snb_ivb_laptops/variants/revolve_810_g1/early_init.c M src/mainboard/intel/harcuvar/spd/spd.c M src/mainboard/intel/kunimitsu/spd/spd_util.c M src/mainboard/lenovo/s230u/early_init.c M src/mainboard/lenovo/t430s/variants/t431s/romstage.c M src/mainboard/lenovo/x1_carbon_gen1/early_init.c M src/mainboard/samsung/lumpy/early_init.c M src/mainboard/sifive/hifive-unleashed/fixup_fdt.c M src/northbridge/intel/sandybridge/raminit_mrc.c M src/security/intel/stm/StmPlatformSmm.c M src/security/intel/txt/ramstage.c M src/security/vboot/ec_sync.c M src/soc/amd/common/block/pi/def_callouts.c M src/soc/amd/picasso/update_microcode.c M src/soc/cavium/cn81xx/soc.c M src/soc/intel/baytrail/romstage/raminit.c M src/soc/intel/common/mma.c M src/soc/intel/denverton_ns/chip.c M src/soc/intel/xeon_sp/skx/chip.c M src/soc/mediatek/mt8183/spm.c M src/soc/mediatek/mt8183/sspm.c M src/soc/qualcomm/ipq40xx/blobs_init.c M src/soc/qualcomm/ipq806x/blobs_init.c M src/soc/qualcomm/sc7180/qclib.c M src/soc/qualcomm/sc7180/qupv3_config.c M src/soc/qualcomm/sdm845/qclib.c M src/vendorcode/eltan/security/mboot/mboot.c M src/vendorcode/eltan/security/verified_boot/vboot_check.c M src/vendorcode/google/chromeos/sar.c M src/vendorcode/siemens/hwilib/hwilib.c 78 files changed, 254 insertions(+), 187 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/04/39304/5
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39304 )
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
Patch Set 5:
(4 comments)
https://review.coreboot.org/c/coreboot/+/39304/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/39304/4//COMMIT_MSG@24 PS4, Line 24: known
Some of those are only known by way of Kconfig check. […]
Sorry, I'm not sure what you're saying... are you just arguing that I should add a cbfs_unmap() to all the existing cbfs_map() (even the ones in Intel FSP drivers or src/soc code for x86 platforms?), or are you saying you don't like this approach at all and want to keep the map_with_leak() name? I'm just trying to make this API less of a mouthful because it is used all over the place, and to align it with the rdev_mmap()/rdev_munmap() naming scheme.
https://review.coreboot.org/c/coreboot/+/39304/4/src/include/cbfs.h File src/include/cbfs.h:
https://review.coreboot.org/c/coreboot/+/39304/4/src/include/cbfs.h@27 PS4, Line 27: often
"can't". Without knowing which rdev the mapping is connected to then things fall over. […]
This comment is just to remind people about the behavior of mem_pool_alloc()/mem_pool_free() (which is in practice the only non-trivial mapping backend we have). As mentioned elsewhere I want to rely on the assumption that both RO and RW CBFS are always chained from boot_device_ro().
https://review.coreboot.org/c/coreboot/+/39304/4/src/lib/cbfs.c File src/lib/cbfs.c:
https://review.coreboot.org/c/coreboot/+/39304/4/src/lib/cbfs.c@96 PS4, Line 96: cares about which chained subregion something was mapped from. */
I don't think this is always true in practice. […]
See discussion in https://review.coreboot.org/c/coreboot/+/39327/3/src/lib/cbfs.c#62
https://review.coreboot.org/c/coreboot/+/39304/4/src/security/vboot/ec_sync.... File src/security/vboot/ec_sync.c:
https://review.coreboot.org/c/coreboot/+/39304/4/src/security/vboot/ec_sync.... PS4, Line 397:
Why wouldn't we unamp here?
We're returning the pointer to the caller, its contents must remain valid. The vboot API has no way to return this memory so this is one of those cases where we need to leak a mapping. It's just a hash so it shouldn't be a big deal. Added comment to document.
Aaron Durbin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39304 )
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
Patch Set 7:
(2 comments)
https://review.coreboot.org/c/coreboot/+/39304/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/39304/4//COMMIT_MSG@24 PS4, Line 24: known
Sorry, I'm not sure what you're saying... […]
I'm merely trying to ensure we don't allow for lazy programming. That and those knowns are not always true. I wasn't asking you to fix up all the other code, but...
cbfs_boot_map_with_leak -> cbfs_map
Now the code looks like it's ok to never pair an unmap. The ugly naming forces one to think about the behavior of the code being written or copied.
Anyway, it seems you aren't that concerned so we can let it be.
https://review.coreboot.org/c/coreboot/+/39304/4/src/security/vboot/ec_sync.... File src/security/vboot/ec_sync.c:
https://review.coreboot.org/c/coreboot/+/39304/4/src/security/vboot/ec_sync.... PS4, Line 397:
We're returning the pointer to the caller, its contents must remain valid. […]
got it. ick.
Aaron Durbin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39304 )
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
Patch Set 11: Code-Review+2
(1 comment)
https://review.coreboot.org/c/coreboot/+/39304/11/src/cpu/amd/pi/00730F01/mi... File src/cpu/amd/pi/00730F01/microcode_fam16h.c:
https://review.coreboot.org/c/coreboot/+/39304/11/src/cpu/amd/pi/00730F01/mi... PS11, Line 1: /* SPDX-License-Identifier: GPL-2.0-only */ Does this file need to be removed from your patchset?
Hello build bot (Jenkins), Patrick Georgi, Philipp Hug, Angel Pons, Andrey Petrov, Aaron Durbin, Patrick Rudolph, David Guckian, Lee Leahy, Vanessa Eusebio, Huang Jin, Alexander Couzens, Evgeny Zinoviev, ron minnich,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/39304
to look at the new patch set (#12).
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
cbfs: Simplify load/map API names, remove type arguments
This patch renames cbfs_boot_map_with_leak() and cbfs_boot_load_file() to cbfs_map() and cbfs_load() respectively. This is supposed to be the start of a new, better organized CBFS API where the most common operations have the most simple and straight-forward names. Less commonly used variants of these operations (e.g. cbfs_ro_load() or cbfs_region_load()) can be introduced later. It seems unnecessary to keep carrying around "boot" in the names of most CBFS APIs if the vast majority of accesses go to the boot CBFS (instead, more unusual operations should have longer names that describe how they diverge from the common ones).
cbfs_map() is paired with a new cbfs_unmap() to allow callers to cleanly reap mappings when desired. A few new cbfs_unmap() calls are added to generic code where it makes sense, but it seems unnecessary to introduce this everywhere in platform or architecture specific code where the boot medium is known to be memory-mapped anyway. In fact, even for non-memory-mapped platforms, sometimes leaking a mapping to the CBFS cache is a much cleaner solution than jumping through hoops to provide some other storage for some long-lived file object, and it shouldn't be outright forbidden when it makes sense.
Additionally, remove the type arguments from these function signatures. The goal is to eventually remove type arguments for lookup from the whole CBFS API. Filenames already uniquely identify CBFS files. The type field is just informational, and there should be APIs to allow callers to check it when desired, but it's not clear what we gain from forcing this as a parameter into every single CBFS access when the vast majority of the time it provides no additional value and is just clutter.
Signed-off-by: Julius Werner jwerner@chromium.org Change-Id: Ib24325400815a9c3d25f66c61829a24a239bb88e --- M src/acpi/acpi.c M src/arch/x86/bootblock_normal.c M src/cpu/amd/pi/00730F01/update_microcode.c M src/cpu/intel/microcode/microcode.c M src/drivers/amd/agesa/def_callouts.c M src/drivers/amd/agesa/state_machine.c M src/drivers/intel/fsp1_1/logo.c M src/drivers/intel/fsp2_0/logo.c M src/drivers/intel/gma/opregion.c M src/drivers/pc80/rtc/option.c M src/include/cbfs.h M src/lib/bootsplash.c M src/lib/cbfs.c M src/lib/coreboot_table.c M src/lib/fw_config.c M src/lib/spd_bin.c M src/mainboard/apple/macbookair4_2/early_init.c M src/mainboard/dell/optiplex_9010/sch5545_ec.c M src/mainboard/google/asurada/sdram_configs.c M src/mainboard/google/auron/variants/auron_paine/spd/spd.c M src/mainboard/google/auron/variants/auron_yuna/spd/spd.c M src/mainboard/google/auron/variants/buddy/variant.c M src/mainboard/google/auron/variants/gandof/spd/spd.c M src/mainboard/google/auron/variants/lulu/spd/spd.c M src/mainboard/google/auron/variants/samus/spd/spd.c M src/mainboard/google/beltino/lan.c M src/mainboard/google/butterfly/mainboard.c M src/mainboard/google/cyan/spd/spd.c M src/mainboard/google/eve/spd/spd.c M src/mainboard/google/glados/spd/spd.c M src/mainboard/google/gru/sdram_configs.c M src/mainboard/google/jecht/lan.c M src/mainboard/google/kahlee/variants/baseboard/mainboard.c M src/mainboard/google/kahlee/variants/nuwani/mainboard.c M src/mainboard/google/kahlee/variants/treeya/mainboard.c M src/mainboard/google/kukui/mainboard.c M src/mainboard/google/kukui/sdram_configs.c M src/mainboard/google/link/early_init.c M src/mainboard/google/poppy/romstage.c M src/mainboard/google/poppy/variants/nami/mainboard.c M src/mainboard/google/rambi/romstage.c M src/mainboard/google/rambi/variants/ninja/lan.c M src/mainboard/google/rambi/variants/sumo/lan.c M src/mainboard/google/slippy/variants/falco/romstage.c M src/mainboard/google/slippy/variants/leon/romstage.c M src/mainboard/google/slippy/variants/peppy/romstage.c M src/mainboard/google/slippy/variants/wolf/romstage.c M src/mainboard/hp/snb_ivb_laptops/variants/revolve_810_g1/early_init.c M src/mainboard/intel/harcuvar/spd/spd.c M src/mainboard/intel/kunimitsu/spd/spd_util.c M src/mainboard/lenovo/s230u/early_init.c M src/mainboard/lenovo/t430s/variants/t431s/romstage.c M src/mainboard/lenovo/x1_carbon_gen1/early_init.c M src/mainboard/samsung/lumpy/early_init.c M src/mainboard/sifive/hifive-unleashed/fixup_fdt.c M src/northbridge/intel/sandybridge/raminit_mrc.c M src/security/intel/stm/StmPlatformSmm.c M src/security/intel/txt/ramstage.c M src/security/vboot/ec_sync.c M src/soc/amd/common/block/pi/def_callouts.c M src/soc/amd/picasso/update_microcode.c M src/soc/cavium/cn81xx/soc.c M src/soc/intel/baytrail/romstage/raminit.c M src/soc/intel/common/mma.c M src/soc/intel/denverton_ns/chip.c M src/soc/intel/xeon_sp/skx/chip.c M src/soc/mediatek/mt8183/spm.c M src/soc/mediatek/mt8183/sspm.c M src/soc/qualcomm/ipq40xx/blobs_init.c M src/soc/qualcomm/ipq806x/blobs_init.c M src/soc/qualcomm/sc7180/qclib.c M src/soc/qualcomm/sc7180/qupv3_config.c M src/soc/qualcomm/sdm845/qclib.c M src/vendorcode/eltan/security/mboot/mboot.c M src/vendorcode/eltan/security/verified_boot/vboot_check.c M src/vendorcode/google/chromeos/sar.c M src/vendorcode/siemens/hwilib/hwilib.c 77 files changed, 128 insertions(+), 188 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/04/39304/12
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39304 )
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
Patch Set 12:
(1 comment)
https://review.coreboot.org/c/coreboot/+/39304/11/src/cpu/amd/pi/00730F01/mi... File src/cpu/amd/pi/00730F01/microcode_fam16h.c:
https://review.coreboot.org/c/coreboot/+/39304/11/src/cpu/amd/pi/00730F01/mi... PS11, Line 1: /* SPDX-License-Identifier: GPL-2.0-only */
Does this file need to be removed from your patchset?
Whoops, thanks, must have been a rebasing mistake. Done.
Aaron Durbin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39304 )
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
Patch Set 12: Code-Review+2
Hello build bot (Jenkins), Patrick Georgi, Philipp Hug, Angel Pons, Andrey Petrov, Aaron Durbin, Patrick Rudolph, David Guckian, Lee Leahy, Vanessa Eusebio, Huang Jin, Alexander Couzens, Evgeny Zinoviev, ron minnich,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/39304
to look at the new patch set (#14).
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
cbfs: Simplify load/map API names, remove type arguments
This patch renames cbfs_boot_map_with_leak() and cbfs_boot_load_file() to cbfs_map() and cbfs_load() respectively. This is supposed to be the start of a new, better organized CBFS API where the most common operations have the most simple and straight-forward names. Less commonly used variants of these operations (e.g. cbfs_ro_load() or cbfs_region_load()) can be introduced later. It seems unnecessary to keep carrying around "boot" in the names of most CBFS APIs if the vast majority of accesses go to the boot CBFS (instead, more unusual operations should have longer names that describe how they diverge from the common ones).
cbfs_map() is paired with a new cbfs_unmap() to allow callers to cleanly reap mappings when desired. A few new cbfs_unmap() calls are added to generic code where it makes sense, but it seems unnecessary to introduce this everywhere in platform or architecture specific code where the boot medium is known to be memory-mapped anyway. In fact, even for non-memory-mapped platforms, sometimes leaking a mapping to the CBFS cache is a much cleaner solution than jumping through hoops to provide some other storage for some long-lived file object, and it shouldn't be outright forbidden when it makes sense.
Additionally, remove the type arguments from these function signatures. The goal is to eventually remove type arguments for lookup from the whole CBFS API. Filenames already uniquely identify CBFS files. The type field is just informational, and there should be APIs to allow callers to check it when desired, but it's not clear what we gain from forcing this as a parameter into every single CBFS access when the vast majority of the time it provides no additional value and is just clutter.
Signed-off-by: Julius Werner jwerner@chromium.org Change-Id: Ib24325400815a9c3d25f66c61829a24a239bb88e --- M src/acpi/acpi.c M src/arch/x86/bootblock_normal.c M src/cpu/amd/pi/00730F01/update_microcode.c M src/cpu/intel/microcode/microcode.c M src/drivers/amd/agesa/def_callouts.c M src/drivers/amd/agesa/state_machine.c M src/drivers/intel/fsp1_1/logo.c M src/drivers/intel/fsp2_0/logo.c M src/drivers/intel/gma/opregion.c M src/drivers/pc80/rtc/option.c M src/include/cbfs.h M src/lib/bootsplash.c M src/lib/cbfs.c M src/lib/coreboot_table.c M src/lib/fw_config.c M src/lib/spd_bin.c M src/mainboard/apple/macbookair4_2/early_init.c M src/mainboard/dell/optiplex_9010/sch5545_ec.c M src/mainboard/google/asurada/sdram_configs.c M src/mainboard/google/auron/variants/auron_paine/spd/spd.c M src/mainboard/google/auron/variants/auron_yuna/spd/spd.c M src/mainboard/google/auron/variants/buddy/variant.c M src/mainboard/google/auron/variants/gandof/spd/spd.c M src/mainboard/google/auron/variants/lulu/spd/spd.c M src/mainboard/google/auron/variants/samus/spd/spd.c M src/mainboard/google/beltino/lan.c M src/mainboard/google/butterfly/mainboard.c M src/mainboard/google/cyan/spd/spd.c M src/mainboard/google/eve/spd/spd.c M src/mainboard/google/glados/spd/spd.c M src/mainboard/google/gru/sdram_configs.c M src/mainboard/google/jecht/lan.c M src/mainboard/google/kahlee/variants/baseboard/mainboard.c M src/mainboard/google/kahlee/variants/nuwani/mainboard.c M src/mainboard/google/kahlee/variants/treeya/mainboard.c M src/mainboard/google/kukui/mainboard.c M src/mainboard/google/kukui/sdram_configs.c M src/mainboard/google/link/early_init.c M src/mainboard/google/poppy/romstage.c M src/mainboard/google/poppy/variants/nami/mainboard.c M src/mainboard/google/rambi/romstage.c M src/mainboard/google/rambi/variants/ninja/lan.c M src/mainboard/google/rambi/variants/sumo/lan.c M src/mainboard/google/slippy/variants/falco/romstage.c M src/mainboard/google/slippy/variants/leon/romstage.c M src/mainboard/google/slippy/variants/peppy/romstage.c M src/mainboard/google/slippy/variants/wolf/romstage.c M src/mainboard/hp/snb_ivb_laptops/variants/revolve_810_g1/early_init.c M src/mainboard/intel/harcuvar/spd/spd.c M src/mainboard/intel/kunimitsu/spd/spd_util.c M src/mainboard/lenovo/s230u/early_init.c M src/mainboard/lenovo/t430s/variants/t431s/romstage.c M src/mainboard/lenovo/x1_carbon_gen1/early_init.c M src/mainboard/samsung/lumpy/early_init.c M src/mainboard/sifive/hifive-unleashed/fixup_fdt.c M src/northbridge/intel/sandybridge/raminit_mrc.c M src/security/intel/stm/StmPlatformSmm.c M src/security/intel/txt/ramstage.c M src/security/vboot/ec_sync.c M src/soc/amd/common/block/pi/def_callouts.c M src/soc/amd/picasso/update_microcode.c M src/soc/cavium/cn81xx/soc.c M src/soc/intel/baytrail/romstage/raminit.c M src/soc/intel/common/mma.c M src/soc/intel/denverton_ns/chip.c M src/soc/intel/xeon_sp/skx/chip.c M src/soc/mediatek/mt8183/spm.c M src/soc/mediatek/mt8183/sspm.c M src/soc/qualcomm/ipq40xx/blobs_init.c M src/soc/qualcomm/ipq806x/blobs_init.c M src/soc/qualcomm/sc7180/qclib.c M src/soc/qualcomm/sc7180/qupv3_config.c M src/vendorcode/eltan/security/mboot/mboot.c M src/vendorcode/eltan/security/verified_boot/vboot_check.c M src/vendorcode/google/chromeos/sar.c M src/vendorcode/siemens/hwilib/hwilib.c 76 files changed, 124 insertions(+), 184 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/04/39304/14
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39304 )
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
Patch Set 16: Code-Review+2
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39304 )
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
Patch Set 17: Code-Review+2
Wim Vervoorn has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39304 )
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
Patch Set 17: Code-Review+2
Mariusz Szafrański has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39304 )
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
Patch Set 17: Code-Review+2
Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/39304 )
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
cbfs: Simplify load/map API names, remove type arguments
This patch renames cbfs_boot_map_with_leak() and cbfs_boot_load_file() to cbfs_map() and cbfs_load() respectively. This is supposed to be the start of a new, better organized CBFS API where the most common operations have the most simple and straight-forward names. Less commonly used variants of these operations (e.g. cbfs_ro_load() or cbfs_region_load()) can be introduced later. It seems unnecessary to keep carrying around "boot" in the names of most CBFS APIs if the vast majority of accesses go to the boot CBFS (instead, more unusual operations should have longer names that describe how they diverge from the common ones).
cbfs_map() is paired with a new cbfs_unmap() to allow callers to cleanly reap mappings when desired. A few new cbfs_unmap() calls are added to generic code where it makes sense, but it seems unnecessary to introduce this everywhere in platform or architecture specific code where the boot medium is known to be memory-mapped anyway. In fact, even for non-memory-mapped platforms, sometimes leaking a mapping to the CBFS cache is a much cleaner solution than jumping through hoops to provide some other storage for some long-lived file object, and it shouldn't be outright forbidden when it makes sense.
Additionally, remove the type arguments from these function signatures. The goal is to eventually remove type arguments for lookup from the whole CBFS API. Filenames already uniquely identify CBFS files. The type field is just informational, and there should be APIs to allow callers to check it when desired, but it's not clear what we gain from forcing this as a parameter into every single CBFS access when the vast majority of the time it provides no additional value and is just clutter.
Signed-off-by: Julius Werner jwerner@chromium.org Change-Id: Ib24325400815a9c3d25f66c61829a24a239bb88e Reviewed-on: https://review.coreboot.org/c/coreboot/+/39304 Reviewed-by: Hung-Te Lin hungte@chromium.org Reviewed-by: Wim Vervoorn wvervoorn@eltan.com Reviewed-by: Mariusz Szafrański mariuszx.szafranski@intel.com Reviewed-by: Patrick Georgi pgeorgi@google.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/acpi/acpi.c M src/arch/x86/bootblock_normal.c M src/cpu/amd/pi/00730F01/update_microcode.c M src/cpu/intel/microcode/microcode.c M src/drivers/amd/agesa/def_callouts.c M src/drivers/amd/agesa/state_machine.c M src/drivers/intel/fsp1_1/logo.c M src/drivers/intel/fsp2_0/logo.c M src/drivers/intel/gma/opregion.c M src/drivers/pc80/rtc/option.c M src/include/cbfs.h M src/lib/bootsplash.c M src/lib/cbfs.c M src/lib/coreboot_table.c M src/lib/fw_config.c M src/lib/spd_bin.c M src/mainboard/apple/macbookair4_2/early_init.c M src/mainboard/dell/optiplex_9010/sch5545_ec.c M src/mainboard/google/asurada/sdram_configs.c M src/mainboard/google/auron/variants/auron_paine/spd/spd.c M src/mainboard/google/auron/variants/auron_yuna/spd/spd.c M src/mainboard/google/auron/variants/buddy/variant.c M src/mainboard/google/auron/variants/gandof/spd/spd.c M src/mainboard/google/auron/variants/lulu/spd/spd.c M src/mainboard/google/auron/variants/samus/spd/spd.c M src/mainboard/google/beltino/lan.c M src/mainboard/google/butterfly/mainboard.c M src/mainboard/google/cyan/spd/spd.c M src/mainboard/google/eve/spd/spd.c M src/mainboard/google/glados/spd/spd.c M src/mainboard/google/gru/sdram_configs.c M src/mainboard/google/jecht/lan.c M src/mainboard/google/kahlee/variants/baseboard/mainboard.c M src/mainboard/google/kahlee/variants/nuwani/mainboard.c M src/mainboard/google/kahlee/variants/treeya/mainboard.c M src/mainboard/google/kukui/mainboard.c M src/mainboard/google/kukui/sdram_configs.c M src/mainboard/google/link/early_init.c M src/mainboard/google/poppy/romstage.c M src/mainboard/google/poppy/variants/nami/mainboard.c M src/mainboard/google/rambi/romstage.c M src/mainboard/google/rambi/variants/ninja/lan.c M src/mainboard/google/rambi/variants/sumo/lan.c M src/mainboard/google/slippy/variants/falco/romstage.c M src/mainboard/google/slippy/variants/leon/romstage.c M src/mainboard/google/slippy/variants/peppy/romstage.c M src/mainboard/google/slippy/variants/wolf/romstage.c M src/mainboard/hp/snb_ivb_laptops/variants/revolve_810_g1/early_init.c M src/mainboard/intel/harcuvar/spd/spd.c M src/mainboard/intel/kunimitsu/spd/spd_util.c M src/mainboard/lenovo/s230u/early_init.c M src/mainboard/lenovo/t430s/variants/t431s/romstage.c M src/mainboard/lenovo/x1_carbon_gen1/early_init.c M src/mainboard/samsung/lumpy/early_init.c M src/mainboard/sifive/hifive-unleashed/fixup_fdt.c M src/northbridge/intel/sandybridge/raminit_mrc.c M src/security/intel/stm/StmPlatformSmm.c M src/security/intel/txt/ramstage.c M src/security/vboot/ec_sync.c M src/soc/amd/common/block/pi/def_callouts.c M src/soc/amd/picasso/update_microcode.c M src/soc/cavium/cn81xx/soc.c M src/soc/intel/baytrail/romstage/raminit.c M src/soc/intel/common/mma.c M src/soc/intel/denverton_ns/chip.c M src/soc/intel/xeon_sp/skx/chip.c M src/soc/mediatek/mt8183/spm.c M src/soc/mediatek/mt8183/sspm.c M src/soc/qualcomm/ipq40xx/blobs_init.c M src/soc/qualcomm/ipq806x/blobs_init.c M src/soc/qualcomm/sc7180/qclib.c M src/soc/qualcomm/sc7180/qupv3_config.c M src/vendorcode/eltan/security/mboot/mboot.c M src/vendorcode/eltan/security/verified_boot/vboot_check.c M src/vendorcode/google/chromeos/sar.c M src/vendorcode/siemens/hwilib/hwilib.c 76 files changed, 124 insertions(+), 184 deletions(-)
Approvals: build bot (Jenkins): Verified Patrick Georgi: Looks good to me, approved Wim Vervoorn: Looks good to me, approved Mariusz Szafrański: Looks good to me, approved Hung-Te Lin: Looks good to me, approved
diff --git a/src/acpi/acpi.c b/src/acpi/acpi.c index abc6e01..c319a73 100644 --- a/src/acpi/acpi.c +++ b/src/acpi/acpi.c @@ -1340,9 +1340,7 @@ return fw; }
- dsdt_file = cbfs_boot_map_with_leak( - CONFIG_CBFS_PREFIX "/dsdt.aml", - CBFS_TYPE_RAW, &dsdt_size); + dsdt_file = cbfs_map(CONFIG_CBFS_PREFIX "/dsdt.aml", &dsdt_size); if (!dsdt_file) { printk(BIOS_ERR, "No DSDT file, skipping ACPI tables\n"); return current; @@ -1355,8 +1353,7 @@ return current; }
- slic_file = cbfs_boot_map_with_leak(CONFIG_CBFS_PREFIX "/slic", - CBFS_TYPE_RAW, &slic_size); + slic_file = cbfs_map(CONFIG_CBFS_PREFIX "/slic", &slic_size); if (slic_file && (slic_file->length > slic_size || slic_file->length < sizeof(acpi_header_t) diff --git a/src/arch/x86/bootblock_normal.c b/src/arch/x86/bootblock_normal.c index 3fbdbec..e2dfcf4 100644 --- a/src/arch/x86/bootblock_normal.c +++ b/src/arch/x86/bootblock_normal.c @@ -18,7 +18,7 @@ const char *boot_candidate; size_t stages_len;
- boot_candidate = cbfs_boot_map_with_leak("coreboot-stages", CBFS_TYPE_RAW, &stages_len); + boot_candidate = cbfs_map("coreboot-stages", &stages_len); if (!boot_candidate) boot_candidate = default_filenames;
diff --git a/src/cpu/amd/pi/00730F01/update_microcode.c b/src/cpu/amd/pi/00730F01/update_microcode.c index 11e2531..ccf6468 100644 --- a/src/cpu/amd/pi/00730F01/update_microcode.c +++ b/src/cpu/amd/pi/00730F01/update_microcode.c @@ -115,8 +115,7 @@ size_t ucode_len; uint16_t equivalent_processor_rev_id = get_equivalent_processor_rev_id();
- ucode = cbfs_boot_map_with_leak("cpu_microcode_blob.bin", - CBFS_TYPE_MICROCODE, &ucode_len); + ucode = cbfs_map("cpu_microcode_blob.bin", &ucode_len); if (!ucode) { printk(BIOS_WARNING, "cpu_microcode_blob.bin not found. Skipping updates.\n"); return; diff --git a/src/cpu/intel/microcode/microcode.c b/src/cpu/intel/microcode/microcode.c index 8080545..0f362d4 100644 --- a/src/cpu/intel/microcode/microcode.c +++ b/src/cpu/intel/microcode/microcode.c @@ -126,9 +126,7 @@ unsigned int x86_model, x86_family; msr_t msr;
- ucode_updates = cbfs_boot_map_with_leak(MICROCODE_CBFS_FILE, - CBFS_TYPE_MICROCODE, - µcode_len); + ucode_updates = cbfs_map(MICROCODE_CBFS_FILE, µcode_len); if (ucode_updates == NULL) return NULL;
diff --git a/src/drivers/amd/agesa/def_callouts.c b/src/drivers/amd/agesa/def_callouts.c index 07f7173..5f52ca0 100644 --- a/src/drivers/amd/agesa/def_callouts.c +++ b/src/drivers/amd/agesa/def_callouts.c @@ -121,9 +121,7 @@ AGESA_STATUS agesa_GfxGetVbiosImage(UINT32 Func, UINTN FchData, VOID *ConfigPrt) { GFX_VBIOS_IMAGE_INFO *pVbiosImageInfo = (GFX_VBIOS_IMAGE_INFO *)ConfigPrt; - pVbiosImageInfo->ImagePtr = cbfs_boot_map_with_leak( - "pci"CONFIG_VGA_BIOS_ID".rom", - CBFS_TYPE_OPTIONROM, NULL); + pVbiosImageInfo->ImagePtr = cbfs_map("pci"CONFIG_VGA_BIOS_ID".rom", NULL); /* printk(BIOS_DEBUG, "IMGptr=%x\n", pVbiosImageInfo->ImagePtr); */ return pVbiosImageInfo->ImagePtr == NULL ? AGESA_WARNING : AGESA_SUCCESS; } diff --git a/src/drivers/amd/agesa/state_machine.c b/src/drivers/amd/agesa/state_machine.c index 606a66f..31db0b6 100644 --- a/src/drivers/amd/agesa/state_machine.c +++ b/src/drivers/amd/agesa/state_machine.c @@ -30,8 +30,7 @@ const void *agesa, *image; size_t file_size;
- agesa = cbfs_boot_map_with_leak((const char *)CONFIG_AGESA_CBFS_NAME, - CBFS_TYPE_RAW, &file_size); + agesa = cbfs_map((const char *)CONFIG_AGESA_CBFS_NAME, &file_size); if (agesa == NULL) return;
diff --git a/src/drivers/intel/fsp1_1/logo.c b/src/drivers/intel/fsp1_1/logo.c index feec434..bcaf157 100644 --- a/src/drivers/intel/fsp1_1/logo.c +++ b/src/drivers/intel/fsp1_1/logo.c @@ -13,8 +13,8 @@ if (logo_entry) { logo_buffer = cbmem_entry_start(logo_entry); if (logo_buffer) { - *logo_size = cbfs_boot_load_file("logo.bmp", (void *)logo_buffer, - 1 * MiB, CBFS_TYPE_RAW); + *logo_size = cbfs_load("logo.bmp", (void *)logo_buffer, + 1 * MiB); if (*logo_size) *logo_ptr = (UINT32)logo_buffer; } diff --git a/src/drivers/intel/fsp2_0/logo.c b/src/drivers/intel/fsp2_0/logo.c index 0d430a1..314616b 100644 --- a/src/drivers/intel/fsp2_0/logo.c +++ b/src/drivers/intel/fsp2_0/logo.c @@ -13,8 +13,8 @@ if (logo_entry) { logo_buffer = cbmem_entry_start(logo_entry); if (logo_buffer) { - *logo_size = cbfs_boot_load_file("logo.bmp", (void *)logo_buffer, - 1 * MiB, CBFS_TYPE_RAW); + *logo_size = cbfs_load("logo.bmp", (void *)logo_buffer, + 1 * MiB); if (*logo_size) *logo_ptr = (UINT32)logo_buffer; } diff --git a/src/drivers/intel/gma/opregion.c b/src/drivers/intel/gma/opregion.c index ea05124..4e9f94d 100644 --- a/src/drivers/intel/gma/opregion.c +++ b/src/drivers/intel/gma/opregion.c @@ -34,8 +34,7 @@
const char *filename = mainboard_vbt_filename();
- size_t file_size = cbfs_boot_load_file(filename, - vbt_data, sizeof(vbt_data), CBFS_TYPE_RAW); + size_t file_size = cbfs_load(filename, vbt_data, sizeof(vbt_data));
if (file_size == 0) return NULL; diff --git a/src/drivers/pc80/rtc/option.c b/src/drivers/pc80/rtc/option.c index d17c025..bb9d29a 100644 --- a/src/drivers/pc80/rtc/option.c +++ b/src/drivers/pc80/rtc/option.c @@ -237,8 +237,7 @@ size_t i;
if (CONFIG(TPM_MEASURED_BOOT) || cmos_need_reset) { - cmos_default = cbfs_boot_map_with_leak("cmos.default", - CBFS_COMPONENT_CMOS_DEFAULT, &length); + cmos_default = cbfs_map("cmos.default", &length);
if (!cmos_default || !cmos_need_reset) return; diff --git a/src/include/cbfs.h b/src/include/cbfs.h index 1b446ac..992b658 100644 --- a/src/include/cbfs.h +++ b/src/include/cbfs.h @@ -18,19 +18,22 @@ void *cbfs_boot_map_optionrom_revision(uint16_t vendor, uint16_t device, uint8_t rev); /* Locate file by name and optional type. Return 0 on success. < 0 on error. */ int cbfs_boot_locate(struct cbfsf *fh, const char *name, uint32_t *type); -/* Map file into memory leaking the mapping. Only should be used when - * leaking mappings are a no-op. Returns NULL on error, else returns - * the mapping and sets the size of the file. */ -void *cbfs_boot_map_with_leak(const char *name, uint32_t type, size_t *size); +/* Map file into memory, returning a pointer to the mapping or NULL on error. + If |size_out| is not NULL, it will pass out the size of the mapped file. + NOTE: Since this may return a direct pointer to memory-mapped hardware, + compressed files are NOT transparently decompressed (unlike cbfs_load()). */ +void *cbfs_map(const char *name, size_t *size_out); +/* Removes a mapping previously allocated with cbfs_map(). Should try to unmap + mappings in strict LIFO order where possible, since mapping backends often + don't support more complicated cases. */ +int cbfs_unmap(void *mapping); /* Locate file in a specific region of fmap. Return 0 on success. < 0 on error*/ int cbfs_locate_file_in_region(struct cbfsf *fh, const char *region_name, const char *name, uint32_t *type); -/* Load an arbitrary type file from CBFS into a buffer. Returns amount of - * loaded bytes on success or 0 on error. File will get decompressed as - * necessary. Same decompression requirements as - * cbfs_load_and_decompress(). */ -size_t cbfs_boot_load_file(const char *name, void *buf, size_t buf_size, - uint32_t type); +/* Load a file from CBFS into a buffer. Returns amount of loaded bytes on + success or 0 on error. File will get decompressed as necessary. Same + decompression requirements as cbfs_load_and_decompress(). */ +size_t cbfs_load(const char *name, void *buf, size_t buf_size); /* Load |in_size| bytes from |rdev| at |offset| to the |buffer_size| bytes * large |buffer|, decompressing it according to |compression| in the process. * Returns the decompressed file size, or 0 on error. diff --git a/src/lib/bootsplash.c b/src/lib/bootsplash.c index 050d713..0eb94dc 100644 --- a/src/lib/bootsplash.c +++ b/src/lib/bootsplash.c @@ -16,8 +16,7 @@ printk(BIOS_INFO, "Setting up bootsplash in %dx%d@%d\n", x_resolution, y_resolution, fb_resolution); struct jpeg_decdata *decdata; - unsigned char *jpeg = - cbfs_boot_map_with_leak("bootsplash.jpg", CBFS_TYPE_BOOTSPLASH, NULL); + unsigned char *jpeg = cbfs_map("bootsplash.jpg", NULL); if (!jpeg) { printk(BIOS_ERR, "Could not find bootsplash.jpg\n"); return; @@ -31,6 +30,7 @@ decdata = malloc(sizeof(*decdata)); int ret = jpeg_decode(jpeg, framebuffer, x_resolution, y_resolution, fb_resolution, decdata); + cbfs_unmap(jpeg); if (ret != 0) { printk(BIOS_ERR, "Bootsplash could not be decoded. jpeg_decode returned %d.\n", ret); diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c index 94dae62..493093e 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -70,22 +70,29 @@ return 0; }
-void *cbfs_boot_map_with_leak(const char *name, uint32_t type, size_t *size) +void *cbfs_map(const char *name, size_t *size_out) { struct cbfsf fh; size_t fsize;
- if (cbfs_boot_locate(&fh, name, &type)) + if (cbfs_boot_locate(&fh, name, NULL)) return NULL;
fsize = region_device_sz(&fh.data);
- if (size != NULL) - *size = fsize; + if (size_out != NULL) + *size_out = fsize;
return rdev_mmap(&fh.data, 0, fsize); }
+int cbfs_unmap(void *mapping) +{ + /* This works because munmap() only works on the root rdev and never + cares about which chained subregion something was mapped from. */ + return rdev_munmap(boot_device_ro(), mapping); +} + int cbfs_locate_file_in_region(struct cbfsf *fh, const char *region_name, const char *name, uint32_t *type) { @@ -262,7 +269,7 @@ tohex16(vendor, name + 3); tohex16(device, name + 8);
- return cbfs_boot_map_with_leak(name, CBFS_TYPE_OPTIONROM, NULL); + return cbfs_map(name, NULL); }
void *cbfs_boot_map_optionrom_revision(uint16_t vendor, uint16_t device, uint8_t rev) @@ -273,17 +280,16 @@ tohex16(device, name + 8); tohex8(rev, name + 13);
- return cbfs_boot_map_with_leak(name, CBFS_TYPE_OPTIONROM, NULL); + return cbfs_map(name, NULL); }
-size_t cbfs_boot_load_file(const char *name, void *buf, size_t buf_size, - uint32_t type) +size_t cbfs_load(const char *name, void *buf, size_t buf_size) { struct cbfsf fh; uint32_t compression_algo; size_t decompressed_size;
- if (cbfs_boot_locate(&fh, name, &type) < 0) + if (cbfs_boot_locate(&fh, name, NULL) < 0) return 0;
if (cbfsf_decompression_info(&fh, &compression_algo, diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c index 4cbf3c7..996e76e 100644 --- a/src/lib/coreboot_table.c +++ b/src/lib/coreboot_table.c @@ -455,8 +455,7 @@ #if CONFIG(USE_OPTION_TABLE) { struct cmos_option_table *option_table = - cbfs_boot_map_with_leak("cmos_layout.bin", - CBFS_COMPONENT_CMOS_LAYOUT, NULL); + cbfs_map("cmos_layout.bin", NULL); if (option_table) { struct lb_record *rec_dest = lb_new_record(head); /* Copy the option config table, it's already a diff --git a/src/lib/fw_config.c b/src/lib/fw_config.c index e17d40e..2f7186c 100644 --- a/src/lib/fw_config.c +++ b/src/lib/fw_config.c @@ -24,9 +24,8 @@
/* Look in CBFS to allow override of value. */ if (CONFIG(FW_CONFIG_SOURCE_CBFS)) { - if (cbfs_boot_load_file(CONFIG_CBFS_PREFIX "/fw_config", - &fw_config_value, sizeof(fw_config_value), - CBFS_TYPE_RAW) != sizeof(fw_config_value)) { + if (cbfs_load(CONFIG_CBFS_PREFIX "/fw_config", &fw_config_value, + sizeof(fw_config_value)) != sizeof(fw_config_value)) { printk(BIOS_WARNING, "%s: Could not get fw_config from CBFS\n", __func__); fw_config_value = 0; diff --git a/src/lib/spd_bin.c b/src/lib/spd_bin.c index 38edc5f..863218c 100644 --- a/src/lib/spd_bin.c +++ b/src/lib/spd_bin.c @@ -227,12 +227,11 @@ const int SPD_CRC_HI = 127; const int SPD_CRC_LO = 126;
- const char *spd_file; + char *spd_file; size_t spd_file_len = 0; size_t min_len = (idx + 1) * CONFIG_DIMM_SPD_SIZE;
- spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) printk(BIOS_EMERG, "file [spd.bin] not found in CBFS"); if (spd_file_len < min_len) @@ -242,6 +241,7 @@
memcpy(buf, spd_file + (idx * CONFIG_DIMM_SPD_SIZE), CONFIG_DIMM_SPD_SIZE); + cbfs_unmap(spd_file);
u16 crc = spd_ddr3_calc_crc(buf, CONFIG_DIMM_SPD_SIZE);
diff --git a/src/mainboard/apple/macbookair4_2/early_init.c b/src/mainboard/apple/macbookair4_2/early_init.c index 9da6702..a32298d 100644 --- a/src/mainboard/apple/macbookair4_2/early_init.c +++ b/src/mainboard/apple/macbookair4_2/early_init.c @@ -26,8 +26,7 @@ { void *spd_file; size_t spd_file_len = 0; - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (spd_file && spd_file_len >= 1024) { int i; for (i = 0; i < 4; i++) diff --git a/src/mainboard/dell/optiplex_9010/sch5545_ec.c b/src/mainboard/dell/optiplex_9010/sch5545_ec.c index d11ba97..8110963 100644 --- a/src/mainboard/dell/optiplex_9010/sch5545_ec.c +++ b/src/mainboard/dell/optiplex_9010/sch5545_ec.c @@ -442,8 +442,7 @@ uint32_t *ec_fw_file; size_t ec_fw_file_size;
- ec_fw_file = cbfs_boot_map_with_leak("sch5545_ecfw.bin", CBFS_TYPE_RAW, - &ec_fw_file_size); + ec_fw_file = cbfs_map("sch5545_ecfw.bin", &ec_fw_file_size);
if (!ec_fw_file || ec_fw_file_size != 0x1750) { printk(BIOS_ERR, "EC firmware file not found in CBFS!\n"); diff --git a/src/mainboard/google/asurada/sdram_configs.c b/src/mainboard/google/asurada/sdram_configs.c index 9efcb32..e1eb527 100644 --- a/src/mainboard/google/asurada/sdram_configs.c +++ b/src/mainboard/google/asurada/sdram_configs.c @@ -17,8 +17,7 @@ uint32_t ramcode = ram_code();
if (ramcode >= ARRAY_SIZE(sdram_configs) || - cbfs_boot_load_file(sdram_configs[ramcode], ¶ms, sizeof(params), - CBFS_TYPE_STRUCT) != sizeof(params)) + cbfs_load(sdram_configs[ramcode], ¶ms, sizeof(params)) != sizeof(params)) die("Cannot load SDRAM parameter file for RAM code: %#x", ramcode);
return ¶ms; diff --git a/src/mainboard/google/auron/variants/auron_paine/spd/spd.c b/src/mainboard/google/auron/variants/auron_paine/spd/spd.c index da00ad9..12a9d7c 100644 --- a/src/mainboard/google/auron/variants/auron_paine/spd/spd.c +++ b/src/mainboard/google/auron/variants/auron_paine/spd/spd.c @@ -88,7 +88,7 @@ spd_bits[1], spd_gpio[1], spd_bits[0], spd_gpio[0]);
- spd_file = cbfs_boot_map_with_leak("spd.bin", 0xab, &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/auron/variants/auron_yuna/spd/spd.c b/src/mainboard/google/auron/variants/auron_yuna/spd/spd.c index da00ad9..12a9d7c 100644 --- a/src/mainboard/google/auron/variants/auron_yuna/spd/spd.c +++ b/src/mainboard/google/auron/variants/auron_yuna/spd/spd.c @@ -88,7 +88,7 @@ spd_bits[1], spd_gpio[1], spd_bits[0], spd_gpio[0]);
- spd_file = cbfs_boot_map_with_leak("spd.bin", 0xab, &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/auron/variants/buddy/variant.c b/src/mainboard/google/auron/variants/buddy/variant.c index 81bb828..2ffc38a 100644 --- a/src/mainboard/google/auron/variants/buddy/variant.c +++ b/src/mainboard/google/auron/variants/buddy/variant.c @@ -129,9 +129,7 @@ search_length = region_device_sz(&rdev); } } else { - search_address = cbfs_boot_map_with_leak("vpd.bin", - CBFS_TYPE_RAW, - &search_length); + search_address = cbfs_map("vpd.bin", &search_length); }
if (search_address == NULL) diff --git a/src/mainboard/google/auron/variants/gandof/spd/spd.c b/src/mainboard/google/auron/variants/gandof/spd/spd.c index da00ad9..12a9d7c 100644 --- a/src/mainboard/google/auron/variants/gandof/spd/spd.c +++ b/src/mainboard/google/auron/variants/gandof/spd/spd.c @@ -88,7 +88,7 @@ spd_bits[1], spd_gpio[1], spd_bits[0], spd_gpio[0]);
- spd_file = cbfs_boot_map_with_leak("spd.bin", 0xab, &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/auron/variants/lulu/spd/spd.c b/src/mainboard/google/auron/variants/lulu/spd/spd.c index 750470e..905e196 100644 --- a/src/mainboard/google/auron/variants/lulu/spd/spd.c +++ b/src/mainboard/google/auron/variants/lulu/spd/spd.c @@ -92,7 +92,7 @@ spd_bits[1], spd_gpio[1], spd_bits[0], spd_gpio[0]);
- spd_file = cbfs_boot_map_with_leak("spd.bin", 0xab, &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/auron/variants/samus/spd/spd.c b/src/mainboard/google/auron/variants/samus/spd/spd.c index 4684d86..4cad474 100644 --- a/src/mainboard/google/auron/variants/samus/spd/spd.c +++ b/src/mainboard/google/auron/variants/samus/spd/spd.c @@ -88,7 +88,7 @@ spd_bits[3], spd_gpio[3], spd_bits[2], spd_gpio[2], spd_bits[1], spd_gpio[1], spd_bits[0], spd_gpio[0]);
- spd_file = cbfs_boot_map_with_leak("spd.bin", 0xab, &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/beltino/lan.c b/src/mainboard/google/beltino/lan.c index c14a1e4..d9df5a1 100644 --- a/src/mainboard/google/beltino/lan.c +++ b/src/mainboard/google/beltino/lan.c @@ -110,9 +110,7 @@ search_length = region_device_sz(&rdev); } } else { - search_address = cbfs_boot_map_with_leak("vpd.bin", - CBFS_TYPE_RAW, - &search_length); + search_address = cbfs_map("vpd.bin", &search_length); }
if (search_address == NULL) diff --git a/src/mainboard/google/butterfly/mainboard.c b/src/mainboard/google/butterfly/mainboard.c index d2e2aa5..d9cf1b9 100644 --- a/src/mainboard/google/butterfly/mainboard.c +++ b/src/mainboard/google/butterfly/mainboard.c @@ -180,8 +180,7 @@ } } } else { - vpd_file = cbfs_boot_map_with_leak("vpd.bin", CBFS_TYPE_RAW, - &search_length); + vpd_file = cbfs_map("vpd.bin", &search_length); if (vpd_file) { search_address = (unsigned long)vpd_file; } else { diff --git a/src/mainboard/google/cyan/spd/spd.c b/src/mainboard/google/cyan/spd/spd.c index 1c08d90..21a298e 100644 --- a/src/mainboard/google/cyan/spd/spd.c +++ b/src/mainboard/google/cyan/spd/spd.c @@ -35,8 +35,7 @@ int spd_index = 0;
/* Find the SPD data in CBFS. */ - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/eve/spd/spd.c b/src/mainboard/google/eve/spd/spd.c index 330ea52..e9405f0 100644 --- a/src/mainboard/google/eve/spd/spd.c +++ b/src/mainboard/google/eve/spd/spd.c @@ -82,8 +82,7 @@ printk(BIOS_INFO, "SPD index %d\n", spd_index);
/* Load SPD data from CBFS */ - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/glados/spd/spd.c b/src/mainboard/google/glados/spd/spd.c index 627dc3f..9bfb202 100644 --- a/src/mainboard/google/glados/spd/spd.c +++ b/src/mainboard/google/glados/spd/spd.c @@ -79,8 +79,7 @@ printk(BIOS_INFO, "SPD index %d\n", spd_index);
/* Load SPD data from CBFS */ - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/gru/sdram_configs.c b/src/mainboard/google/gru/sdram_configs.c index 87a5009..2aceb9f 100644 --- a/src/mainboard/google/gru/sdram_configs.c +++ b/src/mainboard/google/gru/sdram_configs.c @@ -53,8 +53,7 @@ if (ramcode >= ARRAY_SIZE(sdram_configs) || !snprintf(config_file, sizeof(config_file), "%s-%d", sdram_configs[ramcode], get_sdram_target_mhz()) || - (cbfs_boot_load_file(config_file, ¶ms, sizeof(params), - CBFS_TYPE_STRUCT) != sizeof(params))) + (cbfs_load(config_file, ¶ms, sizeof(params)) != sizeof(params))) die("Cannot load SDRAM parameter file!");
return ¶ms; diff --git a/src/mainboard/google/jecht/lan.c b/src/mainboard/google/jecht/lan.c index 3d19f99..4dedb56 100644 --- a/src/mainboard/google/jecht/lan.c +++ b/src/mainboard/google/jecht/lan.c @@ -110,9 +110,7 @@ search_length = region_device_sz(&rdev); } } else { - search_address = cbfs_boot_map_with_leak("vpd.bin", - CBFS_TYPE_RAW, - &search_length); + search_address = cbfs_map("vpd.bin", &search_length); }
if (search_address == NULL) diff --git a/src/mainboard/google/kahlee/variants/baseboard/mainboard.c b/src/mainboard/google/kahlee/variants/baseboard/mainboard.c index 95f0a8d..860190a 100644 --- a/src/mainboard/google/kahlee/variants/baseboard/mainboard.c +++ b/src/mainboard/google/kahlee/variants/baseboard/mainboard.c @@ -89,9 +89,7 @@ if (manuf) return manuf;
- if (cbfs_boot_load_file("oem.bin", oem_bin_data, - sizeof(oem_bin_data) - 1, - CBFS_TYPE_RAW)) + if (cbfs_load("oem.bin", oem_bin_data, sizeof(oem_bin_data) - 1)) manuf = &oem_bin_data[0]; else manuf = CONFIG_MAINBOARD_SMBIOS_MANUFACTURER; diff --git a/src/mainboard/google/kahlee/variants/nuwani/mainboard.c b/src/mainboard/google/kahlee/variants/nuwani/mainboard.c index df31c6f..ce98d62 100644 --- a/src/mainboard/google/kahlee/variants/nuwani/mainboard.c +++ b/src/mainboard/google/kahlee/variants/nuwani/mainboard.c @@ -101,9 +101,7 @@ if (manuf) return manuf;
- if (cbfs_boot_load_file("oem.bin", oem_bin_data, - sizeof(oem_bin_data) - 1, - CBFS_TYPE_RAW)) + if (cbfs_load("oem.bin", oem_bin_data, sizeof(oem_bin_data) - 1)) manuf = &oem_bin_data[0]; else manuf = CONFIG_MAINBOARD_SMBIOS_MANUFACTURER; diff --git a/src/mainboard/google/kahlee/variants/treeya/mainboard.c b/src/mainboard/google/kahlee/variants/treeya/mainboard.c index df31c6f..ce98d62 100644 --- a/src/mainboard/google/kahlee/variants/treeya/mainboard.c +++ b/src/mainboard/google/kahlee/variants/treeya/mainboard.c @@ -101,9 +101,7 @@ if (manuf) return manuf;
- if (cbfs_boot_load_file("oem.bin", oem_bin_data, - sizeof(oem_bin_data) - 1, - CBFS_TYPE_RAW)) + if (cbfs_load("oem.bin", oem_bin_data, sizeof(oem_bin_data) - 1)) manuf = &oem_bin_data[0]; else manuf = CONFIG_MAINBOARD_SMBIOS_MANUFACTURER; diff --git a/src/mainboard/google/kukui/mainboard.c b/src/mainboard/google/kukui/mainboard.c index cbcb5da..4220810d 100644 --- a/src/mainboard/google/kukui/mainboard.c +++ b/src/mainboard/google/kukui/mainboard.c @@ -112,8 +112,7 @@ return NULL;
snprintf(cbfs_name, sizeof(cbfs_name), "panel-%s", desc->name); - if (cbfs_boot_load_file(cbfs_name, buffer.raw, sizeof(buffer), - CBFS_TYPE_STRUCT)) + if (cbfs_load(cbfs_name, buffer.raw, sizeof(buffer))) desc->s = &buffer.s; else printk(BIOS_ERR, "Missing %s in CBFS.\n", cbfs_name); diff --git a/src/mainboard/google/kukui/sdram_configs.c b/src/mainboard/google/kukui/sdram_configs.c index 5239587..57f5e6e 100644 --- a/src/mainboard/google/kukui/sdram_configs.c +++ b/src/mainboard/google/kukui/sdram_configs.c @@ -43,8 +43,7 @@ if (ramcode < ARRAY_SIZE(sdram_configs)) name = sdram_configs[ramcode];
- if (!name || cbfs_boot_load_file(name, ¶ms, sizeof(params), - CBFS_TYPE_STRUCT) != sizeof(params)) + if (!name || cbfs_load(name, ¶ms, sizeof(params)) != sizeof(params)) die("Cannot load SDRAM parameter file for RAM code %#02x: %s!", ramcode, name ? name : "unknown");
diff --git a/src/mainboard/google/link/early_init.c b/src/mainboard/google/link/early_init.c index f3da77c..de8f749 100644 --- a/src/mainboard/google/link/early_init.c +++ b/src/mainboard/google/link/early_init.c @@ -66,8 +66,7 @@ int spd_index = get_gpios(gpio_vector);
printk(BIOS_DEBUG, "spd index %d\n", spd_index); - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/poppy/romstage.c b/src/mainboard/google/poppy/romstage.c index 0c1fc02..7fd4409 100644 --- a/src/mainboard/google/poppy/romstage.c +++ b/src/mainboard/google/poppy/romstage.c @@ -112,8 +112,7 @@ printk(BIOS_INFO, "SPD index %d\n", spd_index);
/* Load SPD data from CBFS */ - spd_file = cbfs_boot_map_with_leak(spd_bin, CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map(spd_bin, &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/poppy/variants/nami/mainboard.c b/src/mainboard/google/poppy/variants/nami/mainboard.c index 8d5d0c4..1387716 100644 --- a/src/mainboard/google/poppy/variants/nami/mainboard.c +++ b/src/mainboard/google/poppy/variants/nami/mainboard.c @@ -155,9 +155,8 @@ if (oem_id == OEM_UNKNOWN) return CONFIG_MAINBOARD_SMBIOS_MANUFACTURER;
- oem_data_size = cbfs_boot_load_file("oem.bin", oem_bin_data, - sizeof(oem_bin_data), - CBFS_TYPE_RAW); + oem_data_size = cbfs_load("oem.bin", oem_bin_data, + sizeof(oem_bin_data));
while ((curr < oem_data_size) && ((oem_data_size - curr) >= sizeof(*oem_entry))) { diff --git a/src/mainboard/google/rambi/romstage.c b/src/mainboard/google/rambi/romstage.c index 6487f43..28496b1 100644 --- a/src/mainboard/google/rambi/romstage.c +++ b/src/mainboard/google/rambi/romstage.c @@ -48,8 +48,7 @@ void *spd_file; size_t spd_fsize;
- spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_fsize); + spd_file = cbfs_map("spd.bin", &spd_fsize); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/rambi/variants/ninja/lan.c b/src/mainboard/google/rambi/variants/ninja/lan.c index e5688df..1304071 100644 --- a/src/mainboard/google/rambi/variants/ninja/lan.c +++ b/src/mainboard/google/rambi/variants/ninja/lan.c @@ -109,9 +109,7 @@ search_length = region_device_sz(&rdev); } } else { - search_address = cbfs_boot_map_with_leak("vpd.bin", - CBFS_TYPE_RAW, - &search_length); + search_address = cbfs_map("vpd.bin", &search_length); }
if (search_address == NULL) diff --git a/src/mainboard/google/rambi/variants/sumo/lan.c b/src/mainboard/google/rambi/variants/sumo/lan.c index 53bd4fb..29bc0fe 100644 --- a/src/mainboard/google/rambi/variants/sumo/lan.c +++ b/src/mainboard/google/rambi/variants/sumo/lan.c @@ -109,9 +109,7 @@ search_length = region_device_sz(&rdev); } } else { - search_address = cbfs_boot_map_with_leak("vpd.bin", - CBFS_TYPE_RAW, - &search_length); + search_address = cbfs_map("vpd.bin", &search_length); }
if (search_address == NULL) diff --git a/src/mainboard/google/slippy/variants/falco/romstage.c b/src/mainboard/google/slippy/variants/falco/romstage.c index eba4a8b..516b26c 100644 --- a/src/mainboard/google/slippy/variants/falco/romstage.c +++ b/src/mainboard/google/slippy/variants/falco/romstage.c @@ -21,8 +21,7 @@ size_t spd_len = sizeof(peid->spd_data[0]);
printk(BIOS_DEBUG, "SPD index %d\n", spd_index); - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/slippy/variants/leon/romstage.c b/src/mainboard/google/slippy/variants/leon/romstage.c index 2b1b5ca..e24dcb9 100644 --- a/src/mainboard/google/slippy/variants/leon/romstage.c +++ b/src/mainboard/google/slippy/variants/leon/romstage.c @@ -20,8 +20,7 @@ size_t spd_len = sizeof(peid->spd_data[0]);
printk(BIOS_DEBUG, "SPD index %d\n", spd_index); - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/slippy/variants/peppy/romstage.c b/src/mainboard/google/slippy/variants/peppy/romstage.c index 230595e..92e1e8d 100644 --- a/src/mainboard/google/slippy/variants/peppy/romstage.c +++ b/src/mainboard/google/slippy/variants/peppy/romstage.c @@ -24,8 +24,7 @@ uint32_t board_version = PEPPY_BOARD_VERSION_PROTO;
printk(BIOS_DEBUG, "SPD index %d\n", spd_index); - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/google/slippy/variants/wolf/romstage.c b/src/mainboard/google/slippy/variants/wolf/romstage.c index 405e86a..a0b5055 100644 --- a/src/mainboard/google/slippy/variants/wolf/romstage.c +++ b/src/mainboard/google/slippy/variants/wolf/romstage.c @@ -21,8 +21,7 @@ size_t spd_len = sizeof(peid->spd_data[0]);
printk(BIOS_DEBUG, "SPD index %d\n", spd_index); - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/hp/snb_ivb_laptops/variants/revolve_810_g1/early_init.c b/src/mainboard/hp/snb_ivb_laptops/variants/revolve_810_g1/early_init.c index a7c894b..65a1819 100644 --- a/src/mainboard/hp/snb_ivb_laptops/variants/revolve_810_g1/early_init.c +++ b/src/mainboard/hp/snb_ivb_laptops/variants/revolve_810_g1/early_init.c @@ -39,8 +39,7 @@ { /* C1S0 is a soldered RAM with no real SPD. Use stored SPD. */ size_t spd_file_len = 0; - void *spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + void *spd_file = cbfs_map("spd.bin", &spd_file_len);
if (!spd_file || spd_file_len < sizeof(spd_raw_data)) die("SPD data for C1S0 not found."); diff --git a/src/mainboard/intel/harcuvar/spd/spd.c b/src/mainboard/intel/harcuvar/spd/spd.c index a70bb5f..a66c10b 100644 --- a/src/mainboard/intel/harcuvar/spd/spd.c +++ b/src/mainboard/intel/harcuvar/spd/spd.c @@ -15,8 +15,7 @@
spd_index = 0;
- spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/intel/kunimitsu/spd/spd_util.c b/src/mainboard/intel/kunimitsu/spd/spd_util.c index 71643be..8674512 100644 --- a/src/mainboard/intel/kunimitsu/spd/spd_util.c +++ b/src/mainboard/intel/kunimitsu/spd/spd_util.c @@ -68,8 +68,7 @@ printk(BIOS_INFO, "SPD index %d\n", spd_index);
/* Load SPD data from CBFS */ - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/lenovo/s230u/early_init.c b/src/mainboard/lenovo/s230u/early_init.c index 155b02e..434b58c 100644 --- a/src/mainboard/lenovo/s230u/early_init.c +++ b/src/mainboard/lenovo/s230u/early_init.c @@ -70,8 +70,7 @@ spd_index, mainboard_spd_names[spd_index]);
/* C0S0 is a soldered RAM with no real SPD. Use stored SPD. */ - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len);
if (!spd_file || spd_file_len < SPD_LEN * spd_index + SPD_LEN) die("SPD data not found."); diff --git a/src/mainboard/lenovo/t430s/variants/t431s/romstage.c b/src/mainboard/lenovo/t430s/variants/t431s/romstage.c index 60a1b01..54236a1 100644 --- a/src/mainboard/lenovo/t430s/variants/t431s/romstage.c +++ b/src/mainboard/lenovo/t430s/variants/t431s/romstage.c @@ -28,8 +28,7 @@ { /* C1S0 is a soldered RAM with no real SPD. Use stored SPD. */ size_t spd_file_len = 0; - void *spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + void *spd_file = cbfs_map("spd.bin", &spd_file_len);
if (!spd_file || spd_file_len < sizeof(spd_raw_data)) die("SPD data for C1S0 not found."); diff --git a/src/mainboard/lenovo/x1_carbon_gen1/early_init.c b/src/mainboard/lenovo/x1_carbon_gen1/early_init.c index f49a59f8..6f18fee 100644 --- a/src/mainboard/lenovo/x1_carbon_gen1/early_init.c +++ b/src/mainboard/lenovo/x1_carbon_gen1/early_init.c @@ -32,8 +32,7 @@ size_t spd_file_len;
printk(BIOS_DEBUG, "spd index %d\n", spd_index); - spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_file = cbfs_map("spd.bin", &spd_file_len); if (!spd_file) die("SPD data not found.");
diff --git a/src/mainboard/samsung/lumpy/early_init.c b/src/mainboard/samsung/lumpy/early_init.c index ad4ddb9..90a1764 100644 --- a/src/mainboard/samsung/lumpy/early_init.c +++ b/src/mainboard/samsung/lumpy/early_init.c @@ -104,8 +104,7 @@ break; }
- spd_data = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, - &spd_file_len); + spd_data = cbfs_map("spd.bin", &spd_file_len); if (!spd_data) die("SPD data not found."); if (spd_file_len < (spd_index + 1) * 256) diff --git a/src/mainboard/sifive/hifive-unleashed/fixup_fdt.c b/src/mainboard/sifive/hifive-unleashed/fixup_fdt.c index 38492ac..dda71b6 100644 --- a/src/mainboard/sifive/hifive-unleashed/fixup_fdt.c +++ b/src/mainboard/sifive/hifive-unleashed/fixup_fdt.c @@ -72,7 +72,7 @@ struct device_tree *tree;
/* load flat dt from cbfs */ - fdt_rom = cbfs_boot_map_with_leak("fallback/DTB", CBFS_TYPE_RAW, NULL); + fdt_rom = cbfs_map("fallback/DTB", NULL);
if (fdt_rom == NULL) { printk(BIOS_ERR, "Unable to load fallback/DTB from CBFS\n"); diff --git a/src/northbridge/intel/sandybridge/raminit_mrc.c b/src/northbridge/intel/sandybridge/raminit_mrc.c index 8df7d1b..d6d39a2 100644 --- a/src/northbridge/intel/sandybridge/raminit_mrc.c +++ b/src/northbridge/intel/sandybridge/raminit_mrc.c @@ -148,7 +148,7 @@ pei_data->tx_byte = do_putchar;
/* Locate and call UEFI System Agent binary. */ - entry = cbfs_boot_map_with_leak("mrc.bin", CBFS_TYPE_MRC, NULL); + entry = cbfs_map("mrc.bin", NULL); if (entry) { int rv; rv = entry (pei_data); diff --git a/src/security/intel/stm/StmPlatformSmm.c b/src/security/intel/stm/StmPlatformSmm.c index eb9a0bb..abd7667 100644 --- a/src/security/intel/stm/StmPlatformSmm.c +++ b/src/security/intel/stm/StmPlatformSmm.c @@ -35,8 +35,7 @@
memset((void *)mseg_base, 0, CONFIG_MSEG_SIZE); // clear the mseg
- stm_image_size = cbfs_boot_load_file("stm.bin", mseg_base, - stm_buffer_size, CBFS_TYPE_RAW); + stm_image_size = cbfs_load("stm.bin", mseg_base, stm_buffer_size); printk(BIOS_DEBUG, "STM:loaded into mseg: 0x%p size: %u\n", mseg_base, stm_image_size); /* status is number of bytes loaded */ diff --git a/src/security/intel/txt/ramstage.c b/src/security/intel/txt/ramstage.c index 76eeaaf..81d2dd1 100644 --- a/src/security/intel/txt/ramstage.c +++ b/src/security/intel/txt/ramstage.c @@ -221,10 +221,9 @@ data.bdr.no_logical_procs = dev_count_cpu();
void *sinit_base = (void *)(uintptr_t)read64((void *)TXT_SINIT_BASE); - data.bdr.bios_sinit_size = cbfs_boot_load_file(CONFIG_INTEL_TXT_CBFS_SINIT_ACM, - sinit_base, - read64((void *)TXT_SINIT_SIZE), - CBFS_TYPE_RAW); + data.bdr.bios_sinit_size = cbfs_load(CONFIG_INTEL_TXT_CBFS_SINIT_ACM, + sinit_base, + read64((void *)TXT_SINIT_SIZE));
if (data.bdr.bios_sinit_size) { printk(BIOS_INFO, "TEE-TXT: Placing SINIT ACM in memory.\n"); @@ -277,9 +276,7 @@ data.heap_acm.num_acms = 1; } data.heap_acm.acm_addrs[0] = - (uintptr_t)cbfs_boot_map_with_leak(CONFIG_INTEL_TXT_CBFS_BIOS_ACM, - CBFS_TYPE_RAW, - NULL); + (uintptr_t)cbfs_map(CONFIG_INTEL_TXT_CBFS_BIOS_ACM, NULL); /* Extended elements - End marker */ data.end.type = HEAP_EXTDATA_TYPE_END; data.end.size = sizeof(data.end); diff --git a/src/security/vboot/ec_sync.c b/src/security/vboot/ec_sync.c index 1fd7e75..7e3d29a 100644 --- a/src/security/vboot/ec_sync.c +++ b/src/security/vboot/ec_sync.c @@ -385,7 +385,9 @@ { size_t size; const char *filename = EC_HASH_FILENAME(select); - const uint8_t *file = cbfs_boot_map_with_leak(filename, CBFS_TYPE_RAW, &size); + + /* vboot has no API to return this memory, so must permanently leak a mapping here. */ + const uint8_t *file = cbfs_map(filename, &size);
if (file == NULL) return VB2_ERROR_UNKNOWN; diff --git a/src/soc/amd/common/block/pi/def_callouts.c b/src/soc/amd/common/block/pi/def_callouts.c index 56ce995..2ee7f46 100644 --- a/src/soc/amd/common/block/pi/def_callouts.c +++ b/src/soc/amd/common/block/pi/def_callouts.c @@ -136,9 +136,8 @@ GFX_VBIOS_IMAGE_INFO *pVbiosImageInfo;
pVbiosImageInfo = (GFX_VBIOS_IMAGE_INFO *)ConfigPrt; - pVbiosImageInfo->ImagePtr = cbfs_boot_map_with_leak( - "pci"CONFIG_VGA_BIOS_ID".rom", - CBFS_TYPE_OPTIONROM, NULL); + pVbiosImageInfo->ImagePtr = cbfs_map( + "pci"CONFIG_VGA_BIOS_ID".rom", NULL); printk(BIOS_DEBUG, "%s: IMGptr=%p\n", __func__, pVbiosImageInfo->ImagePtr); return pVbiosImageInfo->ImagePtr ? AGESA_SUCCESS : AGESA_WARNING; diff --git a/src/soc/amd/picasso/update_microcode.c b/src/soc/amd/picasso/update_microcode.c index 8f3d3e2..47a9835 100644 --- a/src/soc/amd/picasso/update_microcode.c +++ b/src/soc/amd/picasso/update_microcode.c @@ -80,8 +80,7 @@ size_t ucode_len; uint16_t equivalent_processor_rev_id = get_equivalent_processor_rev_id();
- ucode = cbfs_boot_map_with_leak("cpu_microcode_blob.bin", - CBFS_TYPE_MICROCODE, &ucode_len); + ucode = cbfs_map("cpu_microcode_blob.bin", &ucode_len); if (!ucode) { printk(BIOS_WARNING, "cpu_microcode_blob.bin not found. Skipping updates.\n"); return; diff --git a/src/soc/cavium/cn81xx/soc.c b/src/soc/cavium/cn81xx/soc.c index 3545d55..368e925 100644 --- a/src/soc/cavium/cn81xx/soc.c +++ b/src/soc/cavium/cn81xx/soc.c @@ -334,8 +334,7 @@
size_t size = 0;
- void *ptr = cbfs_boot_map_with_leak("sff8104-linux.dtb", - CBFS_TYPE_RAW, &size); + void *ptr = cbfs_map("sff8104-linux.dtb", &size); if (ptr) memcpy(_sff8104, ptr, size); /* Point to devicetree in secure memory */ diff --git a/src/soc/intel/baytrail/romstage/raminit.c b/src/soc/intel/baytrail/romstage/raminit.c index 9a67c22..10ad932 100644 --- a/src/soc/intel/baytrail/romstage/raminit.c +++ b/src/soc/intel/baytrail/romstage/raminit.c @@ -153,7 +153,7 @@ }
/* Determine if mrc.bin is in the cbfs. */ - if (cbfs_boot_map_with_leak("mrc.bin", CBFS_TYPE_MRC, NULL) == NULL) { + if (cbfs_map("mrc.bin", NULL) == NULL) { printk(BIOS_DEBUG, "Couldn't find mrc.bin\n"); return; } diff --git a/src/soc/intel/common/mma.c b/src/soc/intel/common/mma.c index a2ccaf5..e015567 100644 --- a/src/soc/intel/common/mma.c +++ b/src/soc/intel/common/mma.c @@ -113,7 +113,7 @@ printk(BIOS_DEBUG, "MMA: Entry %s\n", __func__);
if (cbfs_locate_file_in_region(&metadata_fh, MMA_CBFS_REGION, - MMA_TEST_METADATA_FILENAME, &mma_type)) { + MMA_TEST_METADATA_FILENAME)) { printk(BIOS_DEBUG, "MMA: Failed to locate %s\n", MMA_TEST_METADATA_FILENAME); return -1; @@ -154,7 +154,7 @@ test_filename, test_param_filename);
if (cbfs_locate_file_in_region(&test_content_fh, MMA_CBFS_REGION, - test_filename, &efi_type)) { + test_filename)) { printk(BIOS_DEBUG, "MMA: Failed to locate %s\n", test_filename); return -1; @@ -163,7 +163,7 @@ cbfs_file_data(&mma_cfg->test_content, &test_content_fh);
if (cbfs_locate_file_in_region(&test_param_fh, MMA_CBFS_REGION, - test_param_filename, &mma_type)) { + test_param_filename)) { printk(BIOS_DEBUG, "MMA: Failed to locate %s\n", test_param_filename); return -1; diff --git a/src/soc/intel/denverton_ns/chip.c b/src/soc/intel/denverton_ns/chip.c index 3bade11..9cf3bfb 100644 --- a/src/soc/intel/denverton_ns/chip.c +++ b/src/soc/intel/denverton_ns/chip.c @@ -84,8 +84,7 @@ const struct microcode *microcode_file; size_t microcode_len;
- microcode_file = cbfs_boot_map_with_leak("cpu_microcode_blob.bin", - CBFS_TYPE_MICROCODE, µcode_len); + microcode_file = cbfs_map("cpu_microcode_blob.bin", µcode_len);
if ((microcode_file != NULL) && (microcode_len != 0)) { /* Update CPU Microcode patch base address/size */ diff --git a/src/soc/intel/xeon_sp/skx/chip.c b/src/soc/intel/xeon_sp/skx/chip.c index 7fe330b..0505ea7 100644 --- a/src/soc/intel/xeon_sp/skx/chip.c +++ b/src/soc/intel/xeon_sp/skx/chip.c @@ -59,8 +59,7 @@ const struct microcode *microcode_file; size_t microcode_len;
- microcode_file = cbfs_boot_map_with_leak("cpu_microcode_blob.bin", - CBFS_TYPE_MICROCODE, µcode_len); + microcode_file = cbfs_map("cpu_microcode_blob.bin", µcode_len);
if ((microcode_file != NULL) && (microcode_len != 0)) { /* Update CPU Microcode patch base address/size */ diff --git a/src/soc/mediatek/mt8183/spm.c b/src/soc/mediatek/mt8183/spm.c index 01c6a2f..e35fc57 100644 --- a/src/soc/mediatek/mt8183/spm.c +++ b/src/soc/mediatek/mt8183/spm.c @@ -231,8 +231,7 @@
stopwatch_init(&sw);
- size_t file_size = cbfs_boot_load_file(file_name, spm_bin, - sizeof(spm_bin), CBFS_TYPE_RAW); + size_t file_size = cbfs_load(file_name, spm_bin, sizeof(spm_bin));
if (file_size == 0) { printk(BIOS_ERR, "SPM binary %s not found\n", file_name); diff --git a/src/soc/mediatek/mt8183/sspm.c b/src/soc/mediatek/mt8183/sspm.c index efcf545..1a4ba9e 100644 --- a/src/soc/mediatek/mt8183/sspm.c +++ b/src/soc/mediatek/mt8183/sspm.c @@ -13,10 +13,7 @@ void sspm_init(void) { const char *file_name = "sspm.bin"; - size_t fw_size = cbfs_boot_load_file(file_name, - sspm_bin, - sizeof(sspm_bin), - CBFS_TYPE_RAW); + size_t fw_size = cbfs_load(file_name, sspm_bin, sizeof(sspm_bin));
if (fw_size == 0) die("SSPM file :sspm.bin not found."); diff --git a/src/soc/qualcomm/ipq40xx/blobs_init.c b/src/soc/qualcomm/ipq40xx/blobs_init.c index 8cd9fc7..60e4f0d 100644 --- a/src/soc/qualcomm/ipq40xx/blobs_init.c +++ b/src/soc/qualcomm/ipq40xx/blobs_init.c @@ -22,8 +22,7 @@ void *blob_dest; size_t blob_size;
- blob_mbn = cbfs_boot_map_with_leak(file_name, CBFS_TYPE_RAW, - &blob_size); + blob_mbn = cbfs_map(file_name, &blob_size); if (!blob_mbn) return NULL;
diff --git a/src/soc/qualcomm/ipq806x/blobs_init.c b/src/soc/qualcomm/ipq806x/blobs_init.c index 89c26b5..15068a5 100644 --- a/src/soc/qualcomm/ipq806x/blobs_init.c +++ b/src/soc/qualcomm/ipq806x/blobs_init.c @@ -18,8 +18,7 @@ void *blob_dest; size_t blob_size;
- blob_mbn = cbfs_boot_map_with_leak(file_name, CBFS_TYPE_RAW, - &blob_size); + blob_mbn = cbfs_map(file_name, &blob_size); if (!blob_mbn) return NULL;
diff --git a/src/soc/qualcomm/sc7180/qclib.c b/src/soc/qualcomm/sc7180/qclib.c index 274d906..2bff80d 100644 --- a/src/soc/qualcomm/sc7180/qclib.c +++ b/src/soc/qualcomm/sc7180/qclib.c @@ -11,15 +11,15 @@ size_t size;
/* Attempt to load PMICCFG Blob */ - size = cbfs_boot_load_file(CONFIG_CBFS_PREFIX "/pmiccfg", - _pmic, REGION_SIZE(pmic), CBFS_TYPE_RAW); + size = cbfs_load(CONFIG_CBFS_PREFIX "/pmiccfg", + _pmic, REGION_SIZE(pmic)); if (!size) return -1; qclib_add_if_table_entry(QCLIB_TE_PMIC_SETTINGS, _pmic, size, 0);
/* Attempt to load DCB Blob */ - size = cbfs_boot_load_file(CONFIG_CBFS_PREFIX "/dcb", - _dcb, REGION_SIZE(dcb), CBFS_TYPE_RAW); + size = cbfs_load(CONFIG_CBFS_PREFIX "/dcb", + _dcb, REGION_SIZE(dcb)); if (!size) return -1; qclib_add_if_table_entry(QCLIB_TE_DCB_SETTINGS, _dcb, size, 0); diff --git a/src/soc/qualcomm/sc7180/qupv3_config.c b/src/soc/qualcomm/sc7180/qupv3_config.c index 8cd9670..4bc9936 100644 --- a/src/soc/qualcomm/sc7180/qupv3_config.c +++ b/src/soc/qualcomm/sc7180/qupv3_config.c @@ -27,10 +27,9 @@ die("*ERROR* * INVALID PROTOCOL ***\n");
if (!fw_list[protocol]) { - fw_list[protocol] = cbfs_boot_map_with_leak(filename[protocol], - CBFS_TYPE_RAW, NULL); + fw_list[protocol] = cbfs_map(filename[protocol], NULL); if (!fw_list[protocol]) - die("*ERROR* * cbfs_boot_map_with_leak failed ***\n"); + die("*ERROR* * cbfs_map() failed ***\n"); }
hdr = fw_list[protocol]; diff --git a/src/vendorcode/eltan/security/mboot/mboot.c b/src/vendorcode/eltan/security/mboot/mboot.c index d24a39f..575c5fc 100644 --- a/src/vendorcode/eltan/security/mboot/mboot.c +++ b/src/vendorcode/eltan/security/mboot/mboot.c @@ -234,7 +234,7 @@ size_t size;
printk(BIOS_DEBUG, "%s: Measure %s\n", __func__, name); - base = cbfs_boot_map_with_leak(name, type, &size); + base = cbfs_map(name, &size);
if (base == NULL) { printk(BIOS_DEBUG, "%s: CBFS locate fail: %s\n", __func__, name); diff --git a/src/vendorcode/eltan/security/verified_boot/vboot_check.c b/src/vendorcode/eltan/security/verified_boot/vboot_check.c index 044f2d4..824570e 100644 --- a/src/vendorcode/eltan/security/verified_boot/vboot_check.c +++ b/src/vendorcode/eltan/security/verified_boot/vboot_check.c @@ -33,7 +33,7 @@
sd = vb2_get_sd(ctx);
- buffer = cbfs_boot_map_with_leak(RSA_PUBLICKEY_FILE_NAME, CBFS_TYPE_RAW, &size); + buffer = cbfs_map(RSA_PUBLICKEY_FILE_NAME, &size); if (!buffer || !size) { printk(BIOS_ERR, "ERROR: Public key not found!\n"); goto fail; @@ -71,7 +71,7 @@ pre->flags = VB2_FIRMWARE_PREAMBLE_DISALLOW_HWCRYPTO;
/* Fill body_signature (vb2_structure). RSA2048 key is used */ - cbfs_boot_map_with_leak("oemmanifest.bin", CBFS_TYPE_RAW, &size); + cbfs_map("oemmanifest.bin", &size); if (size != ((CONFIG_VENDORCODE_ELTAN_OEM_MANIFEST_ITEMS * DIGEST_SIZE) + (2048/8))) { printk(BIOS_ERR, "ERROR: Incorrect manifest size!\n"); goto fail; @@ -183,7 +183,7 @@ void *start; size_t size;
- start = cbfs_boot_map_with_leak(name, type & ~VERIFIED_BOOT_COPY_BLOCK, &size); + start = cbfs_map(name, &size); if (start && size) { /* Speed up processing by copying the file content to memory first */ if (!ENV_ROMSTAGE_OR_BEFORE && (type & VERIFIED_BOOT_COPY_BLOCK)) { diff --git a/src/vendorcode/google/chromeos/sar.c b/src/vendorcode/google/chromeos/sar.c index 9bca423..8b31e81 100644 --- a/src/vendorcode/google/chromeos/sar.c +++ b/src/vendorcode/google/chromeos/sar.c @@ -16,8 +16,7 @@ const char *filename = get_wifi_sar_cbfs_filename(); if (filename == NULL) filename = WIFI_SAR_CBFS_FILENAME; - return cbfs_boot_load_file(filename, buf, - buffer_size, CBFS_TYPE_RAW); + return cbfs_load(filename, buf, buffer_size); }
/* Retrieve the wifi SAR limits data from VPD and decode it diff --git a/src/vendorcode/siemens/hwilib/hwilib.c b/src/vendorcode/siemens/hwilib/hwilib.c index be4f7bb..4bfd36b 100644 --- a/src/vendorcode/siemens/hwilib/hwilib.c +++ b/src/vendorcode/siemens/hwilib/hwilib.c @@ -469,7 +469,7 @@ return CB_SUCCESS; }
- ptr = cbfs_boot_map_with_leak(hwi_filename, CBFS_TYPE_RAW, &filesize); + ptr = cbfs_map(hwi_filename, &filesize); if (!ptr) { printk(BIOS_ERR,"HWILIB: Missing file "%s" in cbfs.\n", hwi_filename);
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39304 )
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
Patch Set 18:
(1 comment)
https://review.coreboot.org/c/coreboot/+/39304/3/src/lib/cbfs.c File src/lib/cbfs.c:
https://review.coreboot.org/c/coreboot/+/39304/3/src/lib/cbfs.c@209 PS3, Line 209: cbfs_load since we're here, I wonder if we can add a new API for loading blobs with unlimited buffer size, e.g.
cbfs_alloc_and_load(const char *name, void *(*allocator)(size_t sz))
That it'll first locate, get decompression info,call allocator with decompressed size, and load/decompress there.
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39304 )
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
Patch Set 18:
(1 comment)
https://review.coreboot.org/c/coreboot/+/39304/3/src/lib/cbfs.c File src/lib/cbfs.c:
https://review.coreboot.org/c/coreboot/+/39304/3/src/lib/cbfs.c@209 PS3, Line 209: cbfs_load
since we're here, I wonder if we can add a new API for loading blobs with unlimited buffer size, e. […]
Hmmm... but where does that allocator come from? I don't think we'd want to have every platform implement its own memory allocator somewhere. It's more efficient to just use a single allocator for everything, and currently we already have the CBFS_CACHE allocator so I think we should rather expand on that.
I think it would be reasonable to expand cbfs_map() so that it will transparently allocate space for the decompressed file and decompress it. The x86 boards currently have no concept of CBFS_CACHE so we would have to add it there for that to work, but that could be done. I don't really have time to work in that direction right now, but am happy to review patches if you want to.
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39304 )
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
Patch Set 18:
(1 comment)
https://review.coreboot.org/c/coreboot/+/39304/3/src/lib/cbfs.c File src/lib/cbfs.c:
https://review.coreboot.org/c/coreboot/+/39304/3/src/lib/cbfs.c@209 PS3, Line 209: cbfs_load
but where does that allocator come from?
I'm seeing that need for the case of files for transferring to MCU via DMA - to fulfill the requirements like "must be a DMA memory", or "must be aligned to 0x10 bytes". So the caller should provide an allocator. For x86 it can be dummy. For ARM, it can be malloc(), dma_alloc, xalloc, etc.
Without that, we always to do another allocation + memcpy.
I think it would be reasonable to expand cbfs_map()
Yes it's actually for mapping, with special requirements. Anyway if this request is not common enough I can also implement it in the board-specific folder.
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39304 )
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
Patch Set 18:
(1 comment)
https://review.coreboot.org/c/coreboot/+/39304/3/src/lib/cbfs.c File src/lib/cbfs.c:
https://review.coreboot.org/c/coreboot/+/39304/3/src/lib/cbfs.c@209 PS3, Line 209: cbfs_load
but where does that allocator come from? […]
Decompressing from DMA memory is a very bad idea, though, so you'd have to pass two different allocators (one for the decompression scratch and one for the final area) and make sure it doesn't try to decompress in-place. I think this would quickly become way too complicated.
I would see the operation you're trying to do as a special case of cbfs_load() instead of cbfs_map() (because you're trying to put the file into a specific place). I would just design this in a way where your allocator can tell you how much total space it has remaining... let's say in the simplest case you have
void *allocator_start; size_t used_bytes; size_t total_bytes;
as your allocator state. Then, really, you can just use the existing APIs to do:
void *file_start = allocator_start + used_bytes; size_t size = cbfs_load(filename, file_start, total_bytes - used_bytes); if (!size) ...handle OOM error... used_bytes += size;
and then you have your file loaded to where you want, automatic decompression included. If you want a more complicated allocator (e.g. one that keeps enough state to be able to free the allocation later) you should be able to adapt this as necessary (e.g. to leave some free space for an allocator tag or something). You can of course wrap this in a function that comes with your allocator if you want. But I don't think it really requires any further API support from the CBFS core? (If we need this sort of "DMA allocator" on many boards, we could of course put it in lib/, including a function that wraps cbfs_load().)
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39304 )
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
Patch Set 18:
(1 comment)
https://review.coreboot.org/c/coreboot/+/39304/3/src/lib/cbfs.c File src/lib/cbfs.c:
https://review.coreboot.org/c/coreboot/+/39304/3/src/lib/cbfs.c@209 PS3, Line 209: cbfs_load
Decompressing from DMA memory is a very bad idea, though, so you'd have to pass two different alloca […]
Hmmm. I think you made a good point decompressing in DMA memory is a bad idea.
I think I should write a wrapper instead, that calls cbfs_map or cbfs_load depending on if the target memory is DMA memory. Let's keep current APIs not change. Thanks!
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39304 )
Change subject: cbfs: Simplify load/map API names, remove type arguments ......................................................................
Patch Set 18:
I just recalled that cbfs_map can't decompress, that why I wanted the feature in cbfs_load :)