diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2014-01-17 12:11:49 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2014-02-17 14:15:43 -0500 |
commit | 2a3ed1eb9583625b318bbb26458926394b80901e (patch) | |
tree | 70143fe462a0d67938477a321db7620ad4ccb36c /src | |
parent | 2620984b42fd2a374e94c75f04982c60edf179cb (diff) | |
download | seabios-hppa-2a3ed1eb9583625b318bbb26458926394b80901e.zip seabios-hppa-2a3ed1eb9583625b318bbb26458926394b80901e.tar.gz seabios-hppa-2a3ed1eb9583625b318bbb26458926394b80901e.tar.bz2 |
coreboot: Add support for a "links" file to have aliases in CBFS.
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@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/fw/coreboot.c | 39 |
1 files changed, 39 insertions, 0 deletions
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 { |