summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cpu/x86/pae/pgtbl.c29
-rw-r--r--src/drivers/generic/cbfs-serial/cbfs-serial.c19
-rw-r--r--src/drivers/net/atl1e.c15
-rw-r--r--src/drivers/net/r8168.c15
-rw-r--r--src/lib/nhlt.c20
-rw-r--r--src/mainboard/razer/blade_stealth_kbl/Kconfig1
-rw-r--r--src/mainboard/razer/blade_stealth_kbl/Makefile.inc1
-rw-r--r--src/mainboard/razer/blade_stealth_kbl/mainboard.c35
-rw-r--r--src/security/intel/txt/common.c22
-rw-r--r--src/security/intel/txt/ramstage.c23
-rw-r--r--src/soc/amd/common/block/psp/psp_gen1.c12
-rw-r--r--src/soc/nvidia/tegra210/mtc.c19
12 files changed, 40 insertions, 171 deletions
diff --git a/src/cpu/x86/pae/pgtbl.c b/src/cpu/x86/pae/pgtbl.c
index 145a31b7cc..814dbf5c70 100644
--- a/src/cpu/x86/pae/pgtbl.c
+++ b/src/cpu/x86/pae/pgtbl.c
@@ -321,42 +321,17 @@ void paging_set_default_pat(void)
paging_set_pat(pat);
}
-static int read_from_cbfs(const char *name, void *buf, size_t size)
-{
- struct cbfsf fh;
- struct region_device rdev;
- size_t rdev_sz;
-
- if (cbfs_boot_locate(&fh, name, NULL))
- return -1;
-
- cbfs_file_data(&rdev, &fh);
-
- rdev_sz = region_device_sz(&rdev);
-
- if (size < rdev_sz) {
- printk(BIOS_ERR, "%s region too small to load: %zx < %zx\n",
- name, size, rdev_sz);
- return -1;
- }
-
- if (rdev_readat(&rdev, buf, 0, rdev_sz) != rdev_sz)
- return -1;
-
- return 0;
-}
-
int paging_enable_for_car(const char *pdpt_name, const char *pt_name)
{
if (!preram_symbols_available())
return -1;
- if (read_from_cbfs(pdpt_name, _pdpt, REGION_SIZE(pdpt))) {
+ if (!cbfs_load(pdpt_name, _pdpt, REGION_SIZE(pdpt))) {
printk(BIOS_ERR, "Couldn't load pdpt\n");
return -1;
}
- if (read_from_cbfs(pt_name, _pagetables, REGION_SIZE(pagetables))) {
+ if (!cbfs_load(pt_name, _pagetables, REGION_SIZE(pagetables))) {
printk(BIOS_ERR, "Couldn't load page tables\n");
return -1;
}
diff --git a/src/drivers/generic/cbfs-serial/cbfs-serial.c b/src/drivers/generic/cbfs-serial/cbfs-serial.c
index 9f8aaa80f9..6ff010cb41 100644
--- a/src/drivers/generic/cbfs-serial/cbfs-serial.c
+++ b/src/drivers/generic/cbfs-serial/cbfs-serial.c
@@ -10,25 +10,14 @@
const char *smbios_mainboard_serial_number(void)
{
static char serial_number[MAX_SERIAL_LENGTH + 1] = {0};
- struct cbfsf file;
if (serial_number[0] != 0)
return serial_number;
- if (cbfs_boot_locate(&file, "serial_number", NULL) == 0) {
- struct region_device cbfs_region;
- size_t serial_len;
-
- cbfs_file_data(&cbfs_region, &file);
-
- serial_len = region_device_sz(&cbfs_region);
- if (serial_len <= MAX_SERIAL_LENGTH) {
- if (rdev_readat(&cbfs_region, serial_number, 0,
- serial_len) == serial_len) {
- serial_number[serial_len] = 0;
- return serial_number;
- }
- }
+ size_t serial_len = cbfs_load("serial_number", serial_number, MAX_SERIAL_LENGTH);
+ if (serial_len) {
+ serial_number[serial_len] = '\0';
+ return serial_number;
}
strncpy(serial_number, CONFIG_MAINBOARD_SERIAL_NUMBER,
diff --git a/src/drivers/net/atl1e.c b/src/drivers/net/atl1e.c
index b533537ac8..9b1b2ab953 100644
--- a/src/drivers/net/atl1e.c
+++ b/src/drivers/net/atl1e.c
@@ -41,18 +41,11 @@ static u8 get_hex_digit(const u8 c)
static enum cb_err fetch_mac_string_cbfs(u8 *macstrbuf)
{
- struct cbfsf fh;
- uint32_t matchraw = CBFS_TYPE_RAW;
-
- if (!cbfs_boot_locate(&fh, "atl1e-macaddress", &matchraw)) {
- /* check the cbfs for the mac address */
- if (rdev_readat(&fh.data, macstrbuf, 0, MACLEN) != MACLEN) {
- printk(BIOS_ERR, "atl1e: Error reading MAC from CBFS\n");
- return CB_ERR;
- }
- return CB_SUCCESS;
+ if (!cbfs_load("atl1e-macaddress", macstrbuf, MACLEN)) {
+ printk(BIOS_ERR, "atl1e: Error reading MAC from CBFS\n");
+ return CB_ERR;
}
- return CB_ERR;
+ return CB_SUCCESS;
}
static void get_mac_address(u8 *macaddr, const u8 *strbuf)
diff --git a/src/drivers/net/r8168.c b/src/drivers/net/r8168.c
index af7c38707a..398b15d93c 100644
--- a/src/drivers/net/r8168.c
+++ b/src/drivers/net/r8168.c
@@ -166,18 +166,11 @@ static void fetch_mac_string_vpd(struct drivers_net_config *config, u8 *macstrbu
static enum cb_err fetch_mac_string_cbfs(u8 *macstrbuf)
{
- struct cbfsf fh;
- uint32_t matchraw = CBFS_TYPE_RAW;
-
- if (!cbfs_boot_locate(&fh, "rt8168-macaddress", &matchraw)) {
- /* check the cbfs for the mac address */
- if (rdev_readat(&fh.data, macstrbuf, 0, MACLEN) != MACLEN) {
- printk(BIOS_ERR, "r8168: Error reading MAC from CBFS\n");
- return CB_ERR;
- }
- return CB_SUCCESS;
+ if (!cbfs_load("rt8168-macaddress", macstrbuf, MACLEN)) {
+ printk(BIOS_ERR, "r8168: Error reading MAC from CBFS\n");
+ return CB_ERR;
}
- return CB_ERR;
+ return CB_SUCCESS;
}
static void get_mac_address(u8 *macaddr, const u8 *strbuf)
diff --git a/src/lib/nhlt.c b/src/lib/nhlt.c
index 80b3f2e1d3..90a6cd9eef 100644
--- a/src/lib/nhlt.c
+++ b/src/lib/nhlt.c
@@ -149,9 +149,8 @@ int nhlt_endpoint_add_formats(struct nhlt_endpoint *endp,
for (i = 0; i < num_formats; i++) {
struct nhlt_format *fmt;
- struct cbfsf file;
- struct region_device settings;
void *settings_data;
+ size_t size;
const struct nhlt_format_config *cfg = &formats[i];
fmt = nhlt_add_format(endp, cfg->num_channels,
@@ -167,23 +166,16 @@ int nhlt_endpoint_add_formats(struct nhlt_endpoint *endp,
continue;
/* Find the settings file in CBFS and place it in format. */
- if (cbfs_boot_locate(&file, cfg->settings_file, NULL))
+ settings_data = cbfs_map(cfg->settings_file, &size);
+ if (!settings_data)
return -1;
- cbfs_file_data(&settings, &file);
-
- settings_data = rdev_mmap_full(&settings);
-
- if (settings_data == NULL)
- return -1;
-
- if (nhlt_format_append_config(fmt, settings_data,
- region_device_sz(&settings))) {
- rdev_munmap(&settings, settings_data);
+ if (nhlt_format_append_config(fmt, settings_data, size)) {
+ cbfs_unmap(settings_data);
return -1;
}
- rdev_munmap(&settings, settings_data);
+ cbfs_unmap(settings_data);
}
return 0;
diff --git a/src/mainboard/razer/blade_stealth_kbl/Kconfig b/src/mainboard/razer/blade_stealth_kbl/Kconfig
index 31c29cd31b..3e9f462879 100644
--- a/src/mainboard/razer/blade_stealth_kbl/Kconfig
+++ b/src/mainboard/razer/blade_stealth_kbl/Kconfig
@@ -14,6 +14,7 @@ config BOARD_SPECIFIC_OPTIONS
select DRIVERS_I2C_HID
select HAVE_ACPI_RESUME
select HAVE_ACPI_TABLES
+ select DRIVERS_GENERIC_CBFS_SERIAL
# For now no way to choose the correct the available RAM
config BOARD_RAZER_BLADE_STEALTH_KBL_16GB
diff --git a/src/mainboard/razer/blade_stealth_kbl/Makefile.inc b/src/mainboard/razer/blade_stealth_kbl/Makefile.inc
index 3d8d4fc847..0d4380a6f6 100644
--- a/src/mainboard/razer/blade_stealth_kbl/Makefile.inc
+++ b/src/mainboard/razer/blade_stealth_kbl/Makefile.inc
@@ -2,7 +2,6 @@
subdirs-y += spd
-ramstage-y += mainboard.c
ramstage-y += ramstage.c
ramstage-y += hda_verb.c
diff --git a/src/mainboard/razer/blade_stealth_kbl/mainboard.c b/src/mainboard/razer/blade_stealth_kbl/mainboard.c
deleted file mode 100644
index eecfa3b656..0000000000
--- a/src/mainboard/razer/blade_stealth_kbl/mainboard.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-
-#include <smbios.h>
-#include <string.h>
-#include <cbfs.h>
-
-#define MAX_SERIAL_LENGTH 0x100
-
-const char *smbios_mainboard_serial_number(void)
-{
- static char serial_number[MAX_SERIAL_LENGTH + 1] = {0};
- struct cbfsf file;
-
- if (serial_number[0] != 0)
- return serial_number;
-
- if (cbfs_boot_locate(&file, "serial_number", NULL) == 0) {
- struct region_device cbfs_region;
- size_t ser_len;
-
- cbfs_file_data(&cbfs_region, &file);
-
- ser_len = region_device_sz(&cbfs_region);
- if (ser_len <= MAX_SERIAL_LENGTH) {
- if (rdev_readat(&cbfs_region, serial_number, 0, ser_len) == ser_len) {
- serial_number[ser_len] = 0;
- return serial_number;
- }
- }
- }
-
- strncpy(serial_number, CONFIG_MAINBOARD_SERIAL_NUMBER, MAX_SERIAL_LENGTH);
-
- return serial_number;
-}
diff --git a/src/security/intel/txt/common.c b/src/security/intel/txt/common.c
index 4dd4ad3ddf..437c55edd8 100644
--- a/src/security/intel/txt/common.c
+++ b/src/security/intel/txt/common.c
@@ -215,25 +215,17 @@ static int validate_acm(const void *ptr)
*/
static void *intel_txt_prepare_bios_acm(struct region_device *acm, size_t *acm_len)
{
- struct cbfsf file;
void *acm_data = NULL;
if (!acm || !acm_len)
return NULL;
- if (cbfs_boot_locate(&file, CONFIG_INTEL_TXT_CBFS_BIOS_ACM, NULL)) {
+ acm_data = cbfs_map(CONFIG_INTEL_TXT_CBFS_BIOS_ACM, acm_len);
+ if (!acm_data) {
printk(BIOS_ERR, "TEE-TXT: Couldn't locate BIOS ACM in CBFS.\n");
return NULL;
}
- cbfs_file_data(acm, &file);
- acm_data = rdev_mmap_full(acm);
- *acm_len = region_device_sz(acm);
- if (!acm_data || *acm_len == 0) {
- printk(BIOS_ERR, "TEE-TXT: Couldn't map BIOS ACM from CBFS.\n");
- return NULL;
- }
-
/*
* CPU enforces only 4KiB alignment.
* Chapter A.1.1
@@ -241,7 +233,7 @@ static void *intel_txt_prepare_bios_acm(struct region_device *acm, size_t *acm_l
*/
if (!IS_ALIGNED((uintptr_t)acm_data, 4096)) {
printk(BIOS_ERR, "TEE-TXT: BIOS ACM isn't mapped at page boundary.\n");
- rdev_munmap(acm, acm_data);
+ cbfs_unmap(acm_data);
return NULL;
}
@@ -252,7 +244,7 @@ static void *intel_txt_prepare_bios_acm(struct region_device *acm, size_t *acm_l
*/
if (!IS_ALIGNED(*acm_len, 64)) {
printk(BIOS_ERR, "TEE-TXT: BIOS ACM size isn't multiple of 64.\n");
- rdev_munmap(acm, acm_data);
+ cbfs_unmap(acm_data);
return NULL;
}
@@ -262,7 +254,7 @@ static void *intel_txt_prepare_bios_acm(struct region_device *acm, size_t *acm_l
*/
if (!IS_ALIGNED((uintptr_t)acm_data, (1UL << log2_ceil(*acm_len)))) {
printk(BIOS_ERR, "TEE-TXT: BIOS ACM isn't aligned to its size.\n");
- rdev_munmap(acm, acm_data);
+ cbfs_unmap(acm_data);
return NULL;
}
@@ -273,7 +265,7 @@ static void *intel_txt_prepare_bios_acm(struct region_device *acm, size_t *acm_l
*/
if (popcnt(ALIGN_UP(*acm_len, 4096)) > get_var_mtrr_count()) {
printk(BIOS_ERR, "TEE-TXT: Not enough MTRRs to cache this BIOS ACM's size.\n");
- rdev_munmap(acm, acm_data);
+ cbfs_unmap(acm_data);
return NULL;
}
@@ -283,7 +275,7 @@ static void *intel_txt_prepare_bios_acm(struct region_device *acm, size_t *acm_l
const int ret = validate_acm(acm_data);
if (ret < 0) {
printk(BIOS_ERR, "TEE-TXT: Validation of ACM failed with: %d\n", ret);
- rdev_munmap(acm, acm_data);
+ cbfs_unmap(acm_data);
return NULL;
}
diff --git a/src/security/intel/txt/ramstage.c b/src/security/intel/txt/ramstage.c
index 3401aef336..c830f975a6 100644
--- a/src/security/intel/txt/ramstage.c
+++ b/src/security/intel/txt/ramstage.c
@@ -233,23 +233,14 @@ static void txt_initialize_heap(void)
memset(sinit_base, 0, read64((void *)TXT_SINIT_SIZE));
}
- struct cbfsf file;
/* The following have been removed from BIOS Data Table in version 6 */
- if (!cbfs_boot_locate(&file, CONFIG_INTEL_TXT_CBFS_BIOS_POLICY, NULL)) {
- struct region_device policy;
-
- cbfs_file_data(&policy, &file);
- void *policy_data = rdev_mmap_full(&policy);
- size_t policy_len = region_device_sz(&policy);
-
- if (policy_data && policy_len) {
- /* Point to FIT Type 9 entry in flash */
- data.bdr.lcp_pd_base = (uintptr_t)policy_data;
- data.bdr.lcp_pd_size = (uint64_t)policy_len;
- rdev_munmap(&policy, policy_data);
- } else {
- printk(BIOS_ERR, "TEE-TXT: Couldn't map LCP PD Policy from CBFS.\n");
- }
+ size_t policy_len;
+ void *policy_data = cbfs_map(CONFIG_INTEL_TXT_CBFS_BIOS_POLICY, &policy_len);
+ if (policy_data) {
+ /* Point to FIT Type 9 entry in flash */
+ data.bdr.lcp_pd_base = (uintptr_t)policy_data;
+ data.bdr.lcp_pd_size = (uint64_t)policy_len;
+ cbfs_unmap(policy_data);
} else {
printk(BIOS_ERR, "TEE-TXT: Couldn't locate LCP PD Policy in CBFS.\n");
}
diff --git a/src/soc/amd/common/block/psp/psp_gen1.c b/src/soc/amd/common/block/psp/psp_gen1.c
index 5096dd3adc..076d3548e9 100644
--- a/src/soc/amd/common/block/psp/psp_gen1.c
+++ b/src/soc/amd/common/block/psp/psp_gen1.c
@@ -101,8 +101,6 @@ int psp_load_named_blob(enum psp_blob_type type, const char *name)
int cmd_status;
u32 command;
void *blob;
- struct cbfsf cbfs_file;
- struct region_device rdev;
switch (type) {
case BLOB_SMU_FW:
@@ -122,13 +120,7 @@ int psp_load_named_blob(enum psp_blob_type type, const char *name)
return -PSPSTS_UNSUPPORTED;
}
- if (cbfs_boot_locate(&cbfs_file, name, NULL)) {
- printk(BIOS_ERR, "BUG: Cannot locate blob for PSP loading\n");
- return -PSPSTS_INVALID_NAME;
- }
-
- cbfs_file_data(&rdev, &cbfs_file);
- blob = rdev_mmap_full(&rdev);
+ blob = cbfs_map(name, NULL);
if (!blob) {
printk(BIOS_ERR, "BUG: Cannot map blob for PSP loading\n");
return -PSPSTS_INVALID_NAME;
@@ -140,6 +132,6 @@ int psp_load_named_blob(enum psp_blob_type type, const char *name)
cmd_status = send_psp_command(command, blob);
psp_print_cmd_status(cmd_status, NULL);
- rdev_munmap(&rdev, blob);
+ cbfs_unmap(blob);
return cmd_status;
}
diff --git a/src/soc/nvidia/tegra210/mtc.c b/src/soc/nvidia/tegra210/mtc.c
index b0bba9c4eb..47cbd923ff 100644
--- a/src/soc/nvidia/tegra210/mtc.c
+++ b/src/soc/nvidia/tegra210/mtc.c
@@ -15,30 +15,17 @@ static size_t mtc_table_size;
int tegra210_run_mtc(void)
{
- ssize_t nread;
- struct region_device fh;
- struct cbfsf mtc_file;
-
+ size_t nread;
void *const mtc = (void *)(uintptr_t)CONFIG_MTC_ADDRESS;
void *dvfs_table;
size_t (*mtc_fw)(void **dvfs_table) = (void *)mtc;
- if (cbfs_boot_locate(&mtc_file, "tegra_mtc.bin", NULL)) {
+ nread = cbfs_load("tegra_mtc.bin", mtc, 1*GiB);
+ if (!nread) {
printk(BIOS_ERR, "MTC file not found: tegra_mtc.bin\n");
return -1;
}
- cbfs_file_data(&fh, &mtc_file);
-
- /* Read MTC file into predefined region. */
- nread = rdev_readat(&fh, mtc, 0, region_device_sz(&fh));
-
- if (nread != region_device_sz(&fh)) {
- printk(BIOS_ERR, "MTC bytes read (%zu) != file length(%zu)!\n",
- nread, region_device_sz(&fh));
- return -1;
- }
-
printk(BIOS_INFO, "MTC: %zu bytes loaded @ %p\n", nread, mtc);
mtc_table_size = (*mtc_fw)(&dvfs_table);