]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/Include/sys/EfiSysCall.h
Update or add comments to files and functions for use by Doxygen.
[mirror_edk2.git] / StdLib / Include / sys / EfiSysCall.h
CommitLineData
2aa62f2b 1/** @file\r
2 Function declarations for UEFI "system calls".\r
3\r
61403bd7 4 The following macros are defined in this file:<BR>\r
5@verbatim\r
6 STDIN_FILENO 0 standard input file descriptor\r
7 STDOUT_FILENO 1 standard output file descriptor\r
8 STDERR_FILENO 2 standard error file descriptor\r
9 F_OK 0 test for existence of file\r
10 X_OK 0x01 test for execute or search permission\r
11 W_OK 0x02 test for write permission\r
12 R_OK 0x04 test for read permission\r
13 SEEK_SET 0 set file offset to offset\r
14 SEEK_CUR 1 set file offset to current plus offset\r
15 SEEK_END 2 set file offset to EOF plus offset\r
16 VALID_OPEN 1\r
17 VALID_CLOSED 0\r
18 VALID_DONT_CARE -1\r
19@endverbatim\r
20\r
21 The following types are defined in this file:<BR>\r
22@verbatim\r
23 struct stat; Structure declared in <sys/stat.h>\r
24@endverbatim\r
25\r
26 The following functions are declared in this file:<BR>\r
27@verbatim\r
28 ############### System Calls used in stdio.\r
29 int close (int fd);\r
30 ssize_t read (int fd, void *buf, size_t n);\r
31 ssize_t write (int fd, const void *buf, size_t n);\r
32 int unlink (const char *name);\r
33 int dup2 (int, int);\r
34 int rmdir (const char *);\r
35 int isatty (int);\r
36\r
37 ############### System Calls which are also declared in sys/fcntl.h.\r
38 int open (const char *name, int oflags, int mode);\r
39 int creat (const char *, mode_t);\r
40 int fcntl (int, int, ...);\r
41\r
42 ############### System Calls which are also declared in stat.h.\r
43 int mkdir (const char *, mode_t);\r
44 int fstat (int, struct stat *);\r
45 int lstat (const char *, struct stat *);\r
46 int stat (const char *, void *);\r
47 int chmod (const char *, mode_t);\r
48\r
49 ############### System Calls which are also declared in sys/types.h.\r
50 off_t lseek (int, off_t, int);\r
51 int truncate (const char *, off_t);\r
52 int ftruncate (int, off_t); // IEEE Std 1003.1b-93\r
53\r
54 ############### EFI-specific Functions.\r
55 int DeleteOnClose (int fd); Mark an open file to be deleted when closed.\r
56 int FindFreeFD (int MinFd);\r
57 BOOLEAN ValidateFD (int fd, int IsOpen);\r
58\r
59 ############### Functions added for compatibility.\r
60 char *getcwd (char *, size_t);\r
61 int chdir (const char *);\r
62@endverbatim\r
2aa62f2b 63\r
53e1e5c6 64 Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
2aa62f2b 65 This program and the accompanying materials are licensed and made available under\r
66 the terms and conditions of the BSD License that accompanies this distribution.\r
67 The full text of the license may be found at\r
61403bd7 68 http://opensource.org/licenses/bsd-license.\r
2aa62f2b 69\r
70 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
71 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
2aa62f2b 72**/\r
73#ifndef _EFI_SYS_CALL_H\r
74#define _EFI_SYS_CALL_H\r
75\r
76#include <sys/EfiCdefs.h>\r
77#include <sys/types.h>\r
78\r
53e1e5c6 79struct stat; /* Structure declared in <sys/stat.h> */\r
2aa62f2b 80\r
61403bd7 81#define STDIN_FILENO 0 /**< standard input file descriptor */\r
82#define STDOUT_FILENO 1 /**< standard output file descriptor */\r
83#define STDERR_FILENO 2 /**< standard error file descriptor */\r
2aa62f2b 84\r
85/* access function */\r
61403bd7 86#define F_OK 0 /**< test for existence of file */\r
87#define X_OK 0x01 /**< test for execute or search permission */\r
88#define W_OK 0x02 /**< test for write permission */\r
89#define R_OK 0x04 /**< test for read permission */\r
2aa62f2b 90\r
53e1e5c6 91/* whence values for lseek(2)\r
92 Always ensure that these are consistent with <stdio.h> and <unistd.h>!\r
93*/\r
94#ifndef SEEK_SET\r
61403bd7 95 #define SEEK_SET 0 /**< set file offset to offset */\r
53e1e5c6 96#endif\r
97#ifndef SEEK_CUR\r
61403bd7 98 #define SEEK_CUR 1 /**< set file offset to current plus offset */\r
53e1e5c6 99#endif\r
100#ifndef SEEK_END\r
61403bd7 101 #define SEEK_END 2 /**< set file offset to EOF plus offset */\r
53e1e5c6 102#endif\r
103\r
104// Parameters for the ValidateFD function.\r
105#define VALID_OPEN 1\r
106#define VALID_CLOSED 0\r
107#define VALID_DONT_CARE -1\r
2aa62f2b 108\r
109__BEGIN_DECLS\r
2aa62f2b 110/* EFI versions of BSD system calls used in stdio */\r
61403bd7 111\r
112 /** Close a file or device.\r
113\r
114 @param[in] fd File Descriptor for the file or device to close.\r
115\r
116 @retval 0 Successful completion.\r
117 @retval -1 An error occurred, identified by errno.\r
118 - EBADF fd is not a valid File Descriptor.\r
119 - EINTR The function was interrupted by a signal.\r
120 - EIO An I/O error occurred.\r
121 **/\r
122 int close (int fd);\r
123\r
124 /** Read from a file or device.\r
125\r
126 @param[in] fd File Descriptor for the file or device to read.\r
127 @param[in] buf Buffer to read data into.\r
128 @param[in] N Maximum number of bytes to read.\r
129\r
130 @return On successful completion, read returns a non-negative integer\r
131 indicating the number of bytes actually read. Otherwise, it\r
132 returns -1 and sets errno as follows:\r
133 - EAGAIN\r
134 - EWOULDBLOCK\r
135 - EBADF\r
136 - EBADMSG\r
137 - EINTR\r
138 - EINVAL\r
139 - EIO\r
140 - EISDIR\r
141 - EOVERFLOW\r
142 - ECONNRESET\r
143 - ENOTCONN\r
144 - ETIMEDOUT\r
145 - ENOBUFS\r
146 - ENOMEM\r
147 - ENXIO\r
148 **/\r
149 ssize_t read (int fd, void *buf, size_t n);\r
150\r
151 /** Write to a file or device.\r
152\r
153 @param[in] fd File Descriptor for the file or device to write.\r
154 @param[in] buf Buffer to write data from.\r
155 @param[in] N Maximum number of bytes to write.\r
156\r
157 @return On successful completion, write returns a non-negative integer\r
158 indicating the number of bytes actually written. Otherwise, it\r
159 returns -1 and sets errno as follows:\r
160 - EAGAIN\r
161 - EWOULDBLOCK\r
162 - EBADF\r
163 - EFBIG\r
164 - EINTR\r
165 - EINVAL\r
166 - EIO\r
167 - ENOSPC\r
168 - EPIPE\r
169 - ERANGE\r
170 - ECONNRESET\r
171 - ENOBUFS\r
172 - ENXIO\r
173 - ENETDOWN\r
174 - ENETUNREACH\r
175 **/\r
176 ssize_t write (int fd, const void *buf, size_t n);\r
177\r
178 /** Unlink (delete) a file.\r
179\r
180 @param[in] name The name of the file to be deleted.\r
181\r
182 @retval 0 Successful completion.\r
183 @retval -1 Unable to perform operation, errno contains further\r
184 information. The file name is unchanged.\r
185 **/\r
186 int unlink (const char *name);\r
187\r
188 /** Make file descriptor Fd2 a duplicate of file descriptor Fd1.\r
189\r
190 @param[in] Fd1 File descriptor to be duplicated\r
191 @param[in] Fd2 File descriptor to become a duplicate of Fd1.\r
192\r
193 @retval 0 Successful completion.\r
194 @retval -1 Unable to perform operation, errno contains further\r
195 information.\r
196 **/\r
197 int dup2 (int Fd1, int Fd2);\r
198\r
199 /** Remove a directory.\r
200\r
201 @param[in] Path Path to the directory to be deleted.\r
202\r
203 @retval 0 Successful completion.\r
204 @retval -1 Unable to perform operation, errno contains further\r
205 information. The named directory remains unchanged.\r
206 **/\r
207 int rmdir (const char *Path);\r
208\r
209 /** Determine if fd refers to an interactive terminal device.\r
210\r
211 @param[in] fd The file descriptor to be tested.\r
212\r
213 @retval 0 The file descriptor, fd, is not for a terminal. errno is set\r
214 indicating the cause for failure.\r
215 - EBADF fd is not a valid open file descriptor.\r
216 - ENOTTY fd does not refer to a terminal.\r
217 @retval 1 The file descriptor, fd, is for a terminal.\r
218 **/\r
219 int isatty (int fd);\r
2aa62f2b 220\r
221/* These system calls are also declared in sys/fcntl.h */\r
222#ifndef __FCNTL_SYSCALLS_DECLARED\r
223 #define __FCNTL_SYSCALLS_DECLARED\r
61403bd7 224\r
225 /** Open or create a file named by name.\r
226\r
227 The file name may be one of:\r
228 - An absolute path beginning with '/'.\r
229 - A relative path beginning with "." or ".." or a directory name\r
230 - A file name\r
231 - A mapped path which begins with a name followed by a colon, ':'.\r
232\r
233 Mapped paths are use to refer to specific mass storage volumes or devices.\r
234 In a Shell-hosted environment, the map command will list valid map names\r
235 for both file system and block devices. Mapped paths can also refer to\r
236 devices such as the UEFI console. Supported UEFI console mapped paths are:\r
237 - stdin: Standard Input (from the System Table)\r
238 - stdout: Standard Output (from the System Table)\r
239 - stderr: Standard Error Output (from the System Table)\r
240\r
241 @param[in] name\r
242 @param[in] oflags\r
243 @param[in] mode\r
244\r
245 @return\r
246 **/\r
53e1e5c6 247 int open (const char *name, int oflags, int mode);\r
61403bd7 248\r
249 /**\r
250 @param[in]\r
251\r
252 @return\r
253 **/\r
53e1e5c6 254 int creat (const char *, mode_t);\r
61403bd7 255\r
256 /**\r
257 @param[in]\r
258\r
259 @return\r
260 **/\r
53e1e5c6 261 int fcntl (int, int, ...);\r
2aa62f2b 262#endif // __FCNTL_SYSCALLS_DECLARED\r
263\r
264/* These system calls are also declared in stat.h */\r
265#ifndef __STAT_SYSCALLS_DECLARED\r
266 #define __STAT_SYSCALLS_DECLARED\r
61403bd7 267\r
268 /**\r
269 @param[in]\r
270\r
271 @return\r
272 **/\r
53e1e5c6 273 int mkdir (const char *, mode_t);\r
61403bd7 274\r
275 /**\r
276 @param[in]\r
277\r
278 @return\r
279 **/\r
53e1e5c6 280 int fstat (int, struct stat *);\r
61403bd7 281\r
282 /**\r
283 @param[in]\r
284\r
285 @return\r
286 **/\r
53e1e5c6 287 int lstat (const char *, struct stat *);\r
61403bd7 288\r
289 /**\r
290 @param[in]\r
291\r
292 @return\r
293 **/\r
53e1e5c6 294 int stat (const char *, void *);\r
61403bd7 295\r
296 /**\r
297 @param[in]\r
298\r
299 @return\r
300 **/\r
d7ce7006 301 int chmod (const char *, mode_t);\r
2aa62f2b 302#endif // __STAT_SYSCALLS_DECLARED\r
303\r
304// These are also declared in sys/types.h\r
305#ifndef __OFF_T_SYSCALLS_DECLARED\r
306 #define __OFF_T_SYSCALLS_DECLARED\r
61403bd7 307\r
308 /**\r
309 @param[in]\r
310\r
311 @return\r
312 **/\r
53e1e5c6 313 off_t lseek (int, off_t, int);\r
61403bd7 314\r
315 /**\r
316 @param[in]\r
317\r
318 @return\r
319 **/\r
53e1e5c6 320 int truncate (const char *, off_t);\r
61403bd7 321\r
322 /**\r
323 @param[in]\r
324\r
325 @return\r
326 **/\r
53e1e5c6 327 int ftruncate (int, off_t); // IEEE Std 1003.1b-93\r
2aa62f2b 328#endif /* __OFF_T_SYSCALLS_DECLARED */\r
329\r
53e1e5c6 330/* EFI-specific Functions. */\r
61403bd7 331\r
332 /**\r
333 @param[in]\r
334\r
335 @return\r
336 **/\r
337 int DeleteOnClose(int fd); /* Mark an open file to be deleted when closed. */\r
53e1e5c6 338\r
339/* Find and reserve a free File Descriptor.\r
340\r
341 Returns the first free File Descriptor greater than or equal to the,\r
342 already validated, fd specified by Minfd.\r
343\r
344 @return Returns -1 if there are no free FDs. Otherwise returns the\r
345 found fd.\r
346*/\r
61403bd7 347 int FindFreeFD (int MinFd);\r
53e1e5c6 348\r
349/* Validate that fd refers to a valid file descriptor.\r
350 IsOpen is interpreted as follows:\r
351 - Positive fd must be OPEN\r
352 - Zero fd must be CLOSED\r
353 - Negative fd may be OPEN or CLOSED\r
354\r
355 @retval TRUE fd is VALID\r
356 @retval FALSE fd is INVALID\r
357*/\r
61403bd7 358 BOOLEAN ValidateFD (int fd, int IsOpen);\r
53e1e5c6 359\r
d7ce7006 360\r
61403bd7 361 /**\r
362 @param[in]\r
363\r
364 @return\r
365 **/\r
366 char *getcwd (char *, size_t);\r
2aa62f2b 367\r
61403bd7 368 /**\r
369 @param[in]\r
370\r
371 @return\r
372 **/\r
373 int chdir (const char *);\r
374\r
375/* These system calls don't YET have EFI implementations. */\r
376 int access (const char *path, int amode);\r
377 int reboot (int, char *);\r
2aa62f2b 378__END_DECLS\r
379\r
380#endif /* _EFI_SYS_CALL_H */\r