Fennix  1.0.0
Full Documentation
Loading...
Searching...
No Matches
syscalls.h File Reference

Go to the source code of this file.

Data Structures

struct  FramebufferScreenInfo
 
struct  kutsname
 

Macros

#define scarg   __UINTPTR_TYPE__
 
#define __SYS_NULL   ((void *)0)
 NULL pointer.
 
#define FBIOGET_SCREEN_INFO   0xf0
 Get framebuffer screen info.
 
#define call_api_version(version)   syscall1(SYS_API_VERSION, (scarg)version)
 Set syscall version.
 
#define call_read(fd, buf, count)   syscall3(SYS_READ, (scarg)fd, (scarg)buf, (scarg)count)
 Read from a file descriptor.
 
#define call_pread(fd, buf, count, offset)   syscall4(SYS_PREAD, (scarg)fd, (scarg)buf, (scarg)count, (scarg)offset)
 Read from a file descriptor.
 
#define call_write(fd, buf, count)   syscall3(SYS_WRITE, (scarg)fd, (scarg)buf, (scarg)count)
 Write to a file descriptor.
 
#define call_pwrite(fd, buf, count, offset)   syscall4(SYS_PWRITE, (scarg)fd, (scarg)buf, (scarg)count, (scarg)offset)
 Write to a file descriptor.
 
#define call_open(pathname, flags, mode)   syscall3(SYS_OPEN, (scarg)pathname, (scarg)flags, (scarg)mode)
 Open a file.
 
#define call_close(fd)   syscall1(SYS_CLOSE, fd)
 Close a file descriptor.
 
#define call_ioctl(fd, request, argp)   syscall3(SYS_IOCTL, (scarg)fd, (scarg)request, (scarg)argp)
 Control a device.
 
#define call_fcntl(fd, cmd, arg)   syscall3(SYS_FCNTL, (scarg)fd, (scarg)cmd, (scarg)arg)
 Function control.
 
#define call_stat(pathname, statbuf)   syscall2(SYS_STAT, (scarg)pathname, (scarg)statbuf)
 Retrieve file status.
 
#define call_fstat(fd, statbuf)   syscall2(SYS_FSTAT, (scarg)fd, (scarg)statbuf)
 Retrieve file status for an open file descriptor.
 
#define call_lstat(pathname, statbuf)   syscall2(SYS_LSTAT, (scarg)pathname, (scarg)statbuf)
 Retrieve file status with symbolic link resolution.
 
#define call_access(pathname, mode)   syscall2(SYS_ACCESS, (scarg)pathname, (scarg)mode)
 Check a file's accessibility.
 
#define call_truncate(pathname, length)   syscall2(SYS_TRUNCATE, (scarg)pathname, (scarg)length)
 Change the size of a file.
 
#define call_ftruncate(fd, length)   syscall2(SYS_FTRUNCATE, (scarg)fd, (scarg)length)
 Change the size of a file referred by a file descriptor.
 
#define call_tell(fd)   syscall1(SYS_TELL, (scarg)fd)
 Get the current file offset.
 
#define call_seek(fd, offset, whence)   syscall3(SYS_SEEK, (scarg)fd, (scarg)offset, (scarg)whence)
 Set the file offset.
 
#define call_exit(status)   syscall1(SYS_EXIT, (scarg)status)
 Terminate the calling process.
 
#define call_fork()   syscall0(SYS_FORK)
 Create a child process.
 
#define call_execve(pathname, argv, envp)   syscall3(SYS_EXECVE, (scarg)pathname, (scarg)argv, (scarg)envp)
 Execute a program.
 
#define call_getpid()   syscall0(SYS_GETPID)
 Get the process ID of the calling process.
 
#define call_getppid()   syscall0(SYS_GETPPID)
 Get the parent process ID.
 
#define call_waitpid(pid, wstatus, options)   syscall3(SYS_WAITPID, (scarg)pid, (scarg)wstatus, (scarg)options)
 Wait for a child process to change state.
 
#define call_kill(pid, sig)   syscall2(SYS_KILL, (scarg)pid, (scarg)sig)
 Send a signal to a process.
 
#define call_prctl(option, arg1, arg2, arg3, arg4)   syscall5(SYS_PRCTL, (scarg)option, (scarg)arg1, (scarg)arg2, (scarg)arg3, (scarg)arg4)
 Process/Thread Control.
 
#define call_brk(end_data)   syscall1(SYS_BRK, (scarg)end_data)
 Set the program break.
 
#define call_mmap(addr, length, prot, flags, fd, offset)   syscall6(SYS_MMAP, (scarg)addr, (scarg)length, (scarg)prot, (scarg)flags, (scarg)fd, (scarg)offset)
 Map files or devices into memory.
 
#define call_munmap(addr, length)   syscall2(SYS_MUNMAP, (scarg)addr, (scarg)length)
 Unmap a mapped memory region.
 
#define call_mprotect(addr, length, prot)   syscall3(SYS_MPROTECT, (scarg)addr, (scarg)length, (scarg)prot)
 Change memory protection.
 
#define call_madvise(addr, length, advice)   syscall3(SYS_MADVISE, (scarg)addr, (scarg)length, (scarg)advice)
 Provide advice about memory usage.
 
#define call_pipe(pipefd)   syscall1(SYS_PIPE, (scarg)pipefd)
 Create a pipe.
 
#define call_dup(oldfd)   syscall1(SYS_DUP, (scarg)oldfd)
 Duplicate a file descriptor.
 
#define call_dup2(oldfd, newfd)   syscall2(SYS_DUP2, (scarg)oldfd, (scarg)newfd)
 Duplicate a file descriptor to a specific value.
 
#define call_socket(domain, type, protocol)   syscall3(SYS_SOCKET, (scarg)domain, (scarg)type, (scarg)protocol)
 Create an endpoint for communication.
 
#define call_bind(sockfd, addr, addrlen)   syscall3(SYS_BIND, (scarg)sockfd, (scarg)addr, (scarg)addrlen)
 Bind a socket to a local address.
 
#define call_connect(sockfd, addr, addrlen)   syscall3(SYS_CONNECT, (scarg)sockfd, (scarg)addr, (scarg)addrlen)
 Connect to a remote address.
 
#define call_listen(sockfd, backlog)   syscall2(SYS_LISTEN, (scarg)sockfd, (scarg)backlog)
 Listen for incoming connections on a socket.
 
#define call_accept(sockfd, addr, addrlen)   syscall3(SYS_ACCEPT, (scarg)sockfd, (scarg)addr, (scarg)addrlen)
 Accept an incoming connection on a socket.
 
#define call_send(sockfd, buf, len, flags)   syscall4(SYS_SEND, (scarg)sockfd, (scarg)buf, (scarg)len, (scarg)flags)
 Send data on a socket.
 
#define call_recv(sockfd, buf, len, flags)   syscall4(SYS_RECV, (scarg)sockfd, (scarg)buf, (scarg)len, (scarg)flags)
 Receive data on a socket.
 
#define call_shutdown(sockfd, how)   syscall2(SYS_SHUTDOWN, (scarg)sockfd, (scarg)how)
 Shut down part of a full-duplex connection.
 
#define call_time(t)   syscall1(SYS_TIME, (scarg)t)
 Get the current time.
 
#define call_clock_gettime(clockid, tp)   syscall2(SYS_CLOCK_GETTIME, (scarg)clockid, (scarg)tp)
 Get the current time of a specific clock.
 
#define call_clock_settime(clockid, tp)   syscall2(SYS_CLOCK_SETTIME, (scarg)clockid, (scarg)tp)
 Set the current time of a specific clock.
 
#define call_nanosleep(req, rem)   syscall2(SYS_NANOSLEEP, (scarg)req, (scarg)rem)
 Sleep for a specified time.
 
#define call_getcwd(buf, size)   syscall2(SYS_GETCWD, (scarg)buf, (scarg)size)
 Get the current working directory.
 
#define call_chdir(path)   syscall1(SYS_CHDIR, (scarg)path)
 Change the current working directory.
 
#define call_mkdir(path, mode)   syscall2(SYS_MKDIR, (scarg)path, (scarg)mode)
 Create a new directory.
 
#define call_rmdir(path)   syscall1(SYS_RMDIR, (scarg)path)
 Remove an empty directory.
 
#define call_unlink(pathname)   syscall1(SYS_UNLINK, (scarg)pathname)
 Remove a file.
 
#define call_rename(oldpath, newpath)   syscall2(SYS_RENAME, (scarg)oldpath, (scarg)newpath)
 Rename a file or directory.
 
#define call_uname(buf)   syscall1(SYS_UNAME, (scarg)buf)
 Get unix name information.
 

Typedefs

typedef int __SYS_clockid_t
 
typedef unsigned int __SYS_socklen_t
 
typedef struct FramebufferScreenInfo FramebufferScreenInfo
 

Enumerations

enum  syscall_mmap_flags_t {
  __SYS_PROT_READ = 0x1 , __SYS_PROT_WRITE = 0x2 , __SYS_PROT_EXEC = 0x4 , __SYS_PROT_NONE = 0x0 ,
  __SYS_MAP_SHARED = 0x1 , __SYS_MAP_PRIVATE = 0x2 , __SYS_MAP_FIXED = 0x4 , __SYS_MAP_ANONYMOUS = 0x8 ,
  __SYS_MAP_ANON = __SYS_MAP_ANONYMOUS
}
 
enum  syscall_open_flags_t {
  __SYS_O_RDONLY = O_RDONLY , __SYS_O_WRONLY = O_WRONLY , __SYS_O_RDWR = O_RDWR , __SYS_O_APPEND = O_APPEND ,
  __SYS_O_CREAT = O_CREAT , __SYS_O_DSYNC = O_DSYNC , __SYS_O_EXCL = O_EXCL , __SYS_O_NOCTTY = O_NOCTTY ,
  __SYS_O_NONBLOCK = O_NONBLOCK , __SYS_O_RSYNC = O_RSYNC , __SYS_O_SYNC = O_SYNC , __SYS_O_TRUNC = O_TRUNC
}
 
enum  syscall_access_flags_t { __SYS_F_OK = 0 , __SYS_R_OK = 1 , __SYS_W_OK = 2 , __SYS_X_OK = 3 }
 
enum  syscall_prctl_options_t { __SYS_GET_GS = 0 , __SYS_SET_GS = 1 , __SYS_GET_FS = 2 , __SYS_SET_FS = 3 }
 
enum  syscall_seek_whence_t { __SYS_SEEK_SET = 0 , __SYS_SEEK_CUR = 1 , __SYS_SEEK_END = 2 }
 
enum  syscall_signal_t {
  __SYS_SIGNULL = 0 , __SYS_SIGABRT = 1 , __SYS_SIGALRM = 2 , __SYS_SIGBUS = 3 ,
  __SYS_SIGCHLD = 4 , __SYS_SIGCONT = 5 , __SYS_SIGFPE = 6 , __SYS_SIGHUP = 7 ,
  __SYS_SIGILL = 8 , __SYS_SIGINT = 9 , __SYS_SIGKILL = 10 , __SYS_SIGPIPE = 11 ,
  __SYS_SIGQUIT = 12 , __SYS_SIGSEGV = 13 , __SYS_SIGSTOP = 14 , __SYS_SIGTERM = 15 ,
  __SYS_SIGTSTP = 16 , __SYS_SIGTTIN = 17 , __SYS_SIGTTOU = 18 , __SYS_SIGUSR1 = 19 ,
  __SYS_SIGUSR2 = 20 , __SYS_SIGPOLL = 21 , __SYS_SIGPROF = 22 , __SYS_SIGSYS = 23 ,
  __SYS_SIGTRAP = 24 , __SYS_SIGURG = 25 , __SYS_SIGVTALRM = 26 , __SYS_SIGXCPU = 27 ,
  __SYS_SIGXFSZ = 28 , __SYS_SIGCOMP1 = 29 , __SYS_SIGCOMP2 = 30 , __SYS_SIGCOMP3 = 31 ,
  __SYS_SIGRTMIN = 32 , __SYS_SIGRT_1 = 33 , __SYS_SIGRT_2 = 34 , __SYS_SIGRT_3 = 35 ,
  __SYS_SIGRT_4 = 36 , __SYS_SIGRT_5 = 37 , __SYS_SIGRT_6 = 38 , __SYS_SIGRT_7 = 39 ,
  __SYS_SIGRT_8 = 40 , __SYS_SIGRT_9 = 41 , __SYS_SIGRT_10 = 42 , __SYS_SIGRT_11 = 43 ,
  __SYS_SIGRT_12 = 44 , __SYS_SIGRT_13 = 45 , __SYS_SIGRT_14 = 46 , __SYS_SIGRT_15 = 47 ,
  __SYS_SIGRT_16 = 48 , __SYS_SIGRT_17 = 49 , __SYS_SIGRT_18 = 50 , __SYS_SIGRT_19 = 51 ,
  __SYS_SIGRT_20 = 52 , __SYS_SIGRT_21 = 53 , __SYS_SIGRT_22 = 54 , __SYS_SIGRT_23 = 55 ,
  __SYS_SIGRT_24 = 56 , __SYS_SIGRT_25 = 57 , __SYS_SIGRT_26 = 58 , __SYS_SIGRT_27 = 59 ,
  __SYS_SIGRT_28 = 60 , __SYS_SIGRT_29 = 61 , __SYS_SIGRT_30 = 62 , __SYS_SIGRT_31 = 63 ,
  __SYS_SIGRTMAX = 64 , __SYS_SIGNAL_MAX = __SYS_SIGRTMAX
}
 
