feat: standard vga support (mode switching, framebuffer remapping)
[lunaix-os.git] / lunaix-os / hal / rtc / hwrtc.c
index c3fc1977fdb806bbd63ea33b87b42ccb7e901c87..87e7d1011942888a41d678725e0586c004982ea2 100644 (file)
@@ -12,16 +12,11 @@ static int rtc_count = 0;
 
 DEFINE_LLIST(rtcs);
 
-void
-hwrtc_init()
-{
-    ptr_t init;
-    int index;
-    ldga_foreach(rtcdev, ptr_t, index, init)
-    {
-        ((void (*)())init)();
-    }
-}
+// void
+// hwrtc_init()
+// {
+//     ldga_invoke_fn0(rtcdev);
+// }
 
 void
 hwrtc_walltime(datetime_t* dt)
@@ -74,7 +69,7 @@ hwrtc_read(struct device* dev, void* buf, size_t offset, size_t len)
 }
 
 struct hwrtc*
-hwrtc_alloc_new(char* name)
+hwrtc_alloc_new(struct device_def* def, char* name)
 {
     struct hwrtc* rtc_instance = valloc(sizeof(struct hwrtc));
 
@@ -89,15 +84,16 @@ hwrtc_alloc_new(char* name)
     }
 
     rtc_instance->name = name;
-    struct device* rtcdev =
-      device_addsys(NULL, rtc_instance, "rtc%d", rtc_count);
+    struct device* rtcdev = device_allocsys(NULL, rtc_instance);
 
     rtcdev->ops.exec_cmd = hwrtc_ioctl;
     rtcdev->ops.read = hwrtc_read;
 
     rtc_instance->rtc_dev = rtcdev;
 
-    rtc_count++;
+    device_register(rtcdev, &def->class, "rtc%d", def->class.variant);
+
+    def->class.variant++;
 
     return rtc_instance;
 }