]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c
Check the input VaraibleName for db/dbx when appending variables with formatted as...
[mirror_edk2.git] / ArmPlatformPkg / Drivers / PL011Uart / PL011Uart.c
index ca487ec98c509b48f3e72e1571c125f4c56c8e11..2af207829d884dcbd448ac6fd3651d150133fde1 100644 (file)
@@ -3,7 +3,7 @@
 \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
@@ -34,7 +34,6 @@ PL011UartInitializePort (
   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
@@ -47,7 +46,7 @@ PL011UartInitializePort (
   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
@@ -122,7 +121,7 @@ PL011UartInitializePort (
   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
@@ -132,9 +131,6 @@ PL011UartInitializePort (
   // 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
@@ -305,14 +301,16 @@ PL011UartWrite (
   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
@@ -335,12 +333,12 @@ PL011UartRead (
 {\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