]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/Sec/Gasket.c
Changed the X64 gasket so it would be possible to port it to deal with the Unix to...
[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
318
319 RETURN_STATUS
320 GasketUnixPeCoffGetEntryPoint (
321 IN VOID *Pe32Data,
322 IN OUT VOID **EntryPoint
323 )
324 {
325 return GasketUintnUintn (SecPeCoffGetEntryPoint, (UINTN)Pe32Data, (UINTN)EntryPoint);
326 }
327
328
329
330 VOID
331 GasketUnixPeCoffRelocateImageExtraAction (
332 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
333 )
334 {
335 GasketUintn (SecPeCoffRelocateImageExtraAction, (UINTN)ImageContext);
336 return;
337 }
338
339
340
341 VOID
342 GasketUnixPeCoffUnloadImageExtraAction (
343 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
344 )
345 {
346 GasketUintn (SecPeCoffLoaderUnloadImageExtraAction, (UINTN)ImageContext);
347 return;
348 }
349
350
351 //
352 // Gasket functions for EFI_UNIX_UGA_IO_PROTOCOL
353 //
354
355 EFI_STATUS
356 EFIAPI
357 GasketUgaClose (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
358 {
359 return GasketUintn (UgaClose, (UINTN)UgaIo);
360 }
361
362 EFI_STATUS
363 EFIAPI
364 GasketUgaSize (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, UINT32 Width, UINT32 Height)
365 {
366 return GasketUintnUintnUintn (UgaSize, (UINTN)UgaIo, Width, Height);
367 }
368
369 EFI_STATUS
370 EFIAPI
371 GasketUgaCheckKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
372 {
373 return GasketUintn (UgaCheckKey, (UINTN)UgaIo);
374 }
375
376 EFI_STATUS
377 EFIAPI
378 GasketUgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_INPUT_KEY *key)
379 {
380 return GasketUintnUintn (UgaGetKey, (UINTN)UgaIo, (UINTN)key);
381 }
382
383 EFI_STATUS
384 EFIAPI
385 GasketUgaBlt (
386 EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
387 IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
388 IN EFI_UGA_BLT_OPERATION BltOperation,
389 IN UINTN SourceX,
390 IN UINTN SourceY,
391 IN UINTN DestinationX,
392 IN UINTN DestinationY,
393 IN UINTN Width,
394 IN UINTN Height,
395 IN UINTN Delta OPTIONAL
396 )
397 {
398 return GasketUintn10Args (UgaBlt, (UINTN)UgaIo, (UINTN)BltBuffer, BltOperation, SourceX, SourceY, DestinationX, DestinationY, Width, Height, Delta);
399 }
400
401 #endif
402