Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.f...@cn.fujitsu.com>
---
 UefiCpuPkg/CpuDxe/CpuMp.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c
index ee25eac..f5de832 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.c
+++ b/UefiCpuPkg/CpuDxe/CpuMp.c
@@ -1108,10 +1108,41 @@ 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);
+    }
+
+    CpuPause ();
+  }
+
   CpuSleep ();
   CpuDeadLoop ();
 }
-- 
1.9.3


------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to