]> xenbits.xensource.com Git - seabios.git/commitdiff
coreboot: Move links file processing to its own function.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 16 Feb 2014 20:25:38 +0000 (15:25 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Mon, 17 Feb 2014 19:15:43 +0000 (14:15 -0500)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/fw/coreboot.c

index 2f39e3e20161d2fd810b45d2fcf5404e41c126a8..34ad8fdcf075ab0a0eb17d5ad8a0f30d3535540c 100644 (file)
@@ -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 {