Move IPL definitions from ebda to global variables.
authorKevin O'Connor <kevin@koconnor.net>
Mon, 29 Dec 2008 04:43:20 +0000 (23:43 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Mon, 29 Dec 2008 04:43:20 +0000 (23:43 -0500)
The boot sequence variable remains in ebda.
Move boot specific definitions to a new header (boot.h)

src/biosvar.h
src/boot.c
src/boot.h [new file with mode: 0644]
src/optionroms.c
src/post.c
src/post_menu.c
src/util.h

index dc708022757b15d2b7f9e75bc03e78a4d2d14b37..1a6da34abc3a85f840d94375d79846e14fe7deaf 100644 (file)
@@ -128,31 +128,6 @@ struct bios_data_area_s {
     } while (0)
 
 
-/****************************************************************
- * Initial Program Load (IPL)
- ****************************************************************/
-
-struct ipl_entry_s {
-    u16 type;
-    u16 flags;
-    u32 vector;
-    char *description;
-};
-
-struct ipl_s {
-    struct ipl_entry_s table[8];
-    u16 count;
-    u16 sequence;
-    u32 bootorder;
-    u8 checkfloppysig;
-};
-
-#define IPL_TYPE_FLOPPY      0x01
-#define IPL_TYPE_HARDDISK    0x02
-#define IPL_TYPE_CDROM       0x03
-#define IPL_TYPE_BEV         0x80
-
-
 /****************************************************************
  * Extended Bios Data Area (EBDA)
  ****************************************************************/
@@ -218,8 +193,7 @@ struct extended_bios_data_area_s {
     // Locks for removable devices
     u8 cdrom_locks[CONFIG_MAX_ATA_DEVICES];
 
-    // Initial program load
-    struct ipl_s ipl;
+    u16 boot_sequence;
 
     // Resume stack
     u8 resume_stack[128] __aligned(8);
index ca1b9806a4527f6f4a3c72d24b1f23fdc09c6456..b8104a5745575bc7ab2660d4425a3d3b19eb26cf 100644 (file)
@@ -11,6 +11,9 @@
 #include "ata.h" // ata_detect
 #include "disk.h" // cdrom_boot
 #include "bregs.h" // struct bregs
+#include "boot.h" // struct ipl_s
+
+struct ipl_s IPL;
 
 //--------------------------------------------------------------------------
 // print_boot_device
@@ -24,7 +27,7 @@ static const char drivetypes[][10]={
 void
 printf_bootdev(u16 bootdev)
 {
-    u16 type = GET_EBDA(ipl.table[bootdev].type);
+    u16 type = IPL.table[bootdev].type;
 
     /* NIC appears as type 0x80 */
     if (type == IPL_TYPE_BEV)
@@ -34,7 +37,7 @@ printf_bootdev(u16 bootdev)
     printf("%s", drivetypes[type]);
 
     /* print product string if BEV */
-    char *far_description = GET_EBDA(ipl.table[bootdev].description);
+    char *far_description = IPL.table[bootdev].description;
     if (type == 4 && far_description != 0) {
         char description[33];
         /* first 32 bytes are significant */
@@ -80,9 +83,9 @@ try_boot(u16 seq_nr)
     if (! CONFIG_BOOT)
         BX_PANIC("Boot support not compiled in.\n");
 
-    SET_EBDA(ipl.sequence, seq_nr);
+    SET_EBDA(boot_sequence, seq_nr);
 
-    u32 bootdev = GET_EBDA(ipl.bootorder);
+    u32 bootdev = IPL.bootorder;
     bootdev >>= 4 * seq_nr;
     bootdev &= 0xf;
 
@@ -92,7 +95,7 @@ try_boot(u16 seq_nr)
     /* Translate bootdev to an IPL table offset by subtracting 1 */
     bootdev -= 1;
 
-    if (bootdev >= GET_EBDA(ipl.count)) {
+    if (bootdev >= IPL.count) {
         dprintf(1, "Invalid boot device (0x%x)\n", bootdev);
         return;
     }
@@ -101,7 +104,7 @@ try_boot(u16 seq_nr)
      * address, and bootdrv as the boot drive */
     print_boot_device(bootdev);
 
-    u16 type = GET_EBDA(ipl.table[bootdev].type);
+    u16 type = IPL.table[bootdev].type;
 
     u16 bootseg, bootip;
     u8 bootdrv = 0;
@@ -129,7 +132,7 @@ try_boot(u16 seq_nr)
 
         /* Always check the signature on a HDD boot sector; on FDD,
          * only do the check if configured for it */
-        if (type != IPL_TYPE_FLOPPY || GET_EBDA(ipl.checkfloppysig)) {
+        if (type != IPL_TYPE_FLOPPY || IPL.checkfloppysig) {
             if (GET_FARVAR(bootseg, *(u16*)0x1fe) != 0xaa55) {
                 print_boot_failure(type, 0);
                 return;
@@ -161,7 +164,7 @@ try_boot(u16 seq_nr)
     case IPL_TYPE_BEV: {
         /* Expansion ROM with a Bootstrap Entry Vector (a far
          * pointer) */
-        u32 vector = GET_EBDA(ipl.table[bootdev].vector);
+        u32 vector = IPL.table[bootdev].vector;
         bootseg = vector >> 16;
         bootip = vector & 0xffff;
         break;
@@ -199,7 +202,7 @@ handle_18()
 {
     debug_serial_setup();
     debug_enter(NULL, DEBUG_HDL_18);
-    u16 seq = GET_EBDA(ipl.sequence) + 1;
+    u16 seq = GET_EBDA(boot_sequence) + 1;
     do_boot(seq);
 }
 
diff --git a/src/boot.h b/src/boot.h
new file mode 100644 (file)
index 0000000..a5fe08e
--- /dev/null
@@ -0,0 +1,41 @@
+// Storage for boot definitions.
+#ifndef __BOOT_H
+#define __BOOT_H
+
+
+/****************************************************************
+ * Initial Program Load (IPL)
+ ****************************************************************/
+
+struct ipl_entry_s {
+    u16 type;
+    u16 flags;
+    u32 vector;
+    char *description;
+};
+
+struct ipl_s {
+    struct ipl_entry_s table[8];
+    u16 count;
+    u32 bootorder;
+    u8 checkfloppysig;
+};
+
+#define IPL_TYPE_FLOPPY      0x01
+#define IPL_TYPE_HARDDISK    0x02
+#define IPL_TYPE_CDROM       0x03
+#define IPL_TYPE_BEV         0x80
+
+
+/****************************************************************
+ * Function defs
+ ****************************************************************/
+
+// boot.c
+extern struct ipl_s IPL;
+void printf_bootdev(u16 bootdev);
+
+// post_menu.c
+void interactive_bootmenu();
+
+#endif // __BOOT_H
index b7bc11084d032385c4282b9144332b254ac9381b..44001ee0a24bba547c53672620cc03a124c28699 100644 (file)
@@ -6,11 +6,13 @@
 // This file may be distributed under the terms of the GNU GPLv3 license.
 
 #include "bregs.h" // struct bregs
-#include "biosvar.h" // struct ipl_entry_s
+#include "farptr.h" // FARPTR_TO_SEG
+#include "config.h" // CONFIG_*
 #include "util.h" // dprintf
 #include "pci.h" // pci_find_class
 #include "pci_regs.h" // PCI_ROM_ADDRESS
 #include "pci_ids.h" // PCI_CLASS_DISPLAY_VGA
+#include "boot.h" // IPL
 
 
 /****************************************************************
@@ -156,11 +158,10 @@ add_ipl(struct rom_header *rom, struct pnp_data *pnp)
     if (! CONFIG_BOOT)
         return;
 
-    struct extended_bios_data_area_s *ebda = get_ebda_ptr();
-    if (ebda->ipl.count >= ARRAY_SIZE(ebda->ipl.table))
+    if (IPL.count >= ARRAY_SIZE(IPL.table))
         return;
 
-    struct ipl_entry_s *ip = &ebda->ipl.table[ebda->ipl.count];
+    struct ipl_entry_s *ip = &IPL.table[IPL.count];
     ip->type = IPL_TYPE_BEV;
     ip->vector = (FARPTR_TO_SEG(rom) << 16) | pnp->bev;
 
@@ -168,7 +169,7 @@ add_ipl(struct rom_header *rom, struct pnp_data *pnp)
     if (desc)
         ip->description = MAKE_FARPTR(FARPTR_TO_SEG(rom), desc);
 
-    ebda->ipl.count++;
+    IPL.count++;
 }
 
 // Copy a rom to its permanent location below 1MiB
index ec55ab2394d2b6425af87a4f34e65dde848110e6..cc86abff8f379ee2934a4c15d4f7ccba4c67c0e7 100644 (file)
@@ -17,6 +17,7 @@
 #include "pci.h" // create_pirtable
 #include "acpi.h" // acpi_bios_init
 #include "bregs.h" // struct bregs
+#include "boot.h" // IPL
 
 #define bda ((struct bios_data_area_s *)MAKE_FARPTR(SEG_BDA, 0))
 
@@ -156,8 +157,7 @@ init_boot_vectors()
     dprintf(3, "init boot device ordering\n");
 
     // Floppy drive
-    struct extended_bios_data_area_s *ebda = get_ebda_ptr();
-    struct ipl_entry_s *ip = &ebda->ipl.table[0];
+    struct ipl_entry_s *ip = &IPL.table[0];
     ip->type = IPL_TYPE_FLOPPY;
     ip++;
 
@@ -171,18 +171,18 @@ init_boot_vectors()
         ip++;
     }
 
-    ebda->ipl.count = ip - ebda->ipl.table;
-    ebda->ipl.sequence = 0xffff;
+    IPL.count = ip - IPL.table;
+    SET_EBDA(boot_sequence, 0xffff);
     if (CONFIG_COREBOOT) {
         // XXX - hardcode defaults for coreboot.
-        ebda->ipl.bootorder = 0x00000231;
-        ebda->ipl.checkfloppysig = 1;
+        IPL.bootorder = 0x00000231;
+        IPL.checkfloppysig = 1;
     } else {
         // On emulators, get boot order from nvram.
-        ebda->ipl.bootorder = (inb_cmos(CMOS_BIOS_BOOTFLAG2)
-                               | ((inb_cmos(CMOS_BIOS_BOOTFLAG1) & 0xf0) << 4));
+        IPL.bootorder = (inb_cmos(CMOS_BIOS_BOOTFLAG2)
+                         | ((inb_cmos(CMOS_BIOS_BOOTFLAG1) & 0xf0) << 4));
         if (!(inb_cmos(CMOS_BIOS_BOOTFLAG1) & 1))
-            ebda->ipl.checkfloppysig = 1;
+            IPL.checkfloppysig = 1;
     }
 }
 
index f71466867049f17ee8e201bbce45041b328172ae..8b6e58a182e1ab6b95e2c894328826618a2ce258 100644 (file)
@@ -8,6 +8,7 @@
 #include "biosvar.h" // GET_EBDA
 #include "util.h" // mdelay
 #include "bregs.h" // struct bregs
+#include "boot.h" // IPL
 
 static int
 check_for_keystroke()
@@ -74,7 +75,7 @@ interactive_bootmenu()
 
     printf("Select boot device:\n\n");
 
-    int count = GET_EBDA(ipl.count);
+    int count = IPL.count;
     int i;
     for (i = 0; i < count; i++) {
         printf("%d. ", i+1);
@@ -90,8 +91,8 @@ interactive_bootmenu()
         if (scan_code <= count + 1) {
             // Add user choice to the boot order.
             u16 choice = scan_code - 1;
-            u32 bootorder = GET_EBDA(ipl.bootorder);
-            SET_EBDA(ipl.bootorder, (bootorder << 4) | choice);
+            u32 bootorder = IPL.bootorder;
+            IPL.bootorder = (bootorder << 4) | choice;
             break;
         }
     }
index 89f049a26f55d5740fdde3cfcff52e8583720f91..b3d6a4936222cd36d4ff0593a36f3af52bdf02dc 100644 (file)
@@ -160,12 +160,6 @@ void mptable_init(void);
 // smbios.c
 void smbios_init(void);
 
-// boot.c
-void printf_bootdev(u16 bootdev);
-
-// post_menu.c
-void interactive_bootmenu();
-
 // coreboot.c
 void coreboot_fill_map();