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.

264 lines
6.0 KiB

  1. //++
  2. //
  3. // Module Name:
  4. //
  5. // proceessr.s
  6. //
  7. // Abstract:
  8. //
  9. // Hardware workarounds.
  10. //
  11. // Author:
  12. //
  13. // Allen M. Kay ([email protected]) 4-April-2000
  14. //
  15. // Environment:
  16. //
  17. // Kernel mode only.
  18. //
  19. // Revision History:
  20. //
  21. //--
  22. #include "ksia64.h"
  23. #if _MERCED_A0_
  24. //
  25. // Merced Processor ERRATA Workaround
  26. //
  27. LEAF_ENTRY (KiProcessorWorkAround)
  28. mov t0 = 3
  29. ;;
  30. mov t1 = cpuid[t0] // read cpuid3
  31. ;;
  32. extr.u t1 = t1, 24, 8
  33. ;;
  34. cmp.ne pt0 = 7, t1 // if the processor is not the Itanium processor
  35. ;;
  36. (pt0) br.ret.spnt b0 // then just return
  37. ;;
  38. Disable_L1_Bypass:
  39. tbit.nz pt0, pt1 = a0, DISABLE_L1_BYPASS
  40. (pt0) br.sptk CPL_bug_workaround
  41. mov t0 = 484
  42. mov t1 = 4
  43. ;;
  44. mov msr[t0] = t1
  45. CPL_bug_workaround:
  46. tbit.nz pt0, pt1 = a0, DISABLE_CPL_FIX
  47. (pt0) br.sptk DisableFullDispersal
  48. mov t0 = 66
  49. ;;
  50. mov t1 = msr[t0]
  51. ;;
  52. dep t1 = 1, t1, 0, 4
  53. ;;
  54. mov msr[t0] = t1
  55. DisableFullDispersal:
  56. tbit.z pt0, pt1 = a0, ENABLE_FULL_DISPERSAL
  57. mov t0 = 652
  58. ;;
  59. // Single Dispersal
  60. (pt1) mov t1 = 0
  61. (pt0) mov t1 = 1
  62. ;;
  63. mov msr[t0] = t1
  64. ;;
  65. DisableBtb:
  66. tbit.nz pt0, pt1 = a0, DISABLE_BTB_FIX
  67. (pt0) br.sptk DisableTar
  68. // This change is needed to make WOW64 run (disable BTB)
  69. mov t1 = 224
  70. ;;
  71. mov t0 = msr[t1] // Get the old value
  72. ;;
  73. or t0 = 0x40, t0 // Or in bit 6
  74. ;;
  75. mov msr[t1] = t0 // Put it back
  76. DisableTar:
  77. tbit.nz pt0, pt1 = a0, DISABLE_TAR_FIX
  78. (pt0) br.sptk DataBreakPoint
  79. // disable TAR to fix sighting 3739
  80. mov t0 = 51
  81. mov t1 = 1
  82. ;;
  83. mov msr[t0] = t1
  84. DataBreakPoint:
  85. tbit.nz pt0, pt1 = a0, DISABLE_DATA_BP_FIX
  86. (pt0) br.sptk DetStallFix
  87. // this change is needed to enable data debug
  88. mov t0 = 387
  89. ;;
  90. mov msr[t0] = r0
  91. ;;
  92. DetStallFix:
  93. tbit.nz pt0, pt1 = a0, DISABLE_DET_STALL_FIX
  94. (pt0) br.sptk DisableIA32BranchFix
  95. //
  96. // BSB CADS spacing 7
  97. //
  98. mov t0 = 514
  99. movl t1 = 0x0930442325210445
  100. ;;
  101. mov msr[t0] = t1;
  102. ;;
  103. // p1_disable()
  104. mov t0 = 484
  105. mov t1 = 0xc
  106. ;;
  107. mov msr[t0] = t1
  108. // trickle()
  109. mov t0 = 485
  110. mov t1 = 1
  111. ;;
  112. mov msr[t0] = t1
  113. // Throttle L1 access in L0D
  114. mov t1 = 384
  115. ;;
  116. mov t0 = msr[t1] // Get the old value
  117. ;;
  118. dep t2 = 1, t0, 44, 1
  119. ;;
  120. mov msr[t1] = t2 // Put it back
  121. // rse_disable()
  122. mov t1 = 258
  123. ;;
  124. mov t0 = msr[t1] // Get the old value
  125. movl t2 = 0x4000
  126. ;;
  127. or t0 = t2, t0 // Or in bit 44
  128. ;;
  129. mov msr[t1] = t0 // Put it back
  130. ;;
  131. DisableIA32BranchFix:
  132. tbit.nz pt0, pt1 = a0, DISABLE_IA32BR_FIX
  133. (pt0) br.sptk DisableIA32RsbFix
  134. // Occasionally the ia32 iVE gets confused between macro branches
  135. // and micro branches. This helps that confusion
  136. mov t1 = 204
  137. ;;
  138. mov t0 = msr[t1] // Get the old value
  139. ;;
  140. or t0 = 0x10, t0 // Or in bit 4
  141. ;;
  142. mov msr[t1] = t0 // Put it back
  143. DisableIA32RsbFix:
  144. tbit.nz pt0, pt1 = a0, DISABLE_IA32RSB_FIX
  145. (pt0) br.sptk DisablePrefetchUnsafeFill
  146. // More ia32 confusion. This time on the ReturnStackBuffer
  147. mov t1 = 196
  148. movl t0 = 0x40000008 // Turn off the RSB
  149. ;;
  150. mov msr[t1] = t0
  151. DisablePrefetchUnsafeFill:
  152. tbit.z pt0, pt1 = a0, DISABLE_UNSAFE_FILL
  153. (pt0) br.cond.sptk DisableStoreUpdate
  154. mov t1 = 80
  155. mov t0 = 8
  156. ;;
  157. mov msr[t1] = t0
  158. DisableStoreUpdate:
  159. tbit.nz pt0, pt1 = a0, DISABLE_STORE_UPDATE
  160. (pt0) br.cond.sptk ErrataDone
  161. mov t1 = 384
  162. ;;
  163. mov t0 = msr[t1]
  164. ;;
  165. dep t0 = 1, t0, 18, 1
  166. ;;
  167. mov msr[t1] = t0
  168. ErrataDone:
  169. #if 1
  170. tbit.z pt0 = a0, ENABLE_HISTORY_BUFFER
  171. (pt0) br.cond.sptk HistoryDone
  172. //
  173. // Configure the history buffer for capturing branches/interrupts
  174. //
  175. mov t1 = 674
  176. ;;
  177. mov msr[t1] = r0 // HBC <- 0
  178. ;;
  179. mov t0 = 675
  180. ;;
  181. mov t1 = msr[t0]
  182. mov t2 = 2
  183. ;;
  184. dep t1 = t2, t1, 0, 9
  185. ;;
  186. mov msr[t0] = t1 // HBCF <- 2
  187. ;;
  188. mov t1 = 12
  189. mov t0 = 0xfe8f
  190. ;;
  191. mov pmc[t1] = t0
  192. ;;
  193. mov t1 = 680
  194. mov t2 = 681
  195. mov t3 = 682
  196. mov t4 = 683
  197. mov t5 = 684
  198. mov t6 = 685
  199. mov t7 = 686
  200. mov t8 = 687
  201. ;;
  202. .reg.val t1, 680
  203. mov msr[t1] = r0
  204. .reg.val t2, 681
  205. mov msr[t2] = r0
  206. .reg.val t3, 682
  207. mov msr[t3] = r0
  208. .reg.val t4, 683
  209. mov msr[t4] = r0
  210. .reg.val t5, 684
  211. mov msr[t5] = r0
  212. .reg.val t6, 685
  213. mov msr[t6] = r0
  214. .reg.val t7, 686
  215. mov msr[t7] = r0
  216. .reg.val t8, 687
  217. mov msr[t8] = r0
  218. HistoryDone:
  219. #endif
  220. LEAF_RETURN
  221. LEAF_EXIT (KiProcessorWorkAround)
  222. #endif