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.

1082 lines
37 KiB

  1. //###########################################################################
  2. //**
  3. //** Copyright (C) 1996-2000 Intel Corporation. All rights reserved.
  4. //**
  5. //** The information and source code contained herein is the exclusive
  6. //** property of Intel Corporation and may not be disclosed, examined
  7. //** or reproduced in whole or in part without explicit written authorization
  8. //** from the company.
  9. //**
  10. //###########################################################################
  11. //-----------------------------------------------------------------------------
  12. // Version control information follows.
  13. //
  14. // $Header: I:/DEVPVCS/OSMCA/osmchk.s_v 2.1 05 Mar 1999 12:59:42 smariset $
  15. // $Log: I:/DEVPVCS/OSMCA/osmchk.s_v $
  16. //
  17. // Rev 2.0 Dec 11 1998 11:42:18 khaw
  18. //Post FW 0.5 release sync-up
  19. //
  20. // Rev 1.4 12 Oct 1998 14:05:20 smariset
  21. //gp fix up work around
  22. //
  23. ///////////////////////////////////////////////////////////////////////////////
  24. //
  25. // Module Name: OSINITCHK.S - Merced OS INIT Handler Dispatcher
  26. //
  27. // Description:
  28. // TEMPTEMP CHANGE THE DOC.
  29. // Merced OS INIT event handler Stub to OSINIT "C" frame work. If
  30. // we find a TLB related error, we cannot switch to virtual mode in
  31. // the OS. All TLB related errors will need system reboot after
  32. // storing the errors to a persistence storage media (HD or Flash).
  33. //
  34. // HalpOsInitDispatch - Main
  35. //
  36. // Target Platform: Merced
  37. //
  38. // Reuse: None
  39. //
  40. ////////////////////////////////////////////////////////////////////////////M//
  41. #include "ksia64.h"
  42. #include "fwglobal.h"
  43. GLOBAL_FUNCTION(HalpOsInitDispatch)
  44. GLOBAL_FUNCTION(HalpInitHandler)
  45. GLOBAL_FUNCTION(HalpMcaHandler)
  46. .text
  47. //++
  48. // Name: HalpOsInitDispatch()
  49. //
  50. // Routine Description:
  51. //
  52. // This is the OS Init call back handler, which is only exported
  53. // to the SAL for call back during MCA errors. This
  54. // handler will dispatch to the appripriate Init. proc. This
  55. // proc will be called in physical mode.
  56. //
  57. // Sets up virtual->physical address translation
  58. // 0x00100000->0x00100000 in dtr1/itr1 for OS_INIT.
  59. //
  60. // Arguments:
  61. //
  62. // None
  63. //
  64. // On entry:
  65. // This function is called:
  66. // - in physical mode for uncorrected or correctable MCA events,
  67. // - RSE enforced in lazy mode,
  68. // - Processor resources:
  69. // PSR.dt = 0, PSR.it = 0, PSR.rt = 0 - Physical mode.
  70. // PSR.ic = 0, PSR.i = 0 - Interrupt resources collection and interrupt disabled.
  71. // PSR.mc = 1 - Machine Checks masked
  72. // PSR.mfl = 0 - low fp disabled.
  73. // GR1 : OS_MCA Global Pointer (GP) registered by OS: OS's GP.
  74. // GR2-7: Unspecified.
  75. // GR8 : Physical address of the PAL_PROC entrypoint.
  76. // GR9 : Physical address of the SAL_PROC entrypoint.
  77. // GR10 : Physical address value of the SAL Global Pointer: SAL's GP.
  78. // GR11 : Rendezvous state information, defined as:
  79. // 0 - Rendezvous of other processors was not required by
  80. // PAL_CHECK and as such was not done.
  81. // 1 - All other processors in the system were successfully
  82. // rendezvous using MC_RENDEZVOUS interrupt.
  83. // 2 - All other processors in the system were successfully
  84. // rendezvous using a combination of MC_RENDEZVOUS
  85. // interrupt and INIT.
  86. // -1 - Rendezvous of other processors was required by PAL
  87. // but was unsuccessful.
  88. // GR12 : Return address to a location within SAL_CHECK.
  89. // GR17 : Pointer to processor minimum state saved memory location.
  90. // GR18 : Processor state as defined below:
  91. // D0-D5: Reserved
  92. // D6-D31: As defined in PAL EAS
  93. // D60-D63: As defined in PAL EAS
  94. // D32-D47: Size in bytes of processor dynamic state
  95. // D48-D59: Reserved.
  96. // GR19 : Return address to a location within PAL_CHECK.
  97. // BR0 : Unspecified.
  98. //
  99. // Return State:
  100. //
  101. // Note : The OS_MCA procedure may or may not return to SAL_CHECK
  102. // in the case of uncorrected machine checks.
  103. // If it returns to SAL, the runtime convention requires that
  104. // it sets appropriate values in the Min-State area pointed
  105. // to by GR12 for continuing execution at the interrupted
  106. // context or at a new context.
  107. // Furthermore, the OS_MCA procedure must restore the
  108. // processor state to the same state as on entry except as:
  109. // GR1-7 : Unspecified.
  110. // GR8 : Return status
  111. // 0 [= SAL_STATUS_SUCCESS] - Error has been corrected
  112. // by OS_MCA.
  113. // -1 - Error has not been corrected by OS_MCA and
  114. // SAL must warm boot the system.
  115. // -2 - Error has not been corrected by OS_MCA and
  116. // SAL must cold boot the system.
  117. // -3 - Error has not been corrected by OS_MCA and
  118. // SAL must halt the system.
  119. // GR9 : Physical address value for SAL's GP.
  120. // GR10 : Context flag
  121. // 0 - Return will be to the same context.
  122. // 1 - Return will be to a new context.
  123. // GR11-21: Unspecified.
  124. // GR22 : Pointer to a structure containing new values of registers
  125. // in the Min-State Save area.
  126. // OS_MCA must supply this parameter even if it does not
  127. // change the register values in the Min-State Save areas.
  128. // GR23-31: Unspecified.
  129. // BR0 : Unspecified.
  130. // PSR.mc : May be either 0 or 1.
  131. //--
  132. .proc HalpOsInitDispatch;
  133. HalpOsInitDispatch::
  134. .prologue
  135. .unwabi @nt, EXCEPTION_FRAME
  136. // aliases for known registers:
  137. rPalProcEntryPoint = r8
  138. rSalProcEntryPoint = r9
  139. rSalGlobalPointer = r10
  140. rRendezVousResult = r11
  141. rSalReturnAddress = r12
  142. rProcMinStateSavePtr = r17
  143. rProcStateParameter = r18
  144. rPalCheckReturnAddress = r19
  145. rEventResources = t22
  146. rPcrPhysicalAddress = t6
  147. //
  148. // Use pt1, pt2 to inidcate if this is a INIT or MCA event.
  149. //
  150. cmp.ne pt1, pt2 = r0, r0
  151. br.sptk HalpOsCommonDispatch
  152. ;;
  153. ALTERNATE_ENTRY(HalpOsMcaDispatch1)
  154. cmp.eq pt1, pt2 = r0, r0
  155. HalpOsCommonDispatch::
  156. //
  157. // - Flag the processor as "InOsInit":
  158. // KiPcr.InOsInit = 1
  159. //
  160. // - Update KiPcr.InitPTOM to point to TopOfMemory,
  161. // Memory after Processor Minimum State Save area.
  162. //
  163. // - Update processor InitSalToOsHandOff
  164. //
  165. // - Update local rPcrInitStateDump before calling osInitProcStateDump.
  166. //
  167. mov rEventResources = PcOsMcaResourcePtr
  168. movl t21 = KiPcr
  169. ;;
  170. tpa rPcrPhysicalAddress = t21 // Calculate physical address of PCR
  171. mov t19 = SerSalToOsHandOff
  172. mov t1 = 0x1
  173. ;;
  174. add t0 = rPcrPhysicalAddress, rEventResources
  175. sub t21 = rPcrPhysicalAddress, t21
  176. add t16 = TOM, rProcMinStateSavePtr
  177. ;;
  178. (pt1) ld8 rEventResources = [t0], PcInOsMca-PcOsMcaResourcePtr
  179. mov ar.ccv = r0
  180. ;;
  181. (pt2) ld8 rEventResources = [t0], PcInOsInit-PcOsMcaResourcePtr
  182. mov t18 = SerPTOM
  183. add t20 = 0x8, t19
  184. ;;
  185. //
  186. // Save in preserved registers:
  187. // - pointer to processor minimum state save area,
  188. // - processor state parameter
  189. // - PAL_CHECK return address.
  190. // s0 [=r4] <- r17,
  191. // s1 [=r5] <- r18,
  192. // s2 [=r6] <- r19
  193. //
  194. SaveRs(rProcMinStateSavePtr, rProcStateParameter, rPalCheckReturnAddress)
  195. ;;
  196. cmpxchg1.acq t17 = [t0], t1, ar.ccv
  197. ;;
  198. cmp.ne pt0, p0 = t17, r0
  199. (pt0) br.dpnt iResetNow
  200. ;;
  201. add rEventResources = rEventResources, t21 // Calculate the physical address of the OsMcaResources
  202. add t21 = 0x10, t19
  203. ;;
  204. add t18 = rEventResources, t18
  205. add t19 = rEventResources, t19
  206. add t20 = rEventResources, t20
  207. add t21 = rEventResources, t21
  208. ;;
  209. ld8 t17 = [t16]
  210. st8 [t19] = rPalProcEntryPoint, 0x18
  211. add t0 = SerStateDumpPhysical, rEventResources
  212. ;;
  213. st8 [t18] = t17
  214. st8 [t20] = rSalProcEntryPoint, 0x18
  215. st8 [t21] = rSalGlobalPointer, 0x18
  216. ;;
  217. st8 [t19] = rRendezVousResult
  218. st8 [t20] = rSalReturnAddress
  219. st8 [t21] = rProcMinStateSavePtr
  220. ld8 t0 = [t0] // InitStateDump
  221. ;;
  222. //
  223. // Save processor state in data area:
  224. //
  225. br.dpnt osInitProcStateDump
  226. ;;
  227. osInitDoneDump:
  228. //
  229. // If we have a TLB error, we cannot enable translation
  230. //
  231. tbit.nz.unc pt0,p0=s1, 60 // PSP.tc=60
  232. (pt0) br.dpnt iThyself
  233. ;;
  234. //
  235. // Initialize current sp and ar.bsp and ar.bspstore
  236. //
  237. // KiPcr.InitStackFrame[0] = ar.rsc
  238. // KiPcr.InitStackFrame[1] = ar.pfs
  239. // KiPcr.InitStackFrame[2] = ar.ifs
  240. // KiPcr.InitStackFrame[3] = ar.bspstore
  241. // KiPcr.InitStackFrame[4] = ar.rnat
  242. // ar.bspstore = t0 [=KiPcr.InitBspStore]
  243. // KiPcr.InitStackFrame[5] = ar.bsp - KiPcr.InitBspStore
  244. // [BUGBUG ?? : should be ar.bsptore=KiPcr.InitStackFrame[3]]
  245. // sp = KiPcr.InitStack
  246. //
  247. movl t21 = KiPcr + PcOsMcaResourcePtr
  248. ;;
  249. tpa t0 = t21 // Calculate physical address of PCR OsInitResourcePtr
  250. mov t1 = SerStateDumpPhysical
  251. ;;
  252. sub t16 = SerBackStore, t21
  253. sub t1 = t1, t21
  254. ;;
  255. add t16 = t0, t16
  256. add t1 = t0, t1
  257. ld8 rEventResources = [t0], PcInitialBStore - PcOsMcaResourcePtr
  258. ;;
  259. add t16 = rEventResources, t16 // Calculate physical address of the new BSP
  260. mov t21 = t0 // t21 now points to InitialBStore in the PCR
  261. ;;
  262. add t1 = rEventResources, t1 // Calculate the physical address of State Dump physical pointer
  263. ld8 t3 = [t16], SerStack - SerBackStore // t3 contains the initial BSP.
  264. ;;
  265. ld8 t7 = [t1] // t7 now contain the physical address of the state dump area
  266. ;; // and the physical top of stack
  267. st8 [t21] = t3, PcInitialStack - PcInitialBStore // Save the InitialBStore in the PCR
  268. ld8 t1 = [t16], SerBackStoreLimit - SerStack // Get inital Init stack
  269. ;;
  270. st8 [t21] = t1, PcBStoreLimit - PcInitialStack
  271. ld8 t0 = [t16], SerStackLimit - SerBackStoreLimit
  272. ;;
  273. add t1 = -STACK_SCRATCH_AREA-ThreadStateSaveAreaLength-TrapFrameLength-PalMiniSaveLength, t1
  274. add t7 = -STACK_SCRATCH_AREA-ThreadStateSaveAreaLength-TrapFrameLength-PalMiniSaveLength, t7
  275. st8 [t21] = t0, PcStackLimit - PcBStoreLimit // Save BStore limit
  276. ld8 t18 = [t16]
  277. ;;
  278. mov sp = t1
  279. st8 [t21] = t18, PcCurrentIrql - PcStackLimit
  280. ;;
  281. ld1 t1 = [t21]
  282. //
  283. // Copy the PAL Mini-save area to the stack. It must be accessed non-cached.
  284. // t7 contains the physical address for the trap frame.
  285. // r4 contains the minium save area physical address.
  286. //
  287. mov t16 = ar.lc // Save lc
  288. mov t0 = PalMiniSaveLength/8
  289. ;;
  290. add t21 = ThreadStateSaveAreaLength+TrapFrameLength, t7 // Calculate stack physical address
  291. // of PAL mini save area is saved.
  292. dep t17 = 1, r4, 63, 1 // Non-cached address of PAL mini save area
  293. mov ar.lc = t0
  294. ;;
  295. iCopyMini:
  296. ld8 t0 = [t17],8
  297. ;;
  298. st8 [t21] = t0,8
  299. br.ctop.sptk.few iCopyMini
  300. ;;
  301. mov ar.lc = t16 // Restore lc
  302. mov ar.rsc = r0 // put RSE in lazy mode and use kernel mode stores.
  303. ;;
  304. //
  305. // Generate a exception trap frame.
  306. // t7 contains the physical address for the trap frame.
  307. // t3 contains the initial BSP
  308. //
  309. add t17=TrOldIrql, t7
  310. add t21 = ThreadStateSaveAreaLength+TrapFrameLength+PmsRsRSC, t7 // Calculate stack physical address
  311. cover // of PAL mini save area of RSE.
  312. ;;
  313. st1 [t17] = t1, TrEOFMarker - TrOldIrql
  314. movl t0 = KTRAP_FRAME_EOF | EXCEPTION_FRAME
  315. ;;
  316. st8 [t17] = t0
  317. mov t1 = ar.bspstore
  318. ;;
  319. mov t0 = ar.bsp
  320. ld8 t18 = [t21],PmsStIIP - PmsRsRSC
  321. add t17 = TrRsBSP - TrEOFMarker, t17
  322. ;;
  323. dep t3 = t1, t3, 0, 9 // Adjust new BSPSTORE for NATs
  324. st8 [t17] = t0,TrRsBSPSTORE - TrRsBSP
  325. ;;
  326. sub t0 = t0, t1
  327. st8 [t17] = t1, TrRsRSC - TrRsBSPSTORE // Save old BspStore
  328. ;;
  329. dep t18 = t0, t18, RSC_MBZ1, RSC_LOADRS_LEN
  330. mov ar.bspstore = t3
  331. ld8 t1 = [t21], PmsStIPSR - PmsStIIP // Copy IIP to trap frame as IIP
  332. ;;
  333. st8 [t17] = t18, TrStIIP - TrRsRSC
  334. ld8 t0 = [t21], PmsStIFS - PmsStIPSR // Copy IPSR to trap frame as IPSR
  335. ;;
  336. st8 [t17] = t1, TrStIPSR - TrStIIP
  337. ;;
  338. st8 [t17] = t0, TrStIFS - TrStIPSR
  339. ld8 t1 = [t21], PmsBrRp - PmsStIFS // Copy IFS to trap frame as IFS
  340. ;;
  341. st8 [t17] = t1, TrBrRp - TrStIFS
  342. ld8 t0 = [t21], PmsPreds - PmsBrRp
  343. ;;
  344. st8 [t17] = t0, TrStISR - TrBrRp
  345. mov t1 = cr.isr
  346. ;;
  347. st8 [t17] = t1, TrRsPFS - TrStISR
  348. mov t0 = ar.pfs
  349. ;;
  350. st8 [t17] = t0, TrStIIPA - TrRsPFS
  351. mov t1 = cr.iipa
  352. ;;
  353. st8 [t17] = t1, TrStIIM - TrStIIPA
  354. mov t0 = cr.iim
  355. ;;
  356. st8 [t17] = t0, TrStIHA - TrStIIM
  357. mov t1 = cr.iha
  358. ;;
  359. st8 [t17] = t0, TrStFPSR - TrStIHA
  360. mov t0 = ar.fpsr
  361. ;;
  362. st8 [t17] = t0
  363. ld8 t1 = [t21]
  364. ;;
  365. add t17 = TrPreds - TrStFPSR, t17
  366. add t21 = PmsIntGp - PmsPreds, t21
  367. ;;
  368. st8 [t17] = t1, TrApUNAT - TrPreds
  369. mov t0 = ar.unat
  370. ;;
  371. st8 [t17] = t0, TrIntGp - TrApUNAT
  372. ld8 t1 = [t21], PmsIntSp - PmsIntGp
  373. ;;
  374. st8 [t17] = t1, TrIntSp - TrIntGp
  375. ld8 t0 = [t21], PmsIntTeb - PmsIntSp
  376. ;;
  377. st8 [t17] = t0, TrIntTeb - TrIntSp
  378. ld8 t1 = [t21], PmsIntT0 - PmsIntTeb
  379. ;;
  380. st8 [t17] = t1, TrRsRNAT - TrIntTeb
  381. mov t0 = ar.rnat
  382. ;;
  383. st8 [t17] = t0, TrBrT0 - TrRsRNAT
  384. mov t1 = bt0
  385. ;;
  386. st8 [t17] = t1, TrBrT1 - TrBrT0
  387. mov t0 = bt1
  388. ;;
  389. st8 [t17] = t0, TrApCCV-TrBrT1
  390. mov t1 = ar.ccv
  391. ;;
  392. st8 [t17] = t1, TrSegCSD - TrApCCV
  393. mov t0 = ar.csd
  394. ;;
  395. st8 [t17] = t0, TrIntT0 - TrSegCSD
  396. ld8 t1 = [t21], PmsIntT1 - PmsIntT0
  397. ;;
  398. st8 [t17] = t1, TrIntT1 - TrIntT0
  399. ld8 t0 = [t21], PmsIntV0 - PmsIntT1
  400. ;;
  401. st8 [t17] = t0, TrIntV0 - TrIntT1
  402. mov t16 = ar.lc
  403. mov t1 = 7
  404. ;;
  405. mov ar.lc = t1
  406. ;;
  407. iRegCopy1:
  408. ld8 t0 = [t21], 8
  409. ;;
  410. st8 [t17] = t0, 8
  411. br.ctop.sptk.few iRegCopy1
  412. ;;
  413. mov t1 = 15
  414. add t21 = PmsIntT7 - PmsB0R16, t21 // Skip over the bank 0 registers.
  415. ;;
  416. mov ar.lc = t1
  417. ;;
  418. iRegCopy2:
  419. ld8 t0 = [t21], 8
  420. ;;
  421. st8 [t17] = t0, 8
  422. br.ctop.sptk.few iRegCopy2
  423. ;;
  424. mov ar.lc = t16
  425. iEnableTranslation:
  426. // let us switch to virtual mode
  427. //
  428. // Need to do a "rfi" in order set "it" and "ed" bits in the PSR.
  429. //
  430. // Make sure interrupts are disabled and that we are running on bank 1.
  431. //
  432. rsm 1 << PSR_I
  433. bsw.1
  434. ;;
  435. //
  436. // psr mask prepration, warning we will have a problem with PMI here
  437. //
  438. movl t0 = MASK_IA64(PSR_BN,1) | MASK_IA64(PSR_IC,1) |MASK_IA64(PSR_DA,1) | MASK_IA64(PSR_IT,1) | MASK_IA64(PSR_RT,1) | MASK_IA64(PSR_DT,1) | MASK_IA64(PSR_MC,1);;
  439. mov t1=psr;;
  440. or t0=t0,t1
  441. movl t1=iVirtualSwitchDone;;
  442. mov cr.iip=t1;;
  443. movl t1 = FPSR_FOR_KERNEL /* initial fpsr value */;\
  444. mov cr.ipsr = t0;;
  445. mov ar.fpsr = t1;;
  446. rfi
  447. ;;
  448. iVirtualSwitchDone:
  449. // done with enabling address translation
  450. //
  451. // Set up arguments to the handler.
  452. //
  453. alloc t1 = 0, 0, 2, 0
  454. mov r32 = r11
  455. add r33 = ThreadStateSaveAreaLength+TrapFrameLength, sp
  456. // call our handler
  457. (pt1) movl t0=HalpMcaHandler;;
  458. (pt2) movl t0=HalpInitHandler;;
  459. mov b6=t0;;
  460. br.call.dpnt b0=b6
  461. ;;
  462. // psr mask prepration
  463. rsm MASK_IA64(PSR_IC,1);;
  464. movl t0 = MASK_IA64(PSR_DA,1) | MASK_IA64(PSR_IT,1) | MASK_IA64(PSR_RT,1) | MASK_IA64(PSR_DT,1);;
  465. movl t1=0xffffffffffffffff;;
  466. xor t0=t0,t1;;
  467. mov t1=psr;;
  468. and t0=t0,t1
  469. movl t1=BeginOsInitRestore;;
  470. tpa t1=t1;;
  471. mov cr.iip=t1;;
  472. mov cr.ipsr = t0;;
  473. rfi
  474. ;;
  475. BeginOsInitRestore:
  476. // restore the original stack frame here
  477. mov t16 = SerStackFrame
  478. movl t21 = KiPcr + PcOsMcaResourcePtr
  479. ;;
  480. tpa t1 = t21 // Calculate physical address of PCR OsInitResourcePtr
  481. sub t16 = t16, t21
  482. sub t0 = SerStateDumpPhysical, t21
  483. ;;
  484. ld8 rEventResources = [t1]
  485. add t16 = t1, t16
  486. add t0 = t1, t0
  487. ;;
  488. add t16 = rEventResources, t16 // Calculate the physical address of the Stack Frame
  489. add t0 = rEventResources, t0 // Calculate the physical address of the State Dump pointer.
  490. ;;
  491. ld8 t0 = [t0];
  492. movl t7 = PSRmcMask
  493. ;;
  494. RtnIntCxt( t7, t1, t16 ) // switch from interrupt context -> RSC mgmt.
  495. ;;
  496. //
  497. // let us restore all the registers from our PSI structure
  498. //
  499. mov t6 = gp
  500. br.dpnt osInitProcStateRestore
  501. ;;
  502. osInitDoneRestore:
  503. // Pal requires DFH of 0
  504. rsm 1 << PSR_DFH
  505. ;;
  506. rsm 1 << PSR_MFL // just restoring to original state only
  507. ;;
  508. srlz.d
  509. ;;
  510. //
  511. // - Restore processor state from OsToSalHandOff.
  512. //
  513. // - Branch back to SALE_CHECK.
  514. mov t1 = PcOsMcaResourcePtr
  515. movl t21 = KiPcr
  516. ;;
  517. tpa rPcrPhysicalAddress = t21 // Calculate physical address of PCR
  518. ;;
  519. add t0 = rPcrPhysicalAddress, t1
  520. sub t21 = SerOsToSalHandOff, t21
  521. ;;
  522. ld8 t1 = [t0], PcInOsInit-PcOsMcaResourcePtr
  523. add t21 = t21, rPcrPhysicalAddress
  524. ;;
  525. add t1 = t1, t21 // Calculate the physical address of the OsInitResources->SalToOSHandOff
  526. ;;
  527. add t16 = 0x8, t1
  528. add t17 = 0x10, t1
  529. ;;
  530. ld8 r8 = [t1], 0x18 // result of error handling
  531. ld8 r9 = [t16], 0x18 // physical SAL's GP value
  532. ld8 t22 = [t17] // new Processor Min-State Save Ptr
  533. ;;
  534. ld8 t1 = [t1] // SAL return address
  535. ld8 r10 = [t16] // New Context Switch Flag
  536. xchg1 t0 = [t0], r0 // KiPcr.InOsInit = 0
  537. ;;
  538. mov b0 = t1
  539. br.dpnt b0 // Return to SALE_CHECK
  540. ;;
  541. .endp HalpOsInitDispatch
  542. iStayInPhysicalMode::
  543. // we have to reboot the machine, assume the log is already there in NVM
  544. // OS can read the log next time when it comes around. Or OS can try to
  545. // run in physical mode as well.
  546. iResetNow:
  547. mov r8 = -2 // cold reset
  548. mov r9 = rSalGlobalPointer // SalReturnAddress
  549. mov r10 = r0 // return in the same context
  550. mov r22 = rProcMinStateSavePtr // Processor Min-State Save Area
  551. ;;
  552. mov b0 = rSalReturnAddress
  553. br.dpnt b0
  554. ;;
  555. #if 0
  556. // do EFI system reset here...
  557. // Go to BugCheck (in physical mode).
  558. // Out to Port 80: Fatal TLB error
  559. //
  560. #endif // 0
  561. iThyself:
  562. br iThyself // loop for safety
  563. ;;
  564. //EndMain//////////////////////////////////////////////////////////////////////
  565. //++
  566. // Name:
  567. // osInitProcStateDump()
  568. //
  569. // Stub Description:
  570. //
  571. // This stub dumps the processor state during MCHK to a data area
  572. //
  573. // On Entry:
  574. //
  575. // t0 = rPcrInitStateDump.
  576. //
  577. // Return Value:
  578. //
  579. // None.
  580. //
  581. //--
  582. osInitProcStateDump:
  583. // TF: ASSERT( t0 == rPcrInitStateDump )
  584. //save BRs
  585. add t2=Inc8,t0 // duplicate t0 in t2
  586. add t7=2*Inc8,t0 // duplicate t0 in t2
  587. mov t1=b0
  588. mov t3=b1
  589. mov t5=b2;;
  590. st8 [t0]=t1,3*Inc8
  591. st8 [t2]=t3,3*Inc8
  592. st8 [t7]=t5,3*Inc8;;
  593. mov t1=b3
  594. mov t3=b4
  595. mov t5=b5;;
  596. st8 [t0]=t1,3*Inc8
  597. st8 [t2]=t3,3*Inc8
  598. st8 [t7]=t5,3*Inc8;;
  599. mov t1=b6
  600. mov t3=b7;;
  601. st8 [t0]=t1,2*Inc8
  602. st8 [t2]=t3,2*Inc8;;
  603. icSaveCRs:
  604. // save CRs
  605. add t2=Inc8,t0 // duplicate t0 in t2
  606. add t7=2*Inc8,t0 // duplicate t0 in t2
  607. mov t1=cr0 // cr.dcr
  608. mov t3=cr1 // cr.itm
  609. mov t5=cr2;; // cr.iva
  610. st8 [t0]=t1,8*Inc8
  611. st8 [t2]=t3,3*Inc8
  612. st8 [t7]=t5,3*Inc8;; // 48 byte increments
  613. mov t1=cr8;; // cr.pta
  614. st8 [t0]=t1,Inc8*8;; // 64 byte increments
  615. // Reading interruption registers when PSR.ic=1 causes an illegal operation fault
  616. mov t1=psr;;
  617. tbit.nz.unc pt0,p0=t1,PSRic;; // PSI Valid Log bit pos. test
  618. (pt0) st8 [t0]=r0,9*8+160 // increment by 168 byte inc.
  619. (pt0) br.dpnt iSkipIntrRegs
  620. ;;
  621. add t2=Inc8,t0 // duplicate t0 in t2
  622. add t7=2*Inc8,t0 // duplicate t0 in t7
  623. mov t1=cr16 // cr.ipsr
  624. mov t3=cr17 // cr.isr
  625. mov t5=r0;; // cr.ida => cr18
  626. st8 [t0]=t1,3*Inc8
  627. st8 [t2]=t3,3*Inc8
  628. st8 [t7]=t5,3*Inc8;;
  629. mov t1=cr19 // cr.iip
  630. mov t3=cr20 // cr.ifa
  631. mov t5=cr21;; // cr.iitr
  632. st8 [t0]=t1,3*Inc8
  633. st8 [t2]=t3,3*Inc8
  634. st8 [t7]=t5,3*Inc8;;
  635. mov t1=cr22 // cr.iipa
  636. mov t3=cr23 // cr.ifs
  637. mov t5=cr24;; // cr.iim
  638. st8 [t0]=t1,3*Inc8
  639. st8 [t2]=t3,3*Inc8
  640. st8 [t7]=t5,3*Inc8;;
  641. mov t1=cr25;; // cr.iha
  642. st8 [t0]=t1,160;; // 160 byte increment
  643. iSkipIntrRegs:
  644. st8 [t0]=r0,168 // another 168 byte inc.
  645. mov t1=cr66;; // cr.lid
  646. st8 [t0]=t1,40 // 40 byte increment
  647. mov t1=cr71;; // cr.ivr
  648. st8 [t0]=t1,Inc8
  649. mov t1=cr72;; // cr.tpr
  650. st8 [t0]=t1,24 // 24 byte increment
  651. mov t1=r0;; // cr.eoi => cr75
  652. st8 [t0]=t1,168 // 168 byte inc.
  653. mov t1=r0;; // cr.irr0 => cr96
  654. st8 [t0]=t1,Inc16 // 16 byte inc.
  655. mov t1=r0;; // cr.irr1 => cr98
  656. st8 [t0]=t1,Inc16 // 16 byte inc.
  657. mov t1=r0;; // cr.irr2 => cr100
  658. st8 [t0]=t1,Inc16 // 16 byte inc
  659. mov t1=r0;; // cr.irt1 => cr100
  660. st8 [t0]=t1,Inc16 // 16b inc.
  661. mov t1=r0;; // cr.itv => cr114
  662. st8 [t0]=t1,Inc16 // 16 byte inc.
  663. mov t1=r0;; // cr.pmv => cr116
  664. st8 [t0]=t1,Inc8
  665. mov t1=r0;; // cr.lrr0 => cr117
  666. st8 [t0]=t1,Inc8
  667. mov t1=r0;; // cr.lrr1 => cr118
  668. st8 [t0]=t1,Inc8
  669. mov t1=r0;; // cr.cmcv => cr119
  670. st8 [t0]=t1,Inc8*10;;
  671. icSaveARs:
  672. // save ARs
  673. add t2=Inc8,t0 // duplicate t0 in t2
  674. add t7=2*Inc8,t0 // duplicate t0 in t7
  675. mov t1=ar0 // ar.kr0
  676. mov t3=ar1 // ar.kr1
  677. mov t5=ar2;; // ar.kr2
  678. st8 [t0]=t1,3*Inc8
  679. st8 [t2]=t3,3*Inc8
  680. st8 [t7]=t5,3*Inc8;;
  681. mov t1=ar3 // ar.kr3
  682. mov t3=ar4 // ar.kr4
  683. mov t5=ar5;; // ar.kr5
  684. st8 [t0]=t1,3*Inc8
  685. st8 [t2]=t3,3*Inc8
  686. st8 [t7]=t5,3*Inc8;;
  687. mov t1=ar6 // ar.kr6
  688. mov t3=ar7 // ar.kr7
  689. mov t5=r0;; // ar.kr8
  690. st8 [t0]=t1,10*Inc8
  691. st8 [t2]=t3,10*Inc8
  692. st8 [t7]=t5,10*Inc8;; // increment by 72 bytes
  693. mov t1=ar16 // ar.rsc
  694. mov t3=ar17 // ar.bsp
  695. mov t5=ar18;; // ar.bspstore
  696. st8 [t0]=t1,3*Inc8
  697. st8 [t2]=t3,3*Inc8
  698. st8 [t7]=t5,3*Inc8;;
  699. mov t1=ar19;; // ar.rnat
  700. st8 [t0]=t1,Inc8*13 // increment by 13x8 bytes
  701. mov t1=ar32;; // ar.ccv
  702. st8 [t0]=t1,Inc8*4
  703. mov t1=ar36;; // ar.unat
  704. st8 [t0]=t1,Inc8*4
  705. mov t1=ar40;; // ar.fpsr
  706. st8 [t0]=t1,Inc8*4
  707. mov t1=ar44;; // ar.itc
  708. st8 [t0]=t1,160 // 160
  709. mov t1=ar64;; // ar.pfs
  710. st8 [t0]=t1,Inc8
  711. mov t1=ar65;; // ar.lc
  712. st8 [t0]=t1,Inc8
  713. mov t1=ar66;; // ar.ec
  714. st8 [t0]=t1
  715. adds t0=Inc8*62,t0 //padding
  716. // save RRs
  717. mov ar.lc=0x08-1
  718. movl t2=0x00;;
  719. icStRR:
  720. mov t1=rr[t2];;
  721. st8 [t0]=t1,Inc8
  722. add t2=1,t2
  723. br.cloop.dpnt icStRR
  724. ;;
  725. // align memory addresses to 16 bytes
  726. and t1=0x0f,t0;;
  727. cmp.ne.unc pt0,p0=t1,r0;;
  728. (pt0) add t0=Inc8,t0
  729. icSaveFRs:
  730. // just save FP for INIT restore only, "C" code will trash f6-f15
  731. // save ar.NaT
  732. mov t3=ar.unat;; // ar.unat
  733. stf.spill [t0]=f6,Inc16;;
  734. stf.spill [t0]=f7,Inc16;;
  735. stf.spill [t0]=f8,Inc16;;
  736. stf.spill [t0]=f9,Inc16;;
  737. stf.spill [t0]=f10,Inc16;;
  738. stf.spill [t0]=f11,Inc16;;
  739. stf.spill [t0]=f12,Inc16;;
  740. stf.spill [t0]=f13,Inc16;;
  741. stf.spill [t0]=f14,Inc16;;
  742. stf.spill [t0]=f15,Inc16;;
  743. mov t2=ar.unat;;
  744. st8 [t0]=t2,Inc8 // save User NaT bits for r16-t11
  745. mov ar.unat=t3 // restore original unat
  746. br.dpnt osInitDoneDump
  747. ;;
  748. //EndStub//////////////////////////////////////////////////////////////////////
  749. //++
  750. // Name:
  751. // osInitProcStateRestore()
  752. //
  753. // Stub Description:
  754. //
  755. // This is a stub to restore the saved processor state during MCHK
  756. //
  757. // On Entry:
  758. //
  759. // t0 = rPcrInitStateDump.
  760. //
  761. // Return Value:
  762. //
  763. // None.
  764. //--
  765. osInitProcStateRestore:
  766. // TF: ASSERT( t0 == rPcrInitStateDump )
  767. // Restore bank1 GR16-31
  768. irestore_BRs:
  769. add t2=Inc8,t0 // duplicate t0 in t2
  770. add t7=2*Inc8,t0;; // duplicate t0 in t2
  771. ld8 t1=[t0],3*Inc8
  772. ld8 t3=[t2],3*Inc8
  773. ld8 t5=[t7],3*Inc8;;
  774. mov b0=t1
  775. mov b1=t3
  776. mov b2=t5;;
  777. ld8 t1=[t0],3*Inc8
  778. ld8 t3=[t2],3*Inc8
  779. ld8 t5=[t7],3*Inc8;;
  780. mov b3=t1
  781. mov b4=t3
  782. mov b5=t5;;
  783. ld8 t1=[t0],2*Inc8
  784. ld8 t3=[t2],2*Inc8;;
  785. mov b6=t1
  786. mov b7=t3;;
  787. irestore_CRs:
  788. add t2=Inc8,t0 // duplicate t0 in t2
  789. add t7=2*Inc8,t0;; // duplicate t0 in t2
  790. ld8 t1=[t0],8*Inc8
  791. ld8 t3=[t2],3*Inc8
  792. ld8 t5=[t7],3*Inc8;; // 48 byte increments
  793. mov cr0=t1 // cr.dcr
  794. mov cr1=t3 // cr.itm
  795. mov cr2=t5;; // cr.iva
  796. ld8 t1=[t0],8*Inc8;; // 64 byte increments
  797. // mov cr8=t1 // cr.pta
  798. // if PSR.ic=1, reading interruption registers causes an illegal operation fault
  799. mov t1=psr;;
  800. tbit.nz.unc pt0,p0=t1,PSRic;; // PSI Valid Log bit pos. test
  801. (pt0) st8 [t0]=r0,9*8+160 // increment by 160 byte inc.
  802. (pt0) br.dpnt irSkipIntrRegs
  803. ;;
  804. add t2=Inc8,t0 // duplicate t0 in t2
  805. add t7=2*Inc8,t0;; // duplicate t0 in t2
  806. ld8 t1=[t0],3*Inc8
  807. ld8 t3=[t2],3*Inc8
  808. ld8 t5=[t7],3*Inc8;;
  809. mov cr16=t1 // cr.ipsr
  810. mov cr17=t3 // cr.isr is read only
  811. // mov cr18=t5;; // cr.ida
  812. ld8 t1=[t0],3*Inc8
  813. ld8 t3=[t2],3*Inc8
  814. ld8 t5=[t7],3*Inc8;;
  815. mov cr19=t1 // cr.iip
  816. mov cr20=t3 // cr.idtr
  817. mov cr21=t5;; // cr.iitr
  818. ld8 t1=[t0],3*Inc8
  819. ld8 t3=[t2],3*Inc8
  820. ld8 t5=[t7],3*Inc8;;
  821. mov cr22=t1 // cr.iipa
  822. mov cr23=t3 // cr.ifs
  823. mov cr24=t5 // cr.iim
  824. ld8 t1=[t0],160;; // 160 byte increment
  825. mov cr25=t1 // cr.iha
  826. irSkipIntrRegs:
  827. ld8 t1=[t0],168;; // another 168 byte inc.
  828. ld8 t1=[t0],40;; // 40 byte increment
  829. mov cr66=t1 // cr.lid
  830. ld8 t1=[t0],Inc8;;
  831. // mov cr71=t1 // cr.ivr is read only
  832. ld8 t1=[t0],24;; // 24 byte increment
  833. mov cr72=t1 // cr.tpr
  834. ld8 t1=[t0],168;; // 168 byte inc.
  835. // mov cr75=t1 // cr.eoi
  836. ld8 t1=[t0],Inc16;; // 16 byte inc.
  837. // mov cr96=t1 // cr.irr0 is read only
  838. ld8 t1=[t0],Inc16;; // 16 byte inc.
  839. // mov cr98=t1 // cr.irr1 is read only
  840. ld8 t1=[t0],Inc16;; // 16 byte inc
  841. // mov cr100=t1 // cr.irr2 is read only
  842. ld8 t1=[t0],Inc16;; // 16b inc.
  843. // mov cr102=t1 // cr.irt1 is read only
  844. ld8 t1=[t0],Inc16;; // 16 byte inc.
  845. // mov cr114=t1 // cr.itv
  846. ld8 t1=[t0],Inc8;;
  847. // mov cr116=t1 // cr.pmv
  848. ld8 t1=[t0],Inc8;;
  849. // mov cr117=t1 // cr.lrr0
  850. ld8 t1=[t0],Inc8;;
  851. // mov cr118=t1 // cr.lrr1
  852. ld8 t1=[t0],Inc8*10;;
  853. // mov cr119=t1 // cr.cmcv
  854. irestore_ARs:
  855. add t2=Inc8,t0 // duplicate t0 in t2
  856. add t7=2*Inc8,t0;; // duplicate t0 in t2
  857. ld8 t1=[t0],3*Inc8
  858. ld8 t3=[t2],3*Inc8
  859. ld8 t5=[t7],3*Inc8;;
  860. mov ar0=t1 // ar.kro
  861. mov ar1=t3 // ar.kr1
  862. mov ar2=t5;; // ar.kr2
  863. ld8 t1=[t0],3*Inc8
  864. ld8 t3=[t2],3*Inc8
  865. ld8 t5=[t7],3*Inc8;;
  866. mov ar3=t1 // ar.kr3
  867. mov ar4=t3 // ar.kr4
  868. mov ar5=t5;; // ar.kr5
  869. ld8 t1=[t0],10*Inc8
  870. ld8 t3=[t2],10*Inc8
  871. ld8 t5=[t7],10*Inc8;;
  872. mov ar6=t1 // ar.kr6
  873. mov ar7=t3 // ar.kr7
  874. // mov ar8=t7 // ar.kr8
  875. ;;
  876. ld8 t1=[t0],3*Inc8
  877. ld8 t3=[t2],3*Inc8
  878. ld8 t5=[t7],3*Inc8;;
  879. // mov ar16=t1 // ar.rsc
  880. // mov ar17=t3 // ar.bsp is read only
  881. mov ar18=t5;; // ar.bspstore
  882. ld8 t1=[t0],Inc8*13;;
  883. mov ar19=t1 // ar.rnat
  884. ld8 t1=[t0],Inc8*4;;
  885. mov ar32=t1 // ar.ccv
  886. ld8 t1=[t0],Inc8*4;;
  887. mov ar36=t1 // ar.unat
  888. ld8 t1=[t0],Inc8*4;;
  889. mov ar40=t1 // ar.fpsr
  890. ld8 t1=[t0],160;; // 160
  891. // mov ar44=t1 // ar.itc
  892. ld8 t1=[t0],Inc8;;
  893. mov ar64=t1 // ar.pfs
  894. ld8 t1=[t0],Inc8;;
  895. mov ar65=t1 // ar.lc
  896. ld8 t1=[t0];;
  897. mov ar66=t1 // ar.ec
  898. adds t0=Inc8*62,t0;; // padding
  899. irestore_RRs:
  900. mov t3=ar.lc
  901. mov ar.lc=0x08-1
  902. movl t2=0x00
  903. icStRRr:
  904. ld8 t1=[t0],Inc8;;
  905. // mov rr[t2]=t1 // what are its access previledges?
  906. add t2=1,t2
  907. br.cloop.dpnt icStRRr
  908. ;;
  909. mov ar.lc=t3
  910. // align memory addresses to 16 bytes
  911. and t1=0x0f,t0;;
  912. cmp.ne.unc pt0,p0=t1,r0;;
  913. (pt0) add t0=Inc8,t0;;
  914. // restore FP's which might be trashed by the "C" code
  915. mov t3=ar.unat
  916. add t1=16*10,t0;; // to get to NaT of GR 16-31
  917. ld8 t1=[t1];;
  918. mov ar.unat=t1;; // first restore NaT
  919. irestore_FRs:
  920. ldf.fill f6=[t0],Inc16;;
  921. ldf.fill f7=[t0],Inc16;;
  922. ldf.fill f8=[t0],Inc16;;
  923. ldf.fill f9=[t0],Inc16;;
  924. ldf.fill f10=[t0],Inc16;;
  925. ldf.fill f11=[t0],Inc16;;
  926. ldf.fill f12=[t0],Inc16;;
  927. ldf.fill f13=[t0],Inc16;;
  928. ldf.fill f14=[t0],Inc16;;
  929. ldf.fill f15=[t0],Inc16;;
  930. mov ar.unat=t3 // restore original NaT
  931. br.dpnt osInitDoneRestore
  932. ;;
  933. //EndStub//////////////////////////////////////////////////////////////////////