feat: lseek(2), read(2), write(2) implementation
[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 #define DEV_ID_SIZE 32
9
10 typedef uint64_t partition_t;
11 typedef uint32_t bdev_t;
12
13 struct block_dev
14 {
15     char bdev_id[DEV_ID_SIZE];
16     char name[PARTITION_NAME_SIZE];
17     struct hba_device* hd_dev;
18     uint64_t base_lba;
19     uint64_t end_lba;
20 };
21
22 struct lpt_entry
23 {
24     char part_name[PARTITION_NAME_SIZE];
25     uint64_t base_lba;
26     uint64_t end_lba;
27 } __attribute__((packed));
28
29 // Lunaix Partition Table
30 struct lpt_header
31 {
32     uint32_t signature;
33     uint32_t crc;
34     uint32_t pt_start_lba;
35     uint32_t pt_end_lba;
36     uint32_t table_len;
37 } __attribute__((packed));
38
39 void
40 block_init();
41
42 int
43 block_mount_disk(struct hba_device* hd_dev);
44
45 #endif /* __LUNAIX_BLOCK_H */