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 | |
parent | cba7316c2662ee1c916345b034ca08dad43984f7 (diff) |
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')
-rw-r--r-- | src/soc/intel/common/opregion.c | 5 | ||||
-rw-r--r-- | src/soc/intel/common/vbt.c | 28 | ||||
-rw-r--r-- | src/soc/intel/common/vbt.h | 4 |
3 files changed, 25 insertions, 12 deletions
diff --git a/src/soc/intel/common/opregion.c b/src/soc/intel/common/opregion.c index 1eb8609ada..b8111a0760 100644 --- a/src/soc/intel/common/opregion.c +++ b/src/soc/intel/common/opregion.c @@ -23,11 +23,10 @@ enum cb_err init_igd_opregion(igd_opregion_t *opregion) { - struct region_device vbt_rdev; optionrom_vbt_t *vbt; optionrom_vbt_t *ext_vbt; - vbt = locate_vbt(&vbt_rdev); + vbt = locate_vbt(); if (!vbt) { printk(BIOS_ERR, "VBT couldn't be read\n"); @@ -64,7 +63,5 @@ enum cb_err init_igd_opregion(igd_opregion_t *opregion) /* FIXME We just assume we're mobile for now */ opregion->header.mailboxes = MAILBOXES_MOBILE; - rdev_munmap(&vbt_rdev, vbt); - return CB_SUCCESS; } 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); diff --git a/src/soc/intel/common/vbt.h b/src/soc/intel/common/vbt.h index 2d52fea6ed..615af4b29c 100644 --- a/src/soc/intel/common/vbt.h +++ b/src/soc/intel/common/vbt.h @@ -28,10 +28,10 @@ const char *mainboard_vbt_filename(void); /* locate vbt.bin file. Returns a pointer to its content. */ -void *locate_vbt(struct region_device *rdev); +void *locate_vbt(void); /* * Returns VBT pointer and mapping after checking prerequisites for Pre OS * Graphics initialization */ -void *vbt_get(struct region_device *rdev); +void *vbt_get(void); #endif |