Windows NT 4.0 source code leak
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.

196 lines
5.8 KiB

4 years ago
  1. // "@(#) NEC cacherr.s 1.2 94/10/17 11:02:44"
  2. // TITLE("Cache Error Handling")
  3. //++
  4. //
  5. // Copyright (c) 1993-1994 Microsoft Corporation
  6. //
  7. // Module Name:
  8. //
  9. // cacherr.s
  10. //
  11. // Abstract:
  12. //
  13. // This module implements cache error handling. It is entered in KSEG1
  14. // directly from the cache error vector wiht ERL set in the processor
  15. // state.
  16. //
  17. // N.B. All the code in this routine MUST run in KSEG1 and reference
  18. // data only in KSEG1 until which time as any cache errors have
  19. // been corrected.
  20. //
  21. // N.B. This routine is NOT COMPLETE. All cache errors result in a
  22. // soft reset.
  23. //
  24. // Environment:
  25. //
  26. // Kernel mode only.
  27. //
  28. // Revision History:
  29. //
  30. //--
  31. #include "halmips.h"
  32. //
  33. // Define local save area for register state.
  34. //
  35. .data
  36. SavedAt:.space 4 // saved integer register at - a3
  37. SavedV0:.space 4 //
  38. SavedV1:.space 4 //
  39. SavedA0:.space 4 //
  40. SavedA1:.space 4 //
  41. SavedA2:.space 4 //
  42. SavedA3:.space 4 //
  43. SBTTL("Cache Error Handling")
  44. //++
  45. //
  46. // VOID
  47. // HalpCacheErrorRoutine (
  48. // VOID
  49. // )
  50. //
  51. // Routine Description:
  52. //
  53. // This function is entered from the cache error vector executing
  54. // in KSEG1. If the error is a single bit ECC error in the second
  55. // level data cache or the error is in the primary instruction cache,
  56. // then the error is corrected and execution is continued. Otherwise,
  57. // a fatal system error has occured and control is transfered to the
  58. // soft reset vector.
  59. //
  60. // N.B. No state has been saved when this routine is entered.
  61. //
  62. // Arguments:
  63. //
  64. // None.
  65. //
  66. // Return Value:
  67. //
  68. // None.
  69. //
  70. //--
  71. LEAF_ENTRY(HalpCacheErrorRoutine)
  72. //
  73. // Save volatile registers needed to fix cache error.
  74. //
  75. .set noreorder
  76. .set noat
  77. la k0,SavedAt // get address of register save area
  78. li k1,KSEG1_BASE // convert address of KSEG1 address
  79. or k0,k0,k1 //
  80. sw AT,0(k0) // save registers AT - a3
  81. sw v0,4(k0) //
  82. sw v1,8(k0) //
  83. sw a0,12(k0) //
  84. sw a1,16(k0) //
  85. sw a2,20(k0) //
  86. //
  87. // Get the current processor state and cache error register, and check
  88. // if the error can be corrected.
  89. //
  90. mfc0 v0,psr // get current processor state
  91. mfc0 v1,cacheerr // get cache error state
  92. .set at
  93. .set reorder
  94. //
  95. // ****** temp ******
  96. //
  97. // The following code is temporary and will be removed when full cache
  98. // error support is included.
  99. //
  100. // ****** temp ******
  101. //
  102. b SoftReset // ****** all error soft rest
  103. //
  104. // If the EXL bit is set in the processor state, then the error is not
  105. // recoverable because the EXL bit may be erroneously set (errata) and
  106. // it cannot be determined whether is should or should not be set, e.g.,
  107. // the exact addresses ranges over which EXL might be correctly set are
  108. // not verifiable. Also, k0 and k1 are destroyed before they are saved
  109. // and are used by the exception handling code (there is no way to save
  110. // a register in noncached memory wihtout the use of a register).
  111. //
  112. sll a0,v0,31 - PSR_EXL // shift EXL bit in sign
  113. bltz a0,SoftReset // if ltz, error not correctable
  114. //
  115. // If the error occured on the SysAd bus, then the error is not correctable.
  116. //
  117. sll a0,v1,31 - CACHEERR_EE // shift EE bit into sign
  118. bltz a0,SoftReset // if ltz, error not correctable
  119. //
  120. // Determine whether the error is in the instruction or data cache.
  121. //
  122. sll a0,v1,31 - CACHEERR_ER // shift ER bit into sign
  123. bgez a0,IcacheError // if gez, instruction cache error
  124. //
  125. // The error occured in the data cache.
  126. //
  127. // If the error is a data error in the primary cache, then the error
  128. // is not correctable since the cache line dirty bit is included in
  129. // the parity calculation and therefore may be wrong.
  130. //
  131. DcacheError: //
  132. sll a0,v1,31 - CACHEERR_EC // shift EC bit into sign
  133. bgez a0,SoftReset // if gez, error in primary cache
  134. b ExitError // exit error
  135. //
  136. // The error occured in the instruction cache.
  137. //
  138. // If the error occured in the secondary data cache, then the error is not
  139. // correctable since there is not secondary instruciton cache.
  140. //
  141. IcacheError: //
  142. sll a0,v1,31 - CACHEERR_EC // shift EC bit into sign
  143. bltz a0,SoftReset // if ltz, error in secondary cache
  144. //
  145. // The cache error has been corrected - restore register state and continue
  146. // execution.
  147. //
  148. ExitError: //
  149. .set noreorder
  150. .set noat
  151. la k0,SavedAt // get address of register save area
  152. li k1,KSEG1_BASE // convert address of KSEG1 address
  153. or k0,k0,k1 //
  154. lw AT,0(k0) // restore registers AT - a3
  155. lw v0,4(k0) //
  156. lw v1,8(k0) //
  157. lw a0,12(k0) //
  158. lw a1,16(k0) //
  159. lw a2,20(k0) //
  160. eret //
  161. .set at
  162. .set reorder
  163. //
  164. // Cache error cannot be corrected - transfer control to soft reset vector.
  165. //
  166. SoftReset: //
  167. la k0,SOFT_RESET_VECTOR // get address of soft reset vector
  168. j k0 // perform a soft reset
  169. .end HalpCacheErrorRoutine