Home | History | Annotate | Line # | Download | only in include
psl.h revision 1.9
      1  1.9  briggs /*	$NetBSD: psl.h,v 1.9 1996/05/19 04:30:32 briggs Exp $	*/
      2  1.1  briggs 
      3  1.5  briggs #ifndef PSL_C
      4  1.3  briggs #include <m68k/psl.h>
      5  1.5  briggs 
      6  1.5  briggs #if defined(_KERNEL) && !defined(_LOCORE)
      7  1.5  briggs /*
      8  1.5  briggs  * spl functions; all but spl0 are done in-line
      9  1.5  briggs  */
     10  1.5  briggs 
     11  1.5  briggs #define _spl(s) \
     12  1.5  briggs ({ \
     13  1.5  briggs         register int _spl_r; \
     14  1.5  briggs \
     15  1.5  briggs         __asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \
     16  1.5  briggs                 "&=d" (_spl_r) : "di" (s)); \
     17  1.5  briggs         _spl_r; \
     18  1.5  briggs })
     19  1.5  briggs 
     20  1.5  briggs /* spl0 requires checking for software interrupts */
     21  1.5  briggs #define spl1()  _spl(PSL_S|PSL_IPL1)
     22  1.5  briggs #define spl2()  _spl(PSL_S|PSL_IPL2)
     23  1.5  briggs #define spl3()  _spl(PSL_S|PSL_IPL3)
     24  1.5  briggs #define spl4()  _spl(PSL_S|PSL_IPL4)
     25  1.5  briggs #define spl5()  _spl(PSL_S|PSL_IPL5)
     26  1.5  briggs #define spl6()  _spl(PSL_S|PSL_IPL6)
     27  1.5  briggs #define spl7()  _spl(PSL_S|PSL_IPL7)
     28  1.5  briggs 
     29  1.7  scottr /*
     30  1.7  scottr  * These should be used for:
     31  1.7  scottr  * 1) ensuring mutual exclusion (why use processor level?)
     32  1.7  scottr  * 2) allowing faster devices to take priority
     33  1.7  scottr  *
     34  1.7  scottr  * Note that on the Mac, most things are masked at spl1, almost
     35  1.7  scottr  * everything at spl2, and everything but the panic switch and
     36  1.7  scottr  * power at spl4.
     37  1.5  briggs  */
     38  1.7  scottr #define	splsoftclock()	spl1()	/* disallow softclock */
     39  1.7  scottr #define	splsoftnet()	spl1()	/* disallow network */
     40  1.7  scottr #define	spltty()	spl1()	/* disallow tty (softserial & ADB) */
     41  1.7  scottr #define	splbio()	spl2()	/* disallow block I/O */
     42  1.7  scottr #define	splnet()	spl2()	/* disallow network */
     43  1.7  scottr #define	splimp()	spl2()	/* disallow goblins and other nonsense */
     44  1.7  scottr #define	splclock()	spl2()	/* disallow clock (and other) interrupts */
     45  1.7  scottr #define	splstatclock()	spl2()	/* ditto */
     46  1.9  briggs #define	splzs()		spl4()	/* disallow serial hw interrupts */
     47  1.7  scottr #define	splhigh()	spl7()	/* disallow everything */
     48  1.7  scottr #define	splsched()	spl7()	/* disallow scheduling */
     49  1.5  briggs 
     50  1.5  briggs /* watch out for side effects */
     51  1.5  briggs #define splx(s)         ((s) & PSL_IPL ? _spl(s) : spl0())
     52  1.6  briggs 
     53  1.6  briggs int	spl0 __P((void));
     54  1.5  briggs 
     55  1.5  briggs #endif /* _KERNEL && !_LOCORE */
     56  1.5  briggs 
     57  1.5  briggs #endif /* ndef PSL_C */
     58