diff --git a/sys/i386/isa/atpic.c b/sys/i386/isa/atpic.c index ba44094bb213..2f8c78c2b1bd 100644 --- a/sys/i386/isa/atpic.c +++ b/sys/i386/isa/atpic.c @@ -119,6 +119,8 @@ struct atpic_intsrc { struct intsrc at_intsrc; int at_irq; /* Relative to PIC base. */ inthand_t *at_intr; + u_long at_count; + u_long at_straycount; }; static void atpic_enable_source(struct intsrc *isrc); @@ -297,29 +299,38 @@ i8259_init(struct atpic *pic, int slave) void atpic_startup(void) { + struct atpic_intsrc *ai; + int i; /* Start off with all interrupts disabled. */ imen = 0xffff; i8259_init(&atpics[MASTER], 0); i8259_init(&atpics[SLAVE], 1); atpic_enable_source((struct intsrc *)&atintrs[ICU_SLAVEID]); + + /* Install low-level interrupt handlers for all of our IRQs. */ + for (i = 0; i < sizeof(atintrs) / sizeof(struct atpic_intsrc); i++) { + if (i == ICU_SLAVEID) + continue; + ai = &atintrs[i]; + ai->at_intsrc.is_count = &ai->at_count; + ai->at_intsrc.is_straycount = &ai->at_straycount; + setidt(((struct atpic *)ai->at_intsrc.is_pic)->at_intbase + + ai->at_irq, ai->at_intr, SDT_SYS386IGT, SEL_KPL, + GSEL(GCODE_SEL, SEL_KPL)); + } } static void atpic_init(void *dummy __unused) { - struct atpic_intsrc *ai; int i; /* Loop through all interrupt sources and add them. */ for (i = 0; i < sizeof(atintrs) / sizeof(struct atpic_intsrc); i++) { if (i == ICU_SLAVEID) continue; - ai = &atintrs[i]; - setidt(((struct atpic *)ai->at_intsrc.is_pic)->at_intbase + - ai->at_irq, ai->at_intr, SDT_SYS386IGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - intr_register_source(&ai->at_intsrc); + intr_register_source(&atintrs[i].at_intsrc); } } SYSINIT(atpic_init, SI_SUB_INTR, SI_ORDER_SECOND + 1, atpic_init, NULL)