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