feat: standard vga support (mode switching, framebuffer remapping)
[lunaix-os.git] / lunaix-os / includes / lunaix / timer.h
index c02d7f6bb49a55b003a8c38a3fdc7d4ed7dd3faf..d1b78450a821c4f6c1691c0d856c5e22998f612f 100644 (file)
@@ -2,19 +2,18 @@
 #define __LUNAIX_TIMER_H
 
 #include <lunaix/ds/llist.h>
-#include <stdint.h>
+#include <lunaix/time.h>
+#include <sys/interrupts.h>
 
-#define SYS_TIMER_FREQUENCY_HZ 2048
+#define SYS_TIMER_FREQUENCY_HZ 1024
 
 #define TIMER_MODE_PERIODIC 0x1
 
-typedef uint32_t ticks_t;
-
 struct lx_timer_context
 {
     struct lx_timer* active_timers;
     /**
-     * @brief APIC timer base frequency (ticks per seconds)
+     * @brief timer hardware base frequency (ticks per seconds)
      *
      */
     ticks_t base_frequency;
@@ -22,7 +21,7 @@ struct lx_timer_context
      * @brief Desired system running frequency
      *
      */
-    uint32_t running_frequency;
+    ticks_t running_frequency;
     /**
      * @brief Ticks per hertz
      *
@@ -30,6 +29,12 @@ struct lx_timer_context
     ticks_t tphz;
 };
 
+struct timer_init_param
+{
+    struct lx_timer_context* context;
+    void* timer_update_isr;
+};
+
 struct lx_timer
 {
     struct llist_header link;
@@ -37,7 +42,7 @@ struct lx_timer
     ticks_t counter;
     void* payload;
     void (*callback)(void*);
-    uint8_t flags;
+    u8_t flags;
 };
 
 /**
@@ -46,22 +51,22 @@ struct lx_timer
  * @param frequency The frequency that timer should run in Hz.
  */
 void
-timer_init(uint32_t frequency);
+timer_init();
 
 struct lx_timer*
-timer_run_second(uint32_t second,
+timer_run_second(u32_t second,
                  void (*callback)(void*),
                  void* payload,
-                 uint8_t flags);
+                 u8_t flags);
 
 struct lx_timer*
-timer_run_ms(uint32_t millisecond,
+timer_run_ms(u32_t millisecond,
              void (*callback)(void*),
              void* payload,
-             uint8_t flags);
+             u8_t flags);
 
 struct lx_timer*
-timer_run(ticks_t ticks, void (*callback)(void*), void* payload, uint8_t flags);
+timer_run(ticks_t ticks, void (*callback)(void*), void* payload, u8_t flags);
 
 struct lx_timer_context*
 timer_context();