enum  syscall_signal_disposition_t {
  __SYS_SIG_TERM = 0 , __SYS_SIG_IGN = 1 , __SYS_SIG_CONT = 2 , __SYS_SIG_STOP = 3 ,
  __SYS_SIG_CORE = 4
}
 
enum  syscall_signal_actions_t { __SYS_SIG_BLOCK = 0 , __SYS_SIG_UNBLOCK = 1 , __SYS_SIG_SETMASK = 2 }
 
enum  syscall_signal_action_flags_t {
  __SYS_SA_NOCLDSTOP = 1 , __SYS_SA_ONSTACK = 0x08000000 , __SYS_SA_RESETHAND = 0x80000000 , __SYS_SA_RESTART = 0x10000000 ,
  __SYS_SA_SIGINFO = 4 , __SYS_SA_NOCLDWAIT = 2 , __SYS_SA_NODEFER = 0x40000000
}
 
enum  syscall_signal_action_disposition_t { __SYS_SIG_ERR = -1 , __SYS_SIG_DFL = 0 , ___SYS_SIG_IGN = 1 }
 
enum  syscall_clockid_t { __SYS_CLOCK_MONOTONIC = 1 , __SYS_CLOCK_PROCESS_CPUTIME_ID = 2 , __SYS_CLOCK_REALTIME = 3 , __SYS_CLOCK_THREAD_CPUTIME_ID = 4 }
 
enum  syscalls_t {
  SYS_API_VERSION = 0 , SYS_DEBUG_REPORT = 1 , SYS_READ = 100 , SYS_PREAD ,
  SYS_WRITE , SYS_PWRITE , SYS_OPEN , SYS_CLOSE ,
  SYS_IOCTL , SYS_FCNTL , SYS_STAT = 200 , SYS_FSTAT ,
  SYS_LSTAT , SYS_ACCESS , SYS_TRUNCATE , SYS_FTRUNCATE ,
  SYS_TELL , SYS_SEEK , SYS_EXIT = 300 , SYS_FORK ,
  SYS_EXECVE , SYS_GETPID , SYS_GETPPID , SYS_WAITPID ,
  SYS_KILL , SYS_PRCTL , SYS_BRK = 400 , SYS_MMAP ,
  SYS_MUNMAP , SYS_MPROTECT , SYS_MADVISE , SYS_PIPE = 500 ,
  SYS_DUP , SYS_DUP2 , SYS_SOCKET , SYS_BIND ,
  SYS_CONNECT , SYS_LISTEN , SYS_ACCEPT , SYS_SEND ,
  SYS_RECV , SYS_SHUTDOWN , SYS_TIME = 600 , SYS_CLOCK_GETTIME ,
  SYS_CLOCK_SETTIME , SYS_NANOSLEEP , SYS_GETCWD = 700 , SYS_CHDIR ,
  SYS_MKDIR , SYS_RMDIR , SYS_UNLINK , SYS_RENAME ,
  SYS_UNAME , SYS_MAX
}
 List of syscalls. More...
 

Functions

static scarg syscall0 (scarg syscall)
 Syscall wrapper with 0 arguments.
 
static scarg syscall1 (scarg syscall, scarg arg1)
 Syscall wrapper with 1 argument.
 
static scarg syscall2 (scarg syscall, scarg arg1, scarg arg2)
 Syscall wrapper with 2 arguments.
 
static scarg syscall3 (scarg syscall, scarg arg1, scarg arg2, scarg arg3)
 Syscall wrapper with 3 arguments.
 
static scarg syscall4 (scarg syscall, scarg arg1, scarg arg2, scarg arg3, scarg arg4)
 Syscall wrapper with 4 arguments.
 
static scarg syscall5 (scarg syscall, scarg arg1, scarg arg2, scarg arg3, scarg arg4, scarg arg5)
 Syscall wrapper with 5 arguments.
 
static scarg syscall6 (scarg syscall, scarg arg1, scarg arg2, scarg arg3, scarg arg4, scarg arg5, scarg arg6)
 Syscall wrapper with 6 arguments.
 

Data Structure Documentation

◆ FramebufferScreenInfo

struct FramebufferScreenInfo

Definition at line 615 of file syscalls.h.

Data Fields
__UINT32_TYPE__ Bpp
__UINT32_TYPE__ Height
__UINT32_TYPE__ Pitch
__UINT32_TYPE__ Size
__UINT32_TYPE__ Width

◆ kutsname

struct kutsname

Definition at line 637 of file syscalls.h.

Data Fields
char machine[65]
char release[65]
char sysname[65]
char version[65]

Macro Definition Documentation

◆ __SYS_NULL

#define __SYS_NULL   ((void *)0)

NULL pointer.

This is a pointer to address 0, which is reserved and cannot be dereferenced.

Note
This macro is defined only for this documentation.

Definition at line 388 of file syscalls.h.

◆ call_accept

#define call_accept (   sockfd,
  addr,
  addrlen 
)    syscall3(SYS_ACCEPT, (scarg)sockfd, (scarg)addr, (scarg)addrlen)

Accept an incoming connection on a socket.

int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);

Accepts an incoming connection on a listening socket, creating a new socket for communication.

Parameters
sockfdSocket file descriptor
addrClient address
addrlenLength of the address
Returns
  • New socket file descriptor on success
  • EINVAL if parameters are invalid

Definition at line 1798 of file syscalls.h.

◆ call_access

#define call_access (   pathname,
  mode 
)    syscall2(SYS_ACCESS, (scarg)pathname, (scarg)mode)

Check a file's accessibility.

int access(const char *pathname, int mode);

Checks if the calling process can access the file specified by pathname according to the specified mode.

Parameters
pathnamePath to the file
modeAccessibility check mode
Supported values:
Returns
  • EOK on success
  • EACCES if access is denied
  • ENOENT if the file does not exist
See also
syscall_access_flags_t

Definition at line 1717 of file syscalls.h.

◆ call_api_version

#define call_api_version (   version)    syscall1(SYS_API_VERSION, (scarg)version)

Set syscall version.

int api_version(int version);

This syscall is used to set the version of the list. To prevent applications from breaking on major changes, this should be called at the very beginning of the program.

Parameters
versionThe version of the syscall list of which the program was compiled with
Returns
  • EOK on success
  • EINVAL if the requested version is invalid
Note
If this syscall is not used, the latest version will be used.

Definition at line 1677 of file syscalls.h.

◆ call_bind

#define call_bind (   sockfd,
  addr,
  addrlen 
)    syscall3(SYS_BIND, (scarg)sockfd, (scarg)addr, (scarg)addrlen)

Bind a socket to a local address.

int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);

Binds a socket to a local address so it can listen for incoming connections.

Parameters
sockfdSocket file descriptor
addrAddress to bind to
addrlenLength of the address
Returns
  • EOK on success
  • EINVAL if the socket is invalid

Definition at line 1789 of file syscalls.h.

◆ call_brk

#define call_brk (   end_data)    syscall1(SYS_BRK, (scarg)end_data)

Set the program break.

int brk(void *end_data);

Increases or decreases the program’s data space, ending at end_data.

Parameters
end_dataNew program break location
Returns
  • EOK on success
  • ENOMEM if memory allocation fails

Definition at line 1760 of file syscalls.h.

◆ call_chdir

#define call_chdir (   path)    syscall1(SYS_CHDIR, (scarg)path)

Change the current working directory.

int chdir(const char *path);

Changes the current working directory to the specified path.

Parameters
pathNew directory path
Returns
  • EOK on success
  • ENOENT if the directory does not exist
  • EACCES if permission is denied

Definition at line 1829 of file syscalls.h.

◆ call_clock_gettime

#define call_clock_gettime (   clockid,
  tp 
)    syscall2(SYS_CLOCK_GETTIME, (scarg)clockid, (scarg)tp)

Get the current time of a specific clock.

int clock_gettime(clockid_t clockid, struct timespec *tp);

Retrieves the current time for the specified clock (CLOCK_REALTIME, CLOCK_MONOTONIC, etc.).

Parameters
clockidClock ID to query
tpPointer to store the time
Returns
  • EOK on success
  • EINVAL if parameters are invalid

Definition at line 1815 of file syscalls.h.

◆ call_clock_settime

#define call_clock_settime (   clockid,
  tp 
)    syscall2(SYS_CLOCK_SETTIME, (scarg)clockid, (scarg)tp)

Set the current time of a specific clock.

int clock_settime(clockid_t clockid, const struct timespec *tp);

Sets the time for the specified clock (CLOCK_REALTIME, CLOCK_MONOTONIC, etc.).

Parameters
clockidClock ID to set
tpPointer to the time value
Returns
  • EOK on success
  • EINVAL if parameters are invalid

Definition at line 1818 of file syscalls.h.

◆ call_close

#define call_close (   fd)    syscall1(SYS_CLOSE, fd)

Close a file descriptor.

int close(int fd);

Closes the file descriptor fd, releasing its resources.

Parameters
fdFile descriptor to close
Returns
  • EOK on success
  • EBADF if fd is not a valid file descriptor

Definition at line 1697 of file syscalls.h.

◆ call_connect

#define call_connect (   sockfd,
  addr,
  addrlen 
)    syscall3(SYS_CONNECT, (scarg)sockfd, (scarg)addr, (scarg)addrlen)

Connect to a remote address.

int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);

Connects a socket to a remote address.

Parameters
sockfdSocket file descriptor
addrRemote address to connect to
addrlenLength of the address
Returns
  • EOK on success
  • EINVAL if parameters are invalid

Definition at line 1792 of file syscalls.h.

◆ call_dup

#define call_dup (   oldfd)    syscall1(SYS_DUP, (scarg)oldfd)

Duplicate a file descriptor.

int dup(int oldfd);

Duplicates the file descriptor oldfd, returning the new file descriptor.

Parameters
oldfdFile descriptor to duplicate
Returns
  • New file descriptor on success
  • EBADF if oldfd is invalid

Definition at line 1780 of file syscalls.h.

◆ call_dup2

#define call_dup2 (   oldfd,
  newfd 
)    syscall2(SYS_DUP2, (scarg)oldfd, (scarg)newfd)

Duplicate a file descriptor to a specific value.

int dup2(int oldfd, int newfd);

Duplicates oldfd to newfd. If newfd is already open, it will be closed first.

Parameters
oldfdFile descriptor to duplicate
newfdFile descriptor to duplicate oldfd to
Returns
  • newfd on success
  • EBADF if oldfd is invalid
  • EINVAL if newfd is invalid

Definition at line 1783 of file syscalls.h.

◆ call_execve

#define call_execve (   pathname,
  argv,
  envp 
)    syscall3(SYS_EXECVE, (scarg)pathname, (scarg)argv, (scarg)envp)

Execute a program.

int execve(const char *pathname, char *const argv[], char *const envp[]);

Replaces the current process image with a new process image specified by pathname.

Parameters
pathnamePath to the executable file
argvArgument vector
envpEnvironment variables
Returns
  • Does not return on success
  • ENOENT if the file does not exist
  • EACCES if permissions are insufficient

Definition at line 1740 of file syscalls.h.

◆ call_exit

#define call_exit (   status)    syscall1(SYS_EXIT, (scarg)status)

Terminate the calling process.

void exit(int status);

Terminates the calling process with the specified status. The status code is made available to the parent process.

Parameters
statusExit status code
Returns
This function does not return.

Definition at line 1734 of file syscalls.h.

◆ call_fcntl

#define call_fcntl (   fd,
  cmd,
  arg 
)    syscall3(SYS_FCNTL, (scarg)fd, (scarg)cmd, (scarg)arg)

Function control.

int fcntl(int fd, int cmd, void *arg);

Manipulates the underlying parameters of a device.

Parameters
fdFile descriptor referring to the device
cmdDevice-specific request code
argArgument for the request
Returns
  • EOK on success
  • EBADF if fd is not valid
  • EINVAL if the request is invalid

Definition at line 1703 of file syscalls.h.

◆ call_fork

#define call_fork ( )    syscall0(SYS_FORK)

Create a child process.

pid_t fork(void);

