irq: make IRQs dynamically mappable

This commit is contained in:
Michael Shaw 2023-05-04 22:10:23 -04:00
commit b8b67aadc9
7 changed files with 108 additions and 21 deletions

View file

@ -7,6 +7,10 @@
static hbamem_t *abar = NULL;
static void ahci_irq_handler()
{
}
void ahci_init()
{
struct pci_device *dev = pci_find_device(0x01, 0x06);
@ -22,5 +26,13 @@ void ahci_init()
return;
}
/* setup device irq number */
uint8_t irq = irq_highest_free();
uint16_t tmp = pci_config_read_word(dev->bus, dev->slot, 0, 0x3C);
tmp &= 0xFF00;
tmp |= irq;
pci_config_write_word(dev->bus, dev->slot, 0, 0x3C, tmp);
irq_map(irq, ahci_irq_handler);
printf(LOG_SUCCESS "AHCI controller ready\n");
}