A Total Overhaul on the Lunaix's Virtual Memory Model (#26)
[lunaix-os.git] / lunaix-os / kernel / device / input.c
index 0680fefebe7be56c4992f3a6dc06945325825902..cc3cc1328f2f38c38c1a98af4f4f7f114d6a5c32 100644 (file)
@@ -1,6 +1,6 @@
 #include <lunaix/clock.h>
 #include <lunaix/input.h>
-#include <lunaix/mm/page.h>
+#include <lunaix/mm/pagetable.h>
 #include <lunaix/mm/valloc.h>
 #include <lunaix/spike.h>
 #include <lunaix/status.h>
@@ -9,19 +9,12 @@
 
 static DEFINE_LLIST(listener_chain);
 
-static struct device* input_devcat = NULL;
+static struct device_cat* input_devcat = NULL;
 
 void
 input_init()
 {
     input_devcat = device_addcat(NULL, "input");
-
-    int i;
-    ptr_t input_dev_init;
-    ldga_foreach(inputdev, ptr_t, i, input_dev_init)
-    {
-        ((void (*)())input_dev_init)();
-    }
 }
 
 void
@@ -73,11 +66,11 @@ __input_dev_read(struct device* dev, void* buf, size_t offset, size_t len)
 int
 __input_dev_read_pg(struct device* dev, void* buf, size_t offset)
 {
-    return __input_dev_read(dev, buf, offset, PG_SIZE);
+    return __input_dev_read(dev, buf, offset, PAGE_SIZE);
 }
 
 struct input_device*
-input_add_device(char* name_fmt, ...)
+input_add_device(struct devclass* class, char* name_fmt, ...)
 {
     assert(input_devcat);
 
@@ -87,8 +80,10 @@ input_add_device(char* name_fmt, ...)
     va_list args;
     va_start(args, name_fmt);
 
-    struct device* dev =
-      device_add(input_devcat, idev, name_fmt, DEV_IFSEQ, args);
+    struct device* dev = device_allocseq(dev_meta(input_devcat), idev);
+
+    device_setname_vargs(dev_meta(dev), name_fmt, args);
+    register_device(dev, class, NULL);
 
     idev->dev_if = dev;
     dev->ops.read = __input_dev_read;