]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/Sec/Gasket.c
Fix issue with fixing tabs.
[mirror_edk2.git] / UnixPkg / Sec / Gasket.c
1 /** @file
2
3 Copyright (c) 2008 - 2010, 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 #ifdef __APPLE__
16
17 #include "SecMain.h"
18 #include "Gasket.h"
19
20 //
21 // Gasket functions for EFI_UNIX_THUNK_PROTOCOL
22 //
23
24 void
25 GasketmsSleep (unsigned long Milliseconds)
26 {
27 GasketUintn (msSleep, Milliseconds);
28 return;
29 }
30
31 void
32 Gasketexit (int status)
33 {
34 GasketUintn (exit, status);
35 return;
36 }
37
38
39 void
40 GasketSetTimer (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs))
41 {
42 GasketUint64Uintn (SetTimer, PeriodMs, (UINTN)CallBack);
43 return;
44 }
45
46
47 void
48 GasketGetLocalTime (EFI_TIME *Time)
49 {
50 GasketUintn (GetLocalTime, (UINTN)Time);
51 return;
52 }
53
54
55 struct tm *
56 Gasketgmtime (const time_t *clock)
57 {
58 return (struct tm *)(UINTN)GasketUintn (localtime, (UINTN)clock);
59 }
60
61
62 long
63 GasketGetTimeZone (void)
64 {
65 return GasketVoid (GetTimeZone);
66 }
67
68
69 int
70 GasketGetDayLight (void)
71 {
72 return GasketVoid (GetDayLight);
73 }
74
75
76 int
77 Gasketpoll (struct pollfd *pfd, unsigned int nfds, int timeout)
78 {
79 return GasketUintnUintnUintn (poll, (UINTN)pfd, nfds, timeout);
80 }
81
82
83 long
84 Gasketread (int fd, void *buf, int count)
85 {
86 return GasketUintnUintnUintn (read, fd, (UINTN)buf, count);
87 }
88
89
90 long
91 Gasketwrite (int fd, const void *buf, int count)
92 {
93 return GasketUintnUintnUintn (write, fd, (UINTN)buf, count);
94 }
95
96
97 char *
98 Gasketgetenv (const char *name)
99 {
100 return (char *)(UINTN)GasketUintn (getenv, (UINTN)name);
101 }
102
103
104 int
105 Gasketopen (const char *name, int flags, int mode)
106 {
107 return GasketUintnUintnUintn (open, (UINTN)name, flags, mode);
108 }
109
110
111 off_t
112 Gasketlseek (int fd, off_t off, int whence)
113 {
114 if (sizeof off == 8) {
115 return GasketUintnUint64Uintn (lseek, fd, off, whence);
116 } else if (sizeof off == 4) {
117 return GasketUintnUintnUintn (lseek, fd, off, whence);
118 }
119 }
120
121
122 int
123 Gasketftruncate (int fd, long int len)
124 {
125 return GasketUintnUintn (ftruncate, fd, len);
126 }
127
128
129 int
130 Gasketclose (int fd)
131 {
132 return GasketUintn (close, fd);
133 }
134
135
136 int
137 Gasketmkdir (const char *pathname, mode_t mode)
138 {
139 return GasketUintnUint16 (mkdir, (UINTN)pathname, mode);
140 }
141
142
143 int
144 Gasketrmdir (const char *pathname)
145 {
146 return GasketUintn (rmdir, (UINTN)pathname);
147 }
148
149
150 int
151 Gasketunlink (const char *pathname)
152 {
153 return GasketUintn (unlink, (UINTN)pathname);
154 }
155
156
157 int
158 GasketGetErrno (void)
159 {
160 return GasketVoid (GetErrno);
161 }
162
163
164 DIR *
165 Gasketopendir (const char *pathname)
166 {
167 return (DIR *)(UINTN)GasketUintn (opendir, (UINTN)pathname);
168 }
169
170
171 void
172 Gasketrewinddir (DIR *dir)
173 {
174 GasketUintn (rewinddir, (UINTN)dir);
175 return;
176 }
177
178
179 struct dirent *
180 Gasketreaddir (DIR *dir)
181 {
182 return (struct dirent *)(UINTN)GasketUintn (readdir, (UINTN)dir);
183 }
184
185
186 int
187 Gasketclosedir (DIR *dir)
188 {
189 return GasketUintn (closedir, (UINTN)dir);
190 }
191
192
193 int
194 Gasketstat (const char *path, STAT_FIX *buf)
195 {
196 return GasketUintnUintn (stat, (UINTN)path, (UINTN)buf);
197 }
198
199
200 int
201 Gasketstatfs (const char *path, struct statfs *buf)
202 {
203 return GasketUintnUintn (statfs, (UINTN)path, (UINTN)buf);
204 }
205
206
207 int
208 Gasketrename (const char *oldpath, const char *newpath)
209 {
210 return GasketUintnUintn (rename, (UINTN)oldpath, (UINTN)newpath);
211 }
212
213
214 time_t
215 Gasketmktime (struct tm *tm)
216 {
217 return GasketUintn (mktime, (UINTN)tm);
218 }
219
220
221 int
222 Gasketfsync (int fd)
223 {
224 return GasketUintn (fsync, fd);
225 }
226
227
228 int
229 Gasketchmod (const char *path, mode_t mode)
230 {
231 return GasketUintnUint16 (chmod, (UINTN)path, mode);
232 }
233
234
235 int
236 Gasketutime (const char *filename, const struct utimbuf *buf)
237 {
238 return GasketUintnUintn (utime, (UINTN)filename, (UINTN)buf);
239 }
240
241
242 int
243 Gaskettcflush (int fildes, int queue_selector)
244 {
245 return GasketUintnUintn (tcflush, fildes, queue_selector);
246 }
247
248
249 EFI_STATUS
250 GasketUgaCreate (struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo, CONST CHAR16 *Title)
251 {
252 return GasketUintnUintn (UgaCreate, (UINTN)UgaIo, (UINTN)Title);
253 }
254
255
256 void
257 Gasketperror (__const char *__s)
258 {
259 GasketUintn (perror, (UINTN)__s);
260 return;
261 }
262
263
264
265 //
266 // ... is always an int or pointer to device specific data structure
267 //
268 int
269 Gasketioctl (int fd, unsigned long int __request, void *Arg)
270 {
271 return GasketUintnUintnUintn (ioctl, fd, __request, (UINTN)Arg);
272 }
273
274
275 int
276 Gasketfcntl (int __fd, int __cmd, void *Arg)
277 {
278 return GasketUintnUintnUintn (fcntl, __fd, __cmd, (UINTN)Arg);
279 }
280
281
282
283 int
284 Gasketcfsetispeed (struct termios *__termios_p, speed_t __speed)
285 {
286 return GasketUintnUintn (cfsetispeed, (UINTN)__termios_p, __speed);
287 }
288
289
290 int
291 Gasketcfsetospeed (struct termios *__termios_p, speed_t __speed)
292 {
293 return GasketUintnUintn (cfsetospeed, (UINTN)__termios_p, __speed);
294 }
295
296
297 int
298 Gaskettcgetattr (int __fd, struct termios *__termios_p)
299 {
300 return GasketUintnUintn (tcgetattr, __fd, (UINTN)__termios_p);
301 }
302
303
304 int
305 Gaskettcsetattr (int __fd, int __optional_actions, __const struct termios *__termios_p)
306 {
307 return GasketUintnUintnUintn (tcsetattr, __fd, __optional_actions, (UINTN)__termios_p);
308 }
309
310
311
312
313 RETURN_STATUS
314 GasketUnixPeCoffGetEntryPoint (
315 IN VOID *Pe32Data,
316 IN OUT VOID **EntryPoint
317 )
318 {
319 return GasketUintnUintn (SecPeCoffGetEntryPoint, (UINTN)Pe32Data, (UINTN)EntryPoint);
320 }
321
322
323
324 VOID
325 GasketUnixPeCoffRelocateImageExtraAction (
326 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
327 )
328 {
329 GasketUintn (SecPeCoffRelocateImageExtraAction, (UINTN)ImageContext);
330 return;
331 }
332
333
334
335 VOID
336 GasketUnixPeCoffUnloadImageExtraAction (
337 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
338 )
339 {
340 GasketUintn (SecPeCoffLoaderUnloadImageExtraAction, (UINTN)ImageContext);
341 return;
342 }
343
344
345 //
346 // Gasket functions for EFI_UNIX_UGA_IO_PROTOCOL
347 //
348
349 EFI_STATUS
350 EFIAPI
351 GasketUgaClose (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
352 {
353 return GasketUintn (UgaClose, (UINTN)UgaIo);
354 }
355
356 EFI_STATUS
357 EFIAPI
358 GasketUgaSize (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, UINT32 Width, UINT32 Height)
359 {
360 return GasketUintnUintnUintn (UgaSize, (UINTN)UgaIo, Width, Height);
361 }
362
363 EFI_STATUS
364 EFIAPI
365 GasketUgaCheckKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
366 {
367 return GasketUintn (UgaCheckKey, (UINTN)UgaIo);
368 }
369
370 EFI_STATUS
371 EFIAPI
372 GasketUgaKeySetState (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_KEY_TOGGLE_STATE *KeyToggleState)
373 {
374 return GasketUintnUintn (UgaGetKey, (UINTN)UgaIo, (UINTN)KeyToggleState);
375 }
376
377 EFI_STATUS
378 EFIAPI
379 GasketUgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_KEY_DATA *key)
380 {
381 return GasketUintnUintn (UgaGetKey, (UINTN)UgaIo, (UINTN)key);
382 }
383
384 EFI_STATUS
385 EFIAPI
386 GasketUgaRegisterKeyNotify (
387 IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
388 IN UGA_REGISTER_KEY_NOTIFY_CALLBACK CallBack,
389 IN VOID *Context
390 )
391 {
392 return GasketUintnUintnUintn (UgaRegisterKeyNotify, (UINTN)UgaIo, (UINTN)CallBack, (UINTN)Context);
393 }
394
395 EFI_STATUS
396 EFIAPI
397 GasketUgaBlt (
398 EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
399 IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
400 IN EFI_UGA_BLT_OPERATION BltOperation,
401 IN UGA_BLT_ARGS *Args
402 )
403 {
404 return GasketUintnUintnUintnUintn (UgaBlt, (UINTN)UgaIo, (UINTN)BltBuffer, (UINTN)BltOperation, (UINTN)Args);
405 }
406
407 EFI_STATUS
408 EFIAPI
409 GasketUgaCheckPointer (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
410 {
411 return GasketUintn (UgaCheckPointer, (UINTN)UgaIo);
412 }
413
414 EFI_STATUS
415 EFIAPI
416 GasketUgaGetPointerState (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_SIMPLE_POINTER_STATE *state)
417 {
418 return GasketUintnUintn (UgaGetPointerState, (UINTN)UgaIo, (UINTN)state);
419 }
420
421 void
422 GasketUnixEnableInterrupt (void)
423 {
424 GasketVoid (UnixEnableInterrupt);
425 }
426
427 void
428 GasketUnixDisableInterrupt (void)
429 {
430 GasketVoid (UnixDisableInterrupt);
431 }
432
433
434 int
435 Gasketgetifaddrs (struct ifaddrs **ifap)
436 {
437 return( GasketUintn( getifaddrs, ( UINTN ) ifap ) );
438 }
439
440
441 void
442 Gasketfreeifaddrs (struct ifaddrs *ifap)
443 {
444 GasketUintn( freeifaddrs, ( UINTN ) ifap );
445 }
446
447
448 int
449 Gasketsocket (int domain, int type, int protocol )
450 {
451 return( GasketUintnUintnUintn( socket, domain, type, protocol ) );
452 }
453
454
455 #endif
456