Creates a new process by duplicating the calling process. The child process has its own copy of the parent's address space.

Returns
  • 0 to the child process
  • PID of the child to the parent process
  • ENOMEM if memory is insufficient

Definition at line 1737 of file syscalls.h.

◆ call_fstat

#define call_fstat (   fd,
  statbuf 
)    syscall2(SYS_FSTAT, (scarg)fd, (scarg)statbuf)

Retrieve file status for an open file descriptor.

int fstat(int fd, struct stat *statbuf);

Gets the status of the file referred to by fd.

Parameters
fdFile descriptor
statbufBuffer to store file status
Returns
  • EOK on success
  • EBADF if fd is not a valid file descriptor
  • EFAULT if statbuf is outside accessible address space

Definition at line 1711 of file syscalls.h.

◆ call_ftruncate

#define call_ftruncate (   fd,
  length 
)    syscall2(SYS_FTRUNCATE, (scarg)fd, (scarg)length)

Change the size of a file referred by a file descriptor.

int ftruncate(int fd, off_t length);

Sets the size of the file referred to by fd to length.

Parameters
fdFile descriptor
lengthDesired file length
Returns

Definition at line 1723 of file syscalls.h.

◆ call_getcwd

#define call_getcwd (   buf,
  size 
)    syscall2(SYS_GETCWD, (scarg)buf, (scarg)size)

Get the current working directory.

char *getcwd(char *buf, size_t size);

Retrieves the current working directory.

Parameters
bufBuffer to store the directory path
sizeSize of the buffer
Returns

Definition at line 1826 of file syscalls.h.

◆ call_getpid

#define call_getpid ( )    syscall0(SYS_GETPID)

Get the process ID of the calling process.

pid_t getpid(void);

Returns the process ID of the calling process.

Returns
  • Process ID on success

Definition at line 1743 of file syscalls.h.

◆ call_getppid

#define call_getppid ( )    syscall0(SYS_GETPPID)

Get the parent process ID.

pid_t getppid(void);

Returns the parent process ID of the calling process.

Returns
  • Parent process ID on success

Definition at line 1746 of file syscalls.h.

◆ call_ioctl

#define call_ioctl (   fd,
  request,
  argp 
)    syscall3(SYS_IOCTL, (scarg)fd, (scarg)request, (scarg)argp)

Control a device.

int ioctl(int fd, unsigned long request, void *argp);

Manipulates the underlying parameters of a device.

Parameters
fdFile descriptor referring to the device
requestDevice-specific request code
argpArgument for the request
Returns
  • EOK on success
  • EBADF if fd is not valid
  • EINVAL if the request is invalid

Definition at line 1700 of file syscalls.h.

◆ call_kill

#define call_kill (   pid,
  sig 
)    syscall2(SYS_KILL, (scarg)pid, (scarg)sig)

Send a signal to a process.

int kill(pid_t pid, int sig);

Sends the signal sig to the process specified by pid.

Parameters
pidProcess ID
sigSignal to send
Returns
  • EOK on success
  • ESRCH if the process does not exist
  • EINVAL if sig is invalid

Definition at line 1752 of file syscalls.h.

◆ call_listen

#define call_listen (   sockfd,
  backlog 
)    syscall2(SYS_LISTEN, (scarg)sockfd, (scarg)backlog)

Listen for incoming connections on a socket.

int listen(int sockfd, int backlog);

Sets a socket to listen for incoming connections, specifying the backlog queue size.

Parameters
sockfdSocket file descriptor
backlogNumber of pending connections to allow
Returns
  • EOK on success
  • EINVAL if parameters are invalid

Definition at line 1795 of file syscalls.h.

◆ call_lstat

#define call_lstat (   pathname,
  statbuf 
)    syscall2(SYS_LSTAT, (scarg)pathname, (scarg)statbuf)

Retrieve file status with symbolic link resolution.

int lstat(const char *pathname, struct stat *statbuf);

Gets the status of the file specified by pathname, but does not follow symbolic links.

Parameters
pathnamePath to the file
statbufBuffer to store file status
Returns
  • EOK on success
  • ENOENT if the file does not exist
  • EACCES if permissions are insufficient

Definition at line 1714 of file syscalls.h.

◆ call_madvise

#define call_madvise (   addr,
  length,
  advice 
)    syscall3(SYS_MADVISE, (scarg)addr, (scarg)length, (scarg)advice)

Provide advice about memory usage.

int madvise(void *addr, size_t length, int advice);

Provides advice to the kernel about the expected behavior of the memory region starting at addr for length, such as whether it will be accessed randomly or sequentially.

Parameters
addrStart address of the memory region
lengthLength of the memory region
adviceDesired advice (e.g., MADV_DONTNEED, MADV_SEQUENTIAL)
Returns
  • EOK on success
  • EINVAL if the parameters are invalid

Definition at line 1772 of file syscalls.h.

◆ call_mkdir

#define call_mkdir (   path,
  mode 
)    syscall2(SYS_MKDIR, (scarg)path, (scarg)mode)

Create a new directory.

int mkdir(const char *path, mode_t mode);

Creates a new directory at path with the specified permissions.

Parameters
pathPath to the new directory
modeDirectory permissions
Returns
  • EOK on success
  • EEXIST if the directory already exists
  • EACCES if permission is denied

Definition at line 1832 of file syscalls.h.

◆ call_mmap

#define call_mmap (   addr,
  length,
  prot,
  flags,
  fd,
  offset 
)    syscall6(SYS_MMAP, (scarg)addr, (scarg)length, (scarg)prot, (scarg)flags, (scarg)fd, (scarg)offset)

Map files or devices into memory.

void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);

Maps a file or device into memory. This can be used for memory-mapped I/O or for sharing memory between processes.

Parameters
addrDesired starting address of the mapping (NULL for automatic allocation)
lengthLength of the mapping
protDesired memory protection
Supported values:
flagsMapping options
Supported values:
fdFile descriptor for the file to map
offsetOffset in the file to start the mapping
Returns
There are several possible return values:
See also
syscall_mmap_flags_t

Definition at line 1763 of file syscalls.h.

◆ call_mprotect

#define call_mprotect (   addr,
  length,
  prot 
)    syscall3(SYS_MPROTECT, (scarg)addr, (scarg)length, (scarg)prot)

Change memory protection.

int mprotect(void *addr, size_t length, int prot);

Sets the protection on the memory region starting at addr for length.

Parameters
addrStart address of the memory region
lengthLength of the memory region
protDesired memory protection (e.g., PROT_READ, PROT_WRITE)
Returns
  • EOK on success
  • EACCES if protection cannot be set

Definition at line 1769 of file syscalls.h.

◆ call_munmap

#define call_munmap (   addr,
  length 
)    syscall2(SYS_MUNMAP, (scarg)addr, (scarg)length)

Unmap a mapped memory region.

int munmap(void *addr, size_t length);

Unmaps a previously mapped memory region, making the memory available for reuse.

Parameters
addrStart address of the memory region
lengthLength of the memory region to unmap
Returns
  • EOK on success
  • EINVAL if the address or length is invalid
  • EFAULT if the memory region is not currently mapped

Definition at line 1766 of file syscalls.h.

◆ call_nanosleep

#define call_nanosleep (   req,
  rem 
)    syscall2(SYS_NANOSLEEP, (scarg)req, (scarg)rem)

Sleep for a specified time.

int nanosleep(const struct timespec *req, struct timespec *rem);

Suspends the execution of the calling thread for the specified time duration.

Parameters
reqPointer to timespec specifying the time to sleep
remPointer to store remaining time if interrupted
Returns
  • EOK on success
  • EINTR if interrupted by a signal

Definition at line 1821 of file syscalls.h.

◆ call_open

#define call_open (   pathname,
  flags,
  mode 
)    syscall3(SYS_OPEN, (scarg)pathname, (scarg)flags, (scarg)mode)

Open a file.

int open(const char *pathname, int flags, mode_t mode);

Opens the file specified by pathname.

Parameters
pathnamePath to the file
flagsFlags for file access mode
Supported values:
modePermissions for newly created file (if applicable)
Returns
  • File descriptor on success
  • ENOENT if the file does not exist
  • EACCES if permissions are insufficient
See also
syscall_open_flags_t

Definition at line 1694 of file syscalls.h.

◆ call_pipe

#define call_pipe (   pipefd)    syscall1(SYS_PIPE, (scarg)pipefd)

Create a pipe.

int pipe(int pipefd[2]);

Creates a pipe, returning two file descriptors in pipefd. One is for reading, and the other is for writing.

Parameters
pipefdArray to store the two file descriptors
Returns
  • EOK on success
  • EMFILE if the process has too many open file descriptors

Definition at line 1777 of file syscalls.h.

◆ call_prctl

#define call_prctl (   option,
  arg1,
  arg2,
  arg3,
  arg4 
)    syscall5(SYS_PRCTL, (scarg)option, (scarg)arg1, (scarg)arg2, (scarg)arg3, (scarg)arg4)

Process/Thread Control.

int prctl(syscall_prctl_options_t option, unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4);
syscall_prctl_options_t
Definition syscalls.h:429

Perform various operations on a process or thread.

Parameters
optionOperation to perform
arg1Argument 1
arg2Argument 2
arg3Argument 3
arg4Argument 4
Returns
  • EOK on success
  • EINVAL if the operation is invalid
  • EFAULT if one of the arguments is invalid

Definition at line 1755 of file syscalls.h.

◆ call_pread

#define call_pread (   fd,
  buf,
  count,
  offset 
)    syscall4(SYS_PREAD, (scarg)fd, (scarg)buf, (scarg)count, (scarg)offset)

Read from a file descriptor.

ssize_t sys_pread(int fildes, void *buf, size_t nbyte, off_t offset);

Reads up to count bytes from the file descriptor fd into the buffer starting at buf.

Parameters
fdFile descriptor to read from
bufBuffer where data will be stored
countMaximum number of bytes to read
offsetOffset in the file
Returns
  • Number of bytes read on success
  • 0 if the end of file is reached
  • EFAULT if the buffer is outside accessible address space
  • EBADF if fd is not a valid file descriptor

Definition at line 1685 of file syscalls.h.

◆ call_pwrite

#define call_pwrite (   fd,
  buf,
  count,
  offset 
)    syscall4(SYS_PWRITE, (scarg)fd, (scarg)buf, (scarg)count, (scarg)offset)

Write to a file descriptor.

ssize_t sys_pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);

Writes up to count bytes from the buffer starting at buf to the file descriptor fd.

Parameters
fdFile descriptor to write to
bufBuffer containing data to write
countNumber of bytes to write
offsetOffset in the file
Returns
  • Number of bytes written on success
  • EFAULT if the buffer is outside accessible address space
  • EBADF if fd is not a valid file descriptor

Definition at line 1691 of file syscalls.h.

◆ call_read

#define call_read (   fd,
  buf,
  count 
)    syscall3(SYS_READ, (scarg)fd, (scarg)buf, (scarg)count)

Read from a file descriptor.

ssize_t sys_read(int fildes, void *buf, size_t nbyte);

Reads up to count bytes from the file descriptor fd into the buffer starting at buf.

Parameters
fdFile descriptor to read from
bufBuffer where data will be stored
countMaximum number of bytes to read
Returns
  • Number of bytes read on success
  • 0 if the end of file is reached
  • EFAULT if the buffer is outside accessible address space
  • EBADF if fd is not a valid file descriptor

Definition at line 1682 of file syscalls.h.

◆ call_recv

#define call_recv (   sockfd,
  buf,
  len,
  flags 
)    syscall4(SYS_RECV, (scarg)sockfd, (scarg)buf, (scarg)len, (scarg)flags)

Receive data on a socket.

ssize_t recv(int sockfd, void *buf, size_t len, int flags);

Receives data from a socket.

Parameters
sockfdSocket file descriptor
bufBuffer to store received data
lenMaximum number of bytes to receive
flagsFlags for the receive operation
Returns
  • Number of bytes received on success
  • EINVAL if parameters are invalid

Definition at line 1804 of file syscalls.h.

◆ call_rename

#define call_rename (   oldpath,
  newpath 
)    syscall2(SYS_RENAME, (scarg)oldpath, (scarg)newpath)

Rename a file or directory.

int rename(const char *oldpath, const char *newpath);

Renames a file or directory from oldpath to newpath.

Parameters
oldpathCurrent name of the file or directory
newpathNew name of the file or directory
Returns
  • EOK on success
  • EEXIST if the target exists
  • EACCES if permission is denied

Definition at line 1841 of file syscalls.h.

◆ call_rmdir

#define call_rmdir (   path)    syscall1(SYS_RMDIR, (scarg)path)

Remove an empty directory.

int rmdir(const char *path);

Removes the empty directory specified by path.

Parameters
pathPath to the directory
Returns

