3 Copyright (c) 2004 - 2009, Intel Corporation
4 Portions copyright (c) 2008-2009 Apple Inc.<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 This protocol allows an EFI driver in the Unix emulation environment
22 NEVER make an Unix call directly, always make the call via this protocol.
24 There are no This pointers on the protocol member functions as they map
25 exactly into Unix system calls.
29 #ifndef _UNIX_THUNK_H_
30 #define _UNIX_THUNK_H_
32 #include <sys/termios.h>
37 #include <sys/dirent.h>
44 #include <sys/types.h>
52 #include <sys/ioctl.h>
55 #include <sys/param.h>
56 #include <sys/mount.h>
67 #include <Library/PeCoffLib.h>
70 #define EFI_UNIX_THUNK_PROTOCOL_GUID \
72 0xf2e98868, 0x8985, 0x11db, {0x9a, 0x59, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
78 unsigned long Milliseconds
84 int status
// exit code for all threads
89 (*UnixSetTimer
) (UINT64 PeriodMs
, VOID (*CallBack
)(UINT64 DeltaMs
));
92 (*UnixGetLocalTime
) (EFI_TIME
*Time
);
95 (*UnixGmTime
)(const time_t *timep
);
98 (*UnixGetTimeZone
)(void);
101 (*UnixGetDayLight
)(void);
104 (*UnixPoll
)(struct pollfd
*pfd
, int nfds
, int timeout
);
107 (*UnixRead
) (int fd
, void *buf
, int count
);
110 (*UnixWrite
) (int fd
, const void *buf
, int count
);
113 (*UnixGetenv
) (const char *var
);
116 (*UnixOpen
) (const char *name
, int flags
, int mode
);
119 (*UnixSeek
) (int fd
, long int off
, int whence
);
122 (*UnixFtruncate
) (int fd
, long int len
);
125 (*UnixClose
) (int fd
);
129 (*UnixMkdir
)(const char *pathname
, mode_t mode
);
132 (*UnixRmDir
)(const char *pathname
);
135 (*UnixUnLink
)(const char *pathname
);
138 (*UnixGetErrno
)(VOID
);
141 (*UnixOpenDir
)(const char *pathname
);
144 (*UnixRewindDir
)(DIR *dir
);
147 (*UnixReadDir
)(DIR *dir
);
150 (*UnixCloseDir
)(DIR *dir
);
153 (*UnixStat
)(const char *path
, struct stat
*buf
);
156 (*UnixStatFs
)(const char *path
, struct statfs
*buf
);
159 (*UnixRename
)(const char *oldpath
, const char *newpath
);
162 (*UnixMkTime
)(struct tm
*tm
);
165 (*UnixFSync
)(int fd
);
168 (*UnixChmod
)(const char *path
, mode_t mode
);
171 (*UnixUTime
)(const char *filename
, const struct utimbuf
*buf
);
173 struct _EFI_UNIX_UGA_IO_PROTOCOL
;
176 (*UnixUgaCreate
)(struct _EFI_UNIX_UGA_IO_PROTOCOL
**UgaIo
,
177 CONST CHAR16
*Title
);
181 (*UnixTcflush
) (int fildes
, int queue_selector
);
185 (*UnixPerror
) (__const
char *__s
);
190 (*UnixIoCtl
) (int fd
, int __request
, ...);
192 (*UnixIoCtl
) (int fd
, unsigned long int __request
, ...);
197 (*UnixFcntl
) (int __fd
, int __cmd
, ...);
201 (*UnixCfsetispeed
) (struct termios
*__termios_p
, speed_t __speed
);
205 (*UnixCfsetospeed
) (struct termios
*__termios_p
, speed_t __speed
);
209 (*UnixTcgetattr
) (int __fd
, struct termios
*__termios_p
);
213 (*UnixTcsetattr
) (int __fd
, int __optional_actions
,
214 __const
struct termios
*__termios_p
);
218 (*UnixDlopen
) (const char *FileName
, int Flag
);
222 (*UnixDlerror
) (VOID
);
226 (*UnixDlsym
) (VOID
* Handle
, const char* Symbol
);
230 // Work functions to enable source level debug in the emulator
235 (EFIAPI
*UnixPeCoffGetEntryPoint
) (
237 IN OUT VOID
**EntryPoint
242 (EFIAPI
*UnixPeCoffRelocateImageExtraAction
) (
243 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
248 (EFIAPI
*UnixPeCoffLoaderUnloadImageExtraAction
) (
249 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
254 #define EFI_UNIX_THUNK_PROTOCOL_SIGNATURE SIGNATURE_32 ('L', 'N', 'X', 'T')
256 typedef struct _EFI_UNIX_THUNK_PROTOCOL
{
261 UnixSetTimer SetTimer
;
262 UnixGetLocalTime GetLocalTime
;
264 UnixGetTimeZone GetTimeZone
;
265 UnixGetDayLight GetDayLight
;
272 UnixFtruncate FTruncate
;
277 UnixGetErrno GetErrno
;
279 UnixRewindDir RewindDir
;
281 UnixCloseDir CloseDir
;
290 UnixUgaCreate UgaCreate
;
294 UnixCfsetispeed Cfsetispeed
;
295 UnixCfsetospeed Cfsetospeed
;
296 UnixTcgetattr Tcgetattr
;
297 UnixTcsetattr Tcsetattr
;
301 UnixPeCoffGetEntryPoint PeCoffGetEntryPoint
;
302 UnixPeCoffRelocateImageExtraAction PeCoffRelocateImageExtraAction
;
303 UnixPeCoffLoaderUnloadImageExtraAction PeCoffUnloadImageExtraAction
;
306 } EFI_UNIX_THUNK_PROTOCOL
;
308 extern EFI_GUID gEfiUnixThunkProtocolGuid
;