]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/Sec/Gasket.c
Add -m32 option for IA32 ASM flag to ensure it is treated as 32-bit for GCC assembler.
[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
a4902ccc 269Gasketioctl (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
275int \r
a4902ccc 276Gasketfcntl (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
283int \r
284Gasketcfsetispeed (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
290int \r
291Gasketcfsetospeed (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
297int \r
298Gaskettcgetattr (int __fd, struct termios *__termios_p)\r
299{\r
300 return GasketUintnUintn (tcgetattr, __fd, (UINTN)__termios_p);\r
301}\r
302\r
303 \r
304int \r
305Gaskettcsetattr (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
313RETURN_STATUS\r
314GasketUnixPeCoffGetEntryPoint (\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
324VOID\r
325GasketUnixPeCoffRelocateImageExtraAction (\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
335VOID\r
b9c8e50e 336GasketUnixPeCoffUnloadImageExtraAction (\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
349EFI_STATUS \r
350EFIAPI \r
351GasketUgaClose (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)\r
352{\r
353 return GasketUintn (UgaClose, (UINTN)UgaIo);\r
354}\r
355\r
356EFI_STATUS \r
357EFIAPI \r
358GasketUgaSize (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
363EFI_STATUS \r
364EFIAPI \r
365GasketUgaCheckKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)\r
366{\r
367 return GasketUintn (UgaCheckKey, (UINTN)UgaIo);\r
368}\r
369\r
370EFI_STATUS \r
371EFIAPI \r
372GasketUgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_INPUT_KEY *key)\r
373{\r
374 return GasketUintnUintn (UgaGetKey, (UINTN)UgaIo, (UINTN)key);\r
375}\r
376\r
377EFI_STATUS \r
378EFIAPI \r
379GasketUgaBlt (\r
380 EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,\r
381 IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,\r
382 IN EFI_UGA_BLT_OPERATION BltOperation,\r
383 IN UINTN SourceX,\r
384 IN UINTN SourceY,\r
385 IN UINTN DestinationX,\r
386 IN UINTN DestinationY,\r
387 IN UINTN Width,\r
388 IN UINTN Height,\r
389 IN UINTN Delta OPTIONAL\r
390 )\r
391{\r
392 return GasketUintn10Args (UgaBlt, (UINTN)UgaIo, (UINTN)BltBuffer, BltOperation, SourceX, SourceY, DestinationX, DestinationY, Width, Height, Delta);\r
393}\r
394\r
5af06fe3
A
395#endif\r
396\r