xref: /netbsd/sys/arch/evbarm/include/intr.h (revision c4a72b64)
1 /*	$NetBSD: intr.h,v 1.9 2002/11/20 18:15:43 bsh Exp $	*/
2 
3 /*
4  * Copyright (c) 2001 Wasabi Systems, Inc.
5  * All rights reserved.
6  *
7  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *	This product includes software developed for the NetBSD Project by
20  *	Wasabi Systems, Inc.
21  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22  *    or promote products derived from this software without specific prior
23  *    written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef	_EVBARM_INTR_H_
39 #define	_EVBARM_INTR_H_
40 
41 #ifdef _KERNEL
42 
43 /* Interrupt priority "levels". */
44 #define	IPL_NONE	0	/* nothing */
45 #define	IPL_SOFT	1	/* generic software interrupts */
46 #define	IPL_SOFTCLOCK	2	/* software clock interrupt */
47 #define	IPL_SOFTNET	3	/* software network interrupt */
48 #define	IPL_BIO		4	/* block I/O */
49 #define	IPL_NET		5	/* network */
50 #define	IPL_SOFTSERIAL	6	/* software serial interrupt */
51 #define	IPL_TTY		7	/* terminals */
52 #define	IPL_IMP		8	/* memory allocation */
53 #define	IPL_AUDIO	9	/* audio device */
54 #define	IPL_CLOCK	10	/* clock interrupt */
55 #define	IPL_STATCLOCK	11	/* statistics clock interrupt */
56 #define	IPL_HIGH	12	/* everything */
57 #define	IPL_SERIAL	13	/* serial device */
58 
59 #define	NIPL		14
60 
61 /* Interrupt sharing types. */
62 #define	IST_NONE	0	/* none */
63 #define	IST_PULSE	1	/* pulsed */
64 #define	IST_EDGE	2	/* edge-triggered */
65 #define	IST_LEVEL	3	/* level-triggered */
66 
67 #ifdef __OLD_INTERRUPT_CODE	/* XXX XXX XXX */
68 
69 /* Software interrupt priority levels */
70 
71 #define SOFTIRQ_CLOCK   0
72 #define SOFTIRQ_NET     1
73 #define SOFTIRQ_SERIAL  2
74 
75 #define SOFTIRQ_BIT(x)  (1 << x)
76 
77 #include <arm/arm32/psl.h>
78 
79 #else /* ! __OLD_INTERRUPT_CODE */
80 
81 #define	__NEWINTR	/* enables new hooks in cpu_fork()/cpu_switch() */
82 
83 #ifndef _LOCORE
84 
85 #include <sys/device.h>
86 #include <sys/queue.h>
87 
88 #if defined(_LKM)
89 
90 int	_splraise(int);
91 int	_spllower(int);
92 void	splx(int);
93 void	_setsoftintr(int);
94 
95 #else	/* _LKM */
96 
97 #if defined(EVBARM_BOARDTYPE)
98 
99 #include <machine/cpu.h>
100 
101 /*
102  * Each board needs to define the following functions:
103  *
104  * int	_splraise(int);
105  * int	_spllower(int);
106  * void	splx(int);
107  * void	_setsoftintr(int);
108  *
109  * These may be defined as functions, static __inline functions, or macros,
110  * but there must be a _spllower() and splx() defined as functions callable
111  * from assembly language (for cpu_switch()).  However, since it's quite
112  * useful to be able to inline splx(), you could do something like the
113  * following:
114  *
115  * in <boardtype>_intr.h:
116  * 	static __inline int
117  *	boardtype_splx(int spl)
118  *	{...}
119  *
120  *	#define splx(nspl)	boardtype_splx(nspl)
121  *	...
122  * and in boardtype's machdep code:
123  *
124  *	...
125  *	#undef splx
126  *	int
127  *	splx(int spl)
128  *	{
129  *		return boardtype_splx(spl);
130  *	}
131  */
132 
133 #if EVBARM_BOARDTYPE == EVBARM_BOARDTYPE_IQ80310
134 #include <arch/evbarm/iq80310/iq80310_intr.h>
135 #elif EVBARM_BOARDTYPE == EVBARM_BOARDTYPE_I80321
136 #include <arch/arm/xscale/i80321_intr.h>
137 #elif EVBARM_BOARDTYPE == EVBARM_BOARDTYPE_IXM1200
138 #include <arch/evbarm/ixm1200/ixm1200_intr.h>
139 #elif EVBARM_BOARDTYPE == EVBARM_BOARDTYPE_PXA2X0
140 #include <arch/arm/xscale/pxa2x0_intr.h>
141 #elif EVBARM_BOARDTYPE == EVBARM_BOARDTYPE_S3C2800 || \
142       EVBARM_BOARDTYPE == EVBARM_BOARDTYPE_S3C24X0
143 #include <arch/arm/s3c2xx0/s3c2xx0_intr.h>
144 #endif
145 
146 #else	/* EVBARM_BOARDTYPE */
147 
148 #error EVBARM_BOARDTYPE not defined.
149 
150 #endif	/* else EVBARM_BOARDTYPE */
151 
152 #endif /* else _LKM */
153 
154 #define	splhigh()	_splraise(IPL_HIGH)
155 #define	splsoft()	_splraise(IPL_SOFT)
156 #define	splsoftclock()	_splraise(IPL_SOFTCLOCK)
157 #define	splsoftnet()	_splraise(IPL_SOFTNET)
158 #define	splbio()	_splraise(IPL_BIO)
159 #define	splnet()	_splraise(IPL_NET)
160 #define	spltty()	_splraise(IPL_TTY)
161 #define	splvm()		_splraise(IPL_IMP)
162 #define	splaudio()	_splraise(IPL_AUDIO)
163 #define	splclock()	_splraise(IPL_CLOCK)
164 #define	splstatclock()	_splraise(IPL_STATCLOCK)
165 #define	splserial()	_splraise(IPL_SERIAL)
166 
167 #define	spl0()		_spllower(IPL_NONE)
168 #define	spllowersoftclock() _spllower(IPL_SOFTCLOCK)
169 
170 #define	splsched()	splhigh()
171 #define	spllock()	splhigh()
172 
173 /* Use generic software interrupt support. */
174 #include <arm/softintr.h>
175 
176 #endif /* _LOCORE */
177 
178 #endif /* __OLD_INTERRUPT_CODE */
179 
180 #endif /* _KERNEL */
181 
182 #endif	/* _EVBARM_INTR_H_ */
183