]> xenbits.xensource.com Git - seabios.git/commitdiff
coreboot: Support alternative locations for CBFS.
authorKevin O'Connor <kevin@koconnor.net>
Sat, 18 Jan 2014 01:21:20 +0000 (20:21 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Wed, 22 Jan 2014 22:30:30 +0000 (17:30 -0500)
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
src/fw/coreboot.c

index a42ab2deb0cbaf110b717efe486f559a84104ff3..071a16eacd7f2a3db58b1d02e71f17f56a6d659d 100644 (file)
@@ -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"
index 01a6fcd9359a80a98ebd9782df68d9794cd30e40..88ac5d9defc36966255cdbf2a6e048ab57a2892a 100644 (file)
@@ -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)