\r
Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
Copyright (c) 2011 - 2012, ARM Ltd. All rights reserved.<BR>\r
- \r
+\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
IN UINTN UartBase,\r
IN UINT64 BaudRate,\r
IN UINT32 ReceiveFifoDepth,\r
- IN UINT32 Timeout,\r
IN EFI_PARITY_TYPE Parity,\r
IN UINT8 DataBits,\r
IN EFI_STOP_BITS_TYPE StopBits\r
if (BaudRate == 0) {\r
return RETURN_INVALID_PARAMETER;\r
}\r
- \r
+\r
LineControl = 0;\r
\r
// The PL011 supports a buffer of either 1 or 32 chars. Therefore we can accept\r
default:\r
return RETURN_INVALID_PARAMETER;\r
}\r
- \r
+\r
// Don't send the LineControl value to the PL011 yet,\r
// wait until after the Baud Rate setting.\r
// This ensures we do not mess up the UART settings halfway through\r
if (PcdGet32(PL011UartInteger) != 0) {\r
// Integer and Factional part must be different of 0\r
ASSERT(PcdGet32(PL011UartFractional) != 0);\r
- \r
+\r
MmioWrite32 (UartBase + UARTIBRD, PcdGet32(PL011UartInteger));\r
MmioWrite32 (UartBase + UARTFBRD, PcdGet32(PL011UartFractional));\r
} else {\r
IN UINTN NumberOfBytes\r
)\r
{\r
- UINTN Count;\r
+ UINTN Count;\r
\r
- for (Count = 0; Count < NumberOfBytes; Count++, Buffer++) {\r
- while ((MmioRead32 (UartBase + UARTFR) & UART_TX_EMPTY_FLAG_MASK) == 0);\r
- MmioWrite8 (UartBase + UARTDR, *Buffer);\r
- }\r
+ for (Count = 0; Count < NumberOfBytes; Count++, Buffer++) {\r
+ while ((MmioRead32 (UartBase + UARTFR) & UART_TX_EMPTY_FLAG_MASK) == 0);\r
+ MmioWrite8 (UartBase + UARTDR, *Buffer);\r
+ }\r
\r
- return NumberOfBytes;\r
+ return NumberOfBytes;\r
}\r
\r
/**\r
{\r
UINTN Count;\r
\r
- for (Count = 0; Count < NumberOfBytes; Count++, Buffer++) {\r
- while ((MmioRead32 (UartBase + UARTFR) & UART_RX_EMPTY_FLAG_MASK) != 0);\r
- *Buffer = MmioRead8 (UartBase + UARTDR);\r
- }\r
+ for (Count = 0; Count < NumberOfBytes; Count++, Buffer++) {\r
+ while ((MmioRead32 (UartBase + UARTFR) & UART_RX_EMPTY_FLAG_MASK) != 0);\r
+ *Buffer = MmioRead8 (UartBase + UARTDR);\r
+ }\r
\r
- return NumberOfBytes;\r
+ return NumberOfBytes;\r
}\r
\r
/**\r
**/
-#include <Include/Base.h>
+#include <Base.h>
#include <Library/IoLib.h>
#include <Library/PcdLib.h>
(UINTN)PcdGet64 (PcdSerialRegisterBase),
(UINTN)PcdGet64 (PcdUartDefaultBaudRate),
0, // Use the default value for Fifo depth
- 0, // Use the default value for Timeout,
(EFI_PARITY_TYPE)PcdGet8 (PcdUartDefaultParity),
PcdGet8 (PcdUartDefaultDataBits),
(EFI_STOP_BITS_TYPE) PcdGet8 (PcdUartDefaultStopBits));
}\r
\r
/**\r
- Writes data to a serial device.\r
+ Reads data from a serial device.\r
\r
@param This Protocol instance pointer.\r
@param BufferSize On input, the size of the Buffer. On output, the amount of\r
)\r
{\r
UINTN Count = 0;\r
- \r
+\r
if (SerialPortPoll()) {\r
Count = SerialPortRead (Buffer, *BufferSize);\r
+ }\r
+\r
+ if (Count != *BufferSize) {\r
*BufferSize = Count;\r
- return (Count == 0) ? EFI_DEVICE_ERROR : EFI_SUCCESS;\r
+ return EFI_TIMEOUT;\r
}\r
- \r
- // No data to return\r
- *BufferSize = 0;\r
+\r
return EFI_SUCCESS;\r
}\r
\r