]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/CpuDxe: split out StartupCode from StartApsStackless()
authorChen Fan <chen.fan.fnst@cn.fujitsu.com>
Thu, 13 Nov 2014 18:29:01 +0000 (18:29 +0000)
committerjljusten <jljusten@Edk2>
Thu, 13 Nov 2014 18:29:01 +0000 (18:29 +0000)
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@16365 6f19259b-4bc3-4df7-8a09-765794883524

UefiCpuPkg/CpuDxe/ApStartup.c
UefiCpuPkg/CpuDxe/CpuMp.c
UefiCpuPkg/CpuDxe/CpuMp.h

index 5477c52672613643bf23e0848b9fe873d40442e3..801f7f8611fd77c63730b1f110c8a505ab4981a0 100644 (file)
@@ -238,27 +238,22 @@ STARTUP_CODE mStartupCodeTemplate = {
 \r
 };\r
 \r
+volatile STARTUP_CODE *StartupCode = NULL;\r
 \r
 /**\r
-  Starts the Application Processors and directs them to jump to the\r
-  specified routine.\r
-\r
-  The processor jumps to this code in flat mode, but the processor's\r
-  stack is not initialized.\r
-\r
-  @param ApEntryPoint    Pointer to the Entry Point routine\r
+  Prepares Startup Code for APs.\r
+  This function prepares Startup Code for APs.\r
 \r
   @retval EFI_SUCCESS           The APs were started\r
   @retval EFI_OUT_OF_RESOURCES  Cannot allocate memory to start APs\r
 \r
 **/\r
 EFI_STATUS\r
-StartApsStackless (\r
-  IN STACKLESS_AP_ENTRY_POINT ApEntryPoint\r
+PrepareAPStartupCode (\r
+  VOID\r
   )\r
 {\r
   EFI_STATUS            Status;\r
-  volatile STARTUP_CODE *StartupCode;\r
   IA32_DESCRIPTOR       Gdtr;\r
   EFI_PHYSICAL_ADDRESS  StartAddress;\r
 \r
@@ -281,7 +276,7 @@ StartApsStackless (
   StartupCode->GdtLimit = Gdtr.Limit;\r
   StartupCode->GdtBase = (UINT32) Gdtr.Base;\r
 \r
-  StartupCode->CpuDxeEntryValue = (UINTN) ApEntryPoint;\r
+  StartupCode->CpuDxeEntryValue = (UINTN) AsmApEntryPoint;\r
 \r
   StartupCode->FlatJmpOffset += (UINT32) StartAddress;\r
 \r
@@ -290,15 +285,46 @@ StartApsStackless (
   StartupCode->LongJmpOffset += (UINT32) StartAddress;\r
 #endif\r
 \r
-  SendInitSipiSipiAllExcludingSelf ((UINT32)(UINTN)(VOID*) StartupCode);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Free the code buffer of startup AP.\r
+\r
+**/\r
+VOID\r
+FreeApStartupCode (\r
+  VOID\r
+  )\r
+{\r
+  if (StartupCode != NULL) {\r
+    gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)(VOID*) StartupCode,\r
+                    EFI_SIZE_TO_PAGES (sizeof (*StartupCode)));\r
+  }\r
+}\r
 \r
+\r
+/**\r
+  Starts the Application Processors and directs them to jump to the\r
+  specified routine.\r
+\r
+  The processor jumps to this code in flat mode, but the processor's\r
+  stack is not initialized.\r
+\r
+  @retval EFI_SUCCESS           The APs were started\r
+\r
+**/\r
+EFI_STATUS\r
+StartApsStackless (\r
+  VOID\r
+  )\r
+{\r
+  SendInitSipiSipiAllExcludingSelf ((UINT32)(UINTN)(VOID*) StartupCode);\r
   //\r
   // Wait 100 milliseconds for APs to arrive at the ApEntryPoint routine\r
   //\r
   MicroSecondDelay (100 * 1000);\r
 \r
-  gBS->FreePages (StartAddress, EFI_SIZE_TO_PAGES (sizeof (*StartupCode)));\r
-\r
   return EFI_SUCCESS;\r
 }\r
 \r
index 3e30d7417d4f0ea88739911544cfb2984e30ba41..029e8d43317beb026a7726101f219dfb14c80006 100644 (file)
@@ -1454,7 +1454,10 @@ InitializeMpSupport (
 \r
   InitMpSystemData ();\r
 \r
+  PrepareAPStartupCode ();\r
+\r
   if (mMpSystemData.NumberOfProcessors == 1) {\r
+    FreeApStartupCode ();\r
     FreePages (mCommonStack, EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));\r
     return;\r
   }\r
index a53ef52d93b4df44016abc9b416a55790b9f9a7c..2b1717d4107453b39d73c703443476d731bf3380 100644 (file)
@@ -40,15 +40,12 @@ VOID
   The processor jumps to this code in flat mode, but the processor's\r
   stack is not initialized.\r
 \r
-  @param ApEntryPoint    Pointer to the Entry Point routine\r
-\r
   @retval EFI_SUCCESS           The APs were started\r
-  @retval EFI_OUT_OF_RESOURCES  Cannot allocate memory to start APs\r
 \r
 **/\r
 EFI_STATUS\r
 StartApsStackless (\r
-  IN STACKLESS_AP_ENTRY_POINT ApEntryPoint\r
+  VOID\r
   );\r
 \r
 /**\r
@@ -603,5 +600,27 @@ ResetProcessorToIdleState (
   IN CPU_DATA_BLOCK  *CpuData\r
   );\r
 \r
+/**\r
+  Prepares Startup Code for APs.\r
+  This function prepares Startup Code for APs.\r
+\r
+  @retval EFI_SUCCESS           The APs were started\r
+  @retval EFI_OUT_OF_RESOURCES  Cannot allocate memory to start APs\r
+\r
+**/\r
+EFI_STATUS\r
+PrepareAPStartupCode (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Free the code buffer of startup AP.\r
+\r
+**/\r
+VOID\r
+FreeApStartupCode (\r
+  VOID\r
+  );\r
+\r
 #endif // _CPU_MP_H_\r
 \r