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.

1065 lines
36 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], PcInOsInit-PcOsMcaResourcePtr
  179. ;;
  180. (pt2) ld8 rEventResources = [t0], PcInOsMca-PcOsMcaResourcePtr
  181. mov t18 = SerPTOM
  182. add t20 = 0x8, t19
  183. ;;
  184. xchg1 t1 = [t0], t1
  185. add rEventResources = rEventResources, t21 // Calculate the physical address of the OsMcaResources
  186. add t21 = 0x10, t19
  187. ;;
  188. add t18 = rEventResources, t18
  189. add t19 = rEventResources, t19
  190. add t20 = rEventResources, t20
  191. add t21 = rEventResources, t21
  192. ;;
  193. ld8 t17 = [t16]
  194. st8 [t19] = rPalProcEntryPoint, 0x18
  195. add t0 = SerStateDumpPhysical, rEventResources
  196. ;;
  197. st8 [t18] = t17
  198. st8 [t20] = rSalProcEntryPoint, 0x18
  199. st8 [t21] = rSalGlobalPointer, 0x18
  200. ;;
  201. st8 [t19] = rRendezVousResult
  202. st8 [t20] = rSalReturnAddress
  203. st8 [t21] = rProcMinStateSavePtr
  204. ld8 t0 = [t0] // InitStateDump
  205. ;;
  206. //
  207. // Save in preserved registers:
  208. // - pointer to processor minimum state save area,
  209. // - processor state parameter
  210. // - PAL_CHECK return address.
  211. // s0 [=r4] <- r17,
  212. // s1 [=r5] <- r18,
  213. // s2 [=r6] <- r19
  214. //
  215. SaveRs(rProcMinStateSavePtr, rProcStateParameter, rPalCheckReturnAddress)
  216. br.dpnt osInitProcStateDump
  217. ;;
  218. osInitDoneDump:
  219. //
  220. // If we have a TLB error, we cannot enable translation
  221. //
  222. tbit.nz.unc pt0,p0=s1, 60 // PSP.tc=60
  223. (pt0) br.dpnt iResetNow
  224. ;;
  225. //
  226. // Initialize current sp and ar.bsp and ar.bspstore
  227. //
  228. // KiPcr.InitStackFrame[0] = ar.rsc
  229. // KiPcr.InitStackFrame[1] = ar.pfs
  230. // KiPcr.InitStackFrame[2] = ar.ifs
  231. // KiPcr.InitStackFrame[3] = ar.bspstore
  232. // KiPcr.InitStackFrame[4] = ar.rnat
  233. // ar.bspstore = t0 [=KiPcr.InitBspStore]
  234. // KiPcr.InitStackFrame[5] = ar.bsp - KiPcr.InitBspStore
  235. // [BUGBUG ?? : should be ar.bsptore=KiPcr.InitStackFrame[3]]
  236. // sp = KiPcr.InitStack
  237. //
  238. movl t21 = KiPcr + PcOsMcaResourcePtr
  239. ;;
  240. tpa t0 = t21 // Calculate physical address of PCR OsInitResourcePtr
  241. mov t1 = SerStateDumpPhysical
  242. ;;
  243. sub t16 = SerBackStore, t21
  244. sub t1 = t1, t21
  245. ;;
  246. add t16 = t0, t16
  247. add t1 = t0, t1
  248. ld8 rEventResources = [t0], PcInitialBStore - PcOsMcaResourcePtr
  249. ;;
  250. add t16 = rEventResources, t16 // Calculate physical address of the new BSP
  251. mov t21 = t0 // t21 now points to InitialBStore in the PCR
  252. ;;
  253. add t1 = rEventResources, t1 // Calculate the physical address of State Dump physical pointer
  254. ld8 t3 = [t16], SerStack - SerBackStore // t3 contains the initial BSP.
  255. ;;
  256. ld8 t7 = [t1] // t7 now contain the physical address of the state dump area
  257. ;; // and the physical top of stack
  258. st8 [t21] = t3, PcInitialStack - PcInitialBStore // Save the InitialBStore in the PCR
  259. ld8 t1 = [t16], SerBackStoreLimit - SerStack // Get inital Init stack
  260. ;;
  261. st8 [t21] = t1, PcBStoreLimit - PcInitialStack
  262. ld8 t0 = [t16], SerStackLimit - SerBackStoreLimit
  263. ;;
  264. add t1 = -STACK_SCRATCH_AREA-ThreadStateSaveAreaLength-TrapFrameLength-PalMiniSaveLength, t1
  265. add t7 = -STACK_SCRATCH_AREA-ThreadStateSaveAreaLength-TrapFrameLength-PalMiniSaveLength, t7
  266. st8 [t21] = t0, PcStackLimit - PcBStoreLimit // Save BStore limit
  267. ld8 t18 = [t16]
  268. ;;
  269. mov sp = t1
  270. st8 [t21] = t18, PcCurrentIrql - PcStackLimit
  271. ;;
  272. ld1 t1 = [t21]
  273. //
  274. // Copy the PAL Mini-save area to the stack. It must be accessed non-cached.
  275. // t7 contains the physical address for the trap frame.
  276. // r4 contains the minium save area physical address.
  277. //
  278. mov t16 = ar.lc // Save lc
  279. mov t0 = PalMiniSaveLength/8
  280. ;;
  281. add t21 = ThreadStateSaveAreaLength+TrapFrameLength, t7 // Calculate stack physical address
  282. // of PAL mini save area is saved.
  283. dep t17 = 1, r4, 63, 1 // Non-cached address of PAL mini save area
  284. mov ar.lc = t0
  285. ;;
  286. iCopyMini:
  287. ld8 t0 = [t17],8
  288. ;;
  289. st8 [t21] = t0,8
  290. br.ctop.sptk.few iCopyMini
  291. ;;
  292. mov ar.lc = t16 // Restore lc
  293. mov ar.rsc = r0 // put RSE in lazy mode and use kernel mode stores.
  294. ;;
  295. //
  296. // Generate a excpetion trap frame.
  297. // t7 contains the physical address for the trap frame.
  298. // t3 contains the initial BSP
  299. //
  300. add t17=TrOldIrql, t7
  301. add t21 = ThreadStateSaveAreaLength+TrapFrameLength+PmsRsRSC, t7 // Calculate stack physical address
  302. cover // of PAL mini save area of RSE.
  303. ;;
  304. st1 [t17] = t1, TrEOFMarker - TrOldIrql
  305. movl t0 = KTRAP_FRAME_EOF | EXCEPTION_FRAME
  306. ;;
  307. st8 [t17] = t0
  308. mov t1 = ar.bspstore
  309. ;;
  310. mov t0 = ar.bsp
  311. ld8 t18 = [t21],PmsStIIP - PmsRsRSC
  312. add t17 = TrRsBSP - TrEOFMarker, t17
  313. ;;
  314. dep t3 = t1, t3, 0, 9 // Adjust new BSPSTORE for NATs
  315. st8 [t17] = t0,TrRsBSPSTORE - TrRsBSP
  316. ;;
  317. sub t0 = t0, t1
  318. st8 [t17] = t1, TrRsRSC - TrRsBSPSTORE // Save old BspStore
  319. ;;
  320. dep t18 = t0, t18, RSC_MBZ1, RSC_LOADRS_LEN
  321. mov ar.bspstore = t3
  322. ld8 t1 = [t21], PmsStIPSR - PmsStIIP // Copy IIP to trap frame as IIP
  323. ;;
  324. st8 [t17] = t18, TrStIIP - TrRsRSC
  325. ld8 t0 = [t21], PmsStIFS - PmsStIPSR // Copy IPSR to trap frame as IPSR
  326. ;;
  327. st8 [t17] = t1, TrStIPSR - TrStIIP
  328. ;;
  329. st8 [t17] = t0, TrStIFS - TrStIPSR
  330. ld8 t1 = [t21], PmsBrRp - PmsStIFS // Copy IFS to trap frame as IFS
  331. ;;
  332. st8 [t17] = t1, TrBrRp - TrStIFS
  333. ld8 t0 = [t21], PmsPreds - PmsBrRp
  334. ;;
  335. st8 [t17] = t0, TrStISR - TrBrRp
  336. mov t1 = cr.isr
  337. ;;
  338. st8 [t17] = t1, TrRsPFS - TrStISR
  339. mov t0 = ar.pfs
  340. ;;
  341. st8 [t17] = t0, TrStIIPA - TrRsPFS
  342. mov t1 = cr.iipa
  343. ;;
  344. st8 [t17] = t1, TrStIIM - TrStIIPA
  345. mov t0 = cr.iim
  346. ;;
  347. st8 [t17] = t0, TrStIHA - TrStIIM
  348. mov t1 = cr.iha
  349. ;;
  350. st8 [t17] = t0, TrStFPSR - TrStIHA
  351. mov t0 = ar.fpsr
  352. ;;
  353. st8 [t17] = t0
  354. ld8 t1 = [t21]
  355. ;;
  356. add t17 = TrPreds - TrStFPSR, t17
  357. add t21 = PmsIntGp - PmsPreds, t21
  358. ;;
  359. st8 [t17] = t1, TrApUNAT - TrPreds
  360. mov t0 = ar.unat
  361. ;;
  362. st8 [t17] = t0, TrIntGp - TrApUNAT
  363. ld8 t1 = [t21], PmsIntSp - PmsIntGp
  364. ;;
  365. st8 [t17] = t1, TrIntSp - TrIntGp
  366. ld8 t0 = [t21], PmsIntTeb - PmsIntSp
  367. ;;
  368. st8 [t17] = t0, TrIntTeb - TrIntSp
  369. ld8 t1 = [t21], PmsIntT0 - PmsIntTeb
  370. ;;
  371. st8 [t17] = t1, TrRsRNAT - TrIntTeb
  372. mov t0 = ar.rnat
  373. ;;
  374. st8 [t17] = t0, TrBrT0 - TrRsRNAT
  375. mov t1 = bt0
  376. ;;
  377. st8 [t17] = t1, TrBrT1 - TrBrT0
  378. mov t0 = bt1
  379. ;;
  380. st8 [t17] = t0, TrApCCV-TrBrT1
  381. mov t1 = ar.ccv
  382. ;;
  383. st8 [t17] = t1, TrApDCR - TrApCCV
  384. mov t0 = cr.dcr
  385. ;;
  386. st8 [t17] = t0, TrIntT0 - TrApDCR
  387. ld8 t1 = [t21], PmsIntT1 - PmsIntT0
  388. ;;
  389. st8 [t17] = t1, TrIntT1 - TrIntT0
  390. ld8 t0 = [t21], PmsIntV0 - PmsIntT1
  391. ;;
  392. st8 [t17] = t0, TrIntV0 - TrIntT1
  393. mov t16 = ar.lc
  394. mov t1 = 7
  395. ;;
  396. mov ar.lc = t1
  397. ;;
  398. iRegCopy1:
  399. ld8 t0 = [t21], 8
  400. ;;
  401. st8 [t17] = t0, 8
  402. br.ctop.sptk.few iRegCopy1
  403. ;;
  404. mov t1 = 15
  405. add t21 = PmsIntT7 - PmsB0R16, t21 // Skip over the bank 0 registers.
  406. ;;
  407. mov ar.lc = t1
  408. ;;
  409. iRegCopy2:
  410. ld8 t0 = [t21], 8
  411. ;;
  412. st8 [t17] = t0, 8
  413. br.ctop.sptk.few iRegCopy2
  414. ;;
  415. mov ar.lc = t16
  416. iEnableTranslation:
  417. // let us switch to virtual mode
  418. //
  419. // Need to do a "rfi" in order set "it" and "ed" bits in the PSR.
  420. //
  421. // Make sure interrupts are disabled and that we are running on bank 1.
  422. //
  423. rsm 1 << PSR_I
  424. bsw.1
  425. ;;
  426. //
  427. // psr mask prepration, warning we will have a problem with PMI here
  428. //
  429. 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);;
  430. mov t1=psr;;
  431. or t0=t0,t1
  432. movl t1=iVirtualSwitchDone;;
  433. mov cr.iip=t1;;
  434. movl t1 = FPSR_FOR_KERNEL /* initial fpsr value */;\
  435. mov cr.ipsr = t0;;
  436. mov ar.fpsr = t1;;
  437. rfi
  438. ;;
  439. iVirtualSwitchDone:
  440. // done with enabling address translation
  441. //
  442. // Set up arguments to the handler.
  443. //
  444. alloc t1 = 0, 0, 2, 0
  445. mov r32 = r11
  446. add r33 = ThreadStateSaveAreaLength+TrapFrameLength, sp
  447. // call our handler
  448. (pt1) movl t0=HalpMcaHandler;;
  449. (pt2) movl t0=HalpInitHandler;;
  450. mov b6=t0;;
  451. br.call.dpnt b0=b6
  452. ;;
  453. // psr mask prepration
  454. rsm MASK_IA64(PSR_IC,1);;
  455. movl t0 = MASK_IA64(PSR_DA,1) | MASK_IA64(PSR_IT,1) | MASK_IA64(PSR_RT,1) | MASK_IA64(PSR_DT,1);;
  456. movl t1=0xffffffffffffffff;;
  457. xor t0=t0,t1;;
  458. mov t1=psr;;
  459. and t0=t0,t1
  460. movl t1=BeginOsInitRestore;;
  461. tpa t1=t1;;
  462. mov cr.iip=t1;;
  463. mov cr.ipsr = t0;;
  464. rfi
  465. ;;
  466. BeginOsInitRestore:
  467. // restore the original stack frame here
  468. mov t16 = SerStackFrame
  469. movl t21 = KiPcr + PcOsMcaResourcePtr
  470. ;;
  471. tpa t1 = t21 // Calculate physical address of PCR OsInitResourcePtr
  472. sub t16 = t16, t21
  473. sub t0 = SerStateDumpPhysical, t21
  474. ;;
  475. ld8 rEventResources = [t1]
  476. add t16 = t1, t16
  477. add t0 = t1, t0
  478. ;;
  479. add t16 = rEventResources, t16 // Calculate the physical address of the Stack Frame
  480. add t0 = rEventResources, t0 // Calculate the physical address of the State Dump pointer.
  481. ;;
  482. ld8 t0 = [t0];
  483. movl t7 = PSRmcMask
  484. ;;
  485. RtnIntCxt( t7, t1, t16 ) // switch from interrupt context -> RSC mgmt.
  486. ;;
  487. //
  488. // let us restore all the registers from our PSI structure
  489. //
  490. mov t6 = gp
  491. br.dpnt osInitProcStateRestore
  492. ;;
  493. osInitDoneRestore:
  494. // Pal requires DFH of 0
  495. rsm 1 << PSR_DFH
  496. ;;
  497. rsm 1 << PSR_MFL // just restoring to original state only
  498. ;;
  499. srlz.d
  500. ;;
  501. //
  502. // - Restore processor state from OsToSalHandOff.
  503. //
  504. // - Branch back to SALE_CHECK.
  505. mov t1 = PcOsMcaResourcePtr
  506. movl t21 = KiPcr
  507. ;;
  508. tpa rPcrPhysicalAddress = t21 // Calculate physical address of PCR
  509. ;;
  510. add t0 = rPcrPhysicalAddress, t1
  511. sub t21 = SerOsToSalHandOff, t21
  512. ;;
  513. ld8 t1 = [t0], PcInOsInit-PcOsMcaResourcePtr
  514. add t21 = t21, rPcrPhysicalAddress
  515. ;;
  516. add t1 = t1, t21 // Calculate the physical address of the OsInitResources->SalToOSHandOff
  517. ;;
  518. add t16 = 0x8, t1
  519. add t17 = 0x10, t1
  520. ;;
  521. ld8 r8 = [t1], 0x18 // result of error handling
  522. ld8 r9 = [t16], 0x18 // physical SAL's GP value
  523. ld8 t22 = [t17] // new Processor Min-State Save Ptr
  524. ;;
  525. ld8 t1 = [t1] // SAL return address
  526. ld8 r10 = [t16] // New Context Switch Flag
  527. xchg1 t0 = [t0], r0 // KiPcr.InOsInit = 0
  528. ;;
  529. mov b0 = t1
  530. br.dpnt b0 // Return to SALE_CHECK
  531. ;;
  532. .endp HalpOsInitDispatch
  533. iStayInPhysicalMode::
  534. // we have to reboot the machine, assume the log is already there in NVM
  535. // OS can read the log next time when it comes around. Or OS can try to
  536. // run in physical mode as well.
  537. iResetNow:
  538. // do EFI system reset here...
  539. // Go to BugCheck (in physical mode).
  540. // Out to Port 80: Fatal TLB error
  541. //
  542. iThyself:
  543. br iThyself // loop for safety
  544. ;;
  545. //EndMain//////////////////////////////////////////////////////////////////////
  546. //++
  547. // Name:
  548. // osInitProcStateDump()
  549. //
  550. // Stub Description:
  551. //
  552. // This stub dumps the processor state during MCHK to a data area
  553. //
  554. // On Entry:
  555. //
  556. // t0 = rPcrInitStateDump.
  557. //
  558. // Return Value:
  559. //
  560. // None.
  561. //
  562. //--
  563. osInitProcStateDump:
  564. // TF: ASSERT( t0 == rPcrInitStateDump )
  565. //save BRs
  566. add t2=Inc8,t0 // duplicate t0 in t2
  567. add t7=2*Inc8,t0 // duplicate t0 in t2
  568. mov t1=b0
  569. mov t3=b1
  570. mov t5=b2;;
  571. st8 [t0]=t1,3*Inc8
  572. st8 [t2]=t3,3*Inc8
  573. st8 [t7]=t5,3*Inc8;;
  574. mov t1=b3
  575. mov t3=b4
  576. mov t5=b5;;
  577. st8 [t0]=t1,3*Inc8
  578. st8 [t2]=t3,3*Inc8
  579. st8 [t7]=t5,3*Inc8;;
  580. mov t1=b6
  581. mov t3=b7;;
  582. st8 [t0]=t1,2*Inc8
  583. st8 [t2]=t3,2*Inc8;;
  584. icSaveCRs:
  585. // save CRs
  586. add t2=Inc8,t0 // duplicate t0 in t2
  587. add t7=2*Inc8,t0 // duplicate t0 in t2
  588. mov t1=cr0 // cr.dcr
  589. mov t3=cr1 // cr.itm
  590. mov t5=cr2;; // cr.iva
  591. st8 [t0]=t1,8*Inc8
  592. st8 [t2]=t3,3*Inc8
  593. st8 [t7]=t5,3*Inc8;; // 48 byte increments
  594. mov t1=cr8;; // cr.pta
  595. st8 [t0]=t1,Inc8*8;; // 64 byte increments
  596. // Reading interruption registers when PSR.ic=1 causes an illegal operation fault
  597. mov t1=psr;;
  598. tbit.nz.unc pt0,p0=t1,PSRic;; // PSI Valid Log bit pos. test
  599. (pt0) st8 [t0]=r0,9*8+160 // increment by 168 byte inc.
  600. (pt0) br.dpnt iSkipIntrRegs
  601. ;;
  602. add t2=Inc8,t0 // duplicate t0 in t2
  603. add t7=2*Inc8,t0 // duplicate t0 in t7
  604. mov t1=cr16 // cr.ipsr
  605. mov t3=cr17 // cr.isr
  606. mov t5=r0;; // cr.ida => cr18
  607. st8 [t0]=t1,3*Inc8
  608. st8 [t2]=t3,3*Inc8
  609. st8 [t7]=t5,3*Inc8;;
  610. mov t1=cr19 // cr.iip
  611. mov t3=cr20 // cr.ifa
  612. mov t5=cr21;; // cr.iitr
  613. st8 [t0]=t1,3*Inc8
  614. st8 [t2]=t3,3*Inc8
  615. st8 [t7]=t5,3*Inc8;;
  616. mov t1=cr22 // cr.iipa
  617. mov t3=cr23 // cr.ifs
  618. mov t5=cr24;; // cr.iim
  619. st8 [t0]=t1,3*Inc8
  620. st8 [t2]=t3,3*Inc8
  621. st8 [t7]=t5,3*Inc8;;
  622. mov t1=cr25;; // cr.iha
  623. st8 [t0]=t1,160;; // 160 byte increment
  624. iSkipIntrRegs:
  625. st8 [t0]=r0,168 // another 168 byte inc.
  626. mov t1=cr66;; // cr.lid
  627. st8 [t0]=t1,40 // 40 byte increment
  628. mov t1=cr71;; // cr.ivr
  629. st8 [t0]=t1,Inc8
  630. mov t1=cr72;; // cr.tpr
  631. st8 [t0]=t1,24 // 24 byte increment
  632. mov t1=r0;; // cr.eoi => cr75
  633. st8 [t0]=t1,168 // 168 byte inc.
  634. mov t1=r0;; // cr.irr0 => cr96
  635. st8 [t0]=t1,Inc16 // 16 byte inc.
  636. mov t1=r0;; // cr.irr1 => cr98
  637. st8 [t0]=t1,Inc16 // 16 byte inc.
  638. mov t1=r0;; // cr.irr2 => cr100
  639. st8 [t0]=t1,Inc16 // 16 byte inc
  640. mov t1=r0;; // cr.irt1 => cr100
  641. st8 [t0]=t1,Inc16 // 16b inc.
  642. mov t1=r0;; // cr.itv => cr114
  643. st8 [t0]=t1,Inc16 // 16 byte inc.
  644. mov t1=r0;; // cr.pmv => cr116
  645. st8 [t0]=t1,Inc8
  646. mov t1=r0;; // cr.lrr0 => cr117
  647. st8 [t0]=t1,Inc8
  648. mov t1=r0;; // cr.lrr1 => cr118
  649. st8 [t0]=t1,Inc8
  650. mov t1=r0;; // cr.cmcv => cr119
  651. st8 [t0]=t1,Inc8*10;;
  652. icSaveARs:
  653. // save ARs
  654. add t2=Inc8,t0 // duplicate t0 in t2
  655. add t7=2*Inc8,t0 // duplicate t0 in t7
  656. mov t1=ar0 // ar.kr0
  657. mov t3=ar1 // ar.kr1
  658. mov t5=ar2;; // ar.kr2
  659. st8 [t0]=t1,3*Inc8
  660. st8 [t2]=t3,3*Inc8
  661. st8 [t7]=t5,3*Inc8;;
  662. mov t1=ar3 // ar.kr3
  663. mov t3=ar4 // ar.kr4
  664. mov t5=ar5;; // ar.kr5
  665. st8 [t0]=t1,3*Inc8
  666. st8 [t2]=t3,3*Inc8
  667. st8 [t7]=t5,3*Inc8;;
  668. mov t1=ar6 // ar.kr6
  669. mov t3=ar7 // ar.kr7
  670. mov t5=r0;; // ar.kr8
  671. st8 [t0]=t1,10*Inc8
  672. st8 [t2]=t3,10*Inc8
  673. st8 [t7]=t5,10*Inc8;; // increment by 72 bytes
  674. mov t1=ar16 // ar.rsc
  675. mov t3=ar17 // ar.bsp
  676. mov t5=ar18;; // ar.bspstore
  677. st8 [t0]=t1,3*Inc8
  678. st8 [t2]=t3,3*Inc8
  679. st8 [t7]=t5,3*Inc8;;
  680. mov t1=ar19;; // ar.rnat
  681. st8 [t0]=t1,Inc8*13 // increment by 13x8 bytes
  682. mov t1=ar32;; // ar.ccv
  683. st8 [t0]=t1,Inc8*4
  684. mov t1=ar36;; // ar.unat
  685. st8 [t0]=t1,Inc8*4
  686. mov t1=ar40;; // ar.fpsr
  687. st8 [t0]=t1,Inc8*4
  688. mov t1=ar44;; // ar.itc
  689. st8 [t0]=t1,160 // 160
  690. mov t1=ar64;; // ar.pfs
  691. st8 [t0]=t1,Inc8
  692. mov t1=ar65;; // ar.lc
  693. st8 [t0]=t1,Inc8
  694. mov t1=ar66;; // ar.ec
  695. st8 [t0]=t1
  696. adds t0=Inc8*62,t0 //padding
  697. // save RRs
  698. mov ar.lc=0x08-1
  699. movl t2=0x00;;
  700. icStRR:
  701. mov t1=rr[t2];;
  702. st8 [t0]=t1,Inc8
  703. add t2=1,t2
  704. br.cloop.dpnt icStRR
  705. ;;
  706. // align memory addresses to 16 bytes
  707. and t1=0x0f,t0;;
  708. cmp.ne.unc pt0,p0=t1,r0;;
  709. (pt0) add t0=Inc8,t0
  710. icSaveFRs:
  711. // just save FP for INIT restore only, "C" code will trash f6-f15
  712. // save ar.NaT
  713. mov t3=ar.unat;; // ar.unat
  714. stf.spill [t0]=f6,Inc16;;
  715. stf.spill [t0]=f7,Inc16;;
  716. stf.spill [t0]=f8,Inc16;;
  717. stf.spill [t0]=f9,Inc16;;
  718. stf.spill [t0]=f10,Inc16;;
  719. stf.spill [t0]=f11,Inc16;;
  720. stf.spill [t0]=f12,Inc16;;
  721. stf.spill [t0]=f13,Inc16;;
  722. stf.spill [t0]=f14,Inc16;;
  723. stf.spill [t0]=f15,Inc16;;
  724. mov t2=ar.unat;;
  725. st8 [t0]=t2,Inc8 // save User NaT bits for r16-t11
  726. mov ar.unat=t3 // restore original unat
  727. br.dpnt osInitDoneDump
  728. ;;
  729. //EndStub//////////////////////////////////////////////////////////////////////
  730. //++
  731. // Name:
  732. // osInitProcStateRestore()
  733. //
  734. // Stub Description:
  735. //
  736. // This is a stub to restore the saved processor state during MCHK
  737. //
  738. // On Entry:
  739. //
  740. // t0 = rPcrInitStateDump.
  741. //
  742. // Return Value:
  743. //
  744. // None.
  745. //--
  746. osInitProcStateRestore:
  747. // TF: ASSERT( t0 == rPcrInitStateDump )
  748. // Restore bank1 GR16-31
  749. irestore_BRs:
  750. add t2=Inc8,t0 // duplicate t0 in t2
  751. add t7=2*Inc8,t0;; // duplicate t0 in t2
  752. ld8 t1=[t0],3*Inc8
  753. ld8 t3=[t2],3*Inc8
  754. ld8 t5=[t7],3*Inc8;;
  755. mov b0=t1
  756. mov b1=t3
  757. mov b2=t5;;
  758. ld8 t1=[t0],3*Inc8
  759. ld8 t3=[t2],3*Inc8
  760. ld8 t5=[t7],3*Inc8;;
  761. mov b3=t1
  762. mov b4=t3
  763. mov b5=t5;;
  764. ld8 t1=[t0],2*Inc8
  765. ld8 t3=[t2],2*Inc8;;
  766. mov b6=t1
  767. mov b7=t3;;
  768. irestore_CRs:
  769. add t2=Inc8,t0 // duplicate t0 in t2
  770. add t7=2*Inc8,t0;; // duplicate t0 in t2
  771. ld8 t1=[t0],8*Inc8
  772. ld8 t3=[t2],3*Inc8
  773. ld8 t5=[t7],3*Inc8;; // 48 byte increments
  774. mov cr0=t1 // cr.dcr
  775. mov cr1=t3 // cr.itm
  776. mov cr2=t5;; // cr.iva
  777. ld8 t1=[t0],8*Inc8;; // 64 byte increments
  778. // mov cr8=t1 // cr.pta
  779. // if PSR.ic=1, reading interruption registers causes an illegal operation fault
  780. mov t1=psr;;
  781. tbit.nz.unc pt0,p0=t1,PSRic;; // PSI Valid Log bit pos. test
  782. (pt0) st8 [t0]=r0,9*8+160 // increment by 160 byte inc.
  783. (pt0) br.dpnt irSkipIntrRegs
  784. ;;
  785. add t2=Inc8,t0 // duplicate t0 in t2
  786. add t7=2*Inc8,t0;; // duplicate t0 in t2
  787. ld8 t1=[t0],3*Inc8
  788. ld8 t3=[t2],3*Inc8
  789. ld8 t5=[t7],3*Inc8;;
  790. mov cr16=t1 // cr.ipsr
  791. mov cr17=t3 // cr.isr is read only
  792. // mov cr18=t5;; // cr.ida
  793. ld8 t1=[t0],3*Inc8
  794. ld8 t3=[t2],3*Inc8
  795. ld8 t5=[t7],3*Inc8;;
  796. mov cr19=t1 // cr.iip
  797. mov cr20=t3 // cr.idtr
  798. mov cr21=t5;; // cr.iitr
  799. ld8 t1=[t0],3*Inc8
  800. ld8 t3=[t2],3*Inc8
  801. ld8 t5=[t7],3*Inc8;;
  802. mov cr22=t1 // cr.iipa
  803. mov cr23=t3 // cr.ifs
  804. mov cr24=t5 // cr.iim
  805. ld8 t1=[t0],160;; // 160 byte increment
  806. mov cr25=t1 // cr.iha
  807. irSkipIntrRegs:
  808. ld8 t1=[t0],168;; // another 168 byte inc.
  809. ld8 t1=[t0],40;; // 40 byte increment
  810. mov cr66=t1 // cr.lid
  811. ld8 t1=[t0],Inc8;;
  812. // mov cr71=t1 // cr.ivr is read only
  813. ld8 t1=[t0],24;; // 24 byte increment
  814. mov cr72=t1 // cr.tpr
  815. ld8 t1=[t0],168;; // 168 byte inc.
  816. // mov cr75=t1 // cr.eoi
  817. ld8 t1=[t0],Inc16;; // 16 byte inc.
  818. // mov cr96=t1 // cr.irr0 is read only
  819. ld8 t1=[t0],Inc16;; // 16 byte inc.
  820. // mov cr98=t1 // cr.irr1 is read only
  821. ld8 t1=[t0],Inc16;; // 16 byte inc
  822. // mov cr100=t1 // cr.irr2 is read only
  823. ld8 t1=[t0],Inc16;; // 16b inc.
  824. // mov cr102=t1 // cr.irt1 is read only
  825. ld8 t1=[t0],Inc16;; // 16 byte inc.
  826. // mov cr114=t1 // cr.itv
  827. ld8 t1=[t0],Inc8;;
  828. // mov cr116=t1 // cr.pmv
  829. ld8 t1=[t0],Inc8;;
  830. // mov cr117=t1 // cr.lrr0
  831. ld8 t1=[t0],Inc8;;
  832. // mov cr118=t1 // cr.lrr1
  833. ld8 t1=[t0],Inc8*10;;
  834. // mov cr119=t1 // cr.cmcv
  835. irestore_ARs:
  836. add t2=Inc8,t0 // duplicate t0 in t2
  837. add t7=2*Inc8,t0;; // duplicate t0 in t2
  838. ld8 t1=[t0],3*Inc8
  839. ld8 t3=[t2],3*Inc8
  840. ld8 t5=[t7],3*Inc8;;
  841. mov ar0=t1 // ar.kro
  842. mov ar1=t3 // ar.kr1
  843. mov ar2=t5;; // ar.kr2
  844. ld8 t1=[t0],3*Inc8
  845. ld8 t3=[t2],3*Inc8
  846. ld8 t5=[t7],3*Inc8;;
  847. mov ar3=t1 // ar.kr3
  848. mov ar4=t3 // ar.kr4
  849. mov ar5=t5;; // ar.kr5
  850. ld8 t1=[t0],10*Inc8
  851. ld8 t3=[t2],10*Inc8
  852. ld8 t5=[t7],10*Inc8;;
  853. mov ar6=t1 // ar.kr6
  854. mov ar7=t3 // ar.kr7
  855. // mov ar8=t7 // ar.kr8
  856. ;;
  857. ld8 t1=[t0],3*Inc8
  858. ld8 t3=[t2],3*Inc8
  859. ld8 t5=[t7],3*Inc8;;
  860. // mov ar16=t1 // ar.rsc
  861. // mov ar17=t3 // ar.bsp is read only
  862. mov ar18=t5;; // ar.bspstore
  863. ld8 t1=[t0],Inc8*13;;
  864. mov ar19=t1 // ar.rnat
  865. ld8 t1=[t0],Inc8*4;;
  866. mov ar32=t1 // ar.ccv
  867. ld8 t1=[t0],Inc8*4;;
  868. mov ar36=t1 // ar.unat
  869. ld8 t1=[t0],Inc8*4;;
  870. mov ar40=t1 // ar.fpsr
  871. ld8 t1=[t0],160;; // 160
  872. // mov ar44=t1 // ar.itc
  873. ld8 t1=[t0],Inc8;;
  874. mov ar64=t1 // ar.pfs
  875. ld8 t1=[t0],Inc8;;
  876. mov ar65=t1 // ar.lc
  877. ld8 t1=[t0];;
  878. mov ar66=t1 // ar.ec
  879. adds t0=Inc8*62,t0;; // padding
  880. irestore_RRs:
  881. mov t3=ar.lc
  882. mov ar.lc=0x08-1
  883. movl t2=0x00
  884. icStRRr:
  885. ld8 t1=[t0],Inc8;;
  886. // mov rr[t2]=t1 // what are its access previledges?
  887. add t2=1,t2
  888. br.cloop.dpnt icStRRr
  889. ;;
  890. mov ar.lc=t3
  891. // align memory addresses to 16 bytes
  892. and t1=0x0f,t0;;
  893. cmp.ne.unc pt0,p0=t1,r0;;
  894. (pt0) add t0=Inc8,t0;;
  895. // restore FP's which might be trashed by the "C" code
  896. mov t3=ar.unat
  897. add t1=16*10,t0;; // to get to NaT of GR 16-31
  898. ld8 t1=[t1];;
  899. mov ar.unat=t1;; // first restore NaT
  900. irestore_FRs:
  901. ldf.fill f6=[t0],Inc16;;
  902. ldf.fill f7=[t0],Inc16;;
  903. ldf.fill f8=[t0],Inc16;;
  904. ldf.fill f9=[t0],Inc16;;
  905. ldf.fill f10=[t0],Inc16;;
  906. ldf.fill f11=[t0],Inc16;;
  907. ldf.fill f12=[t0],Inc16;;
  908. ldf.fill f13=[t0],Inc16;;
  909. ldf.fill f14=[t0],Inc16;;
  910. ldf.fill f15=[t0],Inc16;;
  911. mov ar.unat=t3 // restore original NaT
  912. br.dpnt osInitDoneRestore
  913. ;;
  914. //EndStub//////////////////////////////////////////////////////////////////////