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