1 #include <lunaix/clock.h>
2 #include <lunaix/device.h>
3 #include <lunaix/fs/twifs.h>
4 #include <lunaix/spike.h>
6 #include <klibc/string.h>
9 __clock_read_systime(struct twimap* map)
11 ticks_t sys_time = clock_systime();
12 twimap_printf(map, "%u", sys_time);
16 __clock_read_datetime(struct twimap* map)
21 "%.4d-%.2d-%.2d %.2d:%.2d:%.2d",
31 __clock_read_unix(struct twimap* map)
33 twimap_printf(map, "%u", clock_unixtime());
39 struct twifs_node* root = twifs_dir_node(NULL, "clock");
42 map = twifs_mapping(root, NULL, "systime");
43 map->read = __clock_read_systime;
45 map = twifs_mapping(root, NULL, "unix");
46 map->read = __clock_read_unix;
48 map = twifs_mapping(root, NULL, "datetime");
49 map->read = __clock_read_datetime;
51 EXPORT_TWIFS_PLUGIN(sys_clock, clock_build_mapping);
58 return datetime_tounix(&dt);
68 ticks_t t = hwtimer_current_systicks();
69 ticks_t tu = systimer->running_freq / 1000;
79 clock_walltime(datetime_t* datetime)
81 sysrtc->get_walltime(sysrtc, datetime);
88 struct device_def* pos;
89 foreach_exported_device_of(load_timedev, idx, pos)
91 if (pos->class.device != DEV_RTC) {