]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/i386/isa/intr_machdep.c
This commit was generated by cvs2svn to compensate for changes in r76589,
[FreeBSD/FreeBSD.git] / sys / i386 / isa / intr_machdep.c
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
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *      This product includes software developed by the University of
19  *      California, Berkeley and its contributors.
20  * 4. Neither the name of the University nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
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$
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> 
46 #include <sys/errno.h>
47 #include <sys/interrupt.h>
48 #include <sys/ipl.h>
49 #include <sys/kernel.h>
50 #include <sys/kthread.h>
51 #include <sys/lock.h>
52 #include <sys/malloc.h>
53 #include <sys/module.h>
54 #include <sys/mutex.h>
55 #include <sys/proc.h>
56 #include <sys/syslog.h>
57 #include <sys/systm.h>
58 #include <sys/unistd.h>
59
60 #include <machine/md_var.h>
61 #include <machine/segments.h>
62 #include <machine/intrcnt.h>
63
64 #if defined(APIC_IO)
65 #include <machine/smptests.h>                   /** FAST_HI */
66 #include <machine/smp.h>
67 #include <machine/resource.h>
68 #endif /* APIC_IO */
69 #ifdef PC98
70 #include <pc98/pc98/pc98.h>
71 #include <pc98/pc98/pc98_machdep.h>
72 #include <pc98/pc98/epsonio.h>
73 #else
74 #include <i386/isa/isa.h>
75 #endif
76 #include <i386/isa/icu.h>
77
78 #ifdef DEV_ISA
79 #include <isa/isavar.h>
80 #endif
81 #include <i386/isa/intr_machdep.h>
82 #include <sys/interrupt.h>
83 #ifdef APIC_IO
84 #include <machine/clock.h>
85 #endif
86
87 #ifdef DEV_MCA
88 #include <i386/isa/mca_machdep.h>
89 #endif
90
91 /*
92  * Per-interrupt data.
93  */
94 u_long  *intr_countp[ICU_LEN];          /* pointers to interrupt counters */
95 driver_intr_t   *intr_handler[ICU_LEN]; /* first level interrupt handler */
96 struct   ithd *ithds[ICU_LEN];          /* real interrupt handler */
97 void    *intr_unit[ICU_LEN];
98
99 static struct   mtx ithds_table_lock;   /* protect the ithds table */
100
101 static inthand_t *fastintr[ICU_LEN] = {
102         &IDTVEC(fastintr0), &IDTVEC(fastintr1),
103         &IDTVEC(fastintr2), &IDTVEC(fastintr3),
104         &IDTVEC(fastintr4), &IDTVEC(fastintr5),
105         &IDTVEC(fastintr6), &IDTVEC(fastintr7),
106         &IDTVEC(fastintr8), &IDTVEC(fastintr9),
107         &IDTVEC(fastintr10), &IDTVEC(fastintr11),
108         &IDTVEC(fastintr12), &IDTVEC(fastintr13),
109         &IDTVEC(fastintr14), &IDTVEC(fastintr15),
110 #if defined(APIC_IO)
111         &IDTVEC(fastintr16), &IDTVEC(fastintr17),
112         &IDTVEC(fastintr18), &IDTVEC(fastintr19),
113         &IDTVEC(fastintr20), &IDTVEC(fastintr21),
114         &IDTVEC(fastintr22), &IDTVEC(fastintr23),
115         &IDTVEC(fastintr24), &IDTVEC(fastintr25),
116         &IDTVEC(fastintr26), &IDTVEC(fastintr27),
117         &IDTVEC(fastintr28), &IDTVEC(fastintr29),
118         &IDTVEC(fastintr30), &IDTVEC(fastintr31),
119 #endif /* APIC_IO */
120 };
121
122 static inthand_t *slowintr[ICU_LEN] = {
123         &IDTVEC(intr0), &IDTVEC(intr1), &IDTVEC(intr2), &IDTVEC(intr3),
124         &IDTVEC(intr4), &IDTVEC(intr5), &IDTVEC(intr6), &IDTVEC(intr7),
125         &IDTVEC(intr8), &IDTVEC(intr9), &IDTVEC(intr10), &IDTVEC(intr11),
126         &IDTVEC(intr12), &IDTVEC(intr13), &IDTVEC(intr14), &IDTVEC(intr15),
127 #if defined(APIC_IO)
128         &IDTVEC(intr16), &IDTVEC(intr17), &IDTVEC(intr18), &IDTVEC(intr19),
129         &IDTVEC(intr20), &IDTVEC(intr21), &IDTVEC(intr22), &IDTVEC(intr23),
130         &IDTVEC(intr24), &IDTVEC(intr25), &IDTVEC(intr26), &IDTVEC(intr27),
131         &IDTVEC(intr28), &IDTVEC(intr29), &IDTVEC(intr30), &IDTVEC(intr31),
132 #endif /* APIC_IO */
133 };
134
135 static driver_intr_t isa_strayintr;
136
137 static void     ithds_init(void *dummy);
138 static void     ithread_enable(int vector);
139 static void     ithread_disable(int vector);
140
141 #ifdef PC98
142 #define NMI_PARITY 0x04
143 #define NMI_EPARITY 0x02
144 #else
145 #define NMI_PARITY (1 << 7)
146 #define NMI_IOCHAN (1 << 6)
147 #define ENMI_WATCHDOG (1 << 7)
148 #define ENMI_BUSTIMER (1 << 6)
149 #define ENMI_IOSTATUS (1 << 5)
150 #endif
151
152 /*
153  * Bus attachment for the ISA PIC.
154  */
155 static struct isa_pnp_id atpic_ids[] = {
156         { 0x0000d041 /* PNP0000 */, "AT interrupt controller" },
157         { 0 }
158 };
159
160 static int
161 atpic_probe(device_t dev)
162 {
163         int result;
164         
165         if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, atpic_ids)) <= 0)
166                 device_quiet(dev);
167         return(result);
168 }
169
170 /*
171  * In the APIC_IO case we might be granted IRQ 2, as this is typically
172  * consumed by chaining between the two PIC components.  If we're using
173  * the APIC, however, this may not be the case, and as such we should
174  * free the resource.  (XXX untested)
175  *
176  * The generic ISA attachment code will handle allocating any other resources
177  * that we don't explicitly claim here.
178  */
179 static int
180 atpic_attach(device_t dev)
181 {
182 #ifdef APIC_IO
183         int             rid;
184         struct resource *res;
185
186         /* try to allocate our IRQ and then free it */
187         rid = 0;
188         res = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, 0);
189         if (res != NULL)
190                 bus_release_resource(dev, SYS_RES_IRQ, rid, res);
191 #endif
192         return(0);
193 }
194
195 static device_method_t atpic_methods[] = {
196         /* Device interface */
197         DEVMETHOD(device_probe,         atpic_probe),
198         DEVMETHOD(device_attach,        atpic_attach),
199         DEVMETHOD(device_detach,        bus_generic_detach),
200         DEVMETHOD(device_shutdown,      bus_generic_shutdown),
201         DEVMETHOD(device_suspend,       bus_generic_suspend),
202         DEVMETHOD(device_resume,        bus_generic_resume),
203         { 0, 0 }
204 };
205
206 static driver_t atpic_driver = {
207         "atpic",
208         atpic_methods,
209         1,              /* no softc */
210 };
211
212 static devclass_t atpic_devclass;
213
214 DRIVER_MODULE(atpic, isa, atpic_driver, atpic_devclass, 0, 0);
215
216 /*
217  * Handle a NMI, possibly a machine check.
218  * return true to panic system, false to ignore.
219  */
220 int
221 isa_nmi(cd)
222         int cd;
223 {
224         int retval = 0;
225 #ifdef PC98
226         int port = inb(0x33);
227
228         log(LOG_CRIT, "NMI PC98 port = %x\n", port);
229         if (epson_machine_id == 0x20)
230                 epson_outb(0xc16, epson_inb(0xc16) | 0x1);
231         if (port & NMI_PARITY) {
232                 log(LOG_CRIT, "BASE RAM parity error, likely hardware failure.");
233                 retval = 1;
234         } else if (port & NMI_EPARITY) {
235                 log(LOG_CRIT, "EXTENDED RAM parity error, likely hardware failure.");
236                 retval = 1;
237         } else {
238                 log(LOG_CRIT, "\nNMI Resume ??\n");
239         }
240 #else /* IBM-PC */
241         int isa_port = inb(0x61);
242         int eisa_port = inb(0x461);
243
244         log(LOG_CRIT, "NMI ISA %x, EISA %x\n", isa_port, eisa_port);
245 #ifdef DEV_MCA
246         if (MCA_system && mca_bus_nmi())
247                 return(0);
248 #endif
249         
250         if (isa_port & NMI_PARITY) {
251                 log(LOG_CRIT, "RAM parity error, likely hardware failure.");
252                 retval = 1;
253         }
254
255         if (isa_port & NMI_IOCHAN) {
256                 log(LOG_CRIT, "I/O channel check, likely hardware failure.");
257                 retval = 1;
258         }
259
260         /*
261          * On a real EISA machine, this will never happen.  However it can
262          * happen on ISA machines which implement XT style floating point
263          * error handling (very rare).  Save them from a meaningless panic.
264          */
265         if (eisa_port == 0xff)
266                 return(retval);
267
268         if (eisa_port & ENMI_WATCHDOG) {
269                 log(LOG_CRIT, "EISA watchdog timer expired, likely hardware failure.");
270                 retval = 1;
271         }
272
273         if (eisa_port & ENMI_BUSTIMER) {
274                 log(LOG_CRIT, "EISA bus timeout, likely hardware failure.");
275                 retval = 1;
276         }
277
278         if (eisa_port & ENMI_IOSTATUS) {
279                 log(LOG_CRIT, "EISA I/O port status error.");
280                 retval = 1;
281         }
282 #endif
283         return(retval);
284 }
285
286 /*
287  * Create a default interrupt table to avoid problems caused by
288  * spurious interrupts during configuration of kernel, then setup
289  * interrupt control unit.
290  */
291 void
292 isa_defaultirq()
293 {
294         int i;
295
296         /* icu vectors */
297         for (i = 0; i < ICU_LEN; i++)
298                 icu_unset(i, (driver_intr_t *)NULL);
299
300         /* initialize 8259's */
301 #ifdef DEV_MCA
302         if (MCA_system)
303                 outb(IO_ICU1, 0x19);            /* reset; program device, four bytes */
304         else
305 #endif
306                 outb(IO_ICU1, 0x11);            /* reset; program device, four bytes */
307
308         outb(IO_ICU1+ICU_IMR_OFFSET, NRSVIDT);  /* starting at this vector index */
309         outb(IO_ICU1+ICU_IMR_OFFSET, IRQ_SLAVE);                /* slave on line 7 */
310 #ifdef PC98
311 #ifdef AUTO_EOI_1
312         outb(IO_ICU1+ICU_IMR_OFFSET, 0x1f);             /* (master) auto EOI, 8086 mode */
313 #else
314         outb(IO_ICU1+ICU_IMR_OFFSET, 0x1d);             /* (master) 8086 mode */
315 #endif
316 #else /* IBM-PC */
317 #ifdef AUTO_EOI_1
318         outb(IO_ICU1+ICU_IMR_OFFSET, 2 | 1);            /* auto EOI, 8086 mode */
319 #else
320         outb(IO_ICU1+ICU_IMR_OFFSET, 1);                /* 8086 mode */
321 #endif
322 #endif /* PC98 */
323         outb(IO_ICU1+ICU_IMR_OFFSET, 0xff);             /* leave interrupts masked */
324         outb(IO_ICU1, 0x0a);            /* default to IRR on read */
325 #ifndef PC98
326         outb(IO_ICU1, 0xc0 | (3 - 1));  /* pri order 3-7, 0-2 (com2 first) */
327 #endif /* !PC98 */
328
329 #ifdef DEV_MCA
330         if (MCA_system)
331                 outb(IO_ICU2, 0x19);            /* reset; program device, four bytes */
332         else
333 #endif
334                 outb(IO_ICU2, 0x11);            /* reset; program device, four bytes */
335
336         outb(IO_ICU2+ICU_IMR_OFFSET, NRSVIDT+8); /* staring at this vector index */
337         outb(IO_ICU2+ICU_IMR_OFFSET, ICU_SLAVEID);         /* my slave id is 7 */
338 #ifdef PC98
339         outb(IO_ICU2+ICU_IMR_OFFSET,9);              /* 8086 mode */
340 #else /* IBM-PC */
341 #ifdef AUTO_EOI_2
342         outb(IO_ICU2+ICU_IMR_OFFSET, 2 | 1);            /* auto EOI, 8086 mode */
343 #else
344         outb(IO_ICU2+ICU_IMR_OFFSET,1);         /* 8086 mode */
345 #endif
346 #endif /* PC98 */
347         outb(IO_ICU2+ICU_IMR_OFFSET, 0xff);          /* leave interrupts masked */
348         outb(IO_ICU2, 0x0a);            /* default to IRR on read */
349 }
350
351 /*
352  * Caught a stray interrupt, notify
353  */
354 static void
355 isa_strayintr(vcookiep)
356         void *vcookiep;
357 {
358         int intr = (void **)vcookiep - &intr_unit[0];
359
360         /*
361          * XXX TODO print a different message for #7 if it is for a
362          * glitch.  Glitches can be distinguished from real #7's by
363          * testing that the in-service bit is _not_ set.  The test
364          * must be done before sending an EOI so it can't be done if
365          * we are using AUTO_EOI_1.
366          */
367         if (intrcnt[1 + intr] <= 5)
368                 log(LOG_ERR, "stray irq %d\n", intr);
369         if (intrcnt[1 + intr] == 5)
370                 log(LOG_CRIT,
371                     "too many stray irq %d's; not logging any more\n", intr);
372 }
373
374 #ifdef DEV_ISA
375 /*
376  * Return a bitmap of the current interrupt requests.  This is 8259-specific
377  * and is only suitable for use at probe time.
378  */
379 intrmask_t
380 isa_irq_pending()
381 {
382         u_char irr1;
383         u_char irr2;
384
385         irr1 = inb(IO_ICU1);
386         irr2 = inb(IO_ICU2);
387         return ((irr2 << 8) | irr1);
388 }
389 #endif
390
391 /*
392  * Update intrnames array with the specified name.  This is used by
393  * vmstat(8) and the like.
394  */
395 static void
396 update_intrname(int intr, const char *name)
397 {
398         char buf[32];
399         char *cp;
400         int name_index, off, strayintr;
401
402         /*
403          * Initialise strings for bitbucket and stray interrupt counters.
404          * These have statically allocated indices 0 and 1 through ICU_LEN.
405          */
406         if (intrnames[0] == '\0') {
407                 off = sprintf(intrnames, "???") + 1;
408                 for (strayintr = 0; strayintr < ICU_LEN; strayintr++)
409                         off += sprintf(intrnames + off, "stray irq%d",
410                             strayintr) + 1;
411         }
412
413         if (name == NULL)
414                 name = "???";
415         if (snprintf(buf, sizeof(buf), "%s irq%d", name, intr) >= sizeof(buf))
416                 goto use_bitbucket;
417
418         /*
419          * Search for `buf' in `intrnames'.  In the usual case when it is
420          * not found, append it to the end if there is enough space (the \0
421          * terminator for the previous string, if any, becomes a separator).
422          */
423         for (cp = intrnames, name_index = 0;
424             cp != eintrnames && name_index < NR_INTRNAMES;
425             cp += strlen(cp) + 1, name_index++) {
426                 if (*cp == '\0') {
427                         if (strlen(buf) >= eintrnames - cp)
428                                 break;
429                         strcpy(cp, buf);
430                         goto found;
431                 }
432                 if (strcmp(cp, buf) == 0)
433                         goto found;
434         }
435
436 use_bitbucket:
437         printf("update_intrname: counting %s irq%d as %s\n", name, intr,
438             intrnames);
439         name_index = 0;
440 found:
441         intr_countp[intr] = &intrcnt[name_index];
442 }
443
444 int
445 icu_setup(int intr, driver_intr_t *handler, void *arg, int flags)
446 {
447 #ifdef FAST_HI
448         int             select;         /* the select register is 8 bits */
449         int             vector;
450         u_int32_t       value;          /* the window register is 32 bits */
451 #endif /* FAST_HI */
452         u_long  ef;
453
454 #if defined(APIC_IO)
455         if ((u_int)intr >= ICU_LEN)     /* no 8259 SLAVE to ignore */
456 #else
457         if ((u_int)intr >= ICU_LEN || intr == ICU_SLAVEID)
458 #endif /* APIC_IO */
459         if (intr_handler[intr] != isa_strayintr)
460                 return (EBUSY);
461
462         ef = read_eflags();
463         disable_intr();
464         intr_handler[intr] = handler;
465         intr_unit[intr] = arg;
466 #ifdef FAST_HI
467         if (flags & INTR_FAST) {
468                 vector = TPR_FAST_INTS + intr;
469                 setidt(vector, fastintr[intr],
470                        SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
471         }
472         else {
473                 vector = TPR_SLOW_INTS + intr;
474 #ifdef APIC_INTR_REORDER
475 #ifdef APIC_INTR_HIGHPRI_CLOCK
476                 /* XXX: Hack (kludge?) for more accurate clock. */
477                 if (intr == apic_8254_intr || intr == 8) {
478                         vector = TPR_FAST_INTS + intr;
479                 }
480 #endif
481 #endif
482                 setidt(vector, slowintr[intr],
483                        SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
484         }
485 #ifdef APIC_INTR_REORDER
486         set_lapic_isrloc(intr, vector);
487 #endif
488         /*
489          * Reprogram the vector in the IO APIC.
490          */
491         if (int_to_apicintpin[intr].ioapic >= 0) {
492                 select = int_to_apicintpin[intr].redirindex;
493                 value = io_apic_read(int_to_apicintpin[intr].ioapic, 
494                                      select) & ~IOART_INTVEC;
495                 io_apic_write(int_to_apicintpin[intr].ioapic, 
496                               select, value | vector);
497         }
498 #else
499         setidt(ICU_OFFSET + intr,
500                flags & INTR_FAST ? fastintr[intr] : slowintr[intr],
501                SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
502 #endif /* FAST_HI */
503         INTREN(1 << intr);
504         write_eflags(ef);
505         return (0);
506 }
507
508 /*
509  * Dissociate an interrupt handler from an IRQ and set the handler to
510  * the stray interrupt handler.  The 'handler' parameter is used only
511  * for consistency checking.
512  */
513 int
514 icu_unset(intr, handler)
515         int     intr;
516         driver_intr_t *handler;
517 {
518         u_long  ef;
519
520         if ((u_int)intr >= ICU_LEN || handler != intr_handler[intr])
521                 return (EINVAL);
522
523         INTRDIS(1 << intr);
524         ef = read_eflags();
525         disable_intr();
526         intr_countp[intr] = &intrcnt[1 + intr];
527         intr_handler[intr] = isa_strayintr;
528         intr_unit[intr] = &intr_unit[intr];
529 #ifdef FAST_HI_XXX
530         /* XXX how do I re-create dvp here? */
531         setidt(flags & INTR_FAST ? TPR_FAST_INTS + intr : TPR_SLOW_INTS + intr,
532             slowintr[intr], SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
533 #else /* FAST_HI */
534 #ifdef APIC_INTR_REORDER
535         set_lapic_isrloc(intr, ICU_OFFSET + intr);
536 #endif
537         setidt(ICU_OFFSET + intr, slowintr[intr], SDT_SYS386IGT, SEL_KPL,
538             GSEL(GCODE_SEL, SEL_KPL));
539 #endif /* FAST_HI */
540         write_eflags(ef);
541         return (0);
542 }
543
544 static void
545 ithds_init(void *dummy)
546 {
547
548         mtx_init(&ithds_table_lock, "ithread table lock", MTX_SPIN);
549 }
550 SYSINIT(ithds_init, SI_SUB_INTR, SI_ORDER_SECOND, ithds_init, NULL);
551
552 static void
553 ithread_enable(int vector)
554 {
555
556         INTREN(1 << vector);
557 }
558
559 static void
560 ithread_disable(int vector)
561 {
562
563         INTRDIS(1 << vector);
564 }
565
566 int
567 inthand_add(const char *name, int irq, driver_intr_t handler, void *arg,
568     enum intr_type flags, void **cookiep)
569 {
570         struct ithd *ithd;              /* descriptor for the IRQ */
571         int errcode = 0;
572         int created_ithd = 0;
573
574         /*
575          * Work around a race where more than one CPU may be registering
576          * handlers on the same IRQ at the same time.
577          */
578         mtx_lock_spin(&ithds_table_lock);
579         ithd = ithds[irq];
580         mtx_unlock_spin(&ithds_table_lock);
581         if (ithd == NULL) {
582                 errcode = ithread_create(&ithd, irq, 0, ithread_disable,
583                     ithread_enable, "irq%d:", irq);
584                 if (errcode)
585                         return (errcode);
586                 mtx_lock_spin(&ithds_table_lock);
587                 if (ithds[irq] == NULL) {
588                         ithds[irq] = ithd;
589                         created_ithd++;
590                         mtx_unlock_spin(&ithds_table_lock);
591                 } else {
592                         struct ithd *orphan;
593
594                         orphan = ithd;
595                         ithd = ithds[irq];
596                         mtx_unlock_spin(&ithds_table_lock);
597                         ithread_destroy(orphan);
598                 }
599         }
600
601         errcode = ithread_add_handler(ithd, name, handler, arg,
602             ithread_priority(flags), flags, cookiep);
603         
604         if ((flags & INTR_FAST) == 0 || errcode)
605                 /*
606                  * The interrupt process must be in place, but
607                  * not necessarily schedulable, before we
608                  * initialize the ICU, since it may cause an
609                  * immediate interrupt.
610                  */
611                 if (icu_setup(irq, &sched_ithd, arg, flags) != 0)
612                         panic("inthand_add: Can't initialize ICU");
613
614         if (errcode)
615                 return (errcode);
616         
617         if (flags & INTR_FAST) {
618                 errcode = icu_setup(irq, handler, arg, flags);
619                 if (errcode && bootverbose)
620                         printf("\tinthand_add(irq%d) failed, result=%d\n", 
621                                irq, errcode);
622                 if (errcode)
623                         return (errcode);
624         }
625
626         update_intrname(irq, name);
627         return (0);
628 }
629
630 /*
631  * Deactivate and remove linked list the interrupt handler descriptor
632  * data connected created by an earlier call of inthand_add(), then
633  * adjust the interrupt masks if necessary.
634  *
635  * Return the memory held by the interrupt handler descriptor data
636  * structure to the system.  First ensure the handler is not actively
637  * in use.
638  */
639 int
640 inthand_remove(void *cookie)
641 {
642
643         return (ithread_remove_handler(cookie));
644 }