From 51a80930a9bc25fae0728994cab1e0df3b63ef48 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 27 Apr 2021 23:01:51 +0200 Subject: Huge compositor, timer and yielding improvements --- kernel/drivers/rtc.c | 2 +- kernel/drivers/timer.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'kernel/drivers') diff --git a/kernel/drivers/rtc.c b/kernel/drivers/rtc.c index 01d65f4..2da61da 100644 --- a/kernel/drivers/rtc.c +++ b/kernel/drivers/rtc.c @@ -66,6 +66,6 @@ struct rtc rtc_read(void) u32 rtc_stamp(void) { struct rtc rtc = rtc_read(); - return timer_get() + rtc.second + rtc.minute * 60 + rtc.hour * 360 + rtc.day * 360 * 24 + + return rtc.second + rtc.minute * 60 + rtc.hour * 360 + rtc.day * 360 * 24 + rtc.year * 360 * 24 * 365; } diff --git a/kernel/drivers/timer.c b/kernel/drivers/timer.c index 294df84..176b499 100644 --- a/kernel/drivers/timer.c +++ b/kernel/drivers/timer.c @@ -57,14 +57,26 @@ CLEAR void scheduler_disable(void) irq_install_handler(0, timer_handler); } +static struct timer timer_struct(void) +{ + struct proc *proc = proc_current(); + struct timer timer = { + .rtc = rtc_stamp(), + .ticks.user = proc->ticks.user, + .ticks.kernel = proc->ticks.kernel, + .time = timer_get(), + }; + return timer; +} + static res timer_read(void *buf, u32 offset, u32 count) { UNUSED(offset); - u32 stamp = rtc_stamp(); - memcpy_user(buf, &stamp, MIN(count, sizeof(stamp))); + struct timer timer = timer_struct(); + memcpy_user(buf, &timer, MIN(count, sizeof(timer))); - return MIN(count, sizeof(stamp)); + return MIN(count, sizeof(timer)); } // Install timer handler into IRQ0 -- cgit v1.2.3