feat: kprintf now goes into dedicated pseudo-dev rather than flooding the framebuffer
[lunaix-os.git] / lunaix-os / hal / timer / hwtimer.c
index 3a79ca1a7ec6d773521e8f8b7ff321b04526d406..91dca07459d8e9caf450ecbaab8c9cddd78d8f6d 100644 (file)
@@ -8,18 +8,21 @@ struct hwtimer* current_timer;
 ticks_t
 hwtimer_base_frequency()
 {
+    assert(current_timer);
     return current_timer->base_freq;
 }
 
 ticks_t
 hwtimer_current_systicks()
 {
+    assert(current_timer);
     return current_timer->systicks();
 }
 
 ticks_t
 hwtimer_to_ticks(u32_t value, int unit)
 {
+    assert(current_timer);
     // in case system frequency is less than 1000Hz
     if (unit != TIME_MS) {
         return current_timer->running_freq * unit * value;
@@ -55,7 +58,9 @@ hwtimer_init(u32_t hertz, void* tick_callback)
 
     current_timer = hwt_ctx;
 
-    struct device* timerdev = device_addsys(NULL, hwt_ctx, hwt_ctx->name);
+    struct device* timerdev = device_allocsys(NULL, hwt_ctx);
 
     timerdev->ops.exec_cmd = __hwtimer_ioctl;
+
+    device_register(timerdev, &hwt_ctx->class, hwt_ctx->name);
 }
\ No newline at end of file