/** @file\r
Common header file for CPU Exception Handler Library.\r
\r
- Copyright (c) 2012 - 2013, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
\r
#include "ArchInterruptDefs.h"\r
\r
+#define CPU_EXCEPTION_HANDLER_LIB_HOB_GUID \\r
+ { \\r
+ 0xb21d9148, 0x9211, 0x4d8f, { 0xad, 0xd3, 0x66, 0xb1, 0x89, 0xc9, 0x2c, 0x83 } \\r
+ }\r
+\r
//\r
// Record exception handler information\r
//\r
UINTN HookAfterStubHeaderStart;\r
} EXCEPTION_HANDLER_TEMPLATE_MAP;\r
\r
+typedef struct {\r
+ UINTN IdtEntryCount;\r
+ SPIN_LOCK DisplayMessageSpinLock;\r
+ RESERVED_VECTORS_DATA *ReservedVectors;\r
+ EFI_CPU_INTERRUPT_HANDLER *ExternalInterruptHandler;\r
+} EXCEPTION_HANDLER_DATA;\r
+\r
extern CONST UINT32 mErrorCodeFlag;\r
extern CONST UINTN mImageAlignSize;\r
extern CONST UINTN mDoFarReturnFlag;\r
-extern RESERVED_VECTORS_DATA *mReservedVectors;\r
\r
/**\r
Return address map of exception handler template so that C code can generate\r
/**\r
Internal worker function to initialize exception handler.\r
\r
- @param[in] VectorInfo Pointer to reserved vector list.\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
with default exception handlers.\r
**/\r
EFI_STATUS\r
InitializeCpuExceptionHandlersWorker (\r
- IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL\r
+ IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL,\r
+ IN OUT EXCEPTION_HANDLER_DATA *ExceptionHandlerData\r
);\r
\r
/**\r
Registers a function to be called from the processor interrupt handler.\r
\r
- @param[in] InterruptType Defines which interrupt or exception to hook.\r
- @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called\r
- when a processor interrupt occurs. If this parameter is NULL, then the handler\r
- will be uninstalled.\r
+ @param[in] InterruptType Defines which interrupt or exception to hook.\r
+ @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called\r
+ when a processor interrupt occurs. If this parameter is NULL, then the handler\r
+ will be uninstalled\r
+ @param[in] ExceptionHandlerData Pointer to exception handler data.\r
\r
@retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.\r
@retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was\r
EFI_STATUS\r
RegisterCpuInterruptHandlerWorker (\r
IN EFI_EXCEPTION_TYPE InterruptType,\r
- IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler\r
+ IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler,\r
+ IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData\r
);\r
\r
/**\r
Internal worker function to update IDT entries accordling to vector attributes.\r
\r
- @param[in] IdtTable Pointer to IDT table.\r
- @param[in] TemplateMap Pointer to a buffer where the address map is returned.\r
- @param[in] IdtEntryCount IDT entries number to be updated.\r
+ @param[in] IdtTable Pointer to IDT table.\r
+ @param[in] TemplateMap Pointer to a buffer where the address map is\r
+ returned.\r
+ @param[in] ExceptionHandlerData Pointer to exception handler data.\r
\r
**/\r
VOID\r
UpdateIdtTable (\r
IN IA32_IDT_GATE_DESCRIPTOR *IdtTable,\r
IN EXCEPTION_HANDLER_TEMPLATE_MAP *TemplateMap,\r
- IN UINTN IdtEntryCount\r
+ IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData\r
);\r
\r
/**\r
Save CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case.\r
\r
- @param[in] ExceptionType Exception type.\r
- @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT.\r
-\r
+ @param[in] ExceptionType Exception type.\r
+ @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT.\r
+ @param[in] ExceptionHandlerData Pointer to exception handler data.\r
**/\r
VOID\r
ArchSaveExceptionContext (\r
- IN UINTN ExceptionType,\r
- IN EFI_SYSTEM_CONTEXT SystemContext \r
+ IN UINTN ExceptionType,\r
+ IN EFI_SYSTEM_CONTEXT SystemContext,\r
+ IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData\r
);\r
\r
/**\r
Restore CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case.\r
\r
- @param[in] ExceptionType Exception type.\r
- @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT.\r
-\r
+ @param[in] ExceptionType Exception type.\r
+ @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT.\r
+ @param[in] ExceptionHandlerData Pointer to exception handler data.\r
**/\r
VOID\r
ArchRestoreExceptionContext (\r
- IN UINTN ExceptionType,\r
- IN EFI_SYSTEM_CONTEXT SystemContext \r
+ IN UINTN ExceptionType,\r
+ IN EFI_SYSTEM_CONTEXT SystemContext,\r
+ IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData\r
);\r
\r
/**\r
- Fix up the vector number in the vector code.\r
+ Fix up the vector number and function address in the vector code.\r
\r
- @param[in] VectorBase Base address of the vector handler.\r
- @param[in] VectorNum Index of vector.\r
+ @param[in] NewVectorAddr New vector handler address.\r
+ @param[in] VectorNum Index of vector.\r
+ @param[in] OldVectorAddr Old vector handler address.\r
\r
**/\r
VOID\r
EFIAPI\r
AsmVectorNumFixup (\r
- IN VOID *VectorBase,\r
- IN UINT8 VectorNum\r
+ IN VOID *NewVectorAddr,\r
+ IN UINT8 VectorNum,\r
+ IN VOID *OldVectorAddr\r
);\r
\r
/**\r
IN UINTN VectorCount\r
);\r
\r
+/**\r
+ Get ASCII format string exception name by exception type.\r
+\r
+ @param ExceptionType Exception type.\r
+\r
+ @return ASCII format string exception name.\r
+**/\r
+CONST CHAR8 *\r
+GetExceptionNameStr (\r
+ IN EFI_EXCEPTION_TYPE ExceptionType\r
+ );\r
+\r
+/**\r
+ Internal worker function for common exception handler.\r
+\r
+ @param ExceptionType Exception type.\r
+ @param SystemContext Pointer to EFI_SYSTEM_CONTEXT.\r
+ @param ExceptionHandlerData Pointer to exception handler data.\r
+**/\r
+VOID\r
+CommonExceptionHandlerWorker (\r
+ IN EFI_EXCEPTION_TYPE ExceptionType, \r
+ IN EFI_SYSTEM_CONTEXT SystemContext,\r
+ IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData\r
+ );\r
+\r
#endif\r
\r