shconfig: add `link` command to view the inverse dependency
[lunaix-os.git] / lunaix-os / includes / lunaix / block.h
index 551bc22818a64531fad899c05bfc2243ad82a261..075ed3783ff92875b6e0b4c50cc89ff480427865 100644 (file)
@@ -9,6 +9,16 @@
 #define PARTITION_NAME_SIZE 48
 #define DEV_ID_SIZE 32
 
+struct block_dev;
+
+struct block_dev_ops
+{
+    int (*block_read)(struct block_dev*, void*, u64_t, size_t);
+    int (*block_write)(struct block_dev*, void*, u64_t, size_t);
+    void* (*block_alloc)(struct block_dev*);
+    void (*block_free)(struct block_dev*, void*);
+};
+
 struct block_dev
 {
     struct llist_header parts;
@@ -20,6 +30,8 @@ struct block_dev
     u64_t start_lba;
     u64_t end_lba;
     u32_t blk_size;
+    struct block_dev_ops ops;
+    struct devclass* class;
 };
 
 // Lunaix Partition Table
@@ -33,9 +45,15 @@ struct lpt_header
 } __attribute__((packed));
 
 typedef u64_t partition_t;
-typedef uint32_t bdev_t;
+typedef u32_t bdev_t;
 typedef void (*devfs_exporter)(struct block_dev* bdev, void* fsnode);
 
+static inline struct block_dev*
+block_dev(struct device* dev) 
+{
+    return (struct block_dev*)dev->underlay;
+}
+
 void
 block_init();