From 834b3ecd7cbefbad8f09a9bda4f10cd7842cdbcd Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Wed, 4 Mar 2020 16:52:08 -0800 Subject: cbfs: Simplify load/map API names, remove type arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Change-Id: Ib24325400815a9c3d25f66c61829a24a239bb88e Reviewed-on: https://review.coreboot.org/c/coreboot/+/39304 Reviewed-by: Hung-Te Lin Reviewed-by: Wim Vervoorn Reviewed-by: Mariusz SzafraƄski Reviewed-by: Patrick Georgi Tested-by: build bot (Jenkins) --- src/acpi/acpi.c | 7 ++----- src/arch/x86/bootblock_normal.c | 2 +- src/cpu/amd/pi/00730F01/update_microcode.c | 3 +-- src/cpu/intel/microcode/microcode.c | 4 +--- src/drivers/amd/agesa/def_callouts.c | 4 +--- src/drivers/amd/agesa/state_machine.c | 3 +-- src/drivers/intel/fsp1_1/logo.c | 4 ++-- src/drivers/intel/fsp2_0/logo.c | 4 ++-- src/drivers/intel/gma/opregion.c | 3 +-- src/drivers/pc80/rtc/option.c | 3 +-- src/include/cbfs.h | 23 ++++++++++++--------- src/lib/bootsplash.c | 4 ++-- src/lib/cbfs.c | 24 ++++++++++++++-------- src/lib/coreboot_table.c | 3 +-- src/lib/fw_config.c | 5 ++--- src/lib/spd_bin.c | 6 +++--- src/mainboard/apple/macbookair4_2/early_init.c | 3 +-- src/mainboard/dell/optiplex_9010/sch5545_ec.c | 3 +-- src/mainboard/google/asurada/sdram_configs.c | 3 +-- .../google/auron/variants/auron_paine/spd/spd.c | 2 +- .../google/auron/variants/auron_yuna/spd/spd.c | 2 +- .../google/auron/variants/buddy/variant.c | 4 +--- .../google/auron/variants/gandof/spd/spd.c | 2 +- src/mainboard/google/auron/variants/lulu/spd/spd.c | 2 +- .../google/auron/variants/samus/spd/spd.c | 2 +- src/mainboard/google/beltino/lan.c | 4 +--- src/mainboard/google/butterfly/mainboard.c | 3 +-- src/mainboard/google/cyan/spd/spd.c | 3 +-- src/mainboard/google/eve/spd/spd.c | 3 +-- src/mainboard/google/glados/spd/spd.c | 3 +-- src/mainboard/google/gru/sdram_configs.c | 3 +-- src/mainboard/google/jecht/lan.c | 4 +--- .../google/kahlee/variants/baseboard/mainboard.c | 4 +--- .../google/kahlee/variants/nuwani/mainboard.c | 4 +--- .../google/kahlee/variants/treeya/mainboard.c | 4 +--- src/mainboard/google/kukui/mainboard.c | 3 +-- src/mainboard/google/kukui/sdram_configs.c | 3 +-- src/mainboard/google/link/early_init.c | 3 +-- src/mainboard/google/poppy/romstage.c | 3 +-- .../google/poppy/variants/nami/mainboard.c | 5 ++--- src/mainboard/google/rambi/romstage.c | 3 +-- src/mainboard/google/rambi/variants/ninja/lan.c | 4 +--- src/mainboard/google/rambi/variants/sumo/lan.c | 4 +--- .../google/slippy/variants/falco/romstage.c | 3 +-- .../google/slippy/variants/leon/romstage.c | 3 +-- .../google/slippy/variants/peppy/romstage.c | 3 +-- .../google/slippy/variants/wolf/romstage.c | 3 +-- .../variants/revolve_810_g1/early_init.c | 3 +-- src/mainboard/intel/harcuvar/spd/spd.c | 3 +-- src/mainboard/intel/kunimitsu/spd/spd_util.c | 3 +-- src/mainboard/lenovo/s230u/early_init.c | 3 +-- .../lenovo/t430s/variants/t431s/romstage.c | 3 +-- src/mainboard/lenovo/x1_carbon_gen1/early_init.c | 3 +-- src/mainboard/samsung/lumpy/early_init.c | 3 +-- src/mainboard/sifive/hifive-unleashed/fixup_fdt.c | 2 +- src/northbridge/intel/sandybridge/raminit_mrc.c | 2 +- src/security/intel/stm/StmPlatformSmm.c | 3 +-- src/security/intel/txt/ramstage.c | 11 ++++------ src/security/vboot/ec_sync.c | 4 +++- src/soc/amd/common/block/pi/def_callouts.c | 5 ++--- src/soc/amd/picasso/update_microcode.c | 3 +-- src/soc/cavium/cn81xx/soc.c | 3 +-- src/soc/intel/baytrail/romstage/raminit.c | 2 +- src/soc/intel/common/mma.c | 6 +++--- src/soc/intel/denverton_ns/chip.c | 3 +-- src/soc/intel/xeon_sp/skx/chip.c | 3 +-- src/soc/mediatek/mt8183/spm.c | 3 +-- src/soc/mediatek/mt8183/sspm.c | 5 +---- src/soc/qualcomm/ipq40xx/blobs_init.c | 3 +-- src/soc/qualcomm/ipq806x/blobs_init.c | 3 +-- src/soc/qualcomm/sc7180/qclib.c | 8 ++++---- src/soc/qualcomm/sc7180/qupv3_config.c | 5 ++--- src/vendorcode/eltan/security/mboot/mboot.c | 2 +- .../eltan/security/verified_boot/vboot_check.c | 6 +++--- src/vendorcode/google/chromeos/sar.c | 3 +-- src/vendorcode/siemens/hwilib/hwilib.c | 2 +- 76 files changed, 124 insertions(+), 184 deletions(-) diff --git a/src/acpi/acpi.c b/src/acpi/acpi.c index abc6e01b0a..c319a73aa7 100644 --- a/src/acpi/acpi.c +++ b/src/acpi/acpi.c @@ -1340,9 +1340,7 @@ unsigned long write_acpi_tables(unsigned long start) 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 @@ unsigned long write_acpi_tables(unsigned long start) 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 3fbdbec2cd..e2dfcf4610 100644 --- a/src/arch/x86/bootblock_normal.c +++ b/src/arch/x86/bootblock_normal.c @@ -18,7 +18,7 @@ int legacy_romstage_selector(struct prog *romstage) 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 11e2531e2b..ccf64684aa 100644 --- a/src/cpu/amd/pi/00730F01/update_microcode.c +++ b/src/cpu/amd/pi/00730F01/update_microcode.c @@ -115,8 +115,7 @@ void amd_update_microcode_from_cbfs(void) 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 8080545d39..0f362d4b35 100644 --- a/src/cpu/intel/microcode/microcode.c +++ b/src/cpu/intel/microcode/microcode.c @@ -126,9 +126,7 @@ const void *intel_microcode_find(void) 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 07f717324e..5f52ca0904 100644 --- a/src/drivers/amd/agesa/def_callouts.c +++ b/src/drivers/amd/agesa/def_callouts.c @@ -121,9 +121,7 @@ AGESA_STATUS agesa_RunFuncOnAp (UINT32 Func, UINTN Data, VOID *ConfigPtr) 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 606a66f5cb..31db0b6b4c 100644 --- a/src/drivers/amd/agesa/state_machine.c +++ b/src/drivers/amd/agesa/state_machine.c @@ -30,8 +30,7 @@ static void agesa_locate_image(AMD_CONFIG_PARAMS *StdHeader) 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 feec434cdf..bcaf15715f 100644 --- a/src/drivers/intel/fsp1_1/logo.c +++ b/src/drivers/intel/fsp1_1/logo.c @@ -13,8 +13,8 @@ const struct cbmem_entry *fsp_load_logo(UINT32 *logo_ptr, UINT32 *logo_size) 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 0d430a19ac..314616b296 100644 --- a/src/drivers/intel/fsp2_0/logo.c +++ b/src/drivers/intel/fsp2_0/logo.c @@ -13,8 +13,8 @@ const struct cbmem_entry *fsp_load_logo(UINT32 *logo_ptr, UINT32 *logo_size) 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 ea051241e8..4e9f94d013 100644 --- a/src/drivers/intel/gma/opregion.c +++ b/src/drivers/intel/gma/opregion.c @@ -34,8 +34,7 @@ void *locate_vbt(size_t *vbt_size) 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 d17c025b1f..bb9d29ab2d 100644 --- a/src/drivers/pc80/rtc/option.c +++ b/src/drivers/pc80/rtc/option.c @@ -237,8 +237,7 @@ void sanitize_cmos(void) 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 1b446ac7a8..992b6583ca 100644 --- a/src/include/cbfs.h +++ b/src/include/cbfs.h @@ -18,19 +18,22 @@ void *cbfs_boot_map_optionrom(uint16_t vendor, uint16_t device); 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 050d713154..0eb94dc812 100644 --- a/src/lib/bootsplash.c +++ b/src/lib/bootsplash.c @@ -16,8 +16,7 @@ void set_bootsplash(unsigned char *framebuffer, unsigned int x_resolution, 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 @@ void set_bootsplash(unsigned char *framebuffer, unsigned int x_resolution, 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 94dae625b2..493093ebb9 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -70,22 +70,29 @@ int cbfs_boot_locate(struct cbfsf *fh, const char *name, uint32_t *type) 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 @@ void *cbfs_boot_map_optionrom(uint16_t vendor, uint16_t device) 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 @@ void *cbfs_boot_map_optionrom_revision(uint16_t vendor, uint16_t device, uint8_t 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 4cbf3c742e..996e76ec11 100644 --- a/src/lib/coreboot_table.c +++ b/src/lib/coreboot_table.c @@ -455,8 +455,7 @@ static uintptr_t write_coreboot_table(uintptr_t rom_table_end) #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 e17d40e58a..2f7186cc86 100644 --- a/src/lib/fw_config.c +++ b/src/lib/fw_config.c @@ -24,9 +24,8 @@ uint64_t fw_config_get(void) /* 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 38edc5f151..863218c2d3 100644 --- a/src/lib/spd_bin.c +++ b/src/lib/spd_bin.c @@ -227,12 +227,11 @@ int read_ddr3_spd_from_cbfs(u8 *buf, int idx) 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 @@ int read_ddr3_spd_from_cbfs(u8 *buf, int idx) 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 9da67022c8..a32298d536 100644 --- a/src/mainboard/apple/macbookair4_2/early_init.c +++ b/src/mainboard/apple/macbookair4_2/early_init.c @@ -26,8 +26,7 @@ void mainboard_get_spd(spd_raw_data *spd, bool id_only) { 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 d11ba97fff..8110963c52 100644 --- a/src/mainboard/dell/optiplex_9010/sch5545_ec.c +++ b/src/mainboard/dell/optiplex_9010/sch5545_ec.c @@ -442,8 +442,7 @@ void sch5545_update_ec_firmware(uint16_t ec_version) 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 9efcb32dae..e1eb527720 100644 --- a/src/mainboard/google/asurada/sdram_configs.c +++ b/src/mainboard/google/asurada/sdram_configs.c @@ -17,8 +17,7 @@ const struct sdram_info *get_sdram_config(void) 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 da00ad9dfb..12a9d7cb12 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 @@ void mainboard_fill_spd_data(struct pei_data *pei_data) 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 da00ad9dfb..12a9d7cb12 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 @@ void mainboard_fill_spd_data(struct pei_data *pei_data) 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 81bb828047..2ffc38a185 100644 --- a/src/mainboard/google/auron/variants/buddy/variant.c +++ b/src/mainboard/google/auron/variants/buddy/variant.c @@ -129,9 +129,7 @@ static void program_mac_address(u16 io_base) 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 da00ad9dfb..12a9d7cb12 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 @@ void mainboard_fill_spd_data(struct pei_data *pei_data) 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 750470e89c..905e196f7b 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 @@ void mainboard_fill_spd_data(struct pei_data *pei_data) 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 4684d86dce..4cad47432c 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 @@ void mainboard_fill_spd_data(struct pei_data *pei_data) 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 c14a1e4584..d9df5a1404 100644 --- a/src/mainboard/google/beltino/lan.c +++ b/src/mainboard/google/beltino/lan.c @@ -110,9 +110,7 @@ static void program_mac_address(u16 io_base) 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 d2e2aa552a..d9cf1b9434 100644 --- a/src/mainboard/google/butterfly/mainboard.c +++ b/src/mainboard/google/butterfly/mainboard.c @@ -180,8 +180,7 @@ static void mainboard_init(struct device *dev) } } } 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 1c08d9069a..21a298e88a 100644 --- a/src/mainboard/google/cyan/spd/spd.c +++ b/src/mainboard/google/cyan/spd/spd.c @@ -35,8 +35,7 @@ static void *get_spd_pointer(int *dual) 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 330ea5201c..e9405f08cb 100644 --- a/src/mainboard/google/eve/spd/spd.c +++ b/src/mainboard/google/eve/spd/spd.c @@ -82,8 +82,7 @@ uintptr_t mainboard_get_spd_data(void) 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 627dc3f4e5..9bfb202bb9 100644 --- a/src/mainboard/google/glados/spd/spd.c +++ b/src/mainboard/google/glados/spd/spd.c @@ -79,8 +79,7 @@ void spd_memory_init_params(FSPM_UPD *mupd, int spd_index) 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 87a5009eb6..2aceb9f084 100644 --- a/src/mainboard/google/gru/sdram_configs.c +++ b/src/mainboard/google/gru/sdram_configs.c @@ -53,8 +53,7 @@ const struct rk3399_sdram_params *get_sdram_config() 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 3d19f99953..4dedb56c70 100644 --- a/src/mainboard/google/jecht/lan.c +++ b/src/mainboard/google/jecht/lan.c @@ -110,9 +110,7 @@ static void program_mac_address(u16 io_base) 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 95f0a8d642..860190a2b6 100644 --- a/src/mainboard/google/kahlee/variants/baseboard/mainboard.c +++ b/src/mainboard/google/kahlee/variants/baseboard/mainboard.c @@ -89,9 +89,7 @@ const char *smbios_mainboard_manufacturer(void) 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 df31c6f42f..ce98d62c18 100644 --- a/src/mainboard/google/kahlee/variants/nuwani/mainboard.c +++ b/src/mainboard/google/kahlee/variants/nuwani/mainboard.c @@ -101,9 +101,7 @@ const char *smbios_mainboard_manufacturer(void) 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 df31c6f42f..ce98d62c18 100644 --- a/src/mainboard/google/kahlee/variants/treeya/mainboard.c +++ b/src/mainboard/google/kahlee/variants/treeya/mainboard.c @@ -101,9 +101,7 @@ const char *smbios_mainboard_manufacturer(void) 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 cbcb5da1c6..4220810d17 100644 --- a/src/mainboard/google/kukui/mainboard.c +++ b/src/mainboard/google/kukui/mainboard.c @@ -112,8 +112,7 @@ struct panel_description *get_panel_from_cbfs(struct panel_description *desc) 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 523958788b..57f5e6e765 100644 --- a/src/mainboard/google/kukui/sdram_configs.c +++ b/src/mainboard/google/kukui/sdram_configs.c @@ -43,8 +43,7 @@ const struct sdram_params *get_sdram_config(void) 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 f3da77cd6b..de8f749770 100644 --- a/src/mainboard/google/link/early_init.c +++ b/src/mainboard/google/link/early_init.c @@ -66,8 +66,7 @@ static uint8_t *locate_spd(void) 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 0c1fc02133..7fd4409401 100644 --- a/src/mainboard/google/poppy/romstage.c +++ b/src/mainboard/google/poppy/romstage.c @@ -112,8 +112,7 @@ static uintptr_t mainboard_get_spd_data(enum memory_type type, bool use_sec_spd) 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 8d5d0c482b..1387716298 100644 --- a/src/mainboard/google/poppy/variants/nami/mainboard.c +++ b/src/mainboard/google/poppy/variants/nami/mainboard.c @@ -155,9 +155,8 @@ const char *smbios_mainboard_manufacturer(void) 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 6487f43121..28496b15ba 100644 --- a/src/mainboard/google/rambi/romstage.c +++ b/src/mainboard/google/rambi/romstage.c @@ -48,8 +48,7 @@ void mainboard_fill_mrc_params(struct mrc_params *mp) 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 e5688df0f2..1304071444 100644 --- a/src/mainboard/google/rambi/variants/ninja/lan.c +++ b/src/mainboard/google/rambi/variants/ninja/lan.c @@ -109,9 +109,7 @@ static void program_mac_address(u16 io_base) 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 53bd4fb02f..29bc0fe336 100644 --- a/src/mainboard/google/rambi/variants/sumo/lan.c +++ b/src/mainboard/google/rambi/variants/sumo/lan.c @@ -109,9 +109,7 @@ static void program_mac_address(u16 io_base) 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 eba4a8b648..516b26c9c5 100644 --- a/src/mainboard/google/slippy/variants/falco/romstage.c +++ b/src/mainboard/google/slippy/variants/falco/romstage.c @@ -21,8 +21,7 @@ void copy_spd(struct pei_data *peid) 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 2b1b5ca6bd..e24dcb9808 100644 --- a/src/mainboard/google/slippy/variants/leon/romstage.c +++ b/src/mainboard/google/slippy/variants/leon/romstage.c @@ -20,8 +20,7 @@ void copy_spd(struct pei_data *peid) 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 230595e205..92e1e8dd5e 100644 --- a/src/mainboard/google/slippy/variants/peppy/romstage.c +++ b/src/mainboard/google/slippy/variants/peppy/romstage.c @@ -24,8 +24,7 @@ void copy_spd(struct pei_data *peid) 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 405e86acef..a0b5055457 100644 --- a/src/mainboard/google/slippy/variants/wolf/romstage.c +++ b/src/mainboard/google/slippy/variants/wolf/romstage.c @@ -21,8 +21,7 @@ void copy_spd(struct pei_data *peid) 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 a7c894beb8..65a18199e7 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 @@ void mainboard_get_spd(spd_raw_data *spd, bool id_only) { /* 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 a70bb5f39b..a66c10b032 100644 --- a/src/mainboard/intel/harcuvar/spd/spd.c +++ b/src/mainboard/intel/harcuvar/spd/spd.c @@ -15,8 +15,7 @@ uint8_t *mainboard_find_spd_data() 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 71643bed05..8674512ff4 100644 --- a/src/mainboard/intel/kunimitsu/spd/spd_util.c +++ b/src/mainboard/intel/kunimitsu/spd/spd_util.c @@ -68,8 +68,7 @@ uintptr_t mainboard_get_spd_data(void) 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 155b02eec1..434b58c6a3 100644 --- a/src/mainboard/lenovo/s230u/early_init.c +++ b/src/mainboard/lenovo/s230u/early_init.c @@ -70,8 +70,7 @@ void mainboard_get_spd(spd_raw_data *spd, bool id_only) 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 60a1b01556..54236a1ffc 100644 --- a/src/mainboard/lenovo/t430s/variants/t431s/romstage.c +++ b/src/mainboard/lenovo/t430s/variants/t431s/romstage.c @@ -28,8 +28,7 @@ void mainboard_get_spd(spd_raw_data *spd, bool id_only) { /* 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 f49a59f8e8..6f18feee91 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 @@ static uint8_t *get_spd_data(int spd_index) 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 ad4ddb91ee..90a176471a 100644 --- a/src/mainboard/samsung/lumpy/early_init.c +++ b/src/mainboard/samsung/lumpy/early_init.c @@ -104,8 +104,7 @@ static const uint8_t *locate_spd(void) 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 38492acb87..dda71b6766 100644 --- a/src/mainboard/sifive/hifive-unleashed/fixup_fdt.c +++ b/src/mainboard/sifive/hifive-unleashed/fixup_fdt.c @@ -72,7 +72,7 @@ static void fixup_fdt(void *unused) 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 8df7d1b36a..d6d39a2c66 100644 --- a/src/northbridge/intel/sandybridge/raminit_mrc.c +++ b/src/northbridge/intel/sandybridge/raminit_mrc.c @@ -148,7 +148,7 @@ void sdram_initialize(struct pei_data *pei_data) 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 eb9a0bb22f..abd7667355 100644 --- a/src/security/intel/stm/StmPlatformSmm.c +++ b/src/security/intel/stm/StmPlatformSmm.c @@ -35,8 +35,7 @@ int load_stm_image(uintptr_t mseg) 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 76eeaaffef..81d2dd1083 100644 --- a/src/security/intel/txt/ramstage.c +++ b/src/security/intel/txt/ramstage.c @@ -221,10 +221,9 @@ static void txt_initialize_heap(void) 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 @@ static void txt_initialize_heap(void) 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 1fd7e7590b..7e3d29a4ab 100644 --- a/src/security/vboot/ec_sync.c +++ b/src/security/vboot/ec_sync.c @@ -385,7 +385,9 @@ static vb2_error_t ec_get_expected_hash(enum vb2_firmware_selection select, { 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 56ce995f1c..2ee7f46056 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 @@ AGESA_STATUS agesa_GfxGetVbiosImage(uint32_t Func, uintptr_t FchData, 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 8f3d3e22b8..47a98353b9 100644 --- a/src/soc/amd/picasso/update_microcode.c +++ b/src/soc/amd/picasso/update_microcode.c @@ -80,8 +80,7 @@ void amd_update_microcode_from_cbfs(void) 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 3545d55bd9..368e9250e2 100644 --- a/src/soc/cavium/cn81xx/soc.c +++ b/src/soc/cavium/cn81xx/soc.c @@ -334,8 +334,7 @@ static void soc_init_atf(void) 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 9a67c22e4b..10ad93298b 100644 --- a/src/soc/intel/baytrail/romstage/raminit.c +++ b/src/soc/intel/baytrail/romstage/raminit.c @@ -153,7 +153,7 @@ void raminit(struct mrc_params *mp, int prev_sleep_state) } /* 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 a2ccaf5c16..e015567a69 100644 --- a/src/soc/intel/common/mma.c +++ b/src/soc/intel/common/mma.c @@ -113,7 +113,7 @@ int mma_locate_param(struct mma_config_param *mma_cfg) 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 @@ int mma_locate_param(struct mma_config_param *mma_cfg) 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 @@ int mma_locate_param(struct mma_config_param *mma_cfg) 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 3bade119e6..9cf3bfb54a 100644 --- a/src/soc/intel/denverton_ns/chip.c +++ b/src/soc/intel/denverton_ns/chip.c @@ -84,8 +84,7 @@ void platform_fsp_silicon_init_params_cb(FSPS_UPD *silupd) 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 7fe330b37e..0505ea7eff 100644 --- a/src/soc/intel/xeon_sp/skx/chip.c +++ b/src/soc/intel/xeon_sp/skx/chip.c @@ -59,8 +59,7 @@ void platform_fsp_silicon_init_params_cb(FSPS_UPD *silupd) 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 01c6a2fbfa..e35fc57e2f 100644 --- a/src/soc/mediatek/mt8183/spm.c +++ b/src/soc/mediatek/mt8183/spm.c @@ -231,8 +231,7 @@ static int spm_load_firmware(enum dyna_load_pcm_index index, 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 efcf54574e..1a4ba9e88f 100644 --- a/src/soc/mediatek/mt8183/sspm.c +++ b/src/soc/mediatek/mt8183/sspm.c @@ -13,10 +13,7 @@ static uint8_t sspm_bin[BUF_SIZE] __aligned(8); 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 8cd9fc7f55..60e4f0de04 100644 --- a/src/soc/qualcomm/ipq40xx/blobs_init.c +++ b/src/soc/qualcomm/ipq40xx/blobs_init.c @@ -22,8 +22,7 @@ static void *load_ipq_blob(const char *file_name) 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 89c26b5834..15068a59de 100644 --- a/src/soc/qualcomm/ipq806x/blobs_init.c +++ b/src/soc/qualcomm/ipq806x/blobs_init.c @@ -18,8 +18,7 @@ static void *load_ipq_blob(const char *file_name) 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 274d906240..2bff80d040 100644 --- a/src/soc/qualcomm/sc7180/qclib.c +++ b/src/soc/qualcomm/sc7180/qclib.c @@ -11,15 +11,15 @@ int qclib_soc_blob_load(void) 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 8cd9670f87..4bc99367a0 100644 --- a/src/soc/qualcomm/sc7180/qupv3_config.c +++ b/src/soc/qualcomm/sc7180/qupv3_config.c @@ -27,10 +27,9 @@ void qupv3_se_fw_load_and_init(unsigned int bus, unsigned int protocol, 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 d24a39fd25..575c5fc022 100644 --- a/src/vendorcode/eltan/security/mboot/mboot.c +++ b/src/vendorcode/eltan/security/mboot/mboot.c @@ -234,7 +234,7 @@ int mb_measure_log_worker(const char *name, uint32_t type, uint32_t pcr, 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 044f2d43b1..824570e481 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 @@ int verified_boot_check_manifest(void) 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 @@ int verified_boot_check_manifest(void) 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 verified_boot_check_cbfsfile(const char *name, uint32_t type, uint32_t hash 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 9bca42352d..8b31e8125e 100644 --- a/src/vendorcode/google/chromeos/sar.c +++ b/src/vendorcode/google/chromeos/sar.c @@ -16,8 +16,7 @@ static int load_sar_file_from_cbfs(void *buf, size_t buffer_size) 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 be4f7bbf5f..4bfd36b241 100644 --- a/src/vendorcode/siemens/hwilib/hwilib.c +++ b/src/vendorcode/siemens/hwilib/hwilib.c @@ -469,7 +469,7 @@ enum cb_err hwilib_find_blocks (const char *hwi_filename) 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); -- cgit v1.2.3