git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactor: make pci device driver loading passive, pci bus scanner will not load them...
[lunaix-os.git]
/
lunaix-os
/
kernel
/
time
/
clock.c
diff --git
a/lunaix-os/kernel/time/clock.c
b/lunaix-os/kernel/time/clock.c
index 2dc4e8153359fc91c3137db86021b1bd86b457ee..2bf61d4f48700fed442252b8a694c51c15598405 100644
(file)
--- a/
lunaix-os/kernel/time/clock.c
+++ b/
lunaix-os/kernel/time/clock.c
@@
-1,6
+1,5
@@
-#include <hal/hwrtc.h>
-#include <hal/hwtimer.h>
#include <lunaix/clock.h>
#include <lunaix/clock.h>
+#include <lunaix/device.h>
#include <lunaix/fs/twifs.h>
#include <lunaix/spike.h>
#include <lunaix/fs/twifs.h>
#include <lunaix/spike.h>
@@
-51,12
+50,6
@@
clock_build_mapping()
}
EXPORT_TWIFS_PLUGIN(sys_clock, clock_build_mapping);
}
EXPORT_TWIFS_PLUGIN(sys_clock, clock_build_mapping);
-void
-clock_init()
-{
- hwrtc_init();
-}
-
time_t
clock_unixtime()
{
time_t
clock_unixtime()
{
@@
-68,12
+61,32
@@
clock_unixtime()
time_t
clock_systime()
{
time_t
clock_systime()
{
+ if (!systimer) {
+ return 0;
+ }
+
ticks_t t = hwtimer_current_systicks();
ticks_t t = hwtimer_current_systicks();
- return t / current_timer->running_freq;
+ ticks_t tu = systimer->running_freq / 1000;
+ return t / (tu + 1);
}
void
clock_walltime(datetime_t* datetime)
{
}
void
clock_walltime(datetime_t* datetime)
{
- current_rtc->get_walltime(current_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
}
\ No newline at end of file