[SeaBIOS] [PATCH 4/9] Read bootorder file into memory.

Gleb Natapov gleb at redhat.com
Thu Dec 23 10:29:38 CET 2010


Read bootorder file, parse it and put it into array for easy
consumption.

Signed-off-by: Gleb Natapov <gleb at redhat.com>
---
 src/boot.c |   45 +++++++++++++++++++++++++++++++++++++++++++++
 src/boot.h |    2 ++
 2 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/src/boot.c b/src/boot.c
index 9c94439..9c37023 100644
--- a/src/boot.c
+++ b/src/boot.c
@@ -67,6 +67,51 @@ boot_setup(void)
         if (!(inb_cmos(CMOS_BIOS_BOOTFLAG1) & 1))
             IPL.checkfloppysig = 1;
     }
+
+    u32 file = romfile_find("bootorder");
+    if (!file)
+        return;
+
+    int filesize = romfile_size(file);
+    dprintf(3, "bootorder file found (len %d)\n", filesize);
+
+    if (filesize == 0)
+        return;
+
+    char *f = malloc_tmphigh(filesize);
+
+    if (!f) {
+        warn_noalloc();
+        return;
+    }
+
+    romfile_copy(file, f, filesize);
+    int i;
+    IPL.fw_bootorder_count = 1;
+    while(f[i]) {
+        if (f[i] == '\n')
+            IPL.fw_bootorder_count++;
+        i++;
+    }
+    IPL.fw_bootorder = malloc_tmphigh(IPL.fw_bootorder_count*sizeof(char*));
+    if (!IPL.fw_bootorder) {
+        warn_noalloc();
+        free(f);
+        return;
+    }
+
+    dprintf(3, "boot order:\n");
+    i = 0;
+    do {
+        IPL.fw_bootorder[i] = f;
+        f = strchr(f, '\n');
+        if (f) {
+            *f = '\0';
+            f++;
+            dprintf(3, "%d: %s\n", i, IPL.fw_bootorder[i]);
+            i++;
+        }
+    } while(f);
 }
 
 // Add a BEV vector for a given pnp compatible option rom.
diff --git a/src/boot.h b/src/boot.h
index f751d71..778aebd 100644
--- a/src/boot.h
+++ b/src/boot.h
@@ -20,6 +20,8 @@ struct ipl_s {
     int bevcount, bcvcount;
     u32 bootorder;
     int checkfloppysig;
+    char **fw_bootorder;
+    int fw_bootorder_count;
 };
 
 #define IPL_TYPE_FLOPPY      0x01
-- 
1.7.2.3




More information about the SeaBIOS mailing list