Add time() syscall
This commit is contained in:
@ -11,6 +11,7 @@
|
|||||||
#include "proc.h"
|
#include "proc.h"
|
||||||
#include "fs.h"
|
#include "fs.h"
|
||||||
#include "dev.h"
|
#include "dev.h"
|
||||||
|
#include "time.h"
|
||||||
|
|
||||||
int32_t SYSCALL1(sys_debugprint, string) {
|
int32_t SYSCALL1(sys_debugprint, string) {
|
||||||
char *p = (char *)string;
|
char *p = (char *)string;
|
||||||
@ -52,4 +53,5 @@ SyscallFn SYSCALL_TABLE[SYSCALLS_MAX] = {
|
|||||||
[SYS_DEV_LISTSIZE] = &sys_dev_listsize,
|
[SYS_DEV_LISTSIZE] = &sys_dev_listsize,
|
||||||
[SYS_DEV_STAT] = &sys_dev_stat,
|
[SYS_DEV_STAT] = &sys_dev_stat,
|
||||||
[SYS_DEV_CMD] = &sys_dev_cmd,
|
[SYS_DEV_CMD] = &sys_dev_cmd,
|
||||||
|
[SYS_TIME] = &sys_time,
|
||||||
};
|
};
|
||||||
|
|||||||
13
kernel/syscall/time.c
Normal file
13
kernel/syscall/time.c
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#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;
|
||||||
|
}
|
||||||
9
kernel/syscall/time.h
Normal file
9
kernel/syscall/time.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#ifndef SYSCALL_TIME_H_
|
||||||
|
#define SYSCALL_TIME_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
int32_t SYSCALL1(sys_time, timestruct1);
|
||||||
|
|
||||||
|
#endif // SYSCALL_TIME_H_
|
||||||
@ -3,17 +3,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include "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;
|
|
||||||
|
|
||||||
void time_get(Time *time);
|
void time_get(Time *time);
|
||||||
timeunix_t time_tounix(Time *time);
|
timeunix_t time_tounix(Time *time);
|
||||||
|
|||||||
@ -34,6 +34,7 @@
|
|||||||
#define SYS_DEV_LISTSIZE 34
|
#define SYS_DEV_LISTSIZE 34
|
||||||
#define SYS_DEV_STAT 35
|
#define SYS_DEV_STAT 35
|
||||||
#define SYS_DEV_CMD 36
|
#define SYS_DEV_CMD 36
|
||||||
|
#define SYS_TIME 38
|
||||||
|
|
||||||
|
|
||||||
#endif // SHARE_HDRS_SYSCALL_H_
|
#endif // SHARE_HDRS_SYSCALL_H_
|
||||||
|
|||||||
15
share/sysdefs/time.h
Normal file
15
share/sysdefs/time.h
Normal file
@ -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_
|
||||||
Reference in New Issue
Block a user