diff options
author | Ian Moffett <ian@osmora.org> | 2025-10-08 01:10:01 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-10-08 01:11:58 -0400 |
commit | 25f1f6f830282a667927dfefb5b91e72a5e69e6e (patch) | |
tree | 62cb53d51cc046298ee1a8fc807343d05b27d10a /src | |
parent | a68110d699aec9cb593f217674ec2476019a095b (diff) |
Introduce a helper function to convert legacy ISA IRQ numbers to the GSI
numbers assigned to an I/O APIC pin
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/sys/arch/amd64/mainbus/ioapic.c | 27 | ||||
-rw-r--r-- | src/sys/include/arch/amd64/ioapic.h | 7 |
2 files changed, 26 insertions, 8 deletions
diff --git a/src/sys/arch/amd64/mainbus/ioapic.c b/src/sys/arch/amd64/mainbus/ioapic.c index cf65484..0d5da07 100644 --- a/src/sys/arch/amd64/mainbus/ioapic.c +++ b/src/sys/arch/amd64/mainbus/ioapic.c @@ -155,6 +155,23 @@ __irq_to_gsi(struct apic_header *hdr, size_t irq) } /* + * Convert an IRQ to a GSI + */ +int +ioapic_get_gsi(uint8_t irq) +{ + int gsi; + + gsi = acpi_read_madt( + APIC_TYPE_INTERRUPT_OVERRIDE, + __irq_to_gsi, + irq + ); + + return (gsi < 0) ? irq : gsi; +} + +/* * Mask or unmask a GSI */ void @@ -168,19 +185,13 @@ ioapic_gsi_mask(uint8_t gsi, uint8_t mask) } /* - * Map a GSI to a system interrupt vector + * Map an IRQ to a system interrupt vector */ void ioapic_route_vec(uint8_t irq, uint8_t vector) { union ioapic_redentry redent; - int gsi; - - gsi = acpi_read_madt( - APIC_TYPE_INTERRUPT_OVERRIDE, - __irq_to_gsi, - irq - ); + int gsi = ioapic_get_gsi(irq); ioapic_read_redentry(&redent, gsi); redent.vector = vector; diff --git a/src/sys/include/arch/amd64/ioapic.h b/src/sys/include/arch/amd64/ioapic.h index 20b8058..c0d935e 100644 --- a/src/sys/include/arch/amd64/ioapic.h +++ b/src/sys/include/arch/amd64/ioapic.h @@ -49,6 +49,13 @@ void ioapic_init(void); void ioapic_gsi_mask(uint8_t gsi, uint8_t mask); /* + * Convert an ISA IRQ number into a global system + * interrupt, returnes a less than zero value on + * failure. + */ +int ioapic_get_gsi(uint8_t irq); + +/* * Route an IRQ number to a system interrupt vector * via the internal redirection table * |