home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / kernserv / m68k / spl.h next >
Text File  |  1992-07-29  |  2KB  |  112 lines

  1. /*
  2.  *    File:    spl.h
  3.  *    Author:    Avadis Tevanian, Jr.
  4.  *
  5.  *    Define inline macros for spl routines.
  6.  *    
  7.  * HISTORY
  8.  *
  9.  * 14-May-90  Gregg Kellogg (gk) at NeXT
  10.  *    Changed SPLCLOCK from 6 to 3, as much scheduling code expects
  11.  *    splclock() == splsched().  Added splusclock().
  12.  *
  13.  * 19-Jun-89  Mike DeMoney (mike) at NeXT
  14.  *    Modified to allow spl assertions in spl_measured.h
  15.  */
  16.  
  17. #ifndef    _KERNSERV_M68K_SPL_H_
  18. #define    _KERNSERV_M68K_SPL_H_
  19.  
  20. #ifdef    KERNEL_BUILD
  21. #import <iplmeas.h>
  22. #else    KERNEL_BUILD
  23. #import <mach/features.h>
  24. #endif    KERNEL_BUILD
  25.  
  26. #import <bsd/m68k/psl.h>
  27.  
  28. #if    NIPLMEAS && !defined(NO_IPLMEAS)
  29. #import <machdep/m68k/spl_measured.h>
  30. #endif    NIPLMEAS && !defined(NO_IPLMEAS)
  31.  
  32. #ifndef    SPLU_MACRO
  33.  
  34. #ifdef    ASSEMBLER
  35. #define    SPLU_MACRO(ipl) \
  36.     movw    sr,d0; \
  37.     movw    \#((ipl)*256 + 0x2000),sr;
  38.  
  39. #define    splx(nsr) \
  40.     movw    sr,d0; \
  41.     movw    nsr,sr;
  42.  
  43. #else    ASSEMBLER
  44.  
  45. #define SPLU_MACRO(x) \
  46. ({ register short ret; \
  47.     asm volatile ("movw    sr,%0" : "=dm" (ret)); \
  48.     asm volatile ("movw    %1,sr" : "=m" (*(char *)0): "Jdm" ((short)(x)*256+0x2000)); \
  49.     ret; \
  50. })
  51.  
  52. #define splx(x) \
  53. ({ register short ret; \
  54.     asm volatile ("movw    sr,%0" : "=dm" (ret)); \
  55.     asm volatile ("movw    %1,sr" : "=m" (*(char *)0): "Jdm" ((short)x)); \
  56.     ret; \
  57. })
  58.  
  59. #endif    ASSEMBLER
  60.  
  61. #define    SPLD_MACRO(ipl)    SPLU_MACRO(ipl)
  62. #define    spln(x)        splx(x)
  63.  
  64. #endif    SPLU_MACRO
  65.  
  66. #define ipltospl(ipl)    (SR_SUPER | ((ipl) << 8))
  67.  
  68. /*
  69.  *    Define spls as the usual numbers (which should never be used
  70.  *    directly.
  71.  */
  72.  
  73. #define spl0()    SPLD_MACRO(0)
  74. #define spl1()    SPLU_MACRO(1)
  75. #define spl2()    SPLU_MACRO(2)
  76. #define spl3()    SPLU_MACRO(3)
  77. #define spl4()    SPLU_MACRO(4)
  78. #define spl5()    SPLU_MACRO(5)
  79. #define spl6()    SPLU_MACRO(6)
  80. #define spl7()    SPLU_MACRO(7)
  81.  
  82. /*
  83.  *    Define spl mnemonics.
  84.  */
  85. #define IPLHIGH        7
  86. #define IPLDMA        6
  87. #define IPLUSCLOCK    6
  88. #define IPLSCC        5
  89. #define IPLCLOCK    3
  90. #define IPLBIO        3
  91. #define IPLSCHED    3
  92. #define IPLIMP        3
  93. #define IPLVM        3
  94. #define I$T        2
  95. #define IPLTTY        1
  96. #define IPLSOFTCLOCK    1
  97.  
  98. #define splhigh()    SPLU_MACRO(IPLHIGH)
  99. #define splusclock()    SPLU_MACRO(IPLUSCLOCK)
  100. #define spldma()    SPLU_MACRO(IPLDMA)
  101. #define splscc()    SPLU_MACRO(IPLSCC)
  102. #define splclock()    SPLU_MACRO(IPLCLOCK)
  103. #define splbio()    SPLU_MACRO(IPLBIO)
  104. #define splsched()    SPLU_MACRO(IPLSCHED)
  105. #define splimp()    SPLU_MACRO(IPLIMP)
  106. #define splvm()        SPLU_MACRO(IPLVM)
  107. #define splnet()    SPLU_MACRO(IPLNET)
  108. #define spltty()    SPLU_MACRO(IPLTTY)
  109. #define splsoftclock()    SPLU_MACRO(IPLSOFTCLOCK)
  110.  
  111. #endif    _KERNSERV_M68K_SPL_H_
  112.