Add emulated serialIo device driver for EdkUnixPkg
[mirror_edk2.git] / EdkUnixPkg / 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
33 #define EFI_UNIX_THUNK_PROTOCOL_GUID \
34 { \
35 0xf2e98868, 0x8985, 0x11db, {0x9a, 0x59, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
36 }
37
38 typedef
39 VOID
40 (*UnixSleep) (
41 unsigned long Milliseconds
42 );
43
44 typedef
45 VOID
46 (*UnixExit) (
47 int status // exit code for all threads
48 );
49
50 typedef
51 VOID
52 (*UnixSetTimer) (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs));
53 typedef
54 VOID
55 (*UnixGetLocalTime) (EFI_TIME *Time);
56 typedef
57 struct tm *
58 (*UnixGmTime)(const time_t *timep);
59 typedef
60 long
61 (*UnixGetTimeZone)(void);
62 typedef
63 int
64 (*UnixGetDayLight)(void);
65 typedef
66 int
67 (*UnixPoll)(struct pollfd *pfd, int nfds, int timeout);
68 typedef
69 int
70 (*UnixRead) (int fd, void *buf, int count);
71 typedef
72 int
73 (*UnixWrite) (int fd, const void *buf, int count);
74 typedef
75 char *
76 (*UnixGetenv) (const char *var);
77 typedef
78 int
79 (*UnixOpen) (const char *name, int flags, int mode);
80 typedef
81 long int
82 (*UnixSeek) (int fd, long int off, int whence);
83 typedef
84 int
85 (*UnixFtruncate) (int fd, long int len);
86 typedef
87 int
88 (*UnixClose) (int fd);
89
90 typedef
91 int
92 (*UnixMkdir)(const char *pathname, mode_t mode);
93 typedef
94 int
95 (*UnixRmDir)(const char *pathname);
96 typedef
97 int
98 (*UnixUnLink)(const char *pathname);
99 typedef
100 int
101 (*UnixGetErrno)(VOID);
102 typedef
103 DIR *
104 (*UnixOpenDir)(const char *pathname);
105 typedef
106 void
107 (*UnixRewindDir)(DIR *dir);
108 typedef
109 struct dirent *
110 (*UnixReadDir)(DIR *dir);
111 typedef
112 int
113 (*UnixCloseDir)(DIR *dir);
114 typedef
115 int
116 (*UnixStat)(const char *path, struct stat *buf);
117 typedef
118 int
119 (*UnixStatFs)(const char *path, struct statfs *buf);
120 typedef
121 int
122 (*UnixRename)(const char *oldpath, const char *newpath);
123 typedef
124 time_t
125 (*UnixMkTime)(struct tm *tm);
126 typedef
127 int
128 (*UnixFSync)(int fd);
129 typedef
130 int
131 (*UnixChmod)(const char *path, mode_t mode);
132 typedef
133 int
134 (*UnixUTime)(const char *filename, const struct utimbuf *buf);
135
136 struct _EFI_UNIX_UGA_IO_PROTOCOL;
137 typedef
138 EFI_STATUS
139 (*UnixUgaCreate)(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo,
140 CONST CHAR16 *Title);
141
142 typedef
143 int
144 (*UnixTcflush) (int fildes, int queue_selector);
145
146 typedef
147 void
148 (*UnixPerror) (__const char *__s);
149
150 typedef
151 void
152 (*UnixPrintf) (const char* format, ...);
153
154 typedef
155 int
156 (*UnixIoCtl) (int fd, unsigned long int __request, ...);
157
158 typedef
159 int
160 (*UnixFcntl) (int __fd, int __cmd, ...);
161
162 typedef
163 int
164 (*UnixCfsetispeed) (struct termios *__termios_p, speed_t __speed);
165
166 typedef
167 int
168 (*UnixCfsetospeed) (struct termios *__termios_p, speed_t __speed);
169
170 typedef
171 int
172 (*UnixTcgetattr) (int __fd, struct termios *__termios_p);
173
174 typedef
175 int
176 (*UnixTcsetattr) (int __fd, int __optional_actions,
177 __const struct termios *__termios_p);
178
179 //
180 //
181 //
182
183 #define EFI_UNIX_THUNK_PROTOCOL_SIGNATURE EFI_SIGNATURE_32 ('L', 'N', 'X', 'T')
184
185 typedef struct _EFI_UNIX_THUNK_PROTOCOL {
186 UINT64 Signature;
187
188 UnixSleep Sleep;
189 UnixExit Exit;
190 UnixSetTimer SetTimer;
191 UnixGetLocalTime GetLocalTime;
192 UnixGmTime GmTime;
193 UnixGetTimeZone GetTimeZone;
194 UnixGetDayLight GetDayLight;
195 UnixPoll Poll;
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;
218 UnixTcflush Tcflush;
219 UnixUgaCreate UgaCreate;
220 UnixPerror Perror;
221 UnixPrintf Printf;
222 UnixIoCtl IoCtl;
223 UnixFcntl Fcntl;
224 UnixCfsetispeed Cfsetispeed;
225 UnixCfsetospeed Cfsetospeed;
226 UnixTcgetattr Tcgetattr;
227 UnixTcsetattr Tcsetattr;
228 } EFI_UNIX_THUNK_PROTOCOL;
229
230 extern EFI_GUID gEfiUnixThunkProtocolGuid;
231
232 #endif