diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/drivers/intel/fsp2_0/graphics.c | 5 | ||||
-rw-r--r-- | src/soc/intel/apollolake/chip.c | 6 | ||||
-rw-r--r-- | src/soc/intel/cannonlake/chip.c | 10 | ||||
-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 |
6 files changed, 28 insertions, 30 deletions
diff --git a/src/drivers/intel/fsp2_0/graphics.c b/src/drivers/intel/fsp2_0/graphics.c index e2ff7cf4f8..f2888e8575 100644 --- a/src/drivers/intel/fsp2_0/graphics.c +++ b/src/drivers/intel/fsp2_0/graphics.c @@ -96,10 +96,7 @@ enum cb_err fsp_fill_lb_framebuffer(struct lb_framebuffer *framebuffer) uintptr_t fsp_load_vbt(void) { - struct region_device rdev; - void *vbt_data = NULL; - - vbt_data = locate_vbt(&rdev); + void *vbt_data = locate_vbt(); if (vbt_data == NULL) printk(BIOS_NOTICE, "Could not locate a VBT file in CBFS\n"); diff --git a/src/soc/intel/apollolake/chip.c b/src/soc/intel/apollolake/chip.c index 5759fb6f4c..f122876ab6 100644 --- a/src/soc/intel/apollolake/chip.c +++ b/src/soc/intel/apollolake/chip.c @@ -49,7 +49,6 @@ #include "chip.h" static void *vbt; -static struct region_device vbt_rdev; static const char *soc_acpi_name(const struct device *dev) { @@ -317,7 +316,7 @@ static void soc_init(void *data) struct global_nvs_t *gnvs; /* Save VBT info and mapping */ - vbt = vbt_get(&vbt_rdev); + vbt = vbt_get(); /* Snapshot the current GPIO IRQ polarities. FSP is setting a * default policy that doesn't honor boards' requirements. */ @@ -354,9 +353,6 @@ static void soc_init(void *data) static void soc_final(void *data) { - if (vbt) - rdev_munmap(&vbt_rdev, vbt); - /* Disable global reset, just in case */ pmc_global_reset_enable(0); /* Make sure payload/OS can't trigger global reset */ diff --git a/src/soc/intel/cannonlake/chip.c b/src/soc/intel/cannonlake/chip.c index e1cf167629..57a32244ca 100644 --- a/src/soc/intel/cannonlake/chip.c +++ b/src/soc/intel/cannonlake/chip.c @@ -26,7 +26,6 @@ #include <string.h> static void *vbt; -static struct region_device vbt_rdev; #if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) static const char *soc_acpi_name(const struct device *dev) @@ -164,17 +163,10 @@ static void soc_enable(device_t dev) dev->ops = &cpu_bus_ops; } -static void soc_final(void *data) -{ - if (vbt) - rdev_munmap(&vbt_rdev, vbt); -} - struct chip_operations soc_intel_cannonlake_ops = { CHIP_NAME("Intel Cannonlake") .enable_dev = &soc_enable, .init = &soc_init_pre_device, - .final = &soc_final }; /* UPD parameters to be initialized before SiliconInit */ @@ -189,7 +181,7 @@ void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd) parse_devicetree(params); /* Save VBT info and mapping */ - vbt = vbt_get(&vbt_rdev); + vbt = vbt_get(); /* Load VBT before devicetree-specific config. */ params->GraphicsConfigPtr = (uintptr_t)vbt; 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 |