OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2\r
)\r
{\r
- PEI_CPU_MP_DATA *PeiCpuMpData;\r
UINTN BistInformationSize;\r
UINTN CpuIndex;\r
EFI_SEC_PLATFORM_INFORMATION_CPU *CpuInstance;\r
+ EFI_PROCESSOR_INFORMATION ProcessorInfo;\r
+ EFI_HEALTH_FLAGS BistData;\r
+ UINTN NumberOfProcessors;\r
+ UINTN NumberOfEnabledProcessors;\r
\r
- PeiCpuMpData = GetMpHobData ();\r
+ MpInitLibGetNumberOfProcessors(&NumberOfProcessors, &NumberOfEnabledProcessors);\r
\r
BistInformationSize = sizeof (EFI_SEC_PLATFORM_INFORMATION_RECORD2) +\r
- sizeof (EFI_SEC_PLATFORM_INFORMATION_CPU) * PeiCpuMpData->CpuCount;\r
+ sizeof (EFI_SEC_PLATFORM_INFORMATION_CPU) * NumberOfProcessors;\r
//\r
// return the information size if input buffer size is too small\r
//\r
return EFI_BUFFER_TOO_SMALL;\r
}\r
\r
- PlatformInformationRecord2->NumberOfCpus = PeiCpuMpData->CpuCount;\r
+ PlatformInformationRecord2->NumberOfCpus = (UINT32)NumberOfProcessors;\r
CpuInstance = PlatformInformationRecord2->CpuInstance;\r
- for (CpuIndex = 0; CpuIndex < PeiCpuMpData->CpuCount; CpuIndex ++) {\r
- CpuInstance[CpuIndex].CpuLocation = PeiCpuMpData->CpuData[CpuIndex].ApicId;\r
- CpuInstance[CpuIndex].InfoRecord.IA32HealthFlags = PeiCpuMpData->CpuData[CpuIndex].Health;\r
+ for (CpuIndex = 0; CpuIndex < NumberOfProcessors; CpuIndex ++) {\r
+ MpInitLibGetProcessorInfo (CpuIndex, &ProcessorInfo, &BistData);\r
+ CpuInstance[CpuIndex].CpuLocation = (UINT32) ProcessorInfo.ProcessorId;\r
+ CpuInstance[CpuIndex].InfoRecord.IA32HealthFlags = BistData;\r
}\r
\r
return EFI_SUCCESS;\r
or SEC Platform Information PPI.\r
\r
@param PeiServices Pointer to PEI Services Table\r
- @param PeiCpuMpData Pointer to PEI CPU MP Data\r
\r
**/\r
VOID\r
CollectBistDataFromPpi (\r
- IN CONST EFI_PEI_SERVICES **PeiServices,\r
- IN PEI_CPU_MP_DATA *PeiCpuMpData\r
+ IN CONST EFI_PEI_SERVICES **PeiServices\r
)\r
{\r
EFI_STATUS Status;\r
EFI_SEC_PLATFORM_INFORMATION_CPU BspCpuInstance;\r
UINTN ProcessorNumber;\r
UINTN CpuIndex;\r
- PEI_CPU_DATA *CpuData;\r
+ EFI_PROCESSOR_INFORMATION ProcessorInfo;\r
+ EFI_HEALTH_FLAGS BistData;\r
+ UINTN NumberOfProcessors;\r
+ UINTN NumberOfEnabledProcessors;\r
+\r
+ MpInitLibGetNumberOfProcessors(&NumberOfProcessors, &NumberOfEnabledProcessors);\r
\r
SecPlatformInformation2 = NULL;\r
SecPlatformInformation = NULL;\r
DEBUG ((EFI_D_INFO, "Does not find any stored CPU BIST information from PPI!\n"));\r
}\r
}\r
- for (ProcessorNumber = 0; ProcessorNumber < PeiCpuMpData->CpuCount; ProcessorNumber ++) {\r
- CpuData = &PeiCpuMpData->CpuData[ProcessorNumber];\r
+ for (ProcessorNumber = 0; ProcessorNumber < NumberOfProcessors; ProcessorNumber ++) {\r
+ MpInitLibGetProcessorInfo (ProcessorNumber, &ProcessorInfo, &BistData);\r
for (CpuIndex = 0; CpuIndex < NumberOfData; CpuIndex ++) {\r
ASSERT (CpuInstance != NULL);\r
- if (CpuData->ApicId == CpuInstance[CpuIndex].CpuLocation) {\r
+ if (ProcessorInfo.ProcessorId == CpuInstance[CpuIndex].CpuLocation) {\r
//\r
// Update processor's BIST data if it is already stored before\r
//\r
- CpuData->Health = CpuInstance[CpuIndex].InfoRecord.IA32HealthFlags;\r
+ BistData = CpuInstance[CpuIndex].InfoRecord.IA32HealthFlags;\r
}\r
}\r
- if (CpuData->Health.Uint32 == 0) {\r
- CpuData->CpuHealthy = TRUE;\r
- } else {\r
- CpuData->CpuHealthy = FALSE;\r
+ if (BistData.Uint32 != 0) {\r
//\r
// Report Status Code that self test is failed\r
//\r
);\r
}\r
DEBUG ((EFI_D_INFO, " APICID - 0x%08x, BIST - 0x%08x\n",\r
- PeiCpuMpData->CpuData[ProcessorNumber].ApicId,\r
- PeiCpuMpData->CpuData[ProcessorNumber].Health.Uint32\r
+ ProcessorInfo.ProcessorId,\r
+ BistData\r
));\r
}\r
\r
- if (SecPlatformInformation2 != NULL && NumberOfData < PeiCpuMpData->CpuCount) {\r
+ if (SecPlatformInformation2 != NULL && NumberOfData < NumberOfProcessors) {\r
//\r
- // Reinstall SecPlatformInformation2 PPI to include new BIST inforamtion\r
+ // Reinstall SecPlatformInformation2 PPI to include new BIST information\r
//\r
Status = PeiServicesReInstallPpi (\r
SecInformationDescriptor,\r
ASSERT_EFI_ERROR (Status);\r
} else {\r
//\r
- // Install SecPlatformInformation2 PPI to include new BIST inforamtion\r
+ // Install SecPlatformInformation2 PPI to include new BIST information\r
//\r
Status = PeiServicesInstallPpi (&mPeiSecPlatformInformation2Ppi);\r
ASSERT_EFI_ERROR(Status);\r
}\r
}\r
+\r
\r
@param PeiCpuMpData Pointer to PEI CPU MP Data\r
**/\r
+STATIC\r
VOID\r
SortApicId (\r
IN PEI_CPU_MP_DATA *PeiCpuMpData\r
\r
@param Buffer Pointer to private data buffer.\r
**/\r
+STATIC\r
VOID\r
EFIAPI\r
ApFuncEnableX2Apic (\r
\r
@return The AP loop mode.\r
**/\r
+STATIC\r
UINT8\r
GetApLoopMode (\r
OUT UINT16 *MonitorFilterSize\r
\r
@param VolatileRegisters Returns buffer saved the volatile resisters\r
**/\r
+STATIC\r
VOID\r
SaveVolatileRegisters (\r
OUT CPU_VOLATILE_REGISTERS *VolatileRegisters\r
@param IsRestoreDr TRUE: Restore DRx if supported\r
FALSE: Do not restore DRx\r
**/\r
+STATIC\r
VOID\r
RestoreVolatileRegisters (\r
IN CPU_VOLATILE_REGISTERS *VolatileRegisters,\r
}\r
}\r
\r
+/**\r
+ Find the current Processor number by APIC ID.\r
+\r
+ @param PeiCpuMpData Pointer to PEI CPU MP Data\r
+ @param ProcessorNumber Return the pocessor number found\r
+\r
+ @retval EFI_SUCCESS ProcessorNumber is found and returned.\r
+ @retval EFI_NOT_FOUND ProcessorNumber is not found.\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+GetProcessorNumber (\r
+ IN PEI_CPU_MP_DATA *PeiCpuMpData,\r
+ OUT UINTN *ProcessorNumber\r
+ )\r
+{\r
+ UINTN TotalProcessorNumber;\r
+ UINTN Index;\r
+\r
+ TotalProcessorNumber = PeiCpuMpData->CpuCount;\r
+ for (Index = 0; Index < TotalProcessorNumber; Index ++) {\r
+ if (PeiCpuMpData->CpuData[Index].ApicId == GetInitialApicId ()) {\r
+ *ProcessorNumber = Index;\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+ return EFI_NOT_FOUND;\r
+}\r
+\r
/**\r
This function will be called from AP reset code if BSP uses WakeUpAP.\r
\r
@param ExchangeInfo Pointer to the MP exchange info buffer\r
@param NumApsExecuting Number of current executing AP\r
**/\r
+STATIC\r
VOID\r
EFIAPI\r
ApCFunction (\r
@param Procedure The function to be invoked by AP\r
@param ProcedureArgument The argument to be passed into AP function\r
**/\r
+STATIC\r
VOID\r
WakeUpAP (\r
IN PEI_CPU_MP_DATA *PeiCpuMpData,\r
@retval other Return wakeup buffer address below 1MB.\r
@retval -1 Cannot find free memory below 1MB.\r
**/\r
+STATIC\r
UINTN\r
GetWakeupBuffer (\r
IN UINTN WakeupBufferSize\r
\r
@param PeiCpuMpData Pointer to PEI CPU MP Data\r
**/\r
+STATIC\r
VOID\r
BackupAndPrepareWakeupBuffer(\r
IN PEI_CPU_MP_DATA *PeiCpuMpData\r
\r
@param PeiCpuMpData Pointer to PEI CPU MP Data\r
**/\r
+STATIC\r
VOID\r
RestoreWakeupBuffer(\r
IN PEI_CPU_MP_DATA *PeiCpuMpData\r
@retval EFI_SUCCESS When everything is OK.\r
\r
**/\r
+STATIC\r
EFI_STATUS\r
EFIAPI\r
CpuMpEndOfPeiCallback (\r
IN CONST EFI_PEI_SERVICES **PeiServices\r
)\r
{\r
- EFI_STATUS Status;\r
- PEI_CPU_MP_DATA *PeiCpuMpData;\r
+ EFI_STATUS Status;\r
EFI_VECTOR_HANDOFF_INFO *VectorInfo;\r
EFI_PEI_VECTOR_HANDOFF_INFO_PPI *VectorHandoffInfoPpi;\r
\r
}\r
Status = InitializeCpuExceptionHandlers (VectorInfo);\r
ASSERT_EFI_ERROR (Status);\r
+ \r
//\r
- // Get wakeup buffer and copy AP reset code in it\r
- //\r
- PeiCpuMpData = PrepareAPStartupVector ();\r
- //\r
- // Count processor number and collect processor information\r
- //\r
- CountProcessorNumber (PeiCpuMpData);\r
- //\r
- // Build location of PEI CPU MP DATA buffer in HOB\r
+ // Wakeup APs to do initialization\r
//\r
- BuildGuidDataHob (\r
- &gEfiCallerIdGuid,\r
- (VOID *)&PeiCpuMpData,\r
- sizeof(UINT64)\r
- );\r
+ Status = MpInitLibInitialize ();\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
//\r
// Update and publish CPU BIST information\r
//\r
- CollectBistDataFromPpi (PeiServices, PeiCpuMpData);\r
- //\r
- // register an event for EndOfPei\r
- //\r
- Status = PeiServicesNotifyPpi (&mNotifyList);\r
- ASSERT_EFI_ERROR (Status);\r
+ CollectBistDataFromPpi (PeiServices);\r
+\r
//\r
// Install CPU MP PPI\r
//\r
&mMpServicesPpi\r
};\r
\r
+\r
/**\r
Get CPU Package/Core/Thread location information.\r
\r
@param InitialApicId CPU APIC ID\r
@param Location Pointer to CPU location information\r
**/\r
+STATIC\r
VOID\r
ExtractProcessorLocation (\r
IN UINT32 InitialApicId,\r
Location->Package = (InitialApicId >> (ThreadBits + CoreBits));\r
}\r
\r
-/**\r
- Find the current Processor number by APIC ID.\r
-\r
- @param PeiCpuMpData Pointer to PEI CPU MP Data\r
- @param ProcessorNumber Return the pocessor number found\r
-\r
- @retval EFI_SUCCESS ProcessorNumber is found and returned.\r
- @retval EFI_NOT_FOUND ProcessorNumber is not found.\r
-**/\r
-EFI_STATUS\r
-GetProcessorNumber (\r
- IN PEI_CPU_MP_DATA *PeiCpuMpData,\r
- OUT UINTN *ProcessorNumber\r
- )\r
-{\r
- UINTN TotalProcessorNumber;\r
- UINTN Index;\r
-\r
- TotalProcessorNumber = PeiCpuMpData->CpuCount;\r
- for (Index = 0; Index < TotalProcessorNumber; Index ++) {\r
- if (PeiCpuMpData->CpuData[Index].ApicId == GetInitialApicId ()) {\r
- *ProcessorNumber = Index;\r
- return EFI_SUCCESS;\r
- }\r
- }\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
/**\r
Worker function for SwitchBSP().\r
\r
\r
@param Buffer Pointer to CPU MP Data\r
**/\r
+STATIC\r
VOID\r
EFIAPI\r
FutureBSPProc (\r
OUT UINTN *NumberOfEnabledProcessors\r
)\r
{\r
- PEI_CPU_MP_DATA *PeiCpuMpData;\r
- UINTN CallerNumber;\r
- UINTN ProcessorNumber;\r
- UINTN EnabledProcessorNumber;\r
- UINTN Index;\r
-\r
- PeiCpuMpData = GetMpHobData ();\r
- if (PeiCpuMpData == NULL) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
if ((NumberOfProcessors == NULL) || (NumberOfEnabledProcessors == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- //\r
- // Check whether caller processor is BSP\r
- //\r
- PeiWhoAmI (PeiServices, This, &CallerNumber);\r
- if (CallerNumber != PeiCpuMpData->BspNumber) {\r
- return EFI_DEVICE_ERROR;\r
- }\r
-\r
- ProcessorNumber = PeiCpuMpData->CpuCount;\r
- EnabledProcessorNumber = 0;\r
- for (Index = 0; Index < ProcessorNumber; Index++) {\r
- if (PeiCpuMpData->CpuData[Index].State != CpuStateDisabled) {\r
- EnabledProcessorNumber ++;\r
- }\r
- }\r
-\r
- *NumberOfProcessors = ProcessorNumber;\r
- *NumberOfEnabledProcessors = EnabledProcessorNumber;\r
-\r
- return EFI_SUCCESS;\r
+ return MpInitLibGetNumberOfProcessors (\r
+ NumberOfProcessors,\r
+ NumberOfEnabledProcessors\r
+ );\r
}\r
\r
/**\r
OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer\r
)\r
{\r
- PEI_CPU_MP_DATA *PeiCpuMpData;\r
- UINTN CallerNumber;\r
-\r
- PeiCpuMpData = GetMpHobData ();\r
- if (PeiCpuMpData == NULL) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- //\r
- // Check whether caller processor is BSP\r
- //\r
- PeiWhoAmI (PeiServices, This, &CallerNumber);\r
- if (CallerNumber != PeiCpuMpData->BspNumber) {\r
- return EFI_DEVICE_ERROR;\r
- }\r
-\r
- if (ProcessorInfoBuffer == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (ProcessorNumber >= PeiCpuMpData->CpuCount) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- ProcessorInfoBuffer->ProcessorId = (UINT64) PeiCpuMpData->CpuData[ProcessorNumber].ApicId;\r
- ProcessorInfoBuffer->StatusFlag = 0;\r
- if (PeiCpuMpData->CpuData[ProcessorNumber].ApicId == GetInitialApicId()) {\r
- ProcessorInfoBuffer->StatusFlag |= PROCESSOR_AS_BSP_BIT;\r
- }\r
- if (PeiCpuMpData->CpuData[ProcessorNumber].CpuHealthy) {\r
- ProcessorInfoBuffer->StatusFlag |= PROCESSOR_HEALTH_STATUS_BIT;\r
- }\r
- if (PeiCpuMpData->CpuData[ProcessorNumber].State == CpuStateDisabled) {\r
- ProcessorInfoBuffer->StatusFlag &= ~PROCESSOR_ENABLED_BIT;\r
- } else {\r
- ProcessorInfoBuffer->StatusFlag |= PROCESSOR_ENABLED_BIT;\r
- }\r
-\r
- //\r
- // Get processor location information\r
- //\r
- ExtractProcessorLocation (PeiCpuMpData->CpuData[ProcessorNumber].ApicId, &ProcessorInfoBuffer->Location);\r
-\r
- return EFI_SUCCESS;\r
+ return MpInitLibGetProcessorInfo (ProcessorNumber, ProcessorInfoBuffer, NULL);\r
}\r
\r
/**\r
IN VOID *ProcedureArgument OPTIONAL\r
)\r
{\r
- PEI_CPU_MP_DATA *PeiCpuMpData;\r
- UINTN ProcessorNumber;\r
- UINTN Index;\r
- UINTN CallerNumber;\r
- BOOLEAN HasEnabledAp;\r
- BOOLEAN HasEnabledIdleAp;\r
- volatile UINT32 *FinishedCount;\r
- EFI_STATUS Status;\r
- UINTN WaitCountIndex;\r
- UINTN WaitCountNumber;\r
-\r
- PeiCpuMpData = GetMpHobData ();\r
- if (PeiCpuMpData == NULL) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- if (Procedure == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Check whether caller processor is BSP\r
- //\r
- PeiWhoAmI (PeiServices, This, &CallerNumber);\r
- if (CallerNumber != PeiCpuMpData->BspNumber) {\r
- return EFI_DEVICE_ERROR;\r
- }\r
-\r
- ProcessorNumber = PeiCpuMpData->CpuCount;\r
-\r
- HasEnabledAp = FALSE;\r
- HasEnabledIdleAp = FALSE;\r
- for (Index = 0; Index < ProcessorNumber; Index ++) {\r
- if (Index == CallerNumber) {\r
- //\r
- // Skip BSP\r
- //\r
- continue;\r
- }\r
- if (PeiCpuMpData->CpuData[Index].State != CpuStateDisabled) {\r
- HasEnabledAp = TRUE;\r
- if (PeiCpuMpData->CpuData[Index].State != CpuStateBusy) {\r
- HasEnabledIdleAp = TRUE;\r
- }\r
- }\r
- }\r
- if (!HasEnabledAp) {\r
- //\r
- // If no enabled AP exists, return EFI_NOT_STARTED.\r
- //\r
- return EFI_NOT_STARTED;\r
- }\r
- if (!HasEnabledIdleAp) {\r
- //\r
- // If any enabled APs are busy, return EFI_NOT_READY.\r
- //\r
- return EFI_NOT_READY;\r
- }\r
-\r
- if (PeiCpuMpData->EndOfPeiFlag) {\r
- //\r
- // Backup original data and copy AP reset vector in it\r
- //\r
- BackupAndPrepareWakeupBuffer(PeiCpuMpData);\r
- }\r
-\r
- WaitCountNumber = TimeoutInMicroSeconds / CPU_CHECK_AP_INTERVAL + 1;\r
- WaitCountIndex = 0;\r
- FinishedCount = &PeiCpuMpData->FinishedCount;\r
- if (!SingleThread) {\r
- WakeUpAP (PeiCpuMpData, TRUE, 0, Procedure, ProcedureArgument);\r
- //\r
- // Wait to finish\r
- //\r
- if (TimeoutInMicroSeconds == 0) {\r
- while (*FinishedCount < ProcessorNumber - 1) {\r
- CpuPause ();\r
- }\r
- Status = EFI_SUCCESS;\r
- } else {\r
- Status = EFI_TIMEOUT;\r
- for (WaitCountIndex = 0; WaitCountIndex < WaitCountNumber; WaitCountIndex++) {\r
- MicroSecondDelay (CPU_CHECK_AP_INTERVAL);\r
- if (*FinishedCount >= ProcessorNumber - 1) {\r
- Status = EFI_SUCCESS;\r
- break;\r
- }\r
- }\r
- }\r
- } else {\r
- Status = EFI_SUCCESS;\r
- for (Index = 0; Index < ProcessorNumber; Index++) {\r
- if (Index == CallerNumber) {\r
- continue;\r
- }\r
- WakeUpAP (PeiCpuMpData, FALSE, Index, Procedure, ProcedureArgument);\r
- //\r
- // Wait to finish\r
- //\r
- if (TimeoutInMicroSeconds == 0) {\r
- while (*FinishedCount < 1) {\r
- CpuPause ();\r
- }\r
- } else {\r
- for (WaitCountIndex = 0; WaitCountIndex < WaitCountNumber; WaitCountIndex++) {\r
- MicroSecondDelay (CPU_CHECK_AP_INTERVAL);\r
- if (*FinishedCount >= 1) {\r
- break;\r
- }\r
- }\r
- if (WaitCountIndex == WaitCountNumber) {\r
- Status = EFI_TIMEOUT;\r
- }\r
- }\r
- }\r
- }\r
-\r
- if (PeiCpuMpData->EndOfPeiFlag) {\r
- //\r
- // Restore original data\r
- //\r
- RestoreWakeupBuffer(PeiCpuMpData);\r
- }\r
-\r
- return Status;\r
+ return MpInitLibStartupAllAPs (\r
+ Procedure,\r
+ SingleThread,\r
+ NULL,\r
+ TimeoutInMicroSeconds,\r
+ ProcedureArgument,\r
+ NULL\r
+ );\r
}\r
\r
/**\r
IN VOID *ProcedureArgument OPTIONAL\r
)\r
{\r
- PEI_CPU_MP_DATA *PeiCpuMpData;\r
- UINTN CallerNumber;\r
- volatile UINT32 *FinishedCount;\r
- EFI_STATUS Status;\r
- UINTN WaitCountIndex;\r
- UINTN WaitCountNumber;\r
-\r
- PeiCpuMpData = GetMpHobData ();\r
- if (PeiCpuMpData == NULL) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- //\r
- // Check whether caller processor is BSP\r
- //\r
- PeiWhoAmI (PeiServices, This, &CallerNumber);\r
- if (CallerNumber != PeiCpuMpData->BspNumber) {\r
- return EFI_DEVICE_ERROR;\r
- }\r
-\r
- if (ProcessorNumber >= PeiCpuMpData->CpuCount) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- if (ProcessorNumber == PeiCpuMpData->BspNumber || Procedure == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Check whether specified AP is disabled\r
- //\r
- if (PeiCpuMpData->CpuData[ProcessorNumber].State == CpuStateDisabled) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (PeiCpuMpData->EndOfPeiFlag) {\r
- //\r
- // Backup original data and copy AP reset vector in it\r
- //\r
- BackupAndPrepareWakeupBuffer(PeiCpuMpData);\r
- }\r
-\r
- WaitCountNumber = TimeoutInMicroseconds / CPU_CHECK_AP_INTERVAL + 1;\r
- WaitCountIndex = 0;\r
- FinishedCount = &PeiCpuMpData->FinishedCount;\r
-\r
- WakeUpAP (PeiCpuMpData, FALSE, ProcessorNumber, Procedure, ProcedureArgument);\r
-\r
- //\r
- // Wait to finish\r
- //\r
- if (TimeoutInMicroseconds == 0) {\r
- while (*FinishedCount < 1) {\r
- CpuPause() ;\r
- }\r
- Status = EFI_SUCCESS;\r
- } else {\r
- Status = EFI_TIMEOUT;\r
- for (WaitCountIndex = 0; WaitCountIndex < WaitCountNumber; WaitCountIndex++) {\r
- MicroSecondDelay (CPU_CHECK_AP_INTERVAL);\r
- if (*FinishedCount >= 1) {\r
- Status = EFI_SUCCESS;\r
- break;\r
- }\r
- }\r
- }\r
-\r
- if (PeiCpuMpData->EndOfPeiFlag) {\r
- //\r
- // Backup original data and copy AP reset vector in it\r
- //\r
- RestoreWakeupBuffer(PeiCpuMpData);\r
- }\r
-\r
- return Status;\r
+ return MpInitLibStartupThisAP (\r
+ Procedure,\r
+ ProcessorNumber,\r
+ NULL,\r
+ TimeoutInMicroseconds,\r
+ ProcedureArgument,\r
+ NULL\r
+ );\r
}\r
\r
/**\r
IN BOOLEAN EnableOldBSP\r
)\r
{\r
- PEI_CPU_MP_DATA *PeiCpuMpData;\r
- UINTN CallerNumber;\r
- MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr;\r
-\r
- PeiCpuMpData = GetMpHobData ();\r
- if (PeiCpuMpData == NULL) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- //\r
- // Check whether caller processor is BSP\r
- //\r
- PeiWhoAmI (PeiServices, This, &CallerNumber);\r
- if (CallerNumber != PeiCpuMpData->BspNumber) {\r
- return EFI_SUCCESS;\r
- }\r
-\r
- if (ProcessorNumber >= PeiCpuMpData->CpuCount) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- //\r
- // Check whether specified AP is disabled\r
- //\r
- if (PeiCpuMpData->CpuData[ProcessorNumber].State == CpuStateDisabled) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Check whether ProcessorNumber specifies the current BSP\r
- //\r
- if (ProcessorNumber == PeiCpuMpData->BspNumber) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Check whether specified AP is busy\r
- //\r
- if (PeiCpuMpData->CpuData[ProcessorNumber].State == CpuStateBusy) {\r
- return EFI_NOT_READY;\r
- }\r
-\r
- //\r
- // Clear the BSP bit of MSR_IA32_APIC_BASE\r
- //\r
- ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE);\r
- ApicBaseMsr.Bits.BSP = 0;\r
- AsmWriteMsr64 (MSR_IA32_APIC_BASE, ApicBaseMsr.Uint64);\r
-\r
- PeiCpuMpData->BSPInfo.State = CPU_SWITCH_STATE_IDLE;\r
- PeiCpuMpData->APInfo.State = CPU_SWITCH_STATE_IDLE;\r
-\r
- if (PeiCpuMpData->EndOfPeiFlag) {\r
- //\r
- // Backup original data and copy AP reset vector in it\r
- //\r
- BackupAndPrepareWakeupBuffer(PeiCpuMpData);\r
- }\r
-\r
- //\r
- // Need to wakeUp AP (future BSP).\r
- //\r
- WakeUpAP (PeiCpuMpData, FALSE, ProcessorNumber, FutureBSPProc, PeiCpuMpData);\r
-\r
- AsmExchangeRole (&PeiCpuMpData->BSPInfo, &PeiCpuMpData->APInfo);\r
-\r
- if (PeiCpuMpData->EndOfPeiFlag) {\r
- //\r
- // Backup original data and copy AP reset vector in it\r
- //\r
- RestoreWakeupBuffer(PeiCpuMpData);\r
- }\r
-\r
- //\r
- // Set the BSP bit of MSR_IA32_APIC_BASE on new BSP\r
- //\r
- ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE);\r
- ApicBaseMsr.Bits.BSP = 1;\r
- AsmWriteMsr64 (MSR_IA32_APIC_BASE, ApicBaseMsr.Uint64);\r
- //\r
- // Set old BSP enable state\r
- //\r
- if (!EnableOldBSP) {\r
- PeiCpuMpData->CpuData[PeiCpuMpData->BspNumber].State = CpuStateDisabled;\r
- }\r
- //\r
- // Save new BSP number\r
- //\r
- PeiCpuMpData->BspNumber = (UINT32) ProcessorNumber;\r
-\r
- return EFI_SUCCESS;\r
+ return MpInitLibSwitchBSP (ProcessorNumber, EnableOldBSP);\r
}\r
\r
/**\r
IN UINT32 *HealthFlag OPTIONAL\r
)\r
{\r
- PEI_CPU_MP_DATA *PeiCpuMpData;\r
- UINTN CallerNumber;\r
-\r
- PeiCpuMpData = GetMpHobData ();\r
- if (PeiCpuMpData == NULL) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- //\r
- // Check whether caller processor is BSP\r
- //\r
- PeiWhoAmI (PeiServices, This, &CallerNumber);\r
- if (CallerNumber != PeiCpuMpData->BspNumber) {\r
- return EFI_DEVICE_ERROR;\r
- }\r
-\r
- if (ProcessorNumber == PeiCpuMpData->BspNumber) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (ProcessorNumber >= PeiCpuMpData->CpuCount) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- if (!EnableAP) {\r
- PeiCpuMpData->CpuData[ProcessorNumber].State = CpuStateDisabled;\r
- } else {\r
- PeiCpuMpData->CpuData[ProcessorNumber].State = CpuStateIdle;\r
- }\r
-\r
- if (HealthFlag != NULL) {\r
- PeiCpuMpData->CpuData[ProcessorNumber].CpuHealthy =\r
- (BOOLEAN) ((*HealthFlag & PROCESSOR_HEALTH_STATUS_BIT) != 0);\r
- }\r
- return EFI_SUCCESS;\r
+ return MpInitLibEnableDisableAP (ProcessorNumber, EnableAP, HealthFlag);\r
}\r
\r
/**\r
OUT UINTN *ProcessorNumber\r
)\r
{\r
- PEI_CPU_MP_DATA *PeiCpuMpData;\r
-\r
- PeiCpuMpData = GetMpHobData ();\r
- if (PeiCpuMpData == NULL) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- if (ProcessorNumber == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- return GetProcessorNumber (PeiCpuMpData, ProcessorNumber);\r
+ return MpInitLibWhoAmI (ProcessorNumber);\r
}\r
-\r