\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
// Baud Rate\r
//\r
if (PcdGet32(PL011UartInteger) != 0) {\r
- // Integer and Factional part must be different of 0\r
- ASSERT(PcdGet32(PL011UartFractional) != 0);\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
+ UINT8* CONST Final = &Buffer[NumberOfBytes];\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
+ while (Buffer < Final) {\r
+ // Wait until UART able to accept another char\r
+ while ((MmioRead32 (UartBase + UARTFR) & UART_TX_FULL_FLAG_MASK));\r
+ \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