]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/Include/Protocol/UnixThunk.h
Integrate patch from Andrew Fish to make it run on OS X.
[mirror_edk2.git] / UnixPkg / Include / Protocol / UnixThunk.h
CommitLineData
804405e7 1/*++
2
ccd55824 3Copyright (c) 2004 - 2009, Intel Corporation
4Portions copyright (c) 2008-2009 Apple Inc.<BR>
804405e7 5All rights reserved. This program and the accompanying materials
6are licensed and made available under the terms and conditions of the BSD License
7which accompanies this distribution. The full text of the license may be found at
8http://opensource.org/licenses/bsd-license.php
9
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13Module Name:
14
15 UnixThunk.h
16
17Abstract:
18
19 This protocol allows an EFI driver in the Unix emulation environment
20 to make Posix calls.
21
22 NEVER make an Unix call directly, always make the call via this protocol.
23
24 There are no This pointers on the protocol member functions as they map
25 exactly into Unix system calls.
26
27--*/
28
29#ifndef _UNIX_THUNK_H_
30#define _UNIX_THUNK_H_
31
32#include <sys/termios.h>
33#include <stdio.h>
34#include <sys/time.h>
ccd55824 35
36#if __CYGWIN__
37#include <sys/dirent.h>
38#else
804405e7 39#include <sys/dir.h>
ccd55824 40#endif
41
804405e7 42#include <unistd.h>
43#include <poll.h>
44#include <sys/types.h>
45#include <sys/stat.h>
46#include <fcntl.h>
47#include <time.h>
48#include <signal.h>
49#include <errno.h>
50#include <string.h>
51#include <stdlib.h>
804405e7 52#include <sys/ioctl.h>
ccd55824 53
54#ifdef __APPLE__
55#include <sys/param.h>
56#include <sys/mount.h>
57#define _XOPEN_SOURCE
58#else
59#include <termio.h>
804405e7 60#include <sys/vfs.h>
ccd55824 61#endif
62
804405e7 63#include <utime.h>
398b646f 64#include <dlfcn.h>
804405e7 65
ccd55824 66#include <Base.h>
67#include <Library/PeCoffLib.h>
68
69
804405e7 70#define EFI_UNIX_THUNK_PROTOCOL_GUID \
71 { \
72 0xf2e98868, 0x8985, 0x11db, {0x9a, 0x59, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
73 }
74
75typedef
76VOID
77(*UnixSleep) (
78 unsigned long Milliseconds
79 );
80
81typedef
82VOID
83(*UnixExit) (
84 int status // exit code for all threads
85 );
86
87typedef
88VOID
89(*UnixSetTimer) (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs));
90typedef
91VOID
92(*UnixGetLocalTime) (EFI_TIME *Time);
93typedef
94struct tm *
95(*UnixGmTime)(const time_t *timep);
96typedef
97long
98(*UnixGetTimeZone)(void);
99typedef
100int
101(*UnixGetDayLight)(void);
102typedef
103int
104(*UnixPoll)(struct pollfd *pfd, int nfds, int timeout);
105typedef
106int
107(*UnixRead) (int fd, void *buf, int count);
108typedef
109int
110(*UnixWrite) (int fd, const void *buf, int count);
111typedef
112char *
113(*UnixGetenv) (const char *var);
114typedef
115int
116(*UnixOpen) (const char *name, int flags, int mode);
117typedef
118long int
119(*UnixSeek) (int fd, long int off, int whence);
120typedef
121int
122(*UnixFtruncate) (int fd, long int len);
123typedef
124int
125(*UnixClose) (int fd);
126
127typedef
128int
129(*UnixMkdir)(const char *pathname, mode_t mode);
130typedef
131int
132(*UnixRmDir)(const char *pathname);
133typedef
134int
135(*UnixUnLink)(const char *pathname);
136typedef
137int
138(*UnixGetErrno)(VOID);
139typedef
140DIR *
141(*UnixOpenDir)(const char *pathname);
142typedef
143void
144(*UnixRewindDir)(DIR *dir);
145typedef
146struct dirent *
147(*UnixReadDir)(DIR *dir);
148typedef
149int
150(*UnixCloseDir)(DIR *dir);
151typedef
152int
153(*UnixStat)(const char *path, struct stat *buf);
154typedef
155int
156(*UnixStatFs)(const char *path, struct statfs *buf);
157typedef
158int
159(*UnixRename)(const char *oldpath, const char *newpath);
160typedef
161time_t
162(*UnixMkTime)(struct tm *tm);
163typedef
164int
165(*UnixFSync)(int fd);
166typedef
167int
168(*UnixChmod)(const char *path, mode_t mode);
169typedef
170int
171(*UnixUTime)(const char *filename, const struct utimbuf *buf);
172
173struct _EFI_UNIX_UGA_IO_PROTOCOL;
174typedef
175EFI_STATUS
176(*UnixUgaCreate)(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo,
177 CONST CHAR16 *Title);
178
179typedef
180int
181(*UnixTcflush) (int fildes, int queue_selector);
182
183typedef
184void
185(*UnixPerror) (__const char *__s);
186
187typedef
188int
ccd55824 189#if __CYGWIN__
190(*UnixIoCtl) (int fd, int __request, ...);
191#else
804405e7 192(*UnixIoCtl) (int fd, unsigned long int __request, ...);
ccd55824 193#endif
804405e7 194
195typedef
196int
197(*UnixFcntl) (int __fd, int __cmd, ...);
198
199typedef
200int
201(*UnixCfsetispeed) (struct termios *__termios_p, speed_t __speed);
202
203typedef
204int
205(*UnixCfsetospeed) (struct termios *__termios_p, speed_t __speed);
206
207typedef
208int
209(*UnixTcgetattr) (int __fd, struct termios *__termios_p);
210
211typedef
212int
213(*UnixTcsetattr) (int __fd, int __optional_actions,
214 __const struct termios *__termios_p);
215
398b646f 216typedef
217VOID *
218(*UnixDlopen) (const char *FileName, int Flag);
219
220typedef
221char *
222(*UnixDlerror) (VOID);
223
224typedef
225VOID *
226(*UnixDlsym) (VOID* Handle, const char* Symbol);
227
228
804405e7 229//
ccd55824 230// Work functions to enable source level debug in the emulator
804405e7 231//
ccd55824 232
233typedef
234RETURN_STATUS
235(EFIAPI *UnixPeCoffGetEntryPoint) (
236 IN VOID *Pe32Data,
237 IN OUT VOID **EntryPoint
238 );
239
240typedef
241VOID
242(EFIAPI *UnixPeCoffRelocateImageExtraAction) (
243 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
244 );
245
246typedef
247VOID
248(EFIAPI *UnixPeCoffLoaderUnloadImageExtraAction) (
249 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
250 );
251
252
804405e7 253
208301e9 254#define EFI_UNIX_THUNK_PROTOCOL_SIGNATURE SIGNATURE_32 ('L', 'N', 'X', 'T')
804405e7 255
256typedef struct _EFI_UNIX_THUNK_PROTOCOL {
257 UINT64 Signature;
258
259 UnixSleep Sleep;
260 UnixExit Exit;
261 UnixSetTimer SetTimer;
262 UnixGetLocalTime GetLocalTime;
263 UnixGmTime GmTime;
264 UnixGetTimeZone GetTimeZone;
265 UnixGetDayLight GetDayLight;
266 UnixPoll Poll;
267 UnixRead Read;
268 UnixWrite Write;
269 UnixGetenv Getenv;
270 UnixOpen Open;
271 UnixSeek Lseek;
272 UnixFtruncate FTruncate;
273 UnixClose Close;
274 UnixMkdir MkDir;
275 UnixRmDir RmDir;
276 UnixUnLink UnLink;
277 UnixGetErrno GetErrno;
278 UnixOpenDir OpenDir;
279 UnixRewindDir RewindDir;
280 UnixReadDir ReadDir;
281 UnixCloseDir CloseDir;
282 UnixStat Stat;
283 UnixStatFs StatFs;
284 UnixRename Rename;
285 UnixMkTime MkTime;
286 UnixFSync FSync;
287 UnixChmod Chmod;
288 UnixUTime UTime;
289 UnixTcflush Tcflush;
290 UnixUgaCreate UgaCreate;
291 UnixPerror Perror;
292 UnixIoCtl IoCtl;
293 UnixFcntl Fcntl;
294 UnixCfsetispeed Cfsetispeed;
295 UnixCfsetospeed Cfsetospeed;
296 UnixTcgetattr Tcgetattr;
297 UnixTcsetattr Tcsetattr;
398b646f 298 UnixDlopen Dlopen;
299 UnixDlerror Dlerror;
300 UnixDlsym Dlsym;
ccd55824 301 UnixPeCoffGetEntryPoint PeCoffGetEntryPoint;
302 UnixPeCoffRelocateImageExtraAction PeCoffRelocateImageExtraAction;
303 UnixPeCoffLoaderUnloadImageExtraAction PeCoffUnloadImageExtraAction;
304
305
804405e7 306} EFI_UNIX_THUNK_PROTOCOL;
307
308extern EFI_GUID gEfiUnixThunkProtocolGuid;
309
310#endif