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