]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c
UefiCpuPkg/MpInitLib: Load uCode once for each core.
[mirror_edk2.git] / UefiCpuPkg / Library / CpuExceptionHandlerLib / SmmException.c
index 3f9d001fd525dde640350ba7169af553631030eb..95f4ce51ea20c154a1e81001c93fcd7b3574c3ee 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   CPU exception handler library implemenation for SMM 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
 #include <PiSmm.h>\r
 #include "CpuExceptionCommon.h"\r
 \r
-CONST UINTN   mDoFarReturnFlag   = 1; \r
+CONST UINTN   mDoFarReturnFlag   = 1;\r
 \r
+//\r
+// Spin lock for CPU information display\r
+//\r
+SPIN_LOCK        mDisplayMessageSpinLock;\r
+\r
+RESERVED_VECTORS_DATA       mReservedVectorsData[CPU_EXCEPTION_NUM];\r
+EFI_CPU_INTERRUPT_HANDLER   mExternalInterruptHandlerTable[CPU_EXCEPTION_NUM];\r
 EXCEPTION_HANDLER_DATA      mExceptionHandlerData;\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
@@ -40,20 +63,23 @@ InitializeCpuExceptionHandlers (
   IN EFI_VECTOR_HANDOFF_INFO       *VectorInfo OPTIONAL\r
   )\r
 {\r
-  return InitializeCpuExceptionHandlersWorker (VectorInfo);\r
+  mExceptionHandlerData.ReservedVectors          = mReservedVectorsData;\r
+  mExceptionHandlerData.ExternalInterruptHandler = mExternalInterruptHandlerTable;\r
+  InitializeSpinLock (&mExceptionHandlerData.DisplayMessageSpinLock);\r
+  return InitializeCpuExceptionHandlersWorker (VectorInfo, &mExceptionHandlerData);\r
 }\r
 \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
@@ -71,9 +97,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
@@ -98,5 +124,37 @@ RegisterCpuInterruptHandler (
   IN EFI_CPU_INTERRUPT_HANDLER     InterruptHandler\r
   )\r
 {\r
-  return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler);\r
-}
\ No newline at end of file
+  return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler, &mExceptionHandlerData);\r
+}\r
+\r
+/**\r
+  Initializes all CPU exceptions entries with optional extra initializations.\r
+\r
+  By default, this method should include all functionalities implemented by\r
+  InitializeCpuExceptionHandlers(), plus extra initialization works, if any.\r
+  This could be done by calling InitializeCpuExceptionHandlers() directly\r
+  in this method besides the extra works.\r
+\r
+  InitData is optional and its use and content are processor arch dependent.\r
+  The typical usage of it is to convey resources which have to be reserved\r
+  elsewhere and are necessary for the extra initializations of exception.\r
+\r
+  @param[in]  VectorInfo    Pointer to reserved vector list.\r
+  @param[in]  InitData      Pointer to data optional for extra initializations\r
+                            of exception.\r
+\r
+  @retval EFI_SUCCESS             The exceptions have been successfully\r
+                                  initialized.\r
+  @retval EFI_INVALID_PARAMETER   VectorInfo or InitData contains invalid\r
+                                  content.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeCpuExceptionHandlersEx (\r
+  IN EFI_VECTOR_HANDOFF_INFO            *VectorInfo OPTIONAL,\r
+  IN CPU_EXCEPTION_INIT_DATA            *InitData OPTIONAL\r
+  )\r
+{\r
+  return InitializeCpuExceptionHandlers (VectorInfo);\r
+}\r