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