intr.h revision 1.44 1 1.44 thorpej /* $NetBSD: intr.h,v 1.44 2001/04/15 23:26:05 thorpej Exp $ */
2 1.26 thorpej
3 1.26 thorpej /*-
4 1.26 thorpej * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 1.26 thorpej * All rights reserved.
6 1.26 thorpej *
7 1.26 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.26 thorpej * by Jason R. Thorpe.
9 1.26 thorpej *
10 1.26 thorpej * Redistribution and use in source and binary forms, with or without
11 1.26 thorpej * modification, are permitted provided that the following conditions
12 1.26 thorpej * are met:
13 1.26 thorpej * 1. Redistributions of source code must retain the above copyright
14 1.26 thorpej * notice, this list of conditions and the following disclaimer.
15 1.26 thorpej * 2. Redistributions in binary form must reproduce the above copyright
16 1.26 thorpej * notice, this list of conditions and the following disclaimer in the
17 1.26 thorpej * documentation and/or other materials provided with the distribution.
18 1.26 thorpej * 3. All advertising materials mentioning features or use of this software
19 1.26 thorpej * must display the following acknowledgement:
20 1.26 thorpej * This product includes software developed by the NetBSD
21 1.26 thorpej * Foundation, Inc. and its contributors.
22 1.26 thorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.26 thorpej * contributors may be used to endorse or promote products derived
24 1.26 thorpej * from this software without specific prior written permission.
25 1.26 thorpej *
26 1.26 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.26 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.26 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.26 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.26 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.26 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.26 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.26 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.26 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.26 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.26 thorpej * POSSIBILITY OF SUCH DAMAGE.
37 1.26 thorpej */
38 1.1 cgd
39 1.1 cgd /*
40 1.6 cgd * Copyright (c) 1997 Christopher G. Demetriou. All rights reserved.
41 1.1 cgd * Copyright (c) 1996 Carnegie-Mellon University.
42 1.1 cgd * All rights reserved.
43 1.1 cgd *
44 1.1 cgd * Author: Chris G. Demetriou
45 1.1 cgd *
46 1.1 cgd * Permission to use, copy, modify and distribute this software and
47 1.1 cgd * its documentation is hereby granted, provided that both the copyright
48 1.1 cgd * notice and this permission notice appear in all copies of the
49 1.1 cgd * software, derivative works or modified versions, and any portions
50 1.1 cgd * thereof, and that both notices appear in supporting documentation.
51 1.1 cgd *
52 1.1 cgd * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
53 1.1 cgd * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
54 1.1 cgd * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
55 1.1 cgd *
56 1.1 cgd * Carnegie Mellon requests users of this software to return to
57 1.1 cgd *
58 1.1 cgd * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
59 1.1 cgd * School of Computer Science
60 1.1 cgd * Carnegie Mellon University
61 1.1 cgd * Pittsburgh PA 15213-3890
62 1.1 cgd *
63 1.1 cgd * any improvements or extensions that they make and grant Carnegie the
64 1.1 cgd * rights to redistribute these changes.
65 1.1 cgd */
66 1.1 cgd
67 1.2 cgd #ifndef _ALPHA_INTR_H_
68 1.2 cgd #define _ALPHA_INTR_H_
69 1.2 cgd
70 1.28 thorpej #include <sys/device.h>
71 1.26 thorpej #include <sys/lock.h>
72 1.3 cgd #include <sys/queue.h>
73 1.23 thorpej #include <machine/atomic.h>
74 1.3 cgd
75 1.26 thorpej /*
76 1.26 thorpej * Alpha interrupts come in at one of 4 levels:
77 1.26 thorpej *
78 1.26 thorpej * software interrupt level
79 1.26 thorpej * i/o level 1
80 1.26 thorpej * i/o level 2
81 1.26 thorpej * clock level
82 1.26 thorpej *
83 1.26 thorpej * However, since we do not have any way to know which hardware
84 1.26 thorpej * level a particular i/o interrupt comes in on, we have to
85 1.26 thorpej * whittle it down to 3.
86 1.26 thorpej */
87 1.26 thorpej
88 1.26 thorpej #define IPL_NONE 1 /* disable only this interrupt */
89 1.1 cgd #define IPL_BIO 1 /* disable block I/O interrupts */
90 1.26 thorpej #define IPL_NET 1 /* disable network interrupts */
91 1.26 thorpej #define IPL_TTY 1 /* disable terminal interrupts */
92 1.26 thorpej #define IPL_CLOCK 2 /* disable clock interrupts */
93 1.26 thorpej #define IPL_HIGH 3 /* disable all interrupts */
94 1.26 thorpej #define IPL_SERIAL 1 /* disable serial interrupts */
95 1.26 thorpej
96 1.26 thorpej #define IPL_SOFTSERIAL 0 /* serial software interrupts */
97 1.26 thorpej #define IPL_SOFTNET 1 /* network software interrupts */
98 1.26 thorpej #define IPL_SOFTCLOCK 2 /* clock software interrupts */
99 1.26 thorpej #define IPL_SOFT 3 /* other software interrupts */
100 1.26 thorpej #define IPL_NSOFT 4
101 1.1 cgd
102 1.28 thorpej #define IPL_SOFTNAMES { \
103 1.28 thorpej "serial", \
104 1.28 thorpej "net", \
105 1.28 thorpej "clock", \
106 1.28 thorpej "misc", \
107 1.28 thorpej }
108 1.28 thorpej
109 1.3 cgd #define IST_UNUSABLE -1 /* interrupt cannot be used */
110 1.1 cgd #define IST_NONE 0 /* none (dummy) */
111 1.1 cgd #define IST_PULSE 1 /* pulsed */
112 1.1 cgd #define IST_EDGE 2 /* edge-triggered */
113 1.1 cgd #define IST_LEVEL 3 /* level-triggered */
114 1.17 thorpej
115 1.11 mjacob #ifdef _KERNEL
116 1.2 cgd
117 1.44 thorpej /* Simulated software interrupt register. */
118 1.44 thorpej extern __volatile unsigned long ssir;
119 1.44 thorpej
120 1.6 cgd /* IPL-lowering/restoring macros */
121 1.29 cgd void spl0(void);
122 1.44 thorpej
123 1.29 cgd static __inline void
124 1.29 cgd splx(int s)
125 1.29 cgd {
126 1.44 thorpej if (s == ALPHA_PSL_IPL_0 && ssir != 0)
127 1.29 cgd spl0();
128 1.29 cgd else
129 1.29 cgd alpha_pal_swpipl(s);
130 1.29 cgd }
131 1.29 cgd #define spllowersoftclock() ((void)alpha_pal_swpipl(ALPHA_PSL_IPL_SOFT))
132 1.6 cgd
133 1.8 cgd /* IPL-raising functions/macros */
134 1.8 cgd static __inline int
135 1.27 thorpej _splraise(int s)
136 1.8 cgd {
137 1.8 cgd int cur = alpha_pal_rdps() & ALPHA_PSL_IPL_MASK;
138 1.9 cgd return (s > cur ? alpha_pal_swpipl(s) : cur);
139 1.8 cgd }
140 1.20 thorpej #define splsoft() _splraise(ALPHA_PSL_IPL_SOFT)
141 1.20 thorpej #define splsoftserial() splsoft()
142 1.20 thorpej #define splsoftclock() splsoft()
143 1.20 thorpej #define splsoftnet() splsoft()
144 1.30 thorpej #define splnet() _splraise(ALPHA_PSL_IPL_IO)
145 1.30 thorpej #define splbio() _splraise(ALPHA_PSL_IPL_IO)
146 1.38 thorpej #define splvm() _splraise(ALPHA_PSL_IPL_IO)
147 1.30 thorpej #define spltty() _splraise(ALPHA_PSL_IPL_IO)
148 1.30 thorpej #define splserial() _splraise(ALPHA_PSL_IPL_IO)
149 1.30 thorpej #define splclock() _splraise(ALPHA_PSL_IPL_CLOCK)
150 1.30 thorpej #define splstatclock() _splraise(ALPHA_PSL_IPL_CLOCK)
151 1.30 thorpej #define splhigh() _splraise(ALPHA_PSL_IPL_HIGH)
152 1.14 is
153 1.33 thorpej #define splsched() splhigh()
154 1.34 thorpej #define spllock() splhigh()
155 1.14 is #define spllpt() spltty()
156 1.2 cgd
157 1.2 cgd /*
158 1.19 thorpej * Interprocessor interrupts. In order how we want them processed.
159 1.18 thorpej */
160 1.22 thorpej #define ALPHA_IPI_HALT 0x0000000000000001UL
161 1.22 thorpej #define ALPHA_IPI_TBIA 0x0000000000000002UL
162 1.22 thorpej #define ALPHA_IPI_TBIAP 0x0000000000000004UL
163 1.22 thorpej #define ALPHA_IPI_SHOOTDOWN 0x0000000000000008UL
164 1.22 thorpej #define ALPHA_IPI_IMB 0x0000000000000010UL
165 1.22 thorpej #define ALPHA_IPI_AST 0x0000000000000020UL
166 1.32 thorpej #define ALPHA_IPI_SYNCH_FPU 0x0000000000000040UL
167 1.32 thorpej #define ALPHA_IPI_DISCARD_FPU 0x0000000000000080UL
168 1.33 thorpej #define ALPHA_IPI_PAUSE 0x0000000000000100UL
169 1.19 thorpej
170 1.33 thorpej #define ALPHA_NIPIS 9 /* must not exceed 64 */
171 1.18 thorpej
172 1.35 thorpej struct cpu_info;
173 1.37 thorpej struct trapframe;
174 1.35 thorpej
175 1.35 thorpej void alpha_ipi_init(struct cpu_info *);
176 1.37 thorpej void alpha_ipi_process(struct cpu_info *, struct trapframe *);
177 1.27 thorpej void alpha_send_ipi(unsigned long, unsigned long);
178 1.27 thorpej void alpha_broadcast_ipi(unsigned long);
179 1.31 thorpej void alpha_multicast_ipi(unsigned long, unsigned long);
180 1.3 cgd
181 1.3 cgd /*
182 1.3 cgd * Alpha shared-interrupt-line common code.
183 1.3 cgd */
184 1.3 cgd
185 1.3 cgd struct alpha_shared_intrhand {
186 1.3 cgd TAILQ_ENTRY(alpha_shared_intrhand)
187 1.3 cgd ih_q;
188 1.24 thorpej struct alpha_shared_intr *ih_intrhead;
189 1.27 thorpej int (*ih_fn)(void *);
190 1.3 cgd void *ih_arg;
191 1.3 cgd int ih_level;
192 1.15 thorpej unsigned int ih_num;
193 1.3 cgd };
194 1.3 cgd
195 1.3 cgd struct alpha_shared_intr {
196 1.3 cgd TAILQ_HEAD(,alpha_shared_intrhand)
197 1.3 cgd intr_q;
198 1.28 thorpej struct evcnt intr_evcnt;
199 1.28 thorpej char *intr_string;
200 1.22 thorpej void *intr_private;
201 1.3 cgd int intr_sharetype;
202 1.3 cgd int intr_dfltsharetype;
203 1.3 cgd int intr_nstrays;
204 1.3 cgd int intr_maxstrays;
205 1.3 cgd };
206 1.12 thorpej
207 1.13 thorpej #define ALPHA_SHARED_INTR_DISABLE(asi, num) \
208 1.13 thorpej ((asi)[num].intr_maxstrays != 0 && \
209 1.13 thorpej (asi)[num].intr_nstrays == (asi)[num].intr_maxstrays)
210 1.26 thorpej
211 1.26 thorpej #define setsoft(x) atomic_setbits_ulong(&ssir, 1 << (x))
212 1.26 thorpej
213 1.26 thorpej struct alpha_soft_intrhand {
214 1.42 thorpej TAILQ_ENTRY(alpha_soft_intrhand)
215 1.26 thorpej sih_q;
216 1.26 thorpej struct alpha_soft_intr *sih_intrhead;
217 1.27 thorpej void (*sih_fn)(void *);
218 1.26 thorpej void *sih_arg;
219 1.26 thorpej int sih_pending;
220 1.26 thorpej };
221 1.26 thorpej
222 1.26 thorpej struct alpha_soft_intr {
223 1.42 thorpej TAILQ_HEAD(, alpha_soft_intrhand)
224 1.26 thorpej softintr_q;
225 1.28 thorpej struct evcnt softintr_evcnt;
226 1.26 thorpej struct simplelock softintr_slock;
227 1.26 thorpej unsigned long softintr_ipl;
228 1.26 thorpej };
229 1.26 thorpej
230 1.27 thorpej void *softintr_establish(int, void (*)(void *), void *);
231 1.27 thorpej void softintr_disestablish(void *);
232 1.27 thorpej void softintr_init(void);
233 1.27 thorpej void softintr_dispatch(void);
234 1.26 thorpej
235 1.26 thorpej #define softintr_schedule(arg) \
236 1.26 thorpej do { \
237 1.26 thorpej struct alpha_soft_intrhand *__sih = (arg); \
238 1.42 thorpej struct alpha_soft_intr *__si = __sih->sih_intrhead; \
239 1.42 thorpej int __s; \
240 1.42 thorpej \
241 1.43 thorpej __s = splhigh(); \
242 1.43 thorpej simple_lock(&__si->softintr_slock); \
243 1.42 thorpej if (__sih->sih_pending == 0) { \
244 1.42 thorpej TAILQ_INSERT_TAIL(&__si->softintr_q, __sih, sih_q); \
245 1.42 thorpej __sih->sih_pending = 1; \
246 1.42 thorpej setsoft(__si->softintr_ipl); \
247 1.42 thorpej } \
248 1.43 thorpej simple_unlock(&__si->softintr_slock); \
249 1.43 thorpej splx(__s); \
250 1.26 thorpej } while (0)
251 1.26 thorpej
252 1.26 thorpej /* XXX For legacy software interrupts. */
253 1.26 thorpej extern struct alpha_soft_intrhand *softnet_intrhand;
254 1.26 thorpej
255 1.26 thorpej #define setsoftnet() softintr_schedule(softnet_intrhand)
256 1.3 cgd
257 1.28 thorpej struct alpha_shared_intr *alpha_shared_intr_alloc(unsigned int, unsigned int);
258 1.27 thorpej int alpha_shared_intr_dispatch(struct alpha_shared_intr *,
259 1.27 thorpej unsigned int);
260 1.27 thorpej void *alpha_shared_intr_establish(struct alpha_shared_intr *,
261 1.27 thorpej unsigned int, int, int, int (*)(void *), void *, const char *);
262 1.27 thorpej void alpha_shared_intr_disestablish(struct alpha_shared_intr *,
263 1.27 thorpej void *, const char *);
264 1.27 thorpej int alpha_shared_intr_get_sharetype(struct alpha_shared_intr *,
265 1.27 thorpej unsigned int);
266 1.27 thorpej int alpha_shared_intr_isactive(struct alpha_shared_intr *,
267 1.27 thorpej unsigned int);
268 1.27 thorpej void alpha_shared_intr_set_dfltsharetype(struct alpha_shared_intr *,
269 1.27 thorpej unsigned int, int);
270 1.27 thorpej void alpha_shared_intr_set_maxstrays(struct alpha_shared_intr *,
271 1.27 thorpej unsigned int, int);
272 1.27 thorpej void alpha_shared_intr_stray(struct alpha_shared_intr *, unsigned int,
273 1.27 thorpej const char *);
274 1.27 thorpej void alpha_shared_intr_set_private(struct alpha_shared_intr *,
275 1.27 thorpej unsigned int, void *);
276 1.27 thorpej void *alpha_shared_intr_get_private(struct alpha_shared_intr *,
277 1.27 thorpej unsigned int);
278 1.28 thorpej char *alpha_shared_intr_string(struct alpha_shared_intr *,
279 1.28 thorpej unsigned int);
280 1.28 thorpej struct evcnt *alpha_shared_intr_evcnt(struct alpha_shared_intr *,
281 1.28 thorpej unsigned int);
282 1.28 thorpej
283 1.28 thorpej void set_iointr(void (*)(void *, unsigned long));
284 1.2 cgd
285 1.17 thorpej #endif /* _KERNEL */
286 1.17 thorpej #endif /* ! _ALPHA_INTR_H_ */
287