]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/MpInitLib/MpLib.h
UefiCpuPkg/MpInitLib: Remove redundant CpuStateFinished State.
[mirror_edk2.git] / UefiCpuPkg / Library / MpInitLib / MpLib.h
index 19defdaf4ba4f1567c0074701fec3210349cfc2d..b3a38b4ce7eca35022db87bac15cc26e5cf03bea 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Common header file for MP Initialize Library.\r
 \r
-  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2016 - 2018, 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
@@ -81,11 +81,14 @@ typedef enum {
 //\r
 // AP state\r
 //\r
+// The state transitions for an AP when it process a procedure are:\r
+//  Idle ----> Ready ----> Busy ----> Idle\r
+//       [BSP]       [AP]       [AP]\r
+//\r
 typedef enum {\r
   CpuStateIdle,\r
   CpuStateReady,\r
   CpuStateBusy,\r
-  CpuStateFinished,\r
   CpuStateDisabled\r
 } CPU_STATE;\r
 \r
@@ -102,6 +105,9 @@ typedef struct {
   UINTN                          Dr3;\r
   UINTN                          Dr6;\r
   UINTN                          Dr7;\r
+  IA32_DESCRIPTOR                Gdtr;\r
+  IA32_DESCRIPTOR                Idtr;\r
+  UINT16                         Tr;\r
 } CPU_VOLATILE_REGISTERS;\r
 \r
 //\r
@@ -149,6 +155,7 @@ typedef struct {
   UINTN             RendezvousFunnelSize;\r
   UINT8             *RelocateApLoopFuncAddress;\r
   UINTN             RelocateApLoopFuncSize;\r
+  UINTN             ModeTransitionOffset;\r
 } MP_ASSEMBLY_ADDRESS_MAP;\r
 \r
 typedef struct _CPU_MP_DATA  CPU_MP_DATA;\r
@@ -169,15 +176,20 @@ typedef struct {
   IA32_DESCRIPTOR       IdtrProfile;\r
   UINTN                 BufferStart;\r
   UINTN                 ModeOffset;\r
-  UINTN                 NumApsExecuting;\r
+  UINTN                 ApIndex;\r
   UINTN                 CodeSegment;\r
   UINTN                 DataSegment;\r
   UINTN                 EnableExecuteDisable;\r
   UINTN                 Cr3;\r
   UINTN                 InitFlag;\r
   CPU_INFO_IN_HOB       *CpuInfo;\r
+  UINTN                 NumApsExecuting;\r
   CPU_MP_DATA           *CpuMpData;\r
   UINTN                 InitializeFloatingPointUnitsAddress;\r
+  UINT32                ModeTransitionMemory;\r
+  UINT16                ModeTransitionSegment;\r
+  UINT32                ModeHighMemory;\r
+  UINT16                ModeHighSegment;\r
 } MP_CPU_EXCHANGE_INFO;\r
 \r
 #pragma pack()\r
@@ -199,6 +211,7 @@ struct _CPU_MP_DATA {
   UINTN                          CpuApStackSize;\r
   MP_ASSEMBLY_ADDRESS_MAP        AddressMap;\r
   UINTN                          WakeupBuffer;\r
+  UINTN                          WakeupBufferHigh;\r
   UINTN                          BackupBuffer;\r
   UINTN                          BackupBufferSize;\r
 \r
@@ -233,6 +246,22 @@ struct _CPU_MP_DATA {
   UINT8                          Vector;\r
   BOOLEAN                        PeriodicMode;\r
   BOOLEAN                        TimerInterruptState;\r
+  UINT64                         MicrocodePatchAddress;\r
+  UINT64                         MicrocodePatchRegionSize;\r
+\r
+  UINT32                         ProcessorSignature;\r
+  UINT32                         ProcessorFlags;\r
+  UINT64                         MicrocodeDataAddress;\r
+  UINT32                         MicrocodeRevision;\r
+\r
+  //\r
+  // Whether need to use Init-Sipi-Sipi to wake up the APs.\r
+  // Two cases need to set this value to TRUE. One is in HLT\r
+  // loop mode, the other is resume from S3 which loop mode\r
+  // will be hardcode change to HLT mode by PiSmmCpuDxeSmm \r
+  // driver.\r
+  //\r
+  BOOLEAN                        WakeUpByInitSipiSipi;\r
 };\r
 \r
 extern EFI_GUID mCpuInitMpLibHobGuid;\r
@@ -323,6 +352,23 @@ GetWakeupBuffer (
   IN UINTN                WakeupBufferSize\r
   );\r
 \r
+/**\r
+  Get available EfiBootServicesCode memory below 4GB by specified size.\r
+\r
+  This buffer is required to safely transfer AP from real address mode to\r
+  protected mode or long mode, due to the fact that the buffer returned by\r
+  GetWakeupBuffer() may be marked as non-executable.\r
+\r
+  @param[in] BufferSize   Wakeup transition buffer size.\r
+\r
+  @retval other   Return wakeup transition buffer address below 4GB.\r
+  @retval 0       Cannot find free memory below 4GB.\r
+**/\r
+UINTN\r
+GetModeTransitionBuffer (\r
+  IN UINTN                BufferSize\r
+  );\r
+\r
 /**\r
   This function will be called by BSP to wakeup AP.\r
 \r
@@ -434,7 +480,7 @@ StartupThisAPWorker (
                                enabled AP. Otherwise, it will be disabled.\r
 \r
   @retval EFI_SUCCESS          BSP successfully switched.\r
-  @retval others               Failed to switch BSP. \r
+  @retval others               Failed to switch BSP.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -517,11 +563,13 @@ CheckAndUpdateApsStatus (
 /**\r
   Detect whether specified processor can find matching microcode patch and load it.\r
 \r
-  @param[in]  CpuMpData  The pointer to CPU MP Data structure.\r
+  @param[in]  CpuMpData    The pointer to CPU MP Data structure.\r
+  @param[in]  IsBspCallIn  Indicate whether the caller is BSP or not.\r
 **/\r
 VOID\r
 MicrocodeDetect (\r
-  IN CPU_MP_DATA             *CpuMpData\r
+  IN CPU_MP_DATA             *CpuMpData,\r
+  IN BOOLEAN                 IsBspCallIn\r
   );\r
 \r
 /**\r