From e51316d0cc6f663357d9d6c6f4ee3ffddb0d09e5 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 10 Jun 2012 09:09:22 -0400 Subject: [PATCH] Minor - remove CLEARBITS_BDA and SETBITS_BDA macros. Remove these infrequently used macros and replace with explicit GET_BDA/SET_BDA calls. Signed-off-by: Kevin O'Connor --- src/biosvar.h | 14 ++++++-------- src/block.c | 4 ++-- src/cdrom.c | 2 +- src/floppy.c | 19 +++++++++++-------- src/misc.c | 2 +- src/mouse.c | 2 +- src/serial.c | 6 ++---- vgasrc/vgabios.c | 5 +---- 8 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/biosvar.h b/src/biosvar.h index eceee54..c879f40 100644 --- a/src/biosvar.h +++ b/src/biosvar.h @@ -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); +} /**************************************************************** diff --git a/src/block.c b/src/block.c index 44ba9bd..7a62787 100644 --- a/src/block.c +++ b/src/block.c @@ -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); } } diff --git a/src/cdrom.c b/src/cdrom.c index f3208b5..6e0055d 100644 --- a/src/cdrom.c +++ b/src/cdrom.c @@ -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 diff --git a/src/floppy.c b/src/floppy.c index 72bc79b..ce54d0c 100644 --- a/src/floppy.c +++ b/src/floppy.c @@ -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<