summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2010-12-23 11:29:38 +0200
committerKevin O'Connor <kevin@koconnor.net>2010-12-24 10:49:27 -0500
commitb9a7591188b9a6f43dfa66ec6020f64a939c6fdb (patch)
treeab4bb4b2dfcd53e252abad429955b416916e0219
parent2e109a692553f4c198f3bf755391ccdc3bc1e68a (diff)
Read bootorder file into memory.
Read bootorder file, parse it and put it into array for easy consumption. Signed-off-by: Gleb Natapov <gleb@redhat.com>
-rw-r--r--src/boot.c45
-rw-r--r--src/boot.h2
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