]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/Include/Protocol/UnixThunk.h
ba325bff87f0306758ad03565f74d2df9e6d84bb
[mirror_edk2.git] / UnixPkg / Include / Protocol / UnixThunk.h
1 /*++
2
3 Copyright (c) 2004, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 UnixThunk.h
15
16 Abstract:
17
18 This protocol allows an EFI driver in the Unix emulation environment
19 to make Posix calls.
20
21 NEVER make an Unix call directly, always make the call via this protocol.
22
23 There are no This pointers on the protocol member functions as they map
24 exactly into Unix system calls.
25
26 --*/
27
28 #ifndef _UNIX_THUNK_H_
29 #define _UNIX_THUNK_H_
30
31 #include <sys/termios.h>
32 #include <stdio.h>
33 #include <sys/time.h>
34 #include <sys/dir.h>
35 #include <unistd.h>
36 #include <poll.h>
37 #include <sys/types.h>
38 #include <sys/stat.h>
39 #include <fcntl.h>
40 #include <time.h>
41 #include <signal.h>
42 #include <errno.h>
43 #include <string.h>
44 #include <stdlib.h>
45 #include <termio.h>
46 #include <sys/ioctl.h>
47 #include <sys/vfs.h>
48 #include <utime.h>
49 #include <dlfcn.h>
50
51 #define EFI_UNIX_THUNK_PROTOCOL_GUID \
52 { \
53 0xf2e98868, 0x8985, 0x11db, {0x9a, 0x59, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
54 }
55
56 typedef
57 VOID
58 (*UnixSleep) (
59 unsigned long Milliseconds
60 );
61
62 typedef
63 VOID
64 (*UnixExit) (
65 int status // exit code for all threads
66 );
67
68 typedef
69 VOID
70 (*UnixSetTimer) (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs));
71 typedef
72 VOID
73 (*UnixGetLocalTime) (EFI_TIME *Time);
74 typedef
75 struct tm *
76 (*UnixGmTime)(const time_t *timep);
77 typedef
78 long
79 (*UnixGetTimeZone)(void);
80 typedef
81 int
82 (*UnixGetDayLight)(void);
83 typedef
84 int
85 (*UnixPoll)(struct pollfd *pfd, int nfds, int timeout);
86 typedef
87 int
88 (*UnixRead) (int fd, void *buf, int count);
89 typedef
90 int
91 (*UnixWrite) (int fd, const void *buf, int count);
92 typedef
93 char *
94 (*UnixGetenv) (const char *var);
95 typedef
96 int
97 (*UnixOpen) (const char *name, int flags, int mode);
98 typedef
99 long int
100 (*UnixSeek) (int fd, long int off, int whence);
101 typedef
102 int
103 (*UnixFtruncate) (int fd, long int len);
104 typedef
105 int
106 (*UnixClose) (int fd);
107
108 typedef
109 int
110 (*UnixMkdir)(const char *pathname, mode_t mode);
111 typedef
112 int
113 (*UnixRmDir)(const char *pathname);
114 typedef
115 int
116 (*UnixUnLink)(const char *pathname);
117 typedef
118 int
119 (*UnixGetErrno)(VOID);
120 typedef
121 DIR *
122 (*UnixOpenDir)(const char *pathname);
123 typedef
124 void
125 (*UnixRewindDir)(DIR *dir);
126 typedef
127 struct dirent *
128 (*UnixReadDir)(DIR *dir);
129 typedef
130 int
131 (*UnixCloseDir)(DIR *dir);
132 typedef
133 int
134 (*UnixStat)(const char *path, struct stat *buf);
135 typedef
136 int
137 (*UnixStatFs)(const char *path, struct statfs *buf);
138 typedef
139 int
140 (*UnixRename)(const char *oldpath, const char *newpath);
141 typedef
142 time_t
143 (*UnixMkTime)(struct tm *tm);
144 typedef
145 int
146 (*UnixFSync)(int fd);
147 typedef
148 int
149 (*UnixChmod)(const char *path, mode_t mode);
150 typedef
151 int
152 (*UnixUTime)(const char *filename, const struct utimbuf *buf);
153
154 struct _EFI_UNIX_UGA_IO_PROTOCOL;
155 typedef
156 EFI_STATUS
157 (*UnixUgaCreate)(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo,
158 CONST CHAR16 *Title);
159
160 typedef
161 int
162 (*UnixTcflush) (int fildes, int queue_selector);
163
164 typedef
165 void
166 (*UnixPerror) (__const char *__s);
167
168 typedef
169 int
170 (*UnixIoCtl) (int fd, unsigned long int __request, ...);
171
172 typedef
173 int
174 (*UnixFcntl) (int __fd, int __cmd, ...);
175
176 typedef
177 int
178 (*UnixCfsetispeed) (struct termios *__termios_p, speed_t __speed);
179
180 typedef
181 int
182 (*UnixCfsetospeed) (struct termios *__termios_p, speed_t __speed);
183
184 typedef
185 int
186 (*UnixTcgetattr) (int __fd, struct termios *__termios_p);
187
188 typedef
189 int
190 (*UnixTcsetattr) (int __fd, int __optional_actions,
191 __const struct termios *__termios_p);
192
193 typedef
194 VOID *
195 (*UnixDlopen) (const char *FileName, int Flag);
196
197 typedef
198 char *
199 (*UnixDlerror) (VOID);
200
201 typedef
202 VOID *
203 (*UnixDlsym) (VOID* Handle, const char* Symbol);
204
205
206 //
207 //
208 //
209
210 #define EFI_UNIX_THUNK_PROTOCOL_SIGNATURE SIGNATURE_32 ('L', 'N', 'X', 'T')
211
212 typedef struct _EFI_UNIX_THUNK_PROTOCOL {
213 UINT64 Signature;
214
215 UnixSleep Sleep;
216 UnixExit Exit;
217 UnixSetTimer SetTimer;
218 UnixGetLocalTime GetLocalTime;
219 UnixGmTime GmTime;
220 UnixGetTimeZone GetTimeZone;
221 UnixGetDayLight GetDayLight;
222 UnixPoll Poll;
223 UnixRead Read;
224 UnixWrite Write;
225 UnixGetenv Getenv;
226 UnixOpen Open;
227 UnixSeek Lseek;
228 UnixFtruncate FTruncate;
229 UnixClose Close;
230 UnixMkdir MkDir;
231 UnixRmDir RmDir;
232 UnixUnLink UnLink;
233 UnixGetErrno GetErrno;
234 UnixOpenDir OpenDir;
235 UnixRewindDir RewindDir;
236 UnixReadDir ReadDir;
237 UnixCloseDir CloseDir;
238 UnixStat Stat;
239 UnixStatFs StatFs;
240 UnixRename Rename;
241 UnixMkTime MkTime;
242 UnixFSync FSync;
243 UnixChmod Chmod;
244 UnixUTime UTime;
245 UnixTcflush Tcflush;
246 UnixUgaCreate UgaCreate;
247 UnixPerror Perror;
248 UnixIoCtl IoCtl;
249 UnixFcntl Fcntl;
250 UnixCfsetispeed Cfsetispeed;
251 UnixCfsetospeed Cfsetospeed;
252 UnixTcgetattr Tcgetattr;
253 UnixTcsetattr Tcsetattr;
254 UnixDlopen Dlopen;
255 UnixDlerror Dlerror;
256 UnixDlsym Dlsym;
257 } EFI_UNIX_THUNK_PROTOCOL;
258
259 extern EFI_GUID gEfiUnixThunkProtocolGuid;
260
261 #endif