xref: /netbsd-src/sys/arch/mac68k/include/intr.h (revision 89c5a767f8fc7a4633b2d409966e2becbb98ff92)
1 /*	$NetBSD: intr.h,v 1.17 1999/11/06 23:05:40 scottr Exp $	*/
2 
3 /*
4  * Copyright (C) 1997 Scott Reynolds
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. The name of the author may not be used to endorse or promote products
16  *    derived from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef _MAC68K_INTR_H_
31 #define _MAC68K_INTR_H_
32 
33 #include <machine/psl.h>
34 
35 #ifdef _KERNEL
36 
37 /* spl0 requires checking for software interrupts */
38 
39 /*
40  * This array contains the appropriate PSL_S|PSL_IPL? values
41  * to raise interrupt priority to the requested level.
42  */
43 extern unsigned short mac68k_ipls[];
44 
45 #define	MAC68K_IPL_SOFT		0
46 #define	MAC68K_IPL_BIO		1
47 #define	MAC68K_IPL_NET		2
48 #define	MAC68K_IPL_TTY		3
49 #define	MAC68K_IPL_IMP		4
50 #define	MAC68K_IPL_AUDIO	5
51 #define	MAC68K_IPL_SERIAL	6
52 #define	MAC68K_IPL_ADB		7
53 #define	MAC68K_IPL_CLOCK	8
54 #define	MAC68K_IPL_STATCLOCK	9
55 #define	MAC68K_IPL_SCHED	10
56 #define	MAC68K_IPL_HIGH		11
57 #define	MAC68K_NIPLS		12
58 
59 /* These spl calls are _not_ to be used by machine-independent code. */
60 #define	spladb()	_splraise(mac68k_ipls[MAC68K_IPL_ADB])
61 #define	splzs()		splserial()
62 
63 /*
64  * These should be used for:
65  * 1) ensuring mutual exclusion (why use processor level?)
66  * 2) allowing faster devices to take priority
67  */
68 #define	spllowersoftclock() spl1()
69 #define	splsoftclock()	_splraise(mac68k_ipls[MAC68K_IPL_SOFT])
70 #define	splsoftnet()	_splraise(mac68k_ipls[MAC68K_IPL_SOFT])
71 #define	spltty()	_splraise(mac68k_ipls[MAC68K_IPL_TTY])
72 #define	splbio()	_splraise(mac68k_ipls[MAC68K_IPL_BIO])
73 #define	splnet()	_splraise(mac68k_ipls[MAC68K_IPL_NET])
74 #define	splimp()	_splraise(mac68k_ipls[MAC68K_IPL_IMP])
75 #define	splaudio()	_splraise(mac68k_ipls[MAC68K_IPL_AUDIO])
76 #define	splclock()	_splraise(mac68k_ipls[MAC68K_IPL_CLOCK])
77 #define	splstatclock()	_splraise(mac68k_ipls[MAC68K_IPL_STATCLOCK])
78 #define	splsched()	_splraise(mac68k_ipls[MAC68K_IPL_SCHED])
79 #define	splserial()	_splraise(mac68k_ipls[MAC68K_IPL_SERIAL])
80 #define	splhigh()	spl7()
81 
82 /* watch out for side effects */
83 #define splx(s)         ((s) & PSL_IPL ? _spl(s) : spl0())
84 
85 /*
86  * simulated software interrupt register
87  */
88 extern volatile u_int8_t ssir;
89 
90 #define	SIR_NET		0x01
91 #define	SIR_CLOCK	0x02
92 #define	SIR_SERIAL	0x04
93 #define SIR_DTMGR	0x08
94 #define SIR_ADB		0x10
95 
96 #define	siron(mask)	\
97 	__asm __volatile ( "orb %1,%0" : "=m" (ssir) : "i" (mask))
98 #define	siroff(mask)	\
99 	__asm __volatile ( "andb %1,%0" : "=m" (ssir) : "ir" (~(mask)));
100 
101 #define	setsoftnet()	siron(SIR_NET)
102 #define	setsoftclock()	siron(SIR_CLOCK)
103 #define	setsoftserial()	siron(SIR_SERIAL)
104 #define	setsoftdtmgr()	siron(SIR_DTMGR)
105 #define	setsoftadb()	siron(SIR_ADB)
106 
107 /* intr.c */
108 void	intr_init __P((void));
109 void	intr_establish __P((int (*)(void *), void *, int));
110 void	intr_disestablish __P((int));
111 void	intr_dispatch __P((int));
112 
113 /* locore.s */
114 int	spl0 __P((void));
115 #endif /* _KERNEL */
116 
117 #endif /* _MAC68K_INTR_H_ */
118