rewrite the device subsystem interfaces (#48)
[lunaix-os.git] / lunaix-os / includes / hal / hwtimer.h
index 3a55d6d96e235aa836df1a508b2e4fee7161afd1..e7a22a7644fdfb7b7ff9e65eeb00159058fd5c45 100644 (file)
@@ -7,34 +7,42 @@
 
 typedef void (*timer_tick_cb)();
 
 
 typedef void (*timer_tick_cb)();
 
-struct hwtimer
-{
-    char* name;
-    void* data;
+#define HWTIMER_MIN_PRECEDENCE      0
+#define HWTIMER_MAX_PRECEDENCE      15
 
 
-    struct devclass class;
-    struct device* timer_dev;
+struct hwtimer_pot;
+struct hwtimer_pot_ops
+{
+    void (*calibrate)(struct hwtimer_pot*, u32_t hertz);
+};
 
 
-    int (*supported)(struct hwtimer*);
-    void (*init)(struct hwtimer*, u32_t hertz, timer_tick_cb);
-    ticks_t (*systicks)();
+struct hwtimer_pot
+{
+    POTENS_META;
+    
+    struct llist_header timers;
+    
+    int precedence;
+    timer_tick_cb callback;
     ticks_t base_freq;
     ticks_t running_freq;
     ticks_t base_freq;
     ticks_t running_freq;
+    volatile ticks_t systick_raw;
+
+    struct hwtimer_pot_ops* ops;
 };
 
 void
 hwtimer_init(u32_t hertz, void* tick_callback);
 
 };
 
 void
 hwtimer_init(u32_t hertz, void* tick_callback);
 
-struct hwtimer*
-hwtimer_choose();
-
-ticks_t
-hwtimer_base_frequency();
-
 ticks_t
 hwtimer_current_systicks();
 
 ticks_t
 hwtimer_to_ticks(u32_t value, int unit);
 
 ticks_t
 hwtimer_current_systicks();
 
 ticks_t
 hwtimer_to_ticks(u32_t value, int unit);
 
+struct hwtimer_pot*
+hwtimer_attach_potens(struct device* dev, int precedence, 
+                      struct hwtimer_pot_ops* ops);
+
+
 #endif /* __LUNAIX_HWTIMER_H */
 #endif /* __LUNAIX_HWTIMER_H */