intr.h revision 1.5 1 1.5 matt /* $NetBSD: intr.h,v 1.5 2003/09/03 21:33:33 matt Exp $ */
2 1.2 thorpej
3 1.2 thorpej /*
4 1.2 thorpej * Copyright 2001 Wasabi Systems, Inc.
5 1.2 thorpej * All rights reserved.
6 1.2 thorpej *
7 1.2 thorpej * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 1.2 thorpej *
9 1.2 thorpej * Redistribution and use in source and binary forms, with or without
10 1.2 thorpej * modification, are permitted provided that the following conditions
11 1.2 thorpej * are met:
12 1.2 thorpej * 1. Redistributions of source code must retain the above copyright
13 1.2 thorpej * notice, this list of conditions and the following disclaimer.
14 1.2 thorpej * 2. Redistributions in binary form must reproduce the above copyright
15 1.2 thorpej * notice, this list of conditions and the following disclaimer in the
16 1.2 thorpej * documentation and/or other materials provided with the distribution.
17 1.2 thorpej * 3. All advertising materials mentioning features or use of this software
18 1.2 thorpej * must display the following acknowledgement:
19 1.2 thorpej * This product includes software developed for the NetBSD Project by
20 1.2 thorpej * Wasabi Systems, Inc.
21 1.2 thorpej * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 1.2 thorpej * or promote products derived from this software without specific prior
23 1.2 thorpej * written permission.
24 1.2 thorpej *
25 1.2 thorpej * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 1.2 thorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.2 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.2 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 1.2 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.2 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.2 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.2 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.2 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.2 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.2 thorpej * POSSIBILITY OF SUCH DAMAGE.
36 1.2 thorpej */
37 1.1 matt
38 1.1 matt /*
39 1.1 matt * Copyright (C) 1995-1997 Wolfgang Solfrank.
40 1.1 matt * Copyright (C) 1995-1997 TooLs GmbH.
41 1.1 matt * All rights reserved.
42 1.1 matt *
43 1.1 matt * Redistribution and use in source and binary forms, with or without
44 1.1 matt * modification, are permitted provided that the following conditions
45 1.1 matt * are met:
46 1.1 matt * 1. Redistributions of source code must retain the above copyright
47 1.1 matt * notice, this list of conditions and the following disclaimer.
48 1.1 matt * 2. Redistributions in binary form must reproduce the above copyright
49 1.1 matt * notice, this list of conditions and the following disclaimer in the
50 1.1 matt * documentation and/or other materials provided with the distribution.
51 1.1 matt * 3. All advertising materials mentioning features or use of this software
52 1.1 matt * must display the following acknowledgement:
53 1.1 matt * This product includes software developed by TooLs GmbH.
54 1.1 matt * 4. The name of TooLs GmbH may not be used to endorse or promote products
55 1.1 matt * derived from this software without specific prior written permission.
56 1.1 matt *
57 1.1 matt * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
58 1.1 matt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
59 1.1 matt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
60 1.1 matt * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61 1.1 matt * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
62 1.1 matt * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
63 1.1 matt * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
64 1.1 matt * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
65 1.1 matt * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
66 1.1 matt * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67 1.1 matt */
68 1.2 thorpej
69 1.1 matt #ifndef _MACHINE_INTR_H_
70 1.1 matt #define _MACHINE_INTR_H_
71 1.1 matt
72 1.2 thorpej /* Interrupt priority "levels". */
73 1.2 thorpej #define IPL_NONE 0 /* nothing */
74 1.2 thorpej #define IPL_SOFT 1 /* generic software interrupts */
75 1.2 thorpej #define IPL_SOFTCLOCK 2 /* software clock interrupt */
76 1.2 thorpej #define IPL_SOFTNET 3 /* software network interrupt */
77 1.2 thorpej #define IPL_BIO 4 /* block I/O */
78 1.2 thorpej #define IPL_NET 5 /* network */
79 1.2 thorpej #define IPL_SOFTSERIAL 6 /* software serial interrupt */
80 1.2 thorpej #define IPL_TTY 7 /* terminals */
81 1.4 thorpej #define IPL_VM 8 /* memory allocation */
82 1.2 thorpej #define IPL_AUDIO 9 /* audio device */
83 1.2 thorpej #define IPL_CLOCK 10 /* clock interrupt */
84 1.2 thorpej #define IPL_HIGH 11 /* everything */
85 1.2 thorpej #define IPL_SERIAL 12 /* serial device */
86 1.2 thorpej
87 1.2 thorpej #define NIPL 13
88 1.2 thorpej
89 1.2 thorpej /* Interrupt sharing types. */
90 1.2 thorpej #define IST_NONE 0 /* none */
91 1.2 thorpej #define IST_PULSE 1 /* pulsed */
92 1.2 thorpej #define IST_EDGE 2 /* edge-triggered */
93 1.2 thorpej #define IST_LEVEL 3 /* level-triggered */
94 1.2 thorpej
95 1.2 thorpej #ifdef _KERNEL
96 1.2 thorpej #ifndef _LOCORE
97 1.5 matt #define CLKF_BASEPRI(frame) ((frame)->pri == IPL_NONE)
98 1.2 thorpej
99 1.2 thorpej struct clockframe;
100 1.2 thorpej
101 1.3 chs extern int imask[];
102 1.3 chs
103 1.1 matt struct machvec {
104 1.2 thorpej int (*mvec_splraise)(int);
105 1.2 thorpej int (*mvec_spllower)(int);
106 1.2 thorpej void (*mvec_splx)(int);
107 1.2 thorpej void (*mvec_setsoft)(int);
108 1.2 thorpej void (*mvec_clock_return)(struct clockframe *, int);
109 1.2 thorpej void *(*mvec_intr_establish)(int, int, int, int (*)(void *), void *);
110 1.2 thorpej void (*mvec_intr_disestablish)(void *);
111 1.1 matt };
112 1.1 matt
113 1.1 matt extern struct machvec machine_interface;
114 1.1 matt
115 1.2 thorpej #define _splraise(x) ((*machine_interface.mvec_splraise)(x))
116 1.2 thorpej #define _spllower(x) ((*machine_interface.mvec_spllower)(x))
117 1.2 thorpej #define splx(x) ((*machine_interface.mvec_splx)(x))
118 1.2 thorpej #define setsoftintr(x) ((*machine_interface.mvec_setsoft)(x))
119 1.2 thorpej #define clock_return(x, y) ((*machine_interface.mvec_clock_return)(x, y))
120 1.2 thorpej #define intr_establish(irq, lvl, ist, func, arg) \
121 1.2 thorpej ((*machine_interface.mvec_intr_establish)((irq), (lvl), (ist), \
122 1.2 thorpej (func), (arg)))
123 1.2 thorpej #define intr_disestablish(cookie) \
124 1.2 thorpej ((*machine_interface.mvec_intr_disestablish)((cookie)))
125 1.2 thorpej
126 1.3 chs #define splhigh() _splraise(imask[IPL_HIGH])
127 1.3 chs #define splsoft() _splraise(imask[IPL_SOFT])
128 1.3 chs #define splsoftclock() _splraise(imask[IPL_SOFTCLOCK])
129 1.3 chs #define splsoftnet() _splraise(imask[IPL_SOFTNET])
130 1.3 chs #define splbio() _splraise(imask[IPL_BIO])
131 1.3 chs #define splnet() _splraise(imask[IPL_NET])
132 1.3 chs #define spltty() _splraise(imask[IPL_TTY])
133 1.4 thorpej #define splvm() _splraise(imask[IPL_VM])
134 1.3 chs #define splaudio() _splraise(imask[IPL_AUDIO])
135 1.3 chs #define splclock() _splraise(imask[IPL_CLOCK])
136 1.3 chs #define splserial() _splraise(imask[IPL_SERIAL])
137 1.1 matt
138 1.1 matt #define splstatclock() splclock()
139 1.2 thorpej
140 1.3 chs #define spl0() _spllower(imask[IPL_NONE])
141 1.3 chs #define spllowersoftclock() _spllower(imask[IPL_SOFTCLOCK])
142 1.1 matt
143 1.1 matt #define splsched() splhigh()
144 1.1 matt #define spllock() splhigh()
145 1.2 thorpej
146 1.2 thorpej #define setsoftnet() setsoftintr(IPL_SOFTNET)
147 1.2 thorpej #define setsoftclock() setsoftintr(IPL_SOFTCLOCK)
148 1.2 thorpej
149 1.2 thorpej /*
150 1.2 thorpej * Software interrupt support.
151 1.2 thorpej */
152 1.2 thorpej
153 1.2 thorpej #define SI_SOFT 0 /* for IPL_SOFT */
154 1.2 thorpej #define SI_SOFTCLOCK 1 /* for IPL_SOFTCLOCK */
155 1.2 thorpej #define SI_SOFTNET 2 /* for IPL_SOFTNET */
156 1.2 thorpej #define SI_SOFTSERIAL 3 /* for IPL_SOFTSERIAL */
157 1.2 thorpej
158 1.2 thorpej #define SI_NQUEUES 4
159 1.2 thorpej
160 1.2 thorpej #define SI_QUEUENAMES { \
161 1.2 thorpej "generic", \
162 1.2 thorpej "clock", \
163 1.2 thorpej "net", \
164 1.2 thorpej "serial", \
165 1.2 thorpej }
166 1.2 thorpej
167 1.2 thorpej #endif /* _LOCORE */
168 1.2 thorpej #endif /* _KERNEL */
169 1.1 matt
170 1.1 matt #endif /* _MACHINE_INTR_H_ */
171