Deleted Added
full compact
nmi.c (91367) nmi.c (93264)
1/*-
2 * Copyright (c) 1991 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: @(#)isa.c 7.2 (Berkeley) 5/13/91
1/*-
2 * Copyright (c) 1991 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: @(#)isa.c 7.2 (Berkeley) 5/13/91
37 * $FreeBSD: head/sys/i386/isa/nmi.c 91367 2002-02-27 09:51:33Z peter $
37 * $FreeBSD: head/sys/i386/isa/nmi.c 93264 2002-03-27 05:39:23Z dillon $
38 */
39
40#include "opt_auto_eoi.h"
41#include "opt_isa.h"
42#include "opt_mca.h"
43
44#include <sys/param.h>
45#include <sys/bus.h>

--- 66 unchanged lines hidden (view full) ---

112 &IDTVEC(fastintr22), &IDTVEC(fastintr23),
113 &IDTVEC(fastintr24), &IDTVEC(fastintr25),
114 &IDTVEC(fastintr26), &IDTVEC(fastintr27),
115 &IDTVEC(fastintr28), &IDTVEC(fastintr29),
116 &IDTVEC(fastintr30), &IDTVEC(fastintr31),
117#endif /* APIC_IO */
118};
119
38 */
39
40#include "opt_auto_eoi.h"
41#include "opt_isa.h"
42#include "opt_mca.h"
43
44#include <sys/param.h>
45#include <sys/bus.h>

--- 66 unchanged lines hidden (view full) ---

