intr.h revision 1.13 1 1.13 uch /* $NetBSD: intr.h,v 1.13 2002/02/12 15:26:48 uch Exp $ */
2 1.1 itojun
3 1.1 itojun /*
4 1.1 itojun * Copyright (c) 1996, 1997 Charles M. Hannum. All rights reserved.
5 1.1 itojun *
6 1.1 itojun * Redistribution and use in source and binary forms, with or without
7 1.1 itojun * modification, are permitted provided that the following conditions
8 1.1 itojun * are met:
9 1.1 itojun * 1. Redistributions of source code must retain the above copyright
10 1.1 itojun * notice, this list of conditions and the following disclaimer.
11 1.1 itojun * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 itojun * notice, this list of conditions and the following disclaimer in the
13 1.1 itojun * documentation and/or other materials provided with the distribution.
14 1.1 itojun * 3. All advertising materials mentioning features or use of this software
15 1.1 itojun * must display the following acknowledgement:
16 1.1 itojun * This product includes software developed by Charles M. Hannum.
17 1.1 itojun * 4. The name of the author may not be used to endorse or promote products
18 1.1 itojun * derived from this software without specific prior written permission.
19 1.1 itojun *
20 1.1 itojun * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.1 itojun * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.1 itojun * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.1 itojun * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.1 itojun * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.1 itojun * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.1 itojun * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.1 itojun * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.1 itojun * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.1 itojun * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.1 itojun */
31 1.1 itojun
32 1.1 itojun /*
33 1.1 itojun * SH3 Version
34 1.1 itojun *
35 1.1 itojun * T.Horiuchi Brains Corp. 5/22/98
36 1.1 itojun */
37 1.1 itojun
38 1.1 itojun #ifndef _SH3_INTR_H_
39 1.1 itojun #define _SH3_INTR_H_
40 1.1 itojun
41 1.1 itojun /* Interrupt sharing types. */
42 1.1 itojun #define IST_NONE 0 /* none */
43 1.1 itojun #define IST_PULSE 1 /* pulsed */
44 1.1 itojun #define IST_EDGE 2 /* edge-triggered */
45 1.1 itojun #define IST_LEVEL 3 /* level-triggered */
46 1.1 itojun
47 1.1 itojun #ifndef _LOCORE
48 1.1 itojun
49 1.1 itojun volatile int cpl, ipending, astpending;
50 1.1 itojun int imask[NIPL];
51 1.1 itojun
52 1.13 uch extern void Xspllower(void);
53 1.1 itojun
54 1.13 uch static __inline int splraise(int);
55 1.13 uch static __inline void spllower(int);
56 1.13 uch static __inline void softintr(int);
57 1.1 itojun
58 1.1 itojun /*
59 1.1 itojun * Add a mask to cpl, and return the old value of cpl.
60 1.1 itojun */
61 1.1 itojun static __inline int
62 1.13 uch splraise(int ncpl)
63 1.1 itojun {
64 1.1 itojun int ocpl ;
65 1.1 itojun
66 1.1 itojun ocpl = cpl;
67 1.1 itojun
68 1.1 itojun cpl = ocpl | ncpl;
69 1.1 itojun return (ocpl);
70 1.1 itojun }
71 1.1 itojun
72 1.1 itojun /*
73 1.1 itojun * Restore a value to cpl (unmasking interrupts). If any unmasked
74 1.1 itojun * interrupts are pending, call Xspllower() to process them.
75 1.1 itojun */
76 1.1 itojun static __inline void
77 1.13 uch spllower(int ncpl)
78 1.1 itojun {
79 1.1 itojun
80 1.1 itojun cpl = ncpl;
81 1.1 itojun if (ipending & ~ncpl)
82 1.1 itojun Xspllower();
83 1.1 itojun }
84 1.1 itojun
85 1.1 itojun /*
86 1.1 itojun * Hardware interrupt masks
87 1.1 itojun */
88 1.1 itojun #define splbio() splraise(imask[IPL_BIO])
89 1.1 itojun #define splnet() splraise(imask[IPL_NET])
90 1.1 itojun #define spltty() splraise(imask[IPL_TTY])
91 1.1 itojun #define splaudio() splraise(imask[IPL_AUDIO])
92 1.1 itojun #define splclock() splraise(imask[IPL_CLOCK])
93 1.1 itojun #define splstatclock() splclock()
94 1.1 itojun #define splserial() splraise(imask[IPL_SERIAL])
95 1.1 itojun
96 1.1 itojun /*
97 1.1 itojun * Software interrupt masks
98 1.1 itojun *
99 1.1 itojun * NOTE: splsoftclock() is used by hardclock() to lower the priority from
100 1.1 itojun * clock to softclock before it calls softclock().
101 1.1 itojun */
102 1.2 tsubai #define spllowersoftclock() spllower(imask[IPL_SOFTCLOCK])
103 1.2 tsubai #define splsoftclock() splraise(imask[IPL_SOFTCLOCK])
104 1.1 itojun #define splsoftnet() splraise(imask[IPL_SOFTNET])
105 1.1 itojun #define splsoftserial() splraise(imask[IPL_SOFTSERIAL])
106 1.1 itojun
107 1.1 itojun /*
108 1.1 itojun * Miscellaneous
109 1.1 itojun */
110 1.10 thorpej #define splvm() splraise(imask[IPL_IMP])
111 1.1 itojun #define splhigh() splraise(imask[IPL_HIGH])
112 1.8 thorpej #define splsched() splhigh()
113 1.9 thorpej #define spllock() splhigh()
114 1.1 itojun #define spl0() spllower(0)
115 1.6 msaitoh #define splx(x) spllower(x)
116 1.1 itojun
117 1.1 itojun /*
118 1.1 itojun * Software interrupt registration
119 1.1 itojun *
120 1.1 itojun * We hand-code this to ensure that it's atomic.
121 1.1 itojun */
122 1.1 itojun static __inline void
123 1.13 uch softintr(int mask)
124 1.1 itojun {
125 1.4 msaitoh extern void enable_interrupt(void); /* XXX */
126 1.4 msaitoh extern void disable_interrupt(void);
127 1.4 msaitoh
128 1.4 msaitoh disable_interrupt();
129 1.1 itojun ipending |= (1 << mask);
130 1.4 msaitoh enable_interrupt();
131 1.1 itojun }
132 1.1 itojun
133 1.1 itojun #define setsoftast() (astpending = 1)
134 1.1 itojun #define setsoftclock() softintr(SIR_CLOCK)
135 1.1 itojun #define setsoftnet() softintr(SIR_NET)
136 1.1 itojun #define setsoftserial() softintr(SIR_SERIAL)
137 1.1 itojun
138 1.1 itojun #endif /* !_LOCORE */
139 1.1 itojun
140 1.1 itojun #define INTEVT_SOFT 0xf00 /* This value is stored to INTEVT reg,
141 1.12 wiz when software interrupt occurred */
142 1.1 itojun #define INTEVT_TMU0 0x400
143 1.1 itojun #define INTEVT_TMU1 0x420
144 1.1 itojun #define INTEVT_TMU2 0x440
145 1.3 msaitoh
146 1.3 msaitoh #define INTEVT_SCI0_ERI 0x4e0
147 1.3 msaitoh #define INTEVT_SCI0_RXI 0x500
148 1.3 msaitoh #define INTEVT_SCI0_TXI 0x520
149 1.3 msaitoh #define INTEVT_SCI0_TEI 0x540
150 1.7 msaitoh
151 1.7 msaitoh #define INTEVT_WDT 0x560
152 1.3 msaitoh
153 1.3 msaitoh #define IS_INTEVT_SCI0(x) ((x == INTEVT_SCI0_ERI) || (x == INTEVT_SCI0_RXI) \
154 1.3 msaitoh || (x == INTEVT_SCI0_TXI) || (x == INTEVT_SCI0_TEI))
155 1.3 msaitoh
156 1.3 msaitoh #define INTEVT_PRI 0x4a0 /* Periodic interrupt generated by RTC */
157 1.3 msaitoh
158 1.3 msaitoh #if defined(SH4)
159 1.3 msaitoh #define INTEVT_SCIF 0x700
160 1.3 msaitoh #endif
161 1.1 itojun
162 1.1 itojun #endif /* !_SH3_INTR_H_ */
163