Source code of Windows XP (NT5)
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.

322 lines
7.0 KiB

  1. //
  2. ///////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Module Name: EFIASM.S - IA64 EFI Physical Mode Calls //
  5. // Description:
  6. // Target Platform: Merced
  7. //
  8. // Reuse: None
  9. //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #include "regia64.h"
  12. #include "kxia64.h"
  13. .global HalpCallEfiPhysical
  14. .global HalpPhysBSPointer
  15. .global HalpPhysStackPointer
  16. .text
  17. //++
  18. // Name: HalpCallEfiPhysical()
  19. //
  20. // Routine Description:
  21. //
  22. // Arguments:
  23. //
  24. // Arg 0 to Arg 5
  25. // EntryPoint
  26. // GlobalPointer
  27. //
  28. // Return Value: EFI_STATUS
  29. //
  30. //--
  31. NESTED_ENTRY(HalpCallEfiPhysical)
  32. NESTED_SETUP(8,2,0,0)
  33. //
  34. // Aliases
  35. //
  36. rSaveEP = t22
  37. rSaveGP = t21
  38. rSaveA5 = t20
  39. rSaveA4 = t19
  40. rSaveA3 = t18
  41. rSaveA2 = t17
  42. rSaveA1 = t16
  43. rSaveA0 = t15
  44. rSaveSp = t14
  45. rSaveBSP = t13
  46. rSavePfs = t12
  47. rSaveBrp = t11
  48. rSaveRSC = t10
  49. rSaveRNAT = t9
  50. rSavePSR = t8
  51. rNewSp = t7
  52. rNewBSP = t6
  53. rT1 = t1
  54. rT2 = t2
  55. rT3 = t3
  56. // Save Arguements in static Registers
  57. mov rSaveA0 = a0
  58. mov rSaveA1 = a1
  59. mov rSaveA2 = a2
  60. mov rSaveA3 = a3
  61. mov rSaveA4 = a4
  62. mov rSaveA5 = a5
  63. mov rSaveEP = a6
  64. mov rSaveGP = a7
  65. mov rSaveSp = sp
  66. mov rSavePfs = ar.pfs
  67. mov rSaveBrp = brp
  68. //
  69. // Setup Physical sp, bsp
  70. //
  71. add rT1 = @gprel(HalpPhysStackPointer), gp
  72. add rT2 = @gprel(HalpPhysBSPointer), gp
  73. ;;
  74. ld8 rNewSp = [rT1]
  75. ld8 rNewBSP = [rT2]
  76. // Allocate 0
  77. ;;
  78. alloc rT1 = 0,0,0,0
  79. // Flush RSE
  80. ;;
  81. flushrs
  82. ;;
  83. mov rSavePSR = psr
  84. movl rT2 = (1 << PSR_BN)
  85. ;;
  86. or rSavePSR = rT2, rSavePSR // psr.bn stays on
  87. rsm (1 << PSR_I)
  88. mov rSaveRSC = ar.rsc
  89. // Flush RSE to enforced lazy mode by clearing both RSC.mode bits
  90. mov rT1 = RSC_KERNEL_DISABLED
  91. ;;
  92. mov ar.rsc = rT1
  93. ;;
  94. //
  95. // save RSC, RNAT, BSP, PSR, SP in the allocated space during initialization
  96. //
  97. mov rSaveBSP = ar.bsp
  98. mov rSaveRNAT = ar.rnat
  99. //
  100. // IC = 0; I = 0;
  101. //
  102. ;;
  103. rsm (1 << PSR_IC)
  104. ;;
  105. //
  106. // IIP = HceContinuePhysical: IPSR is physical
  107. //
  108. movl rT1 = (1 << PSR_IT) | (1 << PSR_RT) | (1 << PSR_DT) | (1 << PSR_I)
  109. movl rT2 = 0xffffffffffffffff
  110. ;;
  111. xor rT1 = rT1, rT2
  112. ;;
  113. and rT1 = rT1, rSavePSR // rT1 = old PSR & zero it, dt, rt, i
  114. srlz.i
  115. ;;
  116. mov cr.ipsr = rT1
  117. mov cr.ifs = zero
  118. ;;
  119. movl rT2 = HceContinuePhysical
  120. movl rT3 = 0xe0000000ffffffff
  121. ;;
  122. and rT2 = rT2, rT3
  123. ;;
  124. tpa rT2 = rT2 // phys address of new ip
  125. ;;
  126. mov cr.iip = rT2
  127. ;;
  128. rfi
  129. ;;
  130. //
  131. // Now in physical mode, ic = 1, i = 0
  132. //
  133. HceContinuePhysical::
  134. //
  135. // Switch to new bsp, sp
  136. //
  137. mov sp = rNewSp
  138. mov ar.bspstore = rNewBSP
  139. ;;
  140. mov ar.rnat = zero
  141. ;;
  142. //
  143. // Enable RSC
  144. //
  145. mov ar.rsc = RSC_KERNEL
  146. //
  147. // Allocate frame on new bsp
  148. //
  149. ;;
  150. alloc rT1 = ar.pfs,0,7,6,0
  151. //
  152. // Save caller's state in register stack
  153. //
  154. mov loc0 = rSaveRNAT
  155. mov loc1 = rSaveSp
  156. mov loc2 = rSaveBSP
  157. mov loc3 = rSaveRSC
  158. mov loc4 = rSaveBrp
  159. mov loc5 = rSavePfs
  160. mov loc6 = rSavePSR
  161. ;;
  162. // Setup Arguements
  163. mov out0 = rSaveA0
  164. mov out1 = rSaveA1
  165. mov out2 = rSaveA2
  166. mov out3 = rSaveA3
  167. mov out4 = rSaveA4
  168. mov out5 = rSaveA5
  169. movl rT1 = HceEfiReturnAddress
  170. movl rT2 = 0xe0000000FFFFFFFF
  171. ;;
  172. and rT2 = rT2, rT1
  173. ;;
  174. tpa rT2 = rT2
  175. ;;
  176. mov brp = rT2
  177. mov gp = rSaveGP
  178. mov bt0 = rSaveEP
  179. ;;
  180. br.call.sptk brp = bt0
  181. ;;
  182. HceEfiReturnAddress::
  183. //
  184. // In physical mode: switch to virtual
  185. //
  186. //
  187. // Restore saved state
  188. //
  189. mov rSaveRNAT = loc0
  190. mov rSaveSp = loc1
  191. mov rSaveBSP = loc2
  192. mov rSaveRSC = loc3
  193. mov rSaveBrp = loc4
  194. mov rSavePfs = loc5
  195. mov rSavePSR = loc6
  196. ;;
  197. //
  198. // Restore BSP, SP
  199. //
  200. ;;
  201. mov ar.rsc = RSC_KERNEL_DISABLED
  202. ;;
  203. alloc rT1 = 0,0,0,0
  204. ;;
  205. mov ar.bspstore = rSaveBSP
  206. ;;
  207. mov ar.rnat = rSaveRNAT
  208. mov sp = rSaveSp
  209. ;;
  210. rsm (1 << PSR_IC)
  211. ;;
  212. movl rT1 = HceContinueVirtual
  213. movl rT2 = 0xe0000000ffffffff
  214. ;;
  215. and rT1 = rT2, rT1
  216. ;;
  217. srlz.i
  218. ;;
  219. mov cr.iip = rT1
  220. mov cr.ipsr = rSavePSR
  221. mov cr.ifs = zero
  222. ;;
  223. rfi
  224. ;;
  225. //
  226. // Now in virtual mode, ic = 1, i = 1
  227. //
  228. HceContinueVirtual::
  229. //
  230. // Restore psf, brp and return
  231. //
  232. mov ar.rsc = rSaveRSC
  233. ;;
  234. mov ar.pfs = rSavePfs
  235. mov brp = rSaveBrp
  236. ;;
  237. br.ret.sptk brp
  238. NESTED_EXIT(HalpCallEfiPhysical)
  239. //++
  240. //
  241. // VOID
  242. // HalpCallEfiVirtual(
  243. // ULONGLONG a0, /* Arg 1 */
  244. // ULONGLONG a1, /* Arg 2 */
  245. // ULONGLONG a2, /* Arg 3 */
  246. // ULONGLONG a3, /* Arg 4 */
  247. // ULONGLONG a4, /* Arg 5 */
  248. // ULONGLONG a5, /* Arg 6 */
  249. // ULONGLONG a6, /* Entry Point */
  250. // ULONGLONG a7 /* GP */
  251. // );
  252. //
  253. // Routine Description:
  254. //
  255. // Return Values:
  256. // r8->r11 contain the 4 64-bit return values, r8 is the status
  257. //--
  258. NESTED_ENTRY(HalpCallEfiVirtual)
  259. NESTED_SETUP(8,2,8,0)
  260. // copy args to outs
  261. mov out0 = a0
  262. mov out1 = a1
  263. mov out2 = a2
  264. mov out3 = a3
  265. mov out4 = a4
  266. mov out5 = a5
  267. mov out6 = a6
  268. mov out7 = a7
  269. ;;
  270. // Simply load the address and branch to it
  271. mov gp = a7
  272. ;;
  273. mov bt0 = a6
  274. ;;
  275. br.call.sptk brp = bt0
  276. ;;
  277. NESTED_RETURN
  278. NESTED_EXIT(HalpCallEfiVirtual)