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