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
 

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_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, 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.
 

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 = 0x1 , __SYS_O_WRONLY = 0x2 , __SYS_O_RDWR = 0x3 , __SYS_O_APPEND = 0x4 ,
  __SYS_O_CREAT = 0x8 , __SYS_O_DSYNC = 0x10 , __SYS_O_EXCL = 0x20 , __SYS_O_NOCTTY = 0x40 ,
  __SYS_O_NONBLOCK = 0x80 , __SYS_O_RSYNC = 0x100 , __SYS_O_SYNC = 0x200 , __SYS_O_TRUNC = 0x400
}
 
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_READ = 100 , SYS_PREAD , SYS_WRITE ,
  SYS_PWRITE , SYS_OPEN , SYS_CLOSE , SYS_IOCTL ,
  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_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 605 of file syscalls.h.

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

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 378 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 1740 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 1659 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 1622 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 1731 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 1702 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 1771 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 1757 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 1760 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 1642 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 1734 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 1722 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 1725 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 1682 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 1676 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 1679 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 1653 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 1665 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 1768 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 1685 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 1688 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 1645 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 1694 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 1737 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 1656 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 1714 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 1774 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 1705 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 1711 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 1708 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 1763 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 1639 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 1719 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:419

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 1697 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 1630 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 1636 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 1627 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 1746 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 1783 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 1777 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 1671 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 1743 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 1749 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 1728 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 1650 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 1668 of file syscalls.h.

◆ call_time

#define call_time (   t)    syscall1(SYS_TIME, 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 1754 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 1662 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 1780 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 1691 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 1633 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:625
Parameters
fdFile descriptor of the framebuffer device
infoPointer to the framebuffer screen info structure

Definition at line 625 of file syscalls.h.

◆ scarg

#define scarg   __UINTPTR_TYPE__

Definition at line 23 of file syscalls.h.

Typedef Documentation

◆ __SYS_clockid_t

typedef int __SYS_clockid_t

Definition at line 602 of file syscalls.h.

◆ __SYS_socklen_t

typedef unsigned int __SYS_socklen_t

Definition at line 603 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 410 of file syscalls.h.

