Port EdkUnixPkg to UnixPkg. The changes are listed as follows:
[edk2.git] / UnixPkg / Include / Protocol / UnixThunk.h
bloba0908a0c45700790de2dbab1ceb58d9dda6a98cc
1 /*++
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
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.
12 Module Name:
14 UnixThunk.h
16 Abstract:
18 This protocol allows an EFI driver in the Unix emulation environment
19 to make Posix calls.
21 NEVER make an Unix call directly, always make the call via this protocol.
23 There are no This pointers on the protocol member functions as they map
24 exactly into Unix system calls.
26 --*/
28 #ifndef _UNIX_THUNK_H_
29 #define _UNIX_THUNK_H_
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>
50 #define EFI_UNIX_THUNK_PROTOCOL_GUID \
51 { \
52 0xf2e98868, 0x8985, 0x11db, {0x9a, 0x59, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
55 typedef
56 VOID
57 (*UnixSleep) (
58 unsigned long Milliseconds
61 typedef
62 VOID
63 (*UnixExit) (
64 int status // exit code for all threads
67 typedef
68 VOID
69 (*UnixSetTimer) (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs));
70 typedef
71 VOID
72 (*UnixGetLocalTime) (EFI_TIME *Time);
73 typedef
74 struct tm *
75 (*UnixGmTime)(const time_t *timep);
76 typedef
77 long
78 (*UnixGetTimeZone)(void);
79 typedef
80 int
81 (*UnixGetDayLight)(void);
82 typedef
83 int
84 (*UnixPoll)(struct pollfd *pfd, int nfds, int timeout);
85 typedef
86 int
87 (*UnixRead) (int fd, void *buf, int count);
88 typedef
89 int
90 (*UnixWrite) (int fd, const void *buf, int count);
91 typedef
92 char *
93 (*UnixGetenv) (const char *var);
94 typedef
95 int
96 (*UnixOpen) (const char *name, int flags, int mode);
97 typedef
98 long int
99 (*UnixSeek) (int fd, long int off, int whence);
100 typedef
102 (*UnixFtruncate) (int fd, long int len);
103 typedef
105 (*UnixClose) (int fd);
107 typedef
109 (*UnixMkdir)(const char *pathname, mode_t mode);
110 typedef
112 (*UnixRmDir)(const char *pathname);
113 typedef
115 (*UnixUnLink)(const char *pathname);
116 typedef
118 (*UnixGetErrno)(VOID);
119 typedef
120 DIR *
121 (*UnixOpenDir)(const char *pathname);
122 typedef
123 void
124 (*UnixRewindDir)(DIR *dir);
125 typedef
126 struct dirent *
127 (*UnixReadDir)(DIR *dir);
128 typedef
130 (*UnixCloseDir)(DIR *dir);
131 typedef
133 (*UnixStat)(const char *path, struct stat *buf);
134 typedef
136 (*UnixStatFs)(const char *path, struct statfs *buf);
137 typedef
139 (*UnixRename)(const char *oldpath, const char *newpath);
140 typedef
141 time_t
142 (*UnixMkTime)(struct tm *tm);
143 typedef
145 (*UnixFSync)(int fd);
146 typedef
148 (*UnixChmod)(const char *path, mode_t mode);
149 typedef
151 (*UnixUTime)(const char *filename, const struct utimbuf *buf);
153 struct _EFI_UNIX_UGA_IO_PROTOCOL;
154 typedef
155 EFI_STATUS
156 (*UnixUgaCreate)(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo,
157 CONST CHAR16 *Title);
159 typedef
161 (*UnixTcflush) (int fildes, int queue_selector);
163 typedef
164 void
165 (*UnixPerror) (__const char *__s);
167 typedef
168 int
169 (*UnixIoCtl) (int fd, unsigned long int __request, ...);
171 typedef
172 int
173 (*UnixFcntl) (int __fd, int __cmd, ...);
175 typedef
176 int
177 (*UnixCfsetispeed) (struct termios *__termios_p, speed_t __speed);
179 typedef
180 int
181 (*UnixCfsetospeed) (struct termios *__termios_p, speed_t __speed);
183 typedef
184 int
185 (*UnixTcgetattr) (int __fd, struct termios *__termios_p);
187 typedef
188 int
189 (*UnixTcsetattr) (int __fd, int __optional_actions,
190 __const struct termios *__termios_p);
196 #define EFI_UNIX_THUNK_PROTOCOL_SIGNATURE EFI_SIGNATURE_32 ('L', 'N', 'X', 'T')
198 typedef struct _EFI_UNIX_THUNK_PROTOCOL {
199 UINT64 Signature;
201 UnixSleep Sleep;
202 UnixExit Exit;
203 UnixSetTimer SetTimer;
204 UnixGetLocalTime GetLocalTime;
205 UnixGmTime GmTime;
206 UnixGetTimeZone GetTimeZone;
207 UnixGetDayLight GetDayLight;
208 UnixPoll Poll;
209 UnixRead Read;
210 UnixWrite Write;
211 UnixGetenv Getenv;
212 UnixOpen Open;
213 UnixSeek Lseek;
214 UnixFtruncate FTruncate;
215 UnixClose Close;
216 UnixMkdir MkDir;
217 UnixRmDir RmDir;
218 UnixUnLink UnLink;
219 UnixGetErrno GetErrno;
220 UnixOpenDir OpenDir;
221 UnixRewindDir RewindDir;
222 UnixReadDir ReadDir;
223 UnixCloseDir CloseDir;
224 UnixStat Stat;
225 UnixStatFs StatFs;
226 UnixRename Rename;
227 UnixMkTime MkTime;
228 UnixFSync FSync;
229 UnixChmod Chmod;
230 UnixUTime UTime;
231 UnixTcflush Tcflush;
232 UnixUgaCreate UgaCreate;
233 UnixPerror Perror;
234 UnixIoCtl IoCtl;
235 UnixFcntl Fcntl;
236 UnixCfsetispeed Cfsetispeed;
237 UnixCfsetospeed Cfsetospeed;
238 UnixTcgetattr Tcgetattr;
239 UnixTcsetattr Tcsetattr;
240 } EFI_UNIX_THUNK_PROTOCOL;
242 extern EFI_GUID gEfiUnixThunkProtocolGuid;
244 #endif