18#ifndef __FENNIX_API_SYSCALLS_LIST_H__
19#define __FENNIX_API_SYSCALLS_LIST_H__
21#pragma region Syscall Wrappers
23#define scarg __UINTPTR_TYPE__
28#define __arm_call(...)
29#warning "arm thumb code not implemented"
31#define __thumb_r7 __asm__("r7")
32#define __arm_call(...) \
33 __asm__ __volatile__("svc 0" \
40#define __r7_operand "rI"(r7)
42#define __r7_operand "r"(r7)
58 __asm__ __volatile__(
"syscall"
61 :
"rcx",
"r11",
"memory");
62#elif defined(__i386__)
63 __asm__ __volatile__(
"int $0x30"
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"
79#error "Unsupported architecture"
97 __asm__ __volatile__(
"syscall"
99 :
"a"(syscall),
"D"(arg1)
100 :
"rcx",
"r11",
"memory");
101#elif defined(__i386__)
102 __asm__ __volatile__(
"int $0x30"
104 :
"a"(syscall),
"b"(arg1)
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"
118#error "Unsupported architecture"
136#if defined(__amd64__)
137 __asm__ __volatile__(
"syscall"
139 :
"a"(syscall),
"D"(arg1),
"S"(arg2)
140 :
"rcx",
"r11",
"memory");
141#elif defined(__i386__)
142 __asm__ __volatile__(
"int $0x30"
144 :
"a"(syscall),
"b"(arg1),
"c"(arg2)
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"
157 :
"r"(x8),
"0"(x0),
"r"(x1)
160#error "Unsupported architecture"
179#if defined(__amd64__)
180 __asm__ __volatile__(
"syscall"
182 :
"a"(syscall),
"D"(arg1),
"S"(arg2),
"d"(arg3)
183 :
"rcx",
"r11",
"memory");
184#elif defined(__i386__)
185 __asm__ __volatile__(
"int $0x30"
187 :
"a"(syscall),
"b"(arg1),
"c"(arg2),
"d"(arg3)
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"
202 :
"r"(x8),
"0"(x0),
"r"(x1),
"r"(x2)
205#error "Unsupported architecture"
225#if defined(__amd64__)
226 register scarg r10 __asm__(
"r10") = arg4;
227 __asm__ __volatile__(
"syscall"
229 :
"a"(syscall),
"D"(arg1),
"S"(arg2),
"d"(arg3),
"r"(r10)
230 :
"rcx",
"r11",
"memory");
231#elif defined(__i386__)
232 __asm__ __volatile__(
"int $0x30"
234 :
"a"(syscall),
"b"(arg1),
"c"(arg2),
"d"(arg3),
"S"(arg4)
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"
251 :
"r"(x8),
"0"(x0),
"r"(x1),
"r"(x2),
"r"(x3)
254#error "Unsupported architecture"
275#if defined(__amd64__)
276 register scarg r10 __asm__(
"r10") = arg4;
277 register scarg r8 __asm__(
"r8") = arg5;
278 __asm__ __volatile__(
"syscall"
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"
285 :
"a"(syscall),
"b"(arg1),
"c"(arg2),
"d"(arg3),
"S"(arg4),
"D"(arg5)
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"
304 :
"r"(x8),
"0"(x0),
"r"(x1),
"r"(x2),
"r"(x3),
"r"(x4)
307#error "Unsupported architecture"
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"
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"
340 :
"a"(syscall),
"b"(arg1),
"c"(arg2),
"d"(arg3),
"S"(arg4),
"D"(arg5),
"g"(arg6)
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"
361 :
"r"(x8),
"0"(x0),
"r"(x1),
"r"(x2),
"r"(x3),
"r"(x4),
"r"(x5)
364#error "Unsupported architecture"
369#pragma endregion Syscall Wrappers
378#define __SYS_NULL ((void *)0)
625#define FBIOGET_SCREEN_INFO 0xf0
1622#define call_api_version(version) syscall1(SYS_API_VERSION, (scarg)version)
1627#define call_read(fd, buf, count) syscall3(SYS_READ, (scarg)fd, (scarg)buf, (scarg)count)
1630#define call_pread(fd, buf, count, offset) syscall4(SYS_PREAD, (scarg)fd, (scarg)buf, (scarg)count, (scarg)offset)
1633#define call_write(fd, buf, count) syscall3(SYS_WRITE, (scarg)fd, (scarg)buf, (scarg)count)
1636#define call_pwrite(fd, buf, count, offset) syscall4(SYS_PWRITE, (scarg)fd, (scarg)buf, (scarg)count, (scarg)offset)
1639#define call_open(pathname, flags, mode) syscall3(SYS_OPEN, (scarg)pathname, (scarg)flags, (scarg)mode)
1642#define call_close(fd) syscall1(SYS_CLOSE, fd)
1645#define call_ioctl(fd, request, argp) syscall3(SYS_IOCTL, (scarg)fd, (scarg)request, (scarg)argp)
1650#define call_stat(pathname, statbuf) syscall2(SYS_STAT, (scarg)pathname, (scarg)statbuf)
1653#define call_fstat(fd, statbuf) syscall2(SYS_FSTAT, (scarg)fd, (scarg)statbuf)
1656#define call_lstat(pathname, statbuf) syscall2(SYS_LSTAT, (scarg)pathname, (scarg)statbuf)
1659#define call_access(pathname, mode) syscall2(SYS_ACCESS, (scarg)pathname, (scarg)mode)
1662#define call_truncate(pathname, length) syscall2(SYS_TRUNCATE, (scarg)pathname, (scarg)length)
1665#define call_ftruncate(fd, length) syscall2(SYS_FTRUNCATE, (scarg)fd, (scarg)length)
1668#define call_tell(fd) syscall1(SYS_TELL, (scarg)fd)
1671#define call_seek(fd, offset, whence) syscall3(SYS_SEEK, (scarg)fd, (scarg)offset, (scarg)whence)
1676#define call_exit(status) syscall1(SYS_EXIT, (scarg)status)
1679#define call_fork() syscall0(SYS_FORK)
1682#define call_execve(pathname, argv, envp) syscall3(SYS_EXECVE, (scarg)pathname, (scarg)argv, (scarg)envp)
1685#define call_getpid() syscall0(SYS_GETPID)
1688#define call_getppid() syscall0(SYS_GETPPID)
1691#define call_waitpid(pid, wstatus, options) syscall3(SYS_WAITPID, (scarg)pid, (scarg)wstatus, (scarg)options)
1694#define call_kill(pid, sig) syscall2(SYS_KILL, (scarg)pid, (scarg)sig)
1697#define call_prctl(option, arg1, arg2, arg3, arg4) syscall5(SYS_PRCTL, (scarg)option, (scarg)arg1, (scarg)arg2, (scarg)arg3, (scarg)arg4)
1702#define call_brk(end_data) syscall1(SYS_BRK, (scarg)end_data)
1705#define call_mmap(addr, length, prot, flags, fd, offset) syscall6(SYS_MMAP, (scarg)addr, (scarg)length, (scarg)prot, (scarg)flags, (scarg)fd, (scarg)offset)
1708#define call_munmap(addr, length) syscall2(SYS_MUNMAP, (scarg)addr, (scarg)length)
1711#define call_mprotect(addr, length, prot) syscall3(SYS_MPROTECT, (scarg)addr, (scarg)length, (scarg)prot)
1714#define call_madvise(addr, length, advice) syscall3(SYS_MADVISE, (scarg)addr, (scarg)length, (scarg)advice)
1719#define call_pipe(pipefd) syscall1(SYS_PIPE, (scarg)pipefd)
1722#define call_dup(oldfd) syscall1(SYS_DUP, (scarg)oldfd)
1725#define call_dup2(oldfd, newfd) syscall2(SYS_DUP2, (scarg)oldfd, (scarg)newfd)
1728#define call_socket(domain, type, protocol) syscall3(SYS_SOCKET, (scarg)domain, (scarg)type, (scarg)protocol)
1731#define call_bind(sockfd, addr, addrlen) syscall3(SYS_BIND, (scarg)sockfd, (scarg)addr, (scarg)addrlen)
1734#define call_connect(sockfd, addr, addrlen) syscall3(SYS_CONNECT, (scarg)sockfd, (scarg)addr, (scarg)addrlen)
1737#define call_listen(sockfd, backlog) syscall2(SYS_LISTEN, (scarg)sockfd, (scarg)backlog)
1740#define call_accept(sockfd, addr, addrlen) syscall3(SYS_ACCEPT, (scarg)sockfd, (scarg)addr, (scarg)addrlen)
1743#define call_send(sockfd, buf, len, flags) syscall4(SYS_SEND, (scarg)sockfd, (scarg)buf, (scarg)len, (scarg)flags)
1746#define call_recv(sockfd, buf, len, flags) syscall4(SYS_RECV, (scarg)sockfd, (scarg)buf, (scarg)len, (scarg)flags)
1749#define call_shutdown(sockfd, how) syscall2(SYS_SHUTDOWN, (scarg)sockfd, (scarg)how)
1754#define call_time(t) syscall1(SYS_TIME, t)
1757#define call_clock_gettime(clockid, tp) syscall2(SYS_CLOCK_GETTIME, (scarg)clockid, (scarg)tp)
1760#define call_clock_settime(clockid, tp) syscall2(SYS_CLOCK_SETTIME, (scarg)clockid, (scarg)tp)
1763#define call_nanosleep(req, rem) syscall2(SYS_NANOSLEEP, (scarg)req, (scarg)rem)
1768#define call_getcwd(buf, size) syscall2(SYS_GETCWD, (scarg)buf, (scarg)size)
1771#define call_chdir(path) syscall1(SYS_CHDIR, (scarg)path)
1774#define call_mkdir(path, mode) syscall2(SYS_MKDIR, (scarg)path, (scarg)mode)
1777#define call_rmdir(path) syscall1(SYS_RMDIR, (scarg)path)
1780#define call_unlink(pathname) syscall1(SYS_UNLINK, (scarg)pathname)
1783#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.