411{
412 __SYS_F_OK = 0,
413 __SYS_R_OK = 1,
414 __SYS_W_OK = 2,
415 __SYS_X_OK = 3
syscall_access_flags_t
Definition syscalls.h:411
@ __SYS_X_OK
Definition syscalls.h:415
@ __SYS_R_OK
Definition syscalls.h:413
@ __SYS_F_OK
Definition syscalls.h:412
@ __SYS_W_OK
Definition syscalls.h:414

◆ syscall_clockid_t

Enumerator
__SYS_CLOCK_MONOTONIC 
__SYS_CLOCK_PROCESS_CPUTIME_ID 
__SYS_CLOCK_REALTIME 
__SYS_CLOCK_THREAD_CPUTIME_ID 

Definition at line 588 of file syscalls.h.

589{
syscall_clockid_t
Definition syscalls.h:589
@ __SYS_CLOCK_PROCESS_CPUTIME_ID
Definition syscalls.h:591
@ __SYS_CLOCK_REALTIME
Definition syscalls.h:592
@ __SYS_CLOCK_THREAD_CPUTIME_ID
Definition syscalls.h:593
@ __SYS_CLOCK_MONOTONIC
Definition syscalls.h:590

◆ 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 380 of file syscalls.h.

381{
382 __SYS_PROT_READ = 0x1,
383 __SYS_PROT_WRITE = 0x2,
384 __SYS_PROT_EXEC = 0x4,
385 __SYS_PROT_NONE = 0x0,
386
387 __SYS_MAP_SHARED = 0x1,
388 __SYS_MAP_PRIVATE = 0x2,
389 __SYS_MAP_FIXED = 0x4,
syscall_mmap_flags_t
Definition syscalls.h:381
@ __SYS_MAP_ANON
Definition syscalls.h:391
@ __SYS_PROT_NONE
Definition syscalls.h:385
@ __SYS_PROT_READ
Definition syscalls.h:382
@ __SYS_MAP_FIXED
Definition syscalls.h:389
@ __SYS_MAP_SHARED
Definition syscalls.h:387
@ __SYS_PROT_EXEC
Definition syscalls.h:384
@ __SYS_PROT_WRITE
Definition syscalls.h:383
@ __SYS_MAP_PRIVATE
Definition syscalls.h:388
@ __SYS_MAP_ANONYMOUS
Definition syscalls.h:390

◆ 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 394 of file syscalls.h.

395{
396 __SYS_O_RDONLY = 0x1,
397 __SYS_O_WRONLY = 0x2,
398 __SYS_O_RDWR = 0x3,
399 __SYS_O_APPEND = 0x4,
400 __SYS_O_CREAT = 0x8,
401 __SYS_O_DSYNC = 0x10,
402 __SYS_O_EXCL = 0x20,
403 __SYS_O_NOCTTY = 0x40,
404 __SYS_O_NONBLOCK = 0x80,
405 __SYS_O_RSYNC = 0x100,
406 __SYS_O_SYNC = 0x200,
407 __SYS_O_TRUNC = 0x400
syscall_open_flags_t
Definition syscalls.h:395
@ __SYS_O_RDWR
Definition syscalls.h:398
@ __SYS_O_DSYNC
Definition syscalls.h:401
@ __SYS_O_NONBLOCK
Definition syscalls.h:404
@ __SYS_O_RDONLY
Definition syscalls.h:396
@ __SYS_O_RSYNC
Definition syscalls.h:405
@ __SYS_O_WRONLY
Definition syscalls.h:397
@ __SYS_O_NOCTTY
Definition syscalls.h:403
@ __SYS_O_EXCL
Definition syscalls.h:402
@ __SYS_O_APPEND
Definition syscalls.h:399
@ __SYS_O_SYNC
Definition syscalls.h:406
@ __SYS_O_TRUNC
Definition syscalls.h:407
@ __SYS_O_CREAT
Definition syscalls.h:400

◆ syscall_prctl_options_t

Enumerator
__SYS_GET_GS 
__SYS_SET_GS 
__SYS_GET_FS 
__SYS_SET_FS 

Definition at line 418 of file syscalls.h.

419{
420 __SYS_GET_GS = 0,
421 __SYS_SET_GS = 1,
422 __SYS_GET_FS = 2,
423 __SYS_SET_FS = 3,
@ __SYS_GET_FS
Definition syscalls.h:422
@ __SYS_SET_GS
Definition syscalls.h:421
@ __SYS_GET_GS
Definition syscalls.h:420
@ __SYS_SET_FS
Definition syscalls.h:423

◆ syscall_seek_whence_t

Enumerator
__SYS_SEEK_SET 
__SYS_SEEK_CUR 
__SYS_SEEK_END 

Definition at line 429 of file syscalls.h.

430{
431 __SYS_SEEK_SET = 0,
432 __SYS_SEEK_CUR = 1,
syscall_seek_whence_t
Definition syscalls.h:430
@ __SYS_SEEK_CUR
Definition syscalls.h:432
@ __SYS_SEEK_SET
Definition syscalls.h:431
@ __SYS_SEEK_END
Definition syscalls.h:433

◆ syscall_signal_action_disposition_t

Enumerator
__SYS_SIG_ERR 
__SYS_SIG_DFL 
___SYS_SIG_IGN 

Definition at line 581 of file syscalls.h.

582{
583 __SYS_SIG_ERR = -1,
584 __SYS_SIG_DFL = 0,
syscall_signal_action_disposition_t
Definition syscalls.h:582
@ __SYS_SIG_ERR
Definition syscalls.h:583
@ ___SYS_SIG_IGN
Definition syscalls.h:585
@ __SYS_SIG_DFL
Definition syscalls.h:584

◆ 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 570 of file syscalls.h.

571{
573 __SYS_SA_ONSTACK = 0x08000000,
574 __SYS_SA_RESETHAND = 0x80000000,
575 __SYS_SA_RESTART = 0x10000000,
578 __SYS_SA_NODEFER = 0x40000000,
syscall_signal_action_flags_t
Definition syscalls.h:571
@ __SYS_SA_SIGINFO
Definition syscalls.h:576
@ __SYS_SA_RESTART
Definition syscalls.h:575
@ __SYS_SA_RESETHAND
Definition syscalls.h:574
@ __SYS_SA_ONSTACK
Definition syscalls.h:573
@ __SYS_SA_NODEFER
Definition syscalls.h:578
@ __SYS_SA_NOCLDSTOP
Definition syscalls.h:572
@ __SYS_SA_NOCLDWAIT
Definition syscalls.h:577

◆ syscall_signal_actions_t

Enumerator
__SYS_SIG_BLOCK 
__SYS_SIG_UNBLOCK 
__SYS_SIG_SETMASK 

Definition at line 563 of file syscalls.h.

564{
565 __SYS_SIG_BLOCK = 0,
syscall_signal_actions_t
Definition syscalls.h:564
@ __SYS_SIG_UNBLOCK
Definition syscalls.h:566
@ __SYS_SIG_SETMASK
Definition syscalls.h:567
@ __SYS_SIG_BLOCK
Definition syscalls.h:565

◆ 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 546 of file syscalls.h.

547{
549 __SYS_SIG_TERM = 0,
551 __SYS_SIG_IGN = 1,
553 __SYS_SIG_CONT = 2,
555 __SYS_SIG_STOP = 3,
syscall_signal_disposition_t
Definition syscalls.h:547
@ __SYS_SIG_TERM
Definition syscalls.h:549
@ __SYS_SIG_STOP
Definition syscalls.h:555
@ __SYS_SIG_CORE
Definition syscalls.h:557
@ __SYS_SIG_CONT
Definition syscalls.h:553
@ __SYS_SIG_IGN
Definition syscalls.h:551

◆ 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 436 of file syscalls.h.

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

◆ 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_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_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_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 633 of file syscalls.h.

634{
635 /* Initialization */
636
657 SYS_API_VERSION = 0,
658
659 /* I/O */
660
681 SYS_READ = 100,
703 SYS_PREAD,
724 SYS_WRITE,
779 SYS_OPEN,
795 SYS_CLOSE,
814 SYS_IOCTL,
815
816 /* File Status */
817
835 SYS_STAT = 200,
853 SYS_FSTAT,
872 SYS_LSTAT,
951 SYS_TELL,
975 SYS_SEEK,
976
977 /* Process Control */
978
993 SYS_EXIT = 300,
1009 SYS_FORK,
1029 SYS_EXECVE,
1042 SYS_GETPID,
1091 SYS_KILL,
1112 SYS_PRCTL,
1113
1114 /* Memory */
1115
1131 SYS_BRK = 400,
1174 SYS_MMAP,
1192 SYS_MUNMAP,
1230
1231 /* Communication */
1232
1249 SYS_PIPE = 500,
1265 SYS_DUP,
1283 SYS_DUP2,
1301 SYS_SOCKET,
1319 SYS_BIND,
1354 SYS_LISTEN,
1372 SYS_ACCEPT,
1391 SYS_SEND,
1410 SYS_RECV,
1428
1429 /* Time */
1430
1446 SYS_TIME = 600,
1498
1499 /* Miscellaneous */
1500
1517 SYS_GETCWD = 700,
1534 SYS_CHDIR,
1552 SYS_MKDIR,
1568 SYS_RMDIR,
1585 SYS_UNLINK,
1603 SYS_RENAME,
1604
1616 SYS_MAX
1617} syscalls_t;
syscalls_t
List of syscalls.
Definition syscalls.h:634
@ SYS_UNLINK
Remove a file.
Definition syscalls.h:1585
@ SYS_MMAP
Map files or devices into memory.
Definition syscalls.h:1174
@ SYS_SHUTDOWN
Shut down part of a full-duplex connection.
Definition syscalls.h:1427
@ SYS_RECV
Receive data on a socket.
Definition syscalls.h:1410
@ SYS_MAX
Max number of syscalls.
Definition syscalls.h:1616
@ SYS_STAT
Retrieve file status.
Definition syscalls.h:835
@ SYS_WRITE
Write to a file descriptor.
Definition syscalls.h:724
@ SYS_NANOSLEEP
Sleep for a specified time.
Definition syscalls.h:1497
@ SYS_TELL
Get the current file offset.
Definition syscalls.h:951
@ SYS_TRUNCATE
Change the size of a file.
Definition syscalls.h:917
@ SYS_PIPE
Create a pipe.
Definition syscalls.h:1249
@ SYS_RMDIR
Remove an empty directory.
Definition syscalls.h:1568
@ SYS_READ
Read from a file descriptor.
Definition syscalls.h:681
@ SYS_GETPPID
Get the parent process ID.
Definition syscalls.h:1055
@ SYS_CLOSE
Close a file descriptor.
Definition syscalls.h:795
@ SYS_MADVISE
Provide advice about memory usage.
Definition syscalls.h:1229
@ SYS_EXECVE
Execute a program.
Definition syscalls.h:1029
@ SYS_LISTEN
Listen for incoming connections on a socket.
Definition syscalls.h:1354
@ SYS_WAITPID
Wait for a child process to change state.
Definition syscalls.h:1073
@ SYS_BRK
Set the program break.
Definition syscalls.h:1131
@ SYS_MUNMAP
Unmap a mapped memory region.
Definition syscalls.h:1192
@ SYS_EXIT
Terminate the calling process.
Definition syscalls.h:993
@ SYS_OPEN
Open a file.
Definition syscalls.h:779
@ SYS_CONNECT
Connect to a remote address.
Definition syscalls.h:1337
@ SYS_IOCTL
Control a device.
Definition syscalls.h:814
@ SYS_PREAD
Read from a file descriptor.
Definition syscalls.h:703
@ SYS_RENAME
Rename a file or directory.
Definition syscalls.h:1603
@ SYS_GETPID
Get the process ID of the calling process.
Definition syscalls.h:1042
@ SYS_FSTAT
Retrieve file status for an open file descriptor.
Definition syscalls.h:853
@ SYS_PWRITE
Write to a file descriptor.
Definition syscalls.h:745
@ SYS_BIND
Bind a socket to a local address.
Definition syscalls.h:1319
@ SYS_TIME
Get the current time.
Definition syscalls.h:1446
@ SYS_DUP
Duplicate a file descriptor.
Definition syscalls.h:1265
@ SYS_SOCKET
Create an endpoint for communication.
Definition syscalls.h:1301
@ SYS_CLOCK_SETTIME
Set the current time of a specific clock.
Definition syscalls.h:1480
@ SYS_API_VERSION
Set syscall version.
Definition syscalls.h:657
@ SYS_FORK
Create a child process.
Definition syscalls.h:1009
@ SYS_SEND
Send data on a socket.
Definition syscalls.h:1391
@ SYS_PRCTL
Process/Thread Control.
Definition syscalls.h:1112
@ SYS_LSTAT
Retrieve file status with symbolic link resolution.
Definition syscalls.h:872
@ SYS_DUP2
Duplicate a file descriptor to a specific value.
Definition syscalls.h:1283
@ SYS_KILL
Send a signal to a process.
Definition syscalls.h:1091
@ SYS_MPROTECT
Change memory protection.
Definition syscalls.h:1210
@ SYS_MKDIR
Create a new directory.
Definition syscalls.h:1552
@ SYS_CHDIR
Change the current working directory.
Definition syscalls.h:1534
@ SYS_ACCEPT
Accept an incoming connection on a socket.
Definition syscalls.h:1372
@ SYS_FTRUNCATE
Change the size of a file referred by a file descriptor.
Definition syscalls.h:935
@ SYS_SEEK
Set the file offset.
Definition syscalls.h:975
@ SYS_GETCWD
Get the current working directory.
Definition syscalls.h:1517
@ SYS_CLOCK_GETTIME
Get the current time of a specific clock.
Definition syscalls.h:1463
@ SYS_ACCESS
Check a file's accessibility.
Definition syscalls.h:898

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 54 of file syscalls.h.

55{
56 scarg ret;
57#if defined(__amd64__)
58 __asm__ __volatile__("syscall"
59 : "=a"(ret)
60 : "a"(syscall)
61 : "rcx", "r11", "memory");
62#elif defined(__i386__)
63 __asm__ __volatile__("int $0x30"
64 : "=a"(ret)
65 : "a"(syscall)
66 : "memory");
67#elif defined(__arm__)
68 register scarg r7 __thumb_r7 = syscall;
69 register scarg r0 __asm__("r0");
70 __arm_call(__r7_operand);
71#elif defined(__aarch64__)
72 register scarg x8 __asm__("x8") = syscall;
73 register scarg x0 __asm__("x0");
74 __asm__ __volatile__("svc 0"
75 : "=r"(x0)
76 : "r"(x8)
77 : "memory", "cc");
78#else
79#error "Unsupported architecture"
80#endif
81 return ret;
82}
#define scarg
Definition syscalls.h:23

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 93 of file syscalls.h.

94{
95 scarg ret;
96#if defined(__amd64__)
97 __asm__ __volatile__("syscall"
98 : "=a"(ret)
99 : "a"(syscall), "D"(arg1)
100 : "rcx", "r11", "memory");
101#elif defined(__i386__)
102 __asm__ __volatile__("int $0x30"
103 : "=a"(ret)
104 : "a"(syscall), "b"(arg1)
105 : "memory");
106#elif defined(__arm__)
107 register scarg r7 __thumb_r7 = syscall;
108 register scarg r0 __asm__("r0") = arg1;
109 __arm_call(__r7_operand, "0"(r0));
110#elif defined(__aarch64__)
111 register scarg x8 __asm__("x8") = syscall;
112 register scarg x0 __asm__("x0") = arg1;
113 __asm__ __volatile__("svc 0"
114 : "=r"(ret)
115 : "r"(x8), "0"(x0)
116 : "memory", "cc");
117#else
118#error "Unsupported architecture"
119#endif
120 return ret;
121}

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 133 of file syscalls.h.

134{
135 scarg ret;
136#if defined(__amd64__)
137 __asm__ __volatile__("syscall"
138 : "=a"(ret)
139 : "a"(syscall), "D"(arg1), "S"(arg2)
140 : "rcx", "r11", "memory");
141#elif defined(__i386__)
142 __asm__ __volatile__("int $0x30"
143 : "=a"(ret)
144 : "a"(syscall), "b"(arg1), "c"(arg2)
145 : "memory");
146#elif defined(__arm__)
147 register scarg r7 __thumb_r7 = syscall;
148 register scarg r0 __asm__("r0") = arg1;
149 register scarg r1 __asm__("r1") = arg2;
150 __arm_call(__r7_operand, "0"(r0), "r"(r1));
151#elif defined(__aarch64__)
152 register scarg x8 __asm__("x8") = syscall;
153 register scarg x0 __asm__("x0") = arg1;
154 register scarg x1 __asm__("x1") = arg2;
155 __asm__ __volatile__("svc 0"
156 : "=r"(ret)
157 : "r"(x8), "0"(x0), "r"(x1)
158 : "memory", "cc");
159#else
160#error "Unsupported architecture"
161#endif
162 return ret;
163}

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 176 of file syscalls.h.

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

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 222 of file syscalls.h.

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

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 272 of file syscalls.h.

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

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 326 of file syscalls.h.

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

References scarg.