feat: better rtc framework which aims to remove single rtc restrictions.
[lunaix-os.git] / lunaix-os / kernel / device / pseudo / devnull.c
diff --git a/lunaix-os/kernel/device/pseudo/devnull.c b/lunaix-os/kernel/device/pseudo/devnull.c
new file mode 100644 (file)
index 0000000..3e82bba
--- /dev/null
@@ -0,0 +1,41 @@
+#include <lunaix/device.h>
+#include <lunaix/mm/page.h>
+
+static int
+__null_wr_pg(struct device* dev, void* buf, size_t offset)
+{
+    // do nothing
+    return PG_SIZE;
+}
+
+static int
+__null_wr(struct device* dev, void* buf, size_t offset, size_t len)
+{
+    // do nothing
+    return len;
+}
+
+static int
+__null_rd_pg(struct device* dev, void* buf, size_t offset)
+{
+    // do nothing
+    return 0;
+}
+
+static int
+__null_rd(struct device* dev, void* buf, size_t offset, size_t len)
+{
+    // do nothing
+    return 0;
+}
+
+void
+pdev_nulldev_init()
+{
+    struct device* devnull = device_addseq(NULL, NULL, "null");
+    devnull->ops.write_page = __null_wr_pg;
+    devnull->ops.write = __null_wr;
+    devnull->ops.read_page = __null_rd_pg;
+    devnull->ops.read = __null_rd;
+}
+EXPORT_PSEUDODEV(nulldev, pdev_nulldev_init);
\ No newline at end of file