xref: /netbsd-src/sys/arch/sgimips/include/intr.h (revision 4b896b232495b7a9b8b94a1cf1e21873296d53b8)
1 /*	$NetBSD: intr.h,v 1.16 2004/02/08 13:15:42 sekiya 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_SOFT	0	/* generic software interrupts */
58 #define	IPL_SOFTSERIAL	1	/* serial software interrupts */
59 #define	IPL_SOFTNET	2	/* network software interrupts */
60 #define	IPL_SOFTCLOCK	3	/* clock software interrupts */
61 #define	_IPL_NSOFT	4
62 
63 #define	IPL_SOFTNAMES {							\
64 	"misc",								\
65 	"serial",							\
66 	"net",								\
67 	"clock",							\
68 }
69 
70 #ifdef _KERNEL
71 #ifndef _LOCORE
72 
73 #include <sys/queue.h>
74 #include <sys/types.h>
75 #include <sys/device.h>
76 #include <mips/cpuregs.h>
77 
78 #define NINTR	32
79 
80 struct sgimips_intrhand {
81 	LIST_ENTRY(sgimips_intrhand)
82 		ih_q;
83 	int	(*ih_fun) (void *);
84 	void	 *ih_arg;
85 	struct	sgimips_intr *ih_intrhead;
86 	int	ih_pending;
87 };
88 
89 struct sgimips_intr {
90 	LIST_HEAD(,sgimips_intrhand)
91 		intr_q;
92 	struct	evcnt ih_evcnt;
93 	unsigned long intr_ipl;
94 };
95 
96 extern struct sgimips_intrhand intrtab[];
97 
98 extern int		_splraise(int);
99 extern int		_spllower(int);
100 extern int		_splset(int);
101 extern int		_splget(void);
102 extern void		_splnone(void);
103 extern void		_setsoftintr(int);
104 extern void		_clrsoftintr(int);
105 
106 extern u_int32_t 	biomask;
107 extern u_int32_t 	netmask;
108 extern u_int32_t 	ttymask;
109 extern u_int32_t 	clockmask;
110 
111 #define splhigh()	_splraise(MIPS_INT_MASK)
112 #define spl0()		(void)_spllower(0)
113 #define splx(s)		(void)_splset(s)
114 #define splbio()	_splraise(biomask)
115 #define splnet()	_splraise(netmask)
116 #define spltty()	_splraise(ttymask)
117 #define splvm()		spltty()
118 #define splclock()	_splraise(clockmask)
119 #define splstatclock()	splclock()
120 
121 #define	splsched()	splhigh()
122 #define	spllock()	splhigh()
123 #define splserial()	spltty()
124 #define spllpt()	spltty()
125 
126 #define splsoft()	_splraise(MIPS_SOFT_INT_MASK_1)
127 #define splsoftclock()	splsoft()
128 #define splsoftnet()	splsoft()
129 
130 #define spllowersoftclock() _spllower(MIPS_SOFT_INT_MASK_1)
131 
132 extern void *		cpu_intr_establish(int, int, int (*)(void *), void *);
133 
134 #include <mips/softintr.h>
135 
136 #endif /* _LOCORE */
137 #endif /* !_KERNEL */
138 
139 #endif	/* !_SGIMIPS_INTR_H_ */
140