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