On Thu, Jan 30, 2014 at 12:30:11PM -0500, Kevin O'Connor wrote:
> 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(a)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.
FYI, below is a version of the patch with a more resilent parser.
Same comments as above.
-Kevin
>From 1e44227576fc76d81bfd3ee5ccb32bca827f17b1 Mon Sep 17 00:00:00 2001
Message-Id: <1e44227576fc76d81bfd3ee5ccb32bca827f17b1.1391213161.git.kevin(a)koconnor.net>
From: Kevin O'Connor <kevin(a)koconnor.net>
Date: Fri, 17 Jan 2014 12:11:49 -0500
Subject: [PATCH] coreboot: Add support for a "links" file to have aliases in
CBFS.
To: seabios(a)seabios.org
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(a)koconnor.net>
---
src/fw/coreboot.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/src/fw/coreboot.c b/src/fw/coreboot.c
index df8fca8..cfb7a70 100644
--- a/src/fw/coreboot.c
+++ b/src/fw/coreboot.c
@@ -408,6 +408,45 @@ 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), *next = links;
+ while (next) {
+ // Parse out linkname and destname
+ char *linkname = next;
+ next = strchr(linkname, '\n');
+ if (next)
+ *next++ = '\0';
+ while (*linkname && *linkname <= ' ')
+ linkname++;
+ char *comment = strchr(linkname, '#');
+ if (comment)
+ *comment = '\0';
+ nullTrailingSpace(linkname);
+ char *destname = strchr(linkname, ' ');
+ if (!destname)
+ continue;
+ *destname++ = '\0';
+ while (*destname && *destname <= ' ')
+ destname++;
+ // Lookup destname and create new romfile entry for linkname
+ struct romfile_s *ufile = romfile_find(destname);
+ 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