| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- /* I/O APIC masking.
- *
- * This kernel has no IOAPIC driver: the BSP keeps the 8259 PIC and delivers
- * its interrupts through LAPIC LINT0 in ExtINT mode (lapic.c). Firmware may
- * still leave IOAPIC redirection entries programmed, and their vectors can
- * collide with the PIC vectors (0x20..0x2f) or the LAPIC timer vector 0x30.
- * Masking every normal entry makes the 8259 path deterministic.
- *
- * ExtINT-delivery entries are deliberately left unmasked: a few boards route
- * the 8259 output through an IOAPIC pin instead of LINT0, and that entry must
- * keep working. Entries that are already masked are skipped.
- */
- #include "ioapic.h"
- #include "acpi.h"
- #include "paging.h"
- #include "serial.h"
- #define IOAPIC_REGSEL 0x00
- #define IOAPIC_IOWIN 0x10
- #define IOAPIC_VER 0x01
- #define IOAPIC_REDTBL 0x10
- #define IOAPIC_MASK 0x00010000u
- #define IOAPIC_DELMODE_MASK 0x00000700u
- #define IOAPIC_DELMODE_EXTINT 0x00000700u
- static unsigned int ioapic_read(volatile unsigned int *base, unsigned int reg)
- {
- base[IOAPIC_REGSEL / 4] = reg;
- return base[IOAPIC_IOWIN / 4];
- }
- static void ioapic_write(volatile unsigned int *base, unsigned int reg,
- unsigned int val)
- {
- base[IOAPIC_REGSEL / 4] = reg;
- base[IOAPIC_IOWIN / 4] = val;
- }
- void ioapic_mask_all(void)
- {
- unsigned int n = acpi_ioapic_count();
- unsigned int i;
- for (i = 0; i < n; i++) {
- unsigned int addr = acpi_ioapic_base(i);
- volatile unsigned int *base;
- unsigned int ver, entries, j, masked = 0;
- if (!addr)
- continue;
- base = ioremap(addr, 0x1000, IOREMAP_MMIO);
- if (!base)
- continue;
- ver = ioapic_read(base, IOAPIC_VER);
- if (ver == 0xFFFFFFFFu)
- continue;
- entries = ((ver >> 16) & 0xFFu) + 1u;
- for (j = 0; j < entries; j++) {
- unsigned int lo = ioapic_read(base,
- IOAPIC_REDTBL + 2u * j);
- if (lo & IOAPIC_MASK)
- continue;
- if ((lo & IOAPIC_DELMODE_MASK) ==
- IOAPIC_DELMODE_EXTINT)
- continue;
- ioapic_write(base, IOAPIC_REDTBL + 2u * j,
- lo | IOAPIC_MASK);
- masked++;
- }
- serial_puts(SERIAL_COM1, "ioapic: masked ");
- serial_putdec(SERIAL_COM1, masked);
- serial_puts(SERIAL_COM1, " of ");
- serial_putdec(SERIAL_COM1, entries);
- serial_puts(SERIAL_COM1, " entries at ");
- serial_puthex(SERIAL_COM1, addr);
- serial_puts(SERIAL_COM1, "\n");
- }
- }
|