]>
Commit | Line | Data |
---|---|---|
1 | /*++ | |
2 | ||
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 | |
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. | |
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 | ||
32 | #include <Common/UnixInclude.h> | |
33 | ||
34 | #include <Base.h> | |
35 | #include <Library/PeCoffLib.h> | |
36 | ||
37 | ||
38 | ||
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 | |
46 | (EFIAPI *UnixSleep) ( | |
47 | unsigned long Milliseconds | |
48 | ); | |
49 | ||
50 | typedef | |
51 | VOID | |
52 | (EFIAPI *UnixExit) ( | |
53 | int status // exit code for all threads | |
54 | ); | |
55 | ||
56 | typedef | |
57 | VOID | |
58 | (EFIAPI *UnixSetTimer) ( | |
59 | UINT64 PeriodMs, | |
60 | VOID (EFIAPI *CallBack)(UINT64 DeltaMs) | |
61 | ); | |
62 | ||
63 | typedef | |
64 | VOID | |
65 | (EFIAPI *UnixGetLocalTime) ( | |
66 | EFI_TIME *Time | |
67 | ); | |
68 | ||
69 | typedef | |
70 | struct tm * | |
71 | (EFIAPI *UnixGmTime)( | |
72 | const time_t *timep | |
73 | ); | |
74 | ||
75 | typedef | |
76 | long | |
77 | (EFIAPI *UnixGetTimeZone)( | |
78 | void | |
79 | ); | |
80 | ||
81 | typedef | |
82 | int | |
83 | (EFIAPI *UnixGetDayLight)( | |
84 | void | |
85 | ); | |
86 | ||
87 | typedef | |
88 | int | |
89 | (EFIAPI *UnixPoll)( | |
90 | struct pollfd *pfd, | |
91 | unsigned int nfds, | |
92 | int timeout | |
93 | ); | |
94 | ||
95 | typedef | |
96 | long | |
97 | (EFIAPI *UnixRead) ( | |
98 | int fd, | |
99 | void *buf, | |
100 | int count | |
101 | ); | |
102 | ||
103 | typedef | |
104 | long | |
105 | (EFIAPI *UnixWrite) ( | |
106 | int fd, | |
107 | const void *buf, | |
108 | int count | |
109 | ); | |
110 | ||
111 | typedef | |
112 | char * | |
113 | (EFIAPI *UnixGetenv) (const char *var); | |
114 | ||
115 | typedef | |
116 | int | |
117 | (EFIAPI *UnixOpen) (const char *name, int flags, int mode); | |
118 | ||
119 | typedef | |
120 | off_t | |
121 | (EFIAPI *UnixSeek) (int fd, off_t off, int whence); | |
122 | ||
123 | typedef | |
124 | int | |
125 | (EFIAPI *UnixFtruncate) (int fd, long int len); | |
126 | ||
127 | typedef | |
128 | int | |
129 | (EFIAPI *UnixClose) (int fd); | |
130 | ||
131 | typedef | |
132 | int | |
133 | (EFIAPI *UnixMkdir)(const char *pathname, mode_t mode); | |
134 | ||
135 | typedef | |
136 | int | |
137 | (EFIAPI *UnixRmDir)(const char *pathname); | |
138 | ||
139 | typedef | |
140 | int | |
141 | (EFIAPI *UnixUnLink)(const char *pathname); | |
142 | ||
143 | typedef | |
144 | int | |
145 | (EFIAPI *UnixGetErrno)(VOID); | |
146 | ||
147 | typedef | |
148 | DIR * | |
149 | (EFIAPI *UnixOpenDir)(const char *pathname); | |
150 | ||
151 | typedef | |
152 | void | |
153 | (EFIAPI *UnixRewindDir)(DIR *dir); | |
154 | ||
155 | typedef | |
156 | struct dirent * | |
157 | (EFIAPI *UnixReadDir)(DIR *dir); | |
158 | ||
159 | typedef | |
160 | int | |
161 | (EFIAPI *UnixCloseDir)(DIR *dir); | |
162 | ||
163 | typedef | |
164 | int | |
165 | (EFIAPI *UnixStat)(const char *path, STAT_FIX *buf); | |
166 | ||
167 | typedef | |
168 | int | |
169 | (EFIAPI *UnixStatFs)(const char *path, struct statfs *buf); | |
170 | ||
171 | typedef | |
172 | int | |
173 | (EFIAPI *UnixRename)(const char *oldpath, const char *newpath); | |
174 | ||
175 | typedef | |
176 | time_t | |
177 | (EFIAPI *UnixMkTime)(struct tm *tm); | |
178 | ||
179 | typedef | |
180 | int | |
181 | (EFIAPI *UnixFSync)(int fd); | |
182 | ||
183 | typedef | |
184 | int | |
185 | (EFIAPI *UnixChmod)(const char *path, mode_t mode); | |
186 | ||
187 | typedef | |
188 | int | |
189 | (EFIAPI *UnixUTime)(const char *filename, const struct utimbuf *buf); | |
190 | ||
191 | struct _EFI_UNIX_UGA_IO_PROTOCOL; | |
192 | typedef | |
193 | EFI_STATUS | |
194 | (EFIAPI *UnixUgaCreate)(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo, | |
195 | CONST CHAR16 *Title); | |
196 | ||
197 | typedef | |
198 | int | |
199 | (EFIAPI *UnixTcflush) (int fildes, int queue_selector); | |
200 | ||
201 | typedef | |
202 | void | |
203 | (EFIAPI *UnixPerror) (__const char *__s); | |
204 | ||
205 | typedef | |
206 | int | |
207 | #if __CYGWIN__ | |
208 | (EFIAPI *UnixIoCtl) (int fd, int __request, UINTN Arg); | |
209 | #else | |
210 | (EFIAPI *UnixIoCtl) (int fd, unsigned long int __request, void *Arg); | |
211 | #endif | |
212 | ||
213 | typedef | |
214 | int | |
215 | (EFIAPI *UnixFcntl) (int __fd, int __cmd, void *Arg); | |
216 | ||
217 | typedef | |
218 | int | |
219 | (EFIAPI *UnixCfsetispeed) (struct termios *__termios_p, speed_t __speed); | |
220 | ||
221 | typedef | |
222 | int | |
223 | (EFIAPI *UnixCfsetospeed) (struct termios *__termios_p, speed_t __speed); | |
224 | ||
225 | typedef | |
226 | int | |
227 | (EFIAPI *UnixTcgetattr) (int __fd, struct termios *__termios_p); | |
228 | ||
229 | typedef | |
230 | int | |
231 | (EFIAPI *UnixTcsetattr) (int __fd, int __optional_actions, | |
232 | __const struct termios *__termios_p); | |
233 | ||
234 | ||
235 | // | |
236 | // Worker functions to enable source level debug in the emulator | |
237 | // | |
238 | ||
239 | typedef | |
240 | RETURN_STATUS | |
241 | (EFIAPI *UnixPeCoffGetEntryPoint) ( | |
242 | IN VOID *Pe32Data, | |
243 | IN OUT VOID **EntryPoint | |
244 | ); | |
245 | ||
246 | typedef | |
247 | VOID | |
248 | (EFIAPI *UnixPeCoffRelocateImageExtraAction) ( | |
249 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext | |
250 | ); | |
251 | ||
252 | typedef | |
253 | VOID | |
254 | (EFIAPI *UnixPeCoffLoaderUnloadImageExtraAction) ( | |
255 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext | |
256 | ); | |
257 | ||
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 | ||
287 | ||
288 | ||
289 | #define EFI_UNIX_THUNK_PROTOCOL_SIGNATURE SIGNATURE_32 ('L', 'N', 'X', 'T') | |
290 | ||
291 | typedef struct _EFI_UNIX_THUNK_PROTOCOL { | |
292 | UINT64 Signature; | |
293 | ||
294 | UnixSleep Sleep; | |
295 | UnixExit Exit; | |
296 | UnixSetTimer SetTimer; | |
297 | UnixGetLocalTime GetLocalTime; | |
298 | UnixGmTime GmTime; | |
299 | UnixGetTimeZone GetTimeZone; | |
300 | UnixGetDayLight GetDayLight; | |
301 | UnixPoll Poll; | |
302 | UnixRead Read; | |
303 | UnixWrite Write; | |
304 | UnixGetenv Getenv; | |
305 | UnixOpen Open; | |
306 | UnixSeek Lseek; | |
307 | UnixFtruncate FTruncate; | |
308 | UnixClose Close; | |
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; | |
325 | UnixUgaCreate UgaCreate; | |
326 | UnixPerror Perror; | |
327 | UnixIoCtl IoCtl; | |
328 | UnixFcntl Fcntl; | |
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; | |
338 | ||
339 | UnixGetIfAddrs GetIfAddrs; | |
340 | UnixFreeIfAddrs FreeIfAddrs; | |
341 | UnixSocket Socket; | |
342 | } EFI_UNIX_THUNK_PROTOCOL; | |
343 | ||
344 | extern EFI_GUID gEfiUnixThunkProtocolGuid; | |
345 | ||
346 | #endif |