diff --git a/src/device.c b/src/device.c index dad583cdc..7cfa1d70e 100644 --- a/src/device.c +++ b/src/device.c @@ -490,7 +490,7 @@ device_get_name(const device_t *dev, int bus, char *name) const char *sbus = NULL; const char *fbus; char *tname; - char pbus[8] = { 0 }; + char pbus[11] = { 0 }; if (dev == NULL) return; @@ -498,8 +498,21 @@ device_get_name(const device_t *dev, int bus, char *name) name[0] = 0x00; if (bus) { - if (dev->flags & DEVICE_ISA) - sbus = (dev->flags & DEVICE_AT) ? "ISA16" : "ISA"; + if ((dev->flags & (DEVICE_PCJR | DEVICE_ISA)) == + (DEVICE_PCJR | DEVICE_ISA)) + sbus = "ISA/PCJR"; + else if (dev->flags & DEVICE_SIDECAR) + sbus = "Sidecar"; + else if (dev->flags & DEVICE_XT_KBC) + sbus = "XT KBC"; + else if (dev->flags & DEVICE_ISA16) + sbus = "ISA16"; + else if (dev->flags & DEVICE_AT_KBC) + sbus = "AT KBC"; + else if (dev->flags & DEVICE_PS2_KBC) + sbus = "PS/2 KBC"; + else if (dev->flags & DEVICE_ISA) + sbus = "ISA"; else if (dev->flags & DEVICE_CBUS) sbus = "C-BUS"; else if (dev->flags & DEVICE_PCMCIA) @@ -519,7 +532,7 @@ device_get_name(const device_t *dev, int bus, char *name) else if (dev->flags & DEVICE_PCI) sbus = "PCI"; else if (dev->flags & DEVICE_CARDBUS) - sbus = "CARDBUS"; + sbus = "CardBus"; else if (dev->flags & DEVICE_USB) sbus = "USB"; else if (dev->flags & DEVICE_AGP) @@ -780,67 +793,12 @@ device_set_config_mac(const char *str, int val) int device_is_valid(const device_t *device, int mch) { - if (device == NULL) - return 1; + int ret = 1; - if ((device->flags & DEVICE_PCJR) && !machine_has_bus(mch, MACHINE_BUS_PCJR)) - return 0; + if (device != NULL) + ret = machine_has_bus(mch, device->flags & DEVICE_BUS); - if ((device->flags & DEVICE_XTKBC) && machine_has_bus(mch, MACHINE_BUS_ISA16) && !machine_has_bus(mch, MACHINE_BUS_DM_KBC)) - return 0; - - if ((device->flags & DEVICE_AT) && !machine_has_bus(mch, MACHINE_BUS_ISA16)) - return 0; - - if ((device->flags & DEVICE_ATKBC) && !machine_has_bus(mch, MACHINE_BUS_ISA16) && !machine_has_bus(mch, MACHINE_BUS_DM_KBC)) - return 0; - - if ((device->flags & DEVICE_PS2) && !machine_has_bus(mch, MACHINE_BUS_PS2_PORTS)) - return 0; - - if ((device->flags & DEVICE_ISA) && !machine_has_bus(mch, MACHINE_BUS_ISA)) - return 0; - - if ((device->flags & DEVICE_CBUS) && !machine_has_bus(mch, MACHINE_BUS_CBUS)) - return 0; - - if ((device->flags & DEVICE_PCMCIA) && !machine_has_bus(mch, MACHINE_BUS_PCMCIA) && !machine_has_bus(mch, MACHINE_BUS_ISA)) - return 0; - - if ((device->flags & DEVICE_MCA) && !machine_has_bus(mch, MACHINE_BUS_MCA)) - return 0; - - if ((device->flags & DEVICE_HIL) && !machine_has_bus(mch, MACHINE_BUS_HIL)) - return 0; - - if ((device->flags & DEVICE_EISA) && !machine_has_bus(mch, MACHINE_BUS_EISA)) - return 0; - - if ((device->flags & DEVICE_AT32) && !machine_has_bus(mch, MACHINE_BUS_AT32)) - return 0; - - if ((device->flags & DEVICE_OLB) && !machine_has_bus(mch, MACHINE_BUS_OLB)) - return 0; - - if ((device->flags & DEVICE_VLB) && !machine_has_bus(mch, MACHINE_BUS_VLB)) - return 0; - - if ((device->flags & DEVICE_PCI) && !machine_has_bus(mch, MACHINE_BUS_PCI)) - return 0; - - if ((device->flags & DEVICE_CARDBUS) && !machine_has_bus(mch, MACHINE_BUS_CARDBUS) && !machine_has_bus(mch, MACHINE_BUS_PCI)) - return 0; - - if ((device->flags & DEVICE_USB) && !machine_has_bus(mch, MACHINE_BUS_USB)) - return 0; - - if ((device->flags & DEVICE_AGP) && !machine_has_bus(mch, MACHINE_BUS_AGP)) - return 0; - - if ((device->flags & DEVICE_AC97) && !machine_has_bus(mch, MACHINE_BUS_AC97)) - return 0; - - return 1; + return ret; } int diff --git a/src/device/kbc_at.c b/src/device/kbc_at.c index ad1625873..09855a387 100644 --- a/src/device/kbc_at.c +++ b/src/device/kbc_at.c @@ -810,27 +810,18 @@ write_p2(atkbc_t *dev, uint8_t val) if (!(val & 0x01)) { /* Pin 0 selected. */ /* Pin 0 selected. */ kbc_at_log("write_p2(): Pulse reset!\n"); - if (machines[machine].flags & MACHINE_COREBOOT) { - /* The SeaBIOS hard reset code attempts a KBC reset if ACPI RESET_REG - is not available. However, the KBC reset is normally a soft reset, so - SeaBIOS gets caught in a soft reset loop as it tries to hard reset the - machine. Hack around this by making the KBC reset a hard reset only on - coreboot machines. */ - pc_reset_hard(); - } else { - softresetx86(); /* Pulse reset! */ - cpu_set_edx(); - flushmmucache(); - if ((kbc_ven == KBC_VEN_ALI) || !strcmp(machine_get_internal_name(), "spc7700plw")) - smbase = 0x00030000; + softresetx86(); /* Pulse reset! */ + cpu_set_edx(); + flushmmucache(); + if ((kbc_ven == KBC_VEN_ALI) || !strcmp(machine_get_internal_name(), "spc7700plw")) + smbase = 0x00030000; - /* Yes, this is a hack, but until someone gets ahold of the real PCD-2L - and can find out what they actually did to make it boot from FFFFF0 - correctly despite A20 being gated when the CPU is reset, this will - have to do. */ - if ((kbc_ven == KBC_VEN_SIEMENS) || !strcmp(machine_get_internal_name(), "acera1g")) - is486 ? loadcs(0xf000) : loadcs_2386(0xf000); - } + /* Yes, this is a hack, but until someone gets ahold of the real PCD-2L + and can find out what they actually did to make it boot from FFFFF0 + correctly despite A20 being gated when the CPU is reset, this will + have to do. */ + if ((kbc_ven == KBC_VEN_SIEMENS) || !strcmp(machine_get_internal_name(), "acera1g")) + is486 ? loadcs(0xf000) : loadcs_2386(0xf000); } } diff --git a/src/include/86box/device.h b/src/include/86box/device.h index d92a387e9..d074cc2fc 100644 --- a/src/include/86box/device.h +++ b/src/include/86box/device.h @@ -79,15 +79,15 @@ // #define CONFIG_STANDALONE 257 /* not available on the on-board variant */ enum { - DEVICE_PCJR = 2, /* requires an IBM PCjr */ - DEVICE_XTKBC = 4, /* requires an XT-compatible keyboard controller */ - DEVICE_AT = 8, /* requires an AT-compatible system */ - DEVICE_ATKBC = 0x10, /* requires an AT-compatible keyboard controller */ - DEVICE_PS2 = 0x20, /* requires a PS/1 or PS/2 system */ - DEVICE_ISA = 0x40, /* requires the ISA bus */ - DEVICE_CBUS = 0x80, /* requires the C-BUS bus */ - DEVICE_PCMCIA = 0x100, /* requires the PCMCIA bus */ - DEVICE_MCA = 0x200, /* requires the MCA bus */ + DEVICE_SIDECAR = 2, /* requires an IBM PCjr */ + DEVICE_ISA = 4, /* requires the ISA bus */ + DEVICE_XT_KBC = 8, /* requires an XT-compatible keyboard controller */ + DEVICE_CBUS = 0x10, /* requires the C-BUS bus */ + DEVICE_ISA16 = 0x20, /* requires an AT-compatible system */ + DEVICE_AT_KBC = 0x40, /* requires an AT-compatible keyboard controller */ + DEVICE_MCA = 0x80, /* requires the MCA bus */ + DEVICE_PS2_KBC = 0x100, /* requires a PS/1 or PS/2 system */ + DEVICE_PCMCIA = 0x200, /* requires the PCMCIA bus */ DEVICE_HIL = 0x400, /* requires the HP HIL bus */ DEVICE_EISA = 0x800, /* requires the EISA bus */ DEVICE_AT32 = 0x1000, /* requires the Mylex AT/32 local bus */ @@ -98,8 +98,11 @@ enum { DEVICE_USB = 0x20000, /* requires the USB bus */ DEVICE_AGP = 0x40000, /* requires the AGP bus */ DEVICE_AC97 = 0x80000, /* requires the AC'97 bus */ + DEVICE_BUS = 0xfffff, /* requires a machine bus */ + DEVICE_COM = 0x100000, /* requires a serial port */ DEVICE_LPT = 0x200000, /* requires a parallel port */ + DEVICE_KBC = 0x400000, /* is a keyboard controller */ DEVICE_SOFTRESET = 0x800000, /* requires to be reset on soft reset */ @@ -109,6 +112,11 @@ enum { DEVICE_ALL = 0xffffffff /* match all devices */ }; +/* TODO: Remove this once all the devices' flags have been updated. */ +#define DEVICE_AT DEVICE_ISA16 +#define DEVICE_PCJR DEVICE_SIDECAR +#define DEVICE_PS2 DEVICE_PS2_KBC + #define BIOS_NORMAL 0 #define BIOS_INTERLEAVED 1 #define BIOS_INTERLEAVED_SINGLEFILE 2 diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 1ce46de9b..2c5440438 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -23,34 +23,31 @@ #define EMU_MACHINE_H /* Machine feature flags. */ -#define MACHINE_BUS_NONE 0x00000000 /* sys has no bus */ +#define MACHINE_BUS_NONE 0x00000000 /* sys has no bus */ /* Feature flags for BUS'es. */ -#define MACHINE_BUS_ISA 0x00000001 /* sys has ISA bus */ -#define MACHINE_BUS_CASSETTE 0x00000002 /* sys has cassette port */ -#define MACHINE_BUS_CARTRIDGE 0x00000004 /* sys has two cartridge bays */ -#define MACHINE_BUS_PCJR 0x00000008 /* sys has PCjr sidecar bus */ -#define MACHINE_BUS_DM_KBC 0x00000010 /* system has keyboard controller that supports - both XT and AT keyboards */ +#define MACHINE_BUS_CASSETTE 0x00000001 /* sys has cassette port */ +#define MACHINE_BUS_ISA 0x00000002 /* sys has ISA bus */ +#define MACHINE_BUS_SIDECAR 0x00000004 /* sys has PCjr sidecar bus */ +#define MACHINE_BUS_XT_KBD 0x00000008 /* sys has an XT keyboard port */ +#define MACHINE_BUS_CBUS 0x00000010 /* sys has C-BUS bus */ #define MACHINE_BUS_ISA16 0x00000020 /* sys has ISA16 bus - PC/AT architecture */ -#define MACHINE_BUS_CBUS 0x00000040 /* sys has C-BUS bus */ -#define MACHINE_BUS_PCMCIA 0x00000080 /* sys has PCMCIA bus */ -#define MACHINE_BUS_PS2_LATCH 0x00000100 /* system has PS/2 keyboard controller IRQ latch */ -#define MACHINE_BUS_PS2_PORTS 0x00000200 /* system has PS/2 keyboard and mouse ports */ -#define MACHINE_BUS_PS2 (MACHINE_BUS_PS2_LATCH | MACHINE_BUS_PS2_PORTS) +#define MACHINE_BUS_AT_KBD 0x00000040 /* sys has an AT keyboard port */ +#define MACHINE_BUS_MCA 0x00000080 /* sys has MCA bus */ +#define MACHINE_BUS_PS2_PORTS 0x00000100 /* system has PS/2 keyboard and mouse ports */ +#define MACHINE_BUS_PS2 MACHINE_BUS_PS2_PORTS +#define MACHINE_BUS_PCMCIA 0x00000200 /* sys has PCMCIA bus */ #define MACHINE_BUS_HIL 0x00000400 /* system has HP HIL keyboard and mouse ports */ #define MACHINE_BUS_EISA 0x00000800 /* sys has EISA bus */ #define MACHINE_BUS_AT32 0x00001000 /* sys has Mylex AT/32 local bus */ #define MACHINE_BUS_OLB 0x00002000 /* sys has OPTi local bus */ #define MACHINE_BUS_VLB 0x00004000 /* sys has VL bus */ -#define MACHINE_BUS_MCA 0x00008000 /* sys has MCA bus */ -#define MACHINE_BUS_PCI 0x00010000 /* sys has PCI bus */ -#define MACHINE_BUS_CARDBUS 0x00020000 /* sys has CardBus bus */ -#define MACHINE_BUS_USB 0x00040000 /* sys has USB bus */ -#define MACHINE_BUS_AGP 0x00080000 /* sys has AGP bus */ -#define MACHINE_BUS_AC97 0x00100000 /* sys has AC97 bus (ACR/AMR/CNR slot) */ +#define MACHINE_BUS_PCI 0x00008000 /* sys has PCI bus */ +#define MACHINE_BUS_CARDBUS 0x00010000 /* sys has CardBus bus */ +#define MACHINE_BUS_USB 0x00020000 /* sys has USB bus */ +#define MACHINE_BUS_AGP 0x00040000 /* sys has AGP bus */ +#define MACHINE_BUS_AC97 0x00080000 /* sys has AC97 bus (ACR/AMR/CNR slot) */ /* Aliases. */ #define MACHINE_CASSETTE (MACHINE_BUS_CASSETTE) /* sys has cassette port */ -#define MACHINE_CARTRIDGE (MACHINE_BUS_CARTRIDGE) /* sys has two cartridge bays */ /* Combined flags. */ #define MACHINE_PC (MACHINE_BUS_ISA) /* sys is PC/XT-compatible (ISA) */ #define MACHINE_AT (MACHINE_BUS_ISA | MACHINE_BUS_ISA16) /* sys is AT-compatible (ISA + ISA16) */ @@ -69,18 +66,18 @@ #define MACHINE_AGP (MACHINE_BUS_AGP | MACHINE_PCI) /* sys is AT-compatible with AGP */ #define MACHINE_AGP98 (MACHINE_BUS_AGP | MACHINE_PCI98) /* sys is NEC PC-98x1 series with AGP (did that even exist?) */ -#define MACHINE_PC5150 (MACHINE_PC | MACHINE_CASSETTE) /* sys is IBM PC 5150 */ -#define MACHINE_PCJR (MACHINE_PC | MACHINE_CASSETTE | MACHINE_CARTRIDGE) /* sys is PCjr */ -#define MACHINE_PS2 (MACHINE_AT | MACHINE_BUS_PS2) /* sys is PS/2 */ -#define MACHINE_PS2_MCA (MACHINE_MCA | MACHINE_BUS_PS2) /* sys is MCA PS/2 */ -#define MACHINE_PS2_VLB (MACHINE_VLB | MACHINE_BUS_PS2) /* sys is VLB PS/2 */ -#define MACHINE_PS2_PCI (MACHINE_PCI | MACHINE_BUS_PS2) /* sys is PCI PS/2 */ -#define MACHINE_PS2_PCIV (MACHINE_PCIV | MACHINE_BUS_PS2) /* sys is VLB/PCI PS/2 */ -#define MACHINE_PS2_AGP (MACHINE_AGP | MACHINE_BUS_PS2) /* sys is AGP PS/2 */ -#define MACHINE_PS2_A97 (MACHINE_PS2_AGP | MACHINE_BUS_AC97) /* sys is AGP/AC97 PS/2 */ -#define MACHINE_PS2_NOISA (MACHINE_PS2_AGP & ~MACHINE_AT) /* sys is AGP PS/2 without ISA */ -#define MACHINE_PS2_PCIONLY (MACHINE_PS2_NOISA & ~MACHINE_BUS_AGP) /* sys is PCI PS/2 without ISA */ -#define MACHINE_PS2_NOI97 (MACHINE_PS2_A97 & ~MACHINE_AT) /* sys is AGP/AC97 PS/2 without ISA */ +#define MACHINE_PC5150 (MACHINE_PC | MACHINE_CASSETTE) /* sys is IBM PC 5150 */ +#define MACHINE_PCJR (MACHINE_PC | MACHINE_CASSETTE | MACHINE_BUS_SIDECAR) /* sys is PCjr */ +#define MACHINE_PS2 (MACHINE_AT | MACHINE_BUS_PS2) /* sys is PS/2 */ +#define MACHINE_PS2_MCA (MACHINE_MCA | MACHINE_BUS_PS2) /* sys is MCA PS/2 */ +#define MACHINE_PS2_VLB (MACHINE_VLB | MACHINE_BUS_PS2) /* sys is VLB PS/2 */ +#define MACHINE_PS2_PCI (MACHINE_PCI | MACHINE_BUS_PS2) /* sys is PCI PS/2 */ +#define MACHINE_PS2_PCIV (MACHINE_PCIV | MACHINE_BUS_PS2) /* sys is VLB/PCI PS/2 */ +#define MACHINE_PS2_AGP (MACHINE_AGP | MACHINE_BUS_PS2) /* sys is AGP PS/2 */ +#define MACHINE_PS2_A97 (MACHINE_PS2_AGP | MACHINE_BUS_AC97) /* sys is AGP/AC97 PS/2 */ +#define MACHINE_PS2_NOISA (MACHINE_PS2_AGP & ~MACHINE_AT) /* sys is AGP PS/2 without ISA */ +#define MACHINE_PS2_PCIONLY (MACHINE_PS2_NOISA & ~MACHINE_BUS_AGP) /* sys is PCI PS/2 without ISA */ +#define MACHINE_PS2_NOI97 (MACHINE_PS2_A97 & ~MACHINE_AT) /* sys is AGP/AC97 PS/2 without ISA */ /* Feature flags for miscellaneous internal devices. */ #define MACHINE_FLAGS_NONE 0x00000000 /* sys has no int devices */ #define MACHINE_SOFTFLOAT_ONLY 0x00000001 /* sys requires SoftFloat FPU */ @@ -93,7 +90,8 @@ #define MACHINE_LPT_PRI 0x00000080 /* sys has int pri LPT */ #define MACHINE_LPT_SEC 0x00000100 /* sys has int sec LPT */ #define MACHINE_LPT_TER 0x00000200 /* sys has int ter LPT */ -#define MACHINE_LPT_QUA 0x00000400 /* sys has int qua LPT */ +#define MACHINE_PS2_KBC 0x00000400 /* sys has a PS/2 keyboard controller */ + /* this is separate from having PS/2 ports */ #define MACHINE_UART_PRI 0x00000800 /* sys has int pri UART */ #define MACHINE_UART_SEC 0x00001000 /* sys has int sec UART */ #define MACHINE_UART_TER 0x00002000 /* sys has int ter UART */ @@ -106,7 +104,7 @@ #define MACHINE_APM 0x00080000 /* sys has APM */ #define MACHINE_ACPI 0x00100000 /* sys has ACPI */ #define MACHINE_HWM 0x00200000 /* sys has hw monitor */ -#define MACHINE_COREBOOT 0x00400000 /* sys has coreboot BIOS */ +#define MACHINE_CARTRIDGE 0x00400000 /* sys has cartridge bays */ /* Feature flags for internal storage controllers. */ #define MACHINE_MFM 0x00800000 /* sys has int MFM/RLL */ #define MACHINE_XTA 0x01000000 /* sys has int XTA */ diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index e55d9b494..2785607f6 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -8257,8 +8257,8 @@ const machine_t machines[] = { .min_multi = 0, .max_multi = 0 }, - .bus_flags = MACHINE_BUS_PS2_LATCH | MACHINE_PCI, - .flags = MACHINE_IDE_DUAL | MACHINE_APM, + .bus_flags = MACHINE_PCI, + .flags = MACHINE_PS2_KBC | MACHINE_IDE_DUAL | MACHINE_APM, .ram = { .min = 1024, .max = 131072, @@ -8337,8 +8337,8 @@ const machine_t machines[] = { .min_multi = 0, .max_multi = 0 }, - .bus_flags = MACHINE_BUS_PS2_LATCH | MACHINE_PCI, - .flags = MACHINE_IDE_DUAL | MACHINE_APM, + .bus_flags = MACHINE_PCI, + .flags = MACHINE_PS2_KBC | MACHINE_IDE_DUAL | MACHINE_APM, .ram = { .min = 1024, .max = 261120, @@ -8539,8 +8539,8 @@ const machine_t machines[] = { .min_multi = 0, .max_multi = 0 }, - .bus_flags = MACHINE_PCI | MACHINE_BUS_PS2_LATCH, - .flags = MACHINE_IDE_DUAL | MACHINE_APM, + .bus_flags = MACHINE_PCI, + .flags = MACHINE_PS2_KBC | MACHINE_IDE_DUAL | MACHINE_APM, .ram = { .min = 1024, .max = 131072, @@ -9198,8 +9198,8 @@ const machine_t machines[] = { .min_multi = MACHINE_MULTIPLIER_FIXED, .max_multi = MACHINE_MULTIPLIER_FIXED }, - .bus_flags = MACHINE_BUS_PS2_LATCH | MACHINE_PCI, - .flags = MACHINE_APM, + .bus_flags = MACHINE_PCI, + .flags = MACHINE_PS2_KBC | MACHINE_APM, .ram = { .min = 2048, .max = 196608, @@ -16507,19 +16507,39 @@ machine_get_nvrmask(int m) int machine_has_flags(int m, int flags) { - return (machines[m].flags & flags); + int ret = machines[m].flags & flags; + + /* Can't have PS/2 ports with an AT KBC. */ + if ((flags & MACHINE_PS2_KBC) && + (machines[m].bus_flags & MACHINE_BUS_PS2_PORTS)) + ret |= MACHINE_PS2_KBC; + + return ret; } int machine_has_bus(int m, int bus_flags) { - return (machines[m].bus_flags & bus_flags); + int ret = machines[m].bus_flags & bus_flags; + + /* TODO: Move the KBD flags to the machine table! */ + if ((bus_flags & MACHINE_BUS_XT_KBD) && + !(machines[m].bus_flags & MACHINE_BUS_ISA16) && + !(machines[m].bus_flags & MACHINE_BUS_PS2_PORTS)) + ret |= MACHINE_BUS_XT_KBD; + + if ((bus_flags & MACHINE_BUS_AT_KBD) && + (IS_AT(m)) && + !(machines[m].bus_flags & MACHINE_BUS_PS2_PORTS)) + ret |= MACHINE_BUS_AT_KBD; + + return ret; } int machine_has_cartridge(int m) { - return (machine_has_bus(m, MACHINE_CARTRIDGE) ? 1 : 0); + return (machine_has_flags(m, MACHINE_CARTRIDGE) ? 1 : 0); } int diff --git a/src/pic.c b/src/pic.c index 7f6eda40d..cf17e8205 100644 --- a/src/pic.c +++ b/src/pic.c @@ -629,7 +629,7 @@ pic_reset_hard(void) /* The situation is as follows: There is a giant mess when it comes to these latches on real hardware, to the point that there's even boards with board-level latched that get used in place of the latches on the chipset, therefore, I'm just doing this here for the sake of simplicity. */ - if (machine_has_bus(machine, MACHINE_BUS_PS2_LATCH)) { + if (machine_has_flags(machine, MACHINE_PS2_KBC)) { pic_kbd_latch(0x01); pic_mouse_latch(0x01); } else {