xref: /netbsd/sys/arch/mac68k/include/intr.h (revision bf9ec67e)
1 /*	$NetBSD: intr.h,v 1.20 2001/04/13 23:30:00 thorpej 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	splvm()		_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 #define	spllock()	spl7()
82 
83 /* watch out for side effects */
84 #define splx(s)         ((s) & PSL_IPL ? _spl(s) : spl0())
85 
86 /*
87  * simulated software interrupt register
88  */
89 extern volatile u_int8_t ssir;
90 
91 #define	SIR_NET		0x01
92 #define	SIR_CLOCK	0x02
93 #define	SIR_SERIAL	0x04
94 #define SIR_DTMGR	0x08
95 #define SIR_ADB		0x10
96 
97 #define	siron(mask)	\
98 	__asm __volatile ( "orb %1,%0" : "=m" (ssir) : "i" (mask))
99 #define	siroff(mask)	\
100 	__asm __volatile ( "andb %1,%0" : "=m" (ssir) : "ir" (~(mask)));
101 
102 #define	setsoftnet()	siron(SIR_NET)
103 #define	setsoftclock()	siron(SIR_CLOCK)
104 #define	setsoftserial()	siron(SIR_SERIAL)
105 #define	setsoftdtmgr()	siron(SIR_DTMGR)
106 #define	setsoftadb()	siron(SIR_ADB)
107 
108 /* intr.c */
109 void	intr_init __P((void));
110 void	intr_establish __P((int (*)(void *), void *, int));
111 void	intr_disestablish __P((int));
112 void	intr_dispatch __P((int));
113 
114 /* locore.s */
115 int	spl0 __P((void));
116 #endif /* _KERNEL */
117 
118 #endif /* _MAC68K_INTR_H_ */
119