/* This function gets the command execution status from device. BOT transfer is composed of three phases: Command, Data, and Status. This is the Status phase. */
EFI_STATUS BotStatusPhase(IN EFI_PEI_SERVICES **PeiServices, IN PEI_BOT_DEVICE *PeiBotDev, OUT UINT8 *TransferStatus, IN UINT16 Timeout)
/* This function gets the command execution status from device. BOT transfer is composed of three phases: Command, Data, and Status. This is the Status phase. */
EFI_STATUS BotStatusPhase(IN EFI_PEI_SERVICES **PeiServices, IN PEI_BOT_DEVICE *PeiBotDev, OUT UINT8 *TransferStatus, IN UINT16 Timeout)
{
  CSW             Csw;
  EFI_STATUS      Status;
  PEI_USB_IO_PPI  *UsbIoPpi;
  UINT8           EndpointAddr;
  UINTN           DataSize;
  UsbIoPpi = PeiBotDev->UsbIoPpi;
  ZeroMem (&Csw, sizeof (CSW));
  EndpointAddr = (PeiBotDev->BulkInEndpoint)->EndpointAddress;
  DataSize = sizeof (CSW);
  Status = UsbIoPpi->UsbBulkTransfer (
                       PeiServices,
                       UsbIoPpi,
                       EndpointAddr,
                       &Csw,
                       &DataSize,
                       Timeout
                       );
  if (EFI_ERROR (Status)) {
    return Status;
  }
  if (Csw.Signature == CSWSIG) {
    *TransferStatus = Csw.Status;
  } else {
    return EFI_DEVICE_ERROR;
  }
  return EFI_SUCCESS;
}