]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/Sec/X64/GasketEfiTemplate.c
Fix token dup caused by merge.
[mirror_edk2.git] / UnixPkg / Sec / X64 / GasketEfiTemplate.c
1 /** @file
2
3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include "SecMain.h"
16 #include "Gasket.h"
17
18 //
19 // OS X Posix does some strange name mangling on these names in C.
20 // If you call from assembler you get the wrong version of the function
21 // So these globals get you the correct name mangled functions that can
22 // be accessed from assembly
23 //
24 extern UnixRmDir gUnixRmDir;
25 extern UnixOpenDir gUnixOpenDir;
26 extern UnixStat gUnixStat;
27 extern UnixStatFs gUnixStatFs;
28
29 //
30 // Gasket functions for EFI_UNIX_THUNK_PROTOCOL
31 //
32
33 int
34 Gasketrmdir (const char *pathname)
35 {
36 return gUnixRmDir (pathname);
37 }
38
39
40 DIR *
41 Gasketopendir (const char *pathname)
42 {
43 return gUnixOpenDir (pathname);
44 }
45
46
47 int
48 Gasketstat (const char *path, STAT_FIX *buf)
49 {
50 return gUnixStat (path, buf);
51 }
52
53
54 int
55 Gasketstatfs (const char *path, struct statfs *buf)
56 {
57 return gUnixStatFs (path, buf);
58 }
59
60 /////
61
62
63 void
64 GasketmsSleep (unsigned long Milliseconds)
65 {
66 msSleep (Milliseconds);
67 return;
68 }
69
70 void
71 Gasketexit (int status)
72 {
73 exit (status);
74 return;
75 }
76
77
78 void
79 GasketSetTimer (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs))
80 {
81 SetTimer (PeriodMs, CallBack);
82 return;
83 }
84
85
86 void
87 GasketGetLocalTime (EFI_TIME *Time)
88 {
89 GetLocalTime (Time);
90 return;
91 }
92
93
94 struct tm *
95 Gasketgmtime (const time_t *clock)
96 {
97 return localtime (clock);
98 }
99
100
101 long
102 GasketGetTimeZone (void)
103 {
104 return GetTimeZone ();
105 }
106
107
108 int
109 GasketGetDayLight (void)
110 {
111 return GetDayLight ();
112 }
113
114
115 int
116 Gasketpoll (struct pollfd *pfd, unsigned int nfds, int timeout)
117 {
118 return poll (pfd, nfds, timeout);
119 }
120
121
122 long
123 Gasketread (int fd, void *buf, int count)
124 {
125 return read (fd, buf, count);
126 }
127
128
129 long
130 Gasketwrite (int fd, const void *buf, int count)
131 {
132 return write (fd, buf, count);
133 }
134
135
136 char *
137 Gasketgetenv (const char *name)
138 {
139 return getenv (name);
140 }
141
142
143 int
144 Gasketopen (const char *name, int flags, int mode)
145 {
146 return open (name, flags, mode);
147 }
148
149
150 off_t
151 Gasketlseek (int fd, off_t off, int whence)
152 {
153 return lseek (fd, off, whence);
154 }
155
156
157 int
158 Gasketftruncate (int fd, long int len)
159 {
160 return ftruncate (fd, len);
161 }
162
163
164 int
165 Gasketclose (int fd)
166 {
167 return close (fd);
168 }
169
170
171 int
172 Gasketmkdir (const char *pathname, mode_t mode)
173 {
174 return mkdir (pathname, mode);
175 }
176
177
178 int
179 Gasketunlink (const char *pathname)
180 {
181 return unlink (pathname);
182 }
183
184
185 int
186 GasketGetErrno (void)
187 {
188 return GetErrno ();
189 }
190
191
192 void
193 Gasketrewinddir (DIR *dir)
194 {
195 rewinddir (dir);
196 return;
197 }
198
199
200 struct dirent *
201 Gasketreaddir (DIR *dir)
202 {
203 return readdir (dir);
204 }
205
206
207 int
208 Gasketclosedir (DIR *dir)
209 {
210 return closedir (dir);
211 }
212
213
214 int
215 Gasketrename (const char *oldpath, const char *newpath)
216 {
217 return rename (oldpath, newpath);
218 }
219
220
221 time_t
222 Gasketmktime (struct tm *tm)
223 {
224 return mktime (tm);
225 }
226
227
228 int
229 Gasketfsync (int fd)
230 {
231 return fsync (fd);
232 }
233
234
235 int
236 Gasketchmod (const char *path, mode_t mode)
237 {
238 return chmod (path, mode);
239 }
240
241
242 int
243 Gasketutime (const char *filename, const struct utimbuf *buf)
244 {
245 return utime (filename, buf);
246 }
247
248
249 int
250 Gaskettcflush (int fildes, int queue_selector)
251 {
252 return tcflush (fildes, queue_selector);
253 }
254
255
256 EFI_STATUS
257 GasketUgaCreate (struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo, CONST CHAR16 *Title)
258 {
259 return UgaCreate (UgaIo, Title);
260 }
261
262
263 void
264 Gasketperror (__const char *__s)
265 {
266 perror (__s);
267 return;
268 }
269
270
271
272 //
273 // ... is always an int or pointer to device specific data structure
274 //
275 int
276 Gasketioctl (int fd, unsigned long int __request, ...)
277 {
278 VA_LIST Marker;
279
280 VA_START (Marker, __request);
281 return ioctl (fd, __request, VA_ARG (Marker, UINTN));
282 }
283
284
285 int
286 Gasketfcntl (int __fd, int __cmd, ...)
287 {
288 VA_LIST Marker;
289
290 VA_START (Marker, __cmd);
291 return fcntl (__fd, __cmd, VA_ARG (Marker, UINTN));
292 }
293
294
295
296 int
297 Gasketcfsetispeed (struct termios *__termios_p, speed_t __speed)
298 {
299 return cfsetispeed (__termios_p, __speed);
300 }
301
302
303 int
304 Gasketcfsetospeed (struct termios *__termios_p, speed_t __speed)
305 {
306 return cfsetospeed (__termios_p, __speed);
307 }
308
309
310 int
311 Gaskettcgetattr (int __fd, struct termios *__termios_p)
312 {
313 return tcgetattr (__fd, __termios_p);
314 }
315
316
317 int
318 Gaskettcsetattr (int __fd, int __optional_actions, __const struct termios *__termios_p)
319 {
320 return tcsetattr (__fd, __optional_actions, __termios_p);
321 }
322
323
324
325
326 RETURN_STATUS
327 GasketUnixPeCoffGetEntryPoint (
328 IN VOID *Pe32Data,
329 IN OUT VOID **EntryPoint
330 )
331 {
332 return SecPeCoffGetEntryPoint (Pe32Data, EntryPoint);
333 }
334
335
336
337 VOID
338 GasketUnixPeCoffRelocateImageExtraAction (
339 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
340 )
341 {
342 SecPeCoffRelocateImageExtraAction (ImageContext);
343 return;
344 }
345
346
347
348 VOID
349 GasketUnixPeCoffUnloadImageExtraAction (
350 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
351 )
352 {
353 SecPeCoffLoaderUnloadImageExtraAction (ImageContext);
354 return;
355 }
356
357
358 //
359 // Gasket functions for EFI_UNIX_UGA_IO_PROTOCOL
360 //
361
362 EFI_STATUS
363 EFIAPI
364 GasketUgaClose (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
365 {
366 return UgaClose (UgaIo);
367 }
368
369 EFI_STATUS
370 EFIAPI
371 GasketUgaSize (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, UINT32 Width, UINT32 Height)
372 {
373 return UgaSize (UgaIo, Width, Height);
374 }
375
376 EFI_STATUS
377 EFIAPI
378 GasketUgaCheckKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
379 {
380 return UgaCheckKey (UgaIo);
381 }
382
383 EFI_STATUS
384 EFIAPI
385 GasketUgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_INPUT_KEY *key)
386 {
387 return UgaGetKey (UgaIo, key);
388 }
389
390 EFI_STATUS
391 EFIAPI
392 GasketUgaBlt (
393 EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
394 IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
395 IN EFI_UGA_BLT_OPERATION BltOperation,
396 IN UGA_BLT_ARGS *Args
397 )
398 {
399 return UgaBlt (UgaIo, BltBuffer, BltOperation, Args);
400 }
401
402 typedef void (*SET_TIMER_CALLBACK)(UINT64 delta);
403
404
405 UINTN
406 ReverseGasketUint64 (SET_TIMER_CALLBACK settimer_callback, UINT64 a)
407 {
408 (*settimer_callback)(a);
409 return 0;
410 }
411