3 Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
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
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
, unsigned 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 GasketUintn (rewinddir
, (UINTN
)dir
);
180 Gasketreaddir (DIR *dir
)
182 return (struct dirent
*)(UINTN
)GasketUintn (readdir
, (UINTN
)dir
);
187 Gasketclosedir (DIR *dir
)
189 return GasketUintn (closedir
, (UINTN
)dir
);
194 Gasketstat (const char *path
, STAT_FIX
*buf
)
196 return GasketUintnUintn (stat
, (UINTN
)path
, (UINTN
)buf
);
201 Gasketstatfs (const char *path
, struct statfs
*buf
)
203 return GasketUintnUintn (statfs
, (UINTN
)path
, (UINTN
)buf
);
208 Gasketrename (const char *oldpath
, const char *newpath
)
210 return GasketUintnUintn (rename
, (UINTN
)oldpath
, (UINTN
)newpath
);
215 Gasketmktime (struct tm
*tm
)
217 return GasketUintn (mktime
, (UINTN
)tm
);
224 return GasketUintn (fsync
, fd
);
229 Gasketchmod (const char *path
, mode_t mode
)
231 return GasketUintnUint16 (chmod
, (UINTN
)path
, mode
);
236 Gasketutime (const char *filename
, const struct utimbuf
*buf
)
238 return GasketUintnUintn (utime
, (UINTN
)filename
, (UINTN
)buf
);
243 Gaskettcflush (int fildes
, int queue_selector
)
245 return GasketUintnUintn (tcflush
, fildes
, queue_selector
);
250 GasketUgaCreate (struct _EFI_UNIX_UGA_IO_PROTOCOL
**UgaIo
, CONST CHAR16
*Title
)
252 return GasketUintnUintn (UgaCreate
, (UINTN
)UgaIo
, (UINTN
)Title
);
257 Gasketperror (__const
char *__s
)
259 GasketUintn (perror
, (UINTN
)__s
);
266 // ... is always an int or pointer to device specific data structure
269 Gasketioctl (int fd
, unsigned long int __request
, void *Arg
)
271 return GasketUintnUintnUintn (ioctl
, fd
, __request
, (UINTN
)Arg
);
276 Gasketfcntl (int __fd
, int __cmd
, void *Arg
)
278 return GasketUintnUintnUintn (fcntl
, __fd
, __cmd
, (UINTN
)Arg
);
284 Gasketcfsetispeed (struct termios
*__termios_p
, speed_t __speed
)
286 return GasketUintnUintn (cfsetispeed
, (UINTN
)__termios_p
, __speed
);
291 Gasketcfsetospeed (struct termios
*__termios_p
, speed_t __speed
)
293 return GasketUintnUintn (cfsetospeed
, (UINTN
)__termios_p
, __speed
);
298 Gaskettcgetattr (int __fd
, struct termios
*__termios_p
)
300 return GasketUintnUintn (tcgetattr
, __fd
, (UINTN
)__termios_p
);
305 Gaskettcsetattr (int __fd
, int __optional_actions
, __const
struct termios
*__termios_p
)
307 return GasketUintnUintnUintn (tcsetattr
, __fd
, __optional_actions
, (UINTN
)__termios_p
);
314 GasketUnixPeCoffGetEntryPoint (
316 IN OUT VOID
**EntryPoint
319 return GasketUintnUintn (SecPeCoffGetEntryPoint
, (UINTN
)Pe32Data
, (UINTN
)EntryPoint
);
325 GasketUnixPeCoffRelocateImageExtraAction (
326 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
329 GasketUintn (SecPeCoffRelocateImageExtraAction
, (UINTN
)ImageContext
);
336 GasketUnixPeCoffUnloadImageExtraAction (
337 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT
*ImageContext
340 GasketUintn (SecPeCoffLoaderUnloadImageExtraAction
, (UINTN
)ImageContext
);
346 // Gasket functions for EFI_UNIX_UGA_IO_PROTOCOL
351 GasketUgaClose (EFI_UNIX_UGA_IO_PROTOCOL
*UgaIo
)
353 return GasketUintn (UgaClose
, (UINTN
)UgaIo
);
358 GasketUgaSize (EFI_UNIX_UGA_IO_PROTOCOL
*UgaIo
, UINT32 Width
, UINT32 Height
)
360 return GasketUintnUintnUintn (UgaSize
, (UINTN
)UgaIo
, Width
, Height
);
365 GasketUgaCheckKey (EFI_UNIX_UGA_IO_PROTOCOL
*UgaIo
)
367 return GasketUintn (UgaCheckKey
, (UINTN
)UgaIo
);
372 GasketUgaKeySetState (EFI_UNIX_UGA_IO_PROTOCOL
*UgaIo
, EFI_KEY_TOGGLE_STATE
*KeyToggleState
)
374 return GasketUintnUintn (UgaGetKey
, (UINTN
)UgaIo
, (UINTN
)KeyToggleState
);
379 GasketUgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL
*UgaIo
, EFI_KEY_DATA
*key
)
381 return GasketUintnUintn (UgaGetKey
, (UINTN
)UgaIo
, (UINTN
)key
);
386 GasketUgaRegisterKeyNotify (
387 IN EFI_UNIX_UGA_IO_PROTOCOL
*UgaIo
,
388 IN UGA_REGISTER_KEY_NOTIFY_CALLBACK CallBack
,
392 return GasketUintnUintnUintn (UgaRegisterKeyNotify
, (UINTN
)UgaIo
, (UINTN
)CallBack
, (UINTN
)Context
);
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
404 return GasketUintnUintnUintnUintn (UgaBlt
, (UINTN
)UgaIo
, (UINTN
)BltBuffer
, (UINTN
)BltOperation
, (UINTN
)Args
);
409 GasketUgaCheckPointer (EFI_UNIX_UGA_IO_PROTOCOL
*UgaIo
)
411 return GasketUintn (UgaCheckPointer
, (UINTN
)UgaIo
);
416 GasketUgaGetPointerState (EFI_UNIX_UGA_IO_PROTOCOL
*UgaIo
, EFI_SIMPLE_POINTER_STATE
*state
)
418 return GasketUintnUintn (UgaGetPointerState
, (UINTN
)UgaIo
, (UINTN
)state
);
422 GasketUnixEnableInterrupt (void)
424 GasketVoid (UnixEnableInterrupt
);
428 GasketUnixDisableInterrupt (void)
430 GasketVoid (UnixDisableInterrupt
);
435 Gasketgetifaddrs (struct ifaddrs
**ifap
)
437 return( GasketUintn( getifaddrs
, ( UINTN
) ifap
) );
442 Gasketfreeifaddrs (struct ifaddrs
*ifap
)
444 GasketUintn( freeifaddrs
, ( UINTN
) ifap
);
449 Gasketsocket (int domain
, int type
, int protocol
)
451 return( GasketUintnUintnUintn( socket
, domain
, type
, protocol
) );