feat: block device support (mount device and partitions)
[lunaix-os.git] / lunaix-os / includes / lunaix / block.h
1 #ifndef __LUNAIX_BLOCK_H
2 #define __LUNAIX_BLOCK_H
3
4 #include <hal/ahci/hba.h>
5
6 #define LPT_SIG 0x414e554c
7 #define PARTITION_NAME_SIZE 48
8
9 typedef uint64_t partition_t;
10 typedef uint32_t bdev_t;
11
12 struct block_dev
13 {
14     char name[PARTITION_NAME_SIZE];
15     struct hba_device* hd_dev;
16     uint64_t base_lba;
17     uint64_t end_lba;
18 };
19
20 struct lpt_entry
21 {
22     char part_name[PARTITION_NAME_SIZE];
23     uint64_t base_lba;
24     uint64_t end_lba;
25 } __attribute__((packed));
26
27 // Lunaix Partition Table
28 struct lpt_header
29 {
30     uint32_t signature;
31     uint32_t crc;
32     uint32_t pt_start_lba;
33     uint32_t pt_end_lba;
34     uint32_t table_len;
35 } __attribute__((packed));
36
37 #endif /* __LUNAIX_BLOCK_H */