]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UnixPkg/UnixSerialIoDxe/UnixSerialIo.c
Integrate patch from Andrew Fish to make it run on OS X.
[mirror_edk2.git] / UnixPkg / UnixSerialIoDxe / UnixSerialIo.c
index 9f550f25c0ed23ac296c23e3f029f886c8224e05..edbfd0ad1353bfb715bea6e085946292d9b775cb 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+Copyright (c) 2006 - 2009, Intel Corporation\r
 All rights reserved. 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
@@ -46,7 +46,6 @@ Abstract:
 --*/\r
 \r
 #include "UnixSerialIo.h"\r
-#include <termio.h>\r
 \r
 EFI_DRIVER_BINDING_PROTOCOL gUnixSerialIoDriverBinding = {\r
   UnixSerialIoDriverBindingSupported,\r
@@ -57,7 +56,6 @@ EFI_DRIVER_BINDING_PROTOCOL gUnixSerialIoDriverBinding = {
   NULL\r
 };\r
 \r
-STATIC\r
 UINTN\r
 ConvertBaud2Unix (\r
   UINT64 BaudRate\r
@@ -133,7 +131,6 @@ ConvertBaud2Unix (
   return -1;\r
 }\r
 \r
-STATIC\r
 UINTN\r
 ConvertByteSize2Unix (\r
   UINT8 DataBit\r
@@ -154,7 +151,6 @@ ConvertByteSize2Unix (
   return -1;\r
 }\r
 \r
-STATIC\r
 VOID\r
 ConvertParity2Unix (\r
   struct termios    *Options,\r
@@ -184,7 +180,6 @@ ConvertParity2Unix (
   }\r
 }\r
 \r
-STATIC \r
 VOID\r
 ConvertStopBit2Unix (\r
   struct termios      *Options,\r
@@ -458,7 +453,7 @@ Returns:
   UnixHandle = UnixIo->UnixThunk->Open (AsciiDevName, O_RDWR | O_NOCTTY, 0);\r
   \r
   if (UnixHandle == -1) {\r
-    DEBUG ((EFI_D_INFO, "Faile to open serial device, %s!\r\n", UnixIo->EnvString ));\r
+    DEBUG ((EFI_D_INFO, "Failed to open serial device, %s!\r\n", UnixIo->EnvString ));\r
     UnixIo->UnixThunk->Perror (AsciiDevName);\r
     Status = EFI_DEVICE_ERROR;\r
     goto Error;\r
@@ -1129,6 +1124,7 @@ Returns:
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
+  Bits = 0;\r
   if ((Status & TIOCM_CTS) == TIOCM_CTS) {\r
     Bits |= EFI_SERIAL_CLEAR_TO_SEND;\r
   }\r
@@ -1210,6 +1206,7 @@ Returns:
 --*/\r
 {\r
   UNIX_SERIAL_IO_PRIVATE_DATA   *Private;\r
+  EFI_STATUS                    Status;\r
   UINT8                         *ByteBuffer;\r
   UINT32                        TotalBytesWritten;\r
   UINT32                        BytesToGo;\r
@@ -1223,6 +1220,7 @@ Returns:
   Private           = UNIX_SERIAL_IO_PRIVATE_DATA_FROM_THIS (This); \r
 \r
   ByteBuffer        = (UINT8 *) Buffer;\r
+  Status = EFI_SUCCESS;\r
   TotalBytesWritten = 0;\r
 \r
   if (Private->SoftwareLoopbackEnable || Private->HardwareLoopbackEnable) {\r
@@ -1254,6 +1252,10 @@ Returns:
                                            &ByteBuffer[TotalBytesWritten],\r
                                            BytesToGo\r
                                            );\r
+      if (BytesWritten == -1) {\r
+        Status = EFI_DEVICE_ERROR;\r
+        break;\r
+      }\r
 \r
       if (Private->HardwareFlowControl) {\r
         //\r
@@ -1273,7 +1275,7 @@ Returns:
 \r
   gBS->RestoreTPL (Tpl);\r
 \r
-  return EFI_SUCCESS;\r
+  return Status;\r
 }\r
 \r
 EFI_STATUS\r