summaryrefslogtreecommitdiff
path: root/DevTools
diff options
context:
space:
mode:
authorSimon Danner <danner.simon@gmail.com>2020-11-22 12:12:21 +0100
committerAndreas Kling <kling@serenityos.org>2020-11-23 18:41:42 +0100
commit751e759be2047eec2852d7b2cf31e24be5a69c67 (patch)
treeae4743a1088f7dc963a99b3daaaecb237017c712 /DevTools
parentc6bb3d452a4f2b504c7d77263f811f1d019ac05f (diff)
downloadserenity-751e759be2047eec2852d7b2cf31e24be5a69c67.zip
UserspaceEmulator: Implement clock_nanosleep
Diffstat (limited to 'DevTools')
-rw-r--r--DevTools/UserspaceEmulator/Emulator.cpp22
-rw-r--r--DevTools/UserspaceEmulator/Emulator.h1
2 files changed, 23 insertions, 0 deletions
diff --git a/DevTools/UserspaceEmulator/Emulator.cpp b/DevTools/UserspaceEmulator/Emulator.cpp
index d261993390..4d47600070 100644
--- a/DevTools/UserspaceEmulator/Emulator.cpp
+++ b/DevTools/UserspaceEmulator/Emulator.cpp
@@ -402,6 +402,8 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
return virt$setsid();
case SC_watch_file:
return virt$watch_file(arg1, arg2);
+ case SC_clock_nanosleep:
+ return virt$clock_nanosleep(arg1);
default:
reportln("\n=={}== \033[31;1mUnimplemented syscall: {}\033[0m, {:p}", getpid(), Syscall::to_string((Syscall::Function)function), function);
dump_backtrace();
@@ -1501,4 +1503,24 @@ int Emulator::virt$watch_file(FlatPtr user_path_addr, size_t path_length)
return syscall(SC_watch_file, user_path.data(), user_path.size());
}
+int Emulator::virt$clock_nanosleep(FlatPtr params_addr)
+{
+ Syscall::SC_clock_nanosleep_params params;
+ mmu().copy_from_vm(&params, params_addr, sizeof(params));
+
+ timespec requested_sleep;
+ mmu().copy_from_vm(&requested_sleep, (FlatPtr)params.requested_sleep, sizeof(timespec));
+ params.requested_sleep = &requested_sleep;
+
+ auto remaining_vm_addr = params.remaining_sleep;
+ auto remaining = ByteBuffer::create_zeroed(sizeof(timespec));
+ params.remaining_sleep = (timespec*)remaining.data();
+
+ int rc = syscall(SC_clock_nanosleep, &params);
+ if (remaining_vm_addr)
+ mmu().copy_to_vm((FlatPtr)remaining_vm_addr, remaining.data(), sizeof(timespec));
+
+ return rc;
+}
+
}
diff --git a/DevTools/UserspaceEmulator/Emulator.h b/DevTools/UserspaceEmulator/Emulator.h
index edd3b64786..3fb0a07ad0 100644
--- a/DevTools/UserspaceEmulator/Emulator.h
+++ b/DevTools/UserspaceEmulator/Emulator.h
@@ -118,6 +118,7 @@ private:
int virt$set_process_icon(int);
int virt$gettimeofday(FlatPtr);
int virt$clock_gettime(int, FlatPtr);
+ int virt$clock_nanosleep(FlatPtr);
int virt$dbgputstr(FlatPtr characters, int length);
int virt$dbgputch(char);
int virt$chmod(FlatPtr, size_t, mode_t);