From 585c08d156dc0c4d855197ff942087546299d6ee Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 21 Jun 2017 19:42:36 +0200 Subject: [PATCH] PCI turbo reset control and PCI initialization functions now reset the ELCR registers, the PIC, and the PCI IRQ statuses, fixes PCI cards being stuck unable to issue IRQ's after soft and hard resets. --- src/mouse_serial.c | 40 ++++++++++++++++++++++++---------------- src/pci.c | 15 +++++++++++++++ src/pci.h | 2 ++ src/sio.c | 2 ++ 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/src/mouse_serial.c b/src/mouse_serial.c index 04f23a8d9..3d410355a 100644 --- a/src/mouse_serial.c +++ b/src/mouse_serial.c @@ -57,21 +57,25 @@ sermouse_timer(void *priv) ms->delay = 0; - switch(ms->type) { - case SERMOUSE_TYPE_MICROSOFT: - /* This identifies a two-button Microsoft Serial mouse. */ - serial_write_fifo(ms->serial, 'M', 1); - break; + if (ms->pos == -1) + { + ms->pos = 0; + switch(ms->type) { + case SERMOUSE_TYPE_MICROSOFT: + /* This identifies a two-button Microsoft Serial mouse. */ + serial_write_fifo(ms->serial, 'M', 1); + break; - case SERMOUSE_TYPE_LOGITECH: - /* This identifies a two-button Logitech Serial mouse. */ - serial_write_fifo(ms->serial, 'M', 1); - serial_write_fifo(ms->serial, '3', 1); - break; + case SERMOUSE_TYPE_LOGITECH: + /* This identifies a two-button Logitech Serial mouse. */ + serial_write_fifo(ms->serial, 'M', 1); + serial_write_fifo(ms->serial, '3', 1); + break; - default: - /* No action needed. */ - break; + default: + /* No action needed. */ + break; + } } } @@ -83,6 +87,7 @@ sermouse_poll(int x, int y, int z, int b, void *priv) uint8_t buff[16]; int len; + if (!(serial_ier(0) & 1)) return(1); if (!x && !y && b == ms->oldb) return(1); ms->oldb = b; @@ -142,9 +147,12 @@ sermouse_poll(int x, int y, int z, int b, void *priv) pclog(" ] (%d)\n", len); #endif - /* Send the packet to the bottom-half of the attached port. */ - for (b=0; bserial, buff[b], 1); + if (!(serial_mctrl(0) & 0x10)) + { + /* Send the packet to the bottom-half of the attached port. */ + for (b=0; bserial, buff[b], 1); + } return(0); } diff --git a/src/pci.c b/src/pci.c index 4218c587d..0dc20b68f 100644 --- a/src/pci.c +++ b/src/pci.c @@ -75,6 +75,19 @@ uint8_t elcr_read(uint16_t port, void *priv) return elcr[port & 1]; } +void elcr_reset(void) +{ + int i = 0; + + pic_reset(); + elcr[0] = elcr[1] = 0; + + for (i = 0; i < 32; i++) + { + pci_irq_active[i] = 0; + } +} + void pci_type2_write(uint16_t port, uint8_t val, void *priv); uint8_t pci_type2_read(uint16_t port, void *priv); @@ -188,6 +201,8 @@ void pci_init(int type) PCI = 1; + elcr_reset(); + io_sethandler(0x04d0, 0x0002, elcr_read, NULL, NULL, elcr_write, NULL, NULL, NULL); if (type == PCI_CONFIG_TYPE_1) diff --git a/src/pci.h b/src/pci.h index 6a8778e0f..f1cecc952 100644 --- a/src/pci.h +++ b/src/pci.h @@ -1,3 +1,5 @@ +void elcr_reset(void); + void pci_init(int type); void pci_slot(int card); void pci_add_specific(int card, uint8_t (*read)(int func, int addr, void *priv), void (*write)(int func, int addr, uint8_t val, void *priv), void *priv); diff --git a/src/sio.c b/src/sio.c index 03389a0ed..17e278fc4 100644 --- a/src/sio.c +++ b/src/sio.c @@ -169,6 +169,8 @@ void trc_reset(uint8_t val) port_92_reset(); keyboard_at_reset(); + + elcr_reset(); } resetx86(); }