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.

297 lines
5.4 KiB

  1. TITLE XMM_INTERFACE.ASM
  2. NAME XMM_INTERFACE
  3. ;*******************************************************************************
  4. ; ;
  5. ; XMM C Interface Routines ;
  6. ; ;
  7. ; Microsoft Confidential
  8. ; Copyright (C) Microsoft Corporation 1988,1991
  9. ; All Rights Reserved.
  10. ; ;
  11. ;*******************************************************************************
  12. ?PLM=0
  13. ?WIN=0
  14. include cmacros.inc
  15. sBegin Data
  16. XMM_Initialised dw 0
  17. XMM_Control label dword
  18. dw CodeOFFSET XMM_NotInitialised
  19. dw seg _TEXT
  20. sEnd Data
  21. sBegin CODE
  22. assumes cs, CODE
  23. assumes ds, DGROUP
  24. ;
  25. ; Macro to convert from XMS success/fail to
  26. ; a form more acceptable for C. IE.
  27. ;
  28. ; AX == 1 becomes DX:AX = 0
  29. ; AX != 1 becomes DX:AX = BL << 24 | (AX - 1)
  30. ;
  31. ; Since Error Codes returned in BL have the top bit
  32. ; set, C will interpret the return as negative.
  33. ;
  34. SuccessFail macro
  35. local Success
  36. xor dx, dx
  37. dec ax
  38. jz Success
  39. mov dh, bl
  40. Success:
  41. endm
  42. ;
  43. ; Macro to convert from XMS return value in AX
  44. ; a form more acceptable for C. IE.
  45. ;
  46. ; AX != 0 becomes DX:AX = AX
  47. ; AX == 0 becomes DX:AX = BL << 24 | AX
  48. ;
  49. ; Since Error Codes returned in BL have the top bit
  50. ; set, C will interpret the return as negative.
  51. ; XMS returns of this type return BL == 0 on success.
  52. ;
  53. SuccessFailAX macro
  54. local Success
  55. xor dx, dx
  56. or ax, ax
  57. jnz Success
  58. mov dh, bl
  59. Success:
  60. endm
  61. ;
  62. ; Macro to convert from XMS return value in DX
  63. ; a form more acceptable for C. IE.
  64. ;
  65. ; AX != 0 becomes DX:AX = DX
  66. ; AX == 0 becomes DX:AX = BL << 24 | DX
  67. ;
  68. ; Since Error Codes returned in BL have the top bit
  69. ; set, C will interpret the return as negative.
  70. ; XMS returns of this type return BL == 0 on success.
  71. ;
  72. SuccessFailDX macro
  73. local Success
  74. or ax, ax
  75. mov ax, dx
  76. mov dx, 0 ; Preserves Flags
  77. jnz Success
  78. mov dh, bl
  79. Success:
  80. endm
  81. cProc XMM_NotInitialised, <FAR>
  82. cBegin
  83. xor ax, ax ; Immediate failure
  84. mov bl, 80h ; Not Implemented
  85. cEnd
  86. cProc XMM_Installed, <NEAR, PUBLIC>, <si, di>
  87. cBegin
  88. cmp [XMM_Initialised], 0
  89. jne Already_Initialised
  90. mov ax, 4300h ; Test for XMM
  91. int 2fh
  92. cmp al, 80h
  93. jne NoDriver
  94. mov ax, 4310h ; Get Control Function
  95. int 2fh
  96. mov word ptr [XMM_Control], bx
  97. mov word ptr [XMM_Control+2], es
  98. inc [XMM_Initialised]
  99. NoDriver:
  100. Already_Initialised:
  101. mov ax, [XMM_Initialised]
  102. cEnd
  103. cProc XMM_Version, <NEAR, PUBLIC>, <si, di>
  104. cBegin
  105. xor ah, ah ; Function 0
  106. call [XMM_Control]
  107. mov dx, bx ; Return a long
  108. cEnd
  109. ;
  110. ; long XMM_RequestHMA(Space_Needed: unsigned short);
  111. ;
  112. cProc XMM_RequestHMA, <NEAR, PUBLIC>, <si, di>
  113. parmW Space_Needed
  114. cBegin
  115. mov ah, 1
  116. mov dx, Space_Needed
  117. call [XMM_Control]
  118. SuccessFail
  119. cEnd
  120. cProc XMM_ReleaseHMA, <NEAR, PUBLIC>, <si, di>
  121. cBegin
  122. mov ah, 2
  123. call [XMM_Control]
  124. SuccessFail
  125. cEnd
  126. cProc XMM_GlobalEnableA20, <NEAR, PUBLIC>, <si, di>
  127. cBegin
  128. mov ah, 3
  129. call [XMM_Control]
  130. SuccessFail
  131. cEnd
  132. cProc XMM_GlobalDisableA20, <NEAR, PUBLIC>, <si, di>
  133. cBegin
  134. mov ah, 4
  135. call [XMM_Control]
  136. SuccessFail
  137. cEnd
  138. cProc XMM_EnableA20, <NEAR, PUBLIC>, <si, di>
  139. cBegin
  140. mov ah, 5
  141. call [XMM_Control]
  142. SuccessFail
  143. cEnd
  144. cProc XMM_DisableA20, <NEAR, PUBLIC>, <si, di>
  145. cBegin
  146. mov ah, 6
  147. call [XMM_Control]
  148. SuccessFail
  149. cEnd
  150. cProc XMM_QueryA20, <NEAR, PUBLIC>, <si, di>
  151. cBegin
  152. mov ah, 7
  153. call [XMM_Control]
  154. SuccessFailAX
  155. cEnd
  156. cProc XMM_QueryLargestFree, <NEAR, PUBLIC>, <si, di>
  157. cBegin
  158. mov ah, 8
  159. call [XMM_Control]
  160. SuccessFailAX
  161. cEnd
  162. cProc XMM_QueryTotalFree, <NEAR, PUBLIC>, <si, di>
  163. cBegin
  164. mov ah, 8
  165. call [XMM_Control]
  166. SuccessFailDX
  167. cEnd
  168. cProc XMM_AllocateExtended, <NEAR, PUBLIC>, <si, di>
  169. parmW SizeK
  170. cBegin
  171. mov ah, 9
  172. mov dx, SizeK
  173. call [XMM_Control]
  174. SuccessFailDX
  175. cEnd
  176. cProc XMM_FreeExtended, <NEAR, PUBLIC>, <si, di>
  177. parmW Handle
  178. cBegin
  179. mov ah, 0Ah
  180. mov dx, Handle
  181. call [XMM_Control]
  182. SuccessFail
  183. cEnd
  184. cProc XMM_MoveExtended, <NEAR, PUBLIC>, <si, di>
  185. parmW pInfo
  186. cBegin
  187. mov ah, 0Bh
  188. mov si, pInfo ; DS:SI => Description
  189. call [XMM_Control]
  190. SuccessFail
  191. cEnd
  192. cProc XMM_LockExtended, <NEAR, PUBLIC>, <si, di>
  193. parmW Handle
  194. cBegin
  195. mov ah, 0Ch
  196. mov dx, Handle
  197. call [XMM_Control]
  198. xchg ax, bx
  199. dec bx
  200. jz XMML_Success
  201. mov dh, al
  202. XMML_Success:
  203. cEnd
  204. cProc XMM_UnLockExtended, <NEAR, PUBLIC>, <si, di>
  205. parmW Handle
  206. cBegin
  207. mov ah, 0Dh
  208. mov dx, Handle
  209. call [XMM_Control]
  210. SuccessFail
  211. cEnd
  212. cProc XMM_GetHandleLength, <NEAR, PUBLIC>, <si, di>
  213. parmW Handle
  214. cBegin
  215. mov ah, 0Eh
  216. mov dx, Handle
  217. call [XMM_Control]
  218. SuccessFailDX
  219. cEnd
  220. cProc XMM_GetHandleInfo, <NEAR, PUBLIC>, <si, di>
  221. parmW Handle
  222. cBegin
  223. mov ah, 0Eh
  224. mov dx, Handle
  225. call [XMM_Control]
  226. mov dx, bx
  227. SuccessFailDX
  228. cEnd
  229. cProc XMM_ReallocateExtended, <NEAR, PUBLIC>, <si, di>
  230. parmW Handle
  231. parmW NewSize
  232. cBegin
  233. mov ah, 0Fh
  234. mov dx, Handle
  235. mov bx, NewSize
  236. call [XMM_Control]
  237. SuccessFail
  238. cEnd
  239. cProc XMM_RequestUMB, <NEAR, PUBLIC>, <si, di>
  240. parmW UMBSize
  241. cBegin
  242. mov ah, 10h
  243. mov dx, UMBSize
  244. call [XMM_Control]
  245. xchg bx, ax ; Segment in AX, Size in DX
  246. dec bx
  247. jz RUMB_Success
  248. xchg ax, dx ; Largest available size in AX
  249. mov dh, dl ; Error code now in DH
  250. RUMB_Success:
  251. cEnd
  252. cProc XMM_ReleaseUMB, <NEAR, PUBLIC>, <si, di>
  253. parmW UMBSegment
  254. cBegin
  255. mov ah, 11h
  256. mov dx, UMBSegment
  257. call [XMM_Control]
  258. SuccessFail
  259. cEnd
  260. sEnd CODE
  261. END
  262.