]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkUnixPkg/Sec/UnixThunk.c
Adding top-level Conf directory for next generation of EDK II build infrastructure...
[mirror_edk2.git] / EdkUnixPkg / Sec / UnixThunk.c
index 46b0e34c55d2df820d6814cfc52432d3f3f2ca6f..834498082dc160dac671ac8fbebbd7beac5db9b5 100644 (file)
@@ -1,44 +1,45 @@
-/*++\r
-\r
-Copyright (c) 2004 - 2006, 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
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  UnixThunk.c\r
-\r
-Abstract:\r
-\r
-  Since the SEC is the only program in our emulation we \r
-  must use a Tiano mechanism to export APIs to other modules.\r
-  This is the role of the EFI_UNIX_THUNK_PROTOCOL.\r
-\r
-  The mUnixThunkTable exists so that a change to EFI_UNIX_THUNK_PROTOCOL\r
-  will cause an error in initializing the array if all the member functions\r
-  are not added. It looks like adding a element to end and not initializing\r
-  it may cause the table to be initaliized with the members at the end being\r
-  set to zero. This is bad as jumping to zero will crash.\r
-  \r
-\r
-  gUnix is a a public exported global that contains the initialized\r
-  data.\r
-\r
---*/\r
-\r
-#include "SecMain.h"\r
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation                                                         
+All rights reserved. This program and the accompanying materials                          
+are licensed and made available under the terms and conditions of the BSD License         
+which accompanies this distribution.  The full text of the license may be found at        
+http://opensource.org/licenses/bsd-license.php                                            
+                                                                                          
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
+
+Module Name:
+
+  UnixThunk.c
+
+Abstract:
+
+  Since the SEC is the only program in our emulation we 
+  must use a Tiano mechanism to export APIs to other modules.
+  This is the role of the EFI_UNIX_THUNK_PROTOCOL.
+
+  The mUnixThunkTable exists so that a change to EFI_UNIX_THUNK_PROTOCOL
+  will cause an error in initializing the array if all the member functions
+  are not added. It looks like adding a element to end and not initializing
+  it may cause the table to be initaliized with the members at the end being
+  set to zero. This is bad as jumping to zero will crash.
+  
+
+  gUnix is a a public exported global that contains the initialized
+  data.
+
+--*/
+
+#include "SecMain.h"
 #include "Library/UnixLib.h"
 #include <sys/time.h>
 #include <time.h>
 #include <signal.h>
 #include <string.h>
 #include <stdlib.h>
-
+#include <termio.h>
+#include <sys/ioctl.h>
 static int settimer_initialized;
 static struct timeval settimer_timeval;
 static void (*settimer_callback)(UINT64 delta);
@@ -89,6 +90,18 @@ SetTimer (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs))
   settimer_callback = CallBack;
 }
 
+void
+msSleep (unsigned long Milliseconds)
+{
+  struct timespec ts;
+
+  ts.tv_sec = Milliseconds / 1000;
+  ts.tv_nsec = (Milliseconds % 1000) * 1000000;
+
+  while (nanosleep (&ts, &ts) != 0 && errno == EINTR)
+    ;
+}
+
 void
 GetLocalTime (EFI_TIME *Time)
 {
@@ -110,12 +123,6 @@ GetLocalTime (EFI_TIME *Time)
     | (tm->tm_isdst > 0 ? EFI_TIME_IN_DAYLIGHT : 0);
 }
 
-void
-msSleep (unsigned long Milliseconds)
-{
-  usleep (Milliseconds * 1000);
-}
-
 static void
 TzSet (void)
 {
@@ -149,8 +156,8 @@ GetErrno(void)
 extern EFI_STATUS
 UgaCreate(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo, CONST CHAR16 *Title);
 
-EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {\r
-  EFI_UNIX_THUNK_PROTOCOL_SIGNATURE,\r
+EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
+  EFI_UNIX_THUNK_PROTOCOL_SIGNATURE,
   msSleep, /* Sleep */
   exit, /* Exit */
   SetTimer,
@@ -181,9 +188,16 @@ EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
   fsync,
   chmod,
   utime,
-
+  tcflush,
   UgaCreate,
-};\r
-\r
-\r
-EFI_UNIX_THUNK_PROTOCOL *gUnix = &mUnixThunkTable;\r
+  perror,
+  ioctl,
+  fcntl,
+  cfsetispeed,
+  cfsetospeed,
+  tcgetattr,
+  tcsetattr
+};
+
+
+EFI_UNIX_THUNK_PROTOCOL *gUnix = &mUnixThunkTable;