]> 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 fa4e3aad362651fc3b27a8bf2dd7df64da80558a..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
@@ -454,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
@@ -1125,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
@@ -1206,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
@@ -1219,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
@@ -1250,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
@@ -1269,7 +1275,7 @@ Returns:
 \r
   gBS->RestoreTPL (Tpl);\r
 \r
-  return EFI_SUCCESS;\r
+  return Status;\r
 }\r
 \r
 EFI_STATUS\r