mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 21:00:17 +02:00
Sadly these things can't be split without breaking functionality so it turns in to a bit of a mess. SyscallHandler is very much something that is a Linux only construct and shouldn't be in FEXCore itself. Lets the frontend register a Syscallhandler with FEXCore. FEXCore itself is then aware of the current syscall ABI and handles the ABI in an optimal fashion. So it is not a 100% clean break otherwise we would lose performance. The SignalDelegator then needs to move to the frontend since the SyscallHandler requires it for signal based syscalls. The CPU backend signal handling still needs to happen in FEXCore because it is a very tight coupling with the CPU backend. Once we need to support more Signal handling we can give the backends cleaner support to select which specific OS handler to handle.
45 lines
1.9 KiB
C++
45 lines
1.9 KiB
C++
#include "Tests/LinuxSyscalls/Syscalls.h"
|
|
#include "Tests/LinuxSyscalls/x64/Syscalls.h"
|
|
#include "Tests/LinuxSyscalls/x32/Syscalls.h"
|
|
|
|
#include <sys/mman.h>
|
|
#include <sys/syscall.h>
|
|
#include <unistd.h>
|
|
|
|
namespace FEX::HLE {
|
|
void RegisterKey() {
|
|
REGISTER_SYSCALL_IMPL(add_key, [](FEXCore::Core::InternalThreadState *Thread, const char *type, const char *description, const void *payload, size_t plen, int32_t /*key_serial_t*/ keyring) -> uint64_t {
|
|
uint64_t Result = syscall(SYS_add_key, type, description, payload, plen, keyring);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(request_key, [](FEXCore::Core::InternalThreadState *Thread, const char *type, const char *description, const char *callout_info, int32_t /*key_serial_t*/ dest_keyring) -> uint64_t {
|
|
uint64_t Result = syscall(SYS_request_key, type, description, callout_info, dest_keyring);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(keyctl, [](FEXCore::Core::InternalThreadState *Thread, int operation, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5) -> uint64_t {
|
|
uint64_t Result = syscall(SYS_keyctl, operation, arg2, arg3, arg4, arg5);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(pkey_mprotect, [](FEXCore::Core::InternalThreadState *Thread, void *addr, size_t len, int prot, int pkey) -> uint64_t {
|
|
// Added in Linux 4.9
|
|
uint64_t Result = ::pkey_mprotect(addr, len, prot, pkey);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(pkey_alloc, [](FEXCore::Core::InternalThreadState *Thread, unsigned int flags, unsigned int access_rights) -> uint64_t {
|
|
// Added in Linux 4.9
|
|
uint64_t Result = ::pkey_alloc(flags, access_rights);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(pkey_free, [](FEXCore::Core::InternalThreadState *Thread, int pkey) -> uint64_t {
|
|
// Added in Linux 4.9
|
|
uint64_t Result = ::pkey_free(pkey);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
}
|
|
}
|