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.

326 lines
5.7 KiB

  1. ;++
  2. ;
  3. ; Copyright (c) 1989 Microsoft Corporation
  4. ;
  5. ; Module Name:
  6. ;
  7. ; intmac.inc
  8. ;
  9. ; Abstract:
  10. ;
  11. ; This module contains macros to allow code running in 16 bit protected
  12. ; mode to manipulate the virtual interrupt flag
  13. ;
  14. ; Author:
  15. ;
  16. ; Dave Hastings (daveh) 24-Apr-1992
  17. ;
  18. ; Revision History:
  19. ;
  20. ;--
  21. VDM_INT_TRAP_GATE EQU 00000000h
  22. VDM_INT_INT_GATE EQU 00000001h
  23. VDM_INT_32 EQU 00000002h
  24. VDM_INT_16 EQU 00000000h
  25. EFLAGS_VIF equ 080000H
  26. ifdef WOW_x86
  27. include vint.inc
  28. riret macro
  29. local a,b,c,d
  30. push bp
  31. mov bp,sp
  32. push ax
  33. push ds
  34. mov ax,40h
  35. mov ds,ax
  36. mov ax,[bp+6]
  37. test ax,200h
  38. jz a
  39. test ds:FIXED_NTVDMSTATE_REL40,RI_BIT_MASK
  40. jz c
  41. sti
  42. c: lock or word ptr ds:FIXED_NTVDMSTATE_REL40, VIRTUAL_INTERRUPT_BIT
  43. jmp short b
  44. a:
  45. test ds:FIXED_NTVDMSTATE_REL40,RI_BIT_MASK
  46. jz d
  47. cli
  48. d: lock and word ptr ds:FIXED_NTVDMSTATE_REL40,NOT VIRTUAL_INTERRUPT_BIT
  49. b:
  50. pop ds
  51. pop ax
  52. pop bp
  53. iret
  54. endm
  55. riretd macro
  56. local a,b,c,d
  57. push bp
  58. mov bp,sp
  59. push ax
  60. push ds
  61. mov ax,40h
  62. mov ds,ax
  63. mov ax,[bp+10]
  64. test ax,200h
  65. jz a
  66. test ds:FIXED_NTVDMSTATE_REL40,RI_BIT_MASK
  67. jz c
  68. sti
  69. c: lock or word ptr ds:FIXED_NTVDMSTATE_REL40, VIRTUAL_INTERRUPT_BIT
  70. jmp short b
  71. a:
  72. test ds:FIXED_NTVDMSTATE_REL40,RI_BIT_MASK
  73. jz d
  74. cli
  75. d: lock and word ptr ds:FIXED_NTVDMSTATE_REL40,NOT VIRTUAL_INTERRUPT_BIT
  76. b:
  77. pop ds
  78. pop ax
  79. pop bp
  80. iretd
  81. endm
  82. riretd32 macro
  83. local a,b,c,d
  84. push ebp
  85. mov ebp,esp
  86. push ax
  87. push ds
  88. mov ax,40h
  89. mov ds,ax
  90. mov ax,[ebp+0ch]
  91. test ax,200h
  92. jz a
  93. test ds:FIXED_NTVDMSTATE_REL40,RI_BIT_MASK
  94. jz c
  95. sti
  96. c: lock or word ptr ds:FIXED_NTVDMSTATE_REL40, VIRTUAL_INTERRUPT_BIT
  97. jmp short b
  98. a:
  99. test ds:FIXED_NTVDMSTATE_REL40,RI_BIT_MASK
  100. jz d
  101. cli
  102. d: lock and word ptr ds:FIXED_NTVDMSTATE_REL40,NOT VIRTUAL_INTERRUPT_BIT
  103. b:
  104. pop ds
  105. pop ax
  106. pop ebp
  107. iretd
  108. endm
  109. rpopf macro
  110. local a,b,c,d
  111. push bp
  112. mov bp,sp
  113. push ax
  114. push ds
  115. mov ax,40h
  116. mov ds,ax
  117. mov ax,[bp+2]
  118. test ax,200h
  119. jz a
  120. test ds:FIXED_NTVDMSTATE_REL40,RI_BIT_MASK
  121. jz c
  122. sti
  123. c: lock or word ptr ds:FIXED_NTVDMSTATE_REL40, VIRTUAL_INTERRUPT_BIT
  124. jmp short b
  125. a:
  126. test ds:FIXED_NTVDMSTATE_REL40,RI_BIT_MASK
  127. jz d
  128. cli
  129. d: lock and word ptr ds:FIXED_NTVDMSTATE_REL40,NOT VIRTUAL_INTERRUPT_BIT
  130. b:
  131. pop ds
  132. pop ax
  133. pop bp
  134. popf
  135. endm
  136. rpopfd macro
  137. local a,b,c,d
  138. push bp
  139. mov bp,sp
  140. push ax
  141. push ds
  142. mov ax,40h
  143. mov ds,ax
  144. mov ax,[bp+2]
  145. test ax,200h
  146. jz a
  147. test ds:FIXED_NTVDMSTATE_REL40,RI_BIT_MASK
  148. jz c
  149. sti
  150. c: lock or word ptr ds:FIXED_NTVDMSTATE_REL40, VIRTUAL_INTERRUPT_BIT
  151. jmp short b
  152. a:
  153. test ds:FIXED_NTVDMSTATE_REL40,RI_BIT_MASK
  154. jz d
  155. cli
  156. d: lock and word ptr ds:FIXED_NTVDMSTATE_REL40,NOT VIRTUAL_INTERRUPT_BIT
  157. b:
  158. pop ds
  159. pop ax
  160. pop bp
  161. popfd
  162. endm
  163. ;
  164. ; The following assume that the RI bit implies a virtual interrupt flag
  165. ; in eflags. See appendix h of the Pentium user's manual
  166. ;
  167. rpushf macro
  168. local a,b,c,d
  169. .386p
  170. pushf
  171. push ebp
  172. mov ebp,esp
  173. push eax
  174. push ds
  175. mov ax,ss
  176. movzx eax,ax
  177. lar eax,eax
  178. test eax,(AB_BIG SHL 8)
  179. jnz @f
  180. movzx ebp,bp
  181. @@:
  182. mov ax,40h
  183. mov ds,ax
  184. mov ax,word ptr ds:FIXED_NTVDMSTATE_REL40
  185. test ax,RI_BIT_MASK
  186. jz c
  187. pushfd
  188. test dword ptr [ebp-10],EFLAGS_VIF
  189. jz d
  190. or word ptr [ebp+4],200h
  191. popfd
  192. jmp b
  193. d:
  194. and word ptr [ebp+4],NOT 200h
  195. popfd
  196. jmp b
  197. c:
  198. test ax,VIRTUAL_INTERRUPT_BIT
  199. jz a
  200. or word ptr [ebp+4],200h
  201. jmp b
  202. a:
  203. and word ptr [ebp+4],NOT 200h
  204. b:
  205. pop ds
  206. pop eax
  207. pop ebp
  208. .286p
  209. endm
  210. rpushfd macro
  211. local a,b,c,d
  212. pushfd
  213. push bp
  214. mov bp,sp
  215. push ax
  216. push ds
  217. mov ax,40h
  218. mov ds,ax
  219. mov ax,word ptr ds:FIXED_NTVDMSTATE_REL40
  220. test ax,RI_BIT_MASK
  221. jz c
  222. test dword ptr [bp+2],EFLAGS_VIF
  223. jz d
  224. or word ptr [bp+2],200h
  225. jmp b
  226. d:
  227. and word ptr [bp+2],NOT 200h
  228. jmp b
  229. c:
  230. test ax,VIRTUAL_INTERRUPT_BIT
  231. jz a
  232. or word ptr [bp+2],200h
  233. jmp b
  234. a:
  235. and word ptr [bp+2],NOT 200h
  236. b:
  237. pop ds
  238. pop ax
  239. pop bp
  240. endm
  241. rpushfd32 macro
  242. local a,b,c,d
  243. pushfd
  244. push ebp
  245. mov ebp,esp
  246. push ax
  247. push ds
  248. mov ax,40h
  249. mov ds,ax
  250. mov ax,word ptr ds:FIXED_NTVDMSTATE_REL40
  251. test ax,RI_BIT_MASK
  252. jz c
  253. test dword ptr [ebp+4],EFLAGS_VIF
  254. jz d
  255. or word ptr [ebp+4],200h
  256. jmp b
  257. d:
  258. and word ptr [ebp+4],NOT 200h
  259. jmp b
  260. c:
  261. test ax,VIRTUAL_INTERRUPT_BIT
  262. jz a
  263. or word ptr [ebp+4],200h
  264. jmp b
  265. a:
  266. and word ptr [ebp+4],NOT 200h
  267. b:
  268. pop ds
  269. pop ax
  270. pop ebp
  271. endm
  272. ELSE
  273. riret macro
  274. iret
  275. endm
  276. riretd macro
  277. iretd
  278. endm
  279. riretd32 macro
  280. iretd
  281. endm
  282. rpopf macro
  283. popf
  284. endm
  285. rpopfd macro
  286. popfd
  287. endm
  288. rpushf macro
  289. pushf
  290. endm
  291. rpushfd macro
  292. pushfd
  293. endm
  294. rpushfd32 macro
  295. pushfd
  296. endm
  297. FCLI macro
  298. cli
  299. endm
  300. FSTI macro
  301. sti
  302. endm
  303. ENDIF