feat: (twimap) provide an easy way for mapping kernel objects into filesystem
[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 #include <lunaix/device.h>
6
7 #define LPT_SIG 0x414e554c
8 #define PARTITION_NAME_SIZE 48
9 #define DEV_ID_SIZE 32
10
11 typedef uint64_t partition_t;
12 typedef uint32_t bdev_t;
13
14 struct block_dev
15 {
16     char bdev_id[DEV_ID_SIZE];
17     char name[PARTITION_NAME_SIZE];
18     struct hba_device* hd_dev;
19     struct device* dev;
20     uint64_t base_lba;
21     uint64_t end_lba;
22 };
23
24 struct lpt_entry
25 {
26     char part_name[PARTITION_NAME_SIZE];
27     uint64_t base_lba;
28     uint64_t end_lba;
29 } __attribute__((packed));
30
31 // Lunaix Partition Table
32 struct lpt_header
33 {
34     uint32_t signature;
35     uint32_t crc;
36     uint32_t pt_start_lba;
37     uint32_t pt_end_lba;
38     uint32_t table_len;
39 } __attribute__((packed));
40
41 void
42 block_init();
43
44 int
45 block_mount_disk(struct hba_device* hd_dev);
46
47 void
48 blk_mapping_init();
49
50 void
51 blk_set_blkmapping(struct block_dev* bdev);
52
53 #endif /* __LUNAIX_BLOCK_H */