112 &IDTVEC(fastintr22), &IDTVEC(fastintr23),
113 &IDTVEC(fastintr24), &IDTVEC(fastintr25),
114 &IDTVEC(fastintr26), &IDTVEC(fastintr27),
115 &IDTVEC(fastintr28), &IDTVEC(fastintr29),
116 &IDTVEC(fastintr30), &IDTVEC(fastintr31),
117#endif /* APIC_IO */
118};
119
120static unpendhand_t *fastunpend[ICU_LEN] = {
121 &IDTVEC(fastunpend0), &IDTVEC(fastunpend1),
122 &IDTVEC(fastunpend2), &IDTVEC(fastunpend3),
123 &IDTVEC(fastunpend4), &IDTVEC(fastunpend5),
124 &IDTVEC(fastunpend6), &IDTVEC(fastunpend7),
125 &IDTVEC(fastunpend8), &IDTVEC(fastunpend9),
126 &IDTVEC(fastunpend10), &IDTVEC(fastunpend11),
127 &IDTVEC(fastunpend12), &IDTVEC(fastunpend13),
128 &IDTVEC(fastunpend14), &IDTVEC(fastunpend15),
129#if defined(APIC_IO)
130 &IDTVEC(fastunpend16), &IDTVEC(fastunpend17),
131 &IDTVEC(fastunpend18), &IDTVEC(fastunpend19),
132 &IDTVEC(fastunpend20), &IDTVEC(fastunpend21),
133 &IDTVEC(fastunpend22), &IDTVEC(fastunpend23),
134 &IDTVEC(fastunpend24), &IDTVEC(fastunpend25),
135 &IDTVEC(fastunpend26), &IDTVEC(fastunpend27),
136 &IDTVEC(fastunpend28), &IDTVEC(fastunpend29),
137 &IDTVEC(fastunpend30), &IDTVEC(fastunpend31),
138#endif /* APIC_IO */
139};
140
120static inthand_t *slowintr[ICU_LEN] = {
121 &IDTVEC(intr0), &IDTVEC(intr1), &IDTVEC(intr2), &IDTVEC(intr3),
122 &IDTVEC(intr4), &IDTVEC(intr5), &IDTVEC(intr6), &IDTVEC(intr7),
123 &IDTVEC(intr8), &IDTVEC(intr9), &IDTVEC(intr10), &IDTVEC(intr11),
124 &IDTVEC(intr12), &IDTVEC(intr13), &IDTVEC(intr14), &IDTVEC(intr15),
125#if defined(APIC_IO)
126 &IDTVEC(intr16), &IDTVEC(intr17), &IDTVEC(intr18), &IDTVEC(intr19),
127 &IDTVEC(intr20), &IDTVEC(intr21), &IDTVEC(intr22), &IDTVEC(intr23),

--- 158 unchanged lines hidden (view full) ---

286}
287
288/*
289 * ICU reinitialize when ICU configuration has lost.
290 */
291void icu_reinit()
292{
293 int i;
141static inthand_t *slowintr[ICU_LEN] = {
142 &IDTVEC(intr0), &IDTVEC(intr1), &IDTVEC(intr2), &IDTVEC(intr3),
143 &IDTVEC(intr4), &IDTVEC(intr5), &IDTVEC(intr6), &IDTVEC(intr7),
144 &IDTVEC(intr8), &IDTVEC(intr9), &IDTVEC(intr10), &IDTVEC(intr11),
145 &IDTVEC(intr12), &IDTVEC(intr13), &IDTVEC(intr14), &IDTVEC(intr15),
146#if defined(APIC_IO)
147 &IDTVEC(intr16), &IDTVEC(intr17), &IDTVEC(intr18), &IDTVEC(intr19),
148 &IDTVEC(intr20), &IDTVEC(intr21), &IDTVEC(intr22), &IDTVEC(intr23),

--- 158 unchanged lines hidden (view full) ---

307}
308
309/*
310 * ICU reinitialize when ICU configuration has lost.
311 */
312void icu_reinit()
313{
314 int i;
315 register_t crit;
294
316
317 crit = intr_disable();
295 mtx_lock_spin(&icu_lock);
296 init_i8259();
297 for(i=0;i<ICU_LEN;i++)
298 if(intr_handler[i] != isa_strayintr)
299 INTREN(1<<i);
300 mtx_unlock_spin(&icu_lock);
318 mtx_lock_spin(&icu_lock);
319 init_i8259();
320 for(i=0;i<ICU_LEN;i++)
321 if(intr_handler[i] != isa_strayintr)
322 INTREN(1<<i);
323 mtx_unlock_spin(&icu_lock);
324 intr_restore(crit);
301}
302
303/*
304 * Create a default interrupt table to avoid problems caused by
305 * spurious interrupts during configuration of kernel, then setup
306 * interrupt control unit.
307 */
308void
309isa_defaultirq()
310{
311 int i;
325}
326
327/*
328 * Create a default interrupt table to avoid problems caused by
329 * spurious interrupts during configuration of kernel, then setup
330 * interrupt control unit.
331 */
332void
333isa_defaultirq()
334{
335 int i;
336 register_t crit;
312
313 /* icu vectors */
314 for (i = 0; i < ICU_LEN; i++)
315 icu_unset(i, (driver_intr_t *)NULL);
337
338 /* icu vectors */
339 for (i = 0; i < ICU_LEN; i++)
340 icu_unset(i, (driver_intr_t *)NULL);
341 crit = intr_disable();
316 mtx_lock_spin(&icu_lock);
317 init_i8259();
318 mtx_unlock_spin(&icu_lock);
342 mtx_lock_spin(&icu_lock);
343 init_i8259();
344 mtx_unlock_spin(&icu_lock);
345 intr_restore(crit);
319}
320
321
322/*
323 *initialize 8259's
324 */
325static void init_i8259()
326{

--- 144 unchanged lines hidden (view full) ---

471int
472icu_setup(int intr, driver_intr_t *handler, void *arg, int flags)
473{
474#ifdef FAST_HI
475 int select; /* the select register is 8 bits */
476 int vector;
477 u_int32_t value; /* the window register is 32 bits */
478#endif /* FAST_HI */
346}
347
348
349/*
350 *initialize 8259's
351 */
352static void init_i8259()
353{

--- 144 unchanged lines hidden (view full) ---

498int
499icu_setup(int intr, driver_intr_t *handler, void *arg, int flags)
500{
501#ifdef FAST_HI
502 int select; /* the select register is 8 bits */
503 int vector;
504 u_int32_t value; /* the window register is 32 bits */
505#endif /* FAST_HI */
506 register_t crit;
479
480#if defined(APIC_IO)
481 if ((u_int)intr >= ICU_LEN) /* no 8259 SLAVE to ignore */
482#else
483 if ((u_int)intr >= ICU_LEN || intr == ICU_SLAVEID)
484#endif /* APIC_IO */
485 return (EINVAL);
486#if 0
487 if (intr_handler[intr] != isa_strayintr)
488 return (EBUSY);
489#endif
490
507
508#if defined(APIC_IO)
509 if ((u_int)intr >= ICU_LEN) /* no 8259 SLAVE to ignore */
510#else
511 if ((u_int)intr >= ICU_LEN || intr == ICU_SLAVEID)
512#endif /* APIC_IO */
513 return (EINVAL);
514#if 0
515 if (intr_handler[intr] != isa_strayintr)
516 return (EBUSY);
517#endif
518
519 crit = intr_disable();
491 mtx_lock_spin(&icu_lock);
492 intr_handler[intr] = handler;
493 intr_unit[intr] = arg;
494#ifdef FAST_HI
495 if (flags & INTR_FAST) {
496 vector = TPR_FAST_INTS + intr;
497 setidt(vector, fastintr[intr],
498 SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));

--- 26 unchanged lines hidden (view full) ---

525 }
526#else
527 setidt(ICU_OFFSET + intr,
528 flags & INTR_FAST ? fastintr[intr] : slowintr[intr],
529 SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
530#endif /* FAST_HI */
531 INTREN(1 << intr);
532 mtx_unlock_spin(&icu_lock);
520 mtx_lock_spin(&icu_lock);
521 intr_handler[intr] = handler;
522 intr_unit[intr] = arg;
523#ifdef FAST_HI
524 if (flags & INTR_FAST) {
525 vector = TPR_FAST_INTS + intr;
526 setidt(vector, fastintr[intr],
527 SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));

--- 26 unchanged lines hidden (view full) ---

554 }
555#else
556 setidt(ICU_OFFSET + intr,
557 flags & INTR_FAST ? fastintr[intr] : slowintr[intr],
558 SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
559#endif /* FAST_HI */
560 INTREN(1 << intr);
561 mtx_unlock_spin(&icu_lock);
562 intr_restore(crit);
533 return (0);
534}
535
536/*
537 * Dissociate an interrupt handler from an IRQ and set the handler to
538 * the stray interrupt handler. The 'handler' parameter is used only
539 * for consistency checking.
540 */
541int
542icu_unset(intr, handler)
543 int intr;
544 driver_intr_t *handler;
545{
563 return (0);
564}
565
566/*
567 * Dissociate an interrupt handler from an IRQ and set the handler to
568 * the stray interrupt handler. The 'handler' parameter is used only
569 * for consistency checking.
570 */
571int
572icu_unset(intr, handler)
573 int intr;
574 driver_intr_t *handler;
575{
576 register_t crit;
546
547 if ((u_int)intr >= ICU_LEN || handler != intr_handler[intr])
548 return (EINVAL);
549
577
578 if ((u_int)intr >= ICU_LEN || handler != intr_handler[intr])
579 return (EINVAL);
580
581 crit = intr_disable();
550 mtx_lock_spin(&icu_lock);
551 INTRDIS(1 << intr);
552 intr_countp[intr] = &intrcnt[1 + intr];
553 intr_handler[intr] = isa_strayintr;
554 intr_unit[intr] = &intr_unit[intr];
555#ifdef FAST_HI_XXX
556 /* XXX how do I re-create dvp here? */
557 setidt(flags & INTR_FAST ? TPR_FAST_INTS + intr : TPR_SLOW_INTS + intr,
558 slowintr[intr], SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
559#else /* FAST_HI */
560#ifdef APIC_INTR_REORDER
561 set_lapic_isrloc(intr, ICU_OFFSET + intr);
562#endif
563 setidt(ICU_OFFSET + intr, slowintr[intr], SDT_SYS386IGT, SEL_KPL,
564 GSEL(GCODE_SEL, SEL_KPL));
565#endif /* FAST_HI */
566 mtx_unlock_spin(&icu_lock);
582 mtx_lock_spin(&icu_lock);
583 INTRDIS(1 << intr);
584 intr_countp[intr] = &intrcnt[1 + intr];
585 intr_handler[intr] = isa_strayintr;
586 intr_unit[intr] = &intr_unit[intr];
587#ifdef FAST_HI_XXX
588 /* XXX how do I re-create dvp here? */
589 setidt(flags & INTR_FAST ? TPR_FAST_INTS + intr : TPR_SLOW_INTS + intr,
590 slowintr[intr], SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
591#else /* FAST_HI */
592#ifdef APIC_INTR_REORDER
593 set_lapic_isrloc(intr, ICU_OFFSET + intr);
594#endif
595 setidt(ICU_OFFSET + intr, slowintr[intr], SDT_SYS386IGT, SEL_KPL,
596 GSEL(GCODE_SEL, SEL_KPL));
597#endif /* FAST_HI */
598 mtx_unlock_spin(&icu_lock);
599 intr_restore(crit);
567 return (0);
568}
569
570static void
571ithds_init(void *dummy)
572{
573
574 mtx_init(&ithds_table_lock, "ithread table lock", MTX_SPIN);
575}
576SYSINIT(ithds_init, SI_SUB_INTR, SI_ORDER_SECOND, ithds_init, NULL);
577
578static void
579ithread_enable(int vector)
580{
600 return (0);
601}
602
603static void
604ithds_init(void *dummy)
605{
606
607 mtx_init(&ithds_table_lock, "ithread table lock", MTX_SPIN);
608}
609SYSINIT(ithds_init, SI_SUB_INTR, SI_ORDER_SECOND, ithds_init, NULL);
610
611static void
612ithread_enable(int vector)
613{
614 register_t crit;
581
615
616 crit = intr_disable();
582 mtx_lock_spin(&icu_lock);
583 INTREN(1 << vector);
584 mtx_unlock_spin(&icu_lock);
617 mtx_lock_spin(&icu_lock);
618 INTREN(1 << vector);
619 mtx_unlock_spin(&icu_lock);
620 intr_restore(crit);
585}
586
587static void
588ithread_disable(int vector)
589{
621}
622
623static void
624ithread_disable(int vector)
625{
626 register_t crit;
590
627
628 crit = intr_disable();
591 mtx_lock_spin(&icu_lock);
592 INTRDIS(1 << vector);
593 mtx_unlock_spin(&icu_lock);
629 mtx_lock_spin(&icu_lock);
630 INTRDIS(1 << vector);
631 mtx_unlock_spin(&icu_lock);
632 intr_restore(crit);
594}
595
596int
597inthand_add(const char *name, int irq, driver_intr_t handler, void *arg,
598 enum intr_type flags, void **cookiep)
599{
600 struct ithd *ithd; /* descriptor for the IRQ */
601 int errcode = 0;

--- 65 unchanged lines hidden (view full) ---

667 * in use.
668 */
669int
670inthand_remove(void *cookie)
671{
672
673 return (ithread_remove_handler(cookie));
674}
633}
634
635int
636inthand_add(const char *name, int irq, driver_intr_t handler, void *arg,
637 enum intr_type flags, void **cookiep)
638{
639 struct ithd *ithd; /* descriptor for the IRQ */
640 int errcode = 0;

--- 65 unchanged lines hidden (view full) ---

706 * in use.
707 */
708int
709inthand_remove(void *cookie)
710{
711
712 return (ithread_remove_handler(cookie));
713}
714
715void
716call_fast_unpend(int irq)
717{
718 fastunpend[irq]();
719}
720