3 Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
4 Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
5 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 <Common/UnixInclude.h>
35 #include <Library/PeCoffLib.h>
39 #define EFI_UNIX_THUNK_PROTOCOL_GUID \
41 0xf2e98868, 0x8985, 0x11db, {0x9a, 0x59, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
47 unsigned long Milliseconds
53 int status
// exit code for all threads
58 (EFIAPI
*UnixSetTimer
) (
60 VOID (EFIAPI
*CallBack
)(UINT64 DeltaMs
)
65 (EFIAPI
*UnixGetLocalTime
) (
77 (EFIAPI
*UnixGetTimeZone
)(
83 (EFIAPI
*UnixGetDayLight
)(
105 (EFIAPI
*UnixWrite
) (
113 (EFIAPI
*UnixGetenv
) (const char *var
);
117 (EFIAPI
*UnixOpen
) (const char *name
, int flags
, int mode
);
121 (EFIAPI
*UnixSeek
) (int fd
, off_t off
, int whence
);
125 (EFIAPI
*UnixFtruncate
) (int fd
, long int len
);
129 (EFIAPI
*UnixClose
) (int fd
);
133 (EFIAPI
*UnixMkdir
)(const char *pathname
, mode_t mode
);
137 (EFIAPI
*UnixRmDir
)(const char *pathname
);
141 (EFIAPI
*UnixUnLink
)(const char *pathname
);
145 (EFIAPI
*UnixGetErrno
)(VOID
);
149 (EFIAPI
*UnixOpenDir
)(const char *pathname
);
153 (EFIAPI
*UnixRewindDir
)(DIR *dir
);
157 (EFIAPI
*UnixReadDir
)(DIR *dir
);
161 (EFIAPI
*UnixCloseDir
)(DIR *dir
);
165 (EFIAPI
*UnixStat
)(const char *path
, STAT_FIX
*buf
);
169 (EFIAPI
*UnixStatFs
)(const char *path
, struct statfs
*buf
);
173 (EFIAPI
*UnixRename
)(const char *oldpath
, const char *newpath
);
177 (EFIAPI
*UnixMkTime
)(struct tm
*tm
);
181 (EFIAPI
*UnixFSync
)(int fd
);
185 (EFIAPI
*UnixChmod
)(const char *path
, mode_t mode
);
189 (EFIAPI
*UnixUTime
)(const char *filename
, const struct utimbuf
*buf
);
191 struct _EFI_UNIX_UGA_IO_PROTOCOL
;
194 (EFIAPI
*UnixUgaCreate
)(struct _EFI_UNIX_UGA_IO_PROTOCOL
**UgaIo
,
195 CONST CHAR16
*Title
);
199 (EFIAPI
*UnixTcflush
) (int fildes
, int queue_selector
);
203 (EFIAPI
*UnixPerror
) (__const
char *__s
);
208 (EFIAPI
*UnixIoCtl
) (int fd
, int __request
, UINTN Arg
);
210 (EFIAPI
*UnixIoCtl
) (int fd
, unsigned long int __request
, void *Arg
);
215 (EFIAPI
*UnixFcntl
) (int __fd
, int __cmd
, void *Arg
);
219 (EFIAPI
*UnixCfsetispeed
) (struct termios
*__termios_p
, speed_t __speed
);
223 (EFIAPI
*UnixCfsetospeed
) (struct termios
*__termios_p
, speed_t __speed
);
227 (EFIAPI
*UnixTcgetattr
) (int __fd
, struct termios
*__termios_p
);
231 (EFIAPI
*UnixTcsetattr
) (int __fd
, int __optional_actions
,
232 __const
struct termios
*__termios_p
);
236 // Worker functions to enable source level debug in the emulator
241 (EFIAPI
*UnixPeCoffGetEntryPoint
) (
243 IN OUT VOID
**EntryPoint
248 (EFIAPI
*UnixPeCoffRelocateImageExtraAction
) (
249 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
254 (EFIAPI
*UnixPeCoffLoaderUnloadImageExtraAction
) (
255 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
260 (EFIAPI
*UnixGetIfAddrs
) (
261 struct ifaddrs
**ifap
266 (EFIAPI
*UnixFreeIfAddrs
) (
272 (EFIAPI
*UnixSocket
) (
280 (EFIAPI
*UnixDisableInterruptEmulation
) (void);
284 (EFIAPI
*UnixEnableInterruptEmulation
) (void);
289 #define EFI_UNIX_THUNK_PROTOCOL_SIGNATURE SIGNATURE_32 ('L', 'N', 'X', 'T')
291 typedef struct _EFI_UNIX_THUNK_PROTOCOL
{
296 UnixSetTimer SetTimer
;
297 UnixGetLocalTime GetLocalTime
;
299 UnixGetTimeZone GetTimeZone
;
300 UnixGetDayLight GetDayLight
;
307 UnixFtruncate FTruncate
;
312 UnixGetErrno GetErrno
;
314 UnixRewindDir RewindDir
;
316 UnixCloseDir CloseDir
;
325 UnixUgaCreate UgaCreate
;
329 UnixCfsetispeed Cfsetispeed
;
330 UnixCfsetospeed Cfsetospeed
;
331 UnixTcgetattr Tcgetattr
;
332 UnixTcsetattr Tcsetattr
;
333 UnixPeCoffGetEntryPoint PeCoffGetEntryPoint
;
334 UnixPeCoffRelocateImageExtraAction PeCoffRelocateImageExtraAction
;
335 UnixPeCoffLoaderUnloadImageExtraAction PeCoffUnloadImageExtraAction
;
336 UnixEnableInterruptEmulation EnableInterrupt
;
337 UnixDisableInterruptEmulation DisableInterrupt
;
339 UnixGetIfAddrs GetIfAddrs
;
340 UnixFreeIfAddrs FreeIfAddrs
;
342 } EFI_UNIX_THUNK_PROTOCOL
;
344 extern EFI_GUID gEfiUnixThunkProtocolGuid
;