intr.h revision 1.16
1/*	$NetBSD: intr.h,v 1.16 1999/08/05 18:08:11 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 */
43extern 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_CLOCK	7
53#define	MAC68K_IPL_STATCLOCK	8
54#define	MAC68K_IPL_SCHED	9
55#define	MAC68K_IPL_HIGH		10
56#define	MAC68K_NIPLS		11
57
58/* These spl calls are _not_ to be used by machine-independent code. */
59#define	spladb()	splhigh()
60#define	splzs()		splserial()
61
62/*
63 * These should be used for:
64 * 1) ensuring mutual exclusion (why use processor level?)
65 * 2) allowing faster devices to take priority
66 *
67 * Note that on the Mac, most things are masked at spl1, almost
68 * everything at spl2, and everything but the panic switch and
69 * power at spl4.
70 */
71#define	spllowersoftclock() spl1()
72#define	splsoftclock()	_splraise(mac68k_ipls[MAC68K_IPL_SOFT])
73#define	splsoftnet()	_splraise(mac68k_ipls[MAC68K_IPL_SOFT])
74#define	spltty()	_splraise(mac68k_ipls[MAC68K_IPL_TTY])
75#define	splbio()	_splraise(mac68k_ipls[MAC68K_IPL_BIO])
76#define	splnet()	_splraise(mac68k_ipls[MAC68K_IPL_NET])
77#define	splimp()	_splraise(mac68k_ipls[MAC68K_IPL_IMP])
78#define	splaudio()	_splraise(mac68k_ipls[MAC68K_IPL_AUDIO])
79#define	splclock()	_splraise(mac68k_ipls[MAC68K_IPL_CLOCK])
80#define	splstatclock()	_splraise(mac68k_ipls[MAC68K_IPL_STATCLOCK])
81#define	splsched()	_splraise(mac68k_ipls[MAC68K_IPL_SCHED])
82#define	splserial()	_splraise(mac68k_ipls[MAC68K_IPL_SERIAL])
83#define	splhigh()	spl7()
84
85/* watch out for side effects */
86#define splx(s)         ((s) & PSL_IPL ? _spl(s) : spl0())
87
88/*
89 * simulated software interrupt register
90 */
91extern volatile u_int8_t ssir;
92
93#define	SIR_NET		0x01
94#define	SIR_CLOCK	0x02
95#define	SIR_SERIAL	0x04
96#define SIR_DTMGR	0x08
97#define SIR_ADB		0x10
98
99#define	siron(mask)	\
100	__asm __volatile ( "orb %1,%0" : "=m" (ssir) : "i" (mask))
101#define	siroff(mask)	\
102	__asm __volatile ( "andb %1,%0" : "=m" (ssir) : "ir" (~(mask)));
103
104#define	setsoftnet()	siron(SIR_NET)
105#define	setsoftclock()	siron(SIR_CLOCK)
106#define	setsoftserial()	siron(SIR_SERIAL)
107#define	setsoftdtmgr()	siron(SIR_DTMGR)
108#define	setsoftadb()	siron(SIR_ADB)
109
110/* intr.c */
111void	intr_init __P((void));
112void	intr_establish __P((int (*)(void *), void *, int));
113void	intr_disestablish __P((int));
114void	intr_dispatch __P((int));
115
116/* locore.s */
117int	spl0 __P((void));
118#endif /* _KERNEL */
119
120#endif /* _MAC68K_INTR_H_ */
121