Introduce a PCD value to specify Application Processor
Stack size, by default 32KB, and BSP allocates stack for
APs after APs complete initlization.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <[email protected]>
---
 UefiCpuPkg/CpuDxe/CpuDxe.inf |  3 +++
 UefiCpuPkg/CpuDxe/CpuMp.c    | 18 ++++++++++++++++++
 UefiCpuPkg/UefiCpuPkg.dec    |  4 ++++
 3 files changed, 25 insertions(+)

diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.inf b/UefiCpuPkg/CpuDxe/CpuDxe.inf
index c2f12b7..88b107f 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.inf
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.inf
@@ -75,6 +75,9 @@
   gIdleLoopEventGuid                            ## CONSUMES           ## Event
   gEfiVectorHandoffTableGuid                    ## SOMETIMES_CONSUMES ## 
SystemTable
 
+[Pcd]
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize
+
 [Depex]
   TRUE
 
diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c
index 2d52b22..11129e6 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.c
+++ b/UefiCpuPkg/CpuDxe/CpuMp.c
@@ -15,10 +15,14 @@
 #include "CpuDxe.h"
 #include "CpuMp.h"
 
+UINTN gApStackSize;
+
 VOID *mCommonStack = 0;
 VOID *mTopOfApCommonStack = 0;
+VOID *mApStackStart = 0;
 
 volatile UINTN   mNumberOfProcessors;
+volatile BOOLEAN mAllApsInitFinished = FALSE;
 
 /**
   Application Processor C code entry point.
@@ -37,6 +41,13 @@ ApEntryPointInC (
 
   AsmApDoneWithCommonStack ();
 
+  //
+  // Waiting for all APs complete initialization
+  //
+  while (!mAllApsInitFinished) {
+    CpuPause ();
+  }
+
   CpuSleep ();
 }
 
@@ -57,5 +68,12 @@ InitializeMpSupport (
   }
 
   DEBUG ((DEBUG_INFO, "Detect CPU count: %d\n", mNumberOfProcessors));
+
+  gApStackSize = (UINTN) PcdGet32 (PcdCpuApStackSize);
+
+  mApStackStart = AllocatePages (EFI_SIZE_TO_PAGES ((mNumberOfProcessors - 1) 
* gApStackSize));
+  ASSERT (mApStackStart != 0x0);
+
+  mAllApsInitFinished = TRUE;
 }
 
diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index c6e73a9..5b35a23 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -54,6 +54,10 @@
   ## Specifies delay value in microseconds after sending out an INIT IPI.
   # @Prompt Configure delay value after send an INIT IPI
   
gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds|10000|UINT32|0x30000002
+  ## This value specifies the Application Processor (AP) stack size, which 
used for Mp Service.
+  # @Prompt Configure stack size for Application Processor (AP)
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize|0x8000|UINT32|0x0000000a
+
 
 [UserExtensions.TianoCore."ExtraFiles"]
   UefiCpuPkgExtra.uni
-- 
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