]>
Commit | Line | Data |
---|---|---|
804405e7 | 1 | /*++ |
2 | ||
ccd55824 | 3 | Copyright (c) 2004 - 2009, Intel Corporation |
4 | Portions copyright (c) 2008-2009 Apple Inc.<BR> | |
804405e7 | 5 | All rights reserved. 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 <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 | ||
75 | typedef | |
76 | VOID | |
77 | (*UnixSleep) ( | |
78 | unsigned long Milliseconds | |
79 | ); | |
80 | ||
81 | typedef | |
82 | VOID | |
83 | (*UnixExit) ( | |
84 | int status // exit code for all threads | |
85 | ); | |
86 | ||
87 | typedef | |
88 | VOID | |
89 | (*UnixSetTimer) (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs)); | |
90 | typedef | |
91 | VOID | |
92 | (*UnixGetLocalTime) (EFI_TIME *Time); | |
93 | typedef | |
94 | struct tm * | |
95 | (*UnixGmTime)(const time_t *timep); | |
96 | typedef | |
97 | long | |
98 | (*UnixGetTimeZone)(void); | |
99 | typedef | |
100 | int | |
101 | (*UnixGetDayLight)(void); | |
102 | typedef | |
103 | int | |
104 | (*UnixPoll)(struct pollfd *pfd, int nfds, int timeout); | |
105 | typedef | |
106 | int | |
107 | (*UnixRead) (int fd, void *buf, int count); | |
108 | typedef | |
109 | int | |
110 | (*UnixWrite) (int fd, const void *buf, int count); | |
111 | typedef | |
112 | char * | |
113 | (*UnixGetenv) (const char *var); | |
114 | typedef | |
115 | int | |
116 | (*UnixOpen) (const char *name, int flags, int mode); | |
117 | typedef | |
118 | long int | |
119 | (*UnixSeek) (int fd, long int off, int whence); | |
120 | typedef | |
121 | int | |
122 | (*UnixFtruncate) (int fd, long int len); | |
123 | typedef | |
124 | int | |
125 | (*UnixClose) (int fd); | |
126 | ||
127 | typedef | |
128 | int | |
129 | (*UnixMkdir)(const char *pathname, mode_t mode); | |
130 | typedef | |
131 | int | |
132 | (*UnixRmDir)(const char *pathname); | |
133 | typedef | |
134 | int | |
135 | (*UnixUnLink)(const char *pathname); | |
136 | typedef | |
137 | int | |
138 | (*UnixGetErrno)(VOID); | |
139 | typedef | |
140 | DIR * | |
141 | (*UnixOpenDir)(const char *pathname); | |
142 | typedef | |
143 | void | |
144 | (*UnixRewindDir)(DIR *dir); | |
145 | typedef | |
146 | struct dirent * | |
147 | (*UnixReadDir)(DIR *dir); | |
148 | typedef | |
149 | int | |
150 | (*UnixCloseDir)(DIR *dir); | |
151 | typedef | |
152 | int | |
153 | (*UnixStat)(const char *path, struct stat *buf); | |
154 | typedef | |
155 | int | |
156 | (*UnixStatFs)(const char *path, struct statfs *buf); | |
157 | typedef | |
158 | int | |
159 | (*UnixRename)(const char *oldpath, const char *newpath); | |
160 | typedef | |
161 | time_t | |
162 | (*UnixMkTime)(struct tm *tm); | |
163 | typedef | |
164 | int | |
165 | (*UnixFSync)(int fd); | |
166 | typedef | |
167 | int | |
168 | (*UnixChmod)(const char *path, mode_t mode); | |
169 | typedef | |
170 | int | |
171 | (*UnixUTime)(const char *filename, const struct utimbuf *buf); | |
172 | ||
173 | struct _EFI_UNIX_UGA_IO_PROTOCOL; | |
174 | typedef | |
175 | EFI_STATUS | |
176 | (*UnixUgaCreate)(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo, | |
177 | CONST CHAR16 *Title); | |
178 | ||
179 | typedef | |
180 | int | |
181 | (*UnixTcflush) (int fildes, int queue_selector); | |
182 | ||
183 | typedef | |
184 | void | |
185 | (*UnixPerror) (__const char *__s); | |
186 | ||
187 | typedef | |
188 | int | |
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 | |
195 | typedef | |
196 | int | |
197 | (*UnixFcntl) (int __fd, int __cmd, ...); | |
198 | ||
199 | typedef | |
200 | int | |
201 | (*UnixCfsetispeed) (struct termios *__termios_p, speed_t __speed); | |
202 | ||
203 | typedef | |
204 | int | |
205 | (*UnixCfsetospeed) (struct termios *__termios_p, speed_t __speed); | |
206 | ||
207 | typedef | |
208 | int | |
209 | (*UnixTcgetattr) (int __fd, struct termios *__termios_p); | |
210 | ||
211 | typedef | |
212 | int | |
213 | (*UnixTcsetattr) (int __fd, int __optional_actions, | |
214 | __const struct termios *__termios_p); | |
215 | ||
398b646f | 216 | typedef |
217 | VOID * | |
218 | (*UnixDlopen) (const char *FileName, int Flag); | |
219 | ||
220 | typedef | |
221 | char * | |
222 | (*UnixDlerror) (VOID); | |
223 | ||
224 | typedef | |
225 | VOID * | |
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 | |
233 | typedef | |
234 | RETURN_STATUS | |
235 | (EFIAPI *UnixPeCoffGetEntryPoint) ( | |
236 | IN VOID *Pe32Data, | |
237 | IN OUT VOID **EntryPoint | |
238 | ); | |
239 | ||
240 | typedef | |
241 | VOID | |
242 | (EFIAPI *UnixPeCoffRelocateImageExtraAction) ( | |
243 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext | |
244 | ); | |
245 | ||
246 | typedef | |
247 | VOID | |
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 | |
256 | typedef 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 | ||
308 | extern EFI_GUID gEfiUnixThunkProtocolGuid; | |
309 | ||
310 | #endif |