/* I/O work flow to wait input buffer empty in given time. */
EFI_STATUS WaitInputEmpty(IN UINTN Timeout)
/* I/O work flow to wait input buffer empty in given time. */
EFI_STATUS WaitInputEmpty(IN UINTN Timeout)
{
  UINTN  Delay;
  UINT8  Data;
  Delay = Timeout / 50;
  do {
    Data = IoRead8 (KBC_CMD_STS_PORT);
    if ((Data & KBC_INPB) == 0) {
      break;
    }
    gBS->Stall (50);
    Delay--;
  } while (Delay != 0);
  if (Delay == 0) {
    return EFI_TIMEOUT;
  }
  return EFI_SUCCESS;
}