]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/CpuDxe: implement Mp Services:StartupAllAPs()
authorChen Fan <chen.fan.fnst@cn.fujitsu.com>
Thu, 13 Nov 2014 18:27:34 +0000 (18:27 +0000)
committerjljusten <jljusten@Edk2>
Thu, 13 Nov 2014 18:27:34 +0000 (18:27 +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@16359 6f19259b-4bc3-4df7-8a09-765794883524

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

index 552bac3c6dc2c6268a419e4e7a4fcece5e2cba6f..b576d18ca451cd4a17478f8e1530a01f917fcad3 100644 (file)
@@ -28,7 +28,7 @@ VOID *mApStackStart = 0;
 EFI_MP_SERVICES_PROTOCOL  mMpServicesTemplate = {\r
   GetNumberOfProcessors,\r
   GetProcessorInfo,\r
-  NULL, // StartupAllAPs,\r
+  StartupAllAPs,\r
   StartupThisAP,\r
   NULL, // SwitchBSP,\r
   EnableDisableAP,\r
@@ -238,6 +238,106 @@ GetNextBlockedNumber (
   return EFI_NOT_FOUND;\r
 }\r
 \r
+/**\r
+  Check if the APs state are finished, and update them to idle state\r
+  by StartupAllAPs().\r
+\r
+**/\r
+VOID\r
+CheckAndUpdateAllAPsToIdleState (\r
+  VOID\r
+  )\r
+{\r
+  UINTN                 ProcessorNumber;\r
+  UINTN                 NextNumber;\r
+  CPU_DATA_BLOCK        *CpuData;\r
+  EFI_STATUS            Status;\r
+  CPU_STATE             CpuState;\r
+\r
+  for (ProcessorNumber = 0; ProcessorNumber < mMpSystemData.NumberOfProcessors; ProcessorNumber++) {\r
+    CpuData = &mMpSystemData.CpuDatas[ProcessorNumber];\r
+    if (TestCpuStatusFlag (CpuData, PROCESSOR_AS_BSP_BIT)) {\r
+      //\r
+      // Skip BSP\r
+      //\r
+      continue;\r
+    }\r
+\r
+    if (!TestCpuStatusFlag (CpuData, PROCESSOR_ENABLED_BIT)) {\r
+      //\r
+      // Skip Disabled processors\r
+      //\r
+      continue;\r
+    }\r
+\r
+    CpuState = GetApState (CpuData);\r
+    if (CpuState == CpuStateFinished) {\r
+      mMpSystemData.FinishCount++;\r
+      if (mMpSystemData.SingleThread) {\r
+        Status = GetNextBlockedNumber (&NextNumber);\r
+        if (!EFI_ERROR (Status)) {\r
+          SetApState (&mMpSystemData.CpuDatas[NextNumber], CpuStateReady);\r
+          SetApProcedure (&mMpSystemData.CpuDatas[NextNumber],\r
+                          mMpSystemData.Procedure,\r
+                          mMpSystemData.ProcedureArgument);\r
+        }\r
+      }\r
+\r
+      SetApState (CpuData, CpuStateIdle);\r
+    }\r
+  }\r
+}\r
+\r
+/**\r
+  If the timeout expires before all APs returns from Procedure,\r
+  we should forcibly terminate the executing AP and fill FailedList back\r
+  by StartupAllAPs().\r
+\r
+**/\r
+VOID\r
+ResetAllFailedAPs (\r
+  VOID\r
+  )\r
+{\r
+  CPU_DATA_BLOCK        *CpuData;\r
+  UINTN                 Number;\r
+  CPU_STATE             CpuState;\r
+\r
+  if (mMpSystemData.FailedList != NULL) {\r
+     *mMpSystemData.FailedList = AllocatePool ((mMpSystemData.StartCount - mMpSystemData.FinishCount + 1) * sizeof(UINTN));\r
+     ASSERT (*mMpSystemData.FailedList != NULL);\r
+  }\r
+\r
+  for (Number = 0; Number < mMpSystemData.NumberOfProcessors; Number++) {\r
+    CpuData = &mMpSystemData.CpuDatas[Number];\r
+    if (TestCpuStatusFlag (CpuData,  PROCESSOR_AS_BSP_BIT)) {\r
+      //\r
+      // Skip BSP\r
+      //\r
+      continue;\r
+    }\r
+\r
+    if (!TestCpuStatusFlag (CpuData, PROCESSOR_ENABLED_BIT)) {\r
+      //\r
+      // Skip Disabled processors\r
+      //\r
+      continue;\r
+    }\r
+\r
+    CpuState = GetApState (CpuData);\r
+    if (CpuState != CpuStateIdle) {\r
+      if (mMpSystemData.FailedList != NULL) {\r
+        (*mMpSystemData.FailedList)[mMpSystemData.FailedListIndex++] = Number;\r
+      }\r
+      ResetProcessorToIdleState (CpuData);\r
+    }\r
+  }\r
+\r
+  if (mMpSystemData.FailedList != NULL) {\r
+    (*mMpSystemData.FailedList)[mMpSystemData.FailedListIndex] = END_OF_CPU_LIST;\r
+  }\r
+}\r
+\r
 /**\r
   This service retrieves the number of logical processor in the platform\r
   and the number of those logical processors that are enabled on this boot.\r
@@ -345,6 +445,281 @@ GetProcessorInfo (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  This service executes a caller provided function on all enabled APs. APs can\r
+  run either simultaneously or one at a time in sequence. This service supports\r
+  both blocking and non-blocking requests. The non-blocking requests use EFI\r
+  events so the BSP can detect when the APs have finished. This service may only\r
+  be called from the BSP.\r
+\r
+  This function is used to dispatch all the enabled APs to the function specified\r
+  by Procedure.  If any enabled AP is busy, then EFI_NOT_READY is returned\r
+  immediately and Procedure is not started on any AP.\r
+\r
+  If SingleThread is TRUE, all the enabled APs execute the function specified by\r
+  Procedure one by one, in ascending order of processor handle number. Otherwise,\r
+  all the enabled APs execute the function specified by Procedure simultaneously.\r
+\r
+  If WaitEvent is NULL, execution is in blocking mode. The BSP waits until all\r
+  APs finish or TimeoutInMicroseconds expires. Otherwise, execution is in non-blocking\r
+  mode, and the BSP returns from this service without waiting for APs. If a\r
+  non-blocking mode is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT\r
+  is signaled, then EFI_UNSUPPORTED must be returned.\r
+\r
+  If the timeout specified by TimeoutInMicroseconds expires before all APs return\r
+  from Procedure, then Procedure on the failed APs is terminated. All enabled APs\r
+  are always available for further calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()\r
+  and EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). If FailedCpuList is not NULL, its\r
+  content points to the list of processor handle numbers in which Procedure was\r
+  terminated.\r
+\r
+  Note: It is the responsibility of the consumer of the EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()\r
+  to make sure that the nature of the code that is executed on the BSP and the\r
+  dispatched APs is well controlled. The MP Services Protocol does not guarantee\r
+  that the Procedure function is MP-safe. Hence, the tasks that can be run in\r
+  parallel are limited to certain independent tasks and well-controlled exclusive\r
+  code. EFI services and protocols may not be called by APs unless otherwise\r
+  specified.\r
+\r
+  In blocking execution mode, BSP waits until all APs finish or\r
+  TimeoutInMicroseconds expires.\r
+\r
+  In non-blocking execution mode, BSP is freed to return to the caller and then\r
+  proceed to the next task without having to wait for APs. The following\r
+  sequence needs to occur in a non-blocking execution mode:\r
+\r
+    -# The caller that intends to use this MP Services Protocol in non-blocking\r
+       mode creates WaitEvent by calling the EFI CreateEvent() service.  The caller\r
+       invokes EFI_MP_SERVICES_PROTOCOL.StartupAllAPs(). If the parameter WaitEvent\r
+       is not NULL, then StartupAllAPs() executes in non-blocking mode. It requests\r
+       the function specified by Procedure to be started on all the enabled APs,\r
+       and releases the BSP to continue with other tasks.\r
+    -# The caller can use the CheckEvent() and WaitForEvent() services to check\r
+       the state of the WaitEvent created in step 1.\r
+    -# When the APs complete their task or TimeoutInMicroSecondss expires, the MP\r
+       Service signals WaitEvent by calling the EFI SignalEvent() function. If\r
+       FailedCpuList is not NULL, its content is available when WaitEvent is\r
+       signaled. If all APs returned from Procedure prior to the timeout, then\r
+       FailedCpuList is set to NULL. If not all APs return from Procedure before\r
+       the timeout, then FailedCpuList is filled in with the list of the failed\r
+       APs. The buffer is allocated by MP Service Protocol using AllocatePool().\r
+       It is the caller's responsibility to free the buffer with FreePool() service.\r
+    -# This invocation of SignalEvent() function informs the caller that invoked\r
+       EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() that either all the APs completed\r
+       the specified task or a timeout occurred. The contents of FailedCpuList\r
+       can be examined to determine which APs did not complete the specified task\r
+       prior to the timeout.\r
+\r
+  @param[in]  This                    A pointer to the EFI_MP_SERVICES_PROTOCOL\r
+                                      instance.\r
+  @param[in]  Procedure               A pointer to the function to be run on\r
+                                      enabled APs of the system. See type\r
+                                      EFI_AP_PROCEDURE.\r
+  @param[in]  SingleThread            If TRUE, then all the enabled APs execute\r
+                                      the function specified by Procedure one by\r
+                                      one, in ascending order of processor handle\r
+                                      number.  If FALSE, then all the enabled APs\r
+                                      execute the function specified by Procedure\r
+                                      simultaneously.\r
+  @param[in]  WaitEvent               The event created by the caller with CreateEvent()\r
+                                      service.  If it is NULL, then execute in\r
+                                      blocking mode. BSP waits until all APs finish\r
+                                      or TimeoutInMicroseconds expires.  If it's\r
+                                      not NULL, then execute in non-blocking mode.\r
+                                      BSP requests the function specified by\r
+                                      Procedure to be started on all the enabled\r
+                                      APs, and go on executing immediately. If\r
+                                      all return from Procedure, or TimeoutInMicroseconds\r
+                                      expires, this event is signaled. The BSP\r
+                                      can use the CheckEvent() or WaitForEvent()\r
+                                      services to check the state of event.  Type\r
+                                      EFI_EVENT is defined in CreateEvent() in\r
+                                      the Unified Extensible Firmware Interface\r
+                                      Specification.\r
+  @param[in]  TimeoutInMicroseconds   Indicates the time limit in microseconds for\r
+                                      APs to return from Procedure, either for\r
+                                      blocking or non-blocking mode. Zero means\r
+                                      infinity.  If the timeout expires before\r
+                                      all APs return from Procedure, then Procedure\r
+                                      on the failed APs is terminated. All enabled\r
+                                      APs are available for next function assigned\r
+                                      by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()\r
+                                      or EFI_MP_SERVICES_PROTOCOL.StartupThisAP().\r
+                                      If the timeout expires in blocking mode,\r
+                                      BSP returns EFI_TIMEOUT.  If the timeout\r
+                                      expires in non-blocking mode, WaitEvent\r
+                                      is signaled with SignalEvent().\r
+  @param[in]  ProcedureArgument       The parameter passed into Procedure for\r
+                                      all APs.\r
+  @param[out] FailedCpuList           If NULL, this parameter is ignored. Otherwise,\r
+                                      if all APs finish successfully, then its\r
+                                      content is set to NULL. If not all APs\r
+                                      finish before timeout expires, then its\r
+                                      content is set to address of the buffer\r
+                                      holding handle numbers of the failed APs.\r
+                                      The buffer is allocated by MP Service Protocol,\r
+                                      and it's the caller's responsibility to\r
+                                      free the buffer with FreePool() service.\r
+                                      In blocking mode, it is ready for consumption\r
+                                      when the call returns. In non-blocking mode,\r
+                                      it is ready when WaitEvent is signaled.  The\r
+                                      list of failed CPU is terminated by\r
+                                      END_OF_CPU_LIST.\r
+\r
+  @retval EFI_SUCCESS             In blocking mode, all APs have finished before\r
+                                  the timeout expired.\r
+  @retval EFI_SUCCESS             In non-blocking mode, function has been dispatched\r
+                                  to all enabled APs.\r
+  @retval EFI_UNSUPPORTED         A non-blocking mode request was made after the\r
+                                  UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was\r
+                                  signaled.\r
+  @retval EFI_DEVICE_ERROR        Caller processor is AP.\r
+  @retval EFI_NOT_STARTED         No enabled APs exist in the system.\r
+  @retval EFI_NOT_READY           Any enabled APs are busy.\r
+  @retval EFI_TIMEOUT             In blocking mode, the timeout expired before\r
+                                  all enabled APs have finished.\r
+  @retval EFI_INVALID_PARAMETER   Procedure is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+StartupAllAPs (\r
+  IN  EFI_MP_SERVICES_PROTOCOL  *This,\r
+  IN  EFI_AP_PROCEDURE          Procedure,\r
+  IN  BOOLEAN                   SingleThread,\r
+  IN  EFI_EVENT                 WaitEvent               OPTIONAL,\r
+  IN  UINTN                     TimeoutInMicroseconds,\r
+  IN  VOID                      *ProcedureArgument      OPTIONAL,\r
+  OUT UINTN                     **FailedCpuList         OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  CPU_DATA_BLOCK        *CpuData;\r
+  UINTN                 Number;\r
+  CPU_STATE             APInitialState;\r
+\r
+  CpuData = NULL;\r
+\r
+  if (FailedCpuList != NULL) {\r
+    *FailedCpuList = NULL;\r
+  }\r
+\r
+  if (!IsBSP ()) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  if (mMpSystemData.NumberOfProcessors == 1) {\r
+    return EFI_NOT_STARTED;\r
+  }\r
+\r
+  if (Procedure == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  for (Number = 0; Number < mMpSystemData.NumberOfProcessors; Number++) {\r
+    CpuData = &mMpSystemData.CpuDatas[Number];\r
+    if (TestCpuStatusFlag (CpuData, PROCESSOR_AS_BSP_BIT)) {\r
+      //\r
+      // Skip BSP\r
+      //\r
+      continue;\r
+    }\r
+\r
+    if (!TestCpuStatusFlag (CpuData, PROCESSOR_ENABLED_BIT)) {\r
+      //\r
+      // Skip Disabled processors\r
+      //\r
+      continue;\r
+    }\r
+\r
+    if (GetApState (CpuData) != CpuStateIdle) {\r
+      return EFI_NOT_READY;\r
+    }\r
+  }\r
+\r
+  mMpSystemData.Procedure         = Procedure;\r
+  mMpSystemData.ProcedureArgument = ProcedureArgument;\r
+  mMpSystemData.WaitEvent         = WaitEvent;\r
+  mMpSystemData.Timeout           = TimeoutInMicroseconds;\r
+  mMpSystemData.TimeoutActive     = !!(TimeoutInMicroseconds);\r
+  mMpSystemData.FinishCount       = 0;\r
+  mMpSystemData.StartCount        = 0;\r
+  mMpSystemData.SingleThread      = SingleThread;\r
+  mMpSystemData.FailedList        = FailedCpuList;\r
+  mMpSystemData.FailedListIndex   = 0;\r
+  APInitialState                  = CpuStateReady;\r
+\r
+  for (Number = 0; Number < mMpSystemData.NumberOfProcessors; Number++) {\r
+    CpuData = &mMpSystemData.CpuDatas[Number];\r
+    if (TestCpuStatusFlag (CpuData, PROCESSOR_AS_BSP_BIT)) {\r
+      //\r
+      // Skip BSP\r
+      //\r
+      continue;\r
+    }\r
+\r
+    if (!TestCpuStatusFlag (CpuData, PROCESSOR_ENABLED_BIT)) {\r
+      //\r
+      // Skip Disabled processors\r
+      //\r
+      continue;\r
+    }\r
+\r
+    //\r
+    // Get APs prepared, and put failing APs into FailedCpuList\r
+    // if "SingleThread", only 1 AP will put to ready state, other AP will be put to ready\r
+    // state 1 by 1, until the previous 1 finished its task\r
+    // if not "SingleThread", all APs are put to ready state from the beginning\r
+    //\r
+    if (GetApState (CpuData) == CpuStateIdle) {\r
+      mMpSystemData.StartCount++;\r
+\r
+      SetApState (CpuData, APInitialState);\r
+\r
+      if (APInitialState == CpuStateReady) {\r
+        SetApProcedure (CpuData, Procedure, ProcedureArgument);\r
+      }\r
+\r
+      if (SingleThread) {\r
+        APInitialState = CpuStateBlocked;\r
+      }\r
+    }\r
+  }\r
+\r
+  if (WaitEvent != NULL) {\r
+    Status = gBS->SetTimer (\r
+                    mMpSystemData.CheckAllAPsEvent,\r
+                    TimerPeriodic,\r
+                    EFI_TIMER_PERIOD_MICROSECONDS (100)\r
+                    );\r
+    return Status;\r
+  }\r
+\r
+  while (TRUE) {\r
+    CheckAndUpdateAllAPsToIdleState ();\r
+    if (mMpSystemData.FinishCount == mMpSystemData.StartCount) {\r
+      Status = EFI_SUCCESS;\r
+      goto Done;\r
+    }\r
+\r
+    //\r
+    // task timeout\r
+    //\r
+    if (mMpSystemData.TimeoutActive && mMpSystemData.Timeout < 0) {\r
+      ResetAllFailedAPs();\r
+      Status = EFI_TIMEOUT;\r
+      goto Done;\r
+    }\r
+\r
+    gBS->Stall (gPollInterval);\r
+    mMpSystemData.Timeout -= gPollInterval;\r
+  }\r
+\r
+Done:\r
+\r
+  return Status;\r
+}\r
+\r
 /**\r
   This service lets the caller get one enabled AP to execute a caller-provided\r
   function. The caller can request the BSP to either wait for the completion\r
@@ -746,6 +1121,56 @@ out:
   }\r
 }\r
 \r
+/**\r
+  Checks APs' status periodically.\r
+\r
+  This function is triggerred by timer perodically to check the\r
+  state of APs for StartupAllAPs() executed in non-blocking mode.\r
+\r
+  @param  Event    Event triggered.\r
+  @param  Context  Parameter passed with the event.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CheckAllAPsStatus (\r
+  IN  EFI_EVENT        Event,\r
+  IN  VOID             *Context\r
+  )\r
+{\r
+  if (mMpSystemData.TimeoutActive) {\r
+    mMpSystemData.Timeout -= gPollInterval;\r
+  }\r
+\r
+  CheckAndUpdateAllAPsToIdleState ();\r
+\r
+  //\r
+  // task timeout\r
+  //\r
+  if (mMpSystemData.TimeoutActive && mMpSystemData.Timeout < 0) {\r
+    ResetAllFailedAPs();\r
+    //\r
+    // force exit\r
+    //\r
+    mMpSystemData.FinishCount = mMpSystemData.StartCount;\r
+  }\r
+\r
+  if (mMpSystemData.FinishCount != mMpSystemData.StartCount) {\r
+    return;\r
+  }\r
+\r
+  gBS->SetTimer (\r
+         mMpSystemData.CheckAllAPsEvent,\r
+         TimerCancel,\r
+         0\r
+         );\r
+\r
+  if (mMpSystemData.WaitEvent) {\r
+    gBS->SignalEvent (mMpSystemData.WaitEvent);\r
+    mMpSystemData.WaitEvent = NULL;\r
+  }\r
+}\r
+\r
 /**\r
   Application Processor C code entry point.\r
 \r
@@ -831,6 +1256,15 @@ InitMpSystemData (
   mMpSystemData.CpuDatas = AllocateZeroPool (sizeof (CPU_DATA_BLOCK) * gMaxLogicalProcessorNumber);\r
   ASSERT(mMpSystemData.CpuDatas != NULL);\r
 \r
+  Status = gBS->CreateEvent (\r
+                  EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
+                  TPL_CALLBACK,\r
+                  CheckAllAPsStatus,\r
+                  NULL,\r
+                  &mMpSystemData.CheckAllAPsEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   for (ProcessorNumber = 0; ProcessorNumber < gMaxLogicalProcessorNumber; ProcessorNumber++) {\r
     CpuData = &mMpSystemData.CpuDatas[ProcessorNumber];\r
     Status = gBS->CreateEvent (\r
index 6d80f053b4e900055f0fca4c46a823cc6b20eacc..2b3b9b23d4c28bdf50289f902b66cc2f55814088 100644 (file)
@@ -112,6 +112,18 @@ typedef struct {
   CPU_DATA_BLOCK              *CpuDatas;\r
   UINTN                       NumberOfProcessors;\r
   UINTN                       NumberOfEnabledProcessors;\r
+\r
+  EFI_AP_PROCEDURE            Procedure;\r
+  VOID                        *ProcedureArgument;\r
+  UINTN                       StartCount;\r
+  UINTN                       FinishCount;\r
+  BOOLEAN                     SingleThread;\r
+  UINTN                       **FailedList;\r
+  UINTN                       FailedListIndex;\r
+  INTN                        Timeout;\r
+  EFI_EVENT                   WaitEvent;\r
+  BOOLEAN                     TimeoutActive;\r
+  EFI_EVENT                   CheckAllAPsEvent;\r
 } MP_SYSTEM_DATA;\r
 \r
 /**\r
@@ -207,6 +219,154 @@ GetProcessorInfo (
   OUT EFI_PROCESSOR_INFORMATION  *ProcessorInfoBuffer\r
   );\r
 \r
+/**\r
+  This service executes a caller provided function on all enabled APs. APs can\r
+  run either simultaneously or one at a time in sequence. This service supports\r
+  both blocking and non-blocking requests. The non-blocking requests use EFI\r
+  events so the BSP can detect when the APs have finished. This service may only\r
+  be called from the BSP.\r
+\r
+  This function is used to dispatch all the enabled APs to the function specified\r
+  by Procedure.  If any enabled AP is busy, then EFI_NOT_READY is returned\r
+  immediately and Procedure is not started on any AP.\r
+\r
+  If SingleThread is TRUE, all the enabled APs execute the function specified by\r
+  Procedure one by one, in ascending order of processor handle number. Otherwise,\r
+  all the enabled APs execute the function specified by Procedure simultaneously.\r
+\r
+  If WaitEvent is NULL, execution is in blocking mode. The BSP waits until all\r
+  APs finish or TimeoutInMicroseconds expires. Otherwise, execution is in non-blocking\r
+  mode, and the BSP returns from this service without waiting for APs. If a\r
+  non-blocking mode is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT\r
+  is signaled, then EFI_UNSUPPORTED must be returned.\r
+\r
+  If the timeout specified by TimeoutInMicroseconds expires before all APs return\r
+  from Procedure, then Procedure on the failed APs is terminated. All enabled APs\r
+  are always available for further calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()\r
+  and EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). If FailedCpuList is not NULL, its\r
+  content points to the list of processor handle numbers in which Procedure was\r
+  terminated.\r
+\r
+  Note: It is the responsibility of the consumer of the EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()\r
+  to make sure that the nature of the code that is executed on the BSP and the\r
+  dispatched APs is well controlled. The MP Services Protocol does not guarantee\r
+  that the Procedure function is MP-safe. Hence, the tasks that can be run in\r
+  parallel are limited to certain independent tasks and well-controlled exclusive\r
+  code. EFI services and protocols may not be called by APs unless otherwise\r
+  specified.\r
+\r
+  In blocking execution mode, BSP waits until all APs finish or\r
+  TimeoutInMicroseconds expires.\r
+\r
+  In non-blocking execution mode, BSP is freed to return to the caller and then\r
+  proceed to the next task without having to wait for APs. The following\r
+  sequence needs to occur in a non-blocking execution mode:\r
+\r
+    -# The caller that intends to use this MP Services Protocol in non-blocking\r
+       mode creates WaitEvent by calling the EFI CreateEvent() service.  The caller\r
+       invokes EFI_MP_SERVICES_PROTOCOL.StartupAllAPs(). If the parameter WaitEvent\r
+       is not NULL, then StartupAllAPs() executes in non-blocking mode. It requests\r
+       the function specified by Procedure to be started on all the enabled APs,\r
+       and releases the BSP to continue with other tasks.\r
+    -# The caller can use the CheckEvent() and WaitForEvent() services to check\r
+       the state of the WaitEvent created in step 1.\r
+    -# When the APs complete their task or TimeoutInMicroSecondss expires, the MP\r
+       Service signals WaitEvent by calling the EFI SignalEvent() function. If\r
+       FailedCpuList is not NULL, its content is available when WaitEvent is\r
+       signaled. If all APs returned from Procedure prior to the timeout, then\r
+       FailedCpuList is set to NULL. If not all APs return from Procedure before\r
+       the timeout, then FailedCpuList is filled in with the list of the failed\r
+       APs. The buffer is allocated by MP Service Protocol using AllocatePool().\r
+       It is the caller's responsibility to free the buffer with FreePool() service.\r
+    -# This invocation of SignalEvent() function informs the caller that invoked\r
+       EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() that either all the APs completed\r
+       the specified task or a timeout occurred. The contents of FailedCpuList\r
+       can be examined to determine which APs did not complete the specified task\r
+       prior to the timeout.\r
+\r
+  @param[in]  This                    A pointer to the EFI_MP_SERVICES_PROTOCOL\r
+                                      instance.\r
+  @param[in]  Procedure               A pointer to the function to be run on\r
+                                      enabled APs of the system. See type\r
+                                      EFI_AP_PROCEDURE.\r
+  @param[in]  SingleThread            If TRUE, then all the enabled APs execute\r
+                                      the function specified by Procedure one by\r
+                                      one, in ascending order of processor handle\r
+                                      number.  If FALSE, then all the enabled APs\r
+                                      execute the function specified by Procedure\r
+                                      simultaneously.\r
+  @param[in]  WaitEvent               The event created by the caller with CreateEvent()\r
+                                      service.  If it is NULL, then execute in\r
+                                      blocking mode. BSP waits until all APs finish\r
+                                      or TimeoutInMicroseconds expires.  If it's\r
+                                      not NULL, then execute in non-blocking mode.\r
+                                      BSP requests the function specified by\r
+                                      Procedure to be started on all the enabled\r
+                                      APs, and go on executing immediately. If\r
+                                      all return from Procedure, or TimeoutInMicroseconds\r
+                                      expires, this event is signaled. The BSP\r
+                                      can use the CheckEvent() or WaitForEvent()\r
+                                      services to check the state of event.  Type\r
+                                      EFI_EVENT is defined in CreateEvent() in\r
+                                      the Unified Extensible Firmware Interface\r
+                                      Specification.\r
+  @param[in]  TimeoutInMicroseconds   Indicates the time limit in microseconds for\r
+                                      APs to return from Procedure, either for\r
+                                      blocking or non-blocking mode. Zero means\r
+                                      infinity.  If the timeout expires before\r
+                                      all APs return from Procedure, then Procedure\r
+                                      on the failed APs is terminated. All enabled\r
+                                      APs are available for next function assigned\r
+                                      by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()\r
+                                      or EFI_MP_SERVICES_PROTOCOL.StartupThisAP().\r
+                                      If the timeout expires in blocking mode,\r
+                                      BSP returns EFI_TIMEOUT.  If the timeout\r
+                                      expires in non-blocking mode, WaitEvent\r
+                                      is signaled with SignalEvent().\r
+  @param[in]  ProcedureArgument       The parameter passed into Procedure for\r
+                                      all APs.\r
+  @param[out] FailedCpuList           If NULL, this parameter is ignored. Otherwise,\r
+                                      if all APs finish successfully, then its\r
+                                      content is set to NULL. If not all APs\r
+                                      finish before timeout expires, then its\r
+                                      content is set to address of the buffer\r
+                                      holding handle numbers of the failed APs.\r
+                                      The buffer is allocated by MP Service Protocol,\r
+                                      and it's the caller's responsibility to\r
+                                      free the buffer with FreePool() service.\r
+                                      In blocking mode, it is ready for consumption\r
+                                      when the call returns. In non-blocking mode,\r
+                                      it is ready when WaitEvent is signaled.  The\r
+                                      list of failed CPU is terminated by\r
+                                      END_OF_CPU_LIST.\r
+\r
+  @retval EFI_SUCCESS             In blocking mode, all APs have finished before\r
+                                  the timeout expired.\r
+  @retval EFI_SUCCESS             In non-blocking mode, function has been dispatched\r
+                                  to all enabled APs.\r
+  @retval EFI_UNSUPPORTED         A non-blocking mode request was made after the\r
+                                  UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was\r
+                                  signaled.\r
+  @retval EFI_DEVICE_ERROR        Caller processor is AP.\r
+  @retval EFI_NOT_STARTED         No enabled APs exist in the system.\r
+  @retval EFI_NOT_READY           Any enabled APs are busy.\r
+  @retval EFI_TIMEOUT             In blocking mode, the timeout expired before\r
+                                  all enabled APs have finished.\r
+  @retval EFI_INVALID_PARAMETER   Procedure is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+StartupAllAPs (\r
+  IN  EFI_MP_SERVICES_PROTOCOL  *This,\r
+  IN  EFI_AP_PROCEDURE          Procedure,\r
+  IN  BOOLEAN                   SingleThread,\r
+  IN  EFI_EVENT                 WaitEvent               OPTIONAL,\r
+  IN  UINTN                     TimeoutInMicroseconds,\r
+  IN  VOID                      *ProcedureArgument      OPTIONAL,\r
+  OUT UINTN                     **FailedCpuList         OPTIONAL\r
+  );\r
+\r
 /**\r
   This service lets the caller get one enabled AP to execute a caller-provided\r
   function. The caller can request the BSP to either wait for the completion\r