[SeaBIOS] [PATCHv2] coreboot: Try to auto-detect if the CBFS anchor pointer is a relative pointer

Kevin O'Connor kevin at koconnor.net
Thu Jul 9 01:21:05 CEST 2015


If CONFIG_CBFS_LOCATION is set to a non-zero value then it means the
CBFS flash is not at the very end of memory.  In this case, it's
unclear if the anchor pointer is an absolute pointer or if it is
relative to CONFIG_CBFS_LOCATION.  Some devices have been using
absolute pointers, but it appears some devices are now using relative
pointers there.  Since the anchor pointer almost always points to a
structure in the last 64K of the rom, it should be possible to
auto-detect if the pointer is relative or not.

Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---

Previous patch had a typo that broke normal CBFS users.  This patch
should be better.

---
 src/fw/coreboot.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/fw/coreboot.c b/src/fw/coreboot.c
index 8fd8449..b077fe1 100644
--- a/src/fw/coreboot.c
+++ b/src/fw/coreboot.c
@@ -421,6 +421,9 @@ coreboot_cbfs_init(void)
         return;
 
     struct cbfs_header *hdr = *(void **)(CONFIG_CBFS_LOCATION - 4);
+    if (CONFIG_CBFS_LOCATION && (u32)hdr > CONFIG_CBFS_LOCATION)
+        // Looks like the pointer is relative to CONFIG_CBFS_LOCATION
+        hdr = (void*)hdr + CONFIG_CBFS_LOCATION;
     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));
-- 
1.9.3




More information about the SeaBIOS mailing list