/* This function is used to analyze the Status Register at the condition that BSY is zero. if there is ERR bit set in the Status Register, then return error. */
EFI_STATUS EFIAPI CheckStatusRegister(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters)
/* This function is used to analyze the Status Register at the condition that BSY is zero. if there is ERR bit set in the Status Register, then return error. */
EFI_STATUS EFIAPI CheckStatusRegister(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters)
{
  UINT8  StatusRegister;
  ASSERT (PciIo != NULL);
  ASSERT (IdeRegisters != NULL);
  StatusRegister = IdeReadPortB (PciIo, IdeRegisters->CmdOrStatus);
  if ((StatusRegister & ATA_STSREG_BSY) == 0) {
    if ((StatusRegister & (ATA_STSREG_ERR | ATA_STSREG_DWF | ATA_STSREG_CORR)) == 0) {
      return EFI_SUCCESS;
    } else {
      return EFI_DEVICE_ERROR;
    }
  }
  return EFI_SUCCESS;
}