IDE now updates IRQ when needed.

This commit is contained in:
OBattler
2019-11-06 05:15:17 +01:00
parent 3b209c3015
commit 9c8c9361a6

View File

@@ -261,10 +261,10 @@ ide_irq_raise(ide_t *ide)
/* ide_log("Raising IRQ %i (board %i)\n", ide_boards[ide->board]->irq, ide->board); */ /* ide_log("Raising IRQ %i (board %i)\n", ide_boards[ide->board]->irq, ide->board); */
if (!(ide->fdisk & 2) && (ide_boards[ide->board]->irq != -1)) { if (!(ide->fdisk & 2)) {
if (ide_bm[ide->board] && ide_bm[ide->board]->set_irq) if (ide_bm[ide->board] && ide_bm[ide->board]->set_irq)
ide_bm[ide->board]->set_irq(ide->board | 0x40, ide_bm[ide->board]->priv); ide_bm[ide->board]->set_irq(ide->board | 0x40, ide_bm[ide->board]->priv);
else else if (ide_boards[ide->board]->irq != -1)
picint(1 << ide_boards[ide->board]->irq); picint(1 << ide_boards[ide->board]->irq);
} }
@@ -281,10 +281,10 @@ ide_irq_lower(ide_t *ide)
/* ide_log("Lowering IRQ %i (board %i)\n", ide_boards[ide->board]->irq, ide->board); */ /* ide_log("Lowering IRQ %i (board %i)\n", ide_boards[ide->board]->irq, ide->board); */
if ((ide_boards[ide->board]->irq != -1) && ide->irqstat) { if (ide->irqstat) {
if (ide_bm[ide->board] && ide_bm[ide->board]->set_irq) if (ide_bm[ide->board] && ide_bm[ide->board]->set_irq)
ide_bm[ide->board]->set_irq(ide->board, ide_bm[ide->board]->priv); ide_bm[ide->board]->set_irq(ide->board, ide_bm[ide->board]->priv);
else else if (ide_boards[ide->board]->irq != -1)
picintc(1 << ide_boards[ide->board]->irq); picintc(1 << ide_boards[ide->board]->irq);
} }
@@ -292,6 +292,31 @@ ide_irq_lower(ide_t *ide)
} }
static void
ide_irq_update(ide_t *ide)
{
if (!ide_boards[ide->board])
return;
/* ide_log("Raising IRQ %i (board %i)\n", ide_boards[ide->board]->irq, ide->board); */
if (!(ide->fdisk & 2) && ide->irqstat) {
if (ide_bm[ide->board] && ide_bm[ide->board]->set_irq) {
ide_bm[ide->board]->set_irq(ide->board, ide_bm[ide->board]->priv);
ide_bm[ide->board]->set_irq(ide->board | 0x40, ide_bm[ide->board]->priv);
} else if (ide_boards[ide->board]->irq != -1) {
picintc(1 << ide_boards[ide->board]->irq);
picint(1 << ide_boards[ide->board]->irq);
}
} else if (ide->fdisk & 2) {
if (ide_bm[ide->board] && ide_bm[ide->board]->set_irq)
ide_bm[ide->board]->set_irq(ide->board, ide_bm[ide->board]->priv);
else if (ide_boards[ide->board]->irq != -1)
picintc(1 << ide_boards[ide->board]->irq);
}
}
/** /**
* Copy a string into a buffer, padding with spaces, and placing characters as * Copy a string into a buffer, padding with spaces, and placing characters as
* if they were packed into 16-bit values, stored little-endian. * if they were packed into 16-bit values, stored little-endian.
@@ -1169,6 +1194,7 @@ ide_write_devctl(uint16_t addr, uint8_t val, void *priv)
ide_t *ide, *ide_other; ide_t *ide, *ide_other;
int ch; int ch;
uint8_t old;
ch = dev->cur_dev; ch = dev->cur_dev;
ide = ide_drives[ch]; ide = ide_drives[ch];
@@ -1225,7 +1251,10 @@ ide_write_devctl(uint16_t addr, uint8_t val, void *priv)
} }
} }
old = ide->fdisk;
ide->fdisk = ide_other->fdisk = val; ide->fdisk = ide_other->fdisk = val;
if (!(val & 0x02) && (old & 0x02) && ide->irqstat)
ide_irq_update(ide);
} }
@@ -1365,6 +1394,8 @@ ide_writeb(uint16_t addr, uint8_t val, void *priv)
ide->lba_addr = (ide->lba_addr & 0x0FFFFFF) | ((val & 0xF) << 24); ide->lba_addr = (ide->lba_addr & 0x0FFFFFF) | ((val & 0xF) << 24);
ide_other->lba_addr = (ide_other->lba_addr & 0x0FFFFFF)|((val & 0xF) << 24); ide_other->lba_addr = (ide_other->lba_addr & 0x0FFFFFF)|((val & 0xF) << 24);
ide_irq_update(ide);
return; return;
case 0x7: /* Command register */ case 0x7: /* Command register */