Leaked source code of windows server 2003
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.

354 lines
6.6 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. rpopf386 macro
  110. local a,b,c,d
  111. push ebp
  112. mov ebp,esp
  113. push ax
  114. push ds
  115. mov ax,40h
  116. mov ds,ax
  117. mov ax,[ebp+4]
  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 ebp
  134. popf
  135. endm
  136. rpopf 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. popf
  162. endm
  163. rpopfd macro
  164. local a,b,c,d
  165. push bp
  166. mov bp,sp
  167. push ax
  168. push ds
  169. mov ax,40h
  170. mov ds,ax
  171. mov ax,[bp+2]
  172. test ax,200h
  173. jz a
  174. test ds:FIXED_NTVDMSTATE_REL40,RI_BIT_MASK
  175. jz c
  176. sti
  177. c: lock or word ptr ds:FIXED_NTVDMSTATE_REL40, VIRTUAL_INTERRUPT_BIT
  178. jmp short b
  179. a:
  180. test ds:FIXED_NTVDMSTATE_REL40,RI_BIT_MASK
  181. jz d
  182. cli
  183. d: lock and word ptr ds:FIXED_NTVDMSTATE_REL40,NOT VIRTUAL_INTERRUPT_BIT
  184. b:
  185. pop ds
  186. pop ax
  187. pop bp
  188. popfd
  189. endm
  190. ;
  191. ; The following assume that the RI bit implies a virtual interrupt flag
  192. ; in eflags. See appendix h of the Pentium user's manual
  193. ;
  194. rpushf macro
  195. local a,b,c,d
  196. .386p
  197. pushf
  198. push ebp
  199. mov ebp,esp
  200. push eax
  201. push ds
  202. mov ax,ss
  203. movzx eax,ax
  204. lar eax,eax
  205. test eax,(AB_BIG SHL 8)
  206. jnz @f
  207. movzx ebp,bp
  208. @@:
  209. mov ax,40h
  210. mov ds,ax
  211. mov ax,word ptr ds:FIXED_NTVDMSTATE_REL40
  212. test ax,RI_BIT_MASK
  213. jz c
  214. pushfd
  215. test dword ptr [ebp-10],EFLAGS_VIF
  216. jz d
  217. or word ptr [ebp+4],200h
  218. popfd
  219. jmp b
  220. d:
  221. and word ptr [ebp+4],NOT 200h
  222. popfd
  223. jmp b
  224. c:
  225. test ax,VIRTUAL_INTERRUPT_BIT
  226. jz a
  227. or word ptr [ebp+4],200h
  228. jmp b
  229. a:
  230. and word ptr [ebp+4],NOT 200h
  231. b:
  232. pop ds
  233. pop eax
  234. pop ebp
  235. .286p
  236. endm
  237. rpushfd macro
  238. local a,b,c,d
  239. pushfd
  240. push bp
  241. mov bp,sp
  242. push ax
  243. push ds
  244. mov ax,40h
  245. mov ds,ax
  246. mov ax,word ptr ds:FIXED_NTVDMSTATE_REL40
  247. test ax,RI_BIT_MASK
  248. jz c
  249. test dword ptr [bp+2],EFLAGS_VIF
  250. jz d
  251. or word ptr [bp+2],200h
  252. jmp b
  253. d:
  254. and word ptr [bp+2],NOT 200h
  255. jmp b
  256. c:
  257. test ax,VIRTUAL_INTERRUPT_BIT
  258. jz a
  259. or word ptr [bp+2],200h
  260. jmp b
  261. a:
  262. and word ptr [bp+2],NOT 200h
  263. b:
  264. pop ds
  265. pop ax
  266. pop bp
  267. endm
  268. rpushfd32 macro
  269. local a,b,c,d
  270. pushfd
  271. push ebp
  272. mov ebp,esp
  273. push ax
  274. push ds
  275. mov ax,40h
  276. mov ds,ax
  277. mov ax,word ptr ds:FIXED_NTVDMSTATE_REL40
  278. test ax,RI_BIT_MASK
  279. jz c
  280. test dword ptr [ebp+4],EFLAGS_VIF
  281. jz d
  282. or word ptr [ebp+4],200h
  283. jmp b
  284. d:
  285. and word ptr [ebp+4],NOT 200h
  286. jmp b
  287. c:
  288. test ax,VIRTUAL_INTERRUPT_BIT
  289. jz a
  290. or word ptr [ebp+4],200h
  291. jmp b
  292. a:
  293. and word ptr [ebp+4],NOT 200h
  294. b:
  295. pop ds
  296. pop ax
  297. pop ebp
  298. endm
  299. ELSE
  300. riret macro
  301. iret
  302. endm
  303. riretd macro
  304. iretd
  305. endm
  306. riretd32 macro
  307. iretd
  308. endm
  309. rpopf macro
  310. popf
  311. endm
  312. rpopfd macro
  313. popfd
  314. endm
  315. rpushf macro
  316. pushf
  317. endm
  318. rpushfd macro
  319. pushfd
  320. endm
  321. rpushfd32 macro
  322. pushfd
  323. endm
  324. FCLI macro
  325. cli
  326. endm
  327. FSTI macro
  328. sti
  329. endm
  330. ENDIF