psl.h revision 1.12 1 /* $NetBSD: psl.h,v 1.12 1997/01/27 19:41:07 gwr 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 PSL_C
40 #include <m68k/psl.h>
41
42 /* Could define this in the common <m68k/psl.h> instead. */
43
44 #if defined(_KERNEL) && !defined(_LOCORE)
45
46 #ifndef __GNUC__
47 /* No inline, use real function in locore.s */
48 extern int _spl(int new);
49 #else /* GNUC */
50 /*
51 * Define an inline function for PSL manipulation.
52 * This is as close to a macro as one can get.
53 * If not optimizing, the one in locore.s is used.
54 * (See the GCC extensions info document.)
55 */
56 extern __inline__ int _spl(int new)
57 {
58 register int old;
59
60 __asm __volatile (
61 "clrl %0; movew sr,%0; movew %1,sr" :
62 "&=d" (old) : "di" (new));
63 return (old);
64 }
65 #endif /* GNUC */
66
67 /*
68 * The rest of this is sun3 specific, because other ports may
69 * need to do special things in spl0() (i.e. simulate SIR).
70 * Suns have a REAL interrupt register, so spl0() and splx(s)
71 * have no need to check for any simulated interrupts, etc.
72 */
73
74 #define spl0() _spl(PSL_S|PSL_IPL0)
75 #define spl1() _spl(PSL_S|PSL_IPL1)
76 #define spl2() _spl(PSL_S|PSL_IPL2)
77 #define spl3() _spl(PSL_S|PSL_IPL3)
78 #define spl4() _spl(PSL_S|PSL_IPL4)
79 #define spl5() _spl(PSL_S|PSL_IPL5)
80 #define spl6() _spl(PSL_S|PSL_IPL6)
81 #define spl7() _spl(PSL_S|PSL_IPL7)
82 #define splx(x) _spl(x)
83
84 /* IPL used by soft interrupts: netintr(), softclock() */
85 #define splsoftclock() spl1()
86 #define splsoftnet() spl1()
87
88 /* Highest block device (strategy) IPL. */
89 #define splbio() spl2()
90
91 /* Highest network interface IPL. */
92 #define splnet() spl3()
93
94 /* Highest tty device IPL. */
95 #define spltty() spl4()
96
97 /* Requirement: imp >= (highest network, tty, or disk IPL) */
98 #define splimp() spl4()
99
100 /* Intersil clock hardware interrupts (hard-wired at 5) */
101 #define splclock() spl5()
102 #define splstatclock() splclock()
103
104 /* Block out all interrupts (except NMI of course). */
105 #define splhigh() spl7()
106 #define splsched() spl7()
107
108 /* Get current sr value (debug, etc.) */
109 extern int getsr __P((void));
110
111 #endif /* KERNEL && !_LOCORE */
112 #endif /* PSL_C */
113