From be74288b5e6f9dac2eff28685148ff5429c36161 Mon Sep 17 00:00:00 2001 From: SarahW Date: Mon, 31 May 2021 08:17:37 +0100 Subject: [PATCH] Stricter logic when adding/removing IO handlers. Fixes crashes with GA686BX when triggering power events when using older BIOSes (tested with 02/10/1999 BIOS). --- src/io.c | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/src/io.c b/src/io.c index 3c6cfd9..ea94c67 100644 --- a/src/io.c +++ b/src/io.c @@ -87,36 +87,28 @@ void io_removehandler(uint16_t base, int size, int c; for (c = 0; c < size; c++) { - if (port_priv[base + c][0] == priv) + if (port_priv[base + c][0] == priv && + port_inb[base + c][0] == inb && port_inw[base + c][0] == inw && port_inl[base + c][0] == inl && + port_outb[base + c][0] == outb && port_outw[base + c][0] == outw && port_outl[base + c][0] == outl) { - if (port_inb[ base + c][0] == inb) - port_inb[ base + c][0] = NULL; - if (port_inw[ base + c][0] == inw) - port_inw[ base + c][0] = NULL; - if (port_inl[ base + c][0] == inl) - port_inl[ base + c][0] = NULL; - if (port_outb[ base + c][0] == outb) - port_outb[ base + c][0] = NULL; - if (port_outw[ base + c][0] == outw) - port_outw[ base + c][0] = NULL; - if (port_outl[ base + c][0] == outl) - port_outl[ base + c][0] = NULL; + port_inb[ base + c][0] = NULL; + port_inw[ base + c][0] = NULL; + port_inl[ base + c][0] = NULL; + port_outb[ base + c][0] = NULL; + port_outw[ base + c][0] = NULL; + port_outl[ base + c][0] = NULL; port_priv[base + c][0] = NULL; } - if (port_priv[base + c][1] == priv) + if (port_priv[base + c][1] == priv && + port_inb[base + c][1] == inb && port_inw[base + c][1] == inw && port_inl[base + c][1] == inl && + port_outb[base + c][1] == outb && port_outw[base + c][1] == outw && port_outl[base + c][1] == outl) { - if (port_inb[ base + c][1] == inb) - port_inb[ base + c][1] = NULL; - if (port_inw[ base + c][1] == inw) - port_inw[ base + c][1] = NULL; - if (port_inl[ base + c][1] == inl) - port_inl[ base + c][1] = NULL; - if (port_outb[ base + c][1] == outb) - port_outb[ base + c][1] = NULL; - if (port_outw[ base + c][1] == outw) - port_outw[ base + c][1] = NULL; - if (port_outl[ base + c][1] == outl) - port_outl[ base + c][1] = NULL; + port_inb[ base + c][1] = NULL; + port_inw[ base + c][1] = NULL; + port_inl[ base + c][1] = NULL; + port_outb[base + c][1] = NULL; + port_outw[base + c][1] = NULL; + port_outl[base + c][1] = NULL; port_priv[base + c][1] = NULL; } }