Home | History | Annotate | Line # | Download | only in include
psl.h revision 1.15.2.4
      1  1.15.2.4   bouyer /*	$NetBSD: psl.h,v 1.15.2.4 2001/04/21 17:54:59 bouyer 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.12      gwr  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30      1.12      gwr  * BE 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.15  thorpej #ifndef _SUN3_PSL_H_
     40      1.15  thorpej #define	_SUN3_PSL_H_
     41      1.15  thorpej 
     42       1.2      cgd #include <m68k/psl.h>
     43       1.6      gwr 
     44       1.6      gwr /* Could define this in the common <m68k/psl.h> instead. */
     45       1.6      gwr 
     46       1.9  mycroft #if defined(_KERNEL) && !defined(_LOCORE)
     47       1.6      gwr 
     48       1.6      gwr /*
     49      1.13      gwr  * Define inline functions for PSL manipulation.
     50      1.13      gwr  * These are as close to macros as one can get.
     51      1.13      gwr  * When not optimizing gcc will call the locore.s
     52      1.13      gwr  * functions by the same names, so breakpoints on
     53      1.13      gwr  * these functions will work normally, etc.
     54       1.6      gwr  * (See the GCC extensions info document.)
     55       1.6      gwr  */
     56      1.13      gwr 
     57      1.14   kleink static __inline int _getsr __P((void));
     58      1.14   kleink 
     59      1.13      gwr /* Get current sr value. */
     60      1.14   kleink static __inline int
     61      1.13      gwr _getsr(void)
     62      1.13      gwr {
     63      1.13      gwr 	register int rv;
     64      1.13      gwr 
     65  1.15.2.3   bouyer 	__asm __volatile ("clrl %0; movew %%sr,%0" : "&=d" (rv));
     66      1.13      gwr 	return (rv);
     67      1.13      gwr }
     68      1.13      gwr 
     69       1.6      gwr /*
     70       1.6      gwr  * The rest of this is sun3 specific, because other ports may
     71       1.6      gwr  * need to do special things in spl0() (i.e. simulate SIR).
     72       1.6      gwr  * Suns have a REAL interrupt register, so spl0() and splx(s)
     73       1.6      gwr  * have no need to check for any simulated interrupts, etc.
     74       1.6      gwr  */
     75       1.6      gwr 
     76      1.15  thorpej #define spl0()  _spl0()		/* we have real software interrupts */
     77       1.6      gwr #define splx(x)	_spl(x)
     78       1.6      gwr 
     79       1.6      gwr /* IPL used by soft interrupts: netintr(), softclock() */
     80      1.15  thorpej #define	spllowersoftclock() spl1()
     81      1.15  thorpej #define splsoftclock()  splraise1()
     82      1.15  thorpej #define splsoftnet()    splraise1()
     83       1.6      gwr 
     84       1.6      gwr /* Highest block device (strategy) IPL. */
     85      1.15  thorpej #define splbio()        splraise2()
     86       1.6      gwr 
     87       1.6      gwr /* Highest network interface IPL. */
     88      1.15  thorpej #define splnet()        splraise3()
     89       1.6      gwr 
     90       1.6      gwr /* Highest tty device IPL. */
     91      1.15  thorpej #define spltty()        splraise4()
     92       1.6      gwr 
     93      1.13      gwr /*
     94      1.13      gwr  * Requirement: imp >= (highest network, tty, or disk IPL)
     95  1.15.2.2   bouyer  * This is used mostly in the VM code.
     96      1.13      gwr  * Note that the VM code runs at spl7 during kernel
     97      1.13      gwr  * initialization, and later at spl0, so we have to
     98      1.13      gwr  * use splraise to avoid enabling interrupts early.
     99      1.13      gwr  */
    100  1.15.2.2   bouyer #define splvm()         _splraise(PSL_S|PSL_IPL4)
    101       1.6      gwr 
    102       1.6      gwr /* Intersil clock hardware interrupts (hard-wired at 5) */
    103      1.15  thorpej #define splclock()      splraise5()
    104       1.6      gwr #define splstatclock()  splclock()
    105       1.6      gwr 
    106       1.6      gwr /* Block out all interrupts (except NMI of course). */
    107       1.6      gwr #define splhigh()       spl7()
    108       1.6      gwr #define splsched()      spl7()
    109  1.15.2.1   bouyer #define spllock()	spl7()
    110       1.6      gwr 
    111       1.9  mycroft #endif	/* KERNEL && !_LOCORE */
    112      1.15  thorpej #endif /* _SUN3_PSL_H_ */
    113