return;\r
}\r
\r
- if (gMaxLogicalProcessorNumber == 1) {\r
- return;\r
- }\r
\r
- gApStackSize = (UINTN) PcdGet32 (PcdCpuApStackSize);\r
- ASSERT ((gApStackSize & (SIZE_4KB - 1)) == 0);\r
\r
- mApStackStart = AllocatePages (EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));\r
- ASSERT (mApStackStart != NULL);\r
+ InitMpSystemData ();\r
\r
//\r
- // the first buffer of stack size used for common stack, when the amount of AP\r
- // more than 1, we should never free the common stack which maybe used for AP reset.\r
+ // Only perform AP detection if PcdCpuMaxLogicalProcessorNumber is greater than 1\r
//\r
- mCommonStack = mApStackStart;\r
- mTopOfApCommonStack = (UINT8*) mApStackStart + gApStackSize;\r
- mApStackStart = mTopOfApCommonStack;\r
+ if (gMaxLogicalProcessorNumber > 1) {\r
\r
- InitMpSystemData ();\r
+ gApStackSize = (UINTN) PcdGet32 (PcdCpuApStackSize);\r
+ ASSERT ((gApStackSize & (SIZE_4KB - 1)) == 0);\r
+\r
+ mApStackStart = AllocatePages (EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));\r
+ ASSERT (mApStackStart != NULL);\r
+\r
+ //\r
+ // the first buffer of stack size used for common stack, when the amount of AP\r
+ // more than 1, we should never free the common stack which maybe used for AP reset.\r
+ //\r
+ mCommonStack = mApStackStart;\r
+ mTopOfApCommonStack = (UINT8*) mApStackStart + gApStackSize;\r
+ mApStackStart = mTopOfApCommonStack;\r
\r
- PrepareAPStartupCode ();\r
+ PrepareAPStartupCode ();\r
\r
- StartApsStackless ();\r
+ StartApsStackless ();\r
+ }\r
\r
DEBUG ((DEBUG_INFO, "Detect CPU count: %d\n", mMpSystemData.NumberOfProcessors));\r
if (mMpSystemData.NumberOfProcessors == 1) {\r
FreeApStartupCode ();\r
- FreePages (mCommonStack, EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));\r
- return;\r
+ if (mCommonStack != NULL) {\r
+ FreePages (mCommonStack, EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));\r
+ }\r
}\r
\r
mMpSystemData.CpuDatas = ReallocatePool (\r
);\r
ASSERT_EFI_ERROR (Status);\r
\r
- if (mMpSystemData.NumberOfProcessors < gMaxLogicalProcessorNumber) {\r
- FreePages (mApStackStart, EFI_SIZE_TO_PAGES (\r
- (gMaxLogicalProcessorNumber - mMpSystemData.NumberOfProcessors) *\r
- gApStackSize));\r
+ if (mMpSystemData.NumberOfProcessors > 1 && mMpSystemData.NumberOfProcessors < gMaxLogicalProcessorNumber) {\r
+ if (mApStackStart != NULL) {\r
+ FreePages (mApStackStart, EFI_SIZE_TO_PAGES (\r
+ (gMaxLogicalProcessorNumber - mMpSystemData.NumberOfProcessors) *\r
+ gApStackSize));\r
+ }\r
}\r
\r
Status = gBS->CreateEvent (\r
// Store BSP's MTRR setting\r
//\r
MtrrGetAllMtrrs (&PeiCpuMpData->MtrrTable);\r
+\r
//\r
- // Send broadcast IPI to APs to wakeup APs\r
- //\r
- PeiCpuMpData->InitFlag = 1;\r
- WakeUpAP (PeiCpuMpData, TRUE, 0, NULL, NULL);\r
- //\r
- // Wait for AP task to complete and then exit.\r
- //\r
- MicroSecondDelay (PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds));\r
- PeiCpuMpData->InitFlag = 0;\r
- PeiCpuMpData->CpuCount += (UINT32) PeiCpuMpData->MpCpuExchangeInfo->NumApsExecuting;\r
- ASSERT (PeiCpuMpData->CpuCount <= PcdGet32(PcdCpuMaxLogicalProcessorNumber));\r
- //\r
- // Sort BSP/Aps by CPU APIC ID in ascending order\r
+ // Only perform AP detection if PcdCpuMaxLogicalProcessorNumber is greater than 1\r
//\r
- SortApicId (PeiCpuMpData);\r
+ if (PcdGet32 (PcdCpuMaxLogicalProcessorNumber) > 1) {\r
+ //\r
+ // Send broadcast IPI to APs to wakeup APs\r
+ //\r
+ PeiCpuMpData->InitFlag = 1;\r
+ WakeUpAP (PeiCpuMpData, TRUE, 0, NULL, NULL);\r
+ //\r
+ // Wait for AP task to complete and then exit.\r
+ //\r
+ MicroSecondDelay (PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds));\r
+ PeiCpuMpData->InitFlag = 0;\r
+ PeiCpuMpData->CpuCount += (UINT32)PeiCpuMpData->MpCpuExchangeInfo->NumApsExecuting;\r
+ ASSERT (PeiCpuMpData->CpuCount <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));\r
+ //\r
+ // Sort BSP/Aps by CPU APIC ID in ascending order\r
+ //\r
+ SortApicId (PeiCpuMpData);\r
+ }\r
\r
DEBUG ((EFI_D_INFO, "CpuMpPei: Find %d processors in system.\n", PeiCpuMpData->CpuCount));\r
return PeiCpuMpData->CpuCount;\r