/** @file\r
CPU Exception Library provides PEI/DXE/SMM CPU common exception handler.\r
\r
-Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials are licensed and made available under\r
the terms and conditions of the BSD License that accompanies this distribution.\r
The full text of the license may be found at\r
#include "CpuExceptionCommon.h"\r
#include <Library/DebugLib.h>\r
\r
-\r
-//\r
-// Image align size for DXE/SMM\r
-//\r
-CONST UINTN mImageAlignSize = SIZE_4KB;\r
-\r
-RESERVED_VECTORS_DATA mReservedVectorsData[CPU_EXCEPTION_NUM];\r
-EFI_CPU_INTERRUPT_HANDLER mExternalInterruptHandlerTable[CPU_EXCEPTION_NUM];\r
-EFI_CPU_INTERRUPT_HANDLER *mExternalInterruptHandler = NULL;\r
-UINTN mEnabledInterruptNum = 0;\r
-\r
/**\r
Internal worker function for common exception handler.\r
\r
**/\r
VOID\r
CommonExceptionHandlerWorker (\r
- IN EFI_EXCEPTION_TYPE ExceptionType, \r
+ IN EFI_EXCEPTION_TYPE ExceptionType,\r
IN EFI_SYSTEM_CONTEXT SystemContext,\r
IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData\r
)\r
// Need to execute old IDT handler before running this exception handler\r
//\r
ReservedVectors[ExceptionType].ApicId = GetApicId ();\r
- ArchSaveExceptionContext (ExceptionType, SystemContext);\r
+ ArchSaveExceptionContext (ExceptionType, SystemContext, ExceptionHandlerData);\r
ExceptionHandlerContext->ExceptionDataFlag = (mErrorCodeFlag & (1 << ExceptionType)) ? TRUE : FALSE;\r
ExceptionHandlerContext->OldIdtHandler = ReservedVectors[ExceptionType].ExceptonHandler;\r
return;\r
//\r
if (ReservedVectors[ExceptionType].ApicId == GetApicId ()) {\r
//\r
- // Old IDT handler has been executed, then retore CPU exception content to\r
+ // Old IDT handler has been executed, then restore CPU exception content to\r
// run new exception handler.\r
//\r
- ArchRestoreExceptionContext (ExceptionType, SystemContext);\r
+ ArchRestoreExceptionContext (ExceptionType, SystemContext, ExceptionHandlerData);\r
//\r
// Rlease spin lock for ApicId\r
//\r
CpuDeadLoop ();\r
break;\r
}\r
- \r
+\r
if (ExternalInterruptHandler != NULL &&\r
ExternalInterruptHandler[ExceptionType] != NULL) {\r
(ExternalInterruptHandler[ExceptionType]) (ExceptionType, SystemContext);\r
CpuPause ();\r
}\r
//\r
+ // Initialize the serial port before dumping.\r
+ //\r
+ SerialPortInitialize ();\r
+ //\r
// Display ExceptionType, CPU information and Image information\r
- // \r
- DumpCpuContent (ExceptionType, SystemContext);\r
+ //\r
+ DumpImageAndCpuContent (ExceptionType, SystemContext);\r
//\r
// Release Spinlock of output message\r
//\r
break;\r
}\r
}\r
- \r
- //\r
- // Save Interrupt number to global variable used for RegisterCpuInterruptHandler ()\r
- //\r
- mEnabledInterruptNum = ExceptionHandlerData->IdtEntryCount;\r
}\r
\r
/**\r
\r
@param[in] VectorInfo Pointer to reserved vector list.\r
@param[in, out] ExceptionHandlerData Pointer to exception handler data.\r
- \r
- @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized \r
+\r
+ @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized\r
with default exception handlers.\r
@retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.\r
@retval EFI_UNSUPPORTED This function is not supported.\r
}\r
}\r
\r
- mExternalInterruptHandler = mExternalInterruptHandlerTable;\r
//\r
// Read IDT descriptor and calculate IDT size\r
//\r
\r
ExceptionHandlerData->IdtEntryCount = IdtEntryCount;\r
UpdateIdtTable (IdtTable, &TemplateMap, ExceptionHandlerData);\r
- mEnabledInterruptNum = IdtEntryCount;\r
+\r
return EFI_SUCCESS;\r
}\r
\r