Index: sys/x86/include/apicvar.h =================================================================== --- sys/x86/include/apicvar.h +++ sys/x86/include/apicvar.h @@ -159,10 +159,10 @@ #define APIC_BUS_PCI 2 #define APIC_BUS_MAX APIC_BUS_PCI -#define IRQ_EXTINT -1 -#define IRQ_NMI -2 -#define IRQ_SMI -3 -#define IRQ_DISABLED -4 +#define IRQ_EXTINT ((u_int)-1) +#define IRQ_NMI ((u_int)-2) +#define IRQ_SMI ((u_int)-3) +#define IRQ_DISABLED ((u_int)-4) /* * An APIC enumerator is a pseudo bus driver that enumerates APIC's including @@ -195,7 +195,7 @@ int ioapic_disable_pin(void *cookie, u_int pin); int ioapic_get_vector(void *cookie, u_int pin); void ioapic_register(void *cookie); -int ioapic_remap_vector(void *cookie, u_int pin, int vector); +int ioapic_remap_vector(void *cookie, u_int pin, u_int vector); int ioapic_set_bus(void *cookie, u_int pin, int bus_type); int ioapic_set_extint(void *cookie, u_int pin); int ioapic_set_nmi(void *cookie, u_int pin); Index: sys/x86/x86/io_apic.c =================================================================== --- sys/x86/x86/io_apic.c +++ sys/x86/x86/io_apic.c @@ -80,7 +80,7 @@ struct ioapic_intsrc { struct intsrc io_intsrc; - int io_irq; + u_int io_irq; u_int io_intpin:8; u_int io_vector:8; u_int io_cpu; @@ -256,7 +256,7 @@ printf("SMI"); break; default: - printf("%s IRQ %d", ioapic_bus_string(intpin->io_bus), + printf("%s IRQ %u", ioapic_bus_string(intpin->io_bus), intpin->io_irq); } } @@ -324,7 +324,7 @@ * been enabled yet, just ensure that the pin is masked. */ mtx_assert(&icu_lock, MA_OWNED); - if (intpin->io_irq == IRQ_DISABLED || (intpin->io_irq >= 0 && + if (intpin->io_irq == IRQ_DISABLED || (intpin->io_irq < num_io_irqs && intpin->io_vector == 0)) { low = ioapic_read(io->io_addr, IOAPIC_REDTBL_LO(intpin->io_intpin)); @@ -506,7 +506,7 @@ if (intpin->io_vector == 0) if (ioapic_assign_cpu(isrc, intr_next_cpu(isrc->is_domain)) != 0) - panic("Couldn't find an APIC vector for IRQ %d", + panic("Couldn't find an APIC vector for IRQ %u", intpin->io_irq); apic_enable_vector(intpin->io_cpu, intpin->io_vector); } @@ -756,14 +756,14 @@ } int -ioapic_remap_vector(void *cookie, u_int pin, int vector) +ioapic_remap_vector(void *cookie, u_int pin, u_int vector) { struct ioapic *io; io = (struct ioapic *)cookie; - if (pin >= io->io_numintr || vector < 0) + if (pin >= io->io_numintr || vector >= num_io_irqs) return (EINVAL); - if (io->io_pins[pin].io_irq < 0) + if (io->io_pins[pin].io_irq >= num_io_irqs) return (EINVAL); io->io_pins[pin].io_irq = vector; if (bootverbose) @@ -782,7 +782,7 @@ io = (struct ioapic *)cookie; if (pin >= io->io_numintr) return (EINVAL); - if (io->io_pins[pin].io_irq < 0) + if (io->io_pins[pin].io_irq >= num_io_irqs) return (EINVAL); if (io->io_pins[pin].io_bus == bus_type) return (0); @@ -803,7 +803,7 @@ return (EINVAL); if (io->io_pins[pin].io_irq == IRQ_NMI) return (0); - if (io->io_pins[pin].io_irq < 0) + if (io->io_pins[pin].io_irq >= num_io_irqs) return (EINVAL); io->io_pins[pin].io_bus = APIC_BUS_UNKNOWN; io->io_pins[pin].io_irq = IRQ_NMI; @@ -826,7 +826,7 @@ return (EINVAL); if (io->io_pins[pin].io_irq == IRQ_SMI) return (0); - if (io->io_pins[pin].io_irq < 0) + if (io->io_pins[pin].io_irq >= num_io_irqs) return (EINVAL); io->io_pins[pin].io_bus = APIC_BUS_UNKNOWN; io->io_pins[pin].io_irq = IRQ_SMI; @@ -849,7 +849,7 @@ return (EINVAL); if (io->io_pins[pin].io_irq == IRQ_EXTINT) return (0); - if (io->io_pins[pin].io_irq < 0) + if (io->io_pins[pin].io_irq >= num_io_irqs) return (EINVAL); io->io_pins[pin].io_bus = APIC_BUS_UNKNOWN; io->io_pins[pin].io_irq = IRQ_EXTINT; @@ -874,7 +874,7 @@ io = (struct ioapic *)cookie; if (pin >= io->io_numintr || pol == INTR_POLARITY_CONFORM) return (EINVAL); - if (io->io_pins[pin].io_irq < 0) + if (io->io_pins[pin].io_irq >= num_io_irqs) return (EINVAL); activehi = (pol == INTR_POLARITY_HIGH); if (io->io_pins[pin].io_activehi == activehi) @@ -895,7 +895,7 @@ io = (struct ioapic *)cookie; if (pin >= io->io_numintr || trigger == INTR_TRIGGER_CONFORM) return (EINVAL); - if (io->io_pins[pin].io_irq < 0) + if (io->io_pins[pin].io_irq >= num_io_irqs) return (EINVAL); edgetrigger = (trigger == INTR_TRIGGER_EDGE); if (io->io_pins[pin].io_edgetrigger == edgetrigger) @@ -950,7 +950,7 @@ io = (struct ioapic *)pic; for (i = 0, pin = io->io_pins; i < io->io_numintr; i++, pin++) { - if (pin->io_irq >= 0) + if (pin->io_irq < num_io_irqs) intr_register_source(&pin->io_intsrc); } } @@ -1185,7 +1185,7 @@ } static u_int -db_ioapic_read(volatile ioapic_t *apic, int reg) +db_ioapic_read(volatile ioapic_t *apic, u_int reg) { apic->ioregsel = reg;