]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/Include/Protocol/UnixThunk.h
Fix issue with fixing tabs.
[mirror_edk2.git] / UnixPkg / Include / Protocol / UnixThunk.h
CommitLineData
804405e7 1/*++
2
f9b8ab56 3Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
2ff79f2e 4Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
124f761f 5This 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.
804405e7 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
d0c3acd4 32#include <Common/UnixInclude.h>
804405e7 33
ccd55824 34#include <Base.h>
35#include <Library/PeCoffLib.h>
36
37
7ee3b613 38
804405e7 39#define EFI_UNIX_THUNK_PROTOCOL_GUID \
40 { \
41 0xf2e98868, 0x8985, 0x11db, {0x9a, 0x59, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
42 }
43
44typedef
45VOID
124f761f 46(EFIAPI *UnixSleep) (
804405e7 47 unsigned long Milliseconds
48 );
49
50typedef
51VOID
124f761f 52(EFIAPI *UnixExit) (
804405e7 53 int status // exit code for all threads
54 );
55
56typedef
57VOID
124f761f 58(EFIAPI *UnixSetTimer) (
59 UINT64 PeriodMs,
60 VOID (EFIAPI *CallBack)(UINT64 DeltaMs)
b9c8e50e 61 );
62
804405e7 63typedef
64VOID
124f761f 65(EFIAPI *UnixGetLocalTime) (
b9c8e50e 66 EFI_TIME *Time
67 );
68
804405e7 69typedef
70struct tm *
124f761f 71(EFIAPI *UnixGmTime)(
b9c8e50e 72 const time_t *timep
73 );
74
804405e7 75typedef
76long
124f761f 77(EFIAPI *UnixGetTimeZone)(
b9c8e50e 78 void
79 );
80
804405e7 81typedef
82int
124f761f 83(EFIAPI *UnixGetDayLight)(
b9c8e50e 84 void
85 );
86
804405e7 87typedef
88int
124f761f 89(EFIAPI *UnixPoll)(
90 struct pollfd *pfd,
91 unsigned int nfds,
b9c8e50e 92 int timeout
93 );
94
804405e7 95typedef
b9c8e50e 96long
124f761f 97(EFIAPI *UnixRead) (
98 int fd,
99 void *buf,
b9c8e50e 100 int count
101 );
102
804405e7 103typedef
b9c8e50e 104long
124f761f 105(EFIAPI *UnixWrite) (
106 int fd,
107 const void *buf,
b9c8e50e 108 int count
109 );
110
804405e7 111typedef
112char *
124f761f 113(EFIAPI *UnixGetenv) (const char *var);
b9c8e50e 114
804405e7 115typedef
116int
124f761f 117(EFIAPI *UnixOpen) (const char *name, int flags, int mode);
b9c8e50e 118
804405e7 119typedef
7ee3b613 120off_t
124f761f 121(EFIAPI *UnixSeek) (int fd, off_t off, int whence);
b9c8e50e 122
804405e7 123typedef
124int
124f761f 125(EFIAPI *UnixFtruncate) (int fd, long int len);
b9c8e50e 126
804405e7 127typedef
128int
124f761f 129(EFIAPI *UnixClose) (int fd);
804405e7 130
131typedef
132int
124f761f 133(EFIAPI *UnixMkdir)(const char *pathname, mode_t mode);
b9c8e50e 134
804405e7 135typedef
136int
124f761f 137(EFIAPI *UnixRmDir)(const char *pathname);
b9c8e50e 138
804405e7 139typedef
140int
124f761f 141(EFIAPI *UnixUnLink)(const char *pathname);
b9c8e50e 142
804405e7 143typedef
144int
124f761f 145(EFIAPI *UnixGetErrno)(VOID);
b9c8e50e 146
804405e7 147typedef
148DIR *
124f761f 149(EFIAPI *UnixOpenDir)(const char *pathname);
b9c8e50e 150
804405e7 151typedef
152void
124f761f 153(EFIAPI *UnixRewindDir)(DIR *dir);
b9c8e50e 154
804405e7 155typedef
156struct dirent *
124f761f 157(EFIAPI *UnixReadDir)(DIR *dir);
b9c8e50e 158
804405e7 159typedef
160int
124f761f 161(EFIAPI *UnixCloseDir)(DIR *dir);
b9c8e50e 162
804405e7 163typedef
164int
124f761f 165(EFIAPI *UnixStat)(const char *path, STAT_FIX *buf);
b9c8e50e 166
804405e7 167typedef
168int
124f761f 169(EFIAPI *UnixStatFs)(const char *path, struct statfs *buf);
b9c8e50e 170
804405e7 171typedef
172int
124f761f 173(EFIAPI *UnixRename)(const char *oldpath, const char *newpath);
b9c8e50e 174
804405e7 175typedef
176time_t
124f761f 177(EFIAPI *UnixMkTime)(struct tm *tm);
b9c8e50e 178
804405e7 179typedef
180int
124f761f 181(EFIAPI *UnixFSync)(int fd);
b9c8e50e 182
804405e7 183typedef
184int
124f761f 185(EFIAPI *UnixChmod)(const char *path, mode_t mode);
b9c8e50e 186
804405e7 187typedef
188int
124f761f 189(EFIAPI *UnixUTime)(const char *filename, const struct utimbuf *buf);
804405e7 190
191struct _EFI_UNIX_UGA_IO_PROTOCOL;
192typedef
193EFI_STATUS
124f761f 194(EFIAPI *UnixUgaCreate)(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo,
2ac288f9 195 CONST CHAR16 *Title);
804405e7 196
197typedef
198int
124f761f 199(EFIAPI *UnixTcflush) (int fildes, int queue_selector);
804405e7 200
201typedef
202void
124f761f 203(EFIAPI *UnixPerror) (__const char *__s);
804405e7 204
124f761f 205typedef
206int
ccd55824 207#if __CYGWIN__
124f761f 208(EFIAPI *UnixIoCtl) (int fd, int __request, UINTN Arg);
ccd55824 209#else
124f761f 210(EFIAPI *UnixIoCtl) (int fd, unsigned long int __request, void *Arg);
ccd55824 211#endif
804405e7 212
124f761f 213typedef
214int
215(EFIAPI *UnixFcntl) (int __fd, int __cmd, void *Arg);
804405e7 216
217typedef
124f761f 218int
219(EFIAPI *UnixCfsetispeed) (struct termios *__termios_p, speed_t __speed);
804405e7 220
124f761f 221typedef
222int
223(EFIAPI *UnixCfsetospeed) (struct termios *__termios_p, speed_t __speed);
804405e7 224
225typedef
124f761f 226int
227(EFIAPI *UnixTcgetattr) (int __fd, struct termios *__termios_p);
804405e7 228
124f761f 229typedef
230int
231(EFIAPI *UnixTcsetattr) (int __fd, int __optional_actions,
2ac288f9 232 __const struct termios *__termios_p);
804405e7 233
398b646f 234
804405e7 235//
b9c8e50e 236// Worker functions to enable source level debug in the emulator
804405e7 237//
ccd55824 238
124f761f 239typedef
ccd55824 240RETURN_STATUS
241(EFIAPI *UnixPeCoffGetEntryPoint) (
242 IN VOID *Pe32Data,
243 IN OUT VOID **EntryPoint
244 );
245
124f761f 246typedef
ccd55824 247VOID
248(EFIAPI *UnixPeCoffRelocateImageExtraAction) (
249 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
250 );
251
124f761f 252typedef
ccd55824 253VOID
254(EFIAPI *UnixPeCoffLoaderUnloadImageExtraAction) (
255 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
256 );
257
2ff79f2e 258typedef
259int
260(EFIAPI *UnixGetIfAddrs) (
261 struct ifaddrs **ifap
262 );
263
264typedef
265void
266(EFIAPI *UnixFreeIfAddrs) (
267 struct ifaddrs *ifap
268 );
269
270typedef
271int
272(EFIAPI *UnixSocket) (
273 int domain,
274 int type,
275 int protocol
276 );
277
278typedef
279void
280(EFIAPI *UnixDisableInterruptEmulation) (void);
281
282typedef
283void
284(EFIAPI *UnixEnableInterruptEmulation) (void);
285
286
ccd55824 287
804405e7 288
208301e9 289#define EFI_UNIX_THUNK_PROTOCOL_SIGNATURE SIGNATURE_32 ('L', 'N', 'X', 'T')
804405e7 290
291typedef struct _EFI_UNIX_THUNK_PROTOCOL {
292 UINT64 Signature;
293
294 UnixSleep Sleep;
2ac288f9 295 UnixExit Exit;
804405e7 296 UnixSetTimer SetTimer;
2ac288f9 297 UnixGetLocalTime GetLocalTime;
804405e7 298 UnixGmTime GmTime;
299 UnixGetTimeZone GetTimeZone;
300 UnixGetDayLight GetDayLight;
2ac288f9 301 UnixPoll Poll;
69cf40e0 302 UnixRead Read;
303 UnixWrite Write;
304 UnixGetenv Getenv;
305 UnixOpen Open;
306 UnixSeek Lseek;
307 UnixFtruncate FTruncate;
308 UnixClose Close;
804405e7 309 UnixMkdir MkDir;
310 UnixRmDir RmDir;
311 UnixUnLink UnLink;
312 UnixGetErrno GetErrno;
313 UnixOpenDir OpenDir;
314 UnixRewindDir RewindDir;
315 UnixReadDir ReadDir;
316 UnixCloseDir CloseDir;
317 UnixStat Stat;
318 UnixStatFs StatFs;
319 UnixRename Rename;
320 UnixMkTime MkTime;
321 UnixFSync FSync;
322 UnixChmod Chmod;
323 UnixUTime UTime;
324 UnixTcflush Tcflush;
2ac288f9 325 UnixUgaCreate UgaCreate;
804405e7 326 UnixPerror Perror;
327 UnixIoCtl IoCtl;
328 UnixFcntl Fcntl;
329 UnixCfsetispeed Cfsetispeed;
330 UnixCfsetospeed Cfsetospeed;
331 UnixTcgetattr Tcgetattr;
332 UnixTcsetattr Tcsetattr;
ccd55824 333 UnixPeCoffGetEntryPoint PeCoffGetEntryPoint;
334 UnixPeCoffRelocateImageExtraAction PeCoffRelocateImageExtraAction;
335 UnixPeCoffLoaderUnloadImageExtraAction PeCoffUnloadImageExtraAction;
2ff79f2e 336 UnixEnableInterruptEmulation EnableInterrupt;
337 UnixDisableInterruptEmulation DisableInterrupt;
124f761f 338
2ff79f2e 339 UnixGetIfAddrs GetIfAddrs;
340 UnixFreeIfAddrs FreeIfAddrs;
341 UnixSocket Socket;
804405e7 342} EFI_UNIX_THUNK_PROTOCOL;
343
344extern EFI_GUID gEfiUnixThunkProtocolGuid;
345
346#endif