Breakout cdrom emulation support into CONFIG_CDROM_EMU.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 23 Mar 2008 00:13:08 +0000 (20:13 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 23 Mar 2008 00:13:08 +0000 (20:13 -0400)
This allows one to support just booting from cdroms that don't require
floppy/harddisk emulation.

src/boot.c
src/cdrom.c
src/config.h
src/disk.c

index c1968a5da307c01e98121ec5d19370f8f3f9713e..d37ab7d17be175b053a75b1fa3b4e665cc1b99d8 100644 (file)
@@ -71,6 +71,7 @@ try_boot(u16 seq_nr)
     u8 bootdrv = 0;
     u16 bootdev, bootip;
 
+    // XXX - why different bootdev check based on CONFIG_CDROM_BOOT?
     if (CONFIG_CDROM_BOOT) {
         bootdev = inb_cmos(CMOS_BIOS_BOOTFLAG2);
         bootdev |= ((inb_cmos(CMOS_BIOS_BOOTFLAG1) & 0xf0) << 4);
index cf77584eda9af6de04e1ea786de8320aeaf782be..590569ad0a793db2b5b3b56cc7ae87b81bd8267d 100644 (file)
@@ -465,15 +465,8 @@ cdrom_boot()
     if (buffer[0x20] != 0x88)
         return 11; // Bootable
 
-    SET_EBDA(cdemu.media,buffer[0x21]);
-    if (buffer[0x21] == 0)
-        // FIXME ElTorito Hardcoded. cdrom is hardcoded as device 0xE0.
-        // Win2000 cd boot needs to know it booted from cd
-        SET_EBDA(cdemu.emulated_drive, 0xE0);
-    else if (buffer[0x21] < 4)
-        SET_EBDA(cdemu.emulated_drive, 0x00);
-    else
-        SET_EBDA(cdemu.emulated_drive, 0x80);
+    u8 media = buffer[0x21];
+    SET_EBDA(cdemu.media, media);
 
     SET_EBDA(cdemu.controller_index, device/2);
     SET_EBDA(cdemu.device_spec, device%2);
@@ -481,9 +474,8 @@ cdrom_boot()
     u16 boot_segment = *(u16*)&buffer[0x22];
     if (!boot_segment)
         boot_segment = 0x07C0;
-
-    SET_EBDA(cdemu.load_segment,boot_segment);
-    SET_EBDA(cdemu.buffer_segment,0x0000);
+    SET_EBDA(cdemu.load_segment, boot_segment);
+    SET_EBDA(cdemu.buffer_segment, 0x0000);
 
     u16 nbsectors = *(u16*)&buffer[0x26];
     SET_EBDA(cdemu.sector_count, nbsectors);
@@ -497,8 +489,34 @@ cdrom_boot()
     if (ret)
         return 12;
 
+    if (media == 0) {
+        // No emulation requested - return success.
+
+        // FIXME ElTorito Hardcoded. cdrom is hardcoded as device 0xE0.
+        // Win2000 cd boot needs to know it booted from cd
+        SET_EBDA(cdemu.emulated_drive, 0xE0);
+
+        return 0;
+    }
+
+    // Emulation of a floppy/harddisk requested
+    if (! CONFIG_CDROM_EMU)
+        return 13;
+
+    // Set emulated drive id and increase bios installed hardware
+    // number of devices
+    if (media < 4) {
+        // Floppy emulation
+        SET_EBDA(cdemu.emulated_drive, 0x00);
+        SETBITS_BDA(equipment_list_flags, 0x41);
+    } else {
+        // Harddrive emulation
+        SET_EBDA(cdemu.emulated_drive, 0x80);
+        SET_EBDA(ata.hdcount, GET_EBDA(ata.hdcount) + 1);
+    }
+
     // Remember the media type
-    switch (GET_EBDA(cdemu.media)) {
+    switch (media) {
     case 0x01:  // 1.2M floppy
         SET_EBDA(cdemu.vdevice.spt, 15);
         SET_EBDA(cdemu.vdevice.cylinders, 80);
@@ -525,18 +543,9 @@ cdrom_boot()
     }
     }
 
-    if (GET_EBDA(cdemu.media) != 0) {
-        // Increase bios installed hardware number of devices
-        if (GET_EBDA(cdemu.emulated_drive) == 0x00)
-            SETBITS_BDA(equipment_list_flags, 0x41);
-        else
-            SET_EBDA(ata.hdcount, GET_EBDA(ata.hdcount) + 1);
-        // everything is ok, so from now on, the emulation is active
-        SET_EBDA(cdemu.active, 0x01);
-    }
-
-    DEBUGF("cdemu media=%d active=%d\n"
-           , GET_EBDA(cdemu.media), GET_EBDA(cdemu.active));
+    // everything is ok, so from now on, the emulation is active
+    SET_EBDA(cdemu.active, 0x01);
+    DEBUGF("cdemu media=%d\n", media);
 
     return 0;
 }
index d61830b690c42659f6fcb009526407dd25452a9e..206fffae7f3cdeb9f950324e5f4070f08525d165 100644 (file)
@@ -7,6 +7,7 @@
 #define CONFIG_ATA 1
 #define CONFIG_KBD_CALL_INT15_4F 1
 #define CONFIG_CDROM_BOOT 1
+#define CONFIG_CDROM_EMU 1
 #define CONFIG_PCIBIOS 1
 
 #define CONFIG_MAX_ATA_INTERFACES 4
index 3cf0cedb7c39843c85e4fa961ce30ce216f2fb5a..74c49bf636d8c4081513a6e274605dc5c255261f 100644 (file)
@@ -706,7 +706,7 @@ handle_13(struct bregs *regs)
     //debug_enter(regs);
     u8 drive = regs->dl;
 
-    if (CONFIG_CDROM_BOOT) {
+    if (CONFIG_CDROM_EMU) {
         if (regs->ah == 0x4b) {
             cdemu_134b(regs);
             return;