]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/MpInitLib: Enable x2APIC mode on BSP/APs
authorJeff Fan <jeff.fan@intel.com>
Wed, 20 Jul 2016 16:29:49 +0000 (00:29 +0800)
committerJeff Fan <jeff.fan@intel.com>
Wed, 17 Aug 2016 12:01:45 +0000 (20:01 +0800)
If x2APIC flag is set, enable x2APIC mode on all APs and BSP. Before we wakeup
APs to enable x2APIC mode, we should wait all APs have finished initialization.

Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com>
Cc: Laszlo Ersek <lersek@redhat.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>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Michael Kinney <michael.d.kinney@intel.com>
UefiCpuPkg/Library/MpInitLib/MpLib.c

index 8f7cf43a7c9103fd15a5d7375a8dc31bcdb3fb0e..d84dfec5066119c6fafbb3e14d4d950987e3725a 100644 (file)
@@ -216,6 +216,20 @@ GetApLoopMode (
   return ApLoopMode;\r
 }\r
 \r
+/**\r
+  Enable x2APIC mode on APs.\r
+\r
+  @param[in, out] Buffer  Pointer to private data buffer.\r
+**/\r
+VOID\r
+EFIAPI\r
+ApFuncEnableX2Apic (\r
+  IN OUT VOID  *Buffer\r
+  )\r
+{\r
+  SetApicMode (LOCAL_APIC_MODE_X2APIC);\r
+}\r
+\r
 /**\r
   Do sync on APs.\r
 \r
@@ -299,6 +313,24 @@ CollectProcessorCount (
     CpuPause ();\r
   }\r
 \r
+  if (CpuMpData->X2ApicEnable) {\r
+    DEBUG ((DEBUG_INFO, "Force x2APIC mode!\n"));\r
+    //\r
+    // Wakeup all APs to enable x2APIC mode\r
+    //\r
+    WakeUpAP (CpuMpData, TRUE, 0, ApFuncEnableX2Apic, NULL);\r
+    //\r
+    // Wait for all known APs finished\r
+    //\r
+    while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) {\r
+      CpuPause ();\r
+    }\r
+    //\r
+    // Enable x2APIC on BSP\r
+    //\r
+    SetApicMode (LOCAL_APIC_MODE_X2APIC);\r
+  }\r
+  DEBUG ((DEBUG_INFO, "APIC MODE is %d\n", GetApicMode ()));\r
   DEBUG ((DEBUG_INFO, "MpInitLib: Find %d processors in system.\n", CpuMpData->CpuCount));\r
 \r
   return CpuMpData->CpuCount;\r