]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c
MdePkg/BaseLib: Add stack switch related definitions for IA32
[mirror_edk2.git] / UefiCpuPkg / Library / CpuExceptionHandlerLib / DxeException.c
index cffb13aea98423d9b080c0a8955b39fd0fc2ea06..31febec9767de5ee71beb02a20a21a54b177abce 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   CPU exception handler library implemenation for DXE modules.\r
 \r
-  Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2013 - 2017, 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
 CONST UINTN    mDoFarReturnFlag  = 0;\r
 \r
-extern SPIN_LOCK                   mDisplayMessageSpinLock;\r
-extern EFI_CPU_INTERRUPT_HANDLER   *mExternalInterruptHandler;\r
-extern RESERVED_VECTORS_DATA       mReservedVectorsData[CPU_EXCEPTION_NUM];\r
-extern EFI_CPU_INTERRUPT_HANDLER   mExternalInterruptHandlerTable[CPU_EXCEPTION_NUM];\r
+RESERVED_VECTORS_DATA       mReservedVectorsData[CPU_EXCEPTION_NUM];\r
+EFI_CPU_INTERRUPT_HANDLER   mExternalInterruptHandlerTable[CPU_EXCEPTION_NUM];\r
+UINTN                       mEnabledInterruptNum = 0;\r
+\r
 EXCEPTION_HANDLER_DATA      mExceptionHandlerData;\r
 \r
+/**\r
+  Common exception handler.\r
+\r
+  @param ExceptionType  Exception type.\r
+  @param SystemContext  Pointer to EFI_SYSTEM_CONTEXT.\r
+**/\r
+VOID\r
+EFIAPI\r
+CommonExceptionHandler (\r
+  IN EFI_EXCEPTION_TYPE          ExceptionType,\r
+  IN EFI_SYSTEM_CONTEXT          SystemContext\r
+  )\r
+{\r
+  CommonExceptionHandlerWorker (ExceptionType, SystemContext, &mExceptionHandlerData);\r
+}\r
+\r
 /**\r
   Initializes all CPU exceptions entries and provides the default exception handlers.\r
-  \r
+\r
   Caller should try to get an array of interrupt and/or exception vectors that are in use and need to\r
   persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.\r
-  If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. \r
+  If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.\r
   If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.\r
 \r
   @param[in]  VectorInfo    Pointer to reserved vector list.\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
@@ -55,15 +71,15 @@ InitializeCpuExceptionHandlers (
 \r
 /**\r
   Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers.\r
-  \r
+\r
   Caller should try to get an array of interrupt and/or exception vectors that are in use and need to\r
   persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.\r
-  If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. \r
+  If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.\r
   If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.\r
 \r
   @param[in]  VectorInfo    Pointer to reserved vector list.\r
-  \r
-  @retval EFI_SUCCESS           All CPU interrupt/exception entries have been successfully initialized \r
+\r
+  @retval EFI_SUCCESS           All CPU interrupt/exception entries have been successfully initialized\r
                                 with default interrupt/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
@@ -96,7 +112,7 @@ InitializeCpuInterruptHandlers (
       return EFI_INVALID_PARAMETER;\r
     }\r
   }\r
-  InitializeSpinLock (&mDisplayMessageSpinLock);\r
+\r
   ExternalInterruptHandler = AllocateZeroPool (sizeof (EFI_CPU_INTERRUPT_HANDLER) * CPU_INTERRUPT_NUM);\r
   ASSERT (ExternalInterruptHandler != NULL);\r
 \r
@@ -119,7 +135,7 @@ InitializeCpuInterruptHandlers (
   ASSERT (TemplateMap.ExceptionStubHeaderSize <= HOOKAFTER_STUB_SIZE);\r
   InterruptEntryCode = AllocatePool (TemplateMap.ExceptionStubHeaderSize * CPU_INTERRUPT_NUM);\r
   ASSERT (InterruptEntryCode != NULL);\r
-  \r
+\r
   InterruptEntry = (UINTN) InterruptEntryCode;\r
   for (Index = 0; Index < CPU_INTERRUPT_NUM; Index ++) {\r
     CopyMem (\r
@@ -152,9 +168,9 @@ InitializeCpuInterruptHandlers (
 /**\r
   Registers a function to be called from the processor interrupt handler.\r
 \r
-  This function registers and enables the handler specified by InterruptHandler for a processor \r
-  interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the \r
-  handler for the processor interrupt or exception type specified by InterruptType is uninstalled. \r
+  This function registers and enables the handler specified by InterruptHandler for a processor\r
+  interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the\r
+  handler for the processor interrupt or exception type specified by InterruptType is uninstalled.\r
   The installed handler is called once for each processor interrupt or exception.\r
   NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or\r
   InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned.\r
@@ -179,5 +195,5 @@ RegisterCpuInterruptHandler (
   IN EFI_CPU_INTERRUPT_HANDLER     InterruptHandler\r
   )\r
 {\r
-  return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler);\r
+  return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler, &mExceptionHandlerData);\r
 }\r