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.

370 lines
11 KiB

  1. //** Copyright (C) 1996-98 Intel Corporation. All rights reserved.
  2. //**
  3. //** The information and source code contained herein is the exclusive
  4. //** property of Intel Corporation and may not be disclosed, examined
  5. //** or reproduced in whole or in part without explicit written authorization
  6. //** from the company.
  7. //**
  8. //###########################################################################
  9. //-----------------------------------------------------------------------------
  10. // Version control information follows.
  11. //
  12. //
  13. // 10 Jun 1999 Bugcheck Bernard Lint
  14. // M. Jayakumar ([email protected])
  15. ///////////////////////////////////////////////////////////////////////////////
  16. //
  17. // Module Name: OSINIT.C - Merced OS INIT Handler
  18. //
  19. // Description:
  20. // This module has OS INIT Event Handler Reference Code.
  21. //
  22. // Contents: HalpOsInitInit()
  23. // HalpInitHandler()
  24. //
  25. //
  26. // Target Platform: Merced
  27. //
  28. // Reuse: None
  29. //
  30. ////////////////////////////////////////////////////////////////////////////M//
  31. #include "halp.h"
  32. #include "nthal.h"
  33. #include "arc.h"
  34. #include "i64fw.h"
  35. #include "check.h"
  36. #include "inbv.h"
  37. #include "osmca.h"
  38. // i64fwasm.s: low-level protection data structures
  39. extern KSPIN_LOCK HalpInitSpinLock;
  40. //
  41. // Temporary location for INIT_EXCEPTION definition.
  42. //
  43. typedef ERROR_RECORD_HEADER INIT_EXCEPTION, *PINIT_EXCEPTION; // Init Event Record
  44. HALP_INIT_INFO HalpInitInfo;
  45. volatile ULONG HalpOsInitInProgress = 0;
  46. VOID
  47. HalpInitBugCheck(
  48. ULONG InitBugCheckType,
  49. PINIT_EXCEPTION InitLog,
  50. ULONGLONG InitAllocatedLogSize,
  51. ULONGLONG SalStatus
  52. )
  53. //++
  54. // Name: HalpInitBugCheck()
  55. //
  56. // Routine Description:
  57. //
  58. // This function is called to bugcheck the system in a case of a fatal INIT
  59. // or fatal FW interface errors. The OS must guarantee as much as possible
  60. // error containment in this path.
  61. // With the current implementation, this function should be only called from
  62. // the OS_INIT path.
  63. //
  64. // Arguments On Entry:
  65. // ULONG InitBugCheckType
  66. // PINIT_EXCEPTION InitLog
  67. // ULONGLONG InitAllocatedLogSize
  68. // ULONGLONG SalStatus
  69. //
  70. // Return:
  71. // None.
  72. //
  73. // Implementation notes:
  74. // This code CANNOT [as default rules - at least entry and through fatal INITs handling]
  75. // - make any system call
  76. // - attempt to acquire any spinlock used by any code outside the INIT handler
  77. // - change the interrupt state.
  78. // Passing data to non-INIT code must be done using manual semaphore instructions.
  79. // This code should minimize the path and the global or memory allocated data accesses.
  80. // This code should only access INIT-namespace structures.
  81. // This code is called under the MP protection of HalpInitSpinLock and with the flag
  82. // HalpOsInitInProgress set.
  83. //
  84. //--
  85. {
  86. if ( HalpOsInitInProgress ) {
  87. //
  88. // Enable InbvDisplayString calls to make it through to bootvid driver.
  89. //
  90. if ( InbvIsBootDriverInstalled() ) {
  91. InbvAcquireDisplayOwnership();
  92. InbvResetDisplay();
  93. InbvSolidColorFill(0,0,639,479,4); // make the screen blue
  94. InbvSetTextColor(15);
  95. InbvInstallDisplayStringFilter((INBV_DISPLAY_STRING_FILTER)NULL);
  96. InbvEnableDisplayString(TRUE); // enable display string
  97. InbvSetScrollRegion(0,0,639,479); // set to use entire screen
  98. }
  99. HalDisplayString (MSG_INIT_HARDWARE_ERROR);
  100. HalDisplayString (MSG_HARDWARE_ERROR2);
  101. //
  102. // Thierry 09/2000:
  103. //
  104. // - if desired, process the INIT log HERE...
  105. //
  106. // and use HalDisplayString() to dump info for the field or hardware vendor.
  107. // The processing could be based on processor or platform independent record definitions.
  108. //
  109. HalDisplayString( MSG_HALT );
  110. KeBugCheckEx( MACHINE_CHECK_EXCEPTION, (ULONG_PTR)InitBugCheckType,
  111. (ULONG_PTR)InitLog,
  112. (ULONG_PTR)InitAllocatedLogSize,
  113. (ULONG_PTR)SalStatus );
  114. }
  115. if ( ((*KdDebuggerNotPresent) == FALSE) && ((*KdDebuggerEnabled) != FALSE) ) {
  116. KeEnterKernelDebugger();
  117. }
  118. while( TRUE ) {
  119. //
  120. ; // Simply sit here so the INIT HARDWARE ERROR screen does not get corrupted...
  121. //
  122. }
  123. // noreturn
  124. } // HalpInitBugCheck()
  125. ERROR_SEVERITY
  126. HalpInitProcessLog(
  127. PINIT_EXCEPTION InitLog
  128. )
  129. //++
  130. // Name: HalpInitProcessLog()
  131. //
  132. // Routine Description:
  133. //
  134. // This function is called to process the INIT event log in the OS_INIT path.
  135. //
  136. // Arguments On Entry:
  137. // PINIT_EXCEPTION InitLog - Pointer to the INIT event log.
  138. //
  139. // Return:
  140. // ERROR_SEVERITY
  141. //
  142. // Implementation notes:
  143. // This code does not do anything right now.
  144. // Testing will allow to determine the right filtering depending on FW functionalities
  145. // and user requested operations like warm reset.
  146. //
  147. //--
  148. {
  149. ERROR_SEVERITY initSeverity;
  150. initSeverity = InitLog->ErrorSeverity;
  151. switch( initSeverity ) {
  152. case ErrorFatal:
  153. break;
  154. case ErrorRecoverable:
  155. break;
  156. case ErrorCorrected:
  157. break;
  158. default:
  159. //
  160. // These ERRROR_SEVERITY values have no HAL INIT specific handling.
  161. // As specified by the SAL Specs July 2000, we should not get these values in this path.
  162. //
  163. break;
  164. }
  165. return( initSeverity );
  166. } // HalpInitProcessLog()
  167. //++
  168. // Name: HalpInitHandler()
  169. //
  170. // Routine Description:
  171. //
  172. // This is the OsInit handler for firmware uncorrected errors
  173. // It is our option to run this in physical or virtual mode
  174. //
  175. // Arguments On Entry:
  176. // arg0 = Function ID
  177. //
  178. // Return:
  179. // rtn0=Success/Failure (0/!0)
  180. // rtn1=Alternate MinState Pointer if any else NULL
  181. //--
  182. SAL_PAL_RETURN_VALUES
  183. HalpInitHandler(
  184. ULONG64 RendezvousState,
  185. PPAL_MINI_SAVE_AREA Pmsa
  186. )
  187. {
  188. SAL_PAL_RETURN_VALUES rv;
  189. LONGLONG salStatus;
  190. KIRQL oldIrql;
  191. PINIT_EXCEPTION initLog;
  192. ULONGLONG initAllocatedLogSize;
  193. PSAL_EVENT_RESOURCES initResources;
  194. volatile KPCR * const pcr = KeGetPcr();
  195. //
  196. // Block various I/O interrupts.
  197. //
  198. KeRaiseIrql(SYNCH_LEVEL, &oldIrql);
  199. //
  200. // Enable interrupts so the debugger will work.
  201. //
  202. HalpEnableInterrupts();
  203. HalpAcquireMcaSpinLock(&HalpInitSpinLock);
  204. HalpOsInitInProgress++;
  205. //
  206. // Save OsToSal minimum state
  207. //
  208. initResources = pcr->OsMcaResourcePtr;
  209. initResources->OsToSalHandOff.SalReturnAddress = initResources->SalToOsHandOff.SalReturnAddress;
  210. initResources->OsToSalHandOff.SalGlobalPointer = initResources->SalToOsHandOff.SalGlobalPointer;
  211. //
  212. // update local variables with pre-initialized INIT log data.
  213. //
  214. initLog = (PINIT_EXCEPTION)(initResources->EventPool);
  215. initAllocatedLogSize = initResources->EventPoolSize;
  216. if ( !initLog || !initAllocatedLogSize ) {
  217. //
  218. // The following code should never happen or the implementation of the HAL INIT logs
  219. // pre-allocation failed miserably. This would be a development error.
  220. //
  221. HalpInitBugCheck( (ULONG_PTR)HAL_BUGCHECK_INIT_ASSERT, initLog,
  222. initAllocatedLogSize,
  223. (ULONGLONG)Pmsa );
  224. }
  225. //
  226. // Get the INIT logs
  227. //
  228. salStatus = (LONGLONG)0;
  229. while( salStatus >= 0 ) {
  230. ERROR_SEVERITY errorSeverity;
  231. rv = HalpGetStateInfo( INIT_EVENT, initLog );
  232. salStatus = rv.ReturnValues[0];
  233. switch( salStatus ) {
  234. case SAL_STATUS_SUCCESS:
  235. errorSeverity = HalpInitProcessLog( initLog );
  236. if ( errorSeverity == ErrorFatal ) {
  237. //
  238. // We are now going down with a MACHINE_CHECK_EXCEPTION.
  239. // No return...
  240. //
  241. KeBugCheckEx( MANUALLY_INITIATED_CRASH, (ULONG_PTR) initLog, initAllocatedLogSize, salStatus, (ULONG_PTR) Pmsa );
  242. }
  243. rv = HalpClearStateInfo( INIT_EVENT );
  244. if ( !SAL_SUCCESSFUL(rv) ) {
  245. //
  246. // Current consideration for this implementation - 08/2000:
  247. // if clearing the event fails, we assume that FW has a real problem;
  248. // continuing will be dangerous. We bugcheck.
  249. //
  250. HalpInitBugCheck( HAL_BUGCHECK_INIT_CLEAR_STATEINFO, initLog,
  251. initAllocatedLogSize,
  252. rv.ReturnValues[0] );
  253. }
  254. // SAL_STATUS_SUCCESS, SAL_STATUS_SUCCESS_MORE_RECORDS ... and
  255. // ErrorSeverity != ErrorFatal.
  256. break;
  257. case SAL_STATUS_NO_INFORMATION_AVAILABLE:
  258. //
  259. // The salStatus value will break the salStatus loop.
  260. //
  261. rv.ReturnValues[0] = SAL_STATUS_SUCCESS;
  262. break;
  263. case SAL_STATUS_SUCCESS_WITH_OVERFLOW:
  264. case SAL_STATUS_INVALID_ARGUMENT:
  265. case SAL_STATUS_ERROR:
  266. case SAL_STATUS_VA_NOT_REGISTERED:
  267. default: // Thierry 08/00: WARNING - SAL July 2000 - v2.90.
  268. // default includes possible unknown positive salStatus values.
  269. HalpInitBugCheck( HAL_BUGCHECK_INIT_GET_STATEINFO, initLog,
  270. initAllocatedLogSize,
  271. salStatus );
  272. break;
  273. }
  274. }
  275. if (RendezvousState == 2) {
  276. KeBugCheckEx( MANUALLY_INITIATED_CRASH,
  277. (ULONG_PTR) initLog,
  278. initAllocatedLogSize,
  279. salStatus,
  280. (ULONG_PTR) Pmsa
  281. );
  282. } else {
  283. KeBugCheckEx( NMI_HARDWARE_FAILURE,
  284. (ULONG_PTR) initLog,
  285. initAllocatedLogSize,
  286. salStatus,
  287. (ULONG_PTR) Pmsa
  288. );
  289. }
  290. //
  291. // Currently 08/2000, we do not support the modification of the minstate.
  292. //
  293. initResources->OsToSalHandOff.MinStateSavePtr = initResources->SalToOsHandOff.MinStateSavePtr;
  294. initResources->OsToSalHandOff.Result = rv.ReturnValues[0];
  295. initResources->OsToSalHandOff.NewContextFlag = 0; // continue the same context and NOT new
  296. //
  297. // Release INIT spinlock protecting OS_INIT resources.
  298. //
  299. HalpOsInitInProgress = 0;
  300. HalpReleaseMcaSpinLock(&HalpInitSpinLock);
  301. return(rv);
  302. } // HalpInitHandler()
  303. //EndProc//////////////////////////////////////////////////////////////////////