Definition at line 1835 of file syscalls.h.

◆ call_seek

#define call_seek (   fd,
  offset,
  whence 
)    syscall3(SYS_SEEK, (scarg)fd, (scarg)offset, (scarg)whence)

Set the file offset.

off_t seek(int fd, off_t offset, int whence);

Sets the file offset for the file referred to by fd to the specified offset according to the directive whence.

Parameters
fdFile descriptor
offsetOffset to set
whenceDirective for setting the offset
Supported values:
Returns
  • New file offset on success
  • EBADF if fd is not a valid file descriptor
  • EINVAL if whence is invalid

Definition at line 1729 of file syscalls.h.

◆ call_send

#define call_send (   sockfd,
  buf,
  len,
  flags 
)    syscall4(SYS_SEND, (scarg)sockfd, (scarg)buf, (scarg)len, (scarg)flags)

Send data on a socket.

ssize_t send(int sockfd, const void *buf, size_t len, int flags);

Sends data through a socket.

Parameters
sockfdSocket file descriptor
bufData to send
lenLength of the data
flagsFlags for the send operation
Returns
  • Number of bytes sent on success
  • EINVAL if parameters are invalid

Definition at line 1801 of file syscalls.h.

◆ call_shutdown

#define call_shutdown (   sockfd,
  how 
)    syscall2(SYS_SHUTDOWN, (scarg)sockfd, (scarg)how)

Shut down part of a full-duplex connection.

int shutdown(int sockfd, int how);

Shuts down part of a full-duplex connection on a socket.

Parameters
sockfdSocket file descriptor
howDetermines which operations to shut down (e.g., SHUT_RD, SHUT_WR)
Returns
  • EOK on success
  • EINVAL if parameters are invalid

Definition at line 1807 of file syscalls.h.

◆ call_socket

#define call_socket (   domain,
  type,
  protocol 
)    syscall3(SYS_SOCKET, (scarg)domain, (scarg)type, (scarg)protocol)

Create an endpoint for communication.

int socket(int domain, int type, int protocol);

Creates an endpoint for communication, returning a socket file descriptor.

Parameters
domainCommunication domain (e.g., AF_INET for IPv4)
typeType of socket (e.g., SOCK_STREAM for TCP)
protocolProtocol to use (e.g., IPPROTO_TCP)
Returns
  • Socket file descriptor on success
  • EINVAL if parameters are invalid

Definition at line 1786 of file syscalls.h.

◆ call_stat

#define call_stat (   pathname,
  statbuf 
)    syscall2(SYS_STAT, (scarg)pathname, (scarg)statbuf)

Retrieve file status.

int stat(const char *pathname, struct stat *statbuf);

Gets the status of the file specified by pathname.

Parameters
pathnamePath to the file
statbufBuffer to store file status
Returns
  • EOK on success
  • ENOENT if the file does not exist
  • EACCES if permissions are insufficient

Definition at line 1708 of file syscalls.h.

◆ call_tell

#define call_tell (   fd)    syscall1(SYS_TELL, (scarg)fd)

Get the current file offset.

off_t tell(int fd);

Returns the current file offset for the file referred to by fd.

Parameters
fdFile descriptor
Returns
  • Current file offset on success
  • EBADF if fd is not a valid file descriptor

Definition at line 1726 of file syscalls.h.

◆ call_time

#define call_time (   t)    syscall1(SYS_TIME, (scarg)t)

Get the current time.

time_t time(time_t *t);

Retrieves the current calendar time as the number of seconds since the epoch.

Parameters
tPointer to store the time (optional)
Returns
  • Current time in seconds on success
  • __SYS_NULL if t is NULL

Definition at line 1812 of file syscalls.h.

◆ call_truncate

#define call_truncate (   pathname,
  length 
)    syscall2(SYS_TRUNCATE, (scarg)pathname, (scarg)length)

Change the size of a file.

int truncate(const char *pathname, off_t length);

Sets the size of the file specified by pathname to length. If the file is shorter, it is extended and the extended part is zero-filled.

Parameters
pathnamePath to the file
lengthDesired file length
Returns
  • EOK on success
  • EINVAL if length is invalid
  • EACCES if permissions are insufficient

Definition at line 1720 of file syscalls.h.

◆ call_uname

#define call_uname (   buf)    syscall1(SYS_UNAME, (scarg)buf)

Get unix name information.

int uname(struct kutsname *buf);

Retrieves information about the operating system.

Parameters
bufPointer to kutsname structure to store information
Returns
  • EOK on success
  • EFAULT if buf is outside accessible address space

Definition at line 1844 of file syscalls.h.

◆ call_unlink

#define call_unlink (   pathname)    syscall1(SYS_UNLINK, (scarg)pathname)

Remove a file.

int unlink(const char *pathname);

Removes the file specified by pathname.

Parameters
pathnamePath to the file
Returns
  • EOK on success
  • ENOENT if the file does not exist
  • EACCES if permission is denied

Definition at line 1838 of file syscalls.h.

◆ call_waitpid

#define call_waitpid (   pid,
  wstatus,
  options 
)    syscall3(SYS_WAITPID, (scarg)pid, (scarg)wstatus, (scarg)options)

Wait for a child process to change state.

pid_t waitpid(pid_t pid, int *wstatus, int options);

Waits for the child process specified by pid to change state.

Parameters
pidProcess ID to wait for
wstatusPointer to store the status information
optionsOptions for waiting behavior
Returns
  • Process ID of the child on success
  • ECHILD if no child processes exist

Definition at line 1749 of file syscalls.h.

◆ call_write

#define call_write (   fd,
  buf,
  count 
)    syscall3(SYS_WRITE, (scarg)fd, (scarg)buf, (scarg)count)

Write to a file descriptor.

ssize_t sys_write(int fildes, const void *buf, size_t nbyte);

Writes up to count bytes from the buffer starting at buf to the file descriptor fd.

Parameters
fdFile descriptor to write to
bufBuffer containing data to write
countNumber of bytes to write
Returns
  • Number of bytes written on success
  • EFAULT if the buffer is outside accessible address space
  • EBADF if fd is not a valid file descriptor
  • EPIPE if writing to a pipe with no reader

Definition at line 1688 of file syscalls.h.

◆ FBIOGET_SCREEN_INFO

#define FBIOGET_SCREEN_INFO   0xf0

Get framebuffer screen info.

int ioctl(fd, FBIOGET_SCREEN_INFO, &info);
#define FBIOGET_SCREEN_INFO
Get framebuffer screen info.
Definition syscalls.h:635
Parameters
fdFile descriptor of the framebuffer device
infoPointer to the framebuffer screen info structure

Definition at line 635 of file syscalls.h.

◆ scarg

#define scarg   __UINTPTR_TYPE__

Definition at line 33 of file syscalls.h.

Typedef Documentation

◆ __SYS_clockid_t

typedef int __SYS_clockid_t

Definition at line 612 of file syscalls.h.

◆ __SYS_socklen_t

typedef unsigned int __SYS_socklen_t

Definition at line 613 of file syscalls.h.

◆ FramebufferScreenInfo

Enumeration Type Documentation

◆ syscall_access_flags_t

Enumerator
__SYS_F_OK 
__SYS_R_OK 
__SYS_W_OK 
__SYS_X_OK 

Definition at line 420 of file syscalls.h.

