Home | History | Annotate | Line # | Download | only in include
psl.h revision 1.7
      1 /*	$NetBSD: psl.h,v 1.7 1995/08/13 00:31:28 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 	/*
     55 	 * Get the old sr value.
     56 	 * Not volatile so the optimizer can toss it if
     57 	 * the return value of this inline is not used.
     58 	 */
     59 	__asm ("clrl %0; movw sr,%0" : "=d" (old));
     60 	/*
     61 	 * Set the new sr value (status register).
     62 	 * The volatile qualifier prevents the optimizer
     63 	 * from assuming this statement has no effect.
     64 	 */
     65 	__asm __volatile ("movw %0,sr" : : "di" (new));
     66 	return (old);
     67 }
     68 #endif	/* GNUC */
     69 
     70 /*
     71  * The rest of this is sun3 specific, because other ports may
     72  * need to do special things in spl0() (i.e. simulate SIR).
     73  * Suns have a REAL interrupt register, so spl0() and splx(s)
     74  * have no need to check for any simulated interrupts, etc.
     75  */
     76 
     77 #define spl0()  _spl(PSL_S|PSL_IPL0)
     78 #define spl1()  _spl(PSL_S|PSL_IPL1)
     79 #define spl2()  _spl(PSL_S|PSL_IPL2)
     80 #define spl3()  _spl(PSL_S|PSL_IPL3)
     81 #define spl4()  _spl(PSL_S|PSL_IPL4)
     82 #define spl5()  _spl(PSL_S|PSL_IPL5)
     83 #define spl6()  _spl(PSL_S|PSL_IPL6)
     84 #define spl7()  _spl(PSL_S|PSL_IPL7)
     85 #define splx(x)	_spl(x)
     86 
     87 /* IPL used by soft interrupts: netintr(), softclock() */
     88 #define splsoftclock()  spl1()
     89 #define splsoftnet()    spl1()
     90 
     91 /* Highest block device (strategy) IPL. */
     92 #define splbio()        spl2()
     93 
     94 /* Highest network interface IPL. */
     95 #define splnet()        spl3()
     96 
     97 /* Highest tty device IPL. */
     98 #define spltty()        spl4()
     99 
    100 /* Requirement: imp >= (highest network, tty, or disk IPL) */
    101 #define splimp()        spl4()
    102 
    103 /* Intersil clock hardware interrupts (hard-wired at 5) */
    104 #define splclock()      spl5()
    105 #define splstatclock()  splclock()
    106 
    107 /* Zilog Serial hardware interrupts (hard-wired at 6) */
    108 #define splzs()         spl6()
    109 
    110 /* Block out all interrupts (except NMI of course). */
    111 #define splhigh()       spl7()
    112 #define splsched()      spl7()
    113 
    114 #endif	/* KERNEL && !LOCORE */
    115 #endif	/* PSL_C */
    116