]> xenbits.xensource.com Git - seabios.git/commitdiff
Minor - remove CLEARBITS_BDA and SETBITS_BDA macros.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 10 Jun 2012 13:09:22 +0000 (09:09 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 10 Jun 2012 13:09:22 +0000 (09:09 -0400)
Remove these infrequently used macros and replace with explicit
GET_BDA/SET_BDA calls.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/biosvar.h
src/block.c
src/cdrom.c
src/floppy.c
src/misc.c
src/mouse.c
src/serial.c
vgasrc/vgabios.c

index eceee54fd5dee57d47211354e5a91dee80e9b15f..c879f402c227e56395aa0ada80862693aeee9cb4 100644 (file)
@@ -134,14 +134,12 @@ struct bios_data_area_s {
     GET_FARVAR(SEG_BDA, ((struct bios_data_area_s *)0)->var)
 #define SET_BDA(var, val) \
     SET_FARVAR(SEG_BDA, ((struct bios_data_area_s *)0)->var, (val))
-#define CLEARBITS_BDA(var, val) do {                                    \
-        typeof(((struct bios_data_area_s *)0)->var) __val = GET_BDA(var); \
-        SET_BDA(var, (__val & ~(val)));                                 \
-    } while (0)
-#define SETBITS_BDA(var, val) do {                                      \
-        typeof(((struct bios_data_area_s *)0)->var) __val = GET_BDA(var); \
-        SET_BDA(var, (__val | (val)));                                  \
-    } while (0)
+
+// Helper function to set the bits of the equipment_list_flags variable.
+static inline void set_equipment_flags(u16 clear, u16 set) {
+    u16 eqf = GET_BDA(equipment_list_flags);
+    SET_BDA(equipment_list_flags, (eqf & ~clear) | set);
+}
 
 
 /****************************************************************
index 44ba9bdbc6cefefb76eb3cfbfc9b6d089a8ed28e..7a62787e4225ef98f35af276bc7f52e52957c8a3 100644 (file)
@@ -263,11 +263,11 @@ map_floppy_drive(struct drive_s *drive_g)
     // Update equipment word bits for floppy
     if (FloppyCount == 1) {
         // 1 drive, ready for boot
-        SETBITS_BDA(equipment_list_flags, 0x01);
+        set_equipment_flags(0x41, 0x01);
         SET_BDA(floppy_harddisk_info, 0x07);
     } else if (FloppyCount >= 2) {
         // 2 drives, ready for boot
-        SETBITS_BDA(equipment_list_flags, 0x41);
+        set_equipment_flags(0x41, 0x41);
         SET_BDA(floppy_harddisk_info, 0x77);
     }
 }
index f3208b5452783f3795cfac5982271e8883dd56ad..6e0055ddc9994ce854bb850bd4596887998f93fe 100644 (file)
@@ -280,7 +280,7 @@ cdrom_boot(struct drive_s *drive_g)
         // Floppy emulation
         CDEmu.emulated_extdrive = 0x00;
         // XXX - get and set actual floppy count.
-        SETBITS_BDA(equipment_list_flags, 0x41);
+        set_equipment_flags(0x41, 0x41);
 
         switch (media) {
         case 0x01:  // 1.2M floppy
index 72bc79b8f4984638e0d63e04f9acbf4c407d3328..ce54d0c678f424780109b852da7d85a1590e18fa 100644 (file)
@@ -185,27 +185,28 @@ static int
 wait_floppy_irq(void)
 {
     ASSERT16();
-    u8 v;
+    u8 frs;
     for (;;) {
         if (!GET_BDA(floppy_motor_counter))
             return -1;
-        v = GET_BDA(floppy_recalibration_status);
-        if (v & FRS_TIMEOUT)
+        frs = GET_BDA(floppy_recalibration_status);
+        if (frs & FRS_TIMEOUT)
             break;
         // Could use yield_toirq() here, but that causes issues on
         // bochs, so use yield() instead.
         yield();
     }
 
-    v &= ~FRS_TIMEOUT;
-    SET_BDA(floppy_recalibration_status, v);
+    frs &= ~FRS_TIMEOUT;
+    SET_BDA(floppy_recalibration_status, frs);
     return 0;
 }
 
 static void
 floppy_prepare_controller(u8 floppyid)
 {
-    CLEARBITS_BDA(floppy_recalibration_status, FRS_TIMEOUT);
+    u8 frs = GET_BDA(floppy_recalibration_status);
+    SET_BDA(floppy_recalibration_status, frs & ~FRS_TIMEOUT);
 
     // turn on motor of selected drive, DMA & int enabled, normal operation
     u8 prev_reset = inb(PORT_FD_DOR) & 0x04;
@@ -320,7 +321,8 @@ floppy_drive_recal(u8 floppyid)
     data[1] = floppyid; // 0=drive0, 1=drive1
     floppy_pio(data, 2);
 
-    SETBITS_BDA(floppy_recalibration_status, 1<<floppyid);
+    u8 frs = GET_BDA(floppy_recalibration_status);
+    SET_BDA(floppy_recalibration_status, frs | (1<<floppyid));
     set_diskette_current_cyl(floppyid, 0);
 }
 
@@ -597,7 +599,8 @@ handle_0e(void)
         } while ((inb(PORT_FD_STATUS) & 0xc0) == 0xc0);
     }
     // diskette interrupt has occurred
-    SETBITS_BDA(floppy_recalibration_status, FRS_TIMEOUT);
+    u8 frs = GET_BDA(floppy_recalibration_status);
+    SET_BDA(floppy_recalibration_status, frs | FRS_TIMEOUT);
 
 done:
     eoi_pic1();
index b9487785e4cde34f963c0bada0066a0d71308467..54d8aef66e2deef8a114958b6d91c9b1580af18a 100644 (file)
@@ -65,7 +65,7 @@ mathcp_setup(void)
 {
     dprintf(3, "math cp init\n");
     // 80x87 coprocessor installed
-    SETBITS_BDA(equipment_list_flags, 0x02);
+    set_equipment_flags(0x02, 0x02);
     enable_hwirq(13, FUNC16(entry_75));
 }
 
index e4b25e0e5d36f4788453e8ed1bf4d9a566f23b85..7b28a63247e2c2c1e7f1516abf8bf068070b03c6 100644 (file)
@@ -18,7 +18,7 @@ mouse_setup(void)
         return;
     dprintf(3, "init mouse\n");
     // pointing device installed
-    SETBITS_BDA(equipment_list_flags, 0x04);
+    set_equipment_flags(0x04, 0x04);
 }
 
 static int
index 21b4bd010586166bc4cfe8453a268147870403aa..153f82a62b53290f253e93af0d0c83b9306329a3 100644 (file)
@@ -46,8 +46,7 @@ serial_setup(void)
     dprintf(1, "Found %d serial ports\n", count);
 
     // Equipment word bits 9..11 determing # serial ports
-    u16 eqb = GET_BDA(equipment_list_flags);
-    SET_BDA(equipment_list_flags, (eqb & 0xf1ff) | (count << 9));
+    set_equipment_flags(0xe00, count << 9);
 }
 
 static u16
@@ -211,8 +210,7 @@ lpt_setup(void)
     dprintf(1, "Found %d lpt ports\n", count);
 
     // Equipment word bits 14..15 determing # parallel ports
-    u16 eqb = GET_BDA(equipment_list_flags);
-    SET_BDA(equipment_list_flags, (eqb & 0x3fff) | (count << 14));
+    set_equipment_flags(0xc000, count << 14);
 }
 
 static u16
index d80cd53818d3a6405fce4bfe3aadbc6335e3e54c..b13d274591da9a18a5f25e37eea7572be0568099 100644 (file)
@@ -1197,10 +1197,7 @@ init_bios_area(void)
 {
     // init detected hardware BIOS Area
     // set 80x25 color (not clear from RBIL but usual)
-    u16 eqf = GET_BDA(equipment_list_flags);
-    SET_BDA(equipment_list_flags, (eqf & 0xffcf) | 0x20);
-
-    // Just for the first int10 find its children
+    set_equipment_flags(0x30, 0x20);
 
     // the default char height
     SET_BDA(char_height, 0x10);