/* Check if the env is ready for execute specified TRB. */
EFI_STATUS SdPeimCheckTrbEnv(IN UINTN Bar, IN SD_TRB *Trb)
/* Check if the env is ready for execute specified TRB. */
EFI_STATUS SdPeimCheckTrbEnv(IN UINTN Bar, IN SD_TRB *Trb)
{
  EFI_STATUS         Status;
  SD_COMMAND_PACKET  *Packet;
  UINT32             PresentState;
  Packet = Trb->Packet;
  if ((Packet->SdCmdBlk->CommandType == SdCommandTypeAdtc) ||
      (Packet->SdCmdBlk->ResponseType == SdResponseTypeR1b) ||
      (Packet->SdCmdBlk->ResponseType == SdResponseTypeR5b))
  {
    PresentState = BIT0 | BIT1;
  } else {
    PresentState = BIT0;
  }
  Status = SdPeimHcCheckMmioSet (
             Bar + SD_HC_PRESENT_STATE,
             sizeof (PresentState),
             PresentState,
             0
             );
  return Status;
}