diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-10-24 11:22:11 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-25 10:13:03 +0100 |
commit | 457e00f319e324db6bee6a3c4491439e46455ac2 (patch) | |
tree | 6054f4005df6114c2639e40bf457c8c6eb5771fd /DevTools/UserspaceEmulator | |
parent | 33730cbd925c95e36461152a595a43de29409707 (diff) | |
download | serenity-457e00f319e324db6bee6a3c4491439e46455ac2.zip |
UserspaceEmulator: Add support for sched_(g s)etparam
Diffstat (limited to 'DevTools/UserspaceEmulator')
-rw-r--r-- | DevTools/UserspaceEmulator/Emulator.cpp | 21 | ||||
-rw-r--r-- | DevTools/UserspaceEmulator/Emulator.h | 2 |
2 files changed, 23 insertions, 0 deletions
diff --git a/DevTools/UserspaceEmulator/Emulator.cpp b/DevTools/UserspaceEmulator/Emulator.cpp index 5739636991..61df845f1a 100644 --- a/DevTools/UserspaceEmulator/Emulator.cpp +++ b/DevTools/UserspaceEmulator/Emulator.cpp @@ -36,6 +36,7 @@ #include <fcntl.h> #include <net/if.h> #include <net/route.h> +#include <sched.h> #include <serenity.h> #include <stdio.h> #include <string.h> @@ -381,6 +382,10 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3) return virt$getrandom(arg1, arg2, arg3); case SC_fork: return virt$fork(); + case SC_sched_getparam: + return virt$sched_getparam(arg1, arg2); + case SC_sched_setparam: + return virt$sched_setparam(arg1, arg2); default: reportln("\n=={}== \033[31;1mUnimplemented syscall: {}\033[0m, {:p}", getpid(), Syscall::to_string((Syscall::Function)function), function); dump_backtrace(); @@ -1403,4 +1408,20 @@ int Emulator::virt$dup2(int old_fd, int new_fd) return syscall(SC_dup2, old_fd, new_fd); } +int Emulator::virt$sched_getparam(pid_t pid, FlatPtr user_addr) +{ + sched_param user_param; + mmu().copy_from_vm(&user_param, user_addr, sizeof(user_param)); + auto rc = syscall(SC_sched_getparam, pid, &user_param); + mmu().copy_to_vm(user_addr, &user_param, sizeof(user_param)); + return rc; +} + +int Emulator::virt$sched_setparam(int pid, FlatPtr user_addr) +{ + sched_param user_param; + mmu().copy_from_vm(&user_param, user_addr, sizeof(user_param)); + return syscall(SC_sched_setparam, pid, &user_param); +} + } diff --git a/DevTools/UserspaceEmulator/Emulator.h b/DevTools/UserspaceEmulator/Emulator.h index 0dcb1016f8..a74f648d30 100644 --- a/DevTools/UserspaceEmulator/Emulator.h +++ b/DevTools/UserspaceEmulator/Emulator.h @@ -147,6 +147,8 @@ private: int virt$getcwd(FlatPtr buffer, size_t buffer_size); int virt$waitid(FlatPtr); int virt$getsid(pid_t); + int virt$sched_setparam(int, FlatPtr); + int virt$sched_getparam(pid_t, FlatPtr); FlatPtr allocate_vm(size_t size, size_t alignment); |