]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UnixPkg/Sec/UnixThunk.c
Added support for Xcode on Snow Leopard. Upaded with bug fixes for Snow Leopard.
[mirror_edk2.git] / UnixPkg / Sec / UnixThunk.c
index 8cf64b9d2e6dc45eb411384d324f4b81c5de5e89..c0f35d0729d59c094dd00576518085010f026e41 100644 (file)
@@ -1,6 +1,7 @@
 /*++
 
-Copyright (c) 2004 - 2006, Intel Corporation                                                         
+Copyright (c) 2004 - 2009, Intel Corporation                                                         
+Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.
 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        
@@ -35,6 +36,10 @@ Abstract:
 #include "Uefi.h"
 #include "Library/UnixLib.h"
 
+#ifdef __APPLE__
+#include "Gasket.h"
+#endif
+
 int settimer_initialized;
 struct timeval settimer_timeval;
 void (*settimer_callback)(UINT64 delta);
@@ -149,11 +154,68 @@ GetErrno(void)
   return errno;
 }
 
+
 extern EFI_STATUS
 UgaCreate(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo, CONST CHAR16 *Title);
 
 EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
   EFI_UNIX_THUNK_PROTOCOL_SIGNATURE,
+#ifdef __APPLE__
+//
+// Mac OS X requires the stack to be 16-byte aligned for IA-32. So on an OS X build
+// we add an assembly wrapper that makes sure the stack ges aligned. 
+// This has the nice benfit of being able to run EFI ABI code, like the EFI shell
+// that is checked in to source control in the OS X version of the emulator
+//
+  GasketmsSleep, /* Sleep */
+  Gasketexit, /* Exit */
+  GasketSetTimer,
+  GasketGetLocalTime,
+  Gasketgmtime,
+  GasketGetTimeZone,
+  GasketGetDayLight,
+  (UnixPoll)Gasketpoll,
+  (UnixRead)Gasketread,
+  (UnixWrite)Gasketwrite,
+  Gasketgetenv,
+  (UnixOpen)Gasketopen,
+  (UnixSeek)Gasketlseek,
+  (UnixFtruncate)Gasketftruncate,
+  Gasketclose,
+  Gasketmkdir,
+  Gasketrmdir,
+  Gasketunlink,
+  GasketGetErrno,
+  Gasketopendir,
+  (UnixRewindDir)Gasketrewinddir,
+  Gasketreaddir,
+  Gasketclosedir,
+  Gasketstat,
+  Gasketstatfs,
+  Gasketrename,
+  Gasketmktime,
+  Gasketfsync,
+  Gasketchmod,
+  Gasketutime,
+  Gaskettcflush,
+  GasketUgaCreate,
+  Gasketperror,
+  Gasketioctl,
+  Gasketfcntl,
+  Gasketcfsetispeed,
+  Gasketcfsetospeed,
+  Gaskettcgetattr,
+  Gaskettcsetattr,
+  
+  dlopen,  // Update me with a gasket
+  dlerror, // Update me with a gasket
+  dlsym,   // Update me with a gasket
+
+  SecPeCoffGetEntryPoint,                // Update me with a gasket
+  SecPeCoffRelocateImageExtraAction,     // Update me with a gasket
+  SecPeCoffLoaderUnloadImageExtraAction  // Update me with a gasket
+
+#else
   msSleep, /* Sleep */
   exit, /* Exit */
   SetTimer,
@@ -166,8 +228,8 @@ EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
   (UnixWrite)write,
   getenv,
   (UnixOpen)open,
-  lseek,
-  ftruncate,
+  (UnixSeek)lseek,
+  (UnixFtruncate)ftruncate,
   close,
   mkdir,
   rmdir,
@@ -177,7 +239,7 @@ EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
   rewinddir,
   readdir,
   closedir,
-  stat,
+  (UnixStat)stat,
   statfs,
   rename,
   mktime,
@@ -195,7 +257,11 @@ EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
   tcsetattr,
   dlopen,
   dlerror,
-  dlsym
+  dlsym,
+  SecPeCoffGetEntryPoint,
+  SecPeCoffRelocateImageExtraAction,
+  SecPeCoffLoaderUnloadImageExtraAction
+#endif
 };