diff options
Diffstat (limited to 'common')
| -rw-r--r-- | common/main.c | 2 | ||||
| -rw-r--r-- | common/tcb.c | 3 | ||||
| -rw-r--r-- | common/timer.c | 9 | ||||
| -rw-r--r-- | common/uapi/dispatch.c | 2 | ||||
| -rw-r--r-- | common/uapi/proc.c | 8 | ||||
| -rw-r--r-- | common/uapi/timers.c | 5 |
6 files changed, 19 insertions, 10 deletions
diff --git a/common/main.c b/common/main.c index 0e33ecc..7168aeb 100644 --- a/common/main.c +++ b/common/main.c @@ -1,4 +1,5 @@ #include <apos/mem_nodes.h> +#include <apos/timer.h> #include <apos/attrs.h> #include <apos/proc.h> #include <apos/debug.h> @@ -23,5 +24,6 @@ void __main main(void *fdt) setup_io_dbg(b); init_irq(fdt); + init_timer(fdt); init_proc(fdt, b); } diff --git a/common/tcb.c b/common/tcb.c index 326d9ac..bb1bcec 100644 --- a/common/tcb.c +++ b/common/tcb.c @@ -57,7 +57,8 @@ struct tcb *new_thread() /* move tcb to top of kernel stack, keeping alignment in check * (hopefully) */ /* TODO: check alignment */ - struct tcb *t = (struct tcb *)align_down(bottom + __o_size(MM_O0) - sizeof(struct tcb), sizeof(long)); + struct tcb *t = (struct tcb *)align_down( + bottom + __o_size(MM_O0) - sizeof(struct tcb), sizeof(long)); memset(t, 0, sizeof(struct tcb)); id_t tid = __alloc_tid(t); diff --git a/common/timer.c b/common/timer.c index 2006a6c..da4fd11 100644 --- a/common/timer.c +++ b/common/timer.c @@ -130,3 +130,12 @@ ticks_t nsecs_to_ticks(tunit_t nsecs) ticks_t t = (nsecs * ticks_per_sec) / 1000000000; return t == 0 ? 1 : t; } + +/* call to this function from exception handlers */ +void update_timers() +{ + struct timer *t = newest_timer(); + remove_timer(t); + + /* TODO: handle timer thread ID */ +} diff --git a/common/uapi/dispatch.c b/common/uapi/dispatch.c index 5522c9f..92fa954 100644 --- a/common/uapi/dispatch.c +++ b/common/uapi/dispatch.c @@ -10,6 +10,7 @@ static const sys_t syscall_table[] = { [SYS_FREE_MEM] = sys_free_mem, /* timers */ + [SYS_TIMEBASE] = sys_timebase, [SYS_REQ_REL_TIMER] = sys_req_rel_timer, [SYS_REQ_ABS_TIMER] = sys_req_abs_timer, [SYS_FREE_TIMER] = sys_free_timer, @@ -24,7 +25,6 @@ static const sys_t syscall_table[] = { [SYS_EXEC] = sys_exec, [SYS_SIGNAL] = sys_signal, [SYS_SWITCH] = sys_switch, - [SYS_SYNC] = sys_sync, /* conf */ [SYS_CONF] = sys_conf, diff --git a/common/uapi/proc.c b/common/uapi/proc.c index 7c0a69d..a5ce839 100644 --- a/common/uapi/proc.c +++ b/common/uapi/proc.c @@ -34,11 +34,3 @@ SYSCALL_DEFINE1(switch)(vm_t pid) /* TODO: switch to process */ return 0; } - -SYSCALL_DEFINE2(sync)(vm_t buf, vm_t size) -{ - /* check that only the process manager can use this syscall, otherwise - * just dump process info into the buffer (I guess, not sure if this - * will be quite required */ - return 0; -} diff --git a/common/uapi/timers.c b/common/uapi/timers.c index 66f6533..5ce596f 100644 --- a/common/uapi/timers.c +++ b/common/uapi/timers.c @@ -11,6 +11,11 @@ static ticks_t scaled_ticks(vm_t ticks, vm_t repeat) #endif } +SYSCALL_DEFINE0(timebase)() +{ + return secs_to_ticks(1); +} + SYSCALL_DEFINE2(req_rel_timer)(vm_t ticks, vm_t repeat) { return new_rel_timer(cur_tcb()->tid, scaled_ticks(ticks, repeat)); |
