X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/8c06c883e7b13c115d5ff207f79d4b68fccd5ad6..9eed27f6f2f002145667fb4abfc5e476b53630e5:/lunaix-os/kernel/time/clock.c diff --git a/lunaix-os/kernel/time/clock.c b/lunaix-os/kernel/time/clock.c index 3770dd0..3170731 100644 --- a/lunaix-os/kernel/time/clock.c +++ b/lunaix-os/kernel/time/clock.c @@ -1,6 +1,5 @@ -#include -#include #include +#include #include #include @@ -62,16 +61,37 @@ clock_unixtime() time_t clock_systime() { - if (!current_timer) { + if (!systimer) { return 0; } ticks_t t = hwtimer_current_systicks(); - return t / current_timer->running_freq; + ticks_t tu = systimer->running_freq / 1000; + + if (unlikely(!tu)) { + return t; + } + + return t / (tu); } void clock_walltime(datetime_t* datetime) { - primary_rtc->get_walltime(primary_rtc, datetime); + sysrtc->get_walltime(sysrtc, datetime); +} + +void +clock_init() +{ + int idx = 0; + struct device_def* pos; + foreach_exported_device_of(load_timedev, idx, pos) + { + if (pos->class.device != DEV_RTC) { + continue; + } + + pos->init(pos); + } } \ No newline at end of file