]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/Include/sys/EfiSysCall.h
2 Function declarations for UEFI "system calls".
4 Concept derived from NetBSD's unistd.h file.
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.
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.
16 #ifndef _EFI_SYS_CALL_H
17 #define _EFI_SYS_CALL_H
19 #include <sys/EfiCdefs.h>
20 #include <sys/types.h>
22 struct stat
; /* Structure declared in <sys/stat.h> */
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 */
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 */
34 /* whence values for lseek(2)
35 Always ensure that these are consistent with <stdio.h> and <unistd.h>!
38 #define SEEK_SET 0 /* set file offset to offset */
41 #define SEEK_CUR 1 /* set file offset to current plus offset */
44 #define SEEK_END 2 /* set file offset to EOF plus offset */
47 // Parameters for the ValidateFD function.
49 #define VALID_CLOSED 0
50 #define VALID_DONT_CARE -1
54 /* EFI versions of BSD system calls used in stdio */
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
);
60 int rmdir (const char *);
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
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
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 */
89 /* EFI-specific Functions. */
90 int DeleteOnClose(int fd
); /* Mark an open file to be deleted when closed. */
92 /* Find and reserve a free File Descriptor.
94 Returns the first free File Descriptor greater than or equal to the,
95 already validated, fd specified by Minfd.
97 @return Returns -1 if there are no free FDs. Otherwise returns the
100 int FindFreeFD (int MinFd
);
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
108 @retval TRUE fd is VALID
109 @retval FALSE fd is INVALID
111 BOOLEAN
ValidateFD (int fd
, int IsOpen
);
113 char *getcwd (char *, size_t);
114 int chdir (const char *);
116 /* These system calls don't YET have EFI implementations. */
117 int access (const char *path
, int amode
);
118 int reboot (int, char *);
122 #endif /* _EFI_SYS_CALL_H */