diff options
author | Patrick Georgi <pgeorgi@google.com> | 2017-10-05 18:10:09 +0200 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2017-10-06 16:59:31 +0000 |
commit | 9d3de2649f46cc85269b4877f0d6e715a4fec5aa (patch) | |
tree | 3c5dc7955bc90ff0a2c6c097f1c6453f3ec35bd7 /src/soc/intel/common/vbt.c | |
parent | cba7316c2662ee1c916345b034ca08dad43984f7 (diff) | |
download | coreboot-9d3de2649f46cc85269b4877f0d6e715a4fec5aa.tar.xz |
soc/intel/common: refactor locate_vbt and vbt_get
Instead of having all callers provide a region_device just for the
purpose of reading vbt.bin, let locate_vbt handle its entire life cycle,
simplifying the VBT access API.
Change-Id: Ib85e55164e217050b67674d020d17b2edf5ad14d
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/21897
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/soc/intel/common/vbt.c')
-rw-r--r-- | src/soc/intel/common/vbt.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/soc/intel/common/vbt.c b/src/soc/intel/common/vbt.c index c36f797c9b..eba7d40430 100644 --- a/src/soc/intel/common/vbt.c +++ b/src/soc/intel/common/vbt.c @@ -17,6 +17,7 @@ #include <console/console.h> #include <arch/acpi.h> #include <bootmode.h> +#include <bootstate.h> #include "vbt.h" @@ -28,11 +29,17 @@ const char *mainboard_vbt_filename(void) return "vbt.bin"; } -void *locate_vbt(struct region_device *rdev) +static struct region_device vbt_rdev; +static void *vbt_data; + +void *locate_vbt(void) { uint32_t vbtsig = 0; struct cbfsf file_desc; + if (vbt_data != NULL) + return vbt_data; + const char *filename = mainboard_vbt_filename(); if (cbfs_boot_locate(&file_desc, filename, NULL) < 0) { @@ -40,18 +47,19 @@ void *locate_vbt(struct region_device *rdev) return NULL; } - cbfs_file_data(rdev, &file_desc); - rdev_readat(rdev, &vbtsig, 0, sizeof(uint32_t)); + cbfs_file_data(&vbt_rdev, &file_desc); + rdev_readat(&vbt_rdev, &vbtsig, 0, sizeof(uint32_t)); if (vbtsig != VBT_SIGNATURE) { printk(BIOS_ERR, "Missing/invalid signature in VBT data file!\n"); return NULL; } - return rdev_mmap_full(rdev); + vbt_data = rdev_mmap_full(&vbt_rdev); + return vbt_data; } -void *vbt_get(struct region_device *rdev) +void *vbt_get(void) { if (!IS_ENABLED(CONFIG_RUN_FSP_GOP)) return NULL; @@ -62,5 +70,13 @@ void *vbt_get(struct region_device *rdev) return NULL; if (!display_init_required()) return NULL; - return locate_vbt(rdev); + return locate_vbt(); +} + +static void unmap_vbt(void *unused) +{ + if (vbt_data) + rdev_munmap(&vbt_rdev, vbt_data); } +BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, unmap_vbt, NULL); +BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, unmap_vbt, NULL); |