]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/Sec/Gasket.c
9dd5bb20f4a23de8afd2332536f7b87b63729550
[mirror_edk2.git] / UnixPkg / Sec / Gasket.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 #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, int nfds, int timeout)
78 {
79 return GasketUintnUintnUintn (poll, (UINTN)pfd, nfds, timeout);
80 }
81
82
83 int
84 Gasketread (int fd, void *buf, int count)
85 {
86 return GasketUintnUintnUintn (read, fd, (UINTN)buf, count);
87 }
88
89
90 int
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 return (void *)(UINTN)GasketUintn (rewinddir, (UINTN)dir);
175 }
176
177
178 struct dirent *
179 Gasketreaddir (DIR *dir)
180 {
181 return (struct dirent *)(UINTN)GasketUintn (readdir, (UINTN)dir);
182 }
183
184
185 int
186 Gasketclosedir (DIR *dir)
187 {
188 return GasketUintn (closedir, (UINTN)dir);
189 }
190
191
192 int
193 Gasketstat (const char *path, STAT_FIX *buf)
194 {
195 return GasketUintnUintn (stat, (UINTN)path, (UINTN)buf);
196 }
197
198
199 int
200 Gasketstatfs (const char *path, struct statfs *buf)
201 {
202 return GasketUintnUintn (statfs, (UINTN)path, (UINTN)buf);
203 }
204
205
206 int
207 Gasketrename (const char *oldpath, const char *newpath)
208 {
209 return GasketUintnUintn (rename, (UINTN)oldpath, (UINTN)newpath);
210 }
211
212
213 time_t
214 Gasketmktime (struct tm *tm)
215 {
216 return GasketUintn (mktime, (UINTN)tm);
217 }
218
219
220 int
221 Gasketfsync (int fd)
222 {
223 return GasketUintn (fsync, fd);
224 }
225
226
227 int
228 Gasketchmod (const char *path, mode_t mode)
229 {
230 return GasketUintnUint16 (chmod, (UINTN)path, mode);
231 }
232
233
234 int
235 Gasketutime (const char *filename, const struct utimbuf *buf)
236 {
237 return GasketUintnUintn (utime, (UINTN)filename, (UINTN)buf);
238 }
239
240
241 int
242 Gaskettcflush (int fildes, int queue_selector)
243 {
244 return GasketUintnUintn (tcflush, fildes, queue_selector);
245 }
246
247
248 EFI_STATUS
249 GasketUgaCreate (struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo, CONST CHAR16 *Title)
250 {
251 return GasketUintnUintn (UgaCreate, (UINTN)UgaIo, (UINTN)Title);
252 }
253
254
255 void
256 Gasketperror (__const char *__s)
257 {
258 GasketUintn (perror, (UINTN)__s);
259 return;
260 }
261
262
263
264 //
265 // ... is always an int or pointer to device specific data structure
266 //
267 int
268 Gasketioctl (int fd, unsigned long int __request, ...)
269 {
270 VA_LIST Marker;
271
272 VA_START (Marker, __request);
273 return GasketUintnUintnUintn (ioctl, fd, __request, VA_ARG (Marker, UINTN));
274 }
275
276
277 int
278 Gasketfcntl (int __fd, int __cmd, ...)
279 {
280 VA_LIST Marker;
281
282 VA_START (Marker, __cmd);
283 return GasketUintnUintnUintn (fcntl, __fd, __cmd, VA_ARG (Marker, UINTN));
284 }
285
286
287
288 int
289 Gasketcfsetispeed (struct termios *__termios_p, speed_t __speed)
290 {
291 return GasketUintnUintn (cfsetispeed, (UINTN)__termios_p, __speed);
292 }
293
294
295 int
296 Gasketcfsetospeed (struct termios *__termios_p, speed_t __speed)
297 {
298 return GasketUintnUintn (cfsetospeed, (UINTN)__termios_p, __speed);
299 }
300
301
302 int
303 Gaskettcgetattr (int __fd, struct termios *__termios_p)
304 {
305 return GasketUintnUintn (tcgetattr, __fd, (UINTN)__termios_p);
306 }
307
308
309 int
310 Gaskettcsetattr (int __fd, int __optional_actions, __const struct termios *__termios_p)
311 {
312 return GasketUintnUintnUintn (tcsetattr, __fd, __optional_actions, (UINTN)__termios_p);
313 }
314
315
316 int
317 Gasketsigaction (int sig, const struct sigaction *act, struct sigaction *oact)
318 {
319 return GasketUintnUintn (sigaction, (UINTN)act, (UINTN)oact);
320 }
321
322
323 int
324 Gasketsetcontext (const ucontext_t *ucp)
325 {
326 return GasketUintn (setcontext, (UINTN)ucp);
327 }
328
329
330 int
331 Gasketgetcontext (ucontext_t *ucp)
332 {
333 return GasketUintn (getcontext, (UINTN)ucp);
334 }
335
336
337 int
338 Gasketsigemptyset (sigset_t *set)
339 {
340 return GasketUintn (sigemptyset, (UINTN)set);
341 }
342
343
344 int
345 Gasketsigaltstack (const stack_t *ss, stack_t *oss)
346 {
347 return GasketUintnUintn (sigaltstack, (UINTN)ss, (UINTN)oss);
348 }
349
350
351
352 RETURN_STATUS
353 GasketUnixPeCoffGetEntryPoint (
354 IN VOID *Pe32Data,
355 IN OUT VOID **EntryPoint
356 )
357 {
358 return GasketUintnUintn (SecPeCoffGetEntryPoint, (UINTN)Pe32Data, (UINTN)EntryPoint);
359 }
360
361
362
363 VOID
364 GasketUnixPeCoffRelocateImageExtraAction (
365 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
366 )
367 {
368 GasketUintn (SecPeCoffRelocateImageExtraAction, (UINTN)ImageContext);
369 return;
370 }
371
372
373
374 VOID
375 GasketPeCoffLoaderUnloadImageExtraAction (
376 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
377 )
378 {
379 GasketUintn (SecPeCoffLoaderUnloadImageExtraAction, (UINTN)ImageContext);
380 return;
381 }
382
383
384 //
385 // Gasket functions for EFI_UNIX_UGA_IO_PROTOCOL
386 //
387
388 EFI_STATUS
389 EFIAPI
390 GasketUgaClose (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
391 {
392 return GasketUintn (UgaClose, (UINTN)UgaIo);
393 }
394
395 EFI_STATUS
396 EFIAPI
397 GasketUgaSize (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, UINT32 Width, UINT32 Height)
398 {
399 return GasketUintnUintnUintn (UgaSize, (UINTN)UgaIo, Width, Height);
400 }
401
402 EFI_STATUS
403 EFIAPI
404 GasketUgaCheckKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
405 {
406 return GasketUintn (UgaCheckKey, (UINTN)UgaIo);
407 }
408
409 EFI_STATUS
410 EFIAPI
411 GasketUgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_INPUT_KEY *key)
412 {
413 return GasketUintnUintn (UgaGetKey, (UINTN)UgaIo, (UINTN)key);
414 }
415
416 EFI_STATUS
417 EFIAPI
418 GasketUgaBlt (
419 EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
420 IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
421 IN EFI_UGA_BLT_OPERATION BltOperation,
422 IN UINTN SourceX,
423 IN UINTN SourceY,
424 IN UINTN DestinationX,
425 IN UINTN DestinationY,
426 IN UINTN Width,
427 IN UINTN Height,
428 IN UINTN Delta OPTIONAL
429 )
430 {
431 return GasketUintn10Args (UgaBlt, (UINTN)UgaIo, (UINTN)BltBuffer, BltOperation, SourceX, SourceY, DestinationX, DestinationY, Width, Height, Delta);
432 }
433
434 #endif
435