]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/Sec/Gasket.c
Port UnixPkg to also support X64. Currently only supports Unix x86_64 ABI. In the...
[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, 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, ...)
270 {
271 VA_LIST Marker;
272
273 VA_START (Marker, __request);
274 return GasketUintnUintnUintn (ioctl, fd, __request, VA_ARG (Marker, UINTN));
275 }
276
277
278 int
279 Gasketfcntl (int __fd, int __cmd, ...)
280 {
281 VA_LIST Marker;
282
283 VA_START (Marker, __cmd);
284 return GasketUintnUintnUintn (fcntl, __fd, __cmd, VA_ARG (Marker, UINTN));
285 }
286
287
288
289 int
290 Gasketcfsetispeed (struct termios *__termios_p, speed_t __speed)
291 {
292 return GasketUintnUintn (cfsetispeed, (UINTN)__termios_p, __speed);
293 }
294
295
296 int
297 Gasketcfsetospeed (struct termios *__termios_p, speed_t __speed)
298 {
299 return GasketUintnUintn (cfsetospeed, (UINTN)__termios_p, __speed);
300 }
301
302
303 int
304 Gaskettcgetattr (int __fd, struct termios *__termios_p)
305 {
306 return GasketUintnUintn (tcgetattr, __fd, (UINTN)__termios_p);
307 }
308
309
310 int
311 Gaskettcsetattr (int __fd, int __optional_actions, __const struct termios *__termios_p)
312 {
313 return GasketUintnUintnUintn (tcsetattr, __fd, __optional_actions, (UINTN)__termios_p);
314 }
315
316
317 int
318 Gasketsigaction (int sig, const struct sigaction *act, struct sigaction *oact)
319 {
320 return GasketUintnUintn (sigaction, (UINTN)act, (UINTN)oact);
321 }
322
323
324 int
325 Gasketsetcontext (const ucontext_t *ucp)
326 {
327 return GasketUintn (setcontext, (UINTN)ucp);
328 }
329
330
331 int
332 Gasketgetcontext (ucontext_t *ucp)
333 {
334 return GasketUintn (getcontext, (UINTN)ucp);
335 }
336
337
338 int
339 Gasketsigemptyset (sigset_t *set)
340 {
341 return GasketUintn (sigemptyset, (UINTN)set);
342 }
343
344
345 int
346 Gasketsigaltstack (const stack_t *ss, stack_t *oss)
347 {
348 return GasketUintnUintn (sigaltstack, (UINTN)ss, (UINTN)oss);
349 }
350
351
352
353 RETURN_STATUS
354 GasketUnixPeCoffGetEntryPoint (
355 IN VOID *Pe32Data,
356 IN OUT VOID **EntryPoint
357 )
358 {
359 return GasketUintnUintn (SecPeCoffGetEntryPoint, (UINTN)Pe32Data, (UINTN)EntryPoint);
360 }
361
362
363
364 VOID
365 GasketUnixPeCoffRelocateImageExtraAction (
366 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
367 )
368 {
369 GasketUintn (SecPeCoffRelocateImageExtraAction, (UINTN)ImageContext);
370 return;
371 }
372
373
374
375 VOID
376 GasketUnixPeCoffUnloadImageExtraAction (
377 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
378 )
379 {
380 GasketUintn (SecPeCoffLoaderUnloadImageExtraAction, (UINTN)ImageContext);
381 return;
382 }
383
384
385 //
386 // Gasket functions for EFI_UNIX_UGA_IO_PROTOCOL
387 //
388
389 EFI_STATUS
390 EFIAPI
391 GasketUgaClose (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
392 {
393 return GasketUintn (UgaClose, (UINTN)UgaIo);
394 }
395
396 EFI_STATUS
397 EFIAPI
398 GasketUgaSize (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, UINT32 Width, UINT32 Height)
399 {
400 return GasketUintnUintnUintn (UgaSize, (UINTN)UgaIo, Width, Height);
401 }
402
403 EFI_STATUS
404 EFIAPI
405 GasketUgaCheckKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
406 {
407 return GasketUintn (UgaCheckKey, (UINTN)UgaIo);
408 }
409
410 EFI_STATUS
411 EFIAPI
412 GasketUgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_INPUT_KEY *key)
413 {
414 return GasketUintnUintn (UgaGetKey, (UINTN)UgaIo, (UINTN)key);
415 }
416
417 EFI_STATUS
418 EFIAPI
419 GasketUgaBlt (
420 EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
421 IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
422 IN EFI_UGA_BLT_OPERATION BltOperation,
423 IN UINTN SourceX,
424 IN UINTN SourceY,
425 IN UINTN DestinationX,
426 IN UINTN DestinationY,
427 IN UINTN Width,
428 IN UINTN Height,
429 IN UINTN Delta OPTIONAL
430 )
431 {
432 return GasketUintn10Args (UgaBlt, (UINTN)UgaIo, (UINTN)BltBuffer, BltOperation, SourceX, SourceY, DestinationX, DestinationY, Width, Height, Delta);
433 }
434
435 #endif
436