feat: fstat now handle symbolic link
[lunaix-os.git] / lunaix-os / includes / hal / hwrtc.h
index b43a2ff9304b21ec7f7994dfe24d2c76a78425d8..a5ebb9c21e0587c3f9de6df0d2ee895fb0983aef 100644 (file)
@@ -1,31 +1,41 @@
 #ifndef __LUNAIX_HWRTC_H
 #define __LUNAIX_HWRTC_H
 
+#include <lunaix/device.h>
+#include <lunaix/ds/ldga.h>
+#include <lunaix/ds/llist.h>
 #include <lunaix/time.h>
 
+#define RTC_STATE_MASKED 0x1
+
+#define EXPORT_RTC_DEVICE(id, init_fn)                                         \
+    export_ldga_el(rtcdev, id, ptr_t, init_fn)
+
 struct hwrtc
 {
+    struct llist_header rtc_list;
+    struct device* rtc_dev;
+
     char* name;
     void* data;
-
     ticks_t base_freq;
-
-    int (*supported)(struct hwrtc*);
-    void (*init)(struct hwrtc*);
+    int state;
 
     void (*get_walltime)(struct hwrtc*, datetime_t*);
-
-    void (*do_ticking)(struct hwrtc*, void (*on_tick)());
-    void (*end_ticking)(struct hwrtc*);
+    void (*set_walltime)(struct hwrtc*, datetime_t*);
+    void (*set_mask)(struct hwrtc*);
+    void (*cls_mask)(struct hwrtc*);
+    int (*get_counts)(struct hwrtc*);
+    int (*chfreq)(struct hwrtc*, int);
 };
 
-extern const struct hwrtc* current_rtc;
+extern const struct hwrtc* primary_rtc;
 
 void
 hwrtc_init();
 
 struct hwrtc*
-hwrtc_choose();
+hwrtc_alloc_new(struct device_def* def, char* name);
 
 void
 hwrtc_walltime(datetime_t* dt);