}\r
\r
\r
+/**\r
+ Worker function to let the caller get one enabled AP to execute a caller-provided\r
+ function.\r
+\r
+ @param[in] Procedure A pointer to the function to be run on\r
+ enabled APs of the system.\r
+ @param[in] ProcessorNumber The handle number of the AP.\r
+ @param[in] WaitEvent The event created by the caller with CreateEvent()\r
+ service.\r
+ @param[in] TimeoutInMicrosecsond Indicates the time limit in microseconds for\r
+ APs to return from Procedure, either for\r
+ blocking or non-blocking mode.\r
+ @param[in] ProcedureArgument The parameter passed into Procedure for\r
+ all APs.\r
+ @param[out] Finished If AP returns from Procedure before the\r
+ timeout expires, its content is set to TRUE.\r
+ Otherwise, the value is set to FALSE.\r
+\r
+ @retval EFI_SUCCESS In blocking mode, specified AP finished before\r
+ the timeout expires.\r
+ @retval others Failed to Startup AP.\r
+\r
+**/\r
+EFI_STATUS\r
+StartupThisAPWorker (\r
+ IN EFI_AP_PROCEDURE Procedure,\r
+ IN UINTN ProcessorNumber,\r
+ IN EFI_EVENT WaitEvent OPTIONAL,\r
+ IN UINTN TimeoutInMicroseconds,\r
+ IN VOID *ProcedureArgument OPTIONAL,\r
+ OUT BOOLEAN *Finished OPTIONAL\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ CPU_MP_DATA *CpuMpData;\r
+ CPU_AP_DATA *CpuData;\r
+ UINTN CallerNumber;\r
+\r
+ CpuMpData = GetCpuMpData ();\r
+\r
+ if (Finished != NULL) {\r
+ *Finished = FALSE;\r
+ }\r
+\r
+ //\r
+ // Check whether caller processor is BSP\r
+ //\r
+ MpInitLibWhoAmI (&CallerNumber);\r
+ if (CallerNumber != CpuMpData->BspNumber) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ //\r
+ // Check whether processor with the handle specified by ProcessorNumber exists\r
+ //\r
+ if (ProcessorNumber >= CpuMpData->CpuCount) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+\r
+ //\r
+ // Check whether specified processor is BSP\r
+ //\r
+ if (ProcessorNumber == CpuMpData->BspNumber) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // Check parameter Procedure\r
+ //\r
+ if (Procedure == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // Update AP state\r
+ //\r
+ CheckAndUpdateApsStatus ();\r
+\r
+ //\r
+ // Check whether specified AP is disabled\r
+ //\r
+ if (GetApState (&CpuMpData->CpuData[ProcessorNumber]) == CpuStateDisabled) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // If WaitEvent is not NULL, execute in non-blocking mode.\r
+ // BSP saves data for CheckAPsStatus(), and returns EFI_SUCCESS.\r
+ // CheckAPsStatus() will check completion and timeout periodically.\r
+ //\r
+ CpuData = &CpuMpData->CpuData[ProcessorNumber];\r
+ CpuData->WaitEvent = WaitEvent;\r
+ CpuData->Finished = Finished;\r
+ CpuData->ExpectedTime = CalculateTimeout (TimeoutInMicroseconds, &CpuData->CurrentTime);\r
+ CpuData->TotalTime = 0;\r
+\r
+ WakeUpAP (CpuMpData, FALSE, ProcessorNumber, Procedure, ProcedureArgument);\r
+\r
+ //\r
+ // If WaitEvent is NULL, execute in blocking mode.\r
+ // BSP checks AP's state until it finishes or TimeoutInMicrosecsond expires.\r
+ //\r
+ Status = EFI_SUCCESS;\r
+ if (WaitEvent == NULL) {\r
+ do {\r
+ Status = CheckThisAP (ProcessorNumber);\r
+ } while (Status == EFI_NOT_READY);\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
/**\r
Get pointer to CPU MP Data structure from GUIDed HOB.\r
\r
IN CPU_MP_DATA *CpuMpData\r
);\r
\r
+/**\r
+ Worker function to let the caller get one enabled AP to execute a caller-provided\r
+ function.\r
+\r
+ @param[in] Procedure A pointer to the function to be run on\r
+ enabled APs of the system.\r
+ @param[in] ProcessorNumber The handle number of the AP.\r
+ @param[in] WaitEvent The event created by the caller with CreateEvent()\r
+ service.\r
+ @param[in] TimeoutInMicrosecsond Indicates the time limit in microseconds for\r
+ APs to return from Procedure, either for\r
+ blocking or non-blocking mode.\r
+ @param[in] ProcedureArgument The parameter passed into Procedure for\r
+ all APs.\r
+ @param[out] Finished If AP returns from Procedure before the\r
+ timeout expires, its content is set to TRUE.\r
+ Otherwise, the value is set to FALSE.\r
+\r
+ @retval EFI_SUCCESS In blocking mode, specified AP finished before\r
+ the timeout expires.\r
+ @retval others Failed to Startup AP.\r
+\r
+**/\r
+EFI_STATUS\r
+StartupThisAPWorker (\r
+ IN EFI_AP_PROCEDURE Procedure,\r
+ IN UINTN ProcessorNumber,\r
+ IN EFI_EVENT WaitEvent OPTIONAL,\r
+ IN UINTN TimeoutInMicroseconds,\r
+ IN VOID *ProcedureArgument OPTIONAL,\r
+ OUT BOOLEAN *Finished OPTIONAL\r
+ );\r
+\r
/**\r
Worker function to switch the requested AP to be the BSP from that point onward.\r
\r