#include <klibc/string.h>
-void
-__clock_read_systime(struct twimap* map)
+static void
+__twimap_read_systime(struct twimap* map)
{
ticks_t sys_time = clock_systime();
twimap_printf(map, "%u", sys_time);
}
-void
-__clock_read_datetime(struct twimap* map)
+static void
+__twimap_read_datetime(struct twimap* map)
{
datetime_t dt;
clock_walltime(&dt);
twimap_printf(map,
"%.4d-%.2d-%.2d %.2d:%.2d:%.2d",
- dt.year,
- dt.month,
- dt.day,
- dt.hour,
- dt.minute,
- dt.second);
+ dt.year, dt.month, dt.day,
+ dt.hour, dt.minute, dt.second);
}
-void
-__clock_read_unix(struct twimap* map)
+static void
+__twimap_read_unixtime(struct twimap* map)
{
twimap_printf(map, "%u", clock_unixtime());
}
-void
-clock_build_mapping()
-{
- struct twifs_node* root = twifs_dir_node(NULL, "clock");
- struct twimap* map;
-
- map = twifs_mapping(root, NULL, "systime");
- map->read = __clock_read_systime;
-
- map = twifs_mapping(root, NULL, "unix");
- map->read = __clock_read_unix;
-
- map = twifs_mapping(root, NULL, "datetime");
- map->read = __clock_read_datetime;
-}
-EXPORT_TWIFS_PLUGIN(sys_clock, clock_build_mapping);
-
time_t
clock_unixtime()
{
void
clock_walltime(datetime_t* datetime)
{
- sysrtc->get_walltime(sysrtc, datetime);
+ sysrtc->ops->get_walltime(sysrtc, datetime);
}
-void
-clock_init()
+static void
+clock_build_mapping()
{
- int idx = 0;
- struct device_def* pos;
- foreach_exported_device_of(load_timedev, idx, pos)
- {
- if (pos->class.device != DEV_RTC) {
- continue;
- }
+ struct twifs_node* root;
+ struct twimap* map;
- pos->init(pos);
- }
-}
\ No newline at end of file
+ root = twifs_dir_node(NULL, "clock");
+
+ twimap_export_value(root, systime, FSACL_ugR, NULL);
+ twimap_export_value(root, unixtime, FSACL_ugR, NULL);
+ twimap_export_value(root, datetime, FSACL_ugR, NULL);
+}
+EXPORT_TWIFS_PLUGIN(sys_clock, clock_build_mapping);