]>
Commit | Line | Data |
---|---|---|
5af06fe3 A |
1 | /** @file\r |
2 | \r | |
2ff79f2e | 3 | Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r |
5af06fe3 | 4 | \r |
f9b8ab56 | 5 | This program and the accompanying materials\r |
5af06fe3 A |
6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #ifdef __APPLE__\r | |
7ee3b613 A |
16 | \r |
17 | #include "SecMain.h"\r | |
18 | #include "Gasket.h"\r | |
19 | \r | |
20 | //\r | |
21 | // Gasket functions for EFI_UNIX_THUNK_PROTOCOL\r | |
22 | //\r | |
23 | \r | |
24 | void \r | |
25 | GasketmsSleep (unsigned long Milliseconds)\r | |
26 | { \r | |
27 | GasketUintn (msSleep, Milliseconds);\r | |
28 | return;\r | |
29 | }\r | |
30 | \r | |
31 | void \r | |
32 | Gasketexit (int status)\r | |
33 | {\r | |
34 | GasketUintn (exit, status);\r | |
35 | return;\r | |
36 | }\r | |
37 | \r | |
38 | \r | |
39 | void \r | |
40 | GasketSetTimer (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs))\r | |
41 | {\r | |
42 | GasketUint64Uintn (SetTimer, PeriodMs, (UINTN)CallBack);\r | |
43 | return;\r | |
44 | }\r | |
45 | \r | |
46 | \r | |
47 | void \r | |
48 | GasketGetLocalTime (EFI_TIME *Time)\r | |
49 | {\r | |
50 | GasketUintn (GetLocalTime, (UINTN)Time);\r | |
51 | return;\r | |
52 | }\r | |
53 | \r | |
54 | \r | |
55 | struct tm *\r | |
56 | Gasketgmtime (const time_t *clock)\r | |
57 | {\r | |
58 | return (struct tm *)(UINTN)GasketUintn (localtime, (UINTN)clock);\r | |
59 | }\r | |
60 | \r | |
61 | \r | |
62 | long \r | |
63 | GasketGetTimeZone (void)\r | |
64 | {\r | |
65 | return GasketVoid (GetTimeZone);\r | |
66 | }\r | |
67 | \r | |
68 | \r | |
69 | int \r | |
70 | GasketGetDayLight (void)\r | |
71 | {\r | |
72 | return GasketVoid (GetDayLight);\r | |
73 | }\r | |
74 | \r | |
75 | \r | |
76 | int \r | |
b9c8e50e | 77 | Gasketpoll (struct pollfd *pfd, unsigned int nfds, int timeout)\r |
7ee3b613 A |
78 | {\r |
79 | return GasketUintnUintnUintn (poll, (UINTN)pfd, nfds, timeout);\r | |
80 | }\r | |
81 | \r | |
82 | \r | |
b9c8e50e | 83 | long\r |
7ee3b613 A |
84 | Gasketread (int fd, void *buf, int count)\r |
85 | {\r | |
86 | return GasketUintnUintnUintn (read, fd, (UINTN)buf, count);\r | |
87 | }\r | |
88 | \r | |
89 | \r | |
b9c8e50e | 90 | long\r |
7ee3b613 A |
91 | Gasketwrite (int fd, const void *buf, int count)\r |
92 | {\r | |
93 | return GasketUintnUintnUintn (write, fd, (UINTN)buf, count);\r | |
94 | }\r | |
95 | \r | |
96 | \r | |
97 | char *\r | |
98 | Gasketgetenv (const char *name)\r | |
99 | {\r | |
100 | return (char *)(UINTN)GasketUintn (getenv, (UINTN)name);\r | |
101 | }\r | |
102 | \r | |
103 | \r | |
104 | int \r | |
105 | Gasketopen (const char *name, int flags, int mode)\r | |
106 | {\r | |
107 | return GasketUintnUintnUintn (open, (UINTN)name, flags, mode);\r | |
108 | }\r | |
109 | \r | |
110 | \r | |
111 | off_t \r | |
112 | Gasketlseek (int fd, off_t off, int whence)\r | |
113 | {\r | |
114 | if (sizeof off == 8) {\r | |
115 | return GasketUintnUint64Uintn (lseek, fd, off, whence);\r | |
116 | } else if (sizeof off == 4) {\r | |
117 | return GasketUintnUintnUintn (lseek, fd, off, whence);\r | |
118 | }\r | |
119 | }\r | |
120 | \r | |
121 | \r | |
122 | int \r | |
123 | Gasketftruncate (int fd, long int len)\r | |
124 | {\r | |
125 | return GasketUintnUintn (ftruncate, fd, len);\r | |
126 | }\r | |
127 | \r | |
128 | \r | |
129 | int \r | |
130 | Gasketclose (int fd)\r | |
131 | {\r | |
132 | return GasketUintn (close, fd);\r | |
133 | }\r | |
134 | \r | |
135 | \r | |
136 | int \r | |
137 | Gasketmkdir (const char *pathname, mode_t mode)\r | |
138 | {\r | |
139 | return GasketUintnUint16 (mkdir, (UINTN)pathname, mode);\r | |
140 | }\r | |
141 | \r | |
142 | \r | |
143 | int \r | |
144 | Gasketrmdir (const char *pathname)\r | |
145 | {\r | |
146 | return GasketUintn (rmdir, (UINTN)pathname);\r | |
147 | }\r | |
148 | \r | |
149 | \r | |
150 | int \r | |
151 | Gasketunlink (const char *pathname)\r | |
152 | {\r | |
153 | return GasketUintn (unlink, (UINTN)pathname);\r | |
154 | }\r | |
155 | \r | |
156 | \r | |
157 | int \r | |
158 | GasketGetErrno (void)\r | |
159 | {\r | |
160 | return GasketVoid (GetErrno);\r | |
161 | }\r | |
162 | \r | |
163 | \r | |
164 | DIR *\r | |
165 | Gasketopendir (const char *pathname)\r | |
166 | {\r | |
167 | return (DIR *)(UINTN)GasketUintn (opendir, (UINTN)pathname);\r | |
168 | }\r | |
169 | \r | |
170 | \r | |
b9c8e50e | 171 | void \r |
7ee3b613 A |
172 | Gasketrewinddir (DIR *dir)\r |
173 | {\r | |
b9c8e50e | 174 | GasketUintn (rewinddir, (UINTN)dir);\r |
175 | return;\r | |
7ee3b613 A |
176 | }\r |
177 | \r | |
178 | \r | |
179 | struct dirent *\r | |
180 | Gasketreaddir (DIR *dir)\r | |
181 | {\r | |
182 | return (struct dirent *)(UINTN)GasketUintn (readdir, (UINTN)dir);\r | |
183 | }\r | |
184 | \r | |
185 | \r | |
186 | int \r | |
187 | Gasketclosedir (DIR *dir)\r | |
188 | {\r | |
189 | return GasketUintn (closedir, (UINTN)dir);\r | |
190 | }\r | |
191 | \r | |
192 | \r | |
193 | int \r | |
194 | Gasketstat (const char *path, STAT_FIX *buf)\r | |
195 | {\r | |
196 | return GasketUintnUintn (stat, (UINTN)path, (UINTN)buf);\r | |
197 | }\r | |
198 | \r | |
199 | \r | |
200 | int \r | |
201 | Gasketstatfs (const char *path, struct statfs *buf)\r | |
202 | {\r | |
203 | return GasketUintnUintn (statfs, (UINTN)path, (UINTN)buf);\r | |
204 | }\r | |
205 | \r | |
206 | \r | |
207 | int \r | |
208 | Gasketrename (const char *oldpath, const char *newpath)\r | |
209 | {\r | |
210 | return GasketUintnUintn (rename, (UINTN)oldpath, (UINTN)newpath);\r | |
211 | }\r | |
212 | \r | |
213 | \r | |
214 | time_t \r | |
215 | Gasketmktime (struct tm *tm)\r | |
216 | {\r | |
217 | return GasketUintn (mktime, (UINTN)tm);\r | |
218 | }\r | |
219 | \r | |
220 | \r | |
221 | int \r | |
222 | Gasketfsync (int fd)\r | |
223 | {\r | |
224 | return GasketUintn (fsync, fd);\r | |
225 | }\r | |
226 | \r | |
227 | \r | |
228 | int \r | |
229 | Gasketchmod (const char *path, mode_t mode)\r | |
230 | {\r | |
231 | return GasketUintnUint16 (chmod, (UINTN)path, mode);\r | |
232 | }\r | |
233 | \r | |
234 | \r | |
235 | int \r | |
236 | Gasketutime (const char *filename, const struct utimbuf *buf)\r | |
237 | {\r | |
238 | return GasketUintnUintn (utime, (UINTN)filename, (UINTN)buf);\r | |
239 | }\r | |
240 | \r | |
241 | \r | |
242 | int \r | |
243 | Gaskettcflush (int fildes, int queue_selector)\r | |
244 | {\r | |
245 | return GasketUintnUintn (tcflush, fildes, queue_selector);\r | |
246 | }\r | |
247 | \r | |
248 | \r | |
249 | EFI_STATUS \r | |
250 | GasketUgaCreate (struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo, CONST CHAR16 *Title)\r | |
251 | {\r | |
252 | return GasketUintnUintn (UgaCreate, (UINTN)UgaIo, (UINTN)Title);\r | |
253 | }\r | |
254 | \r | |
255 | \r | |
256 | void \r | |
257 | Gasketperror (__const char *__s)\r | |
258 | {\r | |
259 | GasketUintn (perror, (UINTN)__s);\r | |
260 | return;\r | |
261 | }\r | |
262 | \r | |
263 | \r | |
264 | \r | |
265 | //\r | |
266 | // ... is always an int or pointer to device specific data structure\r | |
267 | //\r | |
268 | int \r | |
a4902ccc | 269 | Gasketioctl (int fd, unsigned long int __request, void *Arg)\r |
7ee3b613 | 270 | {\r |
a4902ccc | 271 | return GasketUintnUintnUintn (ioctl, fd, __request, (UINTN)Arg);\r |
7ee3b613 A |
272 | }\r |
273 | \r | |
274 | \r | |
275 | int \r | |
a4902ccc | 276 | Gasketfcntl (int __fd, int __cmd, void *Arg)\r |
7ee3b613 | 277 | {\r |
a4902ccc | 278 | return GasketUintnUintnUintn (fcntl, __fd, __cmd, (UINTN)Arg);\r |
7ee3b613 A |
279 | }\r |
280 | \r | |
281 | \r | |
282 | \r | |
283 | int \r | |
284 | Gasketcfsetispeed (struct termios *__termios_p, speed_t __speed)\r | |
285 | {\r | |
286 | return GasketUintnUintn (cfsetispeed, (UINTN)__termios_p, __speed);\r | |
287 | }\r | |
288 | \r | |
289 | \r | |
290 | int \r | |
291 | Gasketcfsetospeed (struct termios *__termios_p, speed_t __speed)\r | |
292 | {\r | |
293 | return GasketUintnUintn (cfsetospeed, (UINTN)__termios_p, __speed);\r | |
294 | }\r | |
295 | \r | |
296 | \r | |
297 | int \r | |
298 | Gaskettcgetattr (int __fd, struct termios *__termios_p)\r | |
299 | {\r | |
300 | return GasketUintnUintn (tcgetattr, __fd, (UINTN)__termios_p);\r | |
301 | }\r | |
302 | \r | |
303 | \r | |
304 | int \r | |
305 | Gaskettcsetattr (int __fd, int __optional_actions, __const struct termios *__termios_p)\r | |
306 | {\r | |
307 | return GasketUintnUintnUintn (tcsetattr, __fd, __optional_actions, (UINTN)__termios_p);\r | |
308 | }\r | |
309 | \r | |
310 | \r | |
7ee3b613 A |
311 | \r |
312 | \r | |
313 | RETURN_STATUS\r | |
314 | GasketUnixPeCoffGetEntryPoint (\r | |
315 | IN VOID *Pe32Data,\r | |
316 | IN OUT VOID **EntryPoint\r | |
317 | )\r | |
318 | {\r | |
319 | return GasketUintnUintn (SecPeCoffGetEntryPoint, (UINTN)Pe32Data, (UINTN)EntryPoint);\r | |
320 | }\r | |
321 | \r | |
322 | \r | |
323 | \r | |
324 | VOID\r | |
325 | GasketUnixPeCoffRelocateImageExtraAction (\r | |
326 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
327 | )\r | |
328 | {\r | |
329 | GasketUintn (SecPeCoffRelocateImageExtraAction, (UINTN)ImageContext);\r | |
330 | return;\r | |
331 | }\r | |
332 | \r | |
333 | \r | |
334 | \r | |
335 | VOID\r | |
b9c8e50e | 336 | GasketUnixPeCoffUnloadImageExtraAction (\r |
7ee3b613 A |
337 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r |
338 | )\r | |
339 | {\r | |
340 | GasketUintn (SecPeCoffLoaderUnloadImageExtraAction, (UINTN)ImageContext);\r | |
341 | return;\r | |
342 | }\r | |
343 | \r | |
344 | \r | |
345 | //\r | |
346 | // Gasket functions for EFI_UNIX_UGA_IO_PROTOCOL\r | |
347 | //\r | |
348 | \r | |
349 | EFI_STATUS \r | |
350 | EFIAPI \r | |
351 | GasketUgaClose (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)\r | |
352 | {\r | |
353 | return GasketUintn (UgaClose, (UINTN)UgaIo);\r | |
354 | }\r | |
355 | \r | |
356 | EFI_STATUS \r | |
357 | EFIAPI \r | |
358 | GasketUgaSize (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, UINT32 Width, UINT32 Height)\r | |
359 | {\r | |
360 | return GasketUintnUintnUintn (UgaSize, (UINTN)UgaIo, Width, Height);\r | |
361 | }\r | |
362 | \r | |
363 | EFI_STATUS \r | |
364 | EFIAPI \r | |
365 | GasketUgaCheckKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)\r | |
366 | {\r | |
367 | return GasketUintn (UgaCheckKey, (UINTN)UgaIo);\r | |
368 | }\r | |
369 | \r | |
370 | EFI_STATUS \r | |
371 | EFIAPI \r | |
2ff79f2e | 372 | GasketUgaKeySetState (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_KEY_TOGGLE_STATE *KeyToggleState)\r |
373 | {\r | |
374 | return GasketUintnUintn (UgaGetKey, (UINTN)UgaIo, (UINTN)KeyToggleState);\r | |
375 | }\r | |
376 | \r | |
377 | EFI_STATUS \r | |
378 | EFIAPI \r | |
379 | GasketUgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_KEY_DATA *key)\r | |
7ee3b613 A |
380 | {\r |
381 | return GasketUintnUintn (UgaGetKey, (UINTN)UgaIo, (UINTN)key);\r | |
382 | }\r | |
383 | \r | |
2ff79f2e | 384 | EFI_STATUS \r |
385 | EFIAPI \r | |
386 | GasketUgaRegisterKeyNotify (\r | |
387 | IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, \r | |
388 | IN UGA_REGISTER_KEY_NOTIFY_CALLBACK CallBack,\r | |
389 | IN VOID *Context\r | |
390 | )\r | |
391 | {\r | |
392 | return GasketUintnUintnUintn (UgaRegisterKeyNotify, (UINTN)UgaIo, (UINTN)CallBack, (UINTN)Context); \r | |
393 | }\r | |
394 | \r | |
7ee3b613 A |
395 | EFI_STATUS \r |
396 | EFIAPI \r | |
397 | GasketUgaBlt (\r | |
398 | EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,\r | |
399 | IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,\r | |
400 | IN EFI_UGA_BLT_OPERATION BltOperation,\r | |
2ac288f9 | 401 | IN UGA_BLT_ARGS *Args\r |
7ee3b613 A |
402 | )\r |
403 | {\r | |
2ff79f2e | 404 | return GasketUintnUintnUintnUintn (UgaBlt, (UINTN)UgaIo, (UINTN)BltBuffer, (UINTN)BltOperation, (UINTN)Args);\r |
405 | }\r | |
406 | \r | |
407 | EFI_STATUS \r | |
408 | EFIAPI \r | |
409 | GasketUgaCheckPointer (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)\r | |
410 | {\r | |
411 | return GasketUintn (UgaCheckPointer, (UINTN)UgaIo);\r | |
412 | }\r | |
413 | \r | |
414 | EFI_STATUS \r | |
415 | EFIAPI \r | |
416 | GasketUgaGetPointerState (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_SIMPLE_POINTER_STATE *state)\r | |
417 | {\r | |
418 | return GasketUintnUintn (UgaGetPointerState, (UINTN)UgaIo, (UINTN)state);\r | |
419 | }\r | |
420 | \r | |
421 | void\r | |
422 | GasketUnixEnableInterrupt (void)\r | |
423 | {\r | |
424 | GasketVoid (UnixEnableInterrupt);\r | |
425 | }\r | |
426 | \r | |
427 | void\r | |
428 | GasketUnixDisableInterrupt (void)\r | |
429 | {\r | |
430 | GasketVoid (UnixDisableInterrupt);\r | |
431 | }\r | |
432 | \r | |
433 | \r | |
434 | int\r | |
435 | Gasketgetifaddrs (struct ifaddrs **ifap)\r | |
436 | {\r | |
437 | return( GasketUintn( getifaddrs, ( UINTN ) ifap ) );\r | |
438 | }\r | |
439 | \r | |
440 | \r | |
441 | void\r | |
442 | Gasketfreeifaddrs (struct ifaddrs *ifap)\r | |
443 | {\r | |
444 | GasketUintn( freeifaddrs, ( UINTN ) ifap );\r | |
7ee3b613 A |
445 | }\r |
446 | \r | |
2ff79f2e | 447 | \r |
448 | int\r | |
449 | Gasketsocket (int domain, int type, int protocol )\r | |
450 | {\r | |
451 | return( GasketUintnUintnUintn( socket, domain, type, protocol ) );\r | |
452 | }\r | |
453 | \r | |
454 | \r | |
5af06fe3 A |
455 | #endif\r |
456 | \r |