]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | \r | |
3 | Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r | |
4 | \r | |
5 | This program and the accompanying materials\r | |
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 | #include "SecMain.h"\r | |
16 | #include "Gasket.h"\r | |
17 | \r | |
18 | //\r | |
19 | // OS X Posix does some strange name mangling on these names in C.\r | |
20 | // If you call from assembler you get the wrong version of the function\r | |
21 | // So these globals get you the correct name mangled functions that can\r | |
22 | // be accessed from assembly\r | |
23 | // \r | |
24 | extern UnixRmDir gUnixRmDir;\r | |
25 | extern UnixOpenDir gUnixOpenDir;\r | |
26 | extern UnixStat gUnixStat;\r | |
27 | extern UnixStatFs gUnixStatFs;\r | |
28 | \r | |
29 | //\r | |
30 | // Gasket functions for EFI_UNIX_THUNK_PROTOCOL\r | |
31 | //\r | |
32 | \r | |
33 | int \r | |
34 | Gasketrmdir (const char *pathname)\r | |
35 | {\r | |
36 | return gUnixRmDir (pathname);\r | |
37 | }\r | |
38 | \r | |
39 | \r | |
40 | DIR *\r | |
41 | Gasketopendir (const char *pathname)\r | |
42 | {\r | |
43 | return gUnixOpenDir (pathname);\r | |
44 | }\r | |
45 | \r | |
46 | \r | |
47 | int \r | |
48 | Gasketstat (const char *path, STAT_FIX *buf)\r | |
49 | {\r | |
50 | return gUnixStat (path, buf);\r | |
51 | }\r | |
52 | \r | |
53 | \r | |
54 | int \r | |
55 | Gasketstatfs (const char *path, struct statfs *buf)\r | |
56 | {\r | |
57 | return gUnixStatFs (path, buf);\r | |
58 | }\r | |
59 | \r | |
60 | /////\r | |
61 | \r | |
62 | \r | |
63 | void \r | |
64 | GasketmsSleep (unsigned long Milliseconds)\r | |
65 | { \r | |
66 | msSleep (Milliseconds);\r | |
67 | return;\r | |
68 | }\r | |
69 | \r | |
70 | void \r | |
71 | Gasketexit (int status)\r | |
72 | {\r | |
73 | exit (status);\r | |
74 | return;\r | |
75 | }\r | |
76 | \r | |
77 | \r | |
78 | void \r | |
79 | GasketSetTimer (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs))\r | |
80 | {\r | |
81 | SetTimer (PeriodMs, CallBack);\r | |
82 | return;\r | |
83 | }\r | |
84 | \r | |
85 | \r | |
86 | void \r | |
87 | GasketGetLocalTime (EFI_TIME *Time)\r | |
88 | {\r | |
89 | GetLocalTime (Time);\r | |
90 | return;\r | |
91 | }\r | |
92 | \r | |
93 | \r | |
94 | struct tm *\r | |
95 | Gasketgmtime (const time_t *clock)\r | |
96 | {\r | |
97 | return localtime (clock);\r | |
98 | }\r | |
99 | \r | |
100 | \r | |
101 | long \r | |
102 | GasketGetTimeZone (void)\r | |
103 | {\r | |
104 | return GetTimeZone ();\r | |
105 | }\r | |
106 | \r | |
107 | \r | |
108 | int \r | |
109 | GasketGetDayLight (void)\r | |
110 | {\r | |
111 | return GetDayLight ();\r | |
112 | }\r | |
113 | \r | |
114 | \r | |
115 | int \r | |
116 | Gasketpoll (struct pollfd *pfd, unsigned int nfds, int timeout)\r | |
117 | {\r | |
118 | return poll (pfd, nfds, timeout);\r | |
119 | }\r | |
120 | \r | |
121 | \r | |
122 | long\r | |
123 | Gasketread (int fd, void *buf, int count)\r | |
124 | {\r | |
125 | return read (fd, buf, count);\r | |
126 | }\r | |
127 | \r | |
128 | \r | |
129 | long\r | |
130 | Gasketwrite (int fd, const void *buf, int count)\r | |
131 | {\r | |
132 | return write (fd, buf, count);\r | |
133 | }\r | |
134 | \r | |
135 | \r | |
136 | char *\r | |
137 | Gasketgetenv (const char *name)\r | |
138 | {\r | |
139 | return getenv (name);\r | |
140 | }\r | |
141 | \r | |
142 | \r | |
143 | int \r | |
144 | Gasketopen (const char *name, int flags, int mode)\r | |
145 | {\r | |
146 | return open (name, flags, mode);\r | |
147 | }\r | |
148 | \r | |
149 | \r | |
150 | off_t \r | |
151 | Gasketlseek (int fd, off_t off, int whence)\r | |
152 | {\r | |
153 | return lseek (fd, off, whence);\r | |
154 | }\r | |
155 | \r | |
156 | \r | |
157 | int \r | |
158 | Gasketftruncate (int fd, long int len)\r | |
159 | {\r | |
160 | return ftruncate (fd, len);\r | |
161 | }\r | |
162 | \r | |
163 | \r | |
164 | int \r | |
165 | Gasketclose (int fd)\r | |
166 | {\r | |
167 | return close (fd);\r | |
168 | }\r | |
169 | \r | |
170 | \r | |
171 | int \r | |
172 | Gasketmkdir (const char *pathname, mode_t mode)\r | |
173 | {\r | |
174 | return mkdir (pathname, mode);\r | |
175 | }\r | |
176 | \r | |
177 | \r | |
178 | int \r | |
179 | Gasketunlink (const char *pathname)\r | |
180 | {\r | |
181 | return unlink (pathname);\r | |
182 | }\r | |
183 | \r | |
184 | \r | |
185 | int \r | |
186 | GasketGetErrno (void)\r | |
187 | {\r | |
188 | return GetErrno ();\r | |
189 | }\r | |
190 | \r | |
191 | \r | |
192 | void \r | |
193 | Gasketrewinddir (DIR *dir)\r | |
194 | {\r | |
195 | rewinddir (dir);\r | |
196 | return;\r | |
197 | }\r | |
198 | \r | |
199 | \r | |
200 | struct dirent *\r | |
201 | Gasketreaddir (DIR *dir)\r | |
202 | {\r | |
203 | return readdir (dir);\r | |
204 | }\r | |
205 | \r | |
206 | \r | |
207 | int \r | |
208 | Gasketclosedir (DIR *dir)\r | |
209 | {\r | |
210 | return closedir (dir);\r | |
211 | }\r | |
212 | \r | |
213 | \r | |
214 | int \r | |
215 | Gasketrename (const char *oldpath, const char *newpath)\r | |
216 | {\r | |
217 | return rename (oldpath, newpath);\r | |
218 | }\r | |
219 | \r | |
220 | \r | |
221 | time_t \r | |
222 | Gasketmktime (struct tm *tm)\r | |
223 | {\r | |
224 | return mktime (tm);\r | |
225 | }\r | |
226 | \r | |
227 | \r | |
228 | int \r | |
229 | Gasketfsync (int fd)\r | |
230 | {\r | |
231 | return fsync (fd);\r | |
232 | }\r | |
233 | \r | |
234 | \r | |
235 | int \r | |
236 | Gasketchmod (const char *path, mode_t mode)\r | |
237 | {\r | |
238 | return chmod (path, mode);\r | |
239 | }\r | |
240 | \r | |
241 | \r | |
242 | int \r | |
243 | Gasketutime (const char *filename, const struct utimbuf *buf)\r | |
244 | {\r | |
245 | return utime (filename, buf);\r | |
246 | }\r | |
247 | \r | |
248 | \r | |
249 | int \r | |
250 | Gaskettcflush (int fildes, int queue_selector)\r | |
251 | {\r | |
252 | return tcflush (fildes, queue_selector);\r | |
253 | }\r | |
254 | \r | |
255 | \r | |
256 | EFI_STATUS \r | |
257 | GasketUgaCreate (struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo, CONST CHAR16 *Title)\r | |
258 | {\r | |
259 | return UgaCreate (UgaIo, Title);\r | |
260 | }\r | |
261 | \r | |
262 | \r | |
263 | void \r | |
264 | Gasketperror (__const char *__s)\r | |
265 | {\r | |
266 | perror (__s);\r | |
267 | return;\r | |
268 | }\r | |
269 | \r | |
270 | \r | |
271 | \r | |
272 | //\r | |
273 | // ... is always an int or pointer to device specific data structure\r | |
274 | //\r | |
275 | int \r | |
276 | Gasketioctl (int fd, unsigned long int __request, ...)\r | |
277 | {\r | |
278 | VA_LIST Marker;\r | |
279 | \r | |
280 | VA_START (Marker, __request);\r | |
281 | return ioctl (fd, __request, VA_ARG (Marker, UINTN));\r | |
282 | }\r | |
283 | \r | |
284 | \r | |
285 | int \r | |
286 | Gasketfcntl (int __fd, int __cmd, ...)\r | |
287 | {\r | |
288 | VA_LIST Marker;\r | |
289 | \r | |
290 | VA_START (Marker, __cmd);\r | |
291 | return fcntl (__fd, __cmd, VA_ARG (Marker, UINTN));\r | |
292 | }\r | |
293 | \r | |
294 | \r | |
295 | \r | |
296 | int \r | |
297 | Gasketcfsetispeed (struct termios *__termios_p, speed_t __speed)\r | |
298 | {\r | |
299 | return cfsetispeed (__termios_p, __speed);\r | |
300 | }\r | |
301 | \r | |
302 | \r | |
303 | int \r | |
304 | Gasketcfsetospeed (struct termios *__termios_p, speed_t __speed)\r | |
305 | {\r | |
306 | return cfsetospeed (__termios_p, __speed);\r | |
307 | }\r | |
308 | \r | |
309 | \r | |
310 | int \r | |
311 | Gaskettcgetattr (int __fd, struct termios *__termios_p)\r | |
312 | {\r | |
313 | return tcgetattr (__fd, __termios_p);\r | |
314 | }\r | |
315 | \r | |
316 | \r | |
317 | int \r | |
318 | Gaskettcsetattr (int __fd, int __optional_actions, __const struct termios *__termios_p)\r | |
319 | {\r | |
320 | return tcsetattr (__fd, __optional_actions, __termios_p);\r | |
321 | }\r | |
322 | \r | |
323 | \r | |
324 | \r | |
325 | \r | |
326 | RETURN_STATUS\r | |
327 | GasketUnixPeCoffGetEntryPoint (\r | |
328 | IN VOID *Pe32Data,\r | |
329 | IN OUT VOID **EntryPoint\r | |
330 | )\r | |
331 | {\r | |
332 | return SecPeCoffGetEntryPoint (Pe32Data, EntryPoint);\r | |
333 | }\r | |
334 | \r | |
335 | \r | |
336 | \r | |
337 | VOID\r | |
338 | GasketUnixPeCoffRelocateImageExtraAction (\r | |
339 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
340 | )\r | |
341 | {\r | |
342 | SecPeCoffRelocateImageExtraAction (ImageContext);\r | |
343 | return;\r | |
344 | }\r | |
345 | \r | |
346 | \r | |
347 | \r | |
348 | VOID\r | |
349 | GasketUnixPeCoffUnloadImageExtraAction (\r | |
350 | IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r | |
351 | )\r | |
352 | {\r | |
353 | SecPeCoffLoaderUnloadImageExtraAction (ImageContext);\r | |
354 | return;\r | |
355 | }\r | |
356 | \r | |
357 | \r | |
358 | //\r | |
359 | // Gasket functions for EFI_UNIX_UGA_IO_PROTOCOL\r | |
360 | //\r | |
361 | \r | |
362 | EFI_STATUS \r | |
363 | EFIAPI \r | |
364 | GasketUgaClose (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)\r | |
365 | {\r | |
366 | return UgaClose (UgaIo);\r | |
367 | }\r | |
368 | \r | |
369 | EFI_STATUS \r | |
370 | EFIAPI \r | |
371 | GasketUgaSize (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, UINT32 Width, UINT32 Height)\r | |
372 | {\r | |
373 | return UgaSize (UgaIo, Width, Height);\r | |
374 | }\r | |
375 | \r | |
376 | EFI_STATUS \r | |
377 | EFIAPI \r | |
378 | GasketUgaCheckKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)\r | |
379 | {\r | |
380 | return UgaCheckKey (UgaIo);\r | |
381 | }\r | |
382 | \r | |
383 | EFI_STATUS \r | |
384 | EFIAPI \r | |
385 | GasketUgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_INPUT_KEY *key)\r | |
386 | {\r | |
387 | return UgaGetKey (UgaIo, key);\r | |
388 | }\r | |
389 | \r | |
390 | EFI_STATUS \r | |
391 | EFIAPI \r | |
392 | GasketUgaBlt (\r | |
393 | EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,\r | |
394 | IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,\r | |
395 | IN EFI_UGA_BLT_OPERATION BltOperation,\r | |
396 | IN UGA_BLT_ARGS *Args\r | |
397 | )\r | |
398 | {\r | |
399 | return UgaBlt (UgaIo, BltBuffer, BltOperation, Args);\r | |
400 | }\r | |
401 | \r | |
402 | typedef void (*SET_TIMER_CALLBACK)(UINT64 delta);\r | |
403 | \r | |
404 | \r | |
405 | UINTN \r | |
406 | ReverseGasketUint64 (SET_TIMER_CALLBACK settimer_callback, UINT64 a)\r | |
407 | {\r | |
408 | (*settimer_callback)(a);\r | |
409 | return 0;\r | |
410 | }\r | |
411 | \r |