]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/MpInitLib/MpLib.h
UefiCpuPkg/MpInitLib: Initialize CPU_AP_DATA for CPU APs
[mirror_edk2.git] / UefiCpuPkg / Library / MpInitLib / MpLib.h
index 0453c22d5cf5eb02663fe71b0dab74c35012cf40..84bd8721982caf6b55206cfd1ebaa9651b5d62d5 100644 (file)
 #include <Library/MtrrLib.h>\r
 #include <Library/HobLib.h>\r
 \r
+//\r
+// AP loop state when APs are in idle state\r
+// It's value is the same with PcdCpuApLoopMode\r
+//\r
+typedef enum {\r
+  ApInHltLoop   = 1,\r
+  ApInMwaitLoop = 2,\r
+  ApInRunLoop   = 3\r
+} AP_LOOP_MODE;\r
+\r
+//\r
+// AP initialization state during APs wakeup\r
+//\r
+typedef enum {\r
+  ApInitConfig   = 1,\r
+  ApInitReconfig = 2,\r
+  ApInitDone     = 3\r
+} AP_INIT_STATE;\r
+\r
+//\r
+// AP state\r
+//\r
+typedef enum {\r
+  CpuStateIdle,\r
+  CpuStateReady,\r
+  CpuStateBusy,\r
+  CpuStateFinished,\r
+  CpuStateDisabled\r
+} CPU_STATE;\r
+\r
+//\r
+// AP related data\r
+//\r
+typedef struct {\r
+  SPIN_LOCK                      ApLock;\r
+  volatile UINT32                *StartupApSignal;\r
+  volatile UINTN                 ApFunction;\r
+  volatile UINTN                 ApFunctionArgument;\r
+  UINT32                         InitialApicId;\r
+  UINT32                         ApicId;\r
+  UINT32                         Health;\r
+  BOOLEAN                        CpuHealthy;\r
+  volatile CPU_STATE             State;\r
+  BOOLEAN                        Waiting;\r
+  BOOLEAN                        *Finished;\r
+  UINT64                         ExpectedTime;\r
+  UINT64                         CurrentTime;\r
+  UINT64                         TotalTime;\r
+  EFI_EVENT                      WaitEvent;\r
+} CPU_AP_DATA;\r
+\r
+//\r
+// Basic CPU information saved in Guided HOB.\r
+// Because the contents will be shard between PEI and DXE,\r
+// we need to make sure the each fields offset same in different\r
+// architecture.\r
+//\r
+typedef struct {\r
+  UINT32                         InitialApicId;\r
+  UINT32                         ApicId;\r
+  UINT32                         Health;\r
+} CPU_INFO_IN_HOB;\r
+\r
+//\r
+// AP reset code information including code address and size,\r
+// this structure will be shared be C code and assembly code.\r
+// It is natural aligned by design.\r
+//\r
+typedef struct {\r
+  UINT8             *RendezvousFunnelAddress;\r
+  UINTN             ModeEntryOffset;\r
+  UINTN             RendezvousFunnelSize;\r
+  UINT8             *RelocateApLoopFuncAddress;\r
+  UINTN             RelocateApLoopFuncSize;\r
+} MP_ASSEMBLY_ADDRESS_MAP;\r
+\r
+typedef struct _CPU_MP_DATA  CPU_MP_DATA;\r
 \r
 #pragma pack(1)\r
 \r
@@ -55,10 +132,89 @@ typedef struct {
   UINTN                 NumApsExecuting;\r
   UINTN                 CodeSegment;\r
   UINTN                 DataSegment;\r
+  UINTN                 EnableExecuteDisable;\r
   UINTN                 Cr3;\r
-  PEI_CPU_MP_DATA       *PeiCpuMpData;\r
+  CPU_MP_DATA           *CpuMpData;\r
 } MP_CPU_EXCHANGE_INFO;\r
 \r
 #pragma pack()\r
+\r
+//\r
+// CPU MP Data save in memory\r
+//\r
+struct _CPU_MP_DATA {\r
+  UINT64                         CpuInfoInHob;\r
+  UINT32                         CpuCount;\r
+  UINT32                         BspNumber;\r
+  //\r
+  // The above fields data will be passed from PEI to DXE\r
+  // Please make sure the fields offset same in the different\r
+  // architecture.\r
+  //\r
+  SPIN_LOCK                      MpLock;\r
+  UINTN                          Buffer;\r
+  UINTN                          CpuApStackSize;\r
+  MP_ASSEMBLY_ADDRESS_MAP        AddressMap;\r
+  UINTN                          WakeupBuffer;\r
+  UINTN                          BackupBuffer;\r
+  UINTN                          BackupBufferSize;\r
+  BOOLEAN                        EndOfPeiFlag;\r
+\r
+  volatile UINT32                StartCount;\r
+  volatile UINT32                FinishedCount;\r
+  volatile UINT32                RunningCount;\r
+  BOOLEAN                        SingleThread;\r
+  EFI_AP_PROCEDURE               Procedure;\r
+  VOID                           *ProcArguments;\r
+  BOOLEAN                        *Finished;\r
+  UINT64                         ExpectedTime;\r
+  UINT64                         CurrentTime;\r
+  UINT64                         TotalTime;\r
+  EFI_EVENT                      WaitEvent;\r
+  UINTN                          **FailedCpuList;\r
+\r
+  AP_INIT_STATE                  InitFlag;\r
+  BOOLEAN                        X2ApicEnable;\r
+  MTRR_SETTINGS                  MtrrTable;\r
+  UINT8                          ApLoopMode;\r
+  UINT8                          ApTargetCState;\r
+  UINT16                         PmCodeSegment;\r
+  CPU_AP_DATA                    *CpuData;\r
+  volatile MP_CPU_EXCHANGE_INFO  *MpCpuExchangeInfo;\r
+};\r
+/**\r
+  Assembly code to place AP into safe loop mode.\r
+\r
+  Place AP into targeted C-State if MONITOR is supported, otherwise\r
+  place AP into hlt state.\r
+  Place AP in protected mode if the current is long mode. Due to AP maybe\r
+  wakeup by some hardware event. It could avoid accessing page table that\r
+  may not available during booting to OS.\r
+\r
+  @param[in] MwaitSupport    TRUE indicates MONITOR is supported.\r
+                             FALSE indicates MONITOR is not supported.\r
+  @param[in] ApTargetCState  Target C-State value.\r
+  @param[in] PmCodeSegment   Protected mode code segment value.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI * ASM_RELOCATE_AP_LOOP) (\r
+  IN BOOLEAN                 MwaitSupport,\r
+  IN UINTN                   ApTargetCState,\r
+  IN UINTN                   PmCodeSegment\r
+  );\r
+\r
+/**\r
+  Assembly code to get starting address and size of the rendezvous entry for APs.\r
+  Information for fixing a jump instruction in the code is also returned.\r
+\r
+  @param[out] AddressMap  Output buffer for address map information.\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmGetAddressMap (\r
+  OUT MP_ASSEMBLY_ADDRESS_MAP    *AddressMap\r
+  );\r
+\r
 #endif\r
 \r