diff options
author | Patrick Georgi <pgeorgi@google.com> | 2018-04-30 15:14:35 +0200 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2018-05-02 14:32:21 +0000 |
commit | 77034fa7d4402aab9eef84fc652b0493a2024026 (patch) | |
tree | 2896c6cdc18956c3ff2304c667d2cadd6cb98d26 | |
parent | e134db253589cff2f8c4cfba171a18c75430aad8 (diff) |
intel/common: compress VBT
It's pretty well compressible which helps when space is tight.
The code encodes the assumption that the VBT is 8kb or less. Haven't
seen a larger one yet.
BUG=b:77971803,b:78541692
TEST=build, see that vbt.bin is compressed, boot, check log that the
reported VBT size is correct.
Change-Id: Ie25bca21d9edc408f441a292bbe2ab0459948ec4
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/25927
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r-- | src/drivers/intel/gma/Makefile.inc | 1 | ||||
-rw-r--r-- | src/soc/intel/common/vbt.c | 35 |
2 files changed, 15 insertions, 21 deletions
diff --git a/src/drivers/intel/gma/Makefile.inc b/src/drivers/intel/gma/Makefile.inc index ab799ef99a..0bcf590c55 100644 --- a/src/drivers/intel/gma/Makefile.inc +++ b/src/drivers/intel/gma/Makefile.inc @@ -24,6 +24,7 @@ ramstage-$(CONFIG_INTEL_GMA_ACPI) += opregion.c cbfs-files-$(CONFIG_INTEL_GMA_ADD_VBT_DATA_FILE) += vbt.bin vbt.bin-file := $(call strip_quotes,$(CONFIG_INTEL_GMA_VBT_FILE)) vbt.bin-type := raw +vbt.bin-compression := lzma ifeq ($(CONFIG_MAINBOARD_USE_LIBGFXINIT),y) diff --git a/src/soc/intel/common/vbt.c b/src/soc/intel/common/vbt.c index 3d8f2bffbe..9e3cb3516b 100644 --- a/src/soc/intel/common/vbt.c +++ b/src/soc/intel/common/vbt.c @@ -30,34 +30,35 @@ const char *mainboard_vbt_filename(void) return "vbt.bin"; } -static struct region_device vbt_rdev; -static void *vbt_data; +static char vbt_data[8 * KiB]; +static int vbt_data_used; void *locate_vbt(void) { uint32_t vbtsig = 0; - struct cbfsf file_desc; - if (vbt_data != NULL) - return vbt_data; + if (vbt_data_used == 1) + return (void *)vbt_data; const char *filename = mainboard_vbt_filename(); - if (cbfs_boot_locate(&file_desc, filename, NULL) < 0) { - printk(BIOS_ERR, "Could not locate a VBT file in in CBFS\n"); - return NULL; - } + size_t file_size = cbfs_boot_load_file(filename, + vbt_data, sizeof(vbt_data), CBFS_TYPE_RAW); - cbfs_file_data(&vbt_rdev, &file_desc); - rdev_readat(&vbt_rdev, &vbtsig, 0, sizeof(uint32_t)); + if (file_size == 0) + return NULL; + memcpy(&vbtsig, vbt_data, sizeof(vbtsig)); if (vbtsig != VBT_SIGNATURE) { printk(BIOS_ERR, "Missing/invalid signature in VBT data file!\n"); return NULL; } - vbt_data = rdev_mmap_full(&vbt_rdev); - return vbt_data; + printk(BIOS_INFO, "Found a VBT of %zu bytes after decompression\n", + file_size); + vbt_data_used = 1; + + return (void *)vbt_data; } void *vbt_get(void) @@ -73,11 +74,3 @@ void *vbt_get(void) return NULL; 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); |