diff options
author | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2021-06-03 23:14:05 +0300 |
---|---|---|
committer | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2021-06-07 21:01:19 +0000 |
commit | 93c1eef6c15756871959cca11fab85d6b8ca8e5d (patch) | |
tree | 6ac5ac6cfd4b520ad739837d05c8956c428cc46f | |
parent | ea2fb8d80c64c99404417ccf0d4ba932ba3ade2e (diff) |
arch/x86/ioapic: Add write_vector() helper
Change-Id: I4a44aada7d3dbc016e4044c351534a0d8520f0b2
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55184
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r-- | src/arch/x86/ioapic.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/arch/x86/ioapic.c b/src/arch/x86/ioapic.c index 1a8b489ed3..3b814ad834 100644 --- a/src/arch/x86/ioapic.c +++ b/src/arch/x86/ioapic.c @@ -18,6 +18,15 @@ void io_apic_write(void *ioapic_base, u32 reg, u32 value) write32(ioapic_base + 0x10, value); } +static void write_vector(void *ioapic_base, u8 vector, u32 high, u32 low) +{ + io_apic_write(ioapic_base, vector * 2 + 0x10, low); + io_apic_write(ioapic_base, vector * 2 + 0x11, high); + + printk(BIOS_SPEW, "IOAPIC: vector 0x%02x value 0x%08x 0x%08x\n", + vector, high, low); +} + static int ioapic_interrupt_count(void *ioapic_base) { /* Read the available number of interrupts. */ @@ -42,13 +51,8 @@ static void clear_vectors(void *ioapic_base, u8 first, u8 last) low = INT_DISABLED; high = NONE; - for (i = first; i <= last; i++) { - io_apic_write(ioapic_base, i * 2 + 0x10, low); - io_apic_write(ioapic_base, i * 2 + 0x11, high); - - printk(BIOS_SPEW, "IOAPIC: vector 0x%02x value 0x%08x 0x%08x\n", - i, high, low); - } + for (i = first; i <= last; i++) + write_vector(ioapic_base, i, high, low); if (io_apic_read(ioapic_base, 0x10) == 0xffffffff) { printk(BIOS_WARNING, "IOAPIC not responding.\n"); @@ -75,15 +79,12 @@ static void route_i8259_irq0(void *ioapic_base) low = INT_ENABLED | TRIGGER_EDGE | POLARITY_HIGH | PHYSICAL_DEST | ExtINT; high = bsp_lapicid << (56 - 32); - io_apic_write(ioapic_base, 0x10, low); - io_apic_write(ioapic_base, 0x11, high); + write_vector(ioapic_base, 0, high, low); if (io_apic_read(ioapic_base, 0x10) == 0xffffffff) { printk(BIOS_WARNING, "IOAPIC not responding.\n"); return; } - - printk(BIOS_SPEW, "IOAPIC: reg 0x%08x value 0x%08x 0x%08x\n", 0, high, low); } void set_ioapic_id(void *ioapic_base, u8 ioapic_id) |