/* This function checks whether the specified AP has finished the task assigned by StartupThisAP(), and whether timeout expires. */
EFI_STATUS CheckThisAP(IN UINTN ProcessorNumber)
/* This function checks whether the specified AP has finished the task assigned by StartupThisAP(), and whether timeout expires. */
EFI_STATUS CheckThisAP(IN UINTN ProcessorNumber)
{
  CPU_MP_DATA  *CpuMpData;
  CPU_AP_DATA  *CpuData;
  CpuMpData = GetCpuMpData ();
  CpuData   = &CpuMpData->CpuData[ProcessorNumber];
  if (GetApState (CpuData) == CpuStateFinished) {
    if (CpuData->Finished != NULL) {
      *(CpuData->Finished) = TRUE;
    }
    SetApState (CpuData, CpuStateIdle);
    return EFI_SUCCESS;
  } else {
    if (CheckTimeout (&CpuData->CurrentTime, &CpuData->TotalTime, CpuData->ExpectedTime)) {
      if (CpuData->Finished != NULL) {
        *(CpuData->Finished) = FALSE;
      }
      ResetProcessorToIdleState (ProcessorNumber);
      return EFI_TIMEOUT;
    }
  }
  return EFI_NOT_READY;
}