psl.h revision 1.10 1 1.10 gwr /* $NetBSD: psl.h,v 1.10 1996/11/20 18:57:17 gwr Exp $ */
2 1.1 glass
3 1.10 gwr /*-
4 1.10 gwr * Copyright (c) 1996 The NetBSD Foundation, Inc.
5 1.6 gwr * All rights reserved.
6 1.6 gwr *
7 1.10 gwr * This code is derived from software contributed to The NetBSD Foundation
8 1.10 gwr * by Gordon W. Ross.
9 1.10 gwr *
10 1.6 gwr * Redistribution and use in source and binary forms, with or without
11 1.6 gwr * modification, are permitted provided that the following conditions
12 1.6 gwr * are met:
13 1.6 gwr * 1. Redistributions of source code must retain the above copyright
14 1.6 gwr * notice, this list of conditions and the following disclaimer.
15 1.6 gwr * 2. Redistributions in binary form must reproduce the above copyright
16 1.6 gwr * notice, this list of conditions and the following disclaimer in the
17 1.6 gwr * documentation and/or other materials provided with the distribution.
18 1.10 gwr * 3. All advertising materials mentioning features or use of this software
19 1.6 gwr * must display the following acknowledgement:
20 1.10 gwr * This product includes software developed by the NetBSD
21 1.10 gwr * Foundation, Inc. and its contributors.
22 1.10 gwr * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.10 gwr * contributors may be used to endorse or promote products derived
24 1.10 gwr * from this software without specific prior written permission.
25 1.6 gwr *
26 1.10 gwr * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.10 gwr * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.10 gwr * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.10 gwr * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
30 1.10 gwr * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.10 gwr * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.10 gwr * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.10 gwr * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.10 gwr * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.10 gwr * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.10 gwr * POSSIBILITY OF SUCH DAMAGE.
37 1.6 gwr */
38 1.6 gwr
39 1.6 gwr #ifndef PSL_C
40 1.2 cgd #include <m68k/psl.h>
41 1.6 gwr
42 1.6 gwr /* Could define this in the common <m68k/psl.h> instead. */
43 1.6 gwr
44 1.9 mycroft #if defined(_KERNEL) && !defined(_LOCORE)
45 1.6 gwr
46 1.6 gwr #ifndef __GNUC__
47 1.6 gwr /* No inline, use real function in locore.s */
48 1.6 gwr extern int _spl(int new);
49 1.6 gwr #else /* GNUC */
50 1.6 gwr /*
51 1.6 gwr * Define an inline function for PSL manipulation.
52 1.6 gwr * This is as close to a macro as one can get.
53 1.6 gwr * If not optimizing, the one in locore.s is used.
54 1.6 gwr * (See the GCC extensions info document.)
55 1.6 gwr */
56 1.6 gwr extern __inline__ int _spl(int new)
57 1.6 gwr {
58 1.6 gwr register int old;
59 1.6 gwr
60 1.8 gwr __asm __volatile (
61 1.8 gwr "clrl %0; movew sr,%0; movew %1,sr" :
62 1.8 gwr "&=d" (old) : "di" (new));
63 1.6 gwr return (old);
64 1.6 gwr }
65 1.6 gwr #endif /* GNUC */
66 1.6 gwr
67 1.6 gwr /*
68 1.6 gwr * The rest of this is sun3 specific, because other ports may
69 1.6 gwr * need to do special things in spl0() (i.e. simulate SIR).
70 1.6 gwr * Suns have a REAL interrupt register, so spl0() and splx(s)
71 1.6 gwr * have no need to check for any simulated interrupts, etc.
72 1.6 gwr */
73 1.6 gwr
74 1.6 gwr #define spl0() _spl(PSL_S|PSL_IPL0)
75 1.6 gwr #define spl1() _spl(PSL_S|PSL_IPL1)
76 1.6 gwr #define spl2() _spl(PSL_S|PSL_IPL2)
77 1.6 gwr #define spl3() _spl(PSL_S|PSL_IPL3)
78 1.6 gwr #define spl4() _spl(PSL_S|PSL_IPL4)
79 1.6 gwr #define spl5() _spl(PSL_S|PSL_IPL5)
80 1.6 gwr #define spl6() _spl(PSL_S|PSL_IPL6)
81 1.6 gwr #define spl7() _spl(PSL_S|PSL_IPL7)
82 1.6 gwr #define splx(x) _spl(x)
83 1.6 gwr
84 1.6 gwr /* IPL used by soft interrupts: netintr(), softclock() */
85 1.6 gwr #define splsoftclock() spl1()
86 1.7 mycroft #define splsoftnet() spl1()
87 1.6 gwr
88 1.6 gwr /* Highest block device (strategy) IPL. */
89 1.6 gwr #define splbio() spl2()
90 1.6 gwr
91 1.6 gwr /* Highest network interface IPL. */
92 1.6 gwr #define splnet() spl3()
93 1.6 gwr
94 1.6 gwr /* Highest tty device IPL. */
95 1.6 gwr #define spltty() spl4()
96 1.6 gwr
97 1.6 gwr /* Requirement: imp >= (highest network, tty, or disk IPL) */
98 1.6 gwr #define splimp() spl4()
99 1.6 gwr
100 1.6 gwr /* Intersil clock hardware interrupts (hard-wired at 5) */
101 1.6 gwr #define splclock() spl5()
102 1.6 gwr #define splstatclock() splclock()
103 1.6 gwr
104 1.6 gwr /* Zilog Serial hardware interrupts (hard-wired at 6) */
105 1.6 gwr #define splzs() spl6()
106 1.6 gwr
107 1.6 gwr /* Block out all interrupts (except NMI of course). */
108 1.6 gwr #define splhigh() spl7()
109 1.6 gwr #define splsched() spl7()
110 1.6 gwr
111 1.9 mycroft #endif /* KERNEL && !_LOCORE */
112 1.6 gwr #endif /* PSL_C */
113