2018-10-16 09:01:38 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-10-22 11:55:11 +00:00
|
|
|
#include <AK/Types.h>
|
2019-09-03 19:14:42 +00:00
|
|
|
|
|
|
|
#ifdef __serenity__
|
|
|
|
# include <LibC/fd_set.h>
|
|
|
|
#endif
|
2018-10-22 11:55:11 +00:00
|
|
|
|
2019-06-07 15:13:23 +00:00
|
|
|
extern "C" {
|
|
|
|
struct timeval;
|
2019-11-02 18:34:06 +00:00
|
|
|
struct timespec;
|
2019-11-10 14:32:59 +00:00
|
|
|
struct sockaddr;
|
|
|
|
typedef u32 socklen_t;
|
2019-06-07 15:13:23 +00:00
|
|
|
}
|
2019-06-07 09:52:27 +00:00
|
|
|
|
2019-12-11 19:36:56 +00:00
|
|
|
#define ENUMERATE_SYSCALLS \
|
|
|
|
__ENUMERATE_SYSCALL(sleep) \
|
|
|
|
__ENUMERATE_SYSCALL(yield) \
|
|
|
|
__ENUMERATE_SYSCALL(open) \
|
|
|
|
__ENUMERATE_SYSCALL(close) \
|
|
|
|
__ENUMERATE_SYSCALL(read) \
|
|
|
|
__ENUMERATE_SYSCALL(lseek) \
|
|
|
|
__ENUMERATE_SYSCALL(kill) \
|
|
|
|
__ENUMERATE_SYSCALL(getuid) \
|
|
|
|
__ENUMERATE_SYSCALL(exit) \
|
|
|
|
__ENUMERATE_SYSCALL(getgid) \
|
|
|
|
__ENUMERATE_SYSCALL(getpid) \
|
|
|
|
__ENUMERATE_SYSCALL(waitpid) \
|
|
|
|
__ENUMERATE_SYSCALL(mmap) \
|
|
|
|
__ENUMERATE_SYSCALL(munmap) \
|
|
|
|
__ENUMERATE_SYSCALL(get_dir_entries) \
|
|
|
|
__ENUMERATE_SYSCALL(lstat) \
|
|
|
|
__ENUMERATE_SYSCALL(getcwd) \
|
|
|
|
__ENUMERATE_SYSCALL(gettimeofday) \
|
|
|
|
__ENUMERATE_SYSCALL(gethostname) \
|
|
|
|
__ENUMERATE_SYSCALL(chdir) \
|
|
|
|
__ENUMERATE_SYSCALL(uname) \
|
|
|
|
__ENUMERATE_SYSCALL(set_mmap_name) \
|
|
|
|
__ENUMERATE_SYSCALL(readlink) \
|
|
|
|
__ENUMERATE_SYSCALL(write) \
|
|
|
|
__ENUMERATE_SYSCALL(ttyname_r) \
|
|
|
|
__ENUMERATE_SYSCALL(stat) \
|
|
|
|
__ENUMERATE_SYSCALL(getsid) \
|
|
|
|
__ENUMERATE_SYSCALL(setsid) \
|
|
|
|
__ENUMERATE_SYSCALL(getpgid) \
|
|
|
|
__ENUMERATE_SYSCALL(setpgid) \
|
|
|
|
__ENUMERATE_SYSCALL(getpgrp) \
|
|
|
|
__ENUMERATE_SYSCALL(fork) \
|
|
|
|
__ENUMERATE_SYSCALL(execve) \
|
|
|
|
__ENUMERATE_SYSCALL(geteuid) \
|
|
|
|
__ENUMERATE_SYSCALL(getegid) \
|
|
|
|
__ENUMERATE_SYSCALL(getdtablesize) \
|
|
|
|
__ENUMERATE_SYSCALL(dup) \
|
|
|
|
__ENUMERATE_SYSCALL(dup2) \
|
|
|
|
__ENUMERATE_SYSCALL(sigaction) \
|
|
|
|
__ENUMERATE_SYSCALL(getppid) \
|
|
|
|
__ENUMERATE_SYSCALL(umask) \
|
|
|
|
__ENUMERATE_SYSCALL(getgroups) \
|
|
|
|
__ENUMERATE_SYSCALL(setgroups) \
|
|
|
|
__ENUMERATE_SYSCALL(sigreturn) \
|
|
|
|
__ENUMERATE_SYSCALL(sigprocmask) \
|
|
|
|
__ENUMERATE_SYSCALL(sigpending) \
|
|
|
|
__ENUMERATE_SYSCALL(pipe) \
|
|
|
|
__ENUMERATE_SYSCALL(killpg) \
|
|
|
|
__ENUMERATE_SYSCALL(setuid) \
|
|
|
|
__ENUMERATE_SYSCALL(setgid) \
|
|
|
|
__ENUMERATE_SYSCALL(alarm) \
|
|
|
|
__ENUMERATE_SYSCALL(fstat) \
|
|
|
|
__ENUMERATE_SYSCALL(access) \
|
|
|
|
__ENUMERATE_SYSCALL(fcntl) \
|
|
|
|
__ENUMERATE_SYSCALL(ioctl) \
|
|
|
|
__ENUMERATE_SYSCALL(mkdir) \
|
|
|
|
__ENUMERATE_SYSCALL(times) \
|
|
|
|
__ENUMERATE_SYSCALL(utime) \
|
|
|
|
__ENUMERATE_SYSCALL(sync) \
|
|
|
|
__ENUMERATE_SYSCALL(ptsname_r) \
|
|
|
|
__ENUMERATE_SYSCALL(select) \
|
|
|
|
__ENUMERATE_SYSCALL(unlink) \
|
|
|
|
__ENUMERATE_SYSCALL(poll) \
|
|
|
|
__ENUMERATE_SYSCALL(rmdir) \
|
|
|
|
__ENUMERATE_SYSCALL(chmod) \
|
|
|
|
__ENUMERATE_SYSCALL(usleep) \
|
|
|
|
__ENUMERATE_SYSCALL(socket) \
|
|
|
|
__ENUMERATE_SYSCALL(bind) \
|
|
|
|
__ENUMERATE_SYSCALL(accept) \
|
|
|
|
__ENUMERATE_SYSCALL(listen) \
|
|
|
|
__ENUMERATE_SYSCALL(connect) \
|
|
|
|
__ENUMERATE_SYSCALL(create_shared_buffer) \
|
|
|
|
__ENUMERATE_SYSCALL(share_buffer_with) \
|
|
|
|
__ENUMERATE_SYSCALL(get_shared_buffer) \
|
|
|
|
__ENUMERATE_SYSCALL(release_shared_buffer) \
|
|
|
|
__ENUMERATE_SYSCALL(link) \
|
|
|
|
__ENUMERATE_SYSCALL(chown) \
|
|
|
|
__ENUMERATE_SYSCALL(fchmod) \
|
|
|
|
__ENUMERATE_SYSCALL(symlink) \
|
|
|
|
__ENUMERATE_SYSCALL(get_shared_buffer_size) \
|
|
|
|
__ENUMERATE_SYSCALL(seal_shared_buffer) \
|
|
|
|
__ENUMERATE_SYSCALL(sendto) \
|
|
|
|
__ENUMERATE_SYSCALL(recvfrom) \
|
|
|
|
__ENUMERATE_SYSCALL(getsockopt) \
|
|
|
|
__ENUMERATE_SYSCALL(setsockopt) \
|
|
|
|
__ENUMERATE_SYSCALL(create_thread) \
|
|
|
|
__ENUMERATE_SYSCALL(gettid) \
|
|
|
|
__ENUMERATE_SYSCALL(donate) \
|
|
|
|
__ENUMERATE_SYSCALL(rename) \
|
|
|
|
__ENUMERATE_SYSCALL(ftruncate) \
|
|
|
|
__ENUMERATE_SYSCALL(systrace) \
|
|
|
|
__ENUMERATE_SYSCALL(exit_thread) \
|
|
|
|
__ENUMERATE_SYSCALL(mknod) \
|
|
|
|
__ENUMERATE_SYSCALL(writev) \
|
|
|
|
__ENUMERATE_SYSCALL(beep) \
|
|
|
|
__ENUMERATE_SYSCALL(getsockname) \
|
|
|
|
__ENUMERATE_SYSCALL(getpeername) \
|
|
|
|
__ENUMERATE_SYSCALL(sched_setparam) \
|
|
|
|
__ENUMERATE_SYSCALL(sched_getparam) \
|
|
|
|
__ENUMERATE_SYSCALL(fchown) \
|
|
|
|
__ENUMERATE_SYSCALL(halt) \
|
|
|
|
__ENUMERATE_SYSCALL(reboot) \
|
|
|
|
__ENUMERATE_SYSCALL(mount) \
|
|
|
|
__ENUMERATE_SYSCALL(umount) \
|
|
|
|
__ENUMERATE_SYSCALL(dump_backtrace) \
|
|
|
|
__ENUMERATE_SYSCALL(dbgputch) \
|
|
|
|
__ENUMERATE_SYSCALL(dbgputstr) \
|
|
|
|
__ENUMERATE_SYSCALL(watch_file) \
|
|
|
|
__ENUMERATE_SYSCALL(share_buffer_globally) \
|
|
|
|
__ENUMERATE_SYSCALL(set_process_icon) \
|
|
|
|
__ENUMERATE_SYSCALL(mprotect) \
|
|
|
|
__ENUMERATE_SYSCALL(realpath) \
|
|
|
|
__ENUMERATE_SYSCALL(get_process_name) \
|
|
|
|
__ENUMERATE_SYSCALL(fchdir) \
|
|
|
|
__ENUMERATE_SYSCALL(getrandom) \
|
|
|
|
__ENUMERATE_SYSCALL(setkeymap) \
|
|
|
|
__ENUMERATE_SYSCALL(clock_gettime) \
|
|
|
|
__ENUMERATE_SYSCALL(clock_nanosleep) \
|
|
|
|
__ENUMERATE_SYSCALL(join_thread) \
|
|
|
|
__ENUMERATE_SYSCALL(module_load) \
|
|
|
|
__ENUMERATE_SYSCALL(module_unload) \
|
|
|
|
__ENUMERATE_SYSCALL(detach_thread) \
|
|
|
|
__ENUMERATE_SYSCALL(set_thread_name) \
|
|
|
|
__ENUMERATE_SYSCALL(get_thread_name) \
|
|
|
|
__ENUMERATE_SYSCALL(madvise) \
|
|
|
|
__ENUMERATE_SYSCALL(purge) \
|
|
|
|
__ENUMERATE_SYSCALL(set_shared_buffer_volatile) \
|
|
|
|
__ENUMERATE_SYSCALL(profiling_enable) \
|
2019-12-15 20:29:26 +00:00
|
|
|
__ENUMERATE_SYSCALL(profiling_disable) \
|
2019-12-22 20:29:47 +00:00
|
|
|
__ENUMERATE_SYSCALL(get_kernel_info_page) \
|
2019-12-30 18:23:13 +00:00
|
|
|
__ENUMERATE_SYSCALL(futex) \
|
2019-12-30 19:10:00 +00:00
|
|
|
__ENUMERATE_SYSCALL(set_thread_boost) \
|
2020-01-10 22:14:04 +00:00
|
|
|
__ENUMERATE_SYSCALL(set_process_boost) \
|
2020-01-11 19:48:43 +00:00
|
|
|
__ENUMERATE_SYSCALL(chroot) \
|
|
|
|
__ENUMERATE_SYSCALL(pledge)
|
2018-11-06 12:23:22 +00:00
|
|
|
|
2018-10-16 09:01:38 +00:00
|
|
|
namespace Syscall {
|
|
|
|
|
2019-06-07 15:13:23 +00:00
|
|
|
enum Function {
|
2018-11-06 12:23:22 +00:00
|
|
|
#undef __ENUMERATE_SYSCALL
|
2019-11-17 19:01:03 +00:00
|
|
|
#undef __ENUMERATE_REMOVED_SYSCALL
|
|
|
|
#define __ENUMERATE_REMOVED_SYSCALL(x) SC_##x,
|
2019-05-28 09:53:16 +00:00
|
|
|
#define __ENUMERATE_SYSCALL(x) SC_##x,
|
2018-11-06 12:23:22 +00:00
|
|
|
ENUMERATE_SYSCALLS
|
|
|
|
#undef __ENUMERATE_SYSCALL
|
2019-11-17 19:01:03 +00:00
|
|
|
#undef __ENUMERATE_REMOVED_SYSCALL
|
2019-11-09 21:18:16 +00:00
|
|
|
__Count
|
2018-10-16 09:01:38 +00:00
|
|
|
};
|
|
|
|
|
2019-01-31 16:31:23 +00:00
|
|
|
inline constexpr const char* to_string(Function function)
|
2018-11-06 12:23:22 +00:00
|
|
|
{
|
|
|
|
switch (function) {
|
|
|
|
#undef __ENUMERATE_SYSCALL
|
2019-11-17 19:01:03 +00:00
|
|
|
#undef __ENUMERATE_REMOVED_SYSCALL
|
|
|
|
#define __ENUMERATE_REMOVED_SYSCALL(x) \
|
|
|
|
case SC_##x: \
|
|
|
|
return #x " (removed)";
|
2019-05-28 09:53:16 +00:00
|
|
|
#define __ENUMERATE_SYSCALL(x) \
|
|
|
|
case SC_##x: \
|
|
|
|
return #x;
|
|
|
|
ENUMERATE_SYSCALLS
|
2018-11-06 12:23:22 +00:00
|
|
|
#undef __ENUMERATE_SYSCALL
|
2019-11-17 19:01:03 +00:00
|
|
|
#undef __ENUMERATE_REMOVED_SYSCALL
|
2019-11-09 21:18:16 +00:00
|
|
|
default:
|
|
|
|
break;
|
2018-11-06 12:23:22 +00:00
|
|
|
}
|
2018-11-07 20:19:47 +00:00
|
|
|
return "Unknown";
|
2018-11-06 12:23:22 +00:00
|
|
|
}
|
|
|
|
|
2019-04-20 10:58:02 +00:00
|
|
|
#ifdef __serenity__
|
2020-01-11 11:47:47 +00:00
|
|
|
struct StringArgument {
|
|
|
|
const char* characters { nullptr };
|
|
|
|
size_t length { 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename DataType, typename SizeType>
|
|
|
|
struct MutableBufferArgument {
|
|
|
|
DataType* data { nullptr };
|
|
|
|
SizeType size { 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename DataType, typename SizeType>
|
|
|
|
struct ImmutableBufferArgument {
|
|
|
|
const DataType* data { nullptr };
|
|
|
|
SizeType size { 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
struct StringListArgument {
|
|
|
|
StringArgument* strings { nullptr };
|
|
|
|
size_t length { 0 };
|
|
|
|
};
|
|
|
|
|
2018-11-08 10:37:01 +00:00
|
|
|
struct SC_mmap_params {
|
|
|
|
uint32_t addr;
|
|
|
|
uint32_t size;
|
|
|
|
int32_t prot;
|
|
|
|
int32_t flags;
|
|
|
|
int32_t fd;
|
2018-11-09 09:09:46 +00:00
|
|
|
int32_t offset; // FIXME: 64-bit off_t?
|
2020-01-11 11:47:47 +00:00
|
|
|
StringArgument name;
|
2018-11-08 10:37:01 +00:00
|
|
|
};
|
|
|
|
|
2019-07-08 18:01:49 +00:00
|
|
|
struct SC_open_params {
|
2019-11-10 12:47:02 +00:00
|
|
|
int dirfd;
|
2020-01-11 11:47:47 +00:00
|
|
|
StringArgument path;
|
2019-11-10 12:47:02 +00:00
|
|
|
int options;
|
|
|
|
u16 mode;
|
|
|
|
};
|
|
|
|
|
2019-01-15 22:12:20 +00:00
|
|
|
struct SC_select_params {
|
|
|
|
int nfds;
|
|
|
|
fd_set* readfds;
|
|
|
|
fd_set* writefds;
|
|
|
|
fd_set* exceptfds;
|
|
|
|
struct timeval* timeout;
|
|
|
|
};
|
|
|
|
|
2019-11-02 18:34:06 +00:00
|
|
|
struct SC_clock_nanosleep_params {
|
|
|
|
int clock_id;
|
|
|
|
int flags;
|
|
|
|
const struct timespec* requested_sleep;
|
|
|
|
struct timespec* remaining_sleep;
|
|
|
|
};
|
|
|
|
|
2019-03-12 14:51:42 +00:00
|
|
|
struct SC_sendto_params {
|
|
|
|
int sockfd;
|
2020-01-11 11:47:47 +00:00
|
|
|
ImmutableBufferArgument<void, size_t> data;
|
2019-03-12 14:51:42 +00:00
|
|
|
int flags;
|
2019-11-10 14:32:59 +00:00
|
|
|
const sockaddr* addr;
|
|
|
|
socklen_t addr_length;
|
2019-03-12 14:51:42 +00:00
|
|
|
};
|
|
|
|
|
2019-03-12 16:27:07 +00:00
|
|
|
struct SC_recvfrom_params {
|
|
|
|
int sockfd;
|
2020-01-11 11:47:47 +00:00
|
|
|
MutableBufferArgument<void, size_t> buffer;
|
2019-03-12 16:27:07 +00:00
|
|
|
int flags;
|
2019-11-10 14:32:59 +00:00
|
|
|
sockaddr* addr;
|
|
|
|
socklen_t* addr_length;
|
2019-03-12 16:27:07 +00:00
|
|
|
};
|
|
|
|
|
2019-03-13 12:13:23 +00:00
|
|
|
struct SC_getsockopt_params {
|
|
|
|
int sockfd;
|
|
|
|
int level;
|
|
|
|
int option;
|
|
|
|
void* value;
|
2019-11-10 14:32:59 +00:00
|
|
|
socklen_t* value_size;
|
2019-03-13 12:13:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_setsockopt_params {
|
|
|
|
int sockfd;
|
|
|
|
int level;
|
|
|
|
int option;
|
|
|
|
const void* value;
|
2019-11-10 14:32:59 +00:00
|
|
|
socklen_t value_size;
|
2019-03-13 12:13:23 +00:00
|
|
|
};
|
|
|
|
|
2019-12-22 20:29:47 +00:00
|
|
|
struct SC_futex_params {
|
|
|
|
i32* userspace_address;
|
|
|
|
int futex_op;
|
|
|
|
i32 val;
|
|
|
|
const timespec* timeout;
|
|
|
|
};
|
|
|
|
|
2019-12-31 12:37:38 +00:00
|
|
|
struct SC_setkeymap_params {
|
|
|
|
const char* map;
|
|
|
|
const char* shift_map;
|
|
|
|
const char* alt_map;
|
|
|
|
const char* altgr_map;
|
|
|
|
};
|
|
|
|
|
2019-11-18 03:08:10 +00:00
|
|
|
struct SC_create_thread_params {
|
|
|
|
unsigned int m_detach_state = 0; // JOINABLE or DETACHED
|
2019-12-30 17:46:17 +00:00
|
|
|
int m_schedule_priority = 30; // THREAD_PRIORITY_NORMAL
|
2019-11-18 03:08:10 +00:00
|
|
|
// FIXME: Implment guard pages in create_thread (unreadable pages at "overflow" end of stack)
|
|
|
|
// "If an implementation rounds up the value of guardsize to a multiple of {PAGESIZE},
|
|
|
|
// a call to pthread_attr_getguardsize() specifying attr shall store in the guardsize
|
|
|
|
// parameter the guard size specified by the previous pthread_attr_setguardsize() function call"
|
|
|
|
// ... ok, if you say so posix. Guess we get to lie to people about guard page size
|
|
|
|
unsigned int m_guard_page_size = 0; // Rounded up to PAGE_SIZE
|
|
|
|
unsigned int m_reported_guard_page_size = 0; // The lie we tell callers
|
|
|
|
unsigned int m_stack_size = 4 * MB; // Default PTHREAD_STACK_MIN
|
|
|
|
void* m_stack_location = nullptr; // nullptr means any, o.w. process virtual address
|
|
|
|
};
|
|
|
|
|
2020-01-06 10:32:25 +00:00
|
|
|
struct SC_realpath_params {
|
2020-01-11 11:47:47 +00:00
|
|
|
StringArgument path;
|
|
|
|
MutableBufferArgument<char, size_t> buffer;
|
2020-01-06 10:32:25 +00:00
|
|
|
};
|
|
|
|
|
2020-01-06 10:56:59 +00:00
|
|
|
struct SC_set_mmap_name_params {
|
|
|
|
void* addr;
|
|
|
|
size_t size;
|
2020-01-11 11:47:47 +00:00
|
|
|
StringArgument name;
|
2020-01-10 11:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_execve_params {
|
2020-01-10 19:15:58 +00:00
|
|
|
StringArgument path;
|
2020-01-11 11:47:47 +00:00
|
|
|
StringListArgument arguments;
|
|
|
|
StringListArgument environment;
|
2020-01-10 11:20:36 +00:00
|
|
|
};
|
|
|
|
|
2020-01-10 19:13:23 +00:00
|
|
|
struct SC_readlink_params {
|
2020-01-10 19:15:58 +00:00
|
|
|
StringArgument path;
|
2020-01-10 19:13:23 +00:00
|
|
|
MutableBufferArgument<char, size_t> buffer;
|
|
|
|
};
|
|
|
|
|
2020-01-10 20:26:47 +00:00
|
|
|
struct SC_link_params {
|
|
|
|
StringArgument old_path;
|
|
|
|
StringArgument new_path;
|
|
|
|
};
|
|
|
|
|
2020-01-11 09:17:08 +00:00
|
|
|
struct SC_chown_params {
|
2020-01-11 15:25:26 +00:00
|
|
|
StringArgument path;
|
|
|
|
u32 uid;
|
|
|
|
u32 gid;
|
2020-01-11 09:17:08 +00:00
|
|
|
};
|
|
|
|
|
2020-01-11 09:27:37 +00:00
|
|
|
struct SC_mknod_params {
|
|
|
|
StringArgument path;
|
|
|
|
u16 mode;
|
|
|
|
u32 dev;
|
|
|
|
};
|
|
|
|
|
2020-01-11 09:31:33 +00:00
|
|
|
struct SC_symlink_params {
|
|
|
|
StringArgument target;
|
|
|
|
StringArgument linkpath;
|
|
|
|
};
|
|
|
|
|
2020-01-11 09:36:54 +00:00
|
|
|
struct SC_rename_params {
|
|
|
|
StringArgument old_path;
|
|
|
|
StringArgument new_path;
|
|
|
|
};
|
|
|
|
|
2020-01-11 09:46:21 +00:00
|
|
|
struct SC_mount_params {
|
|
|
|
StringArgument source;
|
|
|
|
StringArgument target;
|
|
|
|
StringArgument fs_type;
|
2020-01-11 15:25:26 +00:00
|
|
|
int flags;
|
2020-01-11 09:46:21 +00:00
|
|
|
};
|
|
|
|
|
2020-01-11 19:48:43 +00:00
|
|
|
struct SC_pledge_params {
|
|
|
|
StringArgument promises;
|
|
|
|
StringArgument execpromises;
|
|
|
|
};
|
|
|
|
|
2018-10-16 09:01:38 +00:00
|
|
|
void initialize();
|
2018-12-20 01:41:55 +00:00
|
|
|
int sync();
|
2018-10-18 11:05:00 +00:00
|
|
|
|
2019-07-03 19:17:35 +00:00
|
|
|
inline u32 invoke(Function function)
|
2018-10-18 11:05:00 +00:00
|
|
|
{
|
2019-07-03 19:17:35 +00:00
|
|
|
u32 result;
|
2019-05-28 09:53:16 +00:00
|
|
|
asm volatile("int $0x82"
|
|
|
|
: "=a"(result)
|
|
|
|
: "a"(function)
|
|
|
|
: "memory");
|
2018-10-18 11:05:00 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-12-21 02:02:06 +00:00
|
|
|
template<typename T1>
|
2019-07-03 19:17:35 +00:00
|
|
|
inline u32 invoke(Function function, T1 arg1)
|
2018-10-18 11:05:00 +00:00
|
|
|
{
|
2019-07-03 19:17:35 +00:00
|
|
|
u32 result;
|
2019-05-28 09:53:16 +00:00
|
|
|
asm volatile("int $0x82"
|
|
|
|
: "=a"(result)
|
2019-07-03 19:17:35 +00:00
|
|
|
: "a"(function), "d"((u32)arg1)
|
2019-05-28 09:53:16 +00:00
|
|
|
: "memory");
|
2018-10-18 11:05:00 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-12-21 02:02:06 +00:00
|
|
|
template<typename T1, typename T2>
|
2019-07-03 19:17:35 +00:00
|
|
|
inline u32 invoke(Function function, T1 arg1, T2 arg2)
|
2018-10-18 11:05:00 +00:00
|
|
|
{
|
2019-07-03 19:17:35 +00:00
|
|
|
u32 result;
|
2019-05-28 09:53:16 +00:00
|
|
|
asm volatile("int $0x82"
|
|
|
|
: "=a"(result)
|
2019-07-03 19:17:35 +00:00
|
|
|
: "a"(function), "d"((u32)arg1), "c"((u32)arg2)
|
2019-05-28 09:53:16 +00:00
|
|
|
: "memory");
|
2018-10-18 11:05:00 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-12-21 02:02:06 +00:00
|
|
|
template<typename T1, typename T2, typename T3>
|
2019-07-03 19:17:35 +00:00
|
|
|
inline u32 invoke(Function function, T1 arg1, T2 arg2, T3 arg3)
|
2018-10-18 11:05:00 +00:00
|
|
|
{
|
2019-07-03 19:17:35 +00:00
|
|
|
u32 result;
|
2019-05-28 09:53:16 +00:00
|
|
|
asm volatile("int $0x82"
|
|
|
|
: "=a"(result)
|
2019-07-03 19:17:35 +00:00
|
|
|
: "a"(function), "d"((u32)arg1), "c"((u32)arg2), "b"((u32)arg3)
|
2019-05-28 09:53:16 +00:00
|
|
|
: "memory");
|
2018-10-18 11:05:00 +00:00
|
|
|
return result;
|
|
|
|
}
|
2019-01-25 04:19:29 +00:00
|
|
|
#endif
|
2018-10-16 09:01:38 +00:00
|
|
|
|
|
|
|
}
|
2018-12-21 02:02:06 +00:00
|
|
|
|
|
|
|
#undef __ENUMERATE_SYSCALL
|
2019-05-28 09:53:16 +00:00
|
|
|
#define __ENUMERATE_SYSCALL(x) using Syscall::SC_##x;
|
2019-11-17 19:01:03 +00:00
|
|
|
#define __ENUMERATE_REMOVED_SYSCALL(x)
|
2019-05-28 09:53:16 +00:00
|
|
|
ENUMERATE_SYSCALLS
|
2018-12-21 02:02:06 +00:00
|
|
|
#undef __ENUMERATE_SYSCALL
|
2019-11-17 19:01:03 +00:00
|
|
|
#undef __ENUMERATE_REMOVED_SYSCALL
|
2018-12-21 02:02:06 +00:00
|
|
|
#define syscall Syscall::invoke
|