fix: corrected time conversion on alarm/sleep syscall
[lunaix-os.git] / lunaix-os / includes / lunaix / block.h
index 4b0c824d1ca06f77e3da46c9a53628da3b15ea09..0ddd00058cb585a22fdf6b17095d26582c85b00c 100644 (file)
@@ -9,24 +9,30 @@
 #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
 {
-    char bdev_id[DEV_ID_SIZE];
-    char name[PARTITION_NAME_SIZE];
+    struct llist_header parts;
     struct blkio_context* blkio;
     struct device* dev;
+    char bdev_id[DEV_ID_SIZE];
+    char name[PARTITION_NAME_SIZE];
     void* driver;
+    u64_t start_lba;
     u64_t end_lba;
     u32_t blk_size;
+    struct block_dev_ops ops;
 };
 
-struct lpt_entry
-{
-    char part_name[PARTITION_NAME_SIZE];
-    u64_t base_lba;
-    u64_t end_lba;
-} __attribute__((packed));
-
 // Lunaix Partition Table
 struct lpt_header
 {
@@ -38,7 +44,7 @@ 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);
 
 void
@@ -56,4 +62,11 @@ blk_mapping_init();
 void
 blk_set_blkmapping(struct block_dev* bdev, void* fsnode);
 
+struct block_dev*
+blk_mount_part(struct block_dev* bdev,
+               const char* name,
+               size_t index,
+               u64_t start_lba,
+               u64_t end_lba);
+
 #endif /* __LUNAIX_BLOCK_H */