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.

546 lines
8.3 KiB

  1. // TITLE ("Memory Fences, Load Acquires and Store Acquires")
  2. /*++
  3. Copyright (c) 1995 Intel Corporation
  4. Module Name:
  5. i64ioasm.s assembly routines for read and write I/O
  6. Abstract:
  7. This module implements the I/O port access routines.
  8. Author:
  9. Bernard Lint, M. Jayakumar 17 Sep '97
  10. Environment:
  11. Kernel mode
  12. Revision History:
  13. --*/
  14. #include "ksia64.h"
  15. #define HAL_RR_PS_VE 0x69
  16. .file "i64ioasm.s"
  17. /*++
  18. VOID
  19. HalpInsertTranslationRegister (
  20. IN UINT_PTR IFA,
  21. IN ULONG SlotNumber,
  22. IN ULONGLONG Attribute,
  23. IN ULONGLONG ITIR
  24. )
  25. Routine Description:
  26. This function fills a fixed entry in TR
  27. N.B. It is assumed that the entry is not in the TB and therefore the TB
  28. is not probed.
  29. Arguements:
  30. (a0) - Supplies the virtual page number to be loaded into IFA.
  31. (a1) - Supplies the slot number to be used for Translation Register.
  32. (a2) - Supplies the attribute and portion of the physical address.
  33. (a3) - Supplies the value to be loaded into ITIR.
  34. Return Value:
  35. None.
  36. --*/
  37. LEAF_ENTRY(HalpInsertTranslationRegister)
  38. // Register aliases
  39. //
  40. rT1 = t3
  41. rT2 = t4
  42. rPKR = t13
  43. rRR = t15
  44. //
  45. // rsm to reset PSR.i bit
  46. //
  47. rsm 1 << PSR_I // reset PSR.i bit
  48. ;;
  49. rsm 1 << PSR_IC // reset PSR.ic bit
  50. ;;
  51. srlz.d // serialize
  52. //
  53. // set RR[0],Region ID (HAL_ RID) = 0x7FFFFF,Page Size (PS) = 8K,
  54. // VHPT enabled (VE) = 1
  55. //
  56. // dep.z rRR= RR_IO_PORT, RR_INDEX, RR_INDEX_LEN
  57. dep.z rRR = 5, RR_INDEX, RR_INDEX_LEN
  58. movl rT2 = (0x7FFFFF << RR_RID) | HAL_RR_PS_VE
  59. ;;
  60. mov rr[rRR] = rT2 // Initialize rr[RR_IOPort]
  61. // Protection Key Registers
  62. mov rPKR = PKRNUM // Total number of key registers
  63. ;;
  64. sub rPKR = rPKR, zero,1 // Choose the last one
  65. movl rT2 = (0x7FFFFF << RR_RID) | PKR_VALID
  66. ;;
  67. mov pkr[rPKR] = rT2
  68. ;;
  69. srlz.i
  70. mov cr.ifa = a0
  71. mov cr.itir = a3
  72. ;;
  73. itr.d dtr[a1] = a2
  74. ssm 1 << PSR_IC // set PSR.ic bit again
  75. ;;
  76. srlz.d // serialize
  77. ssm 1 << PSR_I // set PSR.i bit again
  78. LEAF_RETURN
  79. LEAF_EXIT(HalpInsertTranslationRegister)
  80. /*++
  81. VOID
  82. HalpLoadBufferUCHAR (
  83. PUCHAR VirtualAddress,
  84. PUCHAR Buffer,
  85. UCHAR Count
  86. );
  87. Routine Description:
  88. Arguements:
  89. Return Value:
  90. --*/
  91. LEAF_ENTRY(HalpLoadBufferUCHAR)
  92. .prologue
  93. .save ar.lc, t22
  94. mov t22 = ar.lc
  95. sub a2 = a2,zero,1
  96. ;;
  97. PROLOGUE_END
  98. mov ar.lc = a2
  99. mf
  100. LoadChar:
  101. ld1.acq t1 = [a0]
  102. ;;
  103. st1 [a1] = t1, 1
  104. br.cloop.dptk.few LoadChar
  105. ;;
  106. mf.a
  107. mov ar.lc = t22
  108. LEAF_RETURN
  109. LEAF_EXIT (HalpLoadBufferUCHAR)
  110. /*++
  111. VOID
  112. HalpLoadBufferUSHORT (
  113. PUSHORT VirtualAddress,
  114. PUSHORT Buffer,
  115. ULONG Count
  116. );
  117. Routine Description:
  118. Arguements:
  119. Return Value:
  120. --*/
  121. LEAF_ENTRY(HalpLoadBufferUSHORT)
  122. .prologue
  123. .save ar.lc, t22
  124. mov t22 = ar.lc
  125. sub a2 = a2,zero,1
  126. ;;
  127. PROLOGUE_END
  128. mov ar.lc = a2
  129. mf
  130. LoadShort:
  131. ld2.acq t1 = [a0]
  132. ;;
  133. st2 [a1] = t1, 2
  134. br.cloop.dptk.few LoadShort
  135. ;;
  136. mf.a
  137. mov ar.lc = t22
  138. LEAF_RETURN
  139. LEAF_EXIT (HalpLoadBufferUSHORT)
  140. /*++
  141. VOID
  142. HalpLoadBufferULONG (
  143. PULONG VirtualAddress,
  144. PULONG Buffer,
  145. ULONG Count
  146. );
  147. Routine Description:
  148. Arguements:
  149. Return Value:
  150. --*/
  151. LEAF_ENTRY(HalpLoadBufferULONG)
  152. .prologue
  153. .save ar.lc, t22
  154. mov t22 = ar.lc
  155. sub a2 = a2,zero,1
  156. ;;
  157. PROLOGUE_END
  158. mov ar.lc = a2
  159. mf
  160. LoadLong:
  161. ld4.acq t1 = [a0]
  162. ;;
  163. st4 [a1] = t1, 4
  164. br.cloop.dptk.few LoadLong
  165. ;;
  166. mf.a
  167. mov ar.lc = t22
  168. LEAF_RETURN
  169. LEAF_EXIT (HalpLoadBufferULONG)
  170. /*++
  171. VOID
  172. HalpLoadBufferULONGLONG (
  173. PULONGLONG VirtualAddress,
  174. PULONGLONG Buffer,
  175. ULONG Count
  176. );
  177. Routine Description:
  178. Arguements:
  179. Return Value:
  180. --*/
  181. LEAF_ENTRY(HalpLoadBufferULONGLONG)
  182. .prologue
  183. .save ar.lc, t22
  184. mov t22 = ar.lc
  185. sub a2 = a2,zero,1
  186. ;;
  187. PROLOGUE_END
  188. mov ar.lc = a2
  189. mf
  190. LoadLongLong:
  191. ld8.acq t1 = [a0]
  192. ;;
  193. st8 [a1] = t1, 8
  194. br.cloop.dptk.few LoadLongLong
  195. ;;
  196. mf.a
  197. mov ar.lc = t22
  198. LEAF_RETURN
  199. LEAF_EXIT (HalpLoadBufferULONGLONG)
  200. /*++
  201. VOID
  202. HalpStoreBufferUCHAR (
  203. PUCHAR VirtualAddress,
  204. PUCHAR Buffer,
  205. ULONG Count
  206. );
  207. Routine Description:
  208. Arguements:
  209. Return Value:
  210. --*/
  211. LEAF_ENTRY(HalpStoreBufferUCHAR)
  212. .prologue
  213. .save ar.lc, t22
  214. mov t22 = ar.lc
  215. sub a2 = a2,zero,1
  216. ;;
  217. PROLOGUE_END
  218. mov ar.lc = a2
  219. StoreChar:
  220. ld1 t1 = [a1], 1
  221. ;;
  222. st1.rel [a0] = t1
  223. br.cloop.dptk.few StoreChar
  224. ;;
  225. mf
  226. mf.a
  227. mov ar.lc = t22
  228. LEAF_RETURN
  229. LEAF_EXIT (HalpStoreBufferUCHAR)
  230. /*++
  231. VOID
  232. HalpStoreBufferUSHORT (
  233. PUSHORT VirtualAddress,
  234. PUSHORT Buffer,
  235. ULONG Count
  236. );
  237. Routine Description:
  238. Arguements:
  239. Return Value:
  240. --*/
  241. LEAF_ENTRY(HalpStoreBufferUSHORT)
  242. .prologue
  243. .save ar.lc, t22
  244. mov t22 = ar.lc
  245. sub a2 = a2,zero,1
  246. ;;
  247. PROLOGUE_END
  248. mov ar.lc = a2
  249. StoreShort:
  250. ld2 t1 = [a1], 2
  251. ;;
  252. st2.rel [a0] = t1
  253. br.cloop.dptk.few StoreShort
  254. ;;
  255. mf
  256. mf.a
  257. mov ar.lc = t22
  258. LEAF_RETURN
  259. LEAF_EXIT (HalpStoreBufferUSHORT)
  260. /*++
  261. VOID
  262. HalpStoreBufferULONG (
  263. PULONG VirtualAddress,
  264. PULONG Buffer,
  265. ULONG Count
  266. );
  267. Routine Description:
  268. Arguements:
  269. Return Value:
  270. --*/
  271. LEAF_ENTRY(HalpStoreBufferULONG)
  272. .prologue
  273. .save ar.lc, t22
  274. mov t22 = ar.lc
  275. sub a2 = a2,zero,1
  276. ;;
  277. PROLOGUE_END
  278. mov ar.lc = a2
  279. StoreLong:
  280. ld4.s t1 = [a1],t0
  281. ;;
  282. st4.rel [a0] = t1,4
  283. br.cloop.dptk.few StoreLong
  284. ;;
  285. mf
  286. mf.a
  287. mov ar.lc = t22
  288. LEAF_RETURN
  289. LEAF_EXIT (HalpStoreBufferULONG)
  290. /*++
  291. VOID
  292. HalpStoreBufferULONGLONG (
  293. PULONGLONG VirtualAddress,
  294. PULONGLONG Buffer,
  295. ULONG Count
  296. );
  297. Routine Description:
  298. Arguements:
  299. Return Value:
  300. --*/
  301. LEAF_ENTRY(HalpStoreBufferULONGLONG)
  302. .prologue
  303. .save ar.lc, t22
  304. mov t22 = ar.lc
  305. sub a2 = a2,zero,1
  306. ;;
  307. PROLOGUE_END
  308. mov ar.lc = a2
  309. StoreLongLong:
  310. ld8.s t1 = [a1],t0
  311. ;;
  312. st8.rel [a0] = t1, 8
  313. br.cloop.dptk.few StoreLongLong
  314. ;;
  315. mf
  316. mf.a
  317. mov ar.lc = t22
  318. LEAF_RETURN
  319. LEAF_EXIT (HalpStoreBufferULONGLONG)
  320. //++
  321. //
  322. // VOID
  323. // ReadCpuLid(VOID);
  324. //
  325. // Routine Description:
  326. //
  327. // This function returns that value of cr.lid for this cpu
  328. //
  329. // Arguements:
  330. //
  331. // Return Value:
  332. //
  333. // LID register contents
  334. //
  335. //--
  336. LEAF_ENTRY(ReadCpuLid)
  337. mov v0 = cr.lid
  338. LEAF_RETURN
  339. LEAF_EXIT(ReadCpuLid)