intr.h revision 1.6 1 /* $NetBSD: intr.h,v 1.6 2000/12/10 18:43:02 scw Exp $ */
2
3 /*-
4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe and Steve C. Woodford.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #ifndef _MVME68K_INTR_H
40 #define _MVME68K_INTR_H
41
42 #include <sys/device.h>
43 #include <sys/queue.h>
44 #include <machine/psl.h>
45
46 /*
47 * These are identical to the values used by hp300, but are not meaningful
48 * to mvme68k code at this time.
49 */
50 #define IPL_NONE 0 /* disable only this interrupt */
51 #define IPL_BIO 1 /* disable block I/O interrupts */
52 #define IPL_NET 2 /* disable network interrupts */
53 #define IPL_TTY 3 /* disable terminal interrupts */
54 #define IPL_TTYNOBUF 4 /* IPL_TTY + higher ISR priority */
55 #define IPL_SERIAL 4 /* disable serial interrupts */
56 #define IPL_CLOCK 5 /* disable clock interrupts */
57 #define IPL_HIGH 6 /* disable all interrupts */
58
59 /* Copied from alpha/include/intr.h */
60 #define IPL_SOFTSERIAL 0 /* serial software interrupts */
61 #define IPL_SOFTNET 1 /* network software interrupts */
62 #define IPL_SOFTCLOCK 2 /* clock software interrupts */
63 #define IPL_SOFT 3 /* other software interrupts */
64 #define IPL_NSOFT 4
65
66 #define IPL_SOFTNAMES { \
67 "serial", \
68 "net", \
69 "clock", \
70 "misc", \
71 }
72
73 #ifdef _KERNEL
74 /* spl0 requires checking for software interrupts */
75
76 #define spllowersoftclock() spl1()
77 #define splsoft() splraise1()
78 #define splsoftclock() splsoft()
79 #define splsoftnet() splsoft()
80 #define splsoftserial() splsoft()
81 #define splbio() splraise2()
82 #define splnet() splraise3()
83 #define spltty() splraise3()
84 #define splimp() splraise3()
85 #define splserial() splraise4()
86 #define splclock() splraise5()
87 #define splstatclock() splraise5()
88 #define splvm() splraise5()
89 #define splhigh() spl7()
90 #define splsched() spl7()
91 #define spllock() spl7()
92
93 #ifndef _LOCORE
94
95 /*
96 * Simulated software interrupt register
97 * This is cleared to zero to indicate a soft interrupt is pending
98 * (Yes, it's a bit bizarre, but it allows the use of the m68k's `tas'
99 * instruction so we can avoid masking interrupts elsewhere.)
100 */
101 extern volatile unsigned char ssir;
102
103 extern void mvme68k_dossir(void);
104
105 static __inline void
106 splx(int sr)
107 {
108
109 if ((u_int16_t)sr < (u_int16_t)(PSL_IPL1|PSL_S) && ssir == 0)
110 mvme68k_dossir();
111 else
112 __asm __volatile("movw %0,%%sr" : : "di" (sr));
113 }
114
115 static __inline int
116 spl0(void)
117 {
118 int sr;
119
120 __asm __volatile("movw %%sr,%0" : "=d" (sr));
121
122 if (ssir == 0)
123 mvme68k_dossir();
124 else
125 __asm __volatile("movw %0,%%sr" : : "i" (PSL_LOWIPL));
126
127 return sr;
128 }
129
130
131 #define setsoft(x) x = 0
132
133 #define __GENERIC_SOFT_INTERRUPTS
134 struct mvme68k_soft_intrhand {
135 LIST_ENTRY(mvme68k_soft_intrhand) sih_q;
136 struct mvme68k_soft_intr *sih_intrhead;
137 void (*sih_fn)(void *);
138 void *sih_arg;
139 volatile int sih_pending;
140 };
141
142 struct mvme68k_soft_intr {
143 LIST_HEAD(, mvme68k_soft_intrhand) msi_q;
144 struct evcnt msi_evcnt;
145 volatile unsigned char msi_ssir;
146 };
147
148 void *softintr_establish(int, void (*)(void *), void *);
149 void softintr_disestablish(void *);
150 void softintr_init(void);
151 void softintr_dispatch(void);
152
153 #define softintr_schedule(arg) \
154 do { \
155 struct mvme68k_soft_intrhand *__sih = (arg); \
156 __sih->sih_pending = 1; \
157 setsoft(__sih->sih_intrhead->msi_ssir); \
158 setsoft(ssir); \
159 } while (0)
160
161 /* XXX For legacy software interrupts */
162 extern struct mvme68k_soft_intrhand *softnet_intrhand;
163 extern struct mvme68k_soft_intrhand *softclock_intrhand;
164
165 #define setsoftnet() softintr_schedule(softnet_intrhand)
166 #define setsoftclock() softintr_schedule(softclock_intrhand)
167
168 #endif /* !_LOCORE */
169 #endif /* _KERNEL */
170
171 #endif /* _MVME68K_INTR_H */
172