2020-01-18 11:38:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2018-10-16 12:01:38 +03:00
|
|
|
#pragma once
|
|
|
|
|
2018-10-22 14:55:11 +03:00
|
|
|
#include <AK/Types.h>
|
2020-07-31 17:28:37 +03:00
|
|
|
#include <AK/Userspace.h>
|
2019-09-03 22:14:42 +03:00
|
|
|
|
|
|
|
#ifdef __serenity__
|
|
|
|
# include <LibC/fd_set.h>
|
|
|
|
#endif
|
2018-10-22 14:55:11 +03:00
|
|
|
|
2020-03-14 21:19:38 +03:00
|
|
|
constexpr int syscall_vector = 0x82;
|
|
|
|
|
2019-06-07 18:13:23 +03:00
|
|
|
extern "C" {
|
2020-06-22 18:41:51 +03:00
|
|
|
struct pollfd;
|
2019-06-07 18:13:23 +03:00
|
|
|
struct timeval;
|
2019-11-02 21:34:06 +03:00
|
|
|
struct timespec;
|
2019-11-10 17:32:59 +03:00
|
|
|
struct sockaddr;
|
2020-02-05 19:42:43 +03:00
|
|
|
struct siginfo;
|
2020-08-11 19:57:18 +03:00
|
|
|
struct stat;
|
2019-11-10 17:32:59 +03:00
|
|
|
typedef u32 socklen_t;
|
2019-06-07 18:13:23 +03:00
|
|
|
}
|
2019-06-07 12:52:27 +03:00
|
|
|
|
2020-02-16 03:27:42 +03:00
|
|
|
namespace Kernel {
|
|
|
|
|
2021-05-12 22:17:51 +03:00
|
|
|
#define ENUMERATE_SYSCALLS(S) \
|
|
|
|
S(yield) \
|
|
|
|
S(open) \
|
|
|
|
S(close) \
|
|
|
|
S(read) \
|
|
|
|
S(lseek) \
|
|
|
|
S(kill) \
|
|
|
|
S(getuid) \
|
|
|
|
S(exit) \
|
|
|
|
S(geteuid) \
|
|
|
|
S(getegid) \
|
|
|
|
S(getgid) \
|
|
|
|
S(getpid) \
|
|
|
|
S(getppid) \
|
|
|
|
S(getresuid) \
|
|
|
|
S(getresgid) \
|
|
|
|
S(waitid) \
|
|
|
|
S(mmap) \
|
|
|
|
S(munmap) \
|
|
|
|
S(get_dir_entries) \
|
|
|
|
S(getcwd) \
|
|
|
|
S(gettimeofday) \
|
|
|
|
S(gethostname) \
|
|
|
|
S(sethostname) \
|
|
|
|
S(chdir) \
|
|
|
|
S(uname) \
|
|
|
|
S(set_mmap_name) \
|
|
|
|
S(readlink) \
|
|
|
|
S(write) \
|
|
|
|
S(ttyname) \
|
|
|
|
S(stat) \
|
|
|
|
S(getsid) \
|
|
|
|
S(setsid) \
|
|
|
|
S(getpgid) \
|
|
|
|
S(setpgid) \
|
|
|
|
S(getpgrp) \
|
|
|
|
S(fork) \
|
|
|
|
S(execve) \
|
|
|
|
S(dup2) \
|
|
|
|
S(sigaction) \
|
|
|
|
S(umask) \
|
|
|
|
S(getgroups) \
|
|
|
|
S(setgroups) \
|
|
|
|
S(sigreturn) \
|
|
|
|
S(sigprocmask) \
|
|
|
|
S(sigpending) \
|
|
|
|
S(pipe) \
|
|
|
|
S(killpg) \
|
|
|
|
S(seteuid) \
|
|
|
|
S(setegid) \
|
|
|
|
S(setuid) \
|
|
|
|
S(setgid) \
|
|
|
|
S(setreuid) \
|
|
|
|
S(setresuid) \
|
|
|
|
S(setresgid) \
|
|
|
|
S(alarm) \
|
|
|
|
S(fstat) \
|
|
|
|
S(access) \
|
|
|
|
S(fcntl) \
|
|
|
|
S(ioctl) \
|
|
|
|
S(mkdir) \
|
|
|
|
S(times) \
|
|
|
|
S(utime) \
|
|
|
|
S(sync) \
|
|
|
|
S(ptsname) \
|
|
|
|
S(select) \
|
|
|
|
S(unlink) \
|
|
|
|
S(poll) \
|
|
|
|
S(rmdir) \
|
|
|
|
S(chmod) \
|
|
|
|
S(socket) \
|
|
|
|
S(bind) \
|
|
|
|
S(accept) \
|
|
|
|
S(listen) \
|
|
|
|
S(connect) \
|
|
|
|
S(link) \
|
|
|
|
S(chown) \
|
|
|
|
S(fchmod) \
|
|
|
|
S(symlink) \
|
|
|
|
S(sendmsg) \
|
|
|
|
S(recvmsg) \
|
|
|
|
S(getsockopt) \
|
|
|
|
S(setsockopt) \
|
|
|
|
S(create_thread) \
|
|
|
|
S(gettid) \
|
|
|
|
S(donate) \
|
|
|
|
S(rename) \
|
|
|
|
S(ftruncate) \
|
|
|
|
S(exit_thread) \
|
|
|
|
S(mknod) \
|
|
|
|
S(writev) \
|
|
|
|
S(beep) \
|
|
|
|
S(getsockname) \
|
|
|
|
S(getpeername) \
|
|
|
|
S(socketpair) \
|
|
|
|
S(sched_setparam) \
|
|
|
|
S(sched_getparam) \
|
|
|
|
S(fchown) \
|
|
|
|
S(halt) \
|
|
|
|
S(reboot) \
|
|
|
|
S(mount) \
|
|
|
|
S(umount) \
|
|
|
|
S(dump_backtrace) \
|
|
|
|
S(dbgputch) \
|
|
|
|
S(dbgputstr) \
|
|
|
|
S(create_inode_watcher) \
|
|
|
|
S(inode_watcher_add_watch) \
|
|
|
|
S(inode_watcher_remove_watch) \
|
|
|
|
S(mprotect) \
|
|
|
|
S(realpath) \
|
|
|
|
S(get_process_name) \
|
|
|
|
S(fchdir) \
|
|
|
|
S(getrandom) \
|
|
|
|
S(getkeymap) \
|
|
|
|
S(setkeymap) \
|
|
|
|
S(clock_gettime) \
|
|
|
|
S(clock_settime) \
|
|
|
|
S(clock_nanosleep) \
|
|
|
|
S(join_thread) \
|
|
|
|
S(module_load) \
|
|
|
|
S(module_unload) \
|
|
|
|
S(detach_thread) \
|
|
|
|
S(set_thread_name) \
|
|
|
|
S(get_thread_name) \
|
|
|
|
S(madvise) \
|
|
|
|
S(purge) \
|
|
|
|
S(profiling_enable) \
|
|
|
|
S(profiling_disable) \
|
|
|
|
S(profiling_free_buffer) \
|
|
|
|
S(futex) \
|
|
|
|
S(chroot) \
|
|
|
|
S(pledge) \
|
|
|
|
S(unveil) \
|
|
|
|
S(perf_event) \
|
|
|
|
S(shutdown) \
|
|
|
|
S(get_stack_bounds) \
|
|
|
|
S(ptrace) \
|
|
|
|
S(sendfd) \
|
|
|
|
S(recvfd) \
|
|
|
|
S(sysconf) \
|
|
|
|
S(set_process_name) \
|
|
|
|
S(disown) \
|
|
|
|
S(adjtime) \
|
|
|
|
S(allocate_tls) \
|
|
|
|
S(prctl) \
|
|
|
|
S(mremap) \
|
|
|
|
S(set_coredump_metadata) \
|
|
|
|
S(anon_create) \
|
|
|
|
S(msyscall) \
|
|
|
|
S(readv) \
|
2021-03-09 10:16:00 +03:00
|
|
|
S(emuctl)
|
2018-11-06 15:23:22 +03:00
|
|
|
|
2018-10-16 12:01:38 +03:00
|
|
|
namespace Syscall {
|
|
|
|
|
2020-03-22 03:12:45 +03:00
|
|
|
enum Function {
|
2018-11-06 15:23:22 +03:00
|
|
|
#undef __ENUMERATE_SYSCALL
|
2019-05-28 12:53:16 +03:00
|
|
|
#define __ENUMERATE_SYSCALL(x) SC_##x,
|
2020-08-04 14:00:50 +03:00
|
|
|
ENUMERATE_SYSCALLS(__ENUMERATE_SYSCALL)
|
2018-11-06 15:23:22 +03:00
|
|
|
#undef __ENUMERATE_SYSCALL
|
2020-03-22 03:12:45 +03:00
|
|
|
__Count
|
|
|
|
};
|
2018-10-16 12:01:38 +03:00
|
|
|
|
2020-10-20 19:08:13 +03:00
|
|
|
constexpr const char* to_string(Function function)
|
2020-03-22 03:12:45 +03:00
|
|
|
{
|
|
|
|
switch (function) {
|
2018-11-06 15:23:22 +03:00
|
|
|
#undef __ENUMERATE_SYSCALL
|
2019-05-28 12:53:16 +03:00
|
|
|
#define __ENUMERATE_SYSCALL(x) \
|
|
|
|
case SC_##x: \
|
|
|
|
return #x;
|
2020-08-04 14:00:50 +03:00
|
|
|
ENUMERATE_SYSCALLS(__ENUMERATE_SYSCALL)
|
2018-11-06 15:23:22 +03:00
|
|
|
#undef __ENUMERATE_SYSCALL
|
2020-03-22 03:12:45 +03:00
|
|
|
default:
|
|
|
|
break;
|
2018-11-06 15:23:22 +03:00
|
|
|
}
|
2020-03-22 03:12:45 +03:00
|
|
|
return "Unknown";
|
|
|
|
}
|
2018-11-06 15:23:22 +03:00
|
|
|
|
2019-04-20 13:58:02 +03:00
|
|
|
#ifdef __serenity__
|
2020-03-22 03:12:45 +03:00
|
|
|
struct StringArgument {
|
2020-09-12 06:11:07 +03:00
|
|
|
const char* characters;
|
2020-03-22 03:12:45 +03:00
|
|
|
size_t length { 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename DataType, typename SizeType>
|
|
|
|
struct MutableBufferArgument {
|
|
|
|
DataType* data { nullptr };
|
|
|
|
SizeType size { 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
struct StringListArgument {
|
2020-09-12 06:11:07 +03:00
|
|
|
StringArgument* strings {};
|
2020-03-22 03:12:45 +03:00
|
|
|
size_t length { 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_mmap_params {
|
2020-10-12 15:49:31 +03:00
|
|
|
uintptr_t addr;
|
|
|
|
size_t size;
|
|
|
|
size_t alignment;
|
2020-03-22 03:12:45 +03:00
|
|
|
int32_t prot;
|
|
|
|
int32_t flags;
|
|
|
|
int32_t fd;
|
2021-03-14 00:02:54 +03:00
|
|
|
int64_t offset;
|
2020-03-22 03:12:45 +03:00
|
|
|
StringArgument name;
|
|
|
|
};
|
|
|
|
|
2020-12-29 04:11:47 +03:00
|
|
|
struct SC_mremap_params {
|
|
|
|
uintptr_t old_address;
|
|
|
|
size_t old_size;
|
|
|
|
size_t new_size;
|
|
|
|
int32_t flags;
|
|
|
|
};
|
|
|
|
|
2020-03-22 03:12:45 +03:00
|
|
|
struct SC_open_params {
|
|
|
|
int dirfd;
|
|
|
|
StringArgument path;
|
|
|
|
int options;
|
|
|
|
u16 mode;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_select_params {
|
|
|
|
int nfds;
|
|
|
|
fd_set* readfds;
|
|
|
|
fd_set* writefds;
|
|
|
|
fd_set* exceptfds;
|
2020-06-21 20:54:41 +03:00
|
|
|
const struct timespec* timeout;
|
|
|
|
const u32* sigmask;
|
2020-03-22 03:12:45 +03:00
|
|
|
};
|
|
|
|
|
2020-06-22 18:41:51 +03:00
|
|
|
struct SC_poll_params {
|
|
|
|
struct pollfd* fds;
|
|
|
|
unsigned nfds;
|
2020-09-12 06:11:07 +03:00
|
|
|
const struct timespec* timeout;
|
|
|
|
const u32* sigmask;
|
2020-06-22 18:41:51 +03:00
|
|
|
};
|
|
|
|
|
2020-03-22 03:12:45 +03:00
|
|
|
struct SC_clock_nanosleep_params {
|
|
|
|
int clock_id;
|
|
|
|
int flags;
|
2020-09-12 06:11:07 +03:00
|
|
|
const struct timespec* requested_sleep;
|
|
|
|
struct timespec* remaining_sleep;
|
2020-03-22 03:12:45 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_getsockopt_params {
|
|
|
|
int sockfd;
|
|
|
|
int level;
|
|
|
|
int option;
|
2020-09-12 06:11:07 +03:00
|
|
|
void* value;
|
|
|
|
socklen_t* value_size;
|
2020-03-22 03:12:45 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_setsockopt_params {
|
|
|
|
int sockfd;
|
|
|
|
int level;
|
|
|
|
int option;
|
2020-09-12 06:11:07 +03:00
|
|
|
const void* value;
|
2020-03-22 03:12:45 +03:00
|
|
|
socklen_t value_size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_getsockname_params {
|
|
|
|
int sockfd;
|
2020-09-12 06:11:07 +03:00
|
|
|
sockaddr* addr;
|
|
|
|
socklen_t* addrlen;
|
2020-03-22 03:12:45 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_getpeername_params {
|
|
|
|
int sockfd;
|
2020-09-12 06:11:07 +03:00
|
|
|
sockaddr* addr;
|
|
|
|
socklen_t* addrlen;
|
2020-03-22 03:12:45 +03:00
|
|
|
};
|
|
|
|
|
2021-04-28 13:39:12 +03:00
|
|
|
struct SC_socketpair_params {
|
|
|
|
int domain;
|
|
|
|
int type;
|
|
|
|
int protocol;
|
|
|
|
int* sv;
|
|
|
|
};
|
|
|
|
|
2020-03-22 03:12:45 +03:00
|
|
|
struct SC_futex_params {
|
2020-12-22 09:21:58 +03:00
|
|
|
u32* userspace_address;
|
2020-03-22 03:12:45 +03:00
|
|
|
int futex_op;
|
2020-12-22 09:21:58 +03:00
|
|
|
u32 val;
|
|
|
|
union {
|
|
|
|
const timespec* timeout;
|
2021-02-25 18:18:36 +03:00
|
|
|
uintptr_t val2;
|
2020-12-22 09:21:58 +03:00
|
|
|
};
|
|
|
|
u32* userspace_address2;
|
|
|
|
u32 val3;
|
2020-03-22 03:12:45 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_setkeymap_params {
|
2020-09-12 06:11:07 +03:00
|
|
|
const u32* map;
|
|
|
|
const u32* shift_map;
|
|
|
|
const u32* alt_map;
|
|
|
|
const u32* altgr_map;
|
2021-01-05 11:39:33 +03:00
|
|
|
const u32* shift_altgr_map;
|
2020-08-06 02:03:32 +03:00
|
|
|
StringArgument map_name;
|
2020-03-22 03:12:45 +03:00
|
|
|
};
|
|
|
|
|
2021-01-30 23:35:54 +03:00
|
|
|
struct SC_getkeymap_params {
|
|
|
|
u32* map;
|
|
|
|
u32* shift_map;
|
|
|
|
u32* alt_map;
|
|
|
|
u32* altgr_map;
|
|
|
|
u32* shift_altgr_map;
|
|
|
|
MutableBufferArgument<char, size_t> map_name;
|
|
|
|
};
|
|
|
|
|
2020-03-22 03:12:45 +03:00
|
|
|
struct SC_create_thread_params {
|
|
|
|
unsigned int m_detach_state = 0; // JOINABLE or DETACHED
|
|
|
|
int m_schedule_priority = 30; // THREAD_PRIORITY_NORMAL
|
2020-10-03 00:14:37 +03:00
|
|
|
// FIXME: Implement guard pages in create_thread (unreadable pages at "overflow" end of stack)
|
2020-03-22 03:12:45 +03:00
|
|
|
// "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
|
AK: Rename KB, MB, GB to KiB, MiB, GiB
The SI prefixes "k", "M", "G" mean "10^3", "10^6", "10^9".
The IEC prefixes "Ki", "Mi", "Gi" mean "2^10", "2^20", "2^30".
Let's use the correct name, at least in code.
Only changes the name of the constants, no other behavior change.
2020-08-15 20:55:00 +03:00
|
|
|
unsigned int m_stack_size = 4 * MiB; // Default PTHREAD_STACK_MIN
|
2020-09-18 10:49:51 +03:00
|
|
|
void* m_stack_location; // nullptr means any, o.w. process virtual address
|
2020-03-22 03:12:45 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_realpath_params {
|
|
|
|
StringArgument path;
|
|
|
|
MutableBufferArgument<char, size_t> buffer;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_set_mmap_name_params {
|
|
|
|
void* addr;
|
|
|
|
size_t size;
|
|
|
|
StringArgument name;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_execve_params {
|
|
|
|
StringArgument path;
|
|
|
|
StringListArgument arguments;
|
|
|
|
StringListArgument environment;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_readlink_params {
|
|
|
|
StringArgument path;
|
|
|
|
MutableBufferArgument<char, size_t> buffer;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_link_params {
|
|
|
|
StringArgument old_path;
|
|
|
|
StringArgument new_path;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_chown_params {
|
|
|
|
StringArgument path;
|
|
|
|
u32 uid;
|
|
|
|
u32 gid;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_mknod_params {
|
|
|
|
StringArgument path;
|
|
|
|
u16 mode;
|
|
|
|
u32 dev;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_symlink_params {
|
|
|
|
StringArgument target;
|
|
|
|
StringArgument linkpath;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_rename_params {
|
|
|
|
StringArgument old_path;
|
|
|
|
StringArgument new_path;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_mount_params {
|
2020-04-06 11:55:08 +03:00
|
|
|
int source_fd;
|
2020-03-22 03:12:45 +03:00
|
|
|
StringArgument target;
|
|
|
|
StringArgument fs_type;
|
|
|
|
int flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_pledge_params {
|
|
|
|
StringArgument promises;
|
|
|
|
StringArgument execpromises;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_unveil_params {
|
|
|
|
StringArgument path;
|
|
|
|
StringArgument permissions;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_waitid_params {
|
|
|
|
int idtype;
|
|
|
|
int id;
|
2020-09-12 06:11:07 +03:00
|
|
|
struct siginfo* infop;
|
2020-03-22 03:12:45 +03:00
|
|
|
int options;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SC_stat_params {
|
2021-05-14 21:34:31 +03:00
|
|
|
int dirfd;
|
2020-03-22 03:12:45 +03:00
|
|
|
StringArgument path;
|
2020-09-12 06:11:07 +03:00
|
|
|
struct stat* statbuf;
|
2021-03-02 21:44:09 +03:00
|
|
|
int follow_symlinks;
|
2020-03-22 03:12:45 +03:00
|
|
|
};
|
|
|
|
|
2020-03-28 11:47:16 +03:00
|
|
|
struct SC_ptrace_params {
|
|
|
|
int request;
|
2020-08-09 02:08:24 +03:00
|
|
|
pid_t tid;
|
2020-09-12 06:11:07 +03:00
|
|
|
u8* addr;
|
2020-03-28 11:47:16 +03:00
|
|
|
int data;
|
|
|
|
};
|
|
|
|
|
2020-04-10 17:34:31 +03:00
|
|
|
struct SC_ptrace_peek_params {
|
2020-09-12 06:11:07 +03:00
|
|
|
const u32* address;
|
|
|
|
u32* out_data;
|
2020-04-10 17:34:31 +03:00
|
|
|
};
|
|
|
|
|
2020-12-30 17:19:57 +03:00
|
|
|
struct SC_set_coredump_metadata_params {
|
|
|
|
StringArgument key;
|
|
|
|
StringArgument value;
|
|
|
|
};
|
|
|
|
|
2021-05-12 22:17:51 +03:00
|
|
|
struct SC_inode_watcher_add_watch_params {
|
|
|
|
int fd;
|
|
|
|
StringArgument user_path;
|
|
|
|
u32 event_mask;
|
|
|
|
};
|
|
|
|
|
2020-03-22 03:12:45 +03:00
|
|
|
void initialize();
|
|
|
|
int sync();
|
|
|
|
|
2020-10-12 15:49:31 +03:00
|
|
|
inline uintptr_t invoke(Function function)
|
2020-03-22 03:12:45 +03:00
|
|
|
{
|
2020-10-12 15:49:31 +03:00
|
|
|
uintptr_t result;
|
2020-03-22 03:12:45 +03:00
|
|
|
asm volatile("int $0x82"
|
|
|
|
: "=a"(result)
|
|
|
|
: "a"(function)
|
|
|
|
: "memory");
|
|
|
|
return result;
|
|
|
|
}
|
2018-10-18 14:05:00 +03:00
|
|
|
|
2020-03-22 03:12:45 +03:00
|
|
|
template<typename T1>
|
2020-10-12 15:49:31 +03:00
|
|
|
inline uintptr_t invoke(Function function, T1 arg1)
|
2020-03-22 03:12:45 +03:00
|
|
|
{
|
2020-10-12 15:49:31 +03:00
|
|
|
uintptr_t result;
|
2020-03-22 03:12:45 +03:00
|
|
|
asm volatile("int $0x82"
|
|
|
|
: "=a"(result)
|
2020-10-12 15:49:31 +03:00
|
|
|
: "a"(function), "d"((uintptr_t)arg1)
|
2020-03-22 03:12:45 +03:00
|
|
|
: "memory");
|
|
|
|
return result;
|
|
|
|
}
|
2018-10-18 14:05:00 +03:00
|
|
|
|
2020-03-22 03:12:45 +03:00
|
|
|
template<typename T1, typename T2>
|
2020-10-12 15:49:31 +03:00
|
|
|
inline uintptr_t invoke(Function function, T1 arg1, T2 arg2)
|
2020-03-22 03:12:45 +03:00
|
|
|
{
|
2020-10-12 15:49:31 +03:00
|
|
|
uintptr_t result;
|
2020-03-22 03:12:45 +03:00
|
|
|
asm volatile("int $0x82"
|
|
|
|
: "=a"(result)
|
2020-10-12 15:49:31 +03:00
|
|
|
: "a"(function), "d"((uintptr_t)arg1), "c"((uintptr_t)arg2)
|
2020-03-22 03:12:45 +03:00
|
|
|
: "memory");
|
|
|
|
return result;
|
|
|
|
}
|
2018-10-18 14:05:00 +03:00
|
|
|
|
2020-03-22 03:12:45 +03:00
|
|
|
template<typename T1, typename T2, typename T3>
|
2020-10-12 15:49:31 +03:00
|
|
|
inline uintptr_t invoke(Function function, T1 arg1, T2 arg2, T3 arg3)
|
2020-03-22 03:12:45 +03:00
|
|
|
{
|
2020-10-12 15:49:31 +03:00
|
|
|
uintptr_t result;
|
2020-03-22 03:12:45 +03:00
|
|
|
asm volatile("int $0x82"
|
|
|
|
: "=a"(result)
|
2020-10-12 15:49:31 +03:00
|
|
|
: "a"(function), "d"((uintptr_t)arg1), "c"((uintptr_t)arg2), "b"((uintptr_t)arg3)
|
2020-03-22 03:12:45 +03:00
|
|
|
: "memory");
|
|
|
|
return result;
|
|
|
|
}
|
2019-01-25 07:19:29 +03:00
|
|
|
#endif
|
2018-10-16 12:01:38 +03:00
|
|
|
|
|
|
|
}
|
2018-12-21 05:02:06 +03:00
|
|
|
|
|
|
|
#undef __ENUMERATE_SYSCALL
|
2019-05-28 12:53:16 +03:00
|
|
|
#define __ENUMERATE_SYSCALL(x) using Syscall::SC_##x;
|
2020-08-04 14:00:50 +03:00
|
|
|
ENUMERATE_SYSCALLS(__ENUMERATE_SYSCALL)
|
2018-12-21 05:02:06 +03:00
|
|
|
#undef __ENUMERATE_SYSCALL
|
2020-02-16 03:27:42 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
using namespace Kernel;
|