Remove Drives global struct in favor of independent global variables.
authorKevin O'Connor <kevin@koconnor.net>
Wed, 29 Dec 2010 16:05:46 +0000 (11:05 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Wed, 29 Dec 2010 18:26:26 +0000 (13:26 -0500)
The "Drives" struct just held three global variables - declare the
three global variables independently.

src/block.c
src/cdrom.c
src/disk.c
src/disk.h

index dafaaa6a22eb350562be11bf6e092d30f1011594..619db67341ef4b9c53d3d1f7e320f8f0eab6e84b 100644 (file)
 #include "usb-msc.h" // process_usb_op
 #include "virtio-blk.h" // process_virtio_op
 
-struct drives_s Drives VAR16VISIBLE;
+u8 FloppyCount VAR16VISIBLE;
+u8 CDCount;
+struct drive_s *IDMap[3][CONFIG_MAX_EXTDRIVE] VAR16VISIBLE;
 
 struct drive_s *
 getDrive(u8 exttype, u8 extdriveoffset)
 {
-    if (extdriveoffset >= ARRAY_SIZE(Drives.idmap[0]))
+    if (extdriveoffset >= ARRAY_SIZE(IDMap[0]))
         return NULL;
-    struct drive_s *drive_gf = GET_GLOBAL(Drives.idmap[exttype][extdriveoffset]);
+    struct drive_s *drive_gf = GET_GLOBAL(IDMap[exttype][extdriveoffset]);
     if (!drive_gf)
         return NULL;
     return GLOBALFLAT2GLOBAL(drive_gf);
@@ -30,7 +32,7 @@ getDrive(u8 exttype, u8 extdriveoffset)
 int getDriveId(u8 exttype, struct drive_s *drive_g)
 {
     int i;
-    for (i = 0; i < ARRAY_SIZE(Drives.idmap[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(IDMap[0]); i++)
         if (getDrive(exttype, i) == drive_g)
             return i;
     return -1;
@@ -203,7 +205,7 @@ fill_fdpt(struct drive_s *drive_g, int hdid)
 static void
 add_drive(struct drive_s **idmap, u8 *count, struct drive_s *drive_g)
 {
-    if (*count >= ARRAY_SIZE(Drives.idmap[0])) {
+    if (*count >= ARRAY_SIZE(IDMap[0])) {
         warn_noalloc();
         return;
     }
@@ -219,7 +221,7 @@ map_hd_drive(struct drive_s *drive_g)
     struct bios_data_area_s *bda = MAKE_FLATPTR(SEG_BDA, 0);
     int hdid = bda->hdcount;
     dprintf(3, "Mapping hd drive %p to %d\n", drive_g, hdid);
-    add_drive(Drives.idmap[EXTTYPE_HD], &bda->hdcount, drive_g);
+    add_drive(IDMap[EXTTYPE_HD], &bda->hdcount, drive_g);
 
     // Setup disk geometry translation.
     setup_translation(drive_g);
@@ -233,7 +235,7 @@ void
 map_cd_drive(struct drive_s *drive_g)
 {
     dprintf(3, "Mapping cd drive %p\n", drive_g);
-    add_drive(Drives.idmap[EXTTYPE_CD], &Drives.cdcount, drive_g);
+    add_drive(IDMap[EXTTYPE_CD], &CDCount, drive_g);
 }
 
 // Map a floppy
@@ -241,14 +243,14 @@ void
 map_floppy_drive(struct drive_s *drive_g)
 {
     dprintf(3, "Mapping floppy drive %p\n", drive_g);
-    add_drive(Drives.idmap[EXTTYPE_FLOPPY], &Drives.floppycount, drive_g);
+    add_drive(IDMap[EXTTYPE_FLOPPY], &FloppyCount, drive_g);
 
     // Update equipment word bits for floppy
-    if (Drives.floppycount == 1) {
+    if (FloppyCount == 1) {
         // 1 drive, ready for boot
         SETBITS_BDA(equipment_list_flags, 0x01);
         SET_BDA(floppy_harddisk_info, 0x07);
-    } else if (Drives.floppycount >= 2) {
+    } else if (FloppyCount >= 2) {
         // 2 drives, ready for boot
         SETBITS_BDA(equipment_list_flags, 0x41);
         SET_BDA(floppy_harddisk_info, 0x77);
index 31ceaaaa86fb3ee7f8f5ae4f217a0c54e4b5d9c9..3769dfa6866d10c37ba3864b5f514fd5e56e38bd 100644 (file)
@@ -109,7 +109,7 @@ cdemu_setup(void)
 {
     if (!CONFIG_CDROM_EMU)
         return;
-    if (!Drives.cdcount)
+    if (!CDCount)
         return;
 
     struct drive_s *drive_g = malloc_fseg(sizeof(*drive_g));
index 56c369ae2112c3302250922254a3a8af9753732f..f7bfe9c523ef16104c65c1fc4a5902e25778c3c7 100644 (file)
@@ -235,7 +235,7 @@ disk_1308(struct bregs *regs, struct drive_s *drive_g)
     u8 count;
     if (regs->dl < EXTSTART_HD) {
         // Floppy
-        count = GET_GLOBAL(Drives.floppycount);
+        count = GET_GLOBAL(FloppyCount);
 
         if (CONFIG_CDROM_EMU
             && drive_g == GLOBALFLAT2GLOBAL(GET_GLOBAL(cdemu_drive_gf)))
index 480201129a1240e6f2837dff79b3a9c8853eeb51..b85a62d78603df59ad79547e78246e597e7d48e3 100644 (file)
@@ -207,13 +207,6 @@ struct drive_s {
 #define TRANSLATION_LARGE 2
 #define TRANSLATION_RECHS 3
 
-struct drives_s {
-    // map between bios floppy/hd/cd id and drive_s struct
-    u8 floppycount;
-    u8 cdcount;
-    struct drive_s *idmap[3][CONFIG_MAX_EXTDRIVE];
-};
-
 #define EXTTYPE_FLOPPY 0
 #define EXTTYPE_HD 1
 #define EXTTYPE_CD 2
@@ -227,7 +220,7 @@ struct drives_s {
  ****************************************************************/
 
 // block.c
-extern struct drives_s Drives;
+extern u8 FloppyCount, CDCount;
 struct drive_s *getDrive(u8 exttype, u8 extdriveoffset);
 int getDriveId(u8 exttype, struct drive_s *drive_g);
 void map_floppy_drive(struct drive_s *drive_g);