]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UnixPkg/Include/Protocol/UnixThunk.h
Update the copyright notice format
[mirror_edk2.git] / UnixPkg / Include / Protocol / UnixThunk.h
index ba325bff87f0306758ad03565f74d2df9e6d84bb..67bf53761c12f15914e990ff11871c3150a1f322 100644 (file)
@@ -1,7 +1,8 @@
 /*++
 
-Copyright (c) 2004, Intel Corporation                                                         
-All rights reserved. This program and the accompanying materials                          
+Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
+Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+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                                            
@@ -31,7 +32,13 @@ Abstract:
 #include <sys/termios.h>
 #include <stdio.h>
 #include <sys/time.h>
+
+#if __CYGWIN__
+#include <sys/dirent.h>
+#else
 #include <sys/dir.h>
+#endif
+
 #include <unistd.h>
 #include <poll.h>
 #include <sys/types.h>
@@ -42,11 +49,92 @@ Abstract:
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
-#include <termio.h>
 #include <sys/ioctl.h>
+
+#ifdef __APPLE__
+#include <sys/param.h>
+#include <sys/mount.h>
+#define _XOPEN_SOURCE
+#else
+#include <termio.h>
 #include <sys/vfs.h>
+#endif 
+
 #include <utime.h>
 #include <dlfcn.h>
+#include <ucontext.h>
+
+#include <Base.h>
+#include <Library/PeCoffLib.h>
+
+
+#if __APPLE__
+//
+// EFI packing is not compatible witht he default OS packing for struct stat.
+// st_size is 64-bit but starts on a 32-bit offset in the structure. The compiler
+// flags used to produce compatible EFI images, break struct stat
+//
+#pragma pack(4)
+
+#if __DARWIN_64_BIT_INO_T
+
+typedef struct stat_fix { \
+       dev_t           st_dev;                 /* [XSI] ID of device containing file */ 
+       mode_t          st_mode;                /* [XSI] Mode of file (see below) */ 
+       nlink_t         st_nlink;               /* [XSI] Number of hard links */ 
+       __darwin_ino64_t st_ino;                /* [XSI] File serial number */ 
+       uid_t           st_uid;                 /* [XSI] User ID of the file */ 
+       gid_t           st_gid;                 /* [XSI] Group ID of the file */ 
+       dev_t           st_rdev;                /* [XSI] Device ID */ 
+       __DARWIN_STRUCT_STAT64_TIMES 
+       off_t           st_size;                /* [XSI] file size, in bytes */ 
+       blkcnt_t        st_blocks;              /* [XSI] blocks allocated for file */ 
+       blksize_t       st_blksize;             /* [XSI] optimal blocksize for I/O */ 
+       __uint32_t      st_flags;               /* user defined flags for file */ 
+       __uint32_t      st_gen;                 /* file generation number */ 
+       __int32_t       st_lspare;              /* RESERVED: DO NOT USE! */ 
+       __int64_t       st_qspare[2];           /* RESERVED: DO NOT USE! */ 
+} STAT_FIX;
+
+#else /* !__DARWIN_64_BIT_INO_T */
+
+typedef struct stat_fix {
+       dev_t           st_dev;         /* [XSI] ID of device containing file */
+       ino_t           st_ino;         /* [XSI] File serial number */
+       mode_t          st_mode;        /* [XSI] Mode of file (see below) */
+       nlink_t         st_nlink;       /* [XSI] Number of hard links */
+       uid_t           st_uid;         /* [XSI] User ID of the file */
+       gid_t           st_gid;         /* [XSI] Group ID of the file */
+       dev_t           st_rdev;        /* [XSI] Device ID */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+       struct  timespec st_atimespec;  /* time of last access */
+       struct  timespec st_mtimespec;  /* time of last data modification */
+       struct  timespec st_ctimespec;  /* time of last status change */
+#else
+       time_t          st_atime;       /* [XSI] Time of last access */
+       long            st_atimensec;   /* nsec of last access */
+       time_t          st_mtime;       /* [XSI] Last data modification time */
+       long            st_mtimensec;   /* last data modification nsec */
+       time_t          st_ctime;       /* [XSI] Time of last status change */
+       long            st_ctimensec;   /* nsec of last status change */
+#endif
+       off_t           st_size;        /* [XSI] file size, in bytes */
+       blkcnt_t        st_blocks;      /* [XSI] blocks allocated for file */
+       blksize_t       st_blksize;     /* [XSI] optimal blocksize for I/O */
+       __uint32_t      st_flags;       /* user defined flags for file */
+       __uint32_t      st_gen;         /* file generation number */
+       __int32_t       st_lspare;      /* RESERVED: DO NOT USE! */
+       __int64_t       st_qspare[2];   /* RESERVED: DO NOT USE! */
+} STAT_FIX;
+
+#pragma pack()
+#endif
+
+#else 
+
+  typedef struct stat STAT_FIX;
+
+#endif
 
 #define EFI_UNIX_THUNK_PROTOCOL_GUID \
   { \
@@ -96,8 +184,8 @@ typedef
 int
 (*UnixOpen) (const char *name, int flags, int mode);
 typedef
-long int
-(*UnixSeek) (int fd, long int off, int whence);
+off_t
+(*UnixSeek) (int fd, off_t off, int whence);
 typedef
 int
 (*UnixFtruncate) (int fd, long int len);
@@ -131,7 +219,7 @@ int
 (*UnixCloseDir)(DIR *dir);
 typedef
 int
-(*UnixStat)(const char *path, struct stat *buf);
+(*UnixStat)(const char *path, STAT_FIX *buf);
 typedef
 int
 (*UnixStatFs)(const char *path, struct statfs *buf);
@@ -167,7 +255,11 @@ void
 
 typedef 
 int 
+#if __CYGWIN__
+(*UnixIoCtl) (int fd, int __request, ...);
+#else
 (*UnixIoCtl) (int fd, unsigned long int __request, ...);
+#endif
 
 typedef 
 int 
@@ -190,7 +282,7 @@ int
 (*UnixTcsetattr) (int __fd, int __optional_actions,
                      __const struct termios *__termios_p);
 
-typedef
+typedef 
 VOID *
 (*UnixDlopen) (const char *FileName, int Flag);
 
@@ -204,8 +296,29 @@ VOID *
 
 
 //
+// Work functions to enable source level debug in the emulator
 //
-//
+
+typedef 
+RETURN_STATUS
+(EFIAPI *UnixPeCoffGetEntryPoint) (
+  IN     VOID  *Pe32Data,
+  IN OUT VOID  **EntryPoint
+  );
+
+typedef 
+VOID
+(EFIAPI *UnixPeCoffRelocateImageExtraAction) (
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext
+  );
+
+typedef 
+VOID
+(EFIAPI *UnixPeCoffLoaderUnloadImageExtraAction) (
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext
+  );
+
+
 
 #define EFI_UNIX_THUNK_PROTOCOL_SIGNATURE SIGNATURE_32 ('L', 'N', 'X', 'T')
 
@@ -254,6 +367,11 @@ typedef struct _EFI_UNIX_THUNK_PROTOCOL {
   UnixDlopen                          Dlopen;
   UnixDlerror                         Dlerror;
   UnixDlsym                           Dlsym;
+  UnixPeCoffGetEntryPoint                 PeCoffGetEntryPoint;
+  UnixPeCoffRelocateImageExtraAction      PeCoffRelocateImageExtraAction;
+  UnixPeCoffLoaderUnloadImageExtraAction  PeCoffUnloadImageExtraAction;
+       
+       
 } EFI_UNIX_THUNK_PROTOCOL;
 
 extern EFI_GUID gEfiUnixThunkProtocolGuid;