From: Gleb Natapov Date: Thu, 23 Dec 2010 09:29:38 +0000 (+0200) Subject: Read bootorder file into memory. X-Git-Tag: rel-0.6.2~41 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b9a7591188b9a6f43dfa66ec6020f64a939c6fdb;p=seabios.git Read bootorder file into memory. Read bootorder file, parse it and put it into array for easy consumption. Signed-off-by: Gleb Natapov --- 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