Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
2.9 KiB

  1. ifdef WOW
  2. DPMICALL MACRO callno
  3. mov ax, callno
  4. call DPMIProc
  5. ENDM
  6. else
  7. DPMICALL MACRO func
  8. mov ax, func
  9. int 31h
  10. ENDM
  11. endif; WOW
  12. RING equ 3 ; RING 1 we be
  13. SEL_LDT equ 4
  14. SEG_RING equ (RING+SEL_LDT)
  15. SEG_RING_MASK equ 7
  16. IS_SELECTOR equ 1 ; Selectors are odd, handles even
  17. ; Bits in dsc_access
  18. DSC_PRESENT equ 80h
  19. DSC_CODEDATA equ 10h ; Code or data descriptor
  20. DSC_RING equ (RING SHL 5)
  21. DSC_CODE equ (1Bh+DSC_RING) ; Code, readable, accessed
  22. DSC_CODE_BIT equ 08h ; Identifies code
  23. DSC_RW_BIT equ 02h ; Code readable, data writable bit
  24. DSC_DATA equ (13h+DSC_RING) ; Data, writable, accessed
  25. DSC_ACCESSED equ 01h ; Segment was accessed
  26. DSC_USED equ 0Fh ; Access rights to mark descriptor used
  27. ; Bits in dsc_hlimit
  28. DSC_GRANULARITY equ 80h ; Page granularity segment
  29. DSC_DEFAULT equ 40h ; Default word size
  30. DSC_DISCARDABLE equ 10h ; Available bit in descriptor
  31. ; (using access as a word)
  32. GDT_FREEDSC equ -1
  33. GDT_NPDSC equ 07FFFh
  34. if PMODE
  35. if PMODE32
  36. GA_ALIGN_BYTES = (((GA_ALIGN+1) SHL 4) - 1)
  37. GA_MASK_BYTES = (NOT GA_ALIGN_BYTES)
  38. endif
  39. endif
  40. DscPtr struc ;Descriptor
  41. dsc_limit dw ? ;Descriptor max length
  42. dsc_lbase dw ? ;Descriptor base bits 15-0
  43. dsc_mbase db ? ;Descriptor base bits 23-16
  44. dsc_access db ? ;Descriptor access byte
  45. dsc_hlimit db ? ;High limit, granularity and 2 custom bits
  46. dsc_hbase db ? ;Descriptor base bits 31-24
  47. DscPtr ends
  48. DSC_LEN equ (size DscPtr)
  49. .ERRNZ DSC_LEN-8 ; Paranoia
  50. dsc386 equ word ptr dsc_hlimit
  51. dsc_owner equ word ptr dsc_limit
  52. if PMODE
  53. if PMODE32
  54. GENTER32 MACRO
  55. push esi
  56. push edi
  57. call genter
  58. mov gs, di
  59. ENDM
  60. GLEAVE32 MACRO
  61. mov es, di ; Zero ES for now
  62. mov fs, di ; And FS
  63. call gleave
  64. pop edi
  65. pop esi
  66. ENDM
  67. MIN_FREE_ARENAS equ 30h ; Minimum number of free arenas desired
  68. ARENA_INCR_BYTES equ 8192 ; Space for more arenas
  69. endif
  70. endif
  71. if PMODE
  72. ife RING-3
  73. ;
  74. ; Change selector or handle to a handle
  75. ; Handles are RING 2
  76. ; Selectors are RING 3
  77. ;
  78. Sel_To_Handle MACRO xsel
  79. and xsel, NOT 1
  80. ENDM
  81. ;
  82. ; Change handle or selector to a selector
  83. ;
  84. Handle_To_Sel MACRO xsel
  85. or xsel, 1
  86. ENDM
  87. ;
  88. ; Change known selector into corresponding handle
  89. ;
  90. StoH MACRO sel
  91. dec sel
  92. ENDM
  93. ;
  94. ; Change known handle into corresponding selector
  95. ;
  96. HtoS MACRO h
  97. inc h
  98. ENDM
  99. ;
  100. ; Given a segment limit, calculate the
  101. ; number of selectors in the array
  102. ;
  103. Limit_To_Selectors MACRO reg
  104. shr reg, 16 ; Now divide by 64k to get # of selectors - 1
  105. inc reg
  106. ENDM
  107. endif
  108. ife RING-1
  109. ;
  110. ; Change selector or handle to a handle
  111. ; Handles are RING 2
  112. ; Selectors are RING 1
  113. ;
  114. Sel_To_Handle MACRO xsel
  115. test xsel, 1
  116. jz short @F
  117. inc xsel
  118. @@:
  119. ENDM
  120. ;
  121. ; Change handle or selector to a selector
  122. ;
  123. Handle_To_Sel MACRO xsel
  124. test xsel, 1
  125. jnz short @F
  126. dec xsel
  127. @@:
  128. ENDM
  129. ;
  130. ; Change known selector into corresponding handle
  131. ;
  132. StoH MACRO sel
  133. inc sel
  134. ENDM
  135. ;
  136. ; Change known handle into corresponding selector
  137. ;
  138. HtoS MACRO h
  139. dec h
  140. ENDM
  141. endif
  142. IsFixed MACRO xh
  143. test xh, 1
  144. ENDM
  145. endif ; PMODE