Unix version of EFI emulator
[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
32 #define EFI_UNIX_THUNK_PROTOCOL_GUID \
33 { \
34 0xf2e98868, 0x8985, 0x11db, {0x9a, 0x59, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
35 }
36
37 typedef
38 VOID
39 (*UnixSleep) (
40 unsigned long Milliseconds
41 );
42
43 typedef
44 VOID
45 (*UnixExit) (
46 int status // exit code for all threads
47 );
48
49 typedef
50 VOID
51 (*UnixSetTimer) (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs));
52 typedef
53 VOID
54 (*UnixGetLocalTime) (EFI_TIME *Time);
55 typedef
56 struct tm *
57 (*UnixGmTime)(const time_t *timep);
58 typedef
59 long
60 (*UnixGetTimeZone)(void);
61 typedef
62 int
63 (*UnixGetDayLight)(void);
64 typedef
65 int
66 (*UnixPoll)(struct pollfd *pfd, int nfds, int timeout);
67 typedef
68 int
69 (*UnixRead) (int fd, void *buf, int count);
70 typedef
71 int
72 (*UnixWrite) (int fd, const void *buf, int count);
73 typedef
74 char *
75 (*UnixGetenv) (const char *var);
76 typedef
77 int
78 (*UnixOpen) (const char *name, int flags, int mode);
79 typedef
80 long int
81 (*UnixSeek) (int fd, long int off, int whence);
82 typedef
83 int
84 (*UnixFtruncate) (int fd, long int len);
85 typedef
86 int
87 (*UnixClose) (int fd);
88
89 typedef
90 int
91 (*UnixMkdir)(const char *pathname, mode_t mode);
92 typedef
93 int
94 (*UnixRmDir)(const char *pathname);
95 typedef
96 int
97 (*UnixUnLink)(const char *pathname);
98 typedef
99 int
100 (*UnixGetErrno)(VOID);
101 typedef
102 DIR *
103 (*UnixOpenDir)(const char *pathname);
104 typedef
105 void
106 (*UnixRewindDir)(DIR *dir);
107 typedef
108 struct dirent *
109 (*UnixReadDir)(DIR *dir);
110 typedef
111 int
112 (*UnixCloseDir)(DIR *dir);
113 typedef
114 int
115 (*UnixStat)(const char *path, struct stat *buf);
116 typedef
117 int
118 (*UnixStatFs)(const char *path, struct statfs *buf);
119 typedef
120 int
121 (*UnixRename)(const char *oldpath, const char *newpath);
122 typedef
123 time_t
124 (*UnixMkTime)(struct tm *tm);
125 typedef
126 int
127 (*UnixFSync)(int fd);
128 typedef
129 int
130 (*UnixChmod)(const char *path, mode_t mode);
131 typedef
132 int
133 (*UnixUTime)(const char *filename, const struct utimbuf *buf);
134
135 struct _EFI_UNIX_UGA_IO_PROTOCOL;
136 typedef
137 EFI_STATUS
138 (*UnixUgaCreate)(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo,
139 CONST CHAR16 *Title);
140
141 //
142 //
143 //
144
145 #define EFI_UNIX_THUNK_PROTOCOL_SIGNATURE EFI_SIGNATURE_32 ('L', 'N', 'X', 'T')
146
147 typedef struct _EFI_UNIX_THUNK_PROTOCOL {
148 UINT64 Signature;
149
150 UnixSleep Sleep;
151 UnixExit Exit;
152 UnixSetTimer SetTimer;
153 UnixGetLocalTime GetLocalTime;
154 UnixGmTime GmTime;
155 UnixGetTimeZone GetTimeZone;
156 UnixGetDayLight GetDayLight;
157 UnixPoll Poll;
158 UnixRead Read;
159 UnixWrite Write;
160 UnixGetenv Getenv;
161 UnixOpen Open;
162 UnixSeek Lseek;
163 UnixFtruncate FTruncate;
164 UnixClose Close;
165 UnixMkdir MkDir;
166 UnixRmDir RmDir;
167 UnixUnLink UnLink;
168 UnixGetErrno GetErrno;
169 UnixOpenDir OpenDir;
170 UnixRewindDir RewindDir;
171 UnixReadDir ReadDir;
172 UnixCloseDir CloseDir;
173 UnixStat Stat;
174 UnixStatFs StatFs;
175 UnixRename Rename;
176 UnixMkTime MkTime;
177 UnixFSync FSync;
178 UnixChmod Chmod;
179 UnixUTime UTime;
180
181 UnixUgaCreate UgaCreate;
182
183 } EFI_UNIX_THUNK_PROTOCOL;
184
185 extern EFI_GUID gEfiUnixThunkProtocolGuid;
186
187 #endif