421{
422 __SYS_F_OK = 0,
423 __SYS_R_OK = 1,
424 __SYS_W_OK = 2,
425 __SYS_X_OK = 3
syscall_access_flags_t
Definition syscalls.h:421
@ __SYS_X_OK
Definition syscalls.h:425
@ __SYS_R_OK
Definition syscalls.h:423
@ __SYS_F_OK
Definition syscalls.h:422
@ __SYS_W_OK
Definition syscalls.h:424

◆ syscall_clockid_t

Enumerator
__SYS_CLOCK_MONOTONIC 
__SYS_CLOCK_PROCESS_CPUTIME_ID 
__SYS_CLOCK_REALTIME 
__SYS_CLOCK_THREAD_CPUTIME_ID 

Definition at line 598 of file syscalls.h.

599{
syscall_clockid_t
Definition syscalls.h:599
@ __SYS_CLOCK_PROCESS_CPUTIME_ID
Definition syscalls.h:601
@ __SYS_CLOCK_REALTIME
Definition syscalls.h:602
@ __SYS_CLOCK_THREAD_CPUTIME_ID
Definition syscalls.h:603
@ __SYS_CLOCK_MONOTONIC
Definition syscalls.h:600

◆ syscall_mmap_flags_t

Enumerator
__SYS_PROT_READ 
__SYS_PROT_WRITE 
__SYS_PROT_EXEC 
__SYS_PROT_NONE 
__SYS_MAP_SHARED 
__SYS_MAP_PRIVATE 
__SYS_MAP_FIXED 
__SYS_MAP_ANONYMOUS 
__SYS_MAP_ANON 

Definition at line 390 of file syscalls.h.

391{
392 __SYS_PROT_READ = 0x1,
393 __SYS_PROT_WRITE = 0x2,
394 __SYS_PROT_EXEC = 0x4,
395 __SYS_PROT_NONE = 0x0,
396
397 __SYS_MAP_SHARED = 0x1,
398 __SYS_MAP_PRIVATE = 0x2,
399 __SYS_MAP_FIXED = 0x4,
syscall_mmap_flags_t
Definition syscalls.h:391
@ __SYS_MAP_ANON
Definition syscalls.h:401
@ __SYS_PROT_NONE
Definition syscalls.h:395
@ __SYS_PROT_READ
Definition syscalls.h:392
@ __SYS_MAP_FIXED
Definition syscalls.h:399
@ __SYS_MAP_SHARED
Definition syscalls.h:397
@ __SYS_PROT_EXEC
Definition syscalls.h:394
@ __SYS_PROT_WRITE
Definition syscalls.h:393
@ __SYS_MAP_PRIVATE
Definition syscalls.h:398
@ __SYS_MAP_ANONYMOUS
Definition syscalls.h:400

◆ syscall_open_flags_t

Enumerator
__SYS_O_RDONLY 
__SYS_O_WRONLY 
__SYS_O_RDWR 
__SYS_O_APPEND 
__SYS_O_CREAT 
__SYS_O_DSYNC 
__SYS_O_EXCL 
__SYS_O_NOCTTY 
__SYS_O_NONBLOCK 
__SYS_O_RSYNC 
__SYS_O_SYNC 
__SYS_O_TRUNC 

Definition at line 404 of file syscalls.h.

405{
#define O_WRONLY
Definition fcntl.h:79
#define O_CREAT
Definition fcntl.h:59
#define O_NOCTTY
Definition fcntl.h:62
#define O_NONBLOCK
Definition fcntl.h:69
#define O_RDONLY
Definition fcntl.h:76
#define O_EXCL
Definition fcntl.h:61
#define O_SYNC
Definition fcntl.h:71
#define O_RDWR
Definition fcntl.h:77
#define O_RSYNC
Definition fcntl.h:70
#define O_TRUNC
Definition fcntl.h:64
#define O_APPEND
Definition fcntl.h:67
#define O_DSYNC
Definition fcntl.h:68
syscall_open_flags_t
Definition syscalls.h:405
@ __SYS_O_RDWR
Definition syscalls.h:408
@ __SYS_O_DSYNC
Definition syscalls.h:411
@ __SYS_O_NONBLOCK
Definition syscalls.h:414
@ __SYS_O_RDONLY
Definition syscalls.h:406
@ __SYS_O_RSYNC
Definition syscalls.h:415
@ __SYS_O_WRONLY
Definition syscalls.h:407
@ __SYS_O_NOCTTY
Definition syscalls.h:413
@ __SYS_O_EXCL
Definition syscalls.h:412
@ __SYS_O_APPEND
Definition syscalls.h:409
@ __SYS_O_SYNC
Definition syscalls.h:416
@ __SYS_O_TRUNC
Definition syscalls.h:417
@ __SYS_O_CREAT
Definition syscalls.h:410

◆ syscall_prctl_options_t

Enumerator
__SYS_GET_GS 
__SYS_SET_GS 
__SYS_GET_FS 
__SYS_SET_FS 

Definition at line 428 of file syscalls.h.

429{
430 __SYS_GET_GS = 0,
431 __SYS_SET_GS = 1,
432 __SYS_GET_FS = 2,
433 __SYS_SET_FS = 3,
@ __SYS_GET_FS
Definition syscalls.h:432
@ __SYS_SET_GS
Definition syscalls.h:431
@ __SYS_GET_GS
Definition syscalls.h:430
@ __SYS_SET_FS
Definition syscalls.h:433

◆ syscall_seek_whence_t

Enumerator
__SYS_SEEK_SET 
__SYS_SEEK_CUR 
__SYS_SEEK_END 

Definition at line 439 of file syscalls.h.

440{
441 __SYS_SEEK_SET = 0,
442 __SYS_SEEK_CUR = 1,
syscall_seek_whence_t
Definition syscalls.h:440
@ __SYS_SEEK_CUR
Definition syscalls.h:442
@ __SYS_SEEK_SET
Definition syscalls.h:441
@ __SYS_SEEK_END
Definition syscalls.h:443

◆ syscall_signal_action_disposition_t

Enumerator
__SYS_SIG_ERR 
__SYS_SIG_DFL 
___SYS_SIG_IGN 

Definition at line 591 of file syscalls.h.

592{
593 __SYS_SIG_ERR = -1,
594 __SYS_SIG_DFL = 0,
syscall_signal_action_disposition_t
Definition syscalls.h:592
@ __SYS_SIG_ERR
Definition syscalls.h:593
@ ___SYS_SIG_IGN
Definition syscalls.h:595
@ __SYS_SIG_DFL
Definition syscalls.h:594

◆ syscall_signal_action_flags_t

Enumerator
__SYS_SA_NOCLDSTOP 
__SYS_SA_ONSTACK 
__SYS_SA_RESETHAND 
__SYS_SA_RESTART 
__SYS_SA_SIGINFO 
__SYS_SA_NOCLDWAIT 
__SYS_SA_NODEFER 

Definition at line 580 of file syscalls.h.

581{
583 __SYS_SA_ONSTACK = 0x08000000,
584 __SYS_SA_RESETHAND = 0x80000000,
585 __SYS_SA_RESTART = 0x10000000,
588 __SYS_SA_NODEFER = 0x40000000,
syscall_signal_action_flags_t
Definition syscalls.h:581
@ __SYS_SA_SIGINFO
Definition syscalls.h:586
@ __SYS_SA_RESTART
Definition syscalls.h:585
@ __SYS_SA_RESETHAND
Definition syscalls.h:584
@ __SYS_SA_ONSTACK
Definition syscalls.h:583
@ __SYS_SA_NODEFER
Definition syscalls.h:588
@ __SYS_SA_NOCLDSTOP
Definition syscalls.h:582
@ __SYS_SA_NOCLDWAIT
Definition syscalls.h:587

◆ syscall_signal_actions_t

Enumerator
__SYS_SIG_BLOCK 
__SYS_SIG_UNBLOCK 
__SYS_SIG_SETMASK 

Definition at line 573 of file syscalls.h.

574{
575 __SYS_SIG_BLOCK = 0,
syscall_signal_actions_t
Definition syscalls.h:574
@ __SYS_SIG_UNBLOCK
Definition syscalls.h:576
@ __SYS_SIG_SETMASK
Definition syscalls.h:577
@ __SYS_SIG_BLOCK
Definition syscalls.h:575

◆ syscall_signal_disposition_t

Enumerator
__SYS_SIG_TERM 

Terminate the process.

__SYS_SIG_IGN 

Ignore the signal.

__SYS_SIG_CONT 

Continue the process.

__SYS_SIG_STOP 

Stop the process.

__SYS_SIG_CORE 

Dump core.

Definition at line 556 of file syscalls.h.

557{
559 __SYS_SIG_TERM = 0,
561 __SYS_SIG_IGN = 1,
563 __SYS_SIG_CONT = 2,
565 __SYS_SIG_STOP = 3,
syscall_signal_disposition_t
Definition syscalls.h:557
@ __SYS_SIG_TERM
Definition syscalls.h:559
@ __SYS_SIG_STOP
Definition syscalls.h:565
@ __SYS_SIG_CORE
Definition syscalls.h:567
@ __SYS_SIG_CONT
Definition syscalls.h:563
@ __SYS_SIG_IGN
Definition syscalls.h:561

◆ syscall_signal_t

Enumerator
__SYS_SIGNULL 
__SYS_SIGABRT 
__SYS_SIGALRM 
__SYS_SIGBUS 
__SYS_SIGCHLD 
__SYS_SIGCONT 
__SYS_SIGFPE 
__SYS_SIGHUP 
__SYS_SIGILL 
__SYS_SIGINT 
__SYS_SIGKILL 
__SYS_SIGPIPE 
__SYS_SIGQUIT 
__SYS_SIGSEGV 
__SYS_SIGSTOP 
__SYS_SIGTERM 
__SYS_SIGTSTP 
__SYS_SIGTTIN 
__SYS_SIGTTOU 
__SYS_SIGUSR1 
__SYS_SIGUSR2 
__SYS_SIGPOLL 
__SYS_SIGPROF 
__SYS_SIGSYS 
__SYS_SIGTRAP 
__SYS_SIGURG 
__SYS_SIGVTALRM 
__SYS_SIGXCPU 
__SYS_SIGXFSZ 
__SYS_SIGCOMP1 

Reserved These are just to match Linux's signal numbers.

__SYS_SIGCOMP2 
__SYS_SIGCOMP3 
__SYS_SIGRTMIN 
__SYS_SIGRT_1 
__SYS_SIGRT_2 
__SYS_SIGRT_3 
__SYS_SIGRT_4 
__SYS_SIGRT_5 
__SYS_SIGRT_6 
__SYS_SIGRT_7 
__SYS_SIGRT_8 
__SYS_SIGRT_9 
__SYS_SIGRT_10 
__SYS_SIGRT_11 
__SYS_SIGRT_12 
__SYS_SIGRT_13 
__SYS_SIGRT_14 
__SYS_SIGRT_15 
__SYS_SIGRT_16 
__SYS_SIGRT_17 
__SYS_SIGRT_18 
__SYS_SIGRT_19 
__SYS_SIGRT_20 
__SYS_SIGRT_21 
__SYS_SIGRT_22 
__SYS_SIGRT_23 
__SYS_SIGRT_24 
__SYS_SIGRT_25 
__SYS_SIGRT_26 
__SYS_SIGRT_27 
__SYS_SIGRT_28 
__SYS_SIGRT_29 
__SYS_SIGRT_30 
__SYS_SIGRT_31 
__SYS_SIGRTMAX 
__SYS_SIGNAL_MAX 

Definition at line 446 of file syscalls.h.

447{
448 __SYS_SIGNULL = 0,
449 /* Process abort signal. */
450 __SYS_SIGABRT = 1,
451 /* Alarm clock. */
452 __SYS_SIGALRM = 2,
453 /* Access to an undefined portion of a memory object. */
454 __SYS_SIGBUS = 3,
455 /* Child process terminated, stopped, or continued. */
456 __SYS_SIGCHLD = 4,
457 /* Continue executing, if stopped. */
458 __SYS_SIGCONT = 5,
459 /* Erroneous arithmetic operation. */
460 __SYS_SIGFPE = 6,
461 /* Hangup. */
462 __SYS_SIGHUP = 7,
463 /* Illegal instruction. */
464 __SYS_SIGILL = 8,
465 /* Terminal interrupt signal. */
466 __SYS_SIGINT = 9,
467 /* Kill (cannot be caught or ignored). */
468 __SYS_SIGKILL = 10,
469 /* Write on a pipe with no one to read it. */
470 __SYS_SIGPIPE = 11,
471 /* Terminal quit signal. */
472 __SYS_SIGQUIT = 12,
473 /* Invalid memory reference. */
474 __SYS_SIGSEGV = 13,
475 /* Stop executing (cannot be caught or ignored). */
476 __SYS_SIGSTOP = 14,
477 /* Termination signal. */
478 __SYS_SIGTERM = 15,
479 /* Terminal stop signal. */
480 __SYS_SIGTSTP = 16,
481 /* Background process attempting read. */
482 __SYS_SIGTTIN = 17,
483 /* Background process attempting write. */
484 __SYS_SIGTTOU = 18,
485 /* User-defined signal 1. */
486 __SYS_SIGUSR1 = 19,
487 /* User-defined signal 2. */
488 __SYS_SIGUSR2 = 20,
489 /* Pollable event. */
490 __SYS_SIGPOLL = 21,
491 /* Profiling timer expired. */
492 __SYS_SIGPROF = 22,
493 /* Bad system call. */
494 __SYS_SIGSYS = 23,
495 /* Trace/breakpoint trap. */
496 __SYS_SIGTRAP = 24,
497 /* High bandwidth data is available at a socket. */
498 __SYS_SIGURG = 25,
499 /* Virtual timer expired. */
500 __SYS_SIGVTALRM = 26,
501 /* CPU time limit exceeded. */
502 __SYS_SIGXCPU = 27,
503 /* File size limit exceeded. */
504 __SYS_SIGXFSZ = 28,
505
510 __SYS_SIGCOMP1 = 29,
511 __SYS_SIGCOMP2 = 30,
512 __SYS_SIGCOMP3 = 31,
513
514 /* Real-time signals. */
515 __SYS_SIGRTMIN = 32,
516 __SYS_SIGRT_1 = 33,
517 __SYS_SIGRT_2 = 34,
518 __SYS_SIGRT_3 = 35,
519 __SYS_SIGRT_4 = 36,
520 __SYS_SIGRT_5 = 37,
521 __SYS_SIGRT_6 = 38,
522 __SYS_SIGRT_7 = 39,
523 __SYS_SIGRT_8 = 40,
524 __SYS_SIGRT_9 = 41,
525 __SYS_SIGRT_10 = 42,
526 __SYS_SIGRT_11 = 43,
527 __SYS_SIGRT_12 = 44,
528 __SYS_SIGRT_13 = 45,
529 __SYS_SIGRT_14 = 46,
530 __SYS_SIGRT_15 = 47,
531 __SYS_SIGRT_16 = 48,
532 __SYS_SIGRT_17 = 49,
533 __SYS_SIGRT_18 = 50,
534 __SYS_SIGRT_19 = 51,
535 __SYS_SIGRT_20 = 52,
536 __SYS_SIGRT_21 = 53,
537 __SYS_SIGRT_22 = 54,
538 __SYS_SIGRT_23 = 55,
539 __SYS_SIGRT_24 = 56,
540 __SYS_SIGRT_25 = 57,
541 __SYS_SIGRT_26 = 58,
542 __SYS_SIGRT_27 = 59,
543 __SYS_SIGRT_28 = 60,
544 __SYS_SIGRT_29 = 61,
545 __SYS_SIGRT_30 = 62,
546 __SYS_SIGRT_31 = 63,
547 __SYS_SIGRTMAX = 64,
548
549 /* Maximum signal number. */
syscall_signal_t
Definition syscalls.h:447
@ __SYS_SIGRTMAX
Definition syscalls.h:547
@ __SYS_SIGRT_11
Definition syscalls.h:526
@ __SYS_SIGRT_7
Definition syscalls.h:522
@ __SYS_SIGTTIN
Definition syscalls.h:482
@ __SYS_SIGUSR1
Definition syscalls.h:486
@ __SYS_SIGTSTP
Definition syscalls.h:480
@ __SYS_SIGTERM
Definition syscalls.h:478
@ __SYS_SIGPOLL
Definition syscalls.h:490
@ __SYS_SIGFPE
Definition syscalls.h:460
@ __SYS_SIGKILL
Definition syscalls.h:468
@ __SYS_SIGCOMP3
Definition syscalls.h:512
@ __SYS_SIGRT_29
Definition syscalls.h:544
@ __SYS_SIGRT_9
Definition syscalls.h:524
@ __SYS_SIGRT_1
Definition syscalls.h:516
@ __SYS_SIGRT_23
Definition syscalls.h:538
@ __SYS_SIGQUIT
Definition syscalls.h:472
@ __SYS_SIGURG
Definition syscalls.h:498
@ __SYS_SIGRT_15
Definition syscalls.h:530
@ __SYS_SIGBUS
Definition syscalls.h:454
@ __SYS_SIGTRAP
Definition syscalls.h:496
@ __SYS_SIGRT_3
Definition syscalls.h:518
@ __SYS_SIGRT_13
Definition syscalls.h:528
@ __SYS_SIGCOMP1
Definition syscalls.h:510
@ __SYS_SIGRT_4
Definition syscalls.h:519
@ __SYS_SIGRT_24
Definition syscalls.h:539
@ __SYS_SIGRT_17
Definition syscalls.h:532
@ __SYS_SIGNULL
Definition syscalls.h:448
@ __SYS_SIGCOMP2
Definition syscalls.h:511
@ __SYS_SIGABRT
Definition syscalls.h:450
@ __SYS_SIGRT_5
Definition syscalls.h:520
@ __SYS_SIGTTOU
Definition syscalls.h:484
@ __SYS_SIGNAL_MAX
Definition syscalls.h:550
@ __SYS_SIGALRM
Definition syscalls.h:452
@ __SYS_SIGRT_28
Definition syscalls.h:543
@ __SYS_SIGXFSZ
Definition syscalls.h:504
@ __SYS_SIGINT
Definition syscalls.h:466
@ __SYS_SIGSEGV
Definition syscalls.h:474
@ __SYS_SIGVTALRM
Definition syscalls.h:500
@ __SYS_SIGCONT
Definition syscalls.h:458
@ __SYS_SIGRT_30
Definition syscalls.h:545
@ __SYS_SIGSTOP
Definition syscalls.h:476
@ __SYS_SIGRT_25
Definition syscalls.h:540
@ __SYS_SIGRT_12
Definition syscalls.h:527
@ __SYS_SIGHUP
Definition syscalls.h:462
@ __SYS_SIGRTMIN
Definition syscalls.h:515
@ __SYS_SIGPIPE
Definition syscalls.h:470
@ __SYS_SIGXCPU
Definition syscalls.h:502
@ __SYS_SIGRT_20
Definition syscalls.h:535
@ __SYS_SIGRT_10
Definition syscalls.h:525
@ __SYS_SIGRT_26
Definition syscalls.h:541
@ __SYS_SIGRT_31
Definition syscalls.h:546
@ __SYS_SIGRT_16
Definition syscalls.h:531
@ __SYS_SIGRT_14
Definition syscalls.h:529
@ __SYS_SIGRT_18
Definition syscalls.h:533
@ __SYS_SIGRT_8
Definition syscalls.h:523
@ __SYS_SIGRT_2
Definition syscalls.h:517
@ __SYS_SIGSYS
Definition syscalls.h:494
@ __SYS_SIGRT_21
Definition syscalls.h:536
@ __SYS_SIGRT_22
Definition syscalls.h:537
@ __SYS_SIGCHLD
Definition syscalls.h:456
@ __SYS_SIGRT_19
Definition syscalls.h:534
@ __SYS_SIGRT_27
Definition syscalls.h:542
@ __SYS_SIGPROF
Definition syscalls.h:492
@ __SYS_SIGILL
Definition syscalls.h:464
@ __SYS_SIGUSR2
Definition syscalls.h:488
@ __SYS_SIGRT_6
Definition syscalls.h:521

◆ syscalls_t

enum syscalls_t

List of syscalls.

This list contains all the syscalls of the Fennix Kernel API.

Enumerator
SYS_API_VERSION 

Set syscall version.

int api_version(int version);

This syscall is used to set the version of the list. To prevent applications from breaking on major changes, this should be called at the very beginning of the program.

Parameters
versionThe version of the syscall list of which the program was compiled with
Returns
  • EOK on success
  • EINVAL if the requested version is invalid
Note
If this syscall is not used, the latest version will be used.
SYS_DEBUG_REPORT 
SYS_READ 

Read from a file descriptor.

ssize_t sys_read(int fildes, void *buf, size_t nbyte);

Reads up to count bytes from the file descriptor fd into the buffer starting at buf.

Parameters
fdFile descriptor to read from
bufBuffer where data will be stored
countMaximum number of bytes to read
Returns
  • Number of bytes read on success
  • 0 if the end of file is reached
  • EFAULT if the buffer is outside accessible address space
  • EBADF if fd is not a valid file descriptor
SYS_PREAD 

Read from a file descriptor.

ssize_t sys_pread(int fildes, void *buf, size_t nbyte, off_t offset);

Reads up to count bytes from the file descriptor fd into the buffer starting at buf.

Parameters
fdFile descriptor to read from
bufBuffer where data will be stored
countMaximum number of bytes to read
offsetOffset in the file
Returns
  • Number of bytes read on success
  • 0 if the end of file is reached
  • EFAULT if the buffer is outside accessible address space
  • EBADF if fd is not a valid file descriptor
SYS_WRITE 

Write to a file descriptor.

ssize_t sys_write(int fildes, const void *buf, size_t nbyte);

Writes up to count bytes from the buffer starting at buf to the file descriptor fd.

Parameters
fdFile descriptor to write to
bufBuffer containing data to write
countNumber of bytes to write
Returns
  • Number of bytes written on success
  • EFAULT if the buffer is outside accessible address space
  • EBADF if fd is not a valid file descriptor
  • EPIPE if writing to a pipe with no reader
SYS_PWRITE 

Write to a file descriptor.

ssize_t sys_pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);

Writes up to count bytes from the buffer starting at buf to the file descriptor fd.

Parameters
fdFile descriptor to write to
bufBuffer containing data to write
countNumber of bytes to write
offsetOffset in the file
Returns
  • Number of bytes written on success
  • EFAULT if the buffer is outside accessible address space
  • EBADF if fd is not a valid file descriptor
SYS_OPEN 

Open a file.

int open(const char *pathname, int flags, mode_t mode);

Opens the file specified by pathname.

Parameters
pathnamePath to the file
flagsFlags for file access mode
Supported values:
modePermissions for newly created file (if applicable)
Returns
  • File descriptor on success
  • ENOENT if the file does not exist
  • EACCES if permissions are insufficient
See also
syscall_open_flags_t
SYS_CLOSE 

Close a file descriptor.

int close(int fd);

Closes the file descriptor fd, releasing its resources.

Parameters
fdFile descriptor to close
Returns
  • EOK on success
  • EBADF if fd is not a valid file descriptor
SYS_IOCTL 

Control a device.

int ioctl(int fd, unsigned long request, void *argp);

Manipulates the underlying parameters of a device.

Parameters
fdFile descriptor referring to the device
requestDevice-specific request code
argpArgument for the request
Returns
  • EOK on success
  • EBADF if fd is not valid
  • EINVAL if the request is invalid
SYS_FCNTL 

Function control.

int fcntl(int fd, int cmd, void *arg);

Manipulates the underlying parameters of a device.

Parameters
fdFile descriptor referring to the device
cmdDevice-specific request code
argArgument for the request
Returns
  • EOK on success
  • EBADF if fd is not valid
  • EINVAL if the request is invalid
SYS_STAT 

Retrieve file status.

int stat(const char *pathname, struct stat *statbuf);

Gets the status of the file specified by pathname.

Parameters
pathnamePath to the file
statbufBuffer to store file status
Returns
  • EOK on success
  • ENOENT if the file does not exist
  • EACCES if permissions are insufficient
SYS_FSTAT 

Retrieve file status for an open file descriptor.

int fstat(int fd, struct stat *statbuf);

Gets the status of the file referred to by fd.

Parameters
fdFile descriptor
statbufBuffer to store file status
Returns
  • EOK on success
  • EBADF if fd is not a valid file descriptor
  • EFAULT if statbuf is outside accessible address space
SYS_LSTAT 

Retrieve file status with symbolic link resolution.

int lstat(const char *pathname, struct stat *statbuf);

Gets the status of the file specified by pathname, but does not follow symbolic links.

Parameters
pathnamePath to the file
statbufBuffer to store file status
Returns
  • EOK on success
  • ENOENT if the file does not exist
  • EACCES if permissions are insufficient
SYS_ACCESS 

Check a file's accessibility.

int access(const char *pathname, int mode);

Checks if the calling process can access the file specified by pathname according to the specified mode.

Parameters
pathnamePath to the file
modeAccessibility check mode
Supported values:
Returns
  • EOK on success
  • EACCES if access is denied
  • ENOENT if the file does not exist
See also
syscall_access_flags_t
SYS_TRUNCATE 

Change the size of a file.

int truncate(const char *pathname, off_t length);

Sets the size of the file specified by pathname to length. If the file is shorter, it is extended and the extended part is zero-filled.

Parameters
pathnamePath to the file
lengthDesired file length
Returns
  • EOK on success
  • EINVAL if length is invalid
  • EACCES if permissions are insufficient
SYS_FTRUNCATE 

Change the size of a file referred by a file descriptor.

int ftruncate(int fd, off_t length);

Sets the size of the file referred to by fd to length.

Parameters
fdFile descriptor
lengthDesired file length
Returns
SYS_TELL 

Get the current file offset.

off_t tell(int fd);

Returns the current file offset for the file referred to by fd.

Parameters
fdFile descriptor
Returns
  • Current file offset on success
  • EBADF if fd is not a valid file descriptor
SYS_SEEK 

Set the file offset.

off_t seek(int fd, off_t offset, int whence);

Sets the file offset for the file referred to by fd to the specified offset according to the directive whence.

Parameters
fdFile descriptor
offsetOffset to set
whenceDirective for setting the offset
Supported values:
Returns
  • New file offset on success
  • EBADF if fd is not a valid file descriptor
  • EINVAL if whence is invalid
SYS_EXIT 

Terminate the calling process.

void exit(int status);

Terminates the calling process with the specified status. The status code is made available to the parent process.

Parameters
statusExit status code
Returns
This function does not return.
SYS_FORK 

Create a child process.

pid_t fork(void);

Creates a new process by duplicating the calling process. The child process has its own copy of the parent's address space.

Returns
  • 0 to the child process
  • PID of the child to the parent process
  • ENOMEM if memory is insufficient
SYS_EXECVE 

Execute a program.

int execve(const char *pathname, char *const argv[], char *const envp[]);

Replaces the current process image with a new process image specified by pathname.

Parameters
pathnamePath to the executable file
argvArgument vector
envpEnvironment variables
Returns
  • Does not return on success
  • ENOENT if the file does not exist
  • EACCES if permissions are insufficient
SYS_GETPID 

Get the process ID of the calling process.

pid_t getpid(void);

Returns the process ID of the calling process.

Returns
  • Process ID on success
SYS_GETPPID 

Get the parent process ID.

pid_t getppid(void);

Returns the parent process ID of the calling process.

Returns
  • Parent process ID on success
SYS_WAITPID 

Wait for a child process to change state.

pid_t waitpid(pid_t pid, int *wstatus, int options);

Waits for the child process specified by pid to change state.

Parameters
pidProcess ID to wait for
wstatusPointer to store the status information
optionsOptions for waiting behavior
Returns
  • Process ID of the child on success
  • ECHILD if no child processes exist
SYS_KILL 

Send a signal to a process.

int kill(pid_t pid, int sig);

Sends the signal sig to the process specified by pid.

Parameters
pidProcess ID
sigSignal to send
Returns
  • EOK on success
  • ESRCH if the process does not exist
  • EINVAL if sig is invalid
SYS_PRCTL 

Process/Thread Control.

int prctl(syscall_prctl_options_t option, unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4);

Perform various operations on a process or thread.

Parameters
optionOperation to perform
arg1Argument 1
arg2Argument 2
arg3Argument 3
arg4Argument 4
Returns
  • EOK on success
  • EINVAL if the operation is invalid
  • EFAULT if one of the arguments is invalid
SYS_BRK 

Set the program break.

int brk(void *end_data);

Increases or decreases the program’s data space, ending at end_data.

Parameters
end_dataNew program break location
Returns
  • EOK on success
  • ENOMEM if memory allocation fails
SYS_MMAP 

Map files or devices into memory.

void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);

Maps a file or device into memory. This can be used for memory-mapped I/O or for sharing memory between processes.

Parameters
addrDesired starting address of the mapping (NULL for automatic allocation)
lengthLength of the mapping
protDesired memory protection
Supported values:
flagsMapping options
Supported values:
fdFile descriptor for the file to map
offsetOffset in the file to start the mapping
Returns
There are several possible return values:
See also
syscall_mmap_flags_t
SYS_MUNMAP 

Unmap a mapped memory region.

int munmap(void *addr, size_t length);

Unmaps a previously mapped memory region, making the memory available for reuse.

Parameters
addrStart address of the memory region
lengthLength of the memory region to unmap
Returns
  • EOK on success
  • EINVAL if the address or length is invalid
  • EFAULT if the memory region is not currently mapped
SYS_MPROTECT 

Change memory protection.

int mprotect(void *addr, size_t length, int prot);

Sets the protection on the memory region starting at addr for length.

Parameters
addrStart address of the memory region
lengthLength of the memory region
protDesired memory protection (e.g., PROT_READ, PROT_WRITE)
Returns
  • EOK on success
  • EACCES if protection cannot be set
SYS_MADVISE 

Provide advice about memory usage.

int madvise(void *addr, size_t length, int advice);

Provides advice to the kernel about the expected behavior of the memory region starting at addr for length, such as whether it will be accessed randomly or sequentially.

Parameters
addrStart address of the memory region
lengthLength of the memory region
adviceDesired advice (e.g., MADV_DONTNEED, MADV_SEQUENTIAL)
Returns
  • EOK on success
  • EINVAL if the parameters are invalid
SYS_PIPE 

Create a pipe.

int pipe(int pipefd[2]);

Creates a pipe, returning two file descriptors in pipefd. One is for reading, and the other is for writing.

Parameters
pipefdArray to store the two file descriptors
Returns
  • EOK on success
  • EMFILE if the process has too many open file descriptors
SYS_DUP 

Duplicate a file descriptor.

int dup(int oldfd);

Duplicates the file descriptor oldfd, returning the new file descriptor.

Parameters
oldfdFile descriptor to duplicate
Returns
  • New file descriptor on success
  • EBADF if oldfd is invalid
SYS_DUP2 

Duplicate a file descriptor to a specific value.

int dup2(int oldfd, int newfd);

Duplicates oldfd to newfd. If newfd is already open, it will be closed first.

Parameters
oldfdFile descriptor to duplicate
newfdFile descriptor to duplicate oldfd to
Returns
  • newfd on success
  • EBADF if oldfd is invalid
  • EINVAL if newfd is invalid
SYS_SOCKET 

Create an endpoint for communication.

int socket(int domain, int type, int protocol);

Creates an endpoint for communication, returning a socket file descriptor.

Parameters
domainCommunication domain (e.g., AF_INET for IPv4)
typeType of socket (e.g., SOCK_STREAM for TCP)
protocolProtocol to use (e.g., IPPROTO_TCP)
Returns
  • Socket file descriptor on success
  • EINVAL if parameters are invalid
SYS_BIND 

Bind a socket to a local address.

int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);

Binds a socket to a local address so it can listen for incoming connections.

Parameters
sockfdSocket file descriptor
addrAddress to bind to
addrlenLength of the address
Returns
  • EOK on success
  • EINVAL if the socket is invalid
SYS_CONNECT 

Connect to a remote address.

int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);

Connects a socket to a remote address.

Parameters
sockfdSocket file descriptor
addrRemote address to connect to
addrlenLength of the address
Returns
  • EOK on success
  • EINVAL if parameters are invalid
SYS_LISTEN 

Listen for incoming connections on a socket.

int listen(int sockfd, int backlog);

Sets a socket to listen for incoming connections, specifying the backlog queue size.

Parameters
sockfdSocket file descriptor
backlogNumber of pending connections to allow
Returns
  • EOK on success
  • EINVAL if parameters are invalid
SYS_ACCEPT 

Accept an incoming connection on a socket.

int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);

Accepts an incoming connection on a listening socket, creating a new socket for communication.

Parameters
sockfdSocket file descriptor
addrClient address
addrlenLength of the address
Returns
  • New socket file descriptor on success
  • EINVAL if parameters are invalid
SYS_SEND 

Send data on a socket.

ssize_t send(int sockfd, const void *buf, size_t len, int flags);

Sends data through a socket.

Parameters
sockfdSocket file descriptor
bufData to send
lenLength of the data
flagsFlags for the send operation
Returns
  • Number of bytes sent on success
  • EINVAL if parameters are invalid
SYS_RECV 

Receive data on a socket.

ssize_t recv(int sockfd, void *buf, size_t len, int flags);

Receives data from a socket.

Parameters
sockfdSocket file descriptor
bufBuffer to store received data
lenMaximum number of bytes to receive
flagsFlags for the receive operation
Returns
  • Number of bytes received on success
  • EINVAL if parameters are invalid
SYS_SHUTDOWN 

Shut down part of a full-duplex connection.

int shutdown(int sockfd, int how);

Shuts down part of a full-duplex connection on a socket.

Parameters
sockfdSocket file descriptor
howDetermines which operations to shut down (e.g., SHUT_RD, SHUT_WR)
Returns
  • EOK on success
  • EINVAL if parameters are invalid
SYS_TIME 

Get the current time.

time_t time(time_t *t);

Retrieves the current calendar time as the number of seconds since the epoch.

Parameters
tPointer to store the time (optional)
Returns
  • Current time in seconds on success
  • __SYS_NULL if t is NULL
SYS_CLOCK_GETTIME 

Get the current time of a specific clock.

int clock_gettime(clockid_t clockid, struct timespec *tp);

Retrieves the current time for the specified clock (CLOCK_REALTIME, CLOCK_MONOTONIC, etc.).

Parameters
clockidClock ID to query
tpPointer to store the time
Returns
  • EOK on success
  • EINVAL if parameters are invalid
SYS_CLOCK_SETTIME 

Set the current time of a specific clock.

int clock_settime(clockid_t clockid, const struct timespec *tp);

Sets the time for the specified clock (CLOCK_REALTIME, CLOCK_MONOTONIC, etc.).

Parameters
clockidClock ID to set
tpPointer to the time value
Returns
  • EOK on success
  • EINVAL if parameters are invalid
SYS_NANOSLEEP 

Sleep for a specified time.

int nanosleep(const struct timespec *req, struct timespec *rem);

Suspends the execution of the calling thread for the specified time duration.

Parameters
reqPointer to timespec specifying the time to sleep
remPointer to store remaining time if interrupted
Returns
  • EOK on success
  • EINTR if interrupted by a signal
SYS_GETCWD 

Get the current working directory.

char *getcwd(char *buf, size_t size);

Retrieves the current working directory.

Parameters
bufBuffer to store the directory path
sizeSize of the buffer
Returns
SYS_CHDIR 

Change the current working directory.

int chdir(const char *path);

Changes the current working directory to the specified path.

Parameters
pathNew directory path
Returns
  • EOK on success
  • ENOENT if the directory does not exist
  • EACCES if permission is denied
SYS_MKDIR 

Create a new directory.

int mkdir(const char *path, mode_t mode);

Creates a new directory at path with the specified permissions.

Parameters
pathPath to the new directory
modeDirectory permissions
Returns
  • EOK on success
  • EEXIST if the directory already exists
  • EACCES if permission is denied
SYS_RMDIR 

Remove an empty directory.

int rmdir(const char *path);

Removes the empty directory specified by path.

Parameters
pathPath to the directory
Returns
SYS_UNLINK 

Remove a file.

int unlink(const char *pathname);

Removes the file specified by pathname.

Parameters
pathnamePath to the file
Returns
  • EOK on success
  • ENOENT if the file does not exist
  • EACCES if permission is denied
SYS_RENAME 

Rename a file or directory.

int rename(const char *oldpath, const char *newpath);

Renames a file or directory from oldpath to newpath.

Parameters
oldpathCurrent name of the file or directory
newpathNew name of the file or directory
Returns
  • EOK on success
  • EEXIST if the target exists
  • EACCES if permission is denied
SYS_UNAME 

Get unix name information.

int uname(struct kutsname *buf);

Retrieves information about the operating system.

Parameters
bufPointer to kutsname structure to store information
Returns
  • EOK on success
  • EFAULT if buf is outside accessible address space
SYS_MAX 

Max number of syscalls.

This is used to determine the size of the syscalls_t array.

syscalls_t syscalls[SYS_MAX];
Note
This must be the last element in the list

Definition at line 651 of file syscalls.h.

652{
653 /* Initialization */
654
675 SYS_API_VERSION = 0,
676
678
679 /* I/O */
680
701 SYS_READ = 100,
723 SYS_PREAD,
744 SYS_WRITE,
799 SYS_OPEN,
815 SYS_CLOSE,
834 SYS_IOCTL,
853 SYS_FCNTL,
854
855 /* File Status */
856
874 SYS_STAT = 200,
892 SYS_FSTAT,
911 SYS_LSTAT,
990 SYS_TELL,
1014 SYS_SEEK,
1015
1016 /* Process Control */
1017
1032 SYS_EXIT = 300,
1048 SYS_FORK,
1068 SYS_EXECVE,
1081 SYS_GETPID,
1130 SYS_KILL,
1151 SYS_PRCTL,
1152
1153 /* Memory */
1154
1170 SYS_BRK = 400,
1213 SYS_MMAP,
1231 SYS_MUNMAP,
1269
1270 /* Communication */
1271
1288 SYS_PIPE = 500,
1304 SYS_DUP,
1322 SYS_DUP2,
1340 SYS_SOCKET,
1358 SYS_BIND,
1393 SYS_LISTEN,
1411 SYS_ACCEPT,
1430 SYS_SEND,
1449 SYS_RECV,
1467
1468 /* Time */
1469
1485 SYS_TIME = 600,
1537
1538 /* Miscellaneous */
1539
1556 SYS_GETCWD = 700,
1573 SYS_CHDIR,
1591 SYS_MKDIR,
1607 SYS_RMDIR,
1624 SYS_UNLINK,
1642 SYS_RENAME,
1658 SYS_UNAME,
1659
1671 SYS_MAX
1672} syscalls_t;
syscalls_t
List of syscalls.
Definition syscalls.h:652
@ SYS_UNLINK
Remove a file.
Definition syscalls.h:1624
@ SYS_UNAME
Get unix name information.
Definition syscalls.h:1658
@ SYS_MMAP
Map files or devices into memory.
Definition syscalls.h:1213
@ SYS_SHUTDOWN
Shut down part of a full-duplex connection.
Definition syscalls.h:1466
@ SYS_RECV
Receive data on a socket.
Definition syscalls.h:1449
@ SYS_MAX
Max number of syscalls.
Definition syscalls.h:1671
@ SYS_STAT
Retrieve file status.
Definition syscalls.h:874
@ SYS_WRITE
Write to a file descriptor.
Definition syscalls.h:744
@ SYS_NANOSLEEP
Sleep for a specified time.
Definition syscalls.h:1536
@ SYS_TELL
Get the current file offset.
Definition syscalls.h:990
@ SYS_TRUNCATE
Change the size of a file.
Definition syscalls.h:956
@ SYS_PIPE
Create a pipe.
Definition syscalls.h:1288
@ SYS_RMDIR
Remove an empty directory.
Definition syscalls.h:1607
@ SYS_READ
Read from a file descriptor.
Definition syscalls.h:701
@ SYS_GETPPID
Get the parent process ID.
Definition syscalls.h:1094
@ SYS_CLOSE
Close a file descriptor.
Definition syscalls.h:815
@ SYS_MADVISE
Provide advice about memory usage.
Definition syscalls.h:1268
@ SYS_EXECVE
Execute a program.
Definition syscalls.h:1068
@ SYS_LISTEN
Listen for incoming connections on a socket.
Definition syscalls.h:1393
@ SYS_WAITPID
Wait for a child process to change state.
Definition syscalls.h:1112
@ SYS_BRK
Set the program break.
Definition syscalls.h:1170
@ SYS_MUNMAP
Unmap a mapped memory region.
Definition syscalls.h:1231
@ SYS_EXIT
Terminate the calling process.
Definition syscalls.h:1032
@ SYS_OPEN
Open a file.
Definition syscalls.h:799
@ SYS_CONNECT
Connect to a remote address.
Definition syscalls.h:1376
@ SYS_IOCTL
Control a device.
Definition syscalls.h:834
@ SYS_PREAD
Read from a file descriptor.
Definition syscalls.h:723
@ SYS_RENAME
Rename a file or directory.
Definition syscalls.h:1642
@ SYS_GETPID
Get the process ID of the calling process.
Definition syscalls.h:1081
@ SYS_FSTAT
Retrieve file status for an open file descriptor.
Definition syscalls.h:892
@ SYS_PWRITE
Write to a file descriptor.
Definition syscalls.h:765
@ SYS_BIND
Bind a socket to a local address.
Definition syscalls.h:1358
@ SYS_TIME
Get the current time.
Definition syscalls.h:1485
@ SYS_FCNTL
Function control.
Definition syscalls.h:853
@ SYS_DUP
Duplicate a file descriptor.
Definition syscalls.h:1304
@ SYS_SOCKET
Create an endpoint for communication.
Definition syscalls.h:1340
@ SYS_CLOCK_SETTIME
Set the current time of a specific clock.
Definition syscalls.h:1519
@ SYS_API_VERSION
Set syscall version.
Definition syscalls.h:675
@ SYS_FORK
Create a child process.
Definition syscalls.h:1048
@ SYS_SEND
Send data on a socket.
Definition syscalls.h:1430
@ SYS_PRCTL
Process/Thread Control.
Definition syscalls.h:1151
@ SYS_LSTAT
Retrieve file status with symbolic link resolution.
Definition syscalls.h:911
@ SYS_DUP2
Duplicate a file descriptor to a specific value.
Definition syscalls.h:1322
@ SYS_KILL
Send a signal to a process.
Definition syscalls.h:1130
@ SYS_MPROTECT
Change memory protection.
Definition syscalls.h:1249
@ SYS_MKDIR
Create a new directory.
Definition syscalls.h:1591
@ SYS_CHDIR
Change the current working directory.
Definition syscalls.h:1573
@ SYS_DEBUG_REPORT
Definition syscalls.h:677
@ SYS_ACCEPT
Accept an incoming connection on a socket.
Definition syscalls.h:1411
@ SYS_FTRUNCATE
Change the size of a file referred by a file descriptor.
Definition syscalls.h:974
@ SYS_SEEK
Set the file offset.
Definition syscalls.h:1014
@ SYS_GETCWD
Get the current working directory.
Definition syscalls.h:1556
@ SYS_CLOCK_GETTIME
Get the current time of a specific clock.
Definition syscalls.h:1502
@ SYS_ACCESS
Check a file's accessibility.
Definition syscalls.h:937

Function Documentation

◆ syscall0()

static scarg syscall0 ( scarg  syscall)
inlinestatic

Syscall wrapper with 0 arguments.

This wrapper is used to call syscalls with 0 arguments

Parameters
syscallsyscalls_t
Returns
The return value of the syscall

Definition at line 64 of file syscalls.h.

65{
66 scarg ret;
67#if defined(__amd64__)
68 __asm__ __volatile__("syscall"
69 : "=a"(ret)
70 : "a"(syscall)
71 : "rcx", "r11", "memory");
72#elif defined(__i386__)
73 __asm__ __volatile__("int $0x30"
74 : "=a"(ret)
75 : "a"(syscall)
76 : "memory");
77#elif defined(__arm__)
78 register scarg r7 __thumb_r7 = syscall;
79 register scarg r0 __asm__("r0");
80 __arm_call(__r7_operand);
81#elif defined(__aarch64__)
82 register scarg x8 __asm__("x8") = syscall;
83 register scarg x0 __asm__("x0");
84 __asm__ __volatile__("svc 0"
85 : "=r"(x0)
86 : "r"(x8)
87 : "memory", "cc");
88#else
89#error "Unsupported architecture"
90#endif
91 return ret;
92}
#define scarg
Definition syscalls.h:33

References scarg.

◆ syscall1()

static scarg syscall1 ( scarg  syscall,
scarg  arg1 
)
inlinestatic

Syscall wrapper with 1 argument.

This wrapper is used to call syscalls with 1 argument

Parameters
syscallsyscalls_t
arg1Argument 1
Returns
The return value of the syscall

Definition at line 103 of file syscalls.h.

104{
105 scarg ret;
106#if defined(__amd64__)
107 __asm__ __volatile__("syscall"
108 : "=a"(ret)
109 : "a"(syscall), "D"(arg1)
110 : "rcx", "r11", "memory");
111#elif defined(__i386__)
112 __asm__ __volatile__("int $0x30"
113 : "=a"(ret)
114 : "a"(syscall), "b"(arg1)
115 : "memory");
116#elif defined(__arm__)
117 register scarg r7 __thumb_r7 = syscall;
118 register scarg r0 __asm__("r0") = arg1;
119 __arm_call(__r7_operand, "0"(r0));
120#elif defined(__aarch64__)
121 register scarg x8 __asm__("x8") = syscall;
122 register scarg x0 __asm__("x0") = arg1;
123 __asm__ __volatile__("svc 0"
124 : "=r"(ret)
125 : "r"(x8), "0"(x0)
126 : "memory", "cc");
127#else
128#error "Unsupported architecture"
129#endif
130 return ret;
131}

References scarg.

◆ syscall2()

static scarg syscall2 ( scarg  syscall,
scarg  arg1,
scarg  arg2 
)
inlinestatic

Syscall wrapper with 2 arguments.

This wrapper is used to call syscalls with 2 arguments

Parameters
syscallsyscalls_t
arg1Argument 1
arg2Argument 2
Returns
The return value of the syscall

Definition at line 143 of file syscalls.h.

144{
145 scarg ret;
146#if defined(__amd64__)
147 __asm__ __volatile__("syscall"
148 : "=a"(ret)
149 : "a"(syscall), "D"(arg1), "S"(arg2)
150 : "rcx", "r11", "memory");
151#elif defined(__i386__)
152 __asm__ __volatile__("int $0x30"
153 : "=a"(ret)
154 : "a"(syscall), "b"(arg1), "c"(arg2)
155 : "memory");
156#elif defined(__arm__)
157 register scarg r7 __thumb_r7 = syscall;
158 register scarg r0 __asm__("r0") = arg1;
159 register scarg r1 __asm__("r1") = arg2;
160 __arm_call(__r7_operand, "0"(r0), "r"(r1));
161#elif defined(__aarch64__)
162 register scarg x8 __asm__("x8") = syscall;
163 register scarg x0 __asm__("x0") = arg1;
164 register scarg x1 __asm__("x1") = arg2;
165 __asm__ __volatile__("svc 0"
166 : "=r"(ret)
167 : "r"(x8), "0"(x0), "r"(x1)
168 : "memory", "cc");
169#else
170#error "Unsupported architecture"
171#endif
172 return ret;
173}

References scarg.

◆ syscall3()

static scarg syscall3 ( scarg  syscall,
scarg  arg1,
scarg  arg2,
scarg  arg3 
)
inlinestatic

Syscall wrapper with 3 arguments.

This wrapper is used to call syscalls with 3 arguments

Parameters
syscallsyscalls_t
arg1Argument 1
arg2Argument 2
arg3Argument 3
Returns
The return value of the syscall

Definition at line 186 of file syscalls.h.

187{
188 scarg ret;
189#if defined(__amd64__)
190 __asm__ __volatile__("syscall"
191 : "=a"(ret)
192 : "a"(syscall), "D"(arg1), "S"(arg2), "d"(arg3)
193 : "rcx", "r11", "memory");
194#elif defined(__i386__)
195 __asm__ __volatile__("int $0x30"
196 : "=a"(ret)
197 : "a"(syscall), "b"(arg1), "c"(arg2), "d"(arg3)
198 : "memory");
199#elif defined(__arm__)
200 register scarg r7 __thumb_r7 = syscall;
201 register scarg r0 __asm__("r0") = arg1;
202 register scarg r1 __asm__("r1") = arg2;
203 register scarg r2 __asm__("r2") = arg3;
204 __arm_call(__r7_operand, "0"(r0), "r"(r1), "r"(r2));
205#elif defined(__aarch64__)
206 register scarg x8 __asm__("x8") = syscall;
207 register scarg x0 __asm__("x0") = arg1;
208 register scarg x1 __asm__("x1") = arg2;
209 register scarg x2 __asm__("x2") = arg3;
210 __asm__ __volatile__("svc 0"
211 : "=r"(ret)
212 : "r"(x8), "0"(x0), "r"(x1), "r"(x2)
213 : "memory", "cc");
214#else
215#error "Unsupported architecture"
216#endif
217 return ret;
218}

References scarg.

◆ syscall4()

static scarg syscall4 ( scarg  syscall,
scarg  arg1,
scarg  arg2,
scarg  arg3,
scarg  arg4 
)
inlinestatic

Syscall wrapper with 4 arguments.

This wrapper is used to call syscalls with 4 arguments

Parameters
syscallsyscalls_t
arg1Argument 1
arg2Argument 2
arg3Argument 3
arg4Argument 4
Returns
The return value of the syscall

Definition at line 232 of file syscalls.h.

233{
234 scarg ret;
235#if defined(__amd64__)
236 register scarg r10 __asm__("r10") = arg4;
237 __asm__ __volatile__("syscall"
238 : "=a"(ret)
239 : "a"(syscall), "D"(arg1), "S"(arg2), "d"(arg3), "r"(r10)
240 : "rcx", "r11", "memory");
241#elif defined(__i386__)
242 __asm__ __volatile__("int $0x30"
243 : "=a"(ret)
244 : "a"(syscall), "b"(arg1), "c"(arg2), "d"(arg3), "S"(arg4)
245 : "memory");
246#elif defined(__arm__)
247 register scarg r7 __thumb_r7 = syscall;
248 register scarg r0 __asm__("r0") = arg1;
249 register scarg r1 __asm__("r1") = arg2;
250 register scarg r2 __asm__("r2") = arg3;
251 register scarg r3 __asm__("r3") = arg4;
252 __arm_call(__r7_operand, "0"(r0), "r"(r1), "r"(r2), "r"(r3));
253#elif defined(__aarch64__)
254 register scarg x8 __asm__("x8") = syscall;
255 register scarg x0 __asm__("x0") = arg1;
256 register scarg x1 __asm__("x1") = arg2;
257 register scarg x2 __asm__("x2") = arg3;
258 register scarg x3 __asm__("x3") = arg4;
259 __asm__ __volatile__("svc 0"
260 : "=r"(ret)
261 : "r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3)
262 : "memory", "cc");
263#else
264#error "Unsupported architecture"
265#endif
266 return ret;
267}

References scarg.

◆ syscall5()

static scarg syscall5 ( scarg  syscall,
scarg  arg1,
scarg  arg2,
scarg  arg3,
scarg  arg4,
scarg  arg5 
)
inlinestatic

Syscall wrapper with 5 arguments.

This wrapper is used to call syscalls with 5 arguments

Parameters
syscallsyscalls_t
arg1Argument 1
arg2Argument 2
arg3Argument 3
arg4Argument 4
arg5Argument 5
Returns
The return value of the syscall

Definition at line 282 of file syscalls.h.

283{
284 scarg ret;
285#if defined(__amd64__)
286 register scarg r10 __asm__("r10") = arg4;
287 register scarg r8 __asm__("r8") = arg5;
288 __asm__ __volatile__("syscall"
289 : "=a"(ret)
290 : "a"(syscall), "D"(arg1), "S"(arg2), "d"(arg3), "r"(r10), "r"(r8)
291 : "rcx", "r11", "memory");
292#elif defined(__i386__)
293 __asm__ __volatile__("int $0x30"
294 : "=a"(ret)
295 : "a"(syscall), "b"(arg1), "c"(arg2), "d"(arg3), "S"(arg4), "D"(arg5)
296 : "memory");
297#elif defined(__arm__)
298 register scarg r7 __thumb_r7 = syscall;
299 register scarg r0 __asm__("r0") = arg1;
300 register scarg r1 __asm__("r1") = arg2;
301 register scarg r2 __asm__("r2") = arg3;
302 register scarg r3 __asm__("r3") = arg4;
303 register scarg r4 __asm__("r4") = arg5;
304 __arm_call(__r7_operand, "0"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4));
305#elif defined(__aarch64__)
306 register scarg x8 __asm__("x8") = syscall;
307 register scarg x0 __asm__("x0") = arg1;
308 register scarg x1 __asm__("x1") = arg2;
309 register scarg x2 __asm__("x2") = arg3;
310 register scarg x3 __asm__("x3") = arg4;
311 register scarg x4 __asm__("x4") = arg5;
312 __asm__ __volatile__("svc 0"
313 : "=r"(ret)
314 : "r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4)
315 : "memory", "cc");
316#else
317#error "Unsupported architecture"
318#endif
319 return ret;
320}

References scarg.

◆ syscall6()

static scarg syscall6 ( scarg  syscall,
scarg  arg1,
scarg  arg2,
scarg  arg3,
scarg  arg4,
scarg  arg5,
scarg  arg6 
)
inlinestatic

Syscall wrapper with 6 arguments.

This wrapper is used to call syscalls with 6 arguments

Parameters
syscallsyscalls_t
arg1Argument 1
arg2Argument 2
arg3Argument 3
arg4Argument 4
arg5Argument 5
arg6Argument 6
Returns
The return value of the syscall

Definition at line 336 of file syscalls.h.

337{
338 scarg ret;
339#if defined(__amd64__)
340 register scarg r10 __asm__("r10") = arg4;
341 register scarg r8 __asm__("r8") = arg5;
342 register scarg r9 __asm__("r9") = arg6;
343 __asm__ __volatile__("syscall"
344 : "=a"(ret)
345 : "a"(syscall), "D"(arg1), "S"(arg2), "d"(arg3), "r"(r10), "r"(r8), "r"(r9)
346 : "rcx", "r11", "memory");
347#elif defined(__i386__)
348 __asm__ __volatile__("int $0x30"
349 : "=a"(ret)
350 : "a"(syscall), "b"(arg1), "c"(arg2), "d"(arg3), "S"(arg4), "D"(arg5), "g"(arg6)
351 : "memory");
352#elif defined(__arm__)
353 register scarg r7 __thumb_r7 = syscall;
354 register scarg r0 __asm__("r0") = arg1;
355 register scarg r1 __asm__("r1") = arg2;
356 register scarg r2 __asm__("r2") = arg3;
357 register scarg r3 __asm__("r3") = arg4;
358 register scarg r4 __asm__("r4") = arg5;
359 register scarg r5 __asm__("r5") = arg6;
360 __arm_call(__r7_operand, "0"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4), "r"(r5));
361#elif defined(__aarch64__)
362 register scarg x8 __asm__("x8") = syscall;
363 register scarg x0 __asm__("x0") = arg1;
364 register scarg x1 __asm__("x1") = arg2;
365 register scarg x2 __asm__("x2") = arg3;
366 register scarg x3 __asm__("x3") = arg4;
367 register scarg x4 __asm__("x4") = arg5;
368 register scarg x5 __asm__("x5") = arg6;
369 __asm__ __volatile__("svc 0"
370 : "=r"(ret)
371 : "r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4), "r"(x5)
372 : "memory", "cc");
373#else
374#error "Unsupported architecture"
375#endif
376 return ret;
377}

References scarg.