]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/Include/sys/EfiSysCall.h
1d013286091c6d580b5d3a29f8d8fd4824d7edf2
2 Function declarations for UEFI "system calls".
4 The following macros are defined in this file:<BR>
6 STDIN_FILENO 0 standard input file descriptor
7 STDOUT_FILENO 1 standard output file descriptor
8 STDERR_FILENO 2 standard error file descriptor
9 F_OK 0 test for existence of file
10 X_OK 0x01 test for execute or search permission
11 W_OK 0x02 test for write permission
12 R_OK 0x04 test for read permission
13 SEEK_SET 0 set file offset to offset
14 SEEK_CUR 1 set file offset to current plus offset
15 SEEK_END 2 set file offset to EOF plus offset
21 The following types are defined in this file:<BR>
23 struct stat; Structure declared in <sys/stat.h>
26 The following functions are declared in this file:<BR>
28 ############### System Calls used in stdio.
30 ssize_t read (int fd, void *buf, size_t n);
31 ssize_t write (int fd, const void *buf, size_t n);
32 int unlink (const char *name);
34 int rmdir (const char *);
37 ############### System Calls which are also declared in sys/fcntl.h.
38 int open (const char *name, int oflags, int mode);
39 int creat (const char *, mode_t);
40 int fcntl (int, int, ...);
42 ############### System Calls which are also declared in stat.h.
43 int mkdir (const char *, mode_t);
44 int fstat (int, struct stat *);
45 int lstat (const char *, struct stat *);
46 int stat (const char *, void *);
47 int chmod (const char *, mode_t);
49 ############### System Calls which are also declared in sys/types.h.
50 off_t lseek (int, off_t, int);
51 int truncate (const char *, off_t);
52 int ftruncate (int, off_t); // IEEE Std 1003.1b-93
54 ############### EFI-specific Functions.
55 int DeleteOnClose (int fd); Mark an open file to be deleted when closed.
56 int FindFreeFD (int MinFd);
57 BOOLEAN ValidateFD (int fd, int IsOpen);
59 ############### Functions added for compatibility.
60 char *getcwd (char *, size_t);
61 int chdir (const char *);
64 Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
65 This program and the accompanying materials are licensed and made available under
66 the terms and conditions of the BSD License that accompanies this distribution.
67 The full text of the license may be found at
68 http://opensource.org/licenses/bsd-license.
70 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
71 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
73 #ifndef _EFI_SYS_CALL_H
74 #define _EFI_SYS_CALL_H
76 #include <sys/EfiCdefs.h>
77 #include <sys/types.h>
79 struct stat
; /* Structure declared in <sys/stat.h> */
81 #define STDIN_FILENO 0 /**< standard input file descriptor */
82 #define STDOUT_FILENO 1 /**< standard output file descriptor */
83 #define STDERR_FILENO 2 /**< standard error file descriptor */
86 #define F_OK 0 /**< test for existence of file */
87 #define X_OK 0x01 /**< test for execute or search permission */
88 #define W_OK 0x02 /**< test for write permission */
89 #define R_OK 0x04 /**< test for read permission */
91 /* whence values for lseek(2)
92 Always ensure that these are consistent with <stdio.h> and <unistd.h>!
95 #define SEEK_SET 0 /**< set file offset to offset */
98 #define SEEK_CUR 1 /**< set file offset to current plus offset */
101 #define SEEK_END 2 /**< set file offset to EOF plus offset */
104 // Parameters for the ValidateFD function.
106 #define VALID_CLOSED 0
107 #define VALID_DONT_CARE -1
110 /* EFI versions of BSD system calls used in stdio */
112 /** Close a file or device.
114 @param[in] fd File Descriptor for the file or device to close.
116 @retval 0 Successful completion.
117 @retval -1 An error occurred, identified by errno.
118 - EBADF fd is not a valid File Descriptor.
119 - EINTR The function was interrupted by a signal.
120 - EIO An I/O error occurred.
124 /** Read from a file or device.
126 @param[in] fd File Descriptor for the file or device to read.
127 @param[in] buf Buffer to read data into.
128 @param[in] N Maximum number of bytes to read.
130 @return On successful completion, read returns a non-negative integer
131 indicating the number of bytes actually read. Otherwise, it
132 returns -1 and sets errno as follows:
149 ssize_t
read (int fd
, void *buf
, size_t n
);
151 /** Write to a file or device.
153 @param[in] fd File Descriptor for the file or device to write.
154 @param[in] buf Buffer to write data from.
155 @param[in] N Maximum number of bytes to write.
157 @return On successful completion, write returns a non-negative integer
158 indicating the number of bytes actually written. Otherwise, it
159 returns -1 and sets errno as follows:
176 ssize_t
write (int fd
, const void *buf
, size_t n
);
178 /** Unlink (delete) a file.
180 @param[in] name The name of the file to be deleted.
182 @retval 0 Successful completion.
183 @retval -1 Unable to perform operation, errno contains further
184 information. The file name is unchanged.
186 int unlink (const char *name
);
188 /** Make file descriptor Fd2 a duplicate of file descriptor Fd1.
190 @param[in] Fd1 File descriptor to be duplicated
191 @param[in] Fd2 File descriptor to become a duplicate of Fd1.
193 @retval 0 Successful completion.
194 @retval -1 Unable to perform operation, errno contains further
197 int dup2 (int Fd1
, int Fd2
);
199 /** Remove a directory.
201 @param[in] Path Path to the directory to be deleted.
203 @retval 0 Successful completion.
204 @retval -1 Unable to perform operation, errno contains further
205 information. The named directory remains unchanged.
207 int rmdir (const char *Path
);
209 /** Determine if fd refers to an interactive terminal device.
211 @param[in] fd The file descriptor to be tested.
213 @retval 0 The file descriptor, fd, is not for a terminal. errno is set
214 indicating the cause for failure.
215 - EBADF fd is not a valid open file descriptor.
216 - ENOTTY fd does not refer to a terminal.
217 @retval 1 The file descriptor, fd, is for a terminal.
221 /* These system calls are also declared in sys/fcntl.h */
222 #ifndef __FCNTL_SYSCALLS_DECLARED
223 #define __FCNTL_SYSCALLS_DECLARED
225 /** Open or create a file named by name.
227 The file name may be one of:
228 - An absolute path beginning with '/'.
229 - A relative path beginning with "." or ".." or a directory name
231 - A mapped path which begins with a name followed by a colon, ':'.
233 Mapped paths are use to refer to specific mass storage volumes or devices.
234 In a Shell-hosted environment, the map command will list valid map names
235 for both file system and block devices. Mapped paths can also refer to
236 devices such as the UEFI console. Supported UEFI console mapped paths are:
237 - stdin: Standard Input (from the System Table)
238 - stdout: Standard Output (from the System Table)
239 - stderr: Standard Error Output (from the System Table)
247 int open (const char *name
, int oflags
, int mode
);
254 int creat (const char *, mode_t
);
261 int fcntl (int, int, ...);
262 #endif // __FCNTL_SYSCALLS_DECLARED
264 /* These system calls are also declared in stat.h */
265 #ifndef __STAT_SYSCALLS_DECLARED
266 #define __STAT_SYSCALLS_DECLARED
273 int mkdir (const char *, mode_t
);
280 int fstat (int, struct stat
*);
287 int lstat (const char *, struct stat
*);
294 int stat (const char *, struct stat
*);
301 int chmod (const char *, mode_t
);
302 #endif // __STAT_SYSCALLS_DECLARED
304 // These are also declared in sys/types.h
305 #ifndef __OFF_T_SYSCALLS_DECLARED
306 #define __OFF_T_SYSCALLS_DECLARED
313 off_t
lseek (int, off_t
, int);
320 int truncate (const char *, off_t
);
327 int ftruncate (int, off_t
); // IEEE Std 1003.1b-93
328 #endif /* __OFF_T_SYSCALLS_DECLARED */
330 /* EFI-specific Functions. */
337 int DeleteOnClose(int fd
); /* Mark an open file to be deleted when closed. */
339 /* Find and reserve a free File Descriptor.
341 Returns the first free File Descriptor greater than or equal to the,
342 already validated, fd specified by Minfd.
344 @return Returns -1 if there are no free FDs. Otherwise returns the
347 int FindFreeFD (int MinFd
);
349 /* Validate that fd refers to a valid file descriptor.
350 IsOpen is interpreted as follows:
351 - Positive fd must be OPEN
352 - Zero fd must be CLOSED
353 - Negative fd may be OPEN or CLOSED
355 @retval TRUE fd is VALID
356 @retval FALSE fd is INVALID
358 BOOLEAN
ValidateFD (int fd
, int IsOpen
);
366 char *getcwd (char *, size_t);
373 int chdir (const char *);
375 /* These system calls don't YET have EFI implementations. */
376 int access (const char *path
, int amode
);
377 int reboot (int, char *);
380 #endif /* _EFI_SYS_CALL_H */