[SeaBIOS] [RFC][PATCH] coreboot: Add support for a "links" file to have aliases in CBFS.

Kevin O'Connor kevin at koconnor.net
Thu Jan 30 18:30:11 CET 2014


The "links" file is a newline separated list where each line is a
"link name" followed by a "destination name" separated by a space
character.  For each line, SeaBIOS will consider each "link name" to
be a CBFS file that has the contents found in the CBFS file with
"destination name".

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

This patch may be useful for those using intel option roms where the
same rom is used on a number of VGA devices with different
vendor/device ids.  With this patch, one can make a "links" file with
the list of devices (eg, "pci8086,0a06.rom") that all point to the
same physical rom (eg, "pci8086,0406.rom").

It's possible to implement this aliasing approach in a number of
different ways.  The approach taken in this patch is a single file
with all the link names.  This was done based on feedback that there
could be 20 or more aliases for a single rom and creating individual
CBFS files for each link would be unwieldy.

That said, I'm not sure this is the best approach.  I'm circulating it
for comments.

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

diff --git a/src/fw/coreboot.c b/src/fw/coreboot.c
index df8fca8..270d01a 100644
--- a/src/fw/coreboot.c
+++ b/src/fw/coreboot.c
@@ -408,6 +408,40 @@ coreboot_cbfs_init(void)
         fhdr = (void*)ALIGN((u32)cfile->data + cfile->rawsize
                             , be32_to_cpu(hdr->align));
     }
+
+    // Process CBFS links file.  The links file is a newline separated
+    // file where each line has a "link name" and a destination name
+    // separated by a space character.
+    char *links = romfile_loadfile("links", NULL);
+    if (!links)
+        return;
+    char *p = links;
+    for (;;) {
+        char *linkname = p;
+        char *end = strchr(linkname, '\n');
+        if (!end)
+            break;
+        *end = '\0';
+        p = end + 1;
+        char *linkend = strchr(linkname, ' ');
+        if (!linkend || linkname == linkend)
+            continue;
+        *linkend = '\0';
+        struct romfile_s *ufile = romfile_find(linkend+1);
+        if (!ufile)
+            continue;
+        struct cbfs_romfile_s *cufile
+            = container_of(ufile, struct cbfs_romfile_s, file);
+        struct cbfs_romfile_s *cfile = malloc_tmp(sizeof(*cfile));
+        if (!cfile) {
+            warn_noalloc();
+            break;
+        }
+        memcpy(cfile, cufile, sizeof(*cfile));
+        strtcpy(cfile->file.name, linkname, sizeof(cfile->file.name));
+        romfile_add(&cfile->file);
+    }
+    free(links);
 }
 
 struct cbfs_payload_segment {
-- 
1.8.5.3




More information about the SeaBIOS mailing list