A Total Overhaul on the Lunaix's Virtual Memory Model (#26)
[lunaix-os.git] / lunaix-os / hal / char / devzero.c
index d5f13c69f9268bb1d2426c96791fd3f7de46c387..9013a471f09c22234ff6984e105e700980f04eb1 100644 (file)
@@ -1,13 +1,13 @@
 #include <lunaix/device.h>
-#include <lunaix/mm/page.h>
+#include <lunaix/mm/pagetable.h>
 
 #include <klibc/string.h>
 
 static int
 __zero_rd_pg(struct device* dev, void* buf, size_t offset)
 {
-    memset(&((u8_t*)buf)[offset], 0, PG_SIZE);
-    return PG_SIZE;
+    memset(&((u8_t*)buf)[offset], 0, PAGE_SIZE);
+    return PAGE_SIZE;
 }
 
 static int
@@ -18,18 +18,19 @@ __zero_rd(struct device* dev, void* buf, size_t offset, size_t len)
 }
 
 static int
-pdev_zerodev_init(struct device_def*)
+pdev_zerodev_init(struct device_def* def)
 {
-    struct device* devzero = device_addseq(NULL, NULL, "zero");
+    struct device* devzero = device_allocseq(NULL, NULL);
     devzero->ops.read_page = __zero_rd_pg;
     devzero->ops.read = __zero_rd;
 
+    register_device(devzero, &def->class, "zero");
+
     return 0;
 }
 
 static struct device_def devzero_def = {
     .name = "zero",
-    .class = DEVCLASS(DEVIF_NON, DEVFN_PSEUDO, DEV_BUILTIN, 1),
-    .init = pdev_zerodev_init
-};
-EXPORT_DEVICE(zerodev, &devzero_def, load_earlystage);
+    .class = DEVCLASSV(DEVIF_NON, DEVFN_PSEUDO, DEV_ZERO, DEV_BUILTIN_ZERO),
+    .init = pdev_zerodev_init};
+EXPORT_DEVICE(zerodev, &devzero_def, load_onboot);