Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <[email protected]>
---
 UefiCpuPkg/CpuDxe/CpuMp.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c
index adec818..b9904a2 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.c
+++ b/UefiCpuPkg/CpuDxe/CpuMp.c
@@ -1098,10 +1098,39 @@ ProcessorToIdleState (
   IN      VOID                      *Context2   OPTIONAL
   )
 {
-  DEBUG ((DEBUG_INFO, "Ap apicid is %d\n", GetApicId ()));
+  UINTN                 ProcessorNumber;
+  CPU_DATA_BLOCK        *CpuData;
+  EFI_AP_PROCEDURE      Procedure;
+  VOID                  *ProcedureArgument;
+
+  WhoAmI (&mMpServicesTemplate, &ProcessorNumber);
+  CpuData = &mMpSystemData.CpuDatas[ProcessorNumber];
 
   AsmApDoneWithCommonStack ();
 
+  while (TRUE) {
+    while (!AcquireSpinLockOrFail (&CpuData->CpuDataLock)) {
+      CpuPause ();
+    }
+
+    ProcedureArgument = CpuData->Parameter;
+    Procedure = CpuData->Procedure;
+    ReleaseSpinLock (&CpuData->CpuDataLock);
+
+    if (Procedure != NULL) {
+      Procedure (ProcedureArgument);
+
+      while (!AcquireSpinLockOrFail (&CpuData->CpuDataLock)) {
+        CpuPause ();
+      }
+
+      CpuData->Procedure = NULL;
+      ReleaseSpinLock (&CpuData->CpuDataLock);
+
+      SetApState (CpuData, CpuStateFinished);
+    }
+  }
+
   CpuSleep ();
   CpuDeadLoop ();
 }
-- 
1.9.3


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to