refactor: one more step towards arch-agnostic design
[lunaix-os.git] / lunaix-os / includes / hal / hwrtc.h
diff --git a/lunaix-os/includes/hal/hwrtc.h b/lunaix-os/includes/hal/hwrtc.h
new file mode 100644 (file)
index 0000000..b43a2ff
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef __LUNAIX_HWRTC_H
+#define __LUNAIX_HWRTC_H
+
+#include <lunaix/time.h>
+
+struct hwrtc
+{
+    char* name;
+    void* data;
+
+    ticks_t base_freq;
+
+    int (*supported)(struct hwrtc*);
+    void (*init)(struct hwrtc*);
+
+    void (*get_walltime)(struct hwrtc*, datetime_t*);
+
+    void (*do_ticking)(struct hwrtc*, void (*on_tick)());
+    void (*end_ticking)(struct hwrtc*);
+};
+
+extern const struct hwrtc* current_rtc;
+
+void
+hwrtc_init();
+
+struct hwrtc*
+hwrtc_choose();
+
+void
+hwrtc_walltime(datetime_t* dt);
+
+#endif /* __LUNAIX_HWRTC_H */