From dc38b7d950d71425c89eff81799de26724798d2a Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 1 Aug 2022 03:16:44 +0200 Subject: [PATCH] The PIC now correctly processes slave interrupts in XT mode as well, fixes PS/2 mouse on the Xi8088, fixes #2045. --- src/pic.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/pic.c b/src/pic.c index 857f45cfc..12fd80264 100644 --- a/src/pic.c +++ b/src/pic.c @@ -724,10 +724,25 @@ pic_irq_ack(void) { int ret; + /* Needed for Xi8088. */ + if ((pic.ack_bytes == 0) && pic.int_pending && pic_slave_on(&pic, pic.interrupt)) { + if (!pic.slaves[pic.interrupt]->int_pending) { + /* If we are on AT, IRQ 2 is pending, and we cannot find a pending IRQ on PIC 2, fatal out. */ + fatal("IRQ %i pending on AT without a pending IRQ on PIC %i (normal)\n", pic.interrupt, pic.interrupt); + exit(-1); + return -1; + } + + pic.interrupt |= 0x40; /* Mark slave pending. */ + } + ret = pic_irq_ack_read(&pic, pic.ack_bytes); pic.ack_bytes = (pic.ack_bytes + 1) % (pic_i86_mode(&pic) ? 2 : 3); if (pic.ack_bytes == 0) { + /* Needed for Xi8088. */ + if (pic.interrupt & 0x40) + pic2.interrupt = 0x17; pic.interrupt = 0x17; update_pending(); }