]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg/SerialDxe: Do not block UART when no data is available on the port
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 2 May 2012 20:04:42 +0000 (20:04 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 2 May 2012 20:04:42 +0000 (20:04 +0000)
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13255 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c
ArmPlatformPkg/Include/Drivers/PL011Uart.h
ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.c
EmbeddedPkg/SerialDxe/SerialIo.c

index ca487ec98c509b48f3e72e1571c125f4c56c8e11..d728121b299fb156f42b935e538267d9ae0a58bd 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
@@ -134,7 +133,7 @@ PL011UartInitializePort (
   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
@@ -305,14 +304,14 @@ PL011UartWrite (
   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
@@ -335,12 +334,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
index 518dab587fa536e1412c55e06e6861986c35f4b8..354f11103247c62101343968376fd159454ad9c7 100644 (file)
@@ -94,7 +94,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
index e3d8aabbc767a3d954e8010635aeb62b13c3cfb4..2395ffd6c8aa05ed28cee68dfd227b82eec57c96 100644 (file)
@@ -14,7 +14,7 @@
 
 **/
 
-#include <Include/Base.h>
+#include <Base.h>
 
 #include <Library/IoLib.h>
 #include <Library/PcdLib.h>
@@ -40,7 +40,6 @@ SerialPortInitialize (
       (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));
index 59d904c192a583f1cd4fe2e72cb0e4bcfb2b5bb0..ef4e6a1910f42a94ccdb80d53f583a4886c8a143 100644 (file)
@@ -167,7 +167,7 @@ SerialWrite (
 }\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
@@ -189,15 +189,16 @@ SerialRead (
   )\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