]>
Commit | Line | Data |
---|---|---|
804405e7 | 1 | /*++ |
2 | ||
f9b8ab56 | 3 | Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR> |
2ff79f2e | 4 | Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR> |
124f761f | 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 | |
9 | ||
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. | |
804405e7 | 12 | |
13 | Module Name: | |
14 | ||
15 | UnixThunk.h | |
16 | ||
17 | Abstract: | |
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 | ||
44 | typedef | |
45 | VOID | |
124f761f | 46 | (EFIAPI *UnixSleep) ( |
804405e7 | 47 | unsigned long Milliseconds |
48 | ); | |
49 | ||
50 | typedef | |
51 | VOID | |
124f761f | 52 | (EFIAPI *UnixExit) ( |
804405e7 | 53 | int status // exit code for all threads |
54 | ); | |
55 | ||
56 | typedef | |
57 | VOID | |
124f761f | 58 | (EFIAPI *UnixSetTimer) ( |
59 | UINT64 PeriodMs, | |
60 | VOID (EFIAPI *CallBack)(UINT64 DeltaMs) | |
b9c8e50e | 61 | ); |
62 | ||
804405e7 | 63 | typedef |
64 | VOID | |
124f761f | 65 | (EFIAPI *UnixGetLocalTime) ( |
b9c8e50e | 66 | EFI_TIME *Time |
67 | ); | |
68 | ||
804405e7 | 69 | typedef |
70 | struct tm * | |
124f761f | 71 | (EFIAPI *UnixGmTime)( |
b9c8e50e | 72 | const time_t *timep |
73 | ); | |
74 | ||
804405e7 | 75 | typedef |
76 | long | |
124f761f | 77 | (EFIAPI *UnixGetTimeZone)( |
b9c8e50e | 78 | void |
79 | ); | |
80 | ||
804405e7 | 81 | typedef |
82 | int | |
124f761f | 83 | (EFIAPI *UnixGetDayLight)( |
b9c8e50e | 84 | void |
85 | ); | |
86 | ||
804405e7 | 87 | typedef |
88 | int | |
124f761f | 89 | (EFIAPI *UnixPoll)( |
90 | struct pollfd *pfd, | |
91 | unsigned int nfds, | |
b9c8e50e | 92 | int timeout |
93 | ); | |
94 | ||
804405e7 | 95 | typedef |
b9c8e50e | 96 | long |
124f761f | 97 | (EFIAPI *UnixRead) ( |
98 | int fd, | |
99 | void *buf, | |
b9c8e50e | 100 | int count |
101 | ); | |
102 | ||
804405e7 | 103 | typedef |
b9c8e50e | 104 | long |
124f761f | 105 | (EFIAPI *UnixWrite) ( |
106 | int fd, | |
107 | const void *buf, | |
b9c8e50e | 108 | int count |
109 | ); | |
110 | ||
804405e7 | 111 | typedef |
112 | char * | |
124f761f | 113 | (EFIAPI *UnixGetenv) (const char *var); |
b9c8e50e | 114 | |
804405e7 | 115 | typedef |
116 | int | |
124f761f | 117 | (EFIAPI *UnixOpen) (const char *name, int flags, int mode); |
b9c8e50e | 118 | |
804405e7 | 119 | typedef |
7ee3b613 | 120 | off_t |
124f761f | 121 | (EFIAPI *UnixSeek) (int fd, off_t off, int whence); |
b9c8e50e | 122 | |
804405e7 | 123 | typedef |
124 | int | |
124f761f | 125 | (EFIAPI *UnixFtruncate) (int fd, long int len); |
b9c8e50e | 126 | |
804405e7 | 127 | typedef |
128 | int | |
124f761f | 129 | (EFIAPI *UnixClose) (int fd); |
804405e7 | 130 | |
131 | typedef | |
132 | int | |
124f761f | 133 | (EFIAPI *UnixMkdir)(const char *pathname, mode_t mode); |
b9c8e50e | 134 | |
804405e7 | 135 | typedef |
136 | int | |
124f761f | 137 | (EFIAPI *UnixRmDir)(const char *pathname); |
b9c8e50e | 138 | |
804405e7 | 139 | typedef |
140 | int | |
124f761f | 141 | (EFIAPI *UnixUnLink)(const char *pathname); |
b9c8e50e | 142 | |
804405e7 | 143 | typedef |
144 | int | |
124f761f | 145 | (EFIAPI *UnixGetErrno)(VOID); |
b9c8e50e | 146 | |
804405e7 | 147 | typedef |
148 | DIR * | |
124f761f | 149 | (EFIAPI *UnixOpenDir)(const char *pathname); |
b9c8e50e | 150 | |
804405e7 | 151 | typedef |
152 | void | |
124f761f | 153 | (EFIAPI *UnixRewindDir)(DIR *dir); |
b9c8e50e | 154 | |
804405e7 | 155 | typedef |
156 | struct dirent * | |
124f761f | 157 | (EFIAPI *UnixReadDir)(DIR *dir); |
b9c8e50e | 158 | |
804405e7 | 159 | typedef |
160 | int | |
124f761f | 161 | (EFIAPI *UnixCloseDir)(DIR *dir); |
b9c8e50e | 162 | |
804405e7 | 163 | typedef |
164 | int | |
124f761f | 165 | (EFIAPI *UnixStat)(const char *path, STAT_FIX *buf); |
b9c8e50e | 166 | |
804405e7 | 167 | typedef |
168 | int | |
124f761f | 169 | (EFIAPI *UnixStatFs)(const char *path, struct statfs *buf); |
b9c8e50e | 170 | |
804405e7 | 171 | typedef |
172 | int | |
124f761f | 173 | (EFIAPI *UnixRename)(const char *oldpath, const char *newpath); |
b9c8e50e | 174 | |
804405e7 | 175 | typedef |
176 | time_t | |
124f761f | 177 | (EFIAPI *UnixMkTime)(struct tm *tm); |
b9c8e50e | 178 | |
804405e7 | 179 | typedef |
180 | int | |
124f761f | 181 | (EFIAPI *UnixFSync)(int fd); |
b9c8e50e | 182 | |
804405e7 | 183 | typedef |
184 | int | |
124f761f | 185 | (EFIAPI *UnixChmod)(const char *path, mode_t mode); |
b9c8e50e | 186 | |
804405e7 | 187 | typedef |
188 | int | |
124f761f | 189 | (EFIAPI *UnixUTime)(const char *filename, const struct utimbuf *buf); |
804405e7 | 190 | |
191 | struct _EFI_UNIX_UGA_IO_PROTOCOL; | |
192 | typedef | |
193 | EFI_STATUS | |
124f761f | 194 | (EFIAPI *UnixUgaCreate)(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo, |
2ac288f9 | 195 | CONST CHAR16 *Title); |
804405e7 | 196 | |
197 | typedef | |
198 | int | |
124f761f | 199 | (EFIAPI *UnixTcflush) (int fildes, int queue_selector); |
804405e7 | 200 | |
201 | typedef | |
202 | void | |
124f761f | 203 | (EFIAPI *UnixPerror) (__const char *__s); |
804405e7 | 204 | |
124f761f | 205 | typedef |
206 | int | |
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 | 213 | typedef |
214 | int | |
215 | (EFIAPI *UnixFcntl) (int __fd, int __cmd, void *Arg); | |
804405e7 | 216 | |
217 | typedef | |
124f761f | 218 | int |
219 | (EFIAPI *UnixCfsetispeed) (struct termios *__termios_p, speed_t __speed); | |
804405e7 | 220 | |
124f761f | 221 | typedef |
222 | int | |
223 | (EFIAPI *UnixCfsetospeed) (struct termios *__termios_p, speed_t __speed); | |
804405e7 | 224 | |
225 | typedef | |
124f761f | 226 | int |
227 | (EFIAPI *UnixTcgetattr) (int __fd, struct termios *__termios_p); | |
804405e7 | 228 | |
124f761f | 229 | typedef |
230 | int | |
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 | 239 | typedef |
ccd55824 | 240 | RETURN_STATUS |
241 | (EFIAPI *UnixPeCoffGetEntryPoint) ( | |
242 | IN VOID *Pe32Data, | |
243 | IN OUT VOID **EntryPoint | |
244 | ); | |
245 | ||
124f761f | 246 | typedef |
ccd55824 | 247 | VOID |
248 | (EFIAPI *UnixPeCoffRelocateImageExtraAction) ( | |
249 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext | |
250 | ); | |
251 | ||
124f761f | 252 | typedef |
ccd55824 | 253 | VOID |
254 | (EFIAPI *UnixPeCoffLoaderUnloadImageExtraAction) ( | |
255 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext | |
256 | ); | |
257 | ||
2ff79f2e | 258 | typedef |
259 | int | |
260 | (EFIAPI *UnixGetIfAddrs) ( | |
261 | struct ifaddrs **ifap | |
262 | ); | |
263 | ||
264 | typedef | |
265 | void | |
266 | (EFIAPI *UnixFreeIfAddrs) ( | |
267 | struct ifaddrs *ifap | |
268 | ); | |
269 | ||
270 | typedef | |
271 | int | |
272 | (EFIAPI *UnixSocket) ( | |
273 | int domain, | |
274 | int type, | |
275 | int protocol | |
276 | ); | |
277 | ||
278 | typedef | |
279 | void | |
280 | (EFIAPI *UnixDisableInterruptEmulation) (void); | |
281 | ||
282 | typedef | |
283 | void | |
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 | |
291 | typedef 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 | ||
344 | extern EFI_GUID gEfiUnixThunkProtocolGuid; | |
345 | ||
346 | #endif |