mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-14 17:00:52 +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.
86 lines
3.8 KiB
C++
86 lines
3.8 KiB
C++
#include "Tests/LinuxSyscalls/Syscalls.h"
|
|
#include "Tests/LinuxSyscalls/x64/Syscalls.h"
|
|
#include "Tests/LinuxSyscalls/x32/Syscalls.h"
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <sys/mman.h>
|
|
#include <sys/syscall.h>
|
|
#include <unistd.h>
|
|
#include <numaif.h>
|
|
|
|
namespace FEX::HLE {
|
|
void RegisterMemory() {
|
|
REGISTER_SYSCALL_IMPL(brk, [](FEXCore::Core::InternalThreadState *Thread, void *addr) -> uint64_t {
|
|
uint64_t Result = FEX::HLE::_SyscallHandler->HandleBRK(Thread, addr);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(msync, [](FEXCore::Core::InternalThreadState *Thread, void *addr, size_t length, int32_t flags) -> uint64_t {
|
|
uint64_t Result = ::msync(addr, length, flags);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(mincore, [](FEXCore::Core::InternalThreadState *Thread, void *addr, size_t length, uint8_t *vec) -> uint64_t {
|
|
uint64_t Result = ::mincore(addr, length, vec);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(madvise, [](FEXCore::Core::InternalThreadState *Thread, void *addr, size_t length, int32_t advice) -> uint64_t {
|
|
uint64_t Result = ::madvise(addr, length, advice);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(mlock, [](FEXCore::Core::InternalThreadState *Thread, const void *addr, size_t len) -> uint64_t {
|
|
uint64_t Result = ::mlock(addr, len);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(munlock, [](FEXCore::Core::InternalThreadState *Thread, const void *addr, size_t len) -> uint64_t {
|
|
uint64_t Result = ::munlock(addr, len);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(mlock2, [](FEXCore::Core::InternalThreadState *Thread, const void *addr, size_t len, int flags) -> uint64_t {
|
|
uint64_t Result = ::mlock2(addr, len, flags);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(remap_file_pages, [](FEXCore::Core::InternalThreadState *Thread, void *addr, size_t size, int prot, size_t pgoff, int flags) -> uint64_t {
|
|
// This syscall is deprecated, not sure when it will end up being removed
|
|
uint64_t Result = ::remap_file_pages(addr, size, prot, pgoff, flags);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(mbind, [](FEXCore::Core::InternalThreadState *Thread, void *addr, unsigned long len, int mode, const unsigned long *nodemask, unsigned long maxnode, unsigned flags) -> uint64_t {
|
|
uint64_t Result = ::mbind(addr, len, mode, nodemask, maxnode, flags);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(get_mempolicy, [](FEXCore::Core::InternalThreadState *Thread, int *mode, unsigned long *nodemask, unsigned long maxnode, void *addr, unsigned long flags) -> uint64_t {
|
|
uint64_t Result = ::get_mempolicy(mode, nodemask, maxnode, addr, flags);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(set_mempolicy, [](FEXCore::Core::InternalThreadState *Thread, int mode, const unsigned long *nodemask, unsigned long maxnode) -> uint64_t {
|
|
uint64_t Result = ::set_mempolicy(mode, nodemask, maxnode);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(migrate_pages, [](FEXCore::Core::InternalThreadState *Thread, int pid, unsigned long maxnode, const unsigned long *old_nodes, const unsigned long *new_nodes) -> uint64_t {
|
|
uint64_t Result = ::migrate_pages(pid, maxnode, old_nodes, new_nodes);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(move_pages, [](FEXCore::Core::InternalThreadState *Thread, int pid, unsigned long count, void **pages, const int *nodes, int *status, int flags) -> uint64_t {
|
|
uint64_t Result = ::move_pages(pid, count, pages, nodes, status, flags);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
|
|
REGISTER_SYSCALL_IMPL(membarrier, [](FEXCore::Core::InternalThreadState *Thread, int cmd, int flags) -> uint64_t {
|
|
uint64_t Result = syscall(SYS_membarrier, cmd, flags);
|
|
SYSCALL_ERRNO();
|
|
});
|
|
}
|
|
}
|