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

diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c
index 82554c1..7e12103 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.c
+++ b/UefiCpuPkg/CpuDxe/CpuMp.c
@@ -27,6 +27,7 @@ VOID *mApStackStart = 0;
 
 volatile UINTN   mNumberOfProcessors;
 volatile UINTN   mIndexOfProcessors;
+volatile UINTN   mApDoneCount = 0;
 volatile BOOLEAN mAllApsInitFinished = FALSE;
 
 EFI_MP_SERVICES_PROTOCOL  mMpServicesTemplate = {
@@ -1199,6 +1200,51 @@ out:
 }
 
 /**
+  After APs switch to its own stack, they can
+  do a loop for waiting a Procedure to execute.
+
+  @param Context  the pointer to CpuData
+
+**/
+VOID
+EFIAPI
+ApDoLoop (
+  IN VOID *Context
+  )
+{
+  CPU_DATA_BLOCK        *CpuData;
+  EFI_AP_PROCEDURE      Procedure;
+  VOID                  *ProcedureArgument;
+
+  CpuData = (CPU_DATA_BLOCK *)Context;
+
+  while (TRUE) {
+    while (!AcquireSpinLockOrFail (&CpuData->CpuDataLock)) {
+      CpuPause ();
+    }
+
+    ProcedureArgument = CpuData->Parameter;
+    Procedure = CpuData->Procedure;
+    ReleaseSpinLock (&CpuData->CpuDataLock);
+
+    if (Procedure != NULL) {
+      SetApState (CpuData, CpuStateBuzy);
+
+      Procedure (ProcedureArgument);
+
+      while (!AcquireSpinLockOrFail (&CpuData->CpuDataLock)) {
+        CpuPause ();
+      }
+
+      CpuData->Procedure = NULL;
+      ReleaseSpinLock (&CpuData->CpuDataLock);
+
+      SetApState (CpuData, CpuStateFinished);
+    }
+  }
+}
+
+/**
   Application Processors do loop routine
   after switch to its own stack.
 
@@ -1222,7 +1268,10 @@ ProcessorToIdleState (
   CpuData->Info.Location.Thread  = 0;
 
   mIndexOfProcessors++;
+  mApDoneCount++;
   AsmApReleaseLock ();
+
+  ApDoLoop ((VOID *)CpuData);
 }
 
 /**
@@ -1346,5 +1395,9 @@ InitializeMpSupport (
   InitMpSystemData ();
 
   mAllApsInitFinished = TRUE;
+
+  while (mApDoneCount != (mNumberOfProcessors - 1)) {
+    CpuPause ();
+  };
 }
 
-- 
1.9.3


------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to