xref: /netbsd-src/sys/arch/sun3/include/intr.h (revision fad4c9f71477ae11cea2ee75ec82151ac770a534)
1 /*	$NetBSD: intr.h,v 1.7 2006/03/29 08:55:40 yamt Exp $	*/
2 
3 /*-
4  * Copyright (c) 1996 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Gordon W. Ross.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *        This product includes software developed by the NetBSD
21  *        Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #ifndef _SUN3_INTR_H_
40 #define _SUN3_INTR_H_ 1
41 
42 #include <machine/psl.h>
43 
44 #if defined(_KERNEL) && !defined(_LOCORE)
45 
46 #define	IPL_NONE	0
47 #define	IPL_SOFTCLOCK	(PSL_S|PSL_IPL1)
48 #define	IPL_SOFTNET	(PSL_S|PSL_IPL1)
49 #define	IPL_BIO		(PSL_S|PSL_IPL2)
50 #define	IPL_NET		(PSL_S|PSL_IPL3)
51 #define	IPL_TTY		(PSL_S|PSL_IPL4)
52 #define	IPL_VM		(PSL_S|PSL_IPL4)
53 /* Intersil clock hardware interrupts (hard-wired at 5) */
54 #define	IPL_CLOCK	(PSL_S|PSL_IPL5)
55 #define	IPL_STATCLOCK	IPL_CLOCK
56 #define	IPL_SCHED	(PSL_S|PSL_IPL7)
57 #define	IPL_HIGH	(PSL_S|PSL_IPL7)
58 #define	IPL_LOCK	(PSL_S|PSL_IPL7)
59 #define	IPL_SERIAL	(PSL_S|PSL_IPL4)
60 
61 /*
62  * Define inline functions for PSL manipulation.
63  * These are as close to macros as one can get.
64  * When not optimizing gcc will call the locore.s
65  * functions by the same names, so breakpoints on
66  * these functions will work normally, etc.
67  * (See the GCC extensions info document.)
68  */
69 
70 static __inline int _getsr(void);
71 
72 /* Get current sr value. */
73 static __inline int
74 _getsr(void)
75 {
76 	int rv;
77 
78 	__asm volatile ("clrl %0; movew %%sr,%0" : "=&d" (rv));
79 	return (rv);
80 }
81 
82 /*
83  * The rest of this is sun3 specific, because other ports may
84  * need to do special things in spl0() (i.e. simulate SIR).
85  * Suns have a REAL interrupt register, so spl0() and splx(s)
86  * have no need to check for any simulated interrupts, etc.
87  */
88 
89 #define spl0()  _spl0()		/* we have real software interrupts */
90 #define splx(x)	_spl(x)
91 
92 /* IPL used by soft interrupts: netintr(), softclock() */
93 #define	spllowersoftclock() spl1()
94 
95 #define	splraiseipl(x)	_splraise(x)
96 
97 #include <sys/spl.h>
98 
99 #endif	/* KERNEL && !_LOCORE */
100 #endif	/* _SUN3_INTR_H_ */
101