]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/CpuDxe: introduce two PCD value
authorChen Fan <chen.fan.fnst@cn.fujitsu.com>
Thu, 13 Nov 2014 18:25:48 +0000 (18:25 +0000)
committerjljusten <jljusten@Edk2>
Thu, 13 Nov 2014 18:25:48 +0000 (18:25 +0000)
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

UefiCpuPkg/CpuDxe/CpuDxe.inf
UefiCpuPkg/CpuDxe/CpuMp.c
UefiCpuPkg/UefiCpuPkg.dec

index c2f12b7bbacdbbee30f92806c21510c741680a7d..0e53651edb3af9987ebb07361a2d5f504a762b74 100644 (file)
   gIdleLoopEventGuid                            ## CONSUMES           ## Event\r
   gEfiVectorHandoffTableGuid                    ## SOMETIMES_CONSUMES ## SystemTable\r
 \r
+[Pcd]\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber   ## CONSUMES\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize                 ## CONSUMES\r
+\r
 [Depex]\r
   TRUE\r
 \r
index ea403e8e124310853343f212825fe911fc223e75..bfd0d8d8535c556b5f434af84a4b1a7cc1b86d0e 100644 (file)
 #include "CpuDxe.h"\r
 #include "CpuMp.h"\r
 \r
+UINTN gMaxLogicalProcessorNumber;\r
+UINTN gApStackSize;\r
+\r
 VOID *mCommonStack = 0;\r
 VOID *mTopOfApCommonStack = 0;\r
+VOID *mApStackStart = 0;\r
 \r
+volatile UINTN mNumberOfProcessors;\r
 \r
 /**\r
   Application Processor C code entry point.\r
@@ -29,6 +34,7 @@ ApEntryPointInC (
   VOID\r
   )\r
 {\r
+  mNumberOfProcessors++;\r
 }\r
 \r
 \r
@@ -41,5 +47,39 @@ InitializeMpSupport (
   VOID\r
   )\r
 {\r
-}\r
+  gMaxLogicalProcessorNumber = (UINTN) PcdGet32 (PcdCpuMaxLogicalProcessorNumber);\r
+  if (gMaxLogicalProcessorNumber < 1) {\r
+    DEBUG ((DEBUG_ERROR, "Setting PcdCpuMaxLogicalProcessorNumber should be more than zero.\n"));\r
+    return;\r
+  }\r
+\r
+  if (gMaxLogicalProcessorNumber == 1) {\r
+    return;\r
+  }\r
+\r
+  gApStackSize = (UINTN) PcdGet32 (PcdCpuApStackSize);\r
+  ASSERT ((gApStackSize & (SIZE_4KB - 1)) == 0);\r
+\r
+  mApStackStart = AllocatePages (EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));\r
+  ASSERT (mApStackStart != NULL);\r
 \r
+  //\r
+  // the first buffer of stack size used for common stack, when the amount of AP\r
+  // more than 1, we should never free the common stack which maybe used for AP reset.\r
+  //\r
+  mCommonStack = mApStackStart;\r
+  mTopOfApCommonStack = (UINT8*) mApStackStart + gApStackSize;\r
+  mApStackStart = mTopOfApCommonStack;\r
+\r
+  mNumberOfProcessors = 1;\r
+\r
+  if (mNumberOfProcessors == 1) {\r
+    FreePages (mCommonStack, EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));\r
+    return;\r
+  }\r
+\r
+  if (mNumberOfProcessors < gMaxLogicalProcessorNumber) {\r
+    FreePages (mApStackStart, EFI_SIZE_TO_PAGES ((gMaxLogicalProcessorNumber - mNumberOfProcessors) *\r
+                                                 gApStackSize));\r
+  }\r
+}\r
index c6e73a9d4c208e9c01f652ebffb4afd765039588..14a0bf2e4259285661b9e3dd617567b26eb93a1f 100644 (file)
   ## Specifies delay value in microseconds after sending out an INIT IPI.\r
   # @Prompt Configure delay value after send an INIT IPI\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds|10000|UINT32|0x30000002\r
+  ## Specifies max supported number of Logical Processors.\r
+  # @Prompt Configure max supported number of Logical Processorss\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64|UINT32|0x00000002\r
+  ## This value specifies the Application Processor (AP) stack size, used for Mp Service, which must\r
+  ## aligns the address on a 4-KByte boundary.\r
+  # @Prompt Configure stack size for Application Processor (AP)\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize|0x8000|UINT32|0x00000003\r
 \r
 [UserExtensions.TianoCore."ExtraFiles"]\r
   UefiCpuPkgExtra.uni\r