On Fri, Jan 17, 2014 at 08:27:19PM -0500, Kevin O'Connor wrote:
The Google builds of SeaBIOS place the CBFS data in a non-standard location. Add a config parameter to support non-standard locations. This is based on a patch from Stefan Reinauer reinauer@chromium.org in the Chromium seabios repo (commit 60534ec785).
The previous patch missed a conversion. Below is an updated patch (which I have tested on my acer c720).
-Kevin
From 71dbcf7e972823cf74a42958c8dc5b2bc302623e Mon Sep 17 00:00:00 2001
From: Kevin O'Connor kevin@koconnor.net Date: Fri, 17 Jan 2014 20:21:20 -0500 Subject: [PATCH] coreboot: Support alternative locations for CBFS. To: seabios@seabios.org
The Google builds of SeaBIOS place the CBFS data in a non-standard location. Add a config parameter to support non-standard locations. This is based on a patch from Stefan Reinauer reinauer@chromium.org in the Chromium seabios repo (commit 60534ec785).
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/Kconfig | 12 +++++++++++- src/fw/coreboot.c | 10 +++++----- 2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/Kconfig b/src/Kconfig index a42ab2d..071a16e 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -96,7 +96,17 @@ endchoice default y help Support CBFS files compressed using the lzma decompression - algorighm. + algorithm. + config CBFS_LOCATION + depends on COREBOOT_FLASH + hex "CBFS memory end location" + default 0 + help + Memory address of where the CBFS data ends. This should + be zero for normal builds. It may be a non-zero value if + the CBFS filesystem is at a non-standard location (eg, + 0xffe00000 if CBFS ends 2Meg below the end of flash). + config FLASH_FLOPPY depends on COREBOOT_FLASH bool "Floppy images in CBFS" diff --git a/src/fw/coreboot.c b/src/fw/coreboot.c index 01a6fcd..88ac5d9 100644 --- a/src/fw/coreboot.c +++ b/src/fw/coreboot.c @@ -297,7 +297,6 @@ ulzma(u8 *dst, u32 maxlen, const u8 *src, u32 srclen) ****************************************************************/
#define CBFS_HEADER_MAGIC 0x4F524243 -#define CBFS_HEADPTR_ADDR 0xFFFFFFFc #define CBFS_VERSION1 0x31313131
struct cbfs_header { @@ -369,7 +368,7 @@ coreboot_cbfs_init(void) if (!CONFIG_COREBOOT_FLASH) return;
- struct cbfs_header *hdr = *(void **)CBFS_HEADPTR_ADDR; + struct cbfs_header *hdr = *(void **)(CONFIG_CBFS_LOCATION - 4); if (hdr->magic != cpu_to_be32(CBFS_HEADER_MAGIC)) { dprintf(1, "Unable to find CBFS (ptr=%p; got %x not %x)\n" , hdr, hdr->magic, cpu_to_be32(CBFS_HEADER_MAGIC)); @@ -377,10 +376,11 @@ coreboot_cbfs_init(void) } dprintf(1, "Found CBFS header at %p\n", hdr);
- struct cbfs_file *fhdr = (void *)(0 - be32_to_cpu(hdr->romsize) - + be32_to_cpu(hdr->offset)); + u32 romsize = be32_to_cpu(hdr->romsize); + u32 romstart = CONFIG_CBFS_LOCATION - romsize; + struct cbfs_file *fhdr = (void*)romstart + be32_to_cpu(hdr->offset); for (;;) { - if (fhdr < (struct cbfs_file *)(0xFFFFFFFF - be32_to_cpu(hdr->romsize))) + if ((u32)fhdr - romstart > romsize) break; u64 magic = fhdr->magic; if (magic != CBFS_FILE_MAGIC)