feat: (device) dev_null and dev_rand support
[lunaix-os.git] / lunaix-os / includes / lunaix / device.h
index be6dc26705d3228dba0f36ce0797cba048461834..ee56b1da9d9a19592fa0274b5de5c733e87fea32 100644 (file)
@@ -7,6 +7,8 @@
 #include <lunaix/ds/llist.h>
 #include <lunaix/types.h>
 
 #include <lunaix/ds/llist.h>
 #include <lunaix/types.h>
 
+#define DEV_STRUCT_MAGIC 0x5645444c
+
 #define DEV_MSKIF 0x00000003
 
 #define DEV_IFVOL 0x0 // volumetric (block) device
 #define DEV_MSKIF 0x00000003
 
 #define DEV_IFVOL 0x0 // volumetric (block) device
@@ -17,6 +19,7 @@ typedef unsigned int dev_t;
 
 struct device
 {
 
 struct device
 {
+    u32_t magic;
     struct llist_header siblings;
     struct llist_header children;
     struct device* parent;
     struct llist_header siblings;
     struct llist_header children;
     struct device* parent;
@@ -27,13 +30,16 @@ struct device
     void* underlay;
     int (*read)(struct device* dev, void* buf, size_t offset, size_t len);
     int (*write)(struct device* dev, void* buf, size_t offset, size_t len);
     void* underlay;
     int (*read)(struct device* dev, void* buf, size_t offset, size_t len);
     int (*write)(struct device* dev, void* buf, size_t offset, size_t len);
+    int (*read_page)(struct device* dev, void* buf, size_t offset);
+    int (*write_page)(struct device* dev, void* buf, size_t offset);
+    int (*exec_cmd)(struct device* dev, u32_t req, va_list args);
 };
 
 struct device*
 device_add(struct device* parent,
            void* underlay,
            char* name_fmt,
 };
 
 struct device*
 device_add(struct device* parent,
            void* underlay,
            char* name_fmt,
-           uint32_t type,
+           u32_t type,
            va_list args);
 
 struct device*
            va_list args);
 
 struct device*
@@ -60,4 +66,7 @@ device_getbyname(struct device* root_dev, const char* name, size_t len);
 struct device*
 device_getbyoffset(struct device* root_dev, int pos);
 
 struct device*
 device_getbyoffset(struct device* root_dev, int pos);
 
+void
+device_init_builtin();
+
 #endif /* __LUNAIX_DEVICE_H */
 #endif /* __LUNAIX_DEVICE_H */