/* Reads data from a serial device into a buffer. */
UINTN EFIAPI SerialPortRead(OUT UINT8 *Buffer, IN UINTN NumberOfBytes)
/* Reads data from a serial device into a buffer. */
UINTN EFIAPI SerialPortRead(OUT UINT8 *Buffer, IN UINTN NumberOfBytes)
{
  UINTN  Result;
  UINT8  Data;
  if (NULL == Buffer) {
    return 0;
  }
  Result = NumberOfBytes;
  while ((NumberOfBytes--) != 0) {
    do {
      Data = IoRead8 ((UINT16)gUartBase + LSR_OFFSET);
    } while ((Data & LSR_RXDA) == 0);
    *Buffer++ = IoRead8 ((UINT16)gUartBase);
  }
  return Result;
}