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);
+}
/****************************************************************
// 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);
}
}
// 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
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;
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);
}
} 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();
{
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));
}
return;
dprintf(3, "init mouse\n");
// pointing device installed
- SETBITS_BDA(equipment_list_flags, 0x04);
+ set_equipment_flags(0x04, 0x04);
}
static int
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
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
{
// 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);