diff --git a/kernel/syscall/syscall.c b/kernel/syscall/syscall.c index df2f7c6..16525a8 100644 --- a/kernel/syscall/syscall.c +++ b/kernel/syscall/syscall.c @@ -11,6 +11,7 @@ #include "proc.h" #include "fs.h" #include "dev.h" +#include "time.h" int32_t SYSCALL1(sys_debugprint, string) { char *p = (char *)string; @@ -52,4 +53,5 @@ SyscallFn SYSCALL_TABLE[SYSCALLS_MAX] = { [SYS_DEV_LISTSIZE] = &sys_dev_listsize, [SYS_DEV_STAT] = &sys_dev_stat, [SYS_DEV_CMD] = &sys_dev_cmd, + [SYS_TIME] = &sys_time, }; diff --git a/kernel/syscall/time.c b/kernel/syscall/time.c new file mode 100644 index 0000000..5e8f8b4 --- /dev/null +++ b/kernel/syscall/time.c @@ -0,0 +1,13 @@ +#include +#include +#include "syscall.h" +#include "time.h" +#include "sysdefs/time.h" +#include "time/time.h" +#include "errors.h" + +int32_t SYSCALL1(sys_time, timestruct1) { + Time *time = (Time *)timestruct1; + time_get(time); + return E_OK; +} diff --git a/kernel/syscall/time.h b/kernel/syscall/time.h new file mode 100644 index 0000000..def1cc3 --- /dev/null +++ b/kernel/syscall/time.h @@ -0,0 +1,9 @@ +#ifndef SYSCALL_TIME_H_ +#define SYSCALL_TIME_H_ + +#include +#include + +int32_t SYSCALL1(sys_time, timestruct1); + +#endif // SYSCALL_TIME_H_ diff --git a/kernel/time/time.h b/kernel/time/time.h index 611a5c5..d635099 100644 --- a/kernel/time/time.h +++ b/kernel/time/time.h @@ -3,17 +3,7 @@ #include #include - -typedef struct { - uint32_t second; - uint32_t minute; - uint32_t hour; - uint32_t day; - uint32_t month; - uint32_t year; -} Time; - -typedef uint64_t timeunix_t; +#include "sysdefs/time.h" void time_get(Time *time); timeunix_t time_tounix(Time *time); diff --git a/share/sysdefs/syscall.h b/share/sysdefs/syscall.h index a1f0db8..7b44543 100644 --- a/share/sysdefs/syscall.h +++ b/share/sysdefs/syscall.h @@ -34,6 +34,7 @@ #define SYS_DEV_LISTSIZE 34 #define SYS_DEV_STAT 35 #define SYS_DEV_CMD 36 +#define SYS_TIME 38 #endif // SHARE_HDRS_SYSCALL_H_ diff --git a/share/sysdefs/time.h b/share/sysdefs/time.h new file mode 100644 index 0000000..5ac9920 --- /dev/null +++ b/share/sysdefs/time.h @@ -0,0 +1,15 @@ +#ifndef SHARE_SYSDEFS_TIME_H_ +#define SHARE_SYSDEFS_TIME_H_ + +typedef struct { + uint32_t second; + uint32_t minute; + uint32_t hour; + uint32_t day; + uint32_t month; + uint32_t year; +} Time; + +typedef uint64_t timeunix_t; + +#endif // SHARE_SYSDEFS_TIME_H_