fix: (blkio) enforce disk io buffer size alignment (to block size)
[lunaix-os.git] / lunaix-os / includes / lunaix / block.h
index db8ae5cfd5055b72adf10bedfd53b0a379d5b7cb..551bc22818a64531fad899c05bfc2243ad82a261 100644 (file)
@@ -2,36 +2,60 @@
 #define __LUNAIX_BLOCK_H
 
 #include <hal/ahci/hba.h>
 #define __LUNAIX_BLOCK_H
 
 #include <hal/ahci/hba.h>
+#include <lunaix/blkio.h>
+#include <lunaix/device.h>
 
 #define LPT_SIG 0x414e554c
 #define PARTITION_NAME_SIZE 48
 
 #define LPT_SIG 0x414e554c
 #define PARTITION_NAME_SIZE 48
-
-typedef uint64_t partition_t;
-typedef uint32_t bdev_t;
+#define DEV_ID_SIZE 32
 
 struct block_dev
 {
 
 struct block_dev
 {
+    struct llist_header parts;
+    struct blkio_context* blkio;
+    struct device* dev;
+    char bdev_id[DEV_ID_SIZE];
     char name[PARTITION_NAME_SIZE];
     char name[PARTITION_NAME_SIZE];
-    struct hba_device* hd_dev;
-    uint64_t base_lba;
-    uint64_t end_lba;
+    void* driver;
+    u64_t start_lba;
+    u64_t end_lba;
+    u32_t blk_size;
 };
 
 };
 
-struct lpt_entry
-{
-    char part_name[PARTITION_NAME_SIZE];
-    uint64_t base_lba;
-    uint64_t end_lba;
-} __attribute__((packed));
-
 // Lunaix Partition Table
 struct lpt_header
 {
 // Lunaix Partition Table
 struct lpt_header
 {
-    uint32_t signature;
-    uint32_t crc;
-    uint32_t pt_start_lba;
-    uint32_t pt_end_lba;
-    uint32_t table_len;
+    u32_t signature;
+    u32_t crc;
+    u32_t pt_start_lba;
+    u32_t pt_end_lba;
+    u32_t table_len;
 } __attribute__((packed));
 
 } __attribute__((packed));
 
+typedef u64_t partition_t;
+typedef uint32_t bdev_t;
+typedef void (*devfs_exporter)(struct block_dev* bdev, void* fsnode);
+
+void
+block_init();
+
+struct block_dev*
+block_alloc_dev(const char* blk_id, void* driver, req_handler ioreq_handler);
+
+int
+block_mount(struct block_dev* bdev, devfs_exporter export);
+
+void
+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 */
 #endif /* __LUNAIX_BLOCK_H */