xref: /netbsd/sys/arch/ofppc/include/intr.h (revision c4a72b64)
1 /*	$NetBSD: intr.h,v 1.3 2002/09/18 01:43:07 chs Exp $	*/
2 
3 /*
4  * Copyright 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 /*
39  * Copyright (C) 1995-1997 Wolfgang Solfrank.
40  * Copyright (C) 1995-1997 TooLs GmbH.
41  * All rights reserved.
42  *
43  * Redistribution and use in source and binary forms, with or without
44  * modification, are permitted provided that the following conditions
45  * are met:
46  * 1. Redistributions of source code must retain the above copyright
47  *    notice, this list of conditions and the following disclaimer.
48  * 2. Redistributions in binary form must reproduce the above copyright
49  *    notice, this list of conditions and the following disclaimer in the
50  *    documentation and/or other materials provided with the distribution.
51  * 3. All advertising materials mentioning features or use of this software
52  *    must display the following acknowledgement:
53  *	This product includes software developed by TooLs GmbH.
54  * 4. The name of TooLs GmbH may not be used to endorse or promote products
55  *    derived from this software without specific prior written permission.
56  *
57  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
58  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
59  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
60  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
62  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
63  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
64  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
65  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
66  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67  */
68 
69 #ifndef	_MACHINE_INTR_H_
70 #define	_MACHINE_INTR_H_
71 
72 /* Interrupt priority "levels". */
73 #define	IPL_NONE	0	/* nothing */
74 #define	IPL_SOFT	1	/* generic software interrupts */
75 #define	IPL_SOFTCLOCK	2	/* software clock interrupt */
76 #define	IPL_SOFTNET	3	/* software network interrupt */
77 #define	IPL_BIO		4	/* block I/O */
78 #define	IPL_NET		5	/* network */
79 #define	IPL_SOFTSERIAL	6	/* software serial interrupt */
80 #define	IPL_TTY		7	/* terminals */
81 #define	IPL_IMP		8	/* memory allocation */
82 #define	IPL_AUDIO	9	/* audio device */
83 #define	IPL_CLOCK	10	/* clock interrupt */
84 #define	IPL_HIGH	11	/* everything */
85 #define	IPL_SERIAL	12	/* serial device */
86 
87 #define	NIPL		13
88 
89 /* Interrupt sharing types. */
90 #define	IST_NONE	0	/* none */
91 #define	IST_PULSE	1	/* pulsed */
92 #define	IST_EDGE	2	/* edge-triggered */
93 #define	IST_LEVEL	3	/* level-triggered */
94 
95 #ifdef _KERNEL
96 #ifndef _LOCORE
97 
98 struct clockframe;
99 
100 extern int imask[];
101 
102 struct machvec {
103 	int (*mvec_splraise)(int);
104 	int (*mvec_spllower)(int);
105 	void (*mvec_splx)(int);
106 	void (*mvec_setsoft)(int);
107 	void (*mvec_clock_return)(struct clockframe *, int);
108 	void *(*mvec_intr_establish)(int, int, int, int (*)(void *), void *);
109 	void (*mvec_intr_disestablish)(void *);
110 };
111 
112 extern struct machvec machine_interface;
113 
114 #define	_splraise(x)	((*machine_interface.mvec_splraise)(x))
115 #define	_spllower(x)	((*machine_interface.mvec_spllower)(x))
116 #define	splx(x)		((*machine_interface.mvec_splx)(x))
117 #define	setsoftintr(x)	((*machine_interface.mvec_setsoft)(x))
118 #define	clock_return(x, y) ((*machine_interface.mvec_clock_return)(x, y))
119 #define	intr_establish(irq, lvl, ist, func, arg)			\
120 	((*machine_interface.mvec_intr_establish)((irq), (lvl), (ist),	\
121 	    (func), (arg)))
122 #define	intr_disestablish(cookie)					\
123 	((*machine_interface.mvec_intr_disestablish)((cookie)))
124 
125 #define	splhigh()	_splraise(imask[IPL_HIGH])
126 #define	splsoft()	_splraise(imask[IPL_SOFT])
127 #define	splsoftclock()	_splraise(imask[IPL_SOFTCLOCK])
128 #define	splsoftnet()	_splraise(imask[IPL_SOFTNET])
129 #define	splbio()	_splraise(imask[IPL_BIO])
130 #define	splnet()	_splraise(imask[IPL_NET])
131 #define	spltty()	_splraise(imask[IPL_TTY])
132 #define	splvm()		_splraise(imask[IPL_IMP])
133 #define	splaudio()	_splraise(imask[IPL_AUDIO])
134 #define	splclock()	_splraise(imask[IPL_CLOCK])
135 #define	splserial()	_splraise(imask[IPL_SERIAL])
136 
137 #define	splstatclock()	splclock()
138 
139 #define	spl0()		_spllower(imask[IPL_NONE])
140 #define	spllowersoftclock() _spllower(imask[IPL_SOFTCLOCK])
141 
142 #define	splsched()	splhigh()
143 #define	spllock()	splhigh()
144 
145 #define	setsoftnet()	setsoftintr(IPL_SOFTNET)
146 #define	setsoftclock()	setsoftintr(IPL_SOFTCLOCK)
147 
148 /*
149  * Software interrupt support.
150  */
151 
152 #define	SI_SOFT			0	/* for IPL_SOFT */
153 #define	SI_SOFTCLOCK		1	/* for IPL_SOFTCLOCK */
154 #define	SI_SOFTNET		2	/* for IPL_SOFTNET */
155 #define	SI_SOFTSERIAL		3	/* for IPL_SOFTSERIAL */
156 
157 #define	SI_NQUEUES		4
158 
159 #define	SI_QUEUENAMES {							\
160 	"generic",							\
161 	"clock",							\
162 	"net",								\
163 	"serial",							\
164 }
165 
166 #endif /* _LOCORE */
167 #endif /* _KERNEL */
168 
169 #endif	/* _MACHINE_INTR_H_ */
170