PeiCpuMpData = ExchangeInfo->PeiCpuMpData;\r
if (PeiCpuMpData->InitFlag) {\r
//\r
- // This is first time AP wakeup, get BIST inforamtion from AP stack\r
+ // This is first time AP wakeup, get BIST information from AP stack\r
//\r
BistData = *(UINTN *) (PeiCpuMpData->Buffer + NumApsExecuting * PeiCpuMpData->CpuApStackSize - sizeof (UINTN));\r
- PeiCpuMpData->CpuData[NumApsExecuting].ApicId = GetInitialApicId ();\r
PeiCpuMpData->CpuData[NumApsExecuting].Health.Uint32 = (UINT32) BistData;\r
+ PeiCpuMpData->CpuData[NumApsExecuting].ApicId = GetInitialApicId ();\r
+ if (PeiCpuMpData->CpuData[NumApsExecuting].ApicId >= 0xFF) {\r
+ //\r
+ // Set x2APIC mode if there are any logical processor reporting\r
+ // an APIC ID of 255 or greater.\r
+ //\r
+ AcquireSpinLock(&PeiCpuMpData->MpLock);\r
+ PeiCpuMpData->X2ApicEnable = TRUE;\r
+ ReleaseSpinLock(&PeiCpuMpData->MpLock);\r
+ }\r
//\r
// Sync BSP's Mtrr table to all wakeup APs and load microcode on APs.\r
//\r
//\r
if (PcdGet32 (PcdCpuMaxLogicalProcessorNumber) > 1) {\r
//\r
- // Send broadcast IPI to APs to wakeup APs\r
+ // Send 1st broadcast IPI to APs to wakeup APs\r
//\r
- PeiCpuMpData->InitFlag = 1;\r
+ PeiCpuMpData->InitFlag = TRUE;\r
+ PeiCpuMpData->X2ApicEnable = FALSE;\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->InitFlag = FALSE;\r
PeiCpuMpData->CpuCount += (UINT32)PeiCpuMpData->MpCpuExchangeInfo->NumApsExecuting;\r
ASSERT (PeiCpuMpData->CpuCount <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));\r
//\r
PeiCpuMpData->CpuData[0].ApicId = GetInitialApicId ();\r
PeiCpuMpData->CpuData[0].Health.Uint32 = 0;\r
PeiCpuMpData->EndOfPeiFlag = FALSE;\r
+ InitializeSpinLock(&PeiCpuMpData->MpLock);\r
CopyMem (&PeiCpuMpData->AddressMap, &AddressMap, sizeof (MP_ASSEMBLY_ADDRESS_MAP));\r
\r
//\r