diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2014-02-16 15:25:38 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2014-02-17 14:15:43 -0500 |
commit | b62632a3c78e39b9d5fbbed23779c12bac2c0f6b (patch) | |
tree | 7155da9140199d61912e8eebf9638ccb5bf64ba9 /src | |
parent | d15b0107d6f0f10e259a8937f7695e2130d5e9e4 (diff) | |
download | seabios-hppa-b62632a3c78e39b9d5fbbed23779c12bac2c0f6b.zip seabios-hppa-b62632a3c78e39b9d5fbbed23779c12bac2c0f6b.tar.gz seabios-hppa-b62632a3c78e39b9d5fbbed23779c12bac2c0f6b.tar.bz2 |
coreboot: Move links file processing to its own function.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/fw/coreboot.c | 76 |
1 files changed, 41 insertions, 35 deletions
diff --git a/src/fw/coreboot.c b/src/fw/coreboot.c index 2f39e3e..34ad8fd 100644 --- a/src/fw/coreboot.c +++ b/src/fw/coreboot.c @@ -362,6 +362,46 @@ cbfs_copyfile(struct romfile_s *file, void *dst, u32 maxlen) return size; } +// 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. +static void +process_links_file(void) +{ + 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'; + char *comment = strchr(linkname, '#'); + if (comment) + *comment = '\0'; + linkname = nullTrailingSpace(linkname); + char *destname = strchr(linkname, ' '); + if (!destname) + continue; + *destname++ = '\0'; + destname = nullTrailingSpace(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); +} + void coreboot_cbfs_init(void) { @@ -409,41 +449,7 @@ coreboot_cbfs_init(void) , 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'; - char *comment = strchr(linkname, '#'); - if (comment) - *comment = '\0'; - linkname = nullTrailingSpace(linkname); - char *destname = strchr(linkname, ' '); - if (!destname) - continue; - *destname++ = '\0'; - destname = nullTrailingSpace(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); + process_links_file(); } struct cbfs_payload_segment { |