/* Read data via IsaIo protocol with given number. */
EFI_STATUS PS2MouseRead(OUT UINT8 *Buffer, IN OUT UINTN *BufSize, IN UINTN State)
/* Read data via IsaIo protocol with given number. */
EFI_STATUS PS2MouseRead(OUT UINT8 *Buffer, IN OUT UINTN *BufSize, IN UINTN State)
{
  EFI_STATUS  Status;
  UINTN       BytesRead;
  Status = EFI_SUCCESS;
  if (State == PS2_READ_BYTE_ONE) {
    Status = CheckForInput ();
    if (EFI_ERROR (Status)) {
      return Status;
    }
  }
  for (BytesRead = 0; BytesRead < *BufSize; BytesRead++) {
    Status = WaitOutputFull (TIMEOUT);
    if (EFI_ERROR (Status)) {
      break;
    }
    Buffer[BytesRead] = IoRead8 (KBC_DATA_PORT);
  }
  if ((BytesRead == 0) || (BytesRead != *BufSize)) {
    Status = EFI_NOT_FOUND;
  }
  *BufSize = BytesRead;
  return Status;
}