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