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.

362 lines
6.8 KiB

  1. title "ix ioaccess"
  2. ;++
  3. ;
  4. ; Copyright (c) 1989 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; ixioacc.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; Procedures to correctly touch I/O registers.
  13. ;
  14. ; Author:
  15. ;
  16. ; Bryan Willman (bryanwi) 16 May 1990
  17. ;
  18. ; Environment:
  19. ;
  20. ; User or Kernel, although privledge (IOPL) may be required.
  21. ;
  22. ; Revision History:
  23. ;
  24. ;--
  25. .386p
  26. include callconv.inc
  27. .list
  28. _TEXT SEGMENT DWORD PUBLIC 'CODE'
  29. ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  30. ;++
  31. ;
  32. ; I/O port space read and write functions.
  33. ;
  34. ; These have to be actual functions on the 386, because we need
  35. ; to use assembler, but cannot return a value if we inline it.
  36. ;
  37. ; This set of functions manipulates I/O registers in PORT space.
  38. ; (Uses x86 in and out instructions)
  39. ;
  40. ; WARNING: Port addresses must always be in the range 0 to 64K, because
  41. ; that's the range the hardware understands.
  42. ;
  43. ;--
  44. ;++
  45. ;
  46. ; UCHAR
  47. ; READ_PORT_UCHAR(
  48. ; PUCHAR Port
  49. ; )
  50. ;
  51. ; Arguments:
  52. ; (esp+4) = Port
  53. ;
  54. ; Returns:
  55. ; Value in Port.
  56. ;
  57. ;--
  58. cPublicProc _READ_PORT_UCHAR,1
  59. mov dx,[esp+4] ; (dx) = Port
  60. in al,dx
  61. stdRET _READ_PORT_UCHAR
  62. stdENDP _READ_PORT_UCHAR
  63. ;++
  64. ;
  65. ; USHORT
  66. ; READ_PORT_USHORT(
  67. ; PUSHORT Port
  68. ; )
  69. ;
  70. ; Arguments:
  71. ; (esp+4) = Port
  72. ;
  73. ; Returns:
  74. ; Value in Port.
  75. ;
  76. ;--
  77. cPublicProc _READ_PORT_USHORT,1
  78. mov dx,[esp+4] ; (dx) = Port
  79. in ax,dx
  80. stdRET _READ_PORT_USHORT
  81. stdENDP _READ_PORT_USHORT
  82. ;++
  83. ;
  84. ; ULONG
  85. ; READ_PORT_ULONG(
  86. ; PULONG Port
  87. ; )
  88. ;
  89. ; Arguments:
  90. ; (esp+4) = Port
  91. ;
  92. ; Returns:
  93. ; Value in Port.
  94. ;
  95. ;--
  96. cPublicProc _READ_PORT_ULONG,1
  97. mov dx,[esp+4] ; (dx) = Port
  98. in eax,dx
  99. stdRET _READ_PORT_ULONG
  100. stdENDP _READ_PORT_ULONG
  101. ;++
  102. ;
  103. ; VOID
  104. ; READ_PORT_BUFFER_UCHAR(
  105. ; PUCHAR Port,
  106. ; PUCHAR Buffer,
  107. ; ULONG Count
  108. ; )
  109. ;
  110. ; Arguments:
  111. ; (esp+4) = Port
  112. ; (esp+8) = Buffer address
  113. ; (esp+12) = Count
  114. ;
  115. ;--
  116. cPublicProc _READ_PORT_BUFFER_UCHAR,3
  117. mov dx,[esp+4] ; (dx) = Port
  118. mov ecx,[esp+12] ; (ecx) = transfer count
  119. push edi
  120. mov edi,[esp+12] ; (edi) = (esp+8+push) = buffer
  121. rep insb
  122. pop edi
  123. stdRET _READ_PORT_BUFFER_UCHAR
  124. stdENDP _READ_PORT_BUFFER_UCHAR
  125. ;++
  126. ;
  127. ; VOID
  128. ; READ_PORT_BUFFER_USHORT(
  129. ; PUSHORT Port,
  130. ; PUSHORT Buffer,
  131. ; ULONG Count
  132. ; )
  133. ;
  134. ; Arguments:
  135. ; (esp+4) = Port
  136. ; (esp+8) = Buffer address
  137. ; (esp+12) = Count
  138. ;
  139. ;--
  140. cPublicProc _READ_PORT_BUFFER_USHORT,3
  141. mov dx,[esp+4] ; (dx) = Port
  142. mov ecx,[esp+12] ; (ecx) = transfer count
  143. push edi
  144. mov edi,[esp+12] ; (edi) = (esp+8+push) = buffer
  145. rep insw
  146. pop edi
  147. stdRET _READ_PORT_BUFFER_USHORT
  148. stdENDP _READ_PORT_BUFFER_USHORT
  149. ;++
  150. ;
  151. ; VOID
  152. ; READ_PORT_BUFFER_ULONG(
  153. ; PULONG Port,
  154. ; PULONG Buffer,
  155. ; ULONG Count
  156. ; )
  157. ;
  158. ; Arguments:
  159. ; (esp+4) = Port
  160. ; (esp+8) = Buffer address
  161. ; (esp+12) = Count
  162. ;
  163. ;--
  164. cPublicProc _READ_PORT_BUFFER_ULONG,3
  165. mov dx,[esp+4] ; (dx) = Port
  166. mov ecx,[esp+12] ; (ecx) = transfer count
  167. push edi
  168. mov edi,[esp+12] ; (edi) = (esp+8+push) = buffer
  169. rep insd
  170. pop edi
  171. stdRET _READ_PORT_BUFFER_ULONG
  172. stdENDP _READ_PORT_BUFFER_ULONG
  173. ;++
  174. ;
  175. ; VOID
  176. ; WRITE_PORT_UCHAR(
  177. ; PUCHAR Port,
  178. ; UCHAR Value
  179. ; )
  180. ;
  181. ; Arguments:
  182. ; (esp+4) = Port
  183. ; (esp+8) = Value
  184. ;
  185. ;--
  186. cPublicProc _WRITE_PORT_UCHAR,2
  187. mov dx,[esp+4] ; (dx) = Port
  188. mov al,[esp+8] ; (al) = Value
  189. out dx,al
  190. stdRET _WRITE_PORT_UCHAR
  191. stdENDP _WRITE_PORT_UCHAR
  192. ;++
  193. ;
  194. ; VOID
  195. ; WRITE_PORT_USHORT(
  196. ; PUSHORT Port,
  197. ; USHORT Value
  198. ; )
  199. ;
  200. ; Arguments:
  201. ; (esp+4) = Port
  202. ; (esp+8) = Value
  203. ;
  204. ;--
  205. cPublicProc _WRITE_PORT_USHORT,2
  206. mov dx,[esp+4] ; (dx) = Port
  207. mov ax,[esp+8] ; (ax) = Value
  208. out dx,ax
  209. stdRET _WRITE_PORT_USHORT
  210. stdENDP _WRITE_PORT_USHORT
  211. ;++
  212. ;
  213. ; VOID
  214. ; WRITE_PORT_ULONG(
  215. ; PULONG Port,
  216. ; ULONG Value
  217. ; )
  218. ;
  219. ; Arguments:
  220. ; (esp+4) = Port
  221. ; (esp+8) = Value
  222. ;
  223. ;--
  224. cPublicProc _WRITE_PORT_ULONG,2
  225. mov dx,[esp+4] ; (dx) = Port
  226. mov eax,[esp+8] ; (eax) = Value
  227. out dx,eax
  228. stdRET _WRITE_PORT_ULONG
  229. stdENDP _WRITE_PORT_ULONG
  230. ;++
  231. ;
  232. ; VOID
  233. ; WRITE_PORT_BUFFER_UCHAR(
  234. ; PUCHAR Port,
  235. ; PUCHAR Buffer,
  236. ; ULONG Count
  237. ; )
  238. ;
  239. ; Arguments:
  240. ; (esp+4) = Port
  241. ; (esp+8) = Buffer address
  242. ; (esp+12) = Count
  243. ;
  244. ;--
  245. cPublicProc _WRITE_PORT_BUFFER_UCHAR,3
  246. mov dx,[esp+4] ; (dx) = Port
  247. mov ecx,[esp+12] ; (ecx) = transfer count
  248. push esi
  249. mov esi,[esp+12] ; (esi) = (esp+8+push) = buffer
  250. rep outsb
  251. pop esi
  252. stdRET _WRITE_PORT_BUFFER_UCHAR
  253. stdENDP _WRITE_PORT_BUFFER_UCHAR
  254. ;++
  255. ;
  256. ; VOID
  257. ; WRITE_PORT_BUFFER_USHORT(
  258. ; PUSHORT Port,
  259. ; PUSHORT Buffer,
  260. ; ULONG Count
  261. ; )
  262. ;
  263. ; Arguments:
  264. ; (esp+4) = Port
  265. ; (esp+8) = Buffer address
  266. ; (esp+12) = Count
  267. ;
  268. ;--
  269. cPublicProc _WRITE_PORT_BUFFER_USHORT,3
  270. mov dx,[esp+4] ; (dx) = Port
  271. mov ecx,[esp+12] ; (ecx) = transfer count
  272. push esi
  273. mov esi,[esp+12] ; (esi) = (esp+8+push) = buffer
  274. rep outsw
  275. pop esi
  276. stdRET _WRITE_PORT_BUFFER_USHORT
  277. stdENDP _WRITE_PORT_BUFFER_USHORT
  278. ;++
  279. ;
  280. ; VOID
  281. ; WRITE_PORT_BUFFER_ULONG(
  282. ; PULONG Port,
  283. ; PULONG Buffer,
  284. ; ULONG Count
  285. ; )
  286. ;
  287. ; Arguments:
  288. ; (esp+4) = Port
  289. ; (esp+8) = Buffer address
  290. ; (esp+12) = Count
  291. ;
  292. ;--
  293. cPublicProc _WRITE_PORT_BUFFER_ULONG,3
  294. mov dx,[esp+4] ; (dx) = Port
  295. mov ecx,[esp+12] ; (ecx) = transfer count
  296. push esi
  297. mov esi,[esp+12] ; (esi) = (esp+8+push) = buffer
  298. rep outsd
  299. pop esi
  300. stdRET _WRITE_PORT_BUFFER_ULONG
  301. stdENDP _WRITE_PORT_BUFFER_ULONG
  302. _TEXT ends
  303. end