]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuDxe/ApStartup.c
UefiCpuPkg/CpuDxe: split out StartupCode from StartApsStackless()
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / ApStartup.c
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