/* Retrieves current state of the USB host controller according to UEFI 2.0 spec. */
EFI_STATUS EFIAPI Uhci2GetState(IN EFI_USB2_HC_PROTOCOL *This, OUT EFI_USB_HC_STATE *State)
/* Retrieves current state of the USB host controller according to UEFI 2.0 spec. */
EFI_STATUS EFIAPI Uhci2GetState(IN EFI_USB2_HC_PROTOCOL *This, OUT EFI_USB_HC_STATE *State)
{
  USB_HC_DEV  *Uhc;
  UINT16      UsbSts;
  UINT16      UsbCmd;
  if (State == NULL) {
    return EFI_INVALID_PARAMETER;
  }
  Uhc = UHC_FROM_USB2_HC_PROTO (This);
  UsbCmd = UhciReadReg (Uhc->PciIo, USBCMD_OFFSET);
  UsbSts = UhciReadReg (Uhc->PciIo, USBSTS_OFFSET);
  if ((UsbCmd & USBCMD_EGSM) != 0 ) {
    *State = EfiUsbHcStateSuspend;
  } else if ((UsbSts & USBSTS_HCH) != 0) {
    *State = EfiUsbHcStateHalt;
  } else {
    *State = EfiUsbHcStateOperational;
  }
  return EFI_SUCCESS;
}