18#ifndef __FENNIX_API_SYSTEM_CALLS_LIST_H__
19#define __FENNIX_API_SYSTEM_CALLS_LIST_H__
21#if __has_include(<interface/fcntl.h>)
28#error "__fennix__ not defined"
31#pragma region Syscall Wrappers
33#define scarg __UINTPTR_TYPE__
38#define __arm_call(...)
39#warning "arm thumb code not implemented"
41#define __thumb_r7 __asm__("r7")
42#define __arm_call(...) \
43 __asm__ __volatile__("svc 0" \
50#define __r7_operand "rI"(r7)
52#define __r7_operand "r"(r7)
68 __asm__ __volatile__(
"syscall"
71 :
"rcx",
"r11",
"memory");
72#elif defined(__i386__)
73 __asm__ __volatile__(
"int $0x30"
78 register scarg r7 __thumb_r7 = syscall;
79 register scarg r0 __asm__(
"r0");
80 __arm_call(__r7_operand);
81#elif defined(__aarch64__)
82 register scarg x8 __asm__(
"x8") = syscall;
83 register scarg x0 __asm__(
"x0");
84 __asm__ __volatile__(
"svc 0"
89#error "Unsupported architecture"
106#if defined(__amd64__)
107 __asm__ __volatile__(
"syscall"
109 :
"a"(syscall),
"D"(arg1)
110 :
"rcx",
"r11",
"memory");
111#elif defined(__i386__)
112 __asm__ __volatile__(
"int $0x30"
114 :
"a"(syscall),
"b"(arg1)
116#elif defined(__arm__)
117 register scarg r7 __thumb_r7 = syscall;
118 register scarg r0 __asm__(
"r0") = arg1;
119 __arm_call(__r7_operand,
"0"(r0));
120#elif defined(__aarch64__)
121 register scarg x8 __asm__(
"x8") = syscall;
122 register scarg x0 __asm__(
"x0") = arg1;
123 __asm__ __volatile__(
"svc 0"
128#error "Unsupported architecture"
146#if defined(__amd64__)
147 __asm__ __volatile__(
"syscall"
149 :
"a"(syscall),
"D"(arg1),
"S"(arg2)
150 :
"rcx",
"r11",
"memory");
151#elif defined(__i386__)
152 __asm__ __volatile__(
"int $0x30"
154 :
"a"(syscall),
"b"(arg1),
"c"(arg2)
156#elif defined(__arm__)
157 register scarg r7 __thumb_r7 = syscall;
158 register scarg r0 __asm__(
"r0") = arg1;
159 register scarg r1 __asm__(
"r1") = arg2;
160 __arm_call(__r7_operand,
"0"(r0),
"r"(r1));
161#elif defined(__aarch64__)
162 register scarg x8 __asm__(
"x8") = syscall;
163 register scarg x0 __asm__(
"x0") = arg1;
164 register scarg x1 __asm__(
"x1") = arg2;
165 __asm__ __volatile__(
"svc 0"
167 :
"r"(x8),
"0"(x0),
"r"(x1)
170#error "Unsupported architecture"
189#if defined(__amd64__)
190 __asm__ __volatile__(
"syscall"
192 :
"a"(syscall),
"D"(arg1),
"S"(arg2),
"d"(arg3)
193 :
"rcx",
"r11",
"memory");
194#elif defined(__i386__)
195 __asm__ __volatile__(
"int $0x30"
197 :
"a"(syscall),
"b"(arg1),
"c"(arg2),
"d"(arg3)
199#elif defined(__arm__)
200 register scarg r7 __thumb_r7 = syscall;
201 register scarg r0 __asm__(
"r0") = arg1;
202 register scarg r1 __asm__(
"r1") = arg2;
203 register scarg r2 __asm__(
"r2") = arg3;
204 __arm_call(__r7_operand,
"0"(r0),
"r"(r1),
"r"(r2));
205#elif defined(__aarch64__)
206 register scarg x8 __asm__(
"x8") = syscall;
207 register scarg x0 __asm__(
"x0") = arg1;
208 register scarg x1 __asm__(
"x1") = arg2;
209 register scarg x2 __asm__(
"x2") = arg3;
210 __asm__ __volatile__(
"svc 0"
212 :
"r"(x8),
"0"(x0),
"r"(x1),
"r"(x2)
215#error "Unsupported architecture"
235#if defined(__amd64__)
236 register scarg r10 __asm__(
"r10") = arg4;
237 __asm__ __volatile__(
"syscall"
239 :
"a"(syscall),
"D"(arg1),
"S"(arg2),
"d"(arg3),
"r"(r10)
240 :
"rcx",
"r11",
"memory");
241#elif defined(__i386__)
242 __asm__ __volatile__(
"int $0x30"
244 :
"a"(syscall),
"b"(arg1),
"c"(arg2),
"d"(arg3),
"S"(arg4)
246#elif defined(__arm__)
247 register scarg r7 __thumb_r7 = syscall;
248 register scarg r0 __asm__(
"r0") = arg1;
249 register scarg r1 __asm__(
"r1") = arg2;
250 register scarg r2 __asm__(
"r2") = arg3;
251 register scarg r3 __asm__(
"r3") = arg4;
252 __arm_call(__r7_operand,
"0"(r0),
"r"(r1),
"r"(r2),
"r"(r3));
253#elif defined(__aarch64__)
254 register scarg x8 __asm__(
"x8") = syscall;
255 register scarg x0 __asm__(
"x0") = arg1;
256 register scarg x1 __asm__(
"x1") = arg2;
257 register scarg x2 __asm__(
"x2") = arg3;
258 register scarg x3 __asm__(
"x3") = arg4;
259 __asm__ __volatile__(
"svc 0"
261 :
"r"(x8),
"0"(x0),
"r"(x1),
"r"(x2),
"r"(x3)
264#error "Unsupported architecture"
285#if defined(__amd64__)
286 register scarg r10 __asm__(
"r10") = arg4;
287 register scarg r8 __asm__(
"r8") = arg5;
288 __asm__ __volatile__(
"syscall"
290 :
"a"(syscall),
"D"(arg1),
"S"(arg2),
"d"(arg3),
"r"(r10),
"r"(r8)
291 :
"rcx",
"r11",
"memory");
292#elif defined(__i386__)
293 __asm__ __volatile__(
"int $0x30"
295 :
"a"(syscall),
"b"(arg1),
"c"(arg2),
"d"(arg3),
"S"(arg4),
"D"(arg5)
297#elif defined(__arm__)
298 register scarg r7 __thumb_r7 = syscall;
299 register scarg r0 __asm__(
"r0") = arg1;
300 register scarg r1 __asm__(
"r1") = arg2;
301 register scarg r2 __asm__(
"r2") = arg3;
302 register scarg r3 __asm__(
"r3") = arg4;
303 register scarg r4 __asm__(
"r4") = arg5;
304 __arm_call(__r7_operand,
"0"(r0),
"r"(r1),
"r"(r2),
"r"(r3),
"r"(r4));
305#elif defined(__aarch64__)
306 register scarg x8 __asm__(
"x8") = syscall;
307 register scarg x0 __asm__(
"x0") = arg1;
308 register scarg x1 __asm__(
"x1") = arg2;
309 register scarg x2 __asm__(
"x2") = arg3;
310 register scarg x3 __asm__(
"x3") = arg4;
311 register scarg x4 __asm__(
"x4") = arg5;
312 __asm__ __volatile__(
"svc 0"
314 :
"r"(x8),
"0"(x0),
"r"(x1),
"r"(x2),
"r"(x3),
"r"(x4)
317#error "Unsupported architecture"
339#if defined(__amd64__)
340 register scarg r10 __asm__(
"r10") = arg4;
341 register scarg r8 __asm__(
"r8") = arg5;
342 register scarg r9 __asm__(
"r9") = arg6;
343 __asm__ __volatile__(
"syscall"
345 :
"a"(syscall),
"D"(arg1),
"S"(arg2),
"d"(arg3),
"r"(r10),
"r"(r8),
"r"(r9)
346 :
"rcx",
"r11",
"memory");
347#elif defined(__i386__)
348 __asm__ __volatile__(
"int $0x30"
350 :
"a"(syscall),
"b"(arg1),
"c"(arg2),
"d"(arg3),
"S"(arg4),
"D"(arg5),
"g"(arg6)
352#elif defined(__arm__)
353 register scarg r7 __thumb_r7 = syscall;
354 register scarg r0 __asm__(
"r0") = arg1;
355 register scarg r1 __asm__(
"r1") = arg2;
356 register scarg r2 __asm__(
"r2") = arg3;
357 register scarg r3 __asm__(
"r3") = arg4;
358 register scarg r4 __asm__(
"r4") = arg5;
359 register scarg r5 __asm__(
"r5") = arg6;
360 __arm_call(__r7_operand,
"0"(r0),
"r"(r1),
"r"(r2),
"r"(r3),
"r"(r4),
"r"(r5));
361#elif defined(__aarch64__)
362 register scarg x8 __asm__(
"x8") = syscall;
363 register scarg x0 __asm__(
"x0") = arg1;
364 register scarg x1 __asm__(
"x1") = arg2;
365 register scarg x2 __asm__(
"x2") = arg3;
366 register scarg x3 __asm__(
"x3") = arg4;
367 register scarg x4 __asm__(
"x4") = arg5;
368 register scarg x5 __asm__(
"x5") = arg6;
369 __asm__ __volatile__(
"svc 0"
371 :
"r"(x8),
"0"(x0),
"r"(x1),
"r"(x2),
"r"(x3),
"r"(x4),
"r"(x5)
374#error "Unsupported architecture"
379#pragma endregion Syscall Wrappers
388#define __SYS_NULL ((void *)0)
635#define FBIOGET_SCREEN_INFO 0xf0
1677#define call_api_version(version) syscall1(SYS_API_VERSION, (scarg)version)
1682#define call_read(fd, buf, count) syscall3(SYS_READ, (scarg)fd, (scarg)buf, (scarg)count)
1685#define call_pread(fd, buf, count, offset) syscall4(SYS_PREAD, (scarg)fd, (scarg)buf, (scarg)count, (scarg)offset)
1688#define call_write(fd, buf, count) syscall3(SYS_WRITE, (scarg)fd, (scarg)buf, (scarg)count)
1691#define call_pwrite(fd, buf, count, offset) syscall4(SYS_PWRITE, (scarg)fd, (scarg)buf, (scarg)count, (scarg)offset)
1694#define call_open(pathname, flags, mode) syscall3(SYS_OPEN, (scarg)pathname, (scarg)flags, (scarg)mode)
1697#define call_close(fd) syscall1(SYS_CLOSE, fd)
1700#define call_ioctl(fd, request, argp) syscall3(SYS_IOCTL, (scarg)fd, (scarg)request, (scarg)argp)
1703#define call_fcntl(fd, cmd, arg) syscall3(SYS_FCNTL, (scarg)fd, (scarg)cmd, (scarg)arg)
1708#define call_stat(pathname, statbuf) syscall2(SYS_STAT, (scarg)pathname, (scarg)statbuf)
1711#define call_fstat(fd, statbuf) syscall2(SYS_FSTAT, (scarg)fd, (scarg)statbuf)
1714#define call_lstat(pathname, statbuf) syscall2(SYS_LSTAT, (scarg)pathname, (scarg)statbuf)
1717#define call_access(pathname, mode) syscall2(SYS_ACCESS, (scarg)pathname, (scarg)mode)
1720#define call_truncate(pathname, length) syscall2(SYS_TRUNCATE, (scarg)pathname, (scarg)length)
1723#define call_ftruncate(fd, length) syscall2(SYS_FTRUNCATE, (scarg)fd, (scarg)length)
1726#define call_tell(fd) syscall1(SYS_TELL, (scarg)fd)
1729#define call_seek(fd, offset, whence) syscall3(SYS_SEEK, (scarg)fd, (scarg)offset, (scarg)whence)
1734#define call_exit(status) syscall1(SYS_EXIT, (scarg)status)
1737#define call_fork() syscall0(SYS_FORK)
1740#define call_execve(pathname, argv, envp) syscall3(SYS_EXECVE, (scarg)pathname, (scarg)argv, (scarg)envp)
1743#define call_getpid() syscall0(SYS_GETPID)
1746#define call_getppid() syscall0(SYS_GETPPID)
1749#define call_waitpid(pid, wstatus, options) syscall3(SYS_WAITPID, (scarg)pid, (scarg)wstatus, (scarg)options)
1752#define call_kill(pid, sig) syscall2(SYS_KILL, (scarg)pid, (scarg)sig)
1755#define call_prctl(option, arg1, arg2, arg3, arg4) syscall5(SYS_PRCTL, (scarg)option, (scarg)arg1, (scarg)arg2, (scarg)arg3, (scarg)arg4)
1760#define call_brk(end_data) syscall1(SYS_BRK, (scarg)end_data)
1763#define call_mmap(addr, length, prot, flags, fd, offset) syscall6(SYS_MMAP, (scarg)addr, (scarg)length, (scarg)prot, (scarg)flags, (scarg)fd, (scarg)offset)
1766#define call_munmap(addr, length) syscall2(SYS_MUNMAP, (scarg)addr, (scarg)length)
1769#define call_mprotect(addr, length, prot) syscall3(SYS_MPROTECT, (scarg)addr, (scarg)length, (scarg)prot)
1772#define call_madvise(addr, length, advice) syscall3(SYS_MADVISE, (scarg)addr, (scarg)length, (scarg)advice)
1777#define call_pipe(pipefd) syscall1(SYS_PIPE, (scarg)pipefd)
1780#define call_dup(oldfd) syscall1(SYS_DUP, (scarg)oldfd)
1783#define call_dup2(oldfd, newfd) syscall2(SYS_DUP2, (scarg)oldfd, (scarg)newfd)
1786#define call_socket(domain, type, protocol) syscall3(SYS_SOCKET, (scarg)domain, (scarg)type, (scarg)protocol)
1789#define call_bind(sockfd, addr, addrlen) syscall3(SYS_BIND, (scarg)sockfd, (scarg)addr, (scarg)addrlen)
1792#define call_connect(sockfd, addr, addrlen) syscall3(SYS_CONNECT, (scarg)sockfd, (scarg)addr, (scarg)addrlen)
1795#define call_listen(sockfd, backlog) syscall2(SYS_LISTEN, (scarg)sockfd, (scarg)backlog)
1798#define call_accept(sockfd, addr, addrlen) syscall3(SYS_ACCEPT, (scarg)sockfd, (scarg)addr, (scarg)addrlen)
1801#define call_send(sockfd, buf, len, flags) syscall4(SYS_SEND, (scarg)sockfd, (scarg)buf, (scarg)len, (scarg)flags)
1804#define call_recv(sockfd, buf, len, flags) syscall4(SYS_RECV, (scarg)sockfd, (scarg)buf, (scarg)len, (scarg)flags)
1807#define call_shutdown(sockfd, how) syscall2(SYS_SHUTDOWN, (scarg)sockfd, (scarg)how)
1812#define call_time(t) syscall1(SYS_TIME, (scarg)t)
1815#define call_clock_gettime(clockid, tp) syscall2(SYS_CLOCK_GETTIME, (scarg)clockid, (scarg)tp)
1818#define call_clock_settime(clockid, tp) syscall2(SYS_CLOCK_SETTIME, (scarg)clockid, (scarg)tp)
1821#define call_nanosleep(req, rem) syscall2(SYS_NANOSLEEP, (scarg)req, (scarg)rem)
1826#define call_getcwd(buf, size) syscall2(SYS_GETCWD, (scarg)buf, (scarg)size)
1829#define call_chdir(path) syscall1(SYS_CHDIR, (scarg)path)
1832#define call_mkdir(path, mode) syscall2(SYS_MKDIR, (scarg)path, (scarg)mode)
1835#define call_rmdir(path) syscall1(SYS_RMDIR, (scarg)path)
1838#define call_unlink(pathname) syscall1(SYS_UNLINK, (scarg)pathname)
1841#define call_rename(oldpath, newpath) syscall2(SYS_RENAME, (scarg)oldpath, (scarg)newpath)
1844#define call_uname(buf) syscall1(SYS_UNAME, (scarg)buf)
unsigned int __SYS_socklen_t
syscall_signal_disposition_t
syscalls_t
List of syscalls.
@ SYS_UNLINK
Remove a file.
@ SYS_UNAME
Get unix name information.
@ 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_FCNTL
Function control.
@ 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.