From 4e7918753175dbd8fc38bc7c5b176517e1dbef2f Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Wed, 3 Jul 2024 18:30:51 +0200 Subject: Kernel/Time: Improve time keeping This makes use of TSC and now provides a file system interface for userland programs to change the system time. --- kernel/cpu/syscall.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'kernel/cpu') diff --git a/kernel/cpu/syscall.c b/kernel/cpu/syscall.c index 78d35fe..a74adfd 100644 --- a/kernel/cpu/syscall.c +++ b/kernel/cpu/syscall.c @@ -19,6 +19,7 @@ #include #include #include +#include #include struct two_args { @@ -137,9 +138,7 @@ int syscall_chdir(const char *path) { int syscall_clock_gettime(clockid_t clock_id, struct timespec *tp) { // FIXME: Actually implement this if (tp) { - u64 ms = pit_num_ms(); - tp->tv_sec = ms / 1000; - tp->tv_nsec = ms * 1000 * 1000; + timer_get(tp); } return 0; } @@ -226,7 +225,9 @@ void *syscall_mmap(SYS_MMAP_PARAMS *args) { } void syscall_msleep(u32 ms) { - current_task->sleep_until = pit_num_ms() + ms; + struct timespec t; + timer_get(&t); + current_task->sleep_until = timer_get_ms() + ms; switch_task(); } @@ -371,7 +372,7 @@ int syscall_socket(SYS_SOCKET_PARAMS *args) { } u32 syscall_uptime(void) { - return (u32)pit_num_ms(); + return timer_get_uptime(); } int syscall_write(int fd, const char *buf, size_t count) { -- cgit v1.2.3