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