]> git.proxmox.com Git - mirror_edk2.git/blob - StdLib/Include/sys/EfiSysCall.h
Add Socket Libraries.
[mirror_edk2.git] / StdLib / Include / sys / EfiSysCall.h
1 /** @file
2 Function declarations for UEFI "system calls".
3
4 Concept derived from NetBSD's unistd.h file.
5
6 Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials are licensed and made available under
8 the terms and conditions of the BSD License that accompanies this distribution.
9 The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16 #ifndef _EFI_SYS_CALL_H
17 #define _EFI_SYS_CALL_H
18
19 #include <sys/EfiCdefs.h>
20 #include <sys/types.h>
21
22 struct stat; /* Structure declared in <sys/stat.h> */
23
24 #define STDIN_FILENO 0 /* standard input file descriptor */
25 #define STDOUT_FILENO 1 /* standard output file descriptor */
26 #define STDERR_FILENO 2 /* standard error file descriptor */
27
28 /* access function */
29 #define F_OK 0 /* test for existence of file */
30 #define X_OK 0x01 /* test for execute or search permission */
31 #define W_OK 0x02 /* test for write permission */
32 #define R_OK 0x04 /* test for read permission */
33
34 /* whence values for lseek(2)
35 Always ensure that these are consistent with <stdio.h> and <unistd.h>!
36 */
37 #ifndef SEEK_SET
38 #define SEEK_SET 0 /* set file offset to offset */
39 #endif
40 #ifndef SEEK_CUR
41 #define SEEK_CUR 1 /* set file offset to current plus offset */
42 #endif
43 #ifndef SEEK_END
44 #define SEEK_END 2 /* set file offset to EOF plus offset */
45 #endif
46
47 // Parameters for the ValidateFD function.
48 #define VALID_OPEN 1
49 #define VALID_CLOSED 0
50 #define VALID_DONT_CARE -1
51
52 __BEGIN_DECLS
53
54 /* EFI versions of BSD system calls used in stdio */
55 int close (int fd);
56 ssize_t read (int fd, void *buf, size_t n);
57 ssize_t write (int fd, const void *buf, size_t n);
58 int unlink (const char *name);
59 int dup2 (int, int);
60 int rmdir (const char *);
61 int isatty (int);
62
63 /* These system calls are also declared in sys/fcntl.h */
64 #ifndef __FCNTL_SYSCALLS_DECLARED
65 #define __FCNTL_SYSCALLS_DECLARED
66 int open (const char *name, int oflags, int mode);
67 int creat (const char *, mode_t);
68 int fcntl (int, int, ...);
69 #endif // __FCNTL_SYSCALLS_DECLARED
70
71 /* These system calls are also declared in stat.h */
72 #ifndef __STAT_SYSCALLS_DECLARED
73 #define __STAT_SYSCALLS_DECLARED
74 int mkdir (const char *, mode_t);
75 int fstat (int, struct stat *);
76 int lstat (const char *, struct stat *);
77 int stat (const char *, void *);
78 int chmod (const char *, mode_t);
79 #endif // __STAT_SYSCALLS_DECLARED
80
81 // These are also declared in sys/types.h
82 #ifndef __OFF_T_SYSCALLS_DECLARED
83 #define __OFF_T_SYSCALLS_DECLARED
84 off_t lseek (int, off_t, int);
85 int truncate (const char *, off_t);
86 int ftruncate (int, off_t); // IEEE Std 1003.1b-93
87 #endif /* __OFF_T_SYSCALLS_DECLARED */
88
89 /* EFI-specific Functions. */
90 int DeleteOnClose(int fd); /* Mark an open file to be deleted when closed. */
91
92 /* Find and reserve a free File Descriptor.
93
94 Returns the first free File Descriptor greater than or equal to the,
95 already validated, fd specified by Minfd.
96
97 @return Returns -1 if there are no free FDs. Otherwise returns the
98 found fd.
99 */
100 int FindFreeFD (int MinFd);
101
102 /* Validate that fd refers to a valid file descriptor.
103 IsOpen is interpreted as follows:
104 - Positive fd must be OPEN
105 - Zero fd must be CLOSED
106 - Negative fd may be OPEN or CLOSED
107
108 @retval TRUE fd is VALID
109 @retval FALSE fd is INVALID
110 */
111 BOOLEAN ValidateFD (int fd, int IsOpen);
112
113 char *getcwd (char *, size_t);
114 int chdir (const char *);
115
116 /* These system calls don't YET have EFI implementations. */
117 int access (const char *path, int amode);
118 int reboot (int, char *);
119
120 __END_DECLS
121
122 #endif /* _EFI_SYS_CALL_H */