Store cdrom emulated driveid directly.
authorKevin O'Connor <kevin@koconnor.net>
Wed, 12 Aug 2009 02:36:30 +0000 (22:36 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Wed, 12 Aug 2009 02:36:30 +0000 (22:36 -0400)
src/biosvar.h
src/boot.c
src/cdrom.c
src/disk.c

index 9469c9aa008324114150530198385ce034bfaf4f..b200645faedfbd6484bfce245e4e4cc803581d64 100644 (file)
@@ -175,9 +175,8 @@ struct dpte_s {
 struct cdemu_s {
     u8  active;
     u8  media;
-    u8  emulated_drive;
-    u8  controller_index;
-    u16 device_spec;
+    u8  emulated_extdrive;
+    u8  emulated_driveid;
     u32 ilba;
     u16 buffer_segment;
     u16 load_segment;
index b4067bbfc819da8a11342960b84fe4dd0c7e1ecd..bfd7f06631520c48bf32faf37b0362ebcdcf72e6 100644 (file)
@@ -370,7 +370,7 @@ boot_cdrom(struct ipl_entry_s *ie)
     }
 
     u16 ebda_seg = get_ebda_seg();
-    u8 bootdrv = GET_EBDA2(ebda_seg, cdemu.emulated_drive);
+    u8 bootdrv = GET_EBDA2(ebda_seg, cdemu.emulated_extdrive);
     u16 bootseg = GET_EBDA2(ebda_seg, cdemu.load_segment);
     /* Canonicalize bootseg:bootip */
     u16 bootip = (bootseg & 0x0fff) << 4;
index 5f03b8db21f1858ffcdc5d04fa49df889b2016a7..8823f9b78ead5518ce04fc711c83c27ff04e3a39 100644 (file)
@@ -225,8 +225,7 @@ cdemu_13(struct bregs *regs)
     //debug_stub(regs);
 
     u16 ebda_seg = get_ebda_seg();
-    u8 driveid = GET_EBDA2(ebda_seg, cdemu.controller_index) * 2;
-    driveid += GET_EBDA2(ebda_seg, cdemu.device_spec);
+    u8 driveid = GET_EBDA2(ebda_seg, cdemu.emulated_driveid);
 
     switch (regs->ah) {
     case 0x02: cdemu_1302(regs, driveid); break;
@@ -279,11 +278,13 @@ cdemu_134b(struct bregs *regs)
     u16 ebda_seg = get_ebda_seg();
     SET_INT13ET(regs, size, 0x13);
     SET_INT13ET(regs, media, GET_EBDA2(ebda_seg, cdemu.media));
-    SET_INT13ET(regs, emulated_drive, GET_EBDA2(ebda_seg, cdemu.emulated_drive));
-    SET_INT13ET(regs, controller_index
-                , GET_EBDA2(ebda_seg, cdemu.controller_index));
+    SET_INT13ET(regs, emulated_drive
+                , GET_EBDA2(ebda_seg, cdemu.emulated_extdrive));
+    u8 driveid = GET_EBDA2(ebda_seg, cdemu.emulated_driveid);
+    u8 cntl_id = GET_GLOBAL(Drives.drives[driveid].cntl_id);
+    SET_INT13ET(regs, controller_index, cntl_id / 2);
+    SET_INT13ET(regs, device_spec, cntl_id % 2);
     SET_INT13ET(regs, ilba, GET_EBDA2(ebda_seg, cdemu.ilba));
-    SET_INT13ET(regs, device_spec, GET_EBDA2(ebda_seg, cdemu.device_spec));
     SET_INT13ET(regs, buffer_segment, GET_EBDA2(ebda_seg, cdemu.buffer_segment));
     SET_INT13ET(regs, load_segment, GET_EBDA2(ebda_seg, cdemu.load_segment));
     SET_INT13ET(regs, sector_count, GET_EBDA2(ebda_seg, cdemu.sector_count));
@@ -454,8 +455,7 @@ cdrom_boot(int cdid)
     u8 media = buffer[0x21];
     SET_EBDA2(ebda_seg, cdemu.media, media);
 
-    SET_EBDA2(ebda_seg, cdemu.controller_index, driveid/2);
-    SET_EBDA2(ebda_seg, cdemu.device_spec, driveid%2);
+    SET_EBDA2(ebda_seg, cdemu.emulated_driveid, driveid);
 
     u16 boot_segment = *(u16*)&buffer[0x22];
     if (!boot_segment)
@@ -479,7 +479,7 @@ cdrom_boot(int cdid)
 
     if (media == 0) {
         // No emulation requested - return success.
-        SET_EBDA2(ebda_seg, cdemu.emulated_drive, 0xE0 + cdid);
+        SET_EBDA2(ebda_seg, cdemu.emulated_extdrive, 0xE0 + cdid);
         return 0;
     }
 
@@ -491,7 +491,7 @@ cdrom_boot(int cdid)
     // number of devices
     if (media < 4) {
         // Floppy emulation
-        SET_EBDA2(ebda_seg, cdemu.emulated_drive, 0x00);
+        SET_EBDA2(ebda_seg, cdemu.emulated_extdrive, 0x00);
         SETBITS_BDA(equipment_list_flags, 0x41);
 
         switch (media) {
@@ -513,7 +513,7 @@ cdrom_boot(int cdid)
         }
     } else {
         // Harddrive emulation
-        SET_EBDA2(ebda_seg, cdemu.emulated_drive, 0x80);
+        SET_EBDA2(ebda_seg, cdemu.emulated_extdrive, 0x80);
         SET_BDA(hdcount, GET_BDA(hdcount) + 1);
 
         // Peak at partition table to get chs.
index 32962246ef3d2c00d6c0a501bb268c2181606cfa..0cd2aca47c170911cdcd2c7bbb71a0829cc09005 100644 (file)
@@ -750,7 +750,7 @@ handle_13(struct bregs *regs)
         }
         u16 ebda_seg = get_ebda_seg();
         if (GET_EBDA2(ebda_seg, cdemu.active)) {
-            u8 emudrive = GET_EBDA2(ebda_seg, cdemu.emulated_drive);
+            u8 emudrive = GET_EBDA2(ebda_seg, cdemu.emulated_extdrive);
             if (extdrive == emudrive) {
                 cdemu_13(regs);
                 return;