3 Copyright (c) 2008-2009, Apple Inc. All rights reserved.
5 All rights reserved. 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
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.
21 // Gasket functions for EFI_UNIX_THUNK_PROTOCOL
25 GasketmsSleep (unsigned long Milliseconds
)
27 GasketUintn (msSleep
, Milliseconds
);
32 Gasketexit (int status
)
34 GasketUintn (exit
, status
);
40 GasketSetTimer (UINT64 PeriodMs
, VOID (*CallBack
)(UINT64 DeltaMs
))
42 GasketUint64Uintn (SetTimer
, PeriodMs
, (UINTN
)CallBack
);
48 GasketGetLocalTime (EFI_TIME
*Time
)
50 GasketUintn (GetLocalTime
, (UINTN
)Time
);
56 Gasketgmtime (const time_t *clock
)
58 return (struct tm
*)(UINTN
)GasketUintn (localtime
, (UINTN
)clock
);
63 GasketGetTimeZone (void)
65 return GasketVoid (GetTimeZone
);
70 GasketGetDayLight (void)
72 return GasketVoid (GetDayLight
);
77 Gasketpoll (struct pollfd
*pfd
, int nfds
, int timeout
)
79 return GasketUintnUintnUintn (poll
, (UINTN
)pfd
, nfds
, timeout
);
84 Gasketread (int fd
, void *buf
, int count
)
86 return GasketUintnUintnUintn (read
, fd
, (UINTN
)buf
, count
);
91 Gasketwrite (int fd
, const void *buf
, int count
)
93 return GasketUintnUintnUintn (write
, fd
, (UINTN
)buf
, count
);
98 Gasketgetenv (const char *name
)
100 return (char *)(UINTN
)GasketUintn (getenv
, (UINTN
)name
);
105 Gasketopen (const char *name
, int flags
, int mode
)
107 return GasketUintnUintnUintn (open
, (UINTN
)name
, flags
, mode
);
112 Gasketlseek (int fd
, off_t off
, int whence
)
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
);
123 Gasketftruncate (int fd
, long int len
)
125 return GasketUintnUintn (ftruncate
, fd
, len
);
132 return GasketUintn (close
, fd
);
137 Gasketmkdir (const char *pathname
, mode_t mode
)
139 return GasketUintnUint16 (mkdir
, (UINTN
)pathname
, mode
);
144 Gasketrmdir (const char *pathname
)
146 return GasketUintn (rmdir
, (UINTN
)pathname
);
151 Gasketunlink (const char *pathname
)
153 return GasketUintn (unlink
, (UINTN
)pathname
);
158 GasketGetErrno (void)
160 return GasketVoid (GetErrno
);
165 Gasketopendir (const char *pathname
)
167 return (DIR *)(UINTN
)GasketUintn (opendir
, (UINTN
)pathname
);
172 Gasketrewinddir (DIR *dir
)
174 return (void *)(UINTN
)GasketUintn (rewinddir
, (UINTN
)dir
);
179 Gasketreaddir (DIR *dir
)
181 return (struct dirent
*)(UINTN
)GasketUintn (readdir
, (UINTN
)dir
);
186 Gasketclosedir (DIR *dir
)
188 return GasketUintn (closedir
, (UINTN
)dir
);
193 Gasketstat (const char *path
, STAT_FIX
*buf
)
195 return GasketUintnUintn (stat
, (UINTN
)path
, (UINTN
)buf
);
200 Gasketstatfs (const char *path
, struct statfs
*buf
)
202 return GasketUintnUintn (statfs
, (UINTN
)path
, (UINTN
)buf
);
207 Gasketrename (const char *oldpath
, const char *newpath
)
209 return GasketUintnUintn (rename
, (UINTN
)oldpath
, (UINTN
)newpath
);
214 Gasketmktime (struct tm
*tm
)
216 return GasketUintn (mktime
, (UINTN
)tm
);
223 return GasketUintn (fsync
, fd
);
228 Gasketchmod (const char *path
, mode_t mode
)
230 return GasketUintnUint16 (chmod
, (UINTN
)path
, mode
);
235 Gasketutime (const char *filename
, const struct utimbuf
*buf
)
237 return GasketUintnUintn (utime
, (UINTN
)filename
, (UINTN
)buf
);
242 Gaskettcflush (int fildes
, int queue_selector
)
244 return GasketUintnUintn (tcflush
, fildes
, queue_selector
);
249 GasketUgaCreate (struct _EFI_UNIX_UGA_IO_PROTOCOL
**UgaIo
, CONST CHAR16
*Title
)
251 return GasketUintnUintn (UgaCreate
, (UINTN
)UgaIo
, (UINTN
)Title
);
256 Gasketperror (__const
char *__s
)
258 GasketUintn (perror
, (UINTN
)__s
);
265 // ... is always an int or pointer to device specific data structure
268 Gasketioctl (int fd
, unsigned long int __request
, ...)
272 VA_START (Marker
, __request
);
273 return GasketUintnUintnUintn (ioctl
, fd
, __request
, VA_ARG (Marker
, UINTN
));
278 Gasketfcntl (int __fd
, int __cmd
, ...)
282 VA_START (Marker
, __cmd
);
283 return GasketUintnUintnUintn (fcntl
, __fd
, __cmd
, VA_ARG (Marker
, UINTN
));
289 Gasketcfsetispeed (struct termios
*__termios_p
, speed_t __speed
)
291 return GasketUintnUintn (cfsetispeed
, (UINTN
)__termios_p
, __speed
);
296 Gasketcfsetospeed (struct termios
*__termios_p
, speed_t __speed
)
298 return GasketUintnUintn (cfsetospeed
, (UINTN
)__termios_p
, __speed
);
303 Gaskettcgetattr (int __fd
, struct termios
*__termios_p
)
305 return GasketUintnUintn (tcgetattr
, __fd
, (UINTN
)__termios_p
);
310 Gaskettcsetattr (int __fd
, int __optional_actions
, __const
struct termios
*__termios_p
)
312 return GasketUintnUintnUintn (tcsetattr
, __fd
, __optional_actions
, (UINTN
)__termios_p
);
317 Gasketsigaction (int sig
, const struct sigaction
*act
, struct sigaction
*oact
)
319 return GasketUintnUintn (sigaction
, (UINTN
)act
, (UINTN
)oact
);
324 Gasketsetcontext (const ucontext_t
*ucp
)
326 return GasketUintn (setcontext
, (UINTN
)ucp
);
331 Gasketgetcontext (ucontext_t
*ucp
)
333 return GasketUintn (getcontext
, (UINTN
)ucp
);
338 Gasketsigemptyset (sigset_t
*set
)
340 return GasketUintn (sigemptyset
, (UINTN
)set
);
345 Gasketsigaltstack (const stack_t
*ss
, stack_t
*oss
)
347 return GasketUintnUintn (sigaltstack
, (UINTN
)ss
, (UINTN
)oss
);
353 GasketUnixPeCoffGetEntryPoint (
355 IN OUT VOID
**EntryPoint
358 return GasketUintnUintn (SecPeCoffGetEntryPoint
, (UINTN
)Pe32Data
, (UINTN
)EntryPoint
);
364 GasketUnixPeCoffRelocateImageExtraAction (
365 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
368 GasketUintn (SecPeCoffRelocateImageExtraAction
, (UINTN
)ImageContext
);
375 GasketPeCoffLoaderUnloadImageExtraAction (
376 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
379 GasketUintn (SecPeCoffLoaderUnloadImageExtraAction
, (UINTN
)ImageContext
);
385 // Gasket functions for EFI_UNIX_UGA_IO_PROTOCOL
390 GasketUgaClose (EFI_UNIX_UGA_IO_PROTOCOL
*UgaIo
)
392 return GasketUintn (UgaClose
, (UINTN
)UgaIo
);
397 GasketUgaSize (EFI_UNIX_UGA_IO_PROTOCOL
*UgaIo
, UINT32 Width
, UINT32 Height
)
399 return GasketUintnUintnUintn (UgaSize
, (UINTN
)UgaIo
, Width
, Height
);
404 GasketUgaCheckKey (EFI_UNIX_UGA_IO_PROTOCOL
*UgaIo
)
406 return GasketUintn (UgaCheckKey
, (UINTN
)UgaIo
);
411 GasketUgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL
*UgaIo
, EFI_INPUT_KEY
*key
)
413 return GasketUintnUintn (UgaGetKey
, (UINTN
)UgaIo
, (UINTN
)key
);
419 EFI_UNIX_UGA_IO_PROTOCOL
*UgaIo
,
420 IN EFI_UGA_PIXEL
*BltBuffer OPTIONAL
,
421 IN EFI_UGA_BLT_OPERATION BltOperation
,
424 IN UINTN DestinationX
,
425 IN UINTN DestinationY
,
428 IN UINTN Delta OPTIONAL
431 return GasketUintn10Args (UgaBlt
, (UINTN
)UgaIo
, (UINTN
)BltBuffer
, BltOperation
, SourceX
, SourceY
, DestinationX
, DestinationY
, Width
, Height
, Delta
);