mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-29 13:48:21 +00:00
syscalls: clockget
This commit is contained in:
@@ -27,6 +27,7 @@ extern syscall_faccessat
|
||||
extern syscall_unlinkat
|
||||
extern syscall_ioctl
|
||||
extern syscall_mkdirat
|
||||
extern syscall_clockget
|
||||
syscalltab:
|
||||
dq syscall_print
|
||||
dq syscall_mmap
|
||||
@@ -56,7 +57,8 @@ dq syscall_faccessat
|
||||
dq syscall_unlinkat
|
||||
dq syscall_ioctl
|
||||
dq syscall_mkdirat
|
||||
syscallcount equ 28
|
||||
dq syscall_clockget
|
||||
syscallcount equ 29
|
||||
section .text
|
||||
global arch_syscall_entry
|
||||
; on entry:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#ifdef SYSCALL_LOGGING
|
||||
|
||||
#define SYSCALL_COUNT 28
|
||||
#define SYSCALL_COUNT 29
|
||||
#define LOGSTR(x) arch_e9_puts(x)
|
||||
|
||||
static char *name[] = {
|
||||
@@ -35,7 +35,8 @@ static char *name[] = {
|
||||
"faccessat",
|
||||
"unlinkat",
|
||||
"ioctl",
|
||||
"mkdirat"
|
||||
"mkdirat",
|
||||
"clockget"
|
||||
};
|
||||
|
||||
static char *args[] = {
|
||||
@@ -66,7 +67,8 @@ static char *args[] = {
|
||||
"dirfd %d pathname %s mode %d flags %d", // faccessat
|
||||
"dirfd %d pathname %d flags %d", // unlinkat
|
||||
"fd %d request %lu argument %d", // ioctl
|
||||
"dirfd %d path %s mode %o" // mkdirat
|
||||
"dirfd %d path %s mode %o", // mkdirat
|
||||
"clockid %d timespec %p" // clockget
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#include <kernel/syscalls.h>
|
||||
#include <kernel/abi.h>
|
||||
#include <time.h>
|
||||
#include <kernel/timekeeper.h>
|
||||
#include <kernel/vmm.h>
|
||||
|
||||
#define CLOCK_REALTIME 0
|
||||
#define CLOCK_BOOTTIME 7
|
||||
|
||||
syscallret_t syscall_clockget(context_t *, int clockid, timespec_t *tp){
|
||||
syscallret_t ret = {
|
||||
.ret = -1
|
||||
};
|
||||
|
||||
if ((void *)tp > USERSPACE_END) {
|
||||
ret.errno = EFAULT;
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch (clockid) {
|
||||
case CLOCK_REALTIME:
|
||||
// TODO safe memcpy
|
||||
*tp = timekeeper_time();
|
||||
ret.errno = 0;
|
||||
break;
|
||||
case CLOCK_BOOTTIME:
|
||||
// TODO safe memcpy
|
||||
*tp = timekeeper_timefromboot();
|
||||
ret.errno = 0;
|
||||
break;
|
||||
default:
|
||||
ret.errno = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
ret.ret = ret.errno ? -1 : 0;
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
@@ -133,10 +133,10 @@ index 0000000..e5b087a
|
||||
+
|
||||
diff --git mlibc-workdir/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||
new file mode 100644
|
||||
index 0000000..28f6942
|
||||
index 0000000..97b963a
|
||||
--- /dev/null
|
||||
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||
@@ -0,0 +1,295 @@
|
||||
@@ -0,0 +1,301 @@
|
||||
+#include <bits/ensure.h>
|
||||
+#include <mlibc/debug.hpp>
|
||||
+#include <mlibc/all-sysdeps.hpp>
|
||||
@@ -347,10 +347,12 @@ index 0000000..28f6942
|
||||
+ }
|
||||
+
|
||||
+ int sys_futex_wait(int *pointer, int expected, const struct timespec *time) {
|
||||
+ mlibc::infoLogger() << "mlibc: futex wait is a stub" << frg::endlog;
|
||||
+ // TODO UNSTUB
|
||||
+ return ENOSYS;
|
||||
+ }
|
||||
+ int sys_futex_wake(int *pointer) {
|
||||
+ mlibc::infoLogger() << "mlibc: futex wake is a stub" << frg::endlog;
|
||||
+ // TODO UNSTUB
|
||||
+ return ENOSYS;
|
||||
+ }
|
||||
@@ -426,8 +428,12 @@ index 0000000..28f6942
|
||||
+ }
|
||||
+
|
||||
+ int sys_clock_get(int clock, time_t *secs, long *nanos) {
|
||||
+ // TODO UNSTUB
|
||||
+ return ENOSYS;
|
||||
+ struct timespec ts;
|
||||
+ long ret;
|
||||
+ int err = syscall(SYSCALL_CLOCKGET, &ret, clock, (uint64_t)&ts);
|
||||
+ *secs = ts.tv_sec;
|
||||
+ *nanos = ts.tv_nsec;
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+} // namespace mlibc
|
||||
@@ -451,10 +457,10 @@ index 0000000..990eca0
|
||||
+#endif
|
||||
diff --git mlibc-workdir/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||
new file mode 100644
|
||||
index 0000000..a569d38
|
||||
index 0000000..96da753
|
||||
--- /dev/null
|
||||
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||
@@ -0,0 +1,51 @@
|
||||
@@ -0,0 +1,52 @@
|
||||
+#ifndef _SYSCALL_H_INCLUDE
|
||||
+#define _SYSCALL_H_INCLUDE
|
||||
+
|
||||
@@ -486,6 +492,7 @@ index 0000000..a569d38
|
||||
+#define SYSCALL_UNLINKAT 25
|
||||
+#define SYSCALL_IOCTL 26
|
||||
+#define SYSCALL_MKDIRAT 27
|
||||
+#define SYSCALL_CLOCKGET 28
|
||||
+
|
||||
+#include <stddef.h>
|
||||
+#include <stdint.h>
|
||||
|
||||
Reference in New Issue
Block a user