2 * Copyright (c) 2003 Matthew Dillon <dillon@backplane.com> All rights reserved.
3 * Copyright (c) 1997, Stefan Esser <se@freebsd.org> All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice unmodified, this list of conditions, and the following
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * $FreeBSD: src/sys/kern/kern_intr.c,v 1.24.2.1 2001/10/14 20:05:50 luigi Exp $
27 * $DragonFly: src/sys/kern/kern_intr.c,v 1.48 2007/04/30 16:45:53 dillon Exp $
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/malloc.h>
34 #include <sys/kernel.h>
35 #include <sys/sysctl.h>
36 #include <sys/thread.h>
38 #include <sys/thread2.h>
39 #include <sys/random.h>
40 #include <sys/serialize.h>
41 #include <sys/interrupt.h>
43 #include <sys/machintr.h>
45 #include <machine/frame.h>
47 #include <sys/interrupt.h>
51 typedef struct intrec {
53 struct intr_info *info;
59 struct lwkt_serialize *serializer;
64 struct thread i_thread;
65 struct random_softc i_random;
67 long i_count; /* interrupts dispatched */
68 int i_mplock_required;
72 } intr_info_ary[MAX_INTS];
74 int max_installed_hard_intr;
75 int max_installed_soft_intr;
77 #define EMERGENCY_INTR_POLLING_FREQ_MAX 20000
79 static int sysctl_emergency_freq(SYSCTL_HANDLER_ARGS);
80 static int sysctl_emergency_enable(SYSCTL_HANDLER_ARGS);
81 static void emergency_intr_timer_callback(systimer_t, struct intrframe *);
82 static void ithread_handler(void *arg);
83 static void ithread_emergency(void *arg);
85 int intr_info_size = sizeof(intr_info_ary) / sizeof(intr_info_ary[0]);
87 static struct systimer emergency_intr_timer;
88 static struct thread emergency_intr_thread;
90 #define ISTATE_NOTHREAD 0
91 #define ISTATE_NORMAL 1
92 #define ISTATE_LIVELOCKED 2
95 static int intr_mpsafe = 0;
96 TUNABLE_INT("kern.intr_mpsafe", &intr_mpsafe);
97 SYSCTL_INT(_kern, OID_AUTO, intr_mpsafe,
98 CTLFLAG_RW, &intr_mpsafe, 0, "Run INTR_MPSAFE handlers without the BGL");
100 static int livelock_limit = 50000;
101 static int livelock_lowater = 20000;
102 SYSCTL_INT(_kern, OID_AUTO, livelock_limit,
103 CTLFLAG_RW, &livelock_limit, 0, "Livelock interrupt rate limit");
104 SYSCTL_INT(_kern, OID_AUTO, livelock_lowater,
105 CTLFLAG_RW, &livelock_lowater, 0, "Livelock low-water mark restore");
107 static int emergency_intr_enable = 0; /* emergency interrupt polling */
108 TUNABLE_INT("kern.emergency_intr_enable", &emergency_intr_enable);
109 SYSCTL_PROC(_kern, OID_AUTO, emergency_intr_enable, CTLTYPE_INT | CTLFLAG_RW,
110 0, 0, sysctl_emergency_enable, "I", "Emergency Interrupt Poll Enable");
112 static int emergency_intr_freq = 10; /* emergency polling frequency */
113 TUNABLE_INT("kern.emergency_intr_freq", &emergency_intr_freq);
114 SYSCTL_PROC(_kern, OID_AUTO, emergency_intr_freq, CTLTYPE_INT | CTLFLAG_RW,
115 0, 0, sysctl_emergency_freq, "I", "Emergency Interrupt Poll Frequency");
118 * Sysctl support routines
121 sysctl_emergency_enable(SYSCTL_HANDLER_ARGS)
125 enabled = emergency_intr_enable;
126 error = sysctl_handle_int(oidp, &enabled, 0, req);
127 if (error || req->newptr == NULL)
129 emergency_intr_enable = enabled;
130 if (emergency_intr_enable) {
131 systimer_adjust_periodic(&emergency_intr_timer,
132 emergency_intr_freq);
134 systimer_adjust_periodic(&emergency_intr_timer, 1);
140 sysctl_emergency_freq(SYSCTL_HANDLER_ARGS)
144 phz = emergency_intr_freq;
145 error = sysctl_handle_int(oidp, &phz, 0, req);
146 if (error || req->newptr == NULL)
150 else if (phz > EMERGENCY_INTR_POLLING_FREQ_MAX)
151 phz = EMERGENCY_INTR_POLLING_FREQ_MAX;
153 emergency_intr_freq = phz;
154 if (emergency_intr_enable) {
155 systimer_adjust_periodic(&emergency_intr_timer,
156 emergency_intr_freq);
158 systimer_adjust_periodic(&emergency_intr_timer, 1);
164 * Register an SWI or INTerrupt handler.
167 register_swi(int intr, inthand2_t *handler, void *arg, const char *name,
168 struct lwkt_serialize *serializer)
170 if (intr < FIRST_SOFTINT || intr >= MAX_INTS)
171 panic("register_swi: bad intr %d", intr);
172 return(register_int(intr, handler, arg, name, serializer, 0));
176 register_int(int intr, inthand2_t *handler, void *arg, const char *name,
177 struct lwkt_serialize *serializer, int intr_flags)
179 struct intr_info *info;
180 struct intrec **list;
183 if (intr < 0 || intr >= MAX_INTS)
184 panic("register_int: bad intr %d", intr);
187 info = &intr_info_ary[intr];
190 * Construct an interrupt handler record
192 rec = kmalloc(sizeof(struct intrec), M_DEVBUF, M_INTWAIT);
193 rec->name = kmalloc(strlen(name) + 1, M_DEVBUF, M_INTWAIT);
194 strcpy(rec->name, name);
197 rec->handler = handler;
200 rec->intr_flags = intr_flags;
202 rec->serializer = serializer;
205 * Create an emergency polling thread and set up a systimer to wake
208 if (emergency_intr_thread.td_kstack == NULL) {
209 lwkt_create(ithread_emergency, NULL, NULL,
210 &emergency_intr_thread, TDF_STOPREQ|TDF_INTTHREAD, -1,
212 systimer_init_periodic_nq(&emergency_intr_timer,
213 emergency_intr_timer_callback, &emergency_intr_thread,
214 (emergency_intr_enable ? emergency_intr_freq : 1));
218 * Create an interrupt thread if necessary, leave it in an unscheduled
221 if (info->i_state == ISTATE_NOTHREAD) {
222 info->i_state = ISTATE_NORMAL;
223 lwkt_create((void *)ithread_handler, (void *)intr, NULL,
224 &info->i_thread, TDF_STOPREQ|TDF_INTTHREAD|TDF_MPSAFE, -1,
226 if (intr >= FIRST_SOFTINT)
227 lwkt_setpri(&info->i_thread, TDPRI_SOFT_NORM);
229 lwkt_setpri(&info->i_thread, TDPRI_INT_MED);
230 info->i_thread.td_preemptable = lwkt_preempt;
233 list = &info->i_reclist;
236 * Keep track of how many fast and slow interrupts we have.
237 * Set i_mplock_required if any handler in the chain requires
238 * the MP lock to operate.
240 if ((intr_flags & INTR_MPSAFE) == 0)
241 info->i_mplock_required = 1;
242 if (intr_flags & INTR_FAST)
248 * Enable random number generation keying off of this interrupt.
250 if ((intr_flags & INTR_NOENTROPY) == 0 && info->i_random.sc_enabled == 0) {
251 info->i_random.sc_enabled = 1;
252 info->i_random.sc_intr = intr;
256 * Add the record to the interrupt list.
259 while (*list != NULL)
260 list = &(*list)->next;
265 * Update max_installed_hard_intr to make the emergency intr poll
266 * a bit more efficient.
268 if (intr < FIRST_SOFTINT) {
269 if (max_installed_hard_intr <= intr)
270 max_installed_hard_intr = intr + 1;
272 if (max_installed_soft_intr <= intr)
273 max_installed_soft_intr = intr + 1;
277 * Setup the machine level interrupt vector
279 * XXX temporary workaround for some ACPI brokedness. ACPI installs
280 * its interrupt too early, before the IOAPICs have been configured,
281 * which means the IOAPIC is not enabled by the registration of the
282 * ACPI interrupt. Anything else sharing that IRQ will wind up not
283 * being enabled. Temporarily work around the problem by always
284 * installing and enabling on every new interrupt handler, even
285 * if one has already been setup on that irq.
287 if (intr < FIRST_SOFTINT /* && info->i_slow + info->i_fast == 1*/) {
288 if (machintr_vector_setup(intr, intr_flags))
289 kprintf("machintr_vector_setup: failed on irq %d\n", intr);
296 unregister_swi(void *id)
302 unregister_int(void *id)
304 struct intr_info *info;
305 struct intrec **list;
309 intr = ((intrec_t)id)->intr;
311 if (intr < 0 || intr >= MAX_INTS)
312 panic("register_int: bad intr %d", intr);
314 info = &intr_info_ary[intr];
317 * Remove the interrupt descriptor, adjust the descriptor count,
318 * and teardown the machine level vector if this was the last interrupt.
321 list = &info->i_reclist;
322 while ((rec = *list) != NULL) {
331 if (rec->intr_flags & INTR_FAST)
335 if (intr < FIRST_SOFTINT && info->i_fast + info->i_slow == 0)
336 machintr_vector_teardown(intr);
339 * Clear i_mplock_required if no handlers in the chain require the
342 for (rec0 = info->i_reclist; rec0; rec0 = rec0->next) {
343 if ((rec0->intr_flags & INTR_MPSAFE) == 0)
347 info->i_mplock_required = 0;
356 kfree(rec->name, M_DEVBUF);
357 kfree(rec, M_DEVBUF);
359 kprintf("warning: unregister_int: int %d handler for %s not found\n",
360 intr, ((intrec_t)id)->name);
365 get_registered_name(int intr)
369 if (intr < 0 || intr >= MAX_INTS)
370 panic("register_int: bad intr %d", intr);
372 if ((rec = intr_info_ary[intr].i_reclist) == NULL)
381 count_registered_ints(int intr)
383 struct intr_info *info;
385 if (intr < 0 || intr >= MAX_INTS)
386 panic("register_int: bad intr %d", intr);
387 info = &intr_info_ary[intr];
388 return(info->i_fast + info->i_slow);
392 get_interrupt_counter(int intr)
394 struct intr_info *info;
396 if (intr < 0 || intr >= MAX_INTS)
397 panic("register_int: bad intr %d", intr);
398 info = &intr_info_ary[intr];
399 return(info->i_count);
404 swi_setpriority(int intr, int pri)
406 struct intr_info *info;
408 if (intr < FIRST_SOFTINT || intr >= MAX_INTS)
409 panic("register_swi: bad intr %d", intr);
410 info = &intr_info_ary[intr];
411 if (info->i_state != ISTATE_NOTHREAD)
412 lwkt_setpri(&info->i_thread, pri);
416 register_randintr(int intr)
418 struct intr_info *info;
420 if (intr < 0 || intr >= MAX_INTS)
421 panic("register_randintr: bad intr %d", intr);
422 info = &intr_info_ary[intr];
423 info->i_random.sc_intr = intr;
424 info->i_random.sc_enabled = 1;
428 unregister_randintr(int intr)
430 struct intr_info *info;
432 if (intr < 0 || intr >= MAX_INTS)
433 panic("register_swi: bad intr %d", intr);
434 info = &intr_info_ary[intr];
435 info->i_random.sc_enabled = -1;
439 next_registered_randintr(int intr)
441 struct intr_info *info;
443 if (intr < 0 || intr >= MAX_INTS)
444 panic("register_swi: bad intr %d", intr);
445 while (intr < MAX_INTS) {
446 info = &intr_info_ary[intr];
447 if (info->i_random.sc_enabled > 0)
455 * Dispatch an interrupt. If there's nothing to do we have a stray
456 * interrupt and can just return, leaving the interrupt masked.
458 * We need to schedule the interrupt and set its i_running bit. If
459 * we are not on the interrupt thread's cpu we have to send a message
460 * to the correct cpu that will issue the desired action (interlocking
461 * with the interrupt thread's critical section). We do NOT attempt to
462 * reschedule interrupts whos i_running bit is already set because
463 * this would prematurely wakeup a livelock-limited interrupt thread.
465 * i_running is only tested/set on the same cpu as the interrupt thread.
467 * We are NOT in a critical section, which will allow the scheduled
468 * interrupt to preempt us. The MP lock might *NOT* be held here.
473 sched_ithd_remote(void *arg)
475 sched_ithd((int)arg);
483 struct intr_info *info;
485 info = &intr_info_ary[intr];
488 if (info->i_state != ISTATE_NOTHREAD) {
489 if (info->i_reclist == NULL) {
490 kprintf("sched_ithd: stray interrupt %d on cpu %d\n",
494 if (info->i_thread.td_gd == mycpu) {
495 if (info->i_running == 0) {
497 if (info->i_state != ISTATE_LIVELOCKED)
498 lwkt_schedule(&info->i_thread); /* MIGHT PREEMPT */
501 lwkt_send_ipiq(info->i_thread.td_gd,
502 sched_ithd_remote, (void *)intr);
505 if (info->i_running == 0) {
507 if (info->i_state != ISTATE_LIVELOCKED)
508 lwkt_schedule(&info->i_thread); /* MIGHT PREEMPT */
513 kprintf("sched_ithd: stray interrupt %d on cpu %d\n",
519 * This is run from a periodic SYSTIMER (and thus must be MP safe, the BGL
520 * might not be held).
523 ithread_livelock_wakeup(systimer_t st)
525 struct intr_info *info;
527 info = &intr_info_ary[(int)st->data];
528 if (info->i_state != ISTATE_NOTHREAD)
529 lwkt_schedule(&info->i_thread);
533 * This function is called drectly from the ICU or APIC vector code assembly
534 * to process an interrupt. The critical section and interrupt deferral
535 * checks have already been done but the function is entered WITHOUT
536 * a critical section held. The BGL may or may not be held.
538 * Must return non-zero if we do not want the vector code to re-enable
539 * the interrupt (which we don't if we have to schedule the interrupt)
541 int ithread_fast_handler(struct intrframe *frame);
544 ithread_fast_handler(struct intrframe *frame)
547 struct intr_info *info;
548 struct intrec **list;
553 intrec_t rec, next_rec;
556 intr = frame->if_vec;
559 info = &intr_info_ary[intr];
562 * If we are not processing any FAST interrupts, just schedule the thing.
563 * (since we aren't in a critical section, this can result in a
566 if (info->i_fast == 0) {
572 * This should not normally occur since interrupts ought to be
573 * masked if the ithread has been scheduled or is running.
579 * Bump the interrupt nesting level to process any FAST interrupts.
580 * Obtain the MP lock as necessary. If the MP lock cannot be obtained,
581 * schedule the interrupt thread to deal with the issue instead.
583 * To reduce overhead, just leave the MP lock held once it has been
587 ++gd->gd_intr_nesting_level;
589 must_schedule = info->i_slow;
594 list = &info->i_reclist;
595 for (rec = *list; rec; rec = next_rec) {
596 next_rec = rec->next; /* rec may be invalid after call */
598 if (rec->intr_flags & INTR_FAST) {
600 if ((rec->intr_flags & INTR_MPSAFE) == 0 && got_mplock == 0) {
601 if (try_mplock() == 0) {
605 * If we couldn't get the MP lock try to forward it
606 * to the cpu holding the MP lock, setting must_schedule
607 * to -1 so we do not schedule and also do not unmask
608 * the interrupt. Otherwise just schedule it.
610 owner = owner_mplock();
611 if (owner >= 0 && owner != gd->gd_cpuid) {
612 lwkt_send_ipiq_bycpu(owner, forward_fastint_remote,
615 ++gd->gd_cnt.v_forwarded_ints;
624 if (rec->serializer) {
625 must_schedule += lwkt_serialize_handler_try(
626 rec->serializer, rec->handler,
627 rec->argument, frame);
629 rec->handler(rec->argument, frame);
637 --gd->gd_intr_nesting_level;
645 * If we had a problem, schedule the thread to catch the missed
646 * records (it will just re-run all of them). A return value of 0
647 * indicates that all handlers have been run and the interrupt can
648 * be re-enabled, and a non-zero return indicates that the interrupt
649 * thread controls re-enablement.
651 if (must_schedule > 0)
653 else if (must_schedule == 0)
655 return(must_schedule);
661 /* could not get the MP lock, forward the interrupt */ \
662 movl mp_lock, %eax ; /* check race */ \
663 cmpl $MP_FREE_LOCK,%eax ; \
665 incl PCPU(cnt)+V_FORWARDED_INTS ; \
667 movl $irq_num,8(%esp) ; \
668 movl $forward_fastint_remote,4(%esp) ; \
670 call lwkt_send_ipiq_bycpu ; \
678 * Interrupt threads run this as their main loop.
680 * The handler begins execution outside a critical section and with the BGL
683 * The i_running state starts at 0. When an interrupt occurs, the hardware
684 * interrupt is disabled and sched_ithd() The HW interrupt remains disabled
685 * until all routines have run. We then call ithread_done() to reenable
686 * the HW interrupt and deschedule us until the next interrupt.
688 * We are responsible for atomically checking i_running and ithread_done()
689 * is responsible for atomically checking for platform-specific delayed
690 * interrupts. i_running for our irq is only set in the context of our cpu,
691 * so a critical section is a sufficient interlock.
693 #define LIVELOCK_TIMEFRAME(freq) ((freq) >> 2) /* 1/4 second */
696 ithread_handler(void *arg)
698 struct intr_info *info;
704 struct intrec **list;
707 struct systimer ill_timer; /* enforced freq. timer */
708 u_int ill_count; /* interrupt livelock counter */
714 info = &intr_info_ary[intr];
715 list = &info->i_reclist;
719 * The loop must be entered with one critical section held. The thread
720 * is created with TDF_MPSAFE so the MP lock is not held on start.
727 * The chain is only considered MPSAFE if all its interrupt handlers
728 * are MPSAFE. However, if intr_mpsafe has been turned off we
729 * always operate with the BGL.
732 if (intr_mpsafe == 0) {
737 } else if (info->i_mplock_required != mpheld) {
738 if (info->i_mplock_required) {
739 KKASSERT(mpheld == 0);
743 KKASSERT(mpheld != 0);
751 * If an interrupt is pending, clear i_running and execute the
752 * handlers. Note that certain types of interrupts can re-trigger
753 * and set i_running again.
755 * Each handler is run in a critical section. Note that we run both
756 * FAST and SLOW designated service routines.
758 if (info->i_running) {
762 for (rec = *list; rec; rec = nrec) {
764 if (rec->serializer) {
765 lwkt_serialize_handler_call(rec->serializer, rec->handler,
766 rec->argument, NULL);
768 rec->handler(rec->argument, NULL);
774 * This is our interrupt hook to add rate randomness to the random
777 if (info->i_random.sc_enabled > 0)
778 add_interrupt_randomness(intr);
781 * Unmask the interrupt to allow it to trigger again. This only
782 * applies to certain types of interrupts (typ level interrupts).
783 * This can result in the interrupt retriggering, but the retrigger
784 * will not be processed until we cycle our critical section.
786 * Only unmask interrupts while handlers are installed. It is
787 * possible to hit a situation where no handlers are installed
788 * due to a device driver livelocking and then tearing down its
789 * interrupt on close (the parallel bus being a good example).
792 machintr_intren(intr);
795 * Do a quick exit/enter to catch any higher-priority interrupt
796 * sources, such as the statclock, so thread time accounting
797 * will still work. This may also cause an interrupt to re-trigger.
803 * LIVELOCK STATE MACHINE
805 switch(info->i_state) {
808 * Calculate a running average every tick.
810 if (lticks != ticks) {
812 ill_count -= ill_count / hz;
816 * If we did not exceed the frequency limit, we are done.
817 * If the interrupt has not retriggered we deschedule ourselves.
819 if (ill_count <= livelock_limit) {
820 if (info->i_running == 0) {
821 lwkt_deschedule_self(gd->gd_curthread);
828 * Otherwise we are livelocked. Set up a periodic systimer
829 * to wake the thread up at the limit frequency.
831 kprintf("intr %d at %d > %d hz, livelocked limit engaged!\n",
832 intr, ill_count, livelock_limit);
833 info->i_state = ISTATE_LIVELOCKED;
834 if ((use_limit = livelock_limit) < 100)
836 else if (use_limit > 500000)
838 systimer_init_periodic(&ill_timer, ithread_livelock_wakeup,
839 (void *)intr, use_limit);
842 case ISTATE_LIVELOCKED:
844 * Wait for our periodic timer to go off. Since the interrupt
845 * has re-armed it can still set i_running, but it will not
846 * reschedule us while we are in a livelocked state.
848 lwkt_deschedule_self(gd->gd_curthread);
852 * Check to see if the livelock condition no longer applies.
853 * The interrupt must be able to operate normally for one
854 * full second before we restore normal operation.
856 if (lticks != ticks) {
858 if (ill_count < livelock_lowater) {
859 if (++lcount >= hz) {
860 info->i_state = ISTATE_NORMAL;
861 systimer_del(&ill_timer);
862 kprintf("intr %d at %d < %d hz, livelock removed\n",
863 intr, ill_count, livelock_lowater);
868 ill_count -= ill_count / hz;
877 * Emergency interrupt polling thread. The thread begins execution
878 * outside a critical section with the BGL held.
880 * If emergency interrupt polling is enabled, this thread will
881 * execute all system interrupts not marked INTR_NOPOLL at the
882 * specified polling frequency.
884 * WARNING! This thread runs *ALL* interrupt service routines that
885 * are not marked INTR_NOPOLL, which basically means everything except
886 * the 8254 clock interrupt and the ATA interrupt. It has very high
887 * overhead and should only be used in situations where the machine
888 * cannot otherwise be made to work. Due to the severe performance
889 * degredation, it should not be enabled on production machines.
892 ithread_emergency(void *arg __unused)
894 struct intr_info *info;
899 for (intr = 0; intr < max_installed_hard_intr; ++intr) {
900 info = &intr_info_ary[intr];
901 for (rec = info->i_reclist; rec; rec = nrec) {
902 if ((rec->intr_flags & INTR_NOPOLL) == 0) {
903 if (rec->serializer) {
904 lwkt_serialize_handler_call(rec->serializer,
905 rec->handler, rec->argument, NULL);
907 rec->handler(rec->argument, NULL);
913 lwkt_deschedule_self(curthread);
919 * Systimer callback - schedule the emergency interrupt poll thread
920 * if emergency polling is enabled.
924 emergency_intr_timer_callback(systimer_t info, struct intrframe *frame __unused)
926 if (emergency_intr_enable)
927 lwkt_schedule(info->data);
931 * Sysctls used by systat and others: hw.intrnames and hw.intrcnt.
932 * The data for this machine dependent, and the declarations are in machine
933 * dependent code. The layout of intrnames and intrcnt however is machine
936 * We do not know the length of intrcnt and intrnames at compile time, so
937 * calculate things at run time.
941 sysctl_intrnames(SYSCTL_HANDLER_ARGS)
943 struct intr_info *info;
950 for (intr = 0; error == 0 && intr < MAX_INTS; ++intr) {
951 info = &intr_info_ary[intr];
955 for (rec = info->i_reclist; rec; rec = rec->next) {
956 ksnprintf(buf + len, sizeof(buf) - len, "%s%s",
957 (len ? "/" : ""), rec->name);
958 len += strlen(buf + len);
961 ksnprintf(buf, sizeof(buf), "irq%d", intr);
964 error = SYSCTL_OUT(req, buf, len + 1);
970 SYSCTL_PROC(_hw, OID_AUTO, intrnames, CTLTYPE_OPAQUE | CTLFLAG_RD,
971 NULL, 0, sysctl_intrnames, "", "Interrupt Names");
974 sysctl_intrcnt(SYSCTL_HANDLER_ARGS)
976 struct intr_info *info;
980 for (intr = 0; intr < max_installed_hard_intr; ++intr) {
981 info = &intr_info_ary[intr];
983 error = SYSCTL_OUT(req, &info->i_count, sizeof(info->i_count));
987 for (intr = FIRST_SOFTINT; intr < max_installed_soft_intr; ++intr) {
988 info = &intr_info_ary[intr];
990 error = SYSCTL_OUT(req, &info->i_count, sizeof(info->i_count));
998 SYSCTL_PROC(_hw, OID_AUTO, intrcnt, CTLTYPE_OPAQUE | CTLFLAG_RD,
999 NULL, 0, sysctl_intrcnt, "", "Interrupt Counts");