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.

259 lines
6.9 KiB

  1. /**
  2. *** Copyright (C) 1996-97 Intel Corporation. All rights reserved.
  3. ***
  4. *** The information and source code contained herein is the exclusive
  5. *** property of Intel Corporation and may not be disclosed, examined
  6. *** or reproduced in whole or in part without explicit written authorization
  7. *** from the company.
  8. **/
  9. //++
  10. //
  11. // Module name
  12. // SIMSAL.S
  13. // Author
  14. // Allen Kay (akay) May-6-97
  15. // Description
  16. // Initializes the CPU and loads the first sector from the boot partition.
  17. // SIMSAL does the following:
  18. // 1. Initialize PSR with interrupt disabled.
  19. // 2. Invalidate ALAT.
  20. // 3. Invalidate RS.
  21. // 4. Setup GP.
  22. // 5. Set region registers rr[r0] - rr[r7] to RID=0, PS=8K, E=0.
  23. // 6. Initialize SP to 0x00902000.
  24. // 7. Initialize BSP to 0x00202000.
  25. // 8. Enable register stack engine.
  26. // 9. Setup IVA to 0x001F8000.
  27. // 10. Setup virtual->physical address translation
  28. // 0x80000000->0x00000000 in dtr0/itr0 for NT kernel.
  29. // 11. Setup virtual->physical address translation
  30. // 0x80400000->0x00400000 in dtr1/itr1 for HAL.dll.
  31. // 12. Setup virtual->physical address translation
  32. // 0x00800000->0x00800000 in dtr1/itr1 for NTLDR.
  33. //---
  34. #include "ksia64.h"
  35. #include "susetup.h"
  36. #include "ntfsdefs.h"
  37. .file "start.s"
  38. .global SscExit
  39. .type SscExit, @function
  40. .global ReadSectors
  41. .type ReadSectors, @function
  42. #define Buffer 0x0
  43. //
  44. // Interrupt Vector Table
  45. //
  46. #define VECTOR(Offset, Name) \
  47. .##org Offset; \
  48. Name:: \
  49. mov a0 = cr##.##iip; \
  50. br##.##call##.##sptk##.##clr brp = SscExit
  51. .section ivt = "ax", "progbits"
  52. BlIvtBase::
  53. VECTOR(0x0000, BlVhptTransVector)
  54. VECTOR(0x0400, BlInstTlbVector)
  55. VECTOR(0x0800, BlDataTlbVector)
  56. VECTOR(0x0C00, BlAltInstTlbVector)
  57. VECTOR(0x1000, BlAltDataTlbVector)
  58. VECTOR(0x1400, BlNestedTlbVector)
  59. VECTOR(0x1800, BlInstKeyMissVector)
  60. VECTOR(0x1C00, BlDataKeyMissVector)
  61. VECTOR(0x2000, BlDirtyBitVector)
  62. VECTOR(0x2400, BlInstAccessBitVector)
  63. VECTOR(0x2800, BlDataAccessBitVector)
  64. VECTOR(0x2C00, BlBreakVector)
  65. VECTOR(0x3000, BlExternalInterruptVector)
  66. VECTOR(0x5000, BlPageNotPresentVector)
  67. VECTOR(0x5100, BlKeyPermVector)
  68. VECTOR(0x5200, BlInstAccessRightsVector)
  69. VECTOR(0x5300, BlDataAccessRightsVector)
  70. VECTOR(0x5400, BlGeneralExceptionVector)
  71. VECTOR(0x5500, BlDisabledFpRegisterVector)
  72. VECTOR(0x5600, BlNatConsumptionVector)
  73. VECTOR(0x5700, BlSpeculationVector)
  74. VECTOR(0x6900, BlIA32ExceptionVector)
  75. VECTOR(0x6A00, BlIA32InterceptionVector)
  76. VECTOR(0x6B00, BlIA32InterruptionVector)
  77. // ***************************************************************************
  78. // Initialize the processor
  79. // ***************************************************************************
  80. NESTED_ENTRY(SimSal)
  81. NESTED_SETUP(3,3,8,0)
  82. PROLOGUE_END
  83. rpT0 = t22
  84. rpT1 = t21
  85. rpT2 = t20
  86. rpT3 = t19
  87. mov psr.l = zero // initialize psr.l
  88. movl t0 = FPSR_FOR_KERNEL
  89. mov ar.fpsr = t0 // initialize fpsr
  90. invala // invalidate ALAT
  91. mov ar.rsc = zero // invalidate register stack
  92. loadrs
  93. //
  94. // Initialize Region Registers
  95. //
  96. mov t0 = RR_PAGE_SIZE
  97. mov t1 = zero
  98. Bl_RRLoop:
  99. dep t2 = t2, t1, RR_SHIFT, RR_BITS
  100. mov rr[t2] = t0
  101. add t1 = 1, t1
  102. cmp4.geu pt0, pt1 = RR_SIZE, t1
  103. (pt0) br.cond.sptk.clr Bl_RRLoop
  104. //
  105. // Initialize the protection key registers with only pkr[0] = valid.
  106. //
  107. mov t0 = PKR_VALID
  108. mov t1 = zero
  109. mov pkr[t1] = t0
  110. mov t0 = zero
  111. Bl_PKRLoop:
  112. add t1 = t1, zero, 1 // increment PKR
  113. cmp.gtu pt0, pt1 = PKRNUM, t1
  114. (pt0) mov pkr[t1] = t0
  115. (pt0) br.cond.sptk.clr Bl_PKRLoop
  116. //
  117. // Setup SP
  118. //
  119. movl sp = BL_SP_BASE
  120. //
  121. // Set up tbe scratch area
  122. //
  123. add sp = -STACK_SCRATCH_AREA, sp
  124. //
  125. // Setup register stack backing store.
  126. //
  127. mov t0 = RSC_KERNEL_DISABLED
  128. mov ar.rsc = t0
  129. movl t1 = BL_SP_BASE
  130. mov ar.bspstore = t1
  131. //
  132. // Setup the base address of interrupt vector table
  133. //
  134. movl t0 = BlIvtBase
  135. mov cr.iva = t0
  136. //
  137. // Setup system address translation for NT kernel
  138. //
  139. //
  140. movl t0 = BOOT_SYSTEM_PAGE << PAGE_SHIFT
  141. ADDS4 (t0, 0, t0)
  142. mov cr.ifa = t0
  143. movl t1 = IDTR_IIP_VALUE(0,0,BL_PAGE_SIZE)
  144. mov cr.itir = t1
  145. movl t2 = TR_VALUE(1,BOOT_PHYSICAL_PAGE,3,0,1,1,1,1)
  146. mov t3 = zero
  147. itr.d dtr[t3] = t2
  148. itr.i itr[t3] = t2
  149. //
  150. // Setup the aliased kernel space
  151. //
  152. zxt4 t0 = t0 // zero extend kernel address
  153. mov t4 = 6 // create alias in region 6
  154. mov t5 = 2 // index
  155. dep t0 = t4, t0, 61, 3
  156. mov cr.ifa = t0
  157. itr.i itr[t5] = t2
  158. //
  159. // Setup 1-1 address translation for NT kernel
  160. //
  161. movl t0 = BOOT_USER_PAGE << PAGE_SHIFT
  162. ADDS4 (t0, 0, t0)
  163. mov cr.ifa = t0
  164. movl t2 = TR_VALUE(1,BOOT_USER_PAGE,3,0,1,1,1,1)
  165. add t3 = 1, t3
  166. itr.d dtr[t3] = t2
  167. itr.i itr[t3] = t2
  168. //
  169. // Turn on address translation, interrupt, psr.ed, protection key.
  170. //
  171. movl t1 = MASK(PSR_BN,1) | MASK(PSR_IT,1) | MASK(PSR_DA,1) | MASK(PSR_RT,1) | MASK(PSR_DT,1) | MASK(PSR_PK,1) | MASK(PSR_I,1)| MASK(PSR_IC,1)
  172. mov cr.ipsr = t1
  173. //
  174. // Initialize DCR to defer all speculation faults
  175. //
  176. movl t0 = DCR_DEFER_ALL
  177. mov cr.dcr = t0
  178. //
  179. // Read the first sector of the boot partition
  180. //
  181. mov out0 = zero
  182. movl out1 = 1
  183. movl out2 = Buffer
  184. mov ap = sp
  185. br.call.sptk.many brp = ReadSectors
  186. //
  187. // Read the first sector of the boot partition
  188. //
  189. mov out0 = zero
  190. #ifdef BSDT
  191. movl t0 = Buffer // get the sector count
  192. add rpT0 = 6, t0
  193. ld2 out1 = [rpT0]
  194. #else
  195. movl out1 = 64 // read 64 sectors, 32KB
  196. #endif
  197. movl out2 = Buffer
  198. mov ap = sp
  199. br.call.sptk.many brp = ReadSectors
  200. //
  201. // Now pass control to the first sector code
  202. //
  203. #ifdef BSDT
  204. movl t0 = Buffer // (the second sector).
  205. add rpT0 = 8, t0
  206. ld4 t1 = [rpT0]
  207. #else
  208. movl t1 = 0xd0 // since no bsdt, hardcode it for now.
  209. #endif
  210. mov cr.iip = t1
  211. rfi;;
  212. NESTED_EXIT(SimSal)