From 4ae901c901785befa0fc3226fdfbe8ad4cc30ee3 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 28 Jul 2024 02:26:43 +0200 Subject: [PATCH] Genoa Unknown 486: Port 92h controls the exact same gate as the KBC, fixes #4660. --- src/include/86box/port_92.h | 1 + src/machine/m_at_386dx_486.c | 2 +- src/port_92.c | 27 ++++++++++++++++++++++++--- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/include/86box/port_92.h b/src/include/86box/port_92.h index 2dd4319be..838b7ca28 100644 --- a/src/include/86box/port_92.h +++ b/src/include/86box/port_92.h @@ -37,6 +37,7 @@ extern void port_92_add(void *priv); extern void port_92_remove(void *priv); extern const device_t port_92_device; +extern const device_t port_92_key_device; extern const device_t port_92_inv_device; extern const device_t port_92_word_device; extern const device_t port_92_pci_device; diff --git a/src/machine/m_at_386dx_486.c b/src/machine/m_at_386dx_486.c index 82f946314..6b0ffae50 100644 --- a/src/machine/m_at_386dx_486.c +++ b/src/machine/m_at_386dx_486.c @@ -2333,7 +2333,7 @@ machine_at_genoa486_init(const machine_t *model) machine_at_common_init(model); device_add(&compaq_genoa_device); - device_add(&port_92_device); + device_add(&port_92_key_device); device_add(&keyboard_at_ami_device); diff --git a/src/port_92.c b/src/port_92.c index 1307ecba9..18e60326c 100644 --- a/src/port_92.c +++ b/src/port_92.c @@ -36,6 +36,7 @@ #define PORT_92_PCI 4 #define PORT_92_RESET 8 #define PORT_92_A20 16 +#define PORT_92_KEY 32 static uint8_t port_92_readb(uint16_t port, void *priv) @@ -46,7 +47,10 @@ port_92_readb(uint16_t port, void *priv) if (port == 0x92) { /* Return bit 1 directly from mem_a20_alt, so the pin can be reset independently of the device. */ - ret = (dev->reg & ~0x03) | (mem_a20_alt & 2) | (cpu_alt_reset & 1); + if (dev->flags & PORT_92_KEY) + ret = (dev->reg & ~0x03) | (mem_a20_key & 2) | (cpu_alt_reset & 1); + else + ret = (dev->reg & ~0x03) | (mem_a20_alt & 2) | (cpu_alt_reset & 1); if (dev->flags & PORT_92_INV) ret |= 0xfc; @@ -94,8 +98,11 @@ port_92_writeb(uint16_t port, uint8_t val, void *priv) dev->reg = val & 0x03; - if ((mem_a20_alt ^ val) & 2) { - mem_a20_alt = (val & 2); + if (dev->flags & PORT_92_KEY) { + mem_a20_key = val & 2; + mem_a20_recalc(); + } else if ((mem_a20_alt ^ val) & 2) { + mem_a20_alt = (mem_a20_alt & 0xfd) | (val & 2); mem_a20_recalc(); } @@ -234,6 +241,20 @@ const device_t port_92_device = { .config = NULL }; +const device_t port_92_key_device = { + .name = "Port 92 Register (using A20 key)", + .internal_name = "port_92_key", + .flags = 0, + .local = PORT_92_KEY, + .init = port_92_init, + .close = port_92_close, + .reset = NULL, + { .available = NULL }, + .speed_changed = NULL, + .force_redraw = NULL, + .config = NULL +}; + const device_t port_92_inv_device = { .name = "Port 92 Register (inverted bits 2-7)", .internal_name = "port_92_inv",