]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/Sec/Gasket.c
Sync fix on MdePkg r9982.
[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
b9c8e50e 77Gasketpoll (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 83long\r
7ee3b613
A
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
b9c8e50e 90long\r
7ee3b613
A
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
b9c8e50e 171void \r
7ee3b613
A
172Gasketrewinddir (DIR *dir)\r
173{\r
b9c8e50e 174 GasketUintn (rewinddir, (UINTN)dir);\r
175 return;\r
7ee3b613
A
176}\r
177\r
178\r
179struct dirent *\r
180Gasketreaddir (DIR *dir)\r
181{\r
182 return (struct dirent *)(UINTN)GasketUintn (readdir, (UINTN)dir);\r
183}\r
184\r
185\r
186int \r
187Gasketclosedir (DIR *dir)\r
188{\r
189 return GasketUintn (closedir, (UINTN)dir);\r
190}\r
191\r
192\r
193int \r
194Gasketstat (const char *path, STAT_FIX *buf)\r
195{\r
196 return GasketUintnUintn (stat, (UINTN)path, (UINTN)buf);\r
197}\r
198\r
199\r
200int \r
201Gasketstatfs (const char *path, struct statfs *buf)\r
202{\r
203 return GasketUintnUintn (statfs, (UINTN)path, (UINTN)buf);\r
204}\r
205\r
206\r
207int \r
208Gasketrename (const char *oldpath, const char *newpath)\r
209{\r
210 return GasketUintnUintn (rename, (UINTN)oldpath, (UINTN)newpath);\r
211}\r
212\r
213\r
214time_t \r
215Gasketmktime (struct tm *tm)\r
216{\r
217 return GasketUintn (mktime, (UINTN)tm);\r
218}\r
219\r
220\r
221int \r
222Gasketfsync (int fd)\r
223{\r
224 return GasketUintn (fsync, fd);\r
225}\r
226\r
227\r
228int \r
229Gasketchmod (const char *path, mode_t mode)\r
230{\r
231 return GasketUintnUint16 (chmod, (UINTN)path, mode);\r
232}\r
233\r
234\r
235int \r
236Gasketutime (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
242int \r
243Gaskettcflush (int fildes, int queue_selector)\r
244{\r
245 return GasketUintnUintn (tcflush, fildes, queue_selector);\r
246}\r
247\r
248\r
249EFI_STATUS \r
250GasketUgaCreate (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
256void \r
257Gasketperror (__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
268int \r
269Gasketioctl (int fd, unsigned long int __request, ...)\r
270{\r
271 VA_LIST Marker;\r
272 \r
273 VA_START (Marker, __request);\r
274 return GasketUintnUintnUintn (ioctl, fd, __request, VA_ARG (Marker, UINTN));\r
275}\r
276\r
277\r
278int \r
279Gasketfcntl (int __fd, int __cmd, ...)\r
280{\r
281 VA_LIST Marker;\r
282 \r
283 VA_START (Marker, __cmd);\r
284 return GasketUintnUintnUintn (fcntl, __fd, __cmd, VA_ARG (Marker, UINTN));\r
285}\r
286\r
287\r
288\r
289int \r
290Gasketcfsetispeed (struct termios *__termios_p, speed_t __speed)\r
291{\r
292 return GasketUintnUintn (cfsetispeed, (UINTN)__termios_p, __speed);\r
293}\r
294\r
295\r
296int \r
297Gasketcfsetospeed (struct termios *__termios_p, speed_t __speed)\r
298{\r
299 return GasketUintnUintn (cfsetospeed, (UINTN)__termios_p, __speed);\r
300}\r
301\r
302\r
303int \r
304Gaskettcgetattr (int __fd, struct termios *__termios_p)\r
305{\r
306 return GasketUintnUintn (tcgetattr, __fd, (UINTN)__termios_p);\r
307}\r
308\r
309 \r
310int \r
311Gaskettcsetattr (int __fd, int __optional_actions, __const struct termios *__termios_p)\r
312{\r
313 return GasketUintnUintnUintn (tcsetattr, __fd, __optional_actions, (UINTN)__termios_p);\r
314}\r
315\r
316\r
7ee3b613
A
317\r
318\r
319RETURN_STATUS\r
320GasketUnixPeCoffGetEntryPoint (\r
321 IN VOID *Pe32Data,\r
322 IN OUT VOID **EntryPoint\r
323 )\r
324{\r
325 return GasketUintnUintn (SecPeCoffGetEntryPoint, (UINTN)Pe32Data, (UINTN)EntryPoint);\r
326}\r
327\r
328\r
329\r
330VOID\r
331GasketUnixPeCoffRelocateImageExtraAction (\r
332 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
333 )\r
334{\r
335 GasketUintn (SecPeCoffRelocateImageExtraAction, (UINTN)ImageContext);\r
336 return;\r
337}\r
338\r
339\r
340\r
341VOID\r
b9c8e50e 342GasketUnixPeCoffUnloadImageExtraAction (\r
7ee3b613
A
343 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
344 )\r
345{\r
346 GasketUintn (SecPeCoffLoaderUnloadImageExtraAction, (UINTN)ImageContext);\r
347 return;\r
348}\r
349\r
350\r
351//\r
352// Gasket functions for EFI_UNIX_UGA_IO_PROTOCOL\r
353//\r
354\r
355EFI_STATUS \r
356EFIAPI \r
357GasketUgaClose (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)\r
358{\r
359 return GasketUintn (UgaClose, (UINTN)UgaIo);\r
360}\r
361\r
362EFI_STATUS \r
363EFIAPI \r
364GasketUgaSize (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, UINT32 Width, UINT32 Height)\r
365{\r
366 return GasketUintnUintnUintn (UgaSize, (UINTN)UgaIo, Width, Height);\r
367}\r
368\r
369EFI_STATUS \r
370EFIAPI \r
371GasketUgaCheckKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)\r
372{\r
373 return GasketUintn (UgaCheckKey, (UINTN)UgaIo);\r
374}\r
375\r
376EFI_STATUS \r
377EFIAPI \r
378GasketUgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_INPUT_KEY *key)\r
379{\r
380 return GasketUintnUintn (UgaGetKey, (UINTN)UgaIo, (UINTN)key);\r
381}\r
382\r
383EFI_STATUS \r
384EFIAPI \r
385GasketUgaBlt (\r
386 EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,\r
387 IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,\r
388 IN EFI_UGA_BLT_OPERATION BltOperation,\r
389 IN UINTN SourceX,\r
390 IN UINTN SourceY,\r
391 IN UINTN DestinationX,\r
392 IN UINTN DestinationY,\r
393 IN UINTN Width,\r
394 IN UINTN Height,\r
395 IN UINTN Delta OPTIONAL\r
396 )\r
397{\r
398 return GasketUintn10Args (UgaBlt, (UINTN)UgaIo, (UINTN)BltBuffer, BltOperation, SourceX, SourceY, DestinationX, DestinationY, Width, Height, Delta);\r
399}\r
400\r
5af06fe3
A
401#endif\r
402\r