intr.h revision 1.9.8.2 1 /* $NetBSD: intr.h,v 1.9.8.2 2002/01/08 00:27:30 nathanw Exp $ */
2
3 /*
4 * Copyright (c) 2000 Soren S. Jorvang
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed for the
18 * NetBSD Project. See http://www.netbsd.org/ for
19 * information about NetBSD.
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #ifndef _SGIMIPS_INTR_H_
36 #define _SGIMIPS_INTR_H_
37
38 #define IPL_NONE 0 /* Disable only this interrupt. */
39 #define IPL_BIO 1 /* Disable block I/O interrupts. */
40 #define IPL_NET 2 /* Disable network interrupts. */
41 #define IPL_TTY 3 /* Disable terminal interrupts. */
42 #define IPL_CLOCK 4 /* Disable clock interrupts. */
43 #define IPL_STATCLOCK 5 /* Disable profiling interrupts. */
44 #ifndef __NO_SOFT_SERIAL_INTERRUPT
45 #define IPL_SERIAL 6 /* Disable serial hardware interrupts. */
46 #endif
47 #define IPL_HIGH 7 /* Disable all interrupts. */
48 #define NIPL 8
49
50 /* Interrupt sharing types. */
51 #define IST_NONE 0 /* none */
52 #define IST_PULSE 1 /* pulsed */
53 #define IST_EDGE 2 /* edge-triggered */
54 #define IST_LEVEL 3 /* level-triggered */
55
56 /* Soft interrupt numbers */
57 #define IPL_SOFTSERIAL 0 /* serial software interrupts */
58 #define IPL_SOFTNET 1 /* network software interrupts */
59 #define IPL_SOFTCLOCK 2 /* clock software interrupts */
60 #define IPL_NSOFT 3
61
62 #define IPL_SOFTNAMES { \
63 "serial", \
64 "net", \
65 "clock", \
66 }
67
68 #ifdef _KERNEL
69 #ifndef _LOCORE
70
71 #include <sys/queue.h>
72 #include <sys/types.h>
73 #include <sys/device.h>
74 #include <mips/cpuregs.h>
75
76 /*
77 * software simulated interrupt
78 */
79 #define setsoft(x) do { \
80 extern u_int ssir; \
81 int s; \
82 \
83 s = splhigh(); \
84 ssir |= 1 << (x); \
85 _setsoftintr(MIPS_SOFT_INT_MASK_1); \
86 splx(s); \
87 } while (0)
88
89 #ifdef __HAVE_GENERIC_SOFT_INTERRUPTS
90
91 #define softintr_schedule(arg) \
92 do { \
93 struct sgimips_intrhand *__ih = (arg); \
94 __ih->ih_pending = 1; \
95 setsoft(__ih->ih_intrhead->intr_ipl); \
96 } while (0)
97
98 extern struct sgimips_intrhand *softnet_intrhand;
99
100 #define setsoftnet() softintr_schedule(softnet_intrhand)
101
102 #else /* ! __HAVE_GENERIC_SOFT_INTERRUPTS */
103
104 #define SIR_NET 0x01
105 #define SIR_SERIAL 0x02
106
107 #define setsoftclock() _setsoftintr(MIPS_SOFT_INT_MASK_0)
108 #define setsoftnet() setsoft(SIR_NET)
109 #define setsoftserial() setsoft(SIR_SERIAL)
110 #endif /* __HAVE_GENERIC_SOFT_INTERRUPTS */
111
112 #define NINTR 32
113
114 struct sgimips_intrhand {
115 LIST_ENTRY(sgimips_intrhand)
116 ih_q;
117 int (*ih_fun) __P((void *));
118 void *ih_arg;
119 struct sgimips_intr *ih_intrhead;
120 int ih_pending;
121 };
122
123 struct sgimips_intr {
124 LIST_HEAD(,sgimips_intrhand)
125 intr_q;
126 struct evcnt ih_evcnt;
127 unsigned long intr_ipl;
128 };
129
130 extern struct sgimips_intrhand intrtab[];
131
132 extern int _splraise(int);
133 extern int _spllower(int);
134 extern int _splset(int);
135 extern int _splget(void);
136 extern void _splnone(void);
137 extern void _setsoftintr(int);
138 extern void _clrsoftintr(int);
139
140 extern u_int32_t biomask;
141 extern u_int32_t netmask;
142 extern u_int32_t ttymask;
143 extern u_int32_t clockmask;
144
145 #define splhigh() _splraise(MIPS_INT_MASK)
146 #define spl0() (void)_spllower(0)
147 #define splx(s) (void)_splset(s)
148 #define splbio() _splraise(biomask)
149 #define splnet() _splraise(netmask)
150 #define spltty() _splraise(ttymask)
151 #define splserial() spltty()
152 #define splvm() spltty()
153 #define splclock() _splraise(clockmask)
154 #define splstatclock() splclock()
155
156 #define splsched() splhigh()
157 #define spllock() splhigh()
158 #define spllpt() spltty()
159
160 #define splsoft() _splraise(MIPS_SOFT_INT_MASK_1)
161 #define splsoftclock() splsoft()
162 #define splsoftnet() splsoft()
163
164 #define spllowersoftclock() _spllower(MIPS_SOFT_INT_MASK_1)
165
166 extern void * cpu_intr_establish(int, int, int (*)(void *), void *);
167 void * softintr_establish(int, void (*)(void *), void *);
168 void softintr_disestablish(void *);
169 void softintr_init(void);
170 void softintr_dispatch(void);
171
172
173 #endif /* _LOCORE */
174 #endif /* !_KERNEL */
175
176 #endif /* !_SGIMIPS_INTR_H_ */
177