Change license from GPLv3 to LGPLv3.
[seabios.git] / src / boot.c
index 5beca25066adbff34ecb9592437da38aa8308f7e..e0fb67a33fbff35837354e5242af613c3e383e3d 100644 (file)
@@ -3,14 +3,16 @@
 // Copyright (C) 2008  Kevin O'Connor <kevin@koconnor.net>
 // Copyright (C) 2002  MandrakeSoft S.A.
 //
-// This file may be distributed under the terms of the GNU GPLv3 license.
+// This file may be distributed under the terms of the GNU LGPLv3 license.
 
 #include "util.h" // irq_enable
 #include "biosvar.h" // GET_EBDA
 #include "config.h" // CONFIG_*
-#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 +26,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,11 +36,11 @@ printf_bootdev(u16 bootdev)
     printf("%s", drivetypes[type]);
 
     /* print product string if BEV */
-    void *far_description = (void*)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 */
-        memcpy_far(MAKE_FARPTR(GET_SEG(SS), &description), far_description, 32);
+        memcpy_far(MAKE_FARPTR(GET_SEG(SS), description), far_description, 32);
         /* terminate string */
         description[32] = 0;
         printf(" [%.s]", description);
@@ -80,9 +82,7 @@ try_boot(u16 seq_nr)
     if (! CONFIG_BOOT)
         BX_PANIC("Boot support not compiled in.\n");
 
-    SET_EBDA(ipl.sequence, seq_nr);
-
-    u32 bootdev = GET_EBDA(ipl.bootorder);
+    u32 bootdev = IPL.bootorder;
     bootdev >>= 4 * seq_nr;
     bootdev &= 0xf;
 
@@ -92,7 +92,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 +101,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 +129,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;
@@ -143,7 +143,7 @@ try_boot(u16 seq_nr)
     case IPL_TYPE_CDROM: {
         /* CD-ROM */
         if (! CONFIG_CDROM_BOOT)
-            break;
+            return;
         int status = cdrom_boot();
         if (status) {
             printf("CDROM boot failure code : %04x\n", status);
@@ -151,8 +151,9 @@ try_boot(u16 seq_nr)
             return;
         }
 
-        bootdrv = GET_EBDA(cdemu.emulated_drive);
-        bootseg = GET_EBDA(cdemu.load_segment);
+        u16 ebda_seg = get_ebda_seg();
+        bootdrv = GET_EBDA2(ebda_seg, cdemu.emulated_drive);
+        bootseg = GET_EBDA2(ebda_seg, cdemu.load_segment);
         /* Canonicalize bootseg:bootip */
         bootip = (bootseg & 0x0fff) << 4;
         bootseg &= 0xf000;
@@ -161,7 +162,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 +200,9 @@ handle_18()
 {
     debug_serial_setup();
     debug_enter(NULL, DEBUG_HDL_18);
-    u16 seq = GET_EBDA(ipl.sequence) + 1;
+    u16 ebda_seg = get_ebda_seg();
+    u16 seq = GET_EBDA2(ebda_seg, boot_sequence) + 1;
+    SET_EBDA2(ebda_seg, boot_sequence, seq);
     do_boot(seq);
 }
 
@@ -209,6 +212,7 @@ handle_19()
 {
     debug_serial_setup();
     debug_enter(NULL, DEBUG_HDL_19);
+    SET_EBDA(boot_sequence, 0);
     do_boot(0);
 }