18#ifndef __FENNIX_API_SYSCALLS_LIST_H__
19#define __FENNIX_API_SYSCALLS_LIST_H__
21#pragma region Syscall Wrappers
23#define scarg __UINTPTR_TYPE__
37 __asm__ __volatile__(
"syscall"
40 :
"rcx",
"r11",
"memory");
41#elif defined(__i386__)
42#warning "i386 syscall wrapper not implemented"
44#warning "arm syscall wrapper not implemented"
45#elif defined(__aarch64__)
46 register long x8 __asm__(
"x8") = syscall;
47 register long x0 __asm__(
"x0");
48 __asm__ __volatile__(
"svc 0"
53#error "Unsupported architecture"
71 __asm__ __volatile__(
"syscall"
73 :
"a"(syscall),
"D"(arg1)
74 :
"rcx",
"r11",
"memory");
75#elif defined(__i386__)
76#warning "i386 syscall wrapper not implemented"
78#warning "arm syscall wrapper not implemented"
79#elif defined(__aarch64__)
80 register long x8 __asm__(
"x8") = syscall;
81 register long x0 __asm__(
"x0") = arg1;
82 __asm__ __volatile__(
"svc 0"
87#error "Unsupported architecture"
105#if defined(__amd64__)
106 __asm__ __volatile__(
"syscall"
108 :
"a"(syscall),
"D"(arg1),
"S"(arg2)
109 :
"rcx",
"r11",
"memory");
110#elif defined(__i386__)
111#warning "i386 syscall wrapper not implemented"
112#elif defined(__arm__)
113#warning "arm syscall wrapper not implemented"
114#elif defined(__aarch64__)
115 register long x8 __asm__(
"x8") = syscall;
116 register long x0 __asm__(
"x0") = arg1;
117 register long x1 __asm__(
"x1") = arg2;
118 __asm__ __volatile__(
"svc 0"
120 :
"r"(x8),
"0"(x0),
"r"(x1)
123#error "Unsupported architecture"
142#if defined(__amd64__)
143 __asm__ __volatile__(
"syscall"
145 :
"a"(syscall),
"D"(arg1),
"S"(arg2),
"d"(arg3)
146 :
"rcx",
"r11",
"memory");
147#elif defined(__i386__)
148#warning "i386 syscall wrapper not implemented"
149#elif defined(__arm__)
150#warning "arm syscall wrapper not implemented"
151#elif defined(__aarch64__)
152 register long x8 __asm__(
"x8") = syscall;
153 register long x0 __asm__(
"x0") = arg1;
154 register long x1 __asm__(
"x1") = arg2;
155 register long x2 __asm__(
"x2") = arg3;
156 __asm__ __volatile__(
"svc 0"
158 :
"r"(x8),
"0"(x0),
"r"(x1),
"r"(x2)
161#error "Unsupported architecture"
181#if defined(__amd64__)
182 register scarg r10 __asm__(
"r10") = arg4;
183 __asm__ __volatile__(
"syscall"
185 :
"a"(syscall),
"D"(arg1),
"S"(arg2),
"d"(arg3),
"r"(r10)
186 :
"rcx",
"r11",
"memory");
187#elif defined(__i386__)
188#warning "i386 syscall wrapper not implemented"
189#elif defined(__arm__)
190#warning "arm syscall wrapper not implemented"
191#elif defined(__aarch64__)
192 register long x8 __asm__(
"x8") = syscall;
193 register long x0 __asm__(
"x0") = arg1;
194 register long x1 __asm__(
"x1") = arg2;
195 register long x2 __asm__(
"x2") = arg3;
196 register long x3 __asm__(
"x3") = arg4;
197 __asm__ __volatile__(
"svc 0"
199 :
"r"(x8),
"0"(x0),
"r"(x1),
"r"(x2),
"r"(x3)
202#error "Unsupported architecture"
223#if defined(__amd64__)
224 register scarg r10 __asm__(
"r10") = arg4;
225 register scarg r8 __asm__(
"r8") = arg5;
226 __asm__ __volatile__(
"syscall"
228 :
"a"(syscall),
"D"(arg1),
"S"(arg2),
"d"(arg3),
"r"(r10),
"r"(r8)
229 :
"rcx",
"r11",
"memory");
230#elif defined(__i386__)
231#warning "i386 syscall wrapper not implemented"
232#elif defined(__arm__)
233#warning "arm syscall wrapper not implemented"
234#elif defined(__aarch64__)
235 register long x8 __asm__(
"x8") = syscall;
236 register long x0 __asm__(
"x0") = arg1;
237 register long x1 __asm__(
"x1") = arg2;
238 register long x2 __asm__(
"x2") = arg3;
239 register long x3 __asm__(
"x3") = arg4;
240 register long x4 __asm__(
"x4") = arg5;
241 __asm__ __volatile__(
"svc 0"
243 :
"r"(x8),
"0"(x0),
"r"(x1),
"r"(x2),
"r"(x3),
"r"(x4)
246#error "Unsupported architecture"
268#if defined(__amd64__)
269 register scarg r10 __asm__(
"r10") = arg4;
270 register scarg r8 __asm__(
"r8") = arg5;
271 register scarg r9 __asm__(
"r9") = arg6;
272 __asm__ __volatile__(
"syscall"
274 :
"a"(syscall),
"D"(arg1),
"S"(arg2),
"d"(arg3),
"r"(r10),
"r"(r8),
"r"(r9)
275 :
"rcx",
"r11",
"memory");
276#elif defined(__i386__)
277#warning "i386 syscall wrapper not implemented"
278#elif defined(__arm__)
279#warning "arm syscall wrapper not implemented"
280#elif defined(__aarch64__)
281 register long x8 __asm__(
"x8") = syscall;
282 register long x0 __asm__(
"x0") = arg1;
283 register long x1 __asm__(
"x1") = arg2;
284 register long x2 __asm__(
"x2") = arg3;
285 register long x3 __asm__(
"x3") = arg4;
286 register long x4 __asm__(
"x4") = arg5;
287 register long x5 __asm__(
"x5") = arg6;
288 __asm__ __volatile__(
"svc 0"
290 :
"r"(x8),
"0"(x0),
"r"(x1),
"r"(x2),
"r"(x3),
"r"(x4),
"r"(x5)
293#error "Unsupported architecture"
298#pragma endregion Syscall Wrappers
307#define __SYS_NULL ((void *)0)
1529#define call_api_version(version) syscall1(SYS_API_VERSION, (scarg)version)
1534#define call_read(fd, buf, count) syscall3(SYS_READ, (scarg)fd, (scarg)buf, (scarg)count)
1537#define call_pread(fd, buf, count, offset) syscall4(SYS_PREAD, (scarg)fd, (scarg)buf, (scarg)count, (scarg)offset)
1540#define call_write(fd, buf, count) syscall3(SYS_WRITE, (scarg)fd, (scarg)buf, (scarg)count)
1543#define call_pwrite(fd, buf, count, offset) syscall4(SYS_PWRITE, (scarg)fd, (scarg)buf, (scarg)count, (scarg)offset)
1546#define call_open(pathname, flags, mode) syscall3(SYS_OPEN, (scarg)pathname, (scarg)flags, (scarg)mode)
1549#define call_close(fd) syscall1(SYS_CLOSE, fd)
1552#define call_ioctl(fd, request, argp) syscall3(SYS_IOCTL, (scarg)fd, (scarg)request, (scarg)argp)
1557#define call_stat(pathname, statbuf) syscall2(SYS_STAT, (scarg)pathname, (scarg)statbuf)
1560#define call_fstat(fd, statbuf) syscall2(SYS_FSTAT, (scarg)fd, (scarg)statbuf)
1563#define call_lstat(pathname, statbuf) syscall2(SYS_LSTAT, (scarg)pathname, (scarg)statbuf)
1566#define call_access(pathname, mode) syscall2(SYS_ACCESS, (scarg)pathname, (scarg)mode)
1569#define call_truncate(pathname, length) syscall2(SYS_TRUNCATE, (scarg)pathname, (scarg)length)
1572#define call_ftruncate(fd, length) syscall2(SYS_FTRUNCATE, (scarg)fd, (scarg)length)
1575#define call_tell(fd) syscall1(SYS_TELL, (scarg)fd)
1578#define call_seek(fd, offset, whence) syscall3(SYS_SEEK, (scarg)fd, (scarg)offset, (scarg)whence)
1583#define call_exit(status) syscall1(SYS_EXIT, (scarg)status)
1586#define call_fork() syscall0(SYS_FORK)
1589#define call_execve(pathname, argv, envp) syscall3(SYS_EXECVE, (scarg)pathname, (scarg)argv, (scarg)envp)
1592#define call_getpid() syscall0(SYS_GETPID)
1595#define call_getppid() syscall0(SYS_GETPPID)
1598#define call_waitpid(pid, wstatus, options) syscall3(SYS_WAITPID, (scarg)pid, (scarg)wstatus, (scarg)options)
1601#define call_kill(pid, sig) syscall2(SYS_KILL, (scarg)pid, (scarg)sig)
1604#define call_prctl(option, arg1, arg2, arg3, arg4) syscall5(SYS_PRCTL, (scarg)option, (scarg)arg1, (scarg)arg2, (scarg)arg3, (scarg)arg4)
1609#define call_brk(end_data) syscall1(SYS_BRK, (scarg)end_data)
1612#define call_mmap(addr, length, prot, flags, fd, offset) syscall6(SYS_MMAP, (scarg)addr, (scarg)length, (scarg)prot, (scarg)flags, (scarg)fd, (scarg)offset)
1615#define call_munmap(addr, length) syscall2(SYS_MUNMAP, (scarg)addr, (scarg)length)
1618#define call_mprotect(addr, length, prot) syscall3(SYS_MPROTECT, (scarg)addr, (scarg)length, (scarg)prot)
1621#define call_madvise(addr, length, advice) syscall3(SYS_MADVISE, (scarg)addr, (scarg)length, (scarg)advice)
1626#define call_pipe(pipefd) syscall1(SYS_PIPE, (scarg)pipefd)
1629#define call_dup(oldfd) syscall1(SYS_DUP, (scarg)oldfd)
1632#define call_dup2(oldfd, newfd) syscall2(SYS_DUP2, (scarg)oldfd, (scarg)newfd)
1635#define call_socket(domain, type, protocol) syscall3(SYS_SOCKET, (scarg)domain, (scarg)type, (scarg)protocol)
1638#define call_bind(sockfd, addr, addrlen) syscall3(SYS_BIND, (scarg)sockfd, (scarg)addr, (scarg)addrlen)
1641#define call_connect(sockfd, addr, addrlen) syscall3(SYS_CONNECT, (scarg)sockfd, (scarg)addr, (scarg)addrlen)
1644#define call_listen(sockfd, backlog) syscall2(SYS_LISTEN, (scarg)sockfd, (scarg)backlog)
1647#define call_accept(sockfd, addr, addrlen) syscall3(SYS_ACCEPT, (scarg)sockfd, (scarg)addr, (scarg)addrlen)
1650#define call_send(sockfd, buf, len, flags) syscall4(SYS_SEND, (scarg)sockfd, (scarg)buf, (scarg)len, (scarg)flags)
1653#define call_recv(sockfd, buf, len, flags) syscall4(SYS_RECV, (scarg)sockfd, (scarg)buf, (scarg)len, (scarg)flags)
1656#define call_shutdown(sockfd, how) syscall2(SYS_SHUTDOWN, (scarg)sockfd, (scarg)how)
1661#define call_time(t) syscall1(SYS_TIME, t)
1664#define call_clock_gettime(clockid, tp) syscall2(SYS_CLOCK_GETTIME, (scarg)clockid, (scarg)tp)
1667#define call_clock_settime(clockid, tp) syscall2(SYS_CLOCK_SETTIME, (scarg)clockid, (scarg)tp)
1670#define call_nanosleep(req, rem) syscall2(SYS_NANOSLEEP, (scarg)req, (scarg)rem)
1675#define call_getcwd(buf, size) syscall2(SYS_GETCWD, (scarg)buf, (scarg)size)
1678#define call_chdir(path) syscall1(SYS_CHDIR, (scarg)path)
1681#define call_mkdir(path, mode) syscall2(SYS_MKDIR, (scarg)path, (scarg)mode)
1684#define call_rmdir(path) syscall1(SYS_RMDIR, (scarg)path)
1687#define call_unlink(pathname) syscall1(SYS_UNLINK, (scarg)pathname)
1690#define call_rename(oldpath, newpath) syscall2(SYS_RENAME, (scarg)oldpath, (scarg)newpath)
unsigned int __SYS_socklen_t
syscall_signal_disposition_t
syscalls_t
List of syscalls.
@ SYS_UNLINK
Remove a file.
@ SYS_MMAP
Map files or devices into memory.
@ SYS_SHUTDOWN
Shut down part of a full-duplex connection.
@ SYS_RECV
Receive data on a socket.
@ SYS_MAX
Max number of syscalls.
@ SYS_STAT
Retrieve file status.
@ SYS_WRITE
Write to a file descriptor.
@ SYS_NANOSLEEP
Sleep for a specified time.
@ SYS_TELL
Get the current file offset.
@ SYS_TRUNCATE
Change the size of a file.
@ SYS_RMDIR
Remove an empty directory.
@ SYS_READ
Read from a file descriptor.
@ SYS_GETPPID
Get the parent process ID.
@ SYS_CLOSE
Close a file descriptor.
@ SYS_MADVISE
Provide advice about memory usage.
@ SYS_EXECVE
Execute a program.
@ SYS_LISTEN
Listen for incoming connections on a socket.
@ SYS_WAITPID
Wait for a child process to change state.
@ SYS_BRK
Set the program break.
@ SYS_MUNMAP
Unmap a mapped memory region.
@ SYS_EXIT
Terminate the calling process.
@ SYS_CONNECT
Connect to a remote address.
@ SYS_IOCTL
Control a device.
@ SYS_PREAD
Read from a file descriptor.
@ SYS_RENAME
Rename a file or directory.
@ SYS_GETPID
Get the process ID of the calling process.
@ SYS_FSTAT
Retrieve file status for an open file descriptor.
@ SYS_PWRITE
Write to a file descriptor.
@ SYS_BIND
Bind a socket to a local address.
@ SYS_TIME
Get the current time.
@ SYS_DUP
Duplicate a file descriptor.
@ SYS_SOCKET
Create an endpoint for communication.
@ SYS_CLOCK_SETTIME
Set the current time of a specific clock.
@ SYS_API_VERSION
Set syscall version.
@ SYS_FORK
Create a child process.
@ SYS_SEND
Send data on a socket.
@ SYS_PRCTL
Process/Thread Control.
@ SYS_LSTAT
Retrieve file status with symbolic link resolution.
@ SYS_DUP2
Duplicate a file descriptor to a specific value.
@ SYS_KILL
Send a signal to a process.
@ SYS_MPROTECT
Change memory protection.
@ SYS_MKDIR
Create a new directory.
@ SYS_CHDIR
Change the current working directory.
@ SYS_ACCEPT
Accept an incoming connection on a socket.
@ SYS_FTRUNCATE
Change the size of a file referred by a file descriptor.
@ SYS_SEEK
Set the file offset.
@ SYS_GETCWD
Get the current working directory.
@ SYS_CLOCK_GETTIME
Get the current time of a specific clock.
@ SYS_ACCESS
Check a file's accessibility.
static scarg syscall6(scarg syscall, scarg arg1, scarg arg2, scarg arg3, scarg arg4, scarg arg5, scarg arg6)
Syscall wrapper with 6 arguments.
@ __SYS_CLOCK_PROCESS_CPUTIME_ID
@ __SYS_CLOCK_THREAD_CPUTIME_ID
static scarg syscall5(scarg syscall, scarg arg1, scarg arg2, scarg arg3, scarg arg4, scarg arg5)
Syscall wrapper with 5 arguments.
static scarg syscall4(scarg syscall, scarg arg1, scarg arg2, scarg arg3, scarg arg4)
Syscall wrapper with 4 arguments.
static scarg syscall1(scarg syscall, scarg arg1)
Syscall wrapper with 1 argument.
static scarg syscall0(scarg syscall)
Syscall wrapper with 0 arguments.
syscall_signal_action_flags_t
static scarg syscall2(scarg syscall, scarg arg1, scarg arg2)
Syscall wrapper with 2 arguments.
syscall_signal_action_disposition_t
static scarg syscall3(scarg syscall, scarg arg1, scarg arg2, scarg arg3)
Syscall wrapper with 3 arguments.