intr.h revision 1.11.8.2 1 1.11.8.2 nathanw /* $NetBSD: intr.h,v 1.11.8.2 2002/01/08 00:24:45 nathanw Exp $ */
2 1.11.8.2 nathanw
3 1.11.8.2 nathanw /*-
4 1.11.8.2 nathanw * Copyright (c) 1996, 1997, 1999 The NetBSD Foundation, Inc.
5 1.11.8.2 nathanw * All rights reserved.
6 1.11.8.2 nathanw *
7 1.11.8.2 nathanw * This code is derived from software contributed to The NetBSD Foundation
8 1.11.8.2 nathanw * by Jason R. Thorpe.
9 1.11.8.2 nathanw *
10 1.11.8.2 nathanw * Redistribution and use in source and binary forms, with or without
11 1.11.8.2 nathanw * modification, are permitted provided that the following conditions
12 1.11.8.2 nathanw * are met:
13 1.11.8.2 nathanw * 1. Redistributions of source code must retain the above copyright
14 1.11.8.2 nathanw * notice, this list of conditions and the following disclaimer.
15 1.11.8.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
16 1.11.8.2 nathanw * notice, this list of conditions and the following disclaimer in the
17 1.11.8.2 nathanw * documentation and/or other materials provided with the distribution.
18 1.11.8.2 nathanw * 3. All advertising materials mentioning features or use of this software
19 1.11.8.2 nathanw * must display the following acknowledgement:
20 1.11.8.2 nathanw * This product includes software developed by the NetBSD
21 1.11.8.2 nathanw * Foundation, Inc. and its contributors.
22 1.11.8.2 nathanw * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.11.8.2 nathanw * contributors may be used to endorse or promote products derived
24 1.11.8.2 nathanw * from this software without specific prior written permission.
25 1.11.8.2 nathanw *
26 1.11.8.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.11.8.2 nathanw * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.11.8.2 nathanw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.11.8.2 nathanw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.11.8.2 nathanw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.11.8.2 nathanw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.11.8.2 nathanw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.11.8.2 nathanw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.11.8.2 nathanw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.11.8.2 nathanw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.11.8.2 nathanw * POSSIBILITY OF SUCH DAMAGE.
37 1.11.8.2 nathanw */
38 1.11.8.2 nathanw
39 1.11.8.2 nathanw #ifndef _HP300_INTR_H_
40 1.11.8.2 nathanw #define _HP300_INTR_H_
41 1.11.8.2 nathanw
42 1.11.8.2 nathanw #include <sys/device.h>
43 1.11.8.2 nathanw #include <sys/queue.h>
44 1.11.8.2 nathanw #include <machine/psl.h>
45 1.11.8.2 nathanw
46 1.11.8.2 nathanw /*
47 1.11.8.2 nathanw * Interrupt "levels". These are a more abstract representation
48 1.11.8.2 nathanw * of interrupt levels, and do not have the same meaning as m68k
49 1.11.8.2 nathanw * CPU interrupt levels. They serve two purposes:
50 1.11.8.2 nathanw *
51 1.11.8.2 nathanw * - properly order ISRs in the list for that CPU ipl
52 1.11.8.2 nathanw * - compute CPU PSL values for the spl*() calls.
53 1.11.8.2 nathanw */
54 1.11.8.2 nathanw #define IPL_NONE 0 /* disable only this interrupt */
55 1.11.8.2 nathanw #define IPL_BIO 1 /* disable block I/O interrupts */
56 1.11.8.2 nathanw #define IPL_NET 2 /* disable network interrupts */
57 1.11.8.2 nathanw #define IPL_TTY 3 /* disable terminal interrupts */
58 1.11.8.2 nathanw #define IPL_TTYNOBUF 4 /* IPL_TTY + higher ISR priority */
59 1.11.8.2 nathanw #define IPL_CLOCK 5 /* disable clock interrupts */
60 1.11.8.2 nathanw #define IPL_HIGH 6 /* disable all interrupts */
61 1.11.8.2 nathanw
62 1.11.8.2 nathanw /* Copied from alpha/include/intr.h */
63 1.11.8.2 nathanw #define IPL_SOFTSERIAL 0 /* serial software interrupts */
64 1.11.8.2 nathanw #define IPL_SOFTNET 1 /* network software interrupts */
65 1.11.8.2 nathanw #define IPL_SOFTCLOCK 2 /* clock software interrupts */
66 1.11.8.2 nathanw #define IPL_SOFT 3 /* other software interrupts */
67 1.11.8.2 nathanw #define IPL_NSOFT 4
68 1.11.8.2 nathanw
69 1.11.8.2 nathanw #define IPL_SOFTNAMES { \
70 1.11.8.2 nathanw "serial", \
71 1.11.8.2 nathanw "net", \
72 1.11.8.2 nathanw "clock", \
73 1.11.8.2 nathanw "misc", \
74 1.11.8.2 nathanw }
75 1.11.8.2 nathanw
76 1.11.8.2 nathanw /*
77 1.11.8.2 nathanw * Convert PSL values to CPU IPLs and vice-versa.
78 1.11.8.2 nathanw */
79 1.11.8.2 nathanw #define PSLTOIPL(x) (((x) >> 8) & 0xf)
80 1.11.8.2 nathanw #define IPLTOPSL(x) ((((x) & 0xf) << 8) | PSL_S)
81 1.11.8.2 nathanw
82 1.11.8.2 nathanw #ifdef _KERNEL
83 1.11.8.2 nathanw /*
84 1.11.8.2 nathanw * This array contains the appropriate PSL_S|PSL_IPL? values
85 1.11.8.2 nathanw * to raise interrupt priority to the requested level.
86 1.11.8.2 nathanw */
87 1.11.8.2 nathanw extern unsigned short hp300_ipls[];
88 1.11.8.2 nathanw
89 1.11.8.2 nathanw #define HP300_IPL_SOFT 0
90 1.11.8.2 nathanw #define HP300_IPL_BIO 1
91 1.11.8.2 nathanw #define HP300_IPL_NET 2
92 1.11.8.2 nathanw #define HP300_IPL_TTY 3
93 1.11.8.2 nathanw #define HP300_IPL_VM 4
94 1.11.8.2 nathanw #define HP300_IPL_CLOCK 5
95 1.11.8.2 nathanw #define HP300_IPL_HIGH 6
96 1.11.8.2 nathanw #define HP300_NIPLS 7
97 1.11.8.2 nathanw
98 1.11.8.2 nathanw /* These spl calls are _not_ to be used by machine-independent code. */
99 1.11.8.2 nathanw #define splhil() splraise1()
100 1.11.8.2 nathanw #define splkbd() splhil()
101 1.11.8.2 nathanw
102 1.11.8.2 nathanw /* These spl calls are used by machine-independent code. */
103 1.11.8.2 nathanw /* spl0 requires checking for software interrupts */
104 1.11.8.2 nathanw #define spllowersoftclock() spl1()
105 1.11.8.2 nathanw #define splsoft() splraise1()
106 1.11.8.2 nathanw #define splsoftclock() splsoft()
107 1.11.8.2 nathanw #define splsoftnet() splsoft()
108 1.11.8.2 nathanw #define splsoftserial splsoft()
109 1.11.8.2 nathanw #define splbio() _splraise(hp300_ipls[HP300_IPL_BIO])
110 1.11.8.2 nathanw #define splnet() _splraise(hp300_ipls[HP300_IPL_NET])
111 1.11.8.2 nathanw #define spltty() _splraise(hp300_ipls[HP300_IPL_TTY])
112 1.11.8.2 nathanw #define splvm() _splraise(hp300_ipls[HP300_IPL_VM])
113 1.11.8.2 nathanw #define splclock() spl6()
114 1.11.8.2 nathanw #define splstatclock() splclock()
115 1.11.8.2 nathanw #define splhigh() spl7()
116 1.11.8.2 nathanw #define splsched() spl7()
117 1.11.8.2 nathanw #define spllock() spl7()
118 1.11.8.2 nathanw
119 1.11.8.2 nathanw /* watch out for side effects */
120 1.11.8.2 nathanw #define splx(s) ((s) & PSL_IPL ? _spl((s)) : spl0())
121 1.11.8.2 nathanw
122 1.11.8.2 nathanw struct hp300_intrhand {
123 1.11.8.2 nathanw LIST_ENTRY(hp300_intrhand) ih_q;
124 1.11.8.2 nathanw int (*ih_fn)(void *);
125 1.11.8.2 nathanw void *ih_arg;
126 1.11.8.2 nathanw int ih_ipl;
127 1.11.8.2 nathanw int ih_priority;
128 1.11.8.2 nathanw };
129 1.11.8.2 nathanw
130 1.11.8.2 nathanw struct hp300_intr {
131 1.11.8.2 nathanw LIST_HEAD(, hp300_intrhand) hi_q;
132 1.11.8.2 nathanw struct evcnt hi_evcnt;
133 1.11.8.2 nathanw };
134 1.11.8.2 nathanw
135 1.11.8.2 nathanw /*
136 1.11.8.2 nathanw * Software Interrupts.
137 1.11.8.2 nathanw */
138 1.11.8.2 nathanw
139 1.11.8.2 nathanw struct hp300_soft_intrhand {
140 1.11.8.2 nathanw LIST_ENTRY(hp300_soft_intrhand) sih_q;
141 1.11.8.2 nathanw struct hp300_soft_intr *sih_intrhead;
142 1.11.8.2 nathanw void (*sih_fn)(void *);
143 1.11.8.2 nathanw void *sih_arg;
144 1.11.8.2 nathanw volatile int sih_pending;
145 1.11.8.2 nathanw };
146 1.11.8.2 nathanw
147 1.11.8.2 nathanw struct hp300_soft_intr {
148 1.11.8.2 nathanw LIST_HEAD(, hp300_soft_intrhand) hsi_q;
149 1.11.8.2 nathanw struct evcnt hsi_evcnt;
150 1.11.8.2 nathanw uint8_t hsi_ipl;
151 1.11.8.2 nathanw };
152 1.11.8.2 nathanw
153 1.11.8.2 nathanw void *softintr_establish(int, void (*)(void *), void *);
154 1.11.8.2 nathanw void softintr_disestablish(void *);
155 1.11.8.2 nathanw void softintr_init(void);
156 1.11.8.2 nathanw void softintr_dispatch(void);
157 1.11.8.2 nathanw
158 1.11.8.2 nathanw extern volatile u_int8_t ssir;
159 1.11.8.2 nathanw #define setsoft(x) ssir |= (1<<(x))
160 1.11.8.2 nathanw
161 1.11.8.2 nathanw #define softintr_schedule(arg) \
162 1.11.8.2 nathanw do { \
163 1.11.8.2 nathanw struct hp300_soft_intrhand *__sih = (arg); \
164 1.11.8.2 nathanw __sih->sih_pending = 1; \
165 1.11.8.2 nathanw setsoft(__sih->sih_intrhead->hsi_ipl); \
166 1.11.8.2 nathanw } while (0)
167 1.11.8.2 nathanw
168 1.11.8.2 nathanw /* XXX For legacy software interrupts */
169 1.11.8.2 nathanw extern struct hp300_soft_intrhand *softnet_intrhand;
170 1.11.8.2 nathanw #define setsoftnet() softintr_schedule(softnet_intrhand)
171 1.11.8.2 nathanw
172 1.11.8.2 nathanw /* locore.s */
173 1.11.8.2 nathanw int spl0(void);
174 1.11.8.2 nathanw
175 1.11.8.2 nathanw /* intr.c */
176 1.11.8.2 nathanw void intr_init(void);
177 1.11.8.2 nathanw void *intr_establish(int (*)(void *), void *, int, int);
178 1.11.8.2 nathanw void intr_disestablish(void *);
179 1.11.8.2 nathanw void intr_dispatch(int);
180 1.11.8.2 nathanw void intr_printlevels(void);
181 1.11.8.2 nathanw void netintr(void);
182 1.11.8.2 nathanw
183 1.11.8.2 nathanw #endif /* _KERNEL */
184 1.11.8.2 nathanw
185 1.11.8.2 nathanw #endif /* _HP300_INTR_H_ */
186