summaryrefslogtreecommitdiff
path: root/UefiCpuPkg/CpuDxe/CpuMp.c
diff options
context:
space:
mode:
authorChen Fan <chen.fan.fnst@cn.fujitsu.com>2014-11-13 18:25:48 +0000
committerjljusten <jljusten@Edk2>2014-11-13 18:25:48 +0000
commit6a26a597a38d36c670a5c1ce0bf54c8a413a1868 (patch)
tree641123cece8e401aea1da6334a4c5efbd361ac94 /UefiCpuPkg/CpuDxe/CpuMp.c
parent533263ee5a7fe83ad5a0d2da74ff30815c5ab63c (diff)
downloadedk2-platforms-6a26a597a38d36c670a5c1ce0bf54c8a413a1868.tar.xz
UefiCpuPkg/CpuDxe: introduce two PCD value
introduce PCD value: PcdCpuMaxLogicalProcessorNumber and PcdCpuApStackSize, used for initialize APs stacks. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com> Reviewed-by: Jeff Fan <jeff.fan@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16350 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'UefiCpuPkg/CpuDxe/CpuMp.c')
-rw-r--r--UefiCpuPkg/CpuDxe/CpuMp.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c
index ea403e8e12..bfd0d8d853 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.c
+++ b/UefiCpuPkg/CpuDxe/CpuMp.c
@@ -15,9 +15,14 @@
#include "CpuDxe.h"
#include "CpuMp.h"
+UINTN gMaxLogicalProcessorNumber;
+UINTN gApStackSize;
+
VOID *mCommonStack = 0;
VOID *mTopOfApCommonStack = 0;
+VOID *mApStackStart = 0;
+volatile UINTN mNumberOfProcessors;
/**
Application Processor C code entry point.
@@ -29,6 +34,7 @@ ApEntryPointInC (
VOID
)
{
+ mNumberOfProcessors++;
}
@@ -41,5 +47,39 @@ InitializeMpSupport (
VOID
)
{
-}
+ gMaxLogicalProcessorNumber = (UINTN) PcdGet32 (PcdCpuMaxLogicalProcessorNumber);
+ if (gMaxLogicalProcessorNumber < 1) {
+ DEBUG ((DEBUG_ERROR, "Setting PcdCpuMaxLogicalProcessorNumber should be more than zero.\n"));
+ return;
+ }
+
+ if (gMaxLogicalProcessorNumber == 1) {
+ return;
+ }
+
+ gApStackSize = (UINTN) PcdGet32 (PcdCpuApStackSize);
+ ASSERT ((gApStackSize & (SIZE_4KB - 1)) == 0);
+
+ mApStackStart = AllocatePages (EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));
+ ASSERT (mApStackStart != NULL);
+ //
+ // the first buffer of stack size used for common stack, when the amount of AP
+ // more than 1, we should never free the common stack which maybe used for AP reset.
+ //
+ mCommonStack = mApStackStart;
+ mTopOfApCommonStack = (UINT8*) mApStackStart + gApStackSize;
+ mApStackStart = mTopOfApCommonStack;
+
+ mNumberOfProcessors = 1;
+
+ if (mNumberOfProcessors == 1) {
+ FreePages (mCommonStack, EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));
+ return;
+ }
+
+ if (mNumberOfProcessors < gMaxLogicalProcessorNumber) {
+ FreePages (mApStackStart, EFI_SIZE_TO_PAGES ((gMaxLogicalProcessorNumber - mNumberOfProcessors) *
+ gApStackSize));
+ }
+}