Revision: 16365
          http://sourceforge.net/p/edk2/code/16365
Author:   jljusten
Date:     2014-11-13 18:29:01 +0000 (Thu, 13 Nov 2014)
Log Message:
-----------
UefiCpuPkg/CpuDxe: split out StartupCode from StartApsStackless()

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <[email protected]>
Reviewed-by: Jeff Fan <[email protected]>

Modified Paths:
--------------
    trunk/edk2/UefiCpuPkg/CpuDxe/ApStartup.c
    trunk/edk2/UefiCpuPkg/CpuDxe/CpuMp.c
    trunk/edk2/UefiCpuPkg/CpuDxe/CpuMp.h

Modified: trunk/edk2/UefiCpuPkg/CpuDxe/ApStartup.c
===================================================================
--- trunk/edk2/UefiCpuPkg/CpuDxe/ApStartup.c    2014-11-13 18:28:48 UTC (rev 
16364)
+++ trunk/edk2/UefiCpuPkg/CpuDxe/ApStartup.c    2014-11-13 18:29:01 UTC (rev 
16365)
@@ -238,27 +238,22 @@
 
 };
 
+volatile STARTUP_CODE *StartupCode = NULL;
 
 /**
-  Starts the Application Processors and directs them to jump to the
-  specified routine.
+  Prepares Startup Code for APs.
+  This function prepares Startup Code for APs.
 
-  The processor jumps to this code in flat mode, but the processor's
-  stack is not initialized.
-
-  @param ApEntryPoint    Pointer to the Entry Point routine
-
   @retval EFI_SUCCESS           The APs were started
   @retval EFI_OUT_OF_RESOURCES  Cannot allocate memory to start APs
 
 **/
 EFI_STATUS
-StartApsStackless (
-  IN STACKLESS_AP_ENTRY_POINT ApEntryPoint
+PrepareAPStartupCode (
+  VOID
   )
 {
   EFI_STATUS            Status;
-  volatile STARTUP_CODE *StartupCode;
   IA32_DESCRIPTOR       Gdtr;
   EFI_PHYSICAL_ADDRESS  StartAddress;
 
@@ -281,7 +276,7 @@
   StartupCode->GdtLimit = Gdtr.Limit;
   StartupCode->GdtBase = (UINT32) Gdtr.Base;
 
-  StartupCode->CpuDxeEntryValue = (UINTN) ApEntryPoint;
+  StartupCode->CpuDxeEntryValue = (UINTN) AsmApEntryPoint;
 
   StartupCode->FlatJmpOffset += (UINT32) StartAddress;
 
@@ -290,15 +285,46 @@
   StartupCode->LongJmpOffset += (UINT32) StartAddress;
 #endif
 
+  return EFI_SUCCESS;
+}
+
+/**
+  Free the code buffer of startup AP.
+
+**/
+VOID
+FreeApStartupCode (
+  VOID
+  )
+{
+  if (StartupCode != NULL) {
+    gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)(VOID*) StartupCode,
+                    EFI_SIZE_TO_PAGES (sizeof (*StartupCode)));
+  }
+}
+
+
+/**
+  Starts the Application Processors and directs them to jump to the
+  specified routine.
+
+  The processor jumps to this code in flat mode, but the processor's
+  stack is not initialized.
+
+  @retval EFI_SUCCESS           The APs were started
+
+**/
+EFI_STATUS
+StartApsStackless (
+  VOID
+  )
+{
   SendInitSipiSipiAllExcludingSelf ((UINT32)(UINTN)(VOID*) StartupCode);
-
   //
   // Wait 100 milliseconds for APs to arrive at the ApEntryPoint routine
   //
   MicroSecondDelay (100 * 1000);
 
-  gBS->FreePages (StartAddress, EFI_SIZE_TO_PAGES (sizeof (*StartupCode)));
-
   return EFI_SUCCESS;
 }
 

Modified: trunk/edk2/UefiCpuPkg/CpuDxe/CpuMp.c
===================================================================
--- trunk/edk2/UefiCpuPkg/CpuDxe/CpuMp.c        2014-11-13 18:28:48 UTC (rev 
16364)
+++ trunk/edk2/UefiCpuPkg/CpuDxe/CpuMp.c        2014-11-13 18:29:01 UTC (rev 
16365)
@@ -1454,7 +1454,10 @@
 
   InitMpSystemData ();
 
+  PrepareAPStartupCode ();
+
   if (mMpSystemData.NumberOfProcessors == 1) {
+    FreeApStartupCode ();
     FreePages (mCommonStack, EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * 
gApStackSize));
     return;
   }

Modified: trunk/edk2/UefiCpuPkg/CpuDxe/CpuMp.h
===================================================================
--- trunk/edk2/UefiCpuPkg/CpuDxe/CpuMp.h        2014-11-13 18:28:48 UTC (rev 
16364)
+++ trunk/edk2/UefiCpuPkg/CpuDxe/CpuMp.h        2014-11-13 18:29:01 UTC (rev 
16365)
@@ -40,15 +40,12 @@
   The processor jumps to this code in flat mode, but the processor's
   stack is not initialized.
 
-  @param ApEntryPoint    Pointer to the Entry Point routine
-
   @retval EFI_SUCCESS           The APs were started
-  @retval EFI_OUT_OF_RESOURCES  Cannot allocate memory to start APs
 
 **/
 EFI_STATUS
 StartApsStackless (
-  IN STACKLESS_AP_ENTRY_POINT ApEntryPoint
+  VOID
   );
 
 /**
@@ -603,5 +600,27 @@
   IN CPU_DATA_BLOCK  *CpuData
   );
 
+/**
+  Prepares Startup Code for APs.
+  This function prepares Startup Code for APs.
+
+  @retval EFI_SUCCESS           The APs were started
+  @retval EFI_OUT_OF_RESOURCES  Cannot allocate memory to start APs
+
+**/
+EFI_STATUS
+PrepareAPStartupCode (
+  VOID
+  );
+
+/**
+  Free the code buffer of startup AP.
+
+**/
+VOID
+FreeApStartupCode (
+  VOID
+  );
+
 #endif // _CPU_MP_H_
 


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to