]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/CpuMpPei: Set X2APIC flag if one x2APIC ID larger than 254
authorJeff Fan <jeff.fan@intel.com>
Wed, 25 Nov 2015 02:47:34 +0000 (02:47 +0000)
committervanjeff <vanjeff@Edk2>
Wed, 25 Nov 2015 02:47:34 +0000 (02:47 +0000)
If there are any logical processor reporting an APIC ID of 255 or greater, set
X2ApicEnable flag.

GetInitialApicId() will return x2APIC ID if CPUID leaf B supported.

Cc: Feng Tian <feng.tian@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18933 6f19259b-4bc3-4df7-8a09-765794883524

UefiCpuPkg/CpuMpPei/CpuMpPei.c
UefiCpuPkg/CpuMpPei/CpuMpPei.h

index 8e35f288fe3c64fd235a84658a851671f6317029..8ed52436c98ff8a3ea5fd19fdd71539606cbcf4e 100644 (file)
@@ -146,11 +146,20 @@ ApCFunction (
   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
@@ -363,15 +372,16 @@ CountProcessorNumber (
   //\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
@@ -439,6 +449,7 @@ PrepareAPStartupVector (
   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
index 9325a12d4ceb0d032491da34e681486faa3d33c9..de9011329c0855d6cd595973d6fa60e5b18f7a1a 100644 (file)
@@ -124,6 +124,7 @@ typedef struct {
 // PEI CPU MP Data save in memory\r
 //\r
 struct _PEI_CPU_MP_DATA {\r
+  SPIN_LOCK                      MpLock;\r
   UINT32                         CpuCount;\r
   UINT32                         BspNumber;\r
   UINTN                          Buffer;\r
@@ -137,6 +138,7 @@ struct _PEI_CPU_MP_DATA {
   volatile UINT32                FinishedCount;\r
   BOOLEAN                        EndOfPeiFlag;\r
   BOOLEAN                        InitFlag;\r
+  BOOLEAN                        X2ApicEnable;\r
   CPU_EXCHANGE_ROLE_INFO         BSPInfo;\r
   CPU_EXCHANGE_ROLE_INFO         APInfo;\r
   MTRR_SETTINGS                  MtrrTable;\r