/* This function place APs in Mwait or Run loop. */
VOID PlaceAPInMwaitLoopOrRunLoop(IN UINT8 ApLoopMode, IN volatile UINT32 *ApStartupSignalBuffer, IN UINT8 ApTargetCState)
/* This function place APs in Mwait or Run loop. */
VOID PlaceAPInMwaitLoopOrRunLoop(IN UINT8 ApLoopMode, IN volatile UINT32 *ApStartupSignalBuffer, IN UINT8 ApTargetCState)
{
  while (TRUE) {
    DisableInterrupts ();
    if (ApLoopMode == ApInMwaitLoop) {
      AsmMonitor ((UINTN)ApStartupSignalBuffer, 0, 0);
      if ((*ApStartupSignalBuffer != WAKEUP_AP_SIGNAL) && (*ApStartupSignalBuffer != MP_HAND_OFF_SIGNAL)) {
        AsmMwait (ApTargetCState << 4, 0);
      }
    } else if (ApLoopMode == ApInRunLoop) {
      CpuPause ();
    } else {
      ASSERT (FALSE);
    }
    if ((*ApStartupSignalBuffer == WAKEUP_AP_SIGNAL) || (*ApStartupSignalBuffer == MP_HAND_OFF_SIGNAL)) {
      break;
    }
  }
}