]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/Sec/X64/GasketEfiTemplate.c
Complete coding to support X64 EFI ABI in UnixPkg. Code is not currently hooked in...
[mirror_edk2.git] / UnixPkg / Sec / X64 / GasketEfiTemplate.c
CommitLineData
ede7ec0b 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
24extern UnixRmDir gUnixRmDir;\r
25extern UnixOpenDir gUnixOpenDir;\r
26extern UnixStat gUnixStat;\r
27extern UnixStatFs gUnixStatFs;\r
28\r
29//\r
30// Gasket functions for EFI_UNIX_THUNK_PROTOCOL\r
31//\r
32\r
33int \r
34Gasketrmdir (const char *pathname)\r
35{\r
36 return gUnixRmDir (pathname);\r
37}\r
38\r
39\r
40DIR *\r
41Gasketopendir (const char *pathname)\r
42{\r
43 return gUnixOpenDir (pathname);\r
44}\r
45\r
46\r
47int \r
48Gasketstat (const char *path, STAT_FIX *buf)\r
49{\r
50 return gUnixStat (path, buf);\r
51}\r
52\r
53\r
54int \r
55Gasketstatfs (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
63void \r
64GasketmsSleep (unsigned long Milliseconds)\r
65{ \r
66 msSleep (Milliseconds);\r
67 return;\r
68}\r
69\r
70void \r
71Gasketexit (int status)\r
72{\r
73 exit (status);\r
74 return;\r
75}\r
76\r
77\r
78void \r
79GasketSetTimer (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs))\r
80{\r
81 SetTimer (PeriodMs, CallBack);\r
82 return;\r
83}\r
84\r
85\r
86void \r
87GasketGetLocalTime (EFI_TIME *Time)\r
88{\r
89 GetLocalTime (Time);\r
90 return;\r
91}\r
92\r
93\r
94struct tm *\r
95Gasketgmtime (const time_t *clock)\r
96{\r
97 return localtime (clock);\r
98}\r
99\r
100\r
101long \r
102GasketGetTimeZone (void)\r
103{\r
104 return GetTimeZone ();\r
105}\r
106\r
107\r
108int \r
109GasketGetDayLight (void)\r
110{\r
111 return GetDayLight ();\r
112}\r
113\r
114\r
115int \r
116Gasketpoll (struct pollfd *pfd, unsigned int nfds, int timeout)\r
117{\r
118 return poll (pfd, nfds, timeout);\r
119}\r
120\r
121\r
122long\r
123Gasketread (int fd, void *buf, int count)\r
124{\r
125 return read (fd, buf, count);\r
126}\r
127\r
128\r
129long\r
130Gasketwrite (int fd, const void *buf, int count)\r
131{\r
132 return write (fd, buf, count);\r
133}\r
134\r
135\r
136char *\r
137Gasketgetenv (const char *name)\r
138{\r
139 return getenv (name);\r
140}\r
141\r
142\r
143int \r
144Gasketopen (const char *name, int flags, int mode)\r
145{\r
146 return open (name, flags, mode);\r
147}\r
148\r
149\r
150off_t \r
151Gasketlseek (int fd, off_t off, int whence)\r
152{\r
153 return lseek (fd, off, whence);\r
154}\r
155\r
156\r
157int \r
158Gasketftruncate (int fd, long int len)\r
159{\r
160 return ftruncate (fd, len);\r
161}\r
162\r
163\r
164int \r
165Gasketclose (int fd)\r
166{\r
167 return close (fd);\r
168}\r
169\r
170\r
171int \r
172Gasketmkdir (const char *pathname, mode_t mode)\r
173{\r
174 return mkdir (pathname, mode);\r
175}\r
176\r
177\r
178int \r
179Gasketunlink (const char *pathname)\r
180{\r
181 return unlink (pathname);\r
182}\r
183\r
184\r
185int \r
186GasketGetErrno (void)\r
187{\r
188 return GetErrno ();\r
189}\r
190\r
191\r
192void \r
193Gasketrewinddir (DIR *dir)\r
194{\r
195 rewinddir (dir);\r
196 return;\r
197}\r
198\r
199\r
200struct dirent *\r
201Gasketreaddir (DIR *dir)\r
202{\r
203 return readdir (dir);\r
204}\r
205\r
206\r
207int \r
208Gasketclosedir (DIR *dir)\r
209{\r
210 return closedir (dir);\r
211}\r
212\r
213\r
214int \r
215Gasketrename (const char *oldpath, const char *newpath)\r
216{\r
217 return rename (oldpath, newpath);\r
218}\r
219\r
220\r
221time_t \r
222Gasketmktime (struct tm *tm)\r
223{\r
224 return mktime (tm);\r
225}\r
226\r
227\r
228int \r
229Gasketfsync (int fd)\r
230{\r
231 return fsync (fd);\r
232}\r
233\r
234\r
235int \r
236Gasketchmod (const char *path, mode_t mode)\r
237{\r
238 return chmod (path, mode);\r
239}\r
240\r
241\r
242int \r
243Gasketutime (const char *filename, const struct utimbuf *buf)\r
244{\r
245 return utime (filename, buf);\r
246}\r
247\r
248\r
249int \r
250Gaskettcflush (int fildes, int queue_selector)\r
251{\r
252 return tcflush (fildes, queue_selector);\r
253}\r
254\r
255\r
256EFI_STATUS \r
257GasketUgaCreate (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
263void \r
264Gasketperror (__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
275int \r
276Gasketioctl (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
285int \r
286Gasketfcntl (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
296int \r
297Gasketcfsetispeed (struct termios *__termios_p, speed_t __speed)\r
298{\r
299 return cfsetispeed (__termios_p, __speed);\r
300}\r
301\r
302\r
303int \r
304Gasketcfsetospeed (struct termios *__termios_p, speed_t __speed)\r
305{\r
306 return cfsetospeed (__termios_p, __speed);\r
307}\r
308\r
309\r
310int \r
311Gaskettcgetattr (int __fd, struct termios *__termios_p)\r
312{\r
313 return tcgetattr (__fd, __termios_p);\r
314}\r
315\r
316 \r
317int \r
318Gaskettcsetattr (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
326RETURN_STATUS\r
327GasketUnixPeCoffGetEntryPoint (\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
337VOID\r
338GasketUnixPeCoffRelocateImageExtraAction (\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
348VOID\r
349GasketUnixPeCoffUnloadImageExtraAction (\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
362EFI_STATUS \r
363EFIAPI \r
364GasketUgaClose (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)\r
365{\r
366 return UgaClose (UgaIo);\r
367}\r
368\r
369EFI_STATUS \r
370EFIAPI \r
371GasketUgaSize (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, UINT32 Width, UINT32 Height)\r
372{\r
373 return UgaSize (UgaIo, Width, Height);\r
374}\r
375\r
376EFI_STATUS \r
377EFIAPI \r
378GasketUgaCheckKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)\r
379{\r
380 return UgaCheckKey (UgaIo);\r
381}\r
382\r
383EFI_STATUS \r
384EFIAPI \r
385GasketUgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_INPUT_KEY *key)\r
386{\r
387 return UgaGetKey (UgaIo, key);\r
388}\r
389\r
390EFI_STATUS \r
391EFIAPI \r
392GasketUgaBlt (\r
a4902ccc 393 EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,\r
ede7ec0b 394 IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,\r
395 IN EFI_UGA_BLT_OPERATION BltOperation,\r
a4902ccc 396 IN UGA_BLT_ARGS *Args\r
ede7ec0b 397 )\r
398{\r
a4902ccc 399 return UgaBlt (UgaIo, BltBuffer, BltOperation, Args);\r
ede7ec0b 400}\r
401\r
402typedef void (*SET_TIMER_CALLBACK)(UINT64 delta);\r
403\r
404\r
405UINTN \r
406ReverseGasketUint64 (void *api, UINT64 a)\r
407{\r
408 SET_TIMER_CALLBACK settimer_callback = (SET_TIMER_CALLBACK)api;\r
409 \r
410 (*settimer_callback)(a);\r
411 return 0;\r
412}\r
413\r