Lines Matching +full:slave +full:- +full:mode
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
29 * PIC driver for the 8259A Master and Slave PICs in PC/AT machines.
67 #define SLAVE 1 macro
69 #define IMEN_MASK(ai) (IRQ_MASK((ai)->at_irq))
93 #define IRQ(ap, ai) ((ap)->at_irqbase + (ai)->at_irq)
149 static void i8259_init(struct atpic *pic, int slave);
181 KASSERT(isrc->is_pic == &atpics[MASTER].at_pic, in _atpic_eoi_master()
189 * The data sheet says no auto-EOI on slave, but it sometimes works.
196 KASSERT(isrc->is_pic == &atpics[SLAVE].at_pic, in _atpic_eoi_slave()
199 outb(atpics[SLAVE].at_ioaddr, OCW2_EOI); in _atpic_eoi_slave()
217 * use mixed mode. The "accidental" use could otherwise occur on in atpic_register_sources()
222 * IRQ0 via mixed mode, but now we don't use mixed mode at all. in atpic_register_sources()
224 * To avoid the slave not register sources after the master in atpic_register_sources()
238 intr_register_source(&ai->at_intsrc); in atpic_register_sources()
246 struct atpic *ap = (struct atpic *)isrc->is_pic; in atpic_enable_source()
249 if (ap->at_imen & IMEN_MASK(ai)) { in atpic_enable_source()
250 ap->at_imen &= ~IMEN_MASK(ai); in atpic_enable_source()
251 outb(ap->at_ioaddr + ICU_IMR_OFFSET, ap->at_imen); in atpic_enable_source()
260 struct atpic *ap = (struct atpic *)isrc->is_pic; in atpic_disable_source()
263 if (ai->at_trigger != INTR_TRIGGER_EDGE) { in atpic_disable_source()
264 ap->at_imen |= IMEN_MASK(ai); in atpic_disable_source()
265 outb(ap->at_ioaddr + ICU_IMR_OFFSET, ap->at_imen); in atpic_disable_source()
274 if (isrc->is_pic == &atpics[MASTER].at_pic) in atpic_disable_source()
317 struct atpic *ap = (struct atpic *)isrc->is_pic; in atpic_vector()
326 struct atpic *ap = (struct atpic *)isrc->is_pic; in atpic_source_pending()
328 return (inb(ap->at_ioaddr) & IMEN_MASK(ai)); in atpic_source_pending()
336 i8259_init(ap, ap == &atpics[SLAVE]); in atpic_resume()
337 if (ap == &atpics[SLAVE] && elcr_found) in atpic_resume()
364 if (ai->at_trigger == trig) in atpic_config_intr()
392 ai->at_trigger = trig; in atpic_config_intr()
409 i8259_init(struct atpic *pic, int slave) in i8259_init() argument
415 outb(pic->at_ioaddr, ICW1_RESET | ICW1_IC4); in i8259_init()
416 imr_addr = pic->at_ioaddr + ICU_IMR_OFFSET; in i8259_init()
419 outb(imr_addr, pic->at_intbase); in i8259_init()
422 * Setup slave links. For the master pic, indicate what line in i8259_init()
423 * the slave is configured on. For the slave indicate in i8259_init()
426 if (slave) in i8259_init()
431 /* Set mode. */ in i8259_init()
432 if (slave) in i8259_init()
438 outb(imr_addr, pic->at_imen); in i8259_init()
441 outb(pic->at_ioaddr, OCW3_SEL | OCW3_RR); in i8259_init()
443 /* OCW2_L1 sets priority order to 3-7, 0-2 (com2 first). */ in i8259_init()
444 if (!slave) in i8259_init()
445 outb(pic->at_ioaddr, OCW2_R | OCW2_SL | OCW2_L1); in i8259_init()
458 i8259_init(&atpics[SLAVE], 1); in atpic_startup()
461 /* Install low-level interrupt handlers for all of our IRQs. */ in atpic_startup()
465 ai->at_intsrc.is_count = &ai->at_count; in atpic_startup()
466 ai->at_intsrc.is_straycount = &ai->at_straycount; in atpic_startup()
467 setidt(((struct atpic *)ai->at_intsrc.is_pic)->at_intbase + in atpic_startup()
468 ai->at_irq, pti ? ai->at_intr_pti : ai->at_intr, SDT_ATPIC, in atpic_startup()
485 ai->at_trigger = elcr_read_trigger(i); in atpic_startup()
494 ai->at_trigger = INTR_TRIGGER_EDGE; in atpic_startup()
497 ai->at_trigger = INTR_TRIGGER_LEVEL; in atpic_startup()
536 if (isrc->is_event == NULL && (vector == 7 || vector == 15)) { in atpic_handle_intr()
543 port = ((struct atpic *)isrc->is_pic)->at_ioaddr; in atpic_handle_intr()