Architectural Support: x86_64 (#37)
[lunaix-os.git] / lunaix-os / includes / lunaix / boot_generic.h
1 #ifndef __LUNAIX_BOOT_GENERIC_H
2 #define __LUNAIX_BOOT_GENERIC_H
3
4 #include <lunaix/types.h>
5
6 // Free memory region
7 #define BOOT_MMAP_FREE 0
8
9 // Reserved memory region
10 #define BOOT_MMAP_RSVD 1
11
12 // Reclaimable memory region
13 #define BOOT_MMAP_RCLM 2
14
15 struct boot_mmapent
16 {
17     ptr_t start;
18     size_t size;
19     int type;
20 };
21
22 struct boot_modent
23 {
24     ptr_t start;
25     ptr_t end;
26     char* str;
27 };
28
29 struct boot_handoff
30 {
31     size_t msize;
32     struct
33     {
34         size_t size;
35         struct boot_mmapent* mmap;
36         size_t mmap_len;
37     } mem;
38
39     struct
40     {
41         ptr_t ksections;
42         size_t size;
43
44         char* cmdline;
45         size_t len;
46     } kexec;
47
48     struct
49     {
50         size_t mods_num;
51         struct boot_modent* entries;
52     } mods;
53
54     void (*release)(struct boot_handoff*);
55     void (*prepare)(struct boot_handoff*);
56
57     // XXX: should arch specific boot detect platform interface provider?
58 };
59
60 #ifndef __BOOT_CODE__
61 void
62 boot_begin(struct boot_handoff*);
63
64 void
65 boot_parse_cmdline(struct boot_handoff*);
66
67 void
68 boot_end(struct boot_handoff*);
69
70 void
71 boot_begin_arch_reserve(struct boot_handoff*);
72
73 void
74 boot_clean_arch_reserve(struct boot_handoff*);
75
76 static inline bool
77 free_memregion(struct boot_mmapent* mmapent)
78 {
79     return !mmapent->type;
80 }
81
82 static inline bool
83 reserved_memregion(struct boot_mmapent* mmapent)
84 {
85     return !!(mmapent->type & BOOT_MMAP_RSVD);
86 }
87
88 static inline bool
89 reclaimable_memregion(struct boot_mmapent* mmapent)
90 {
91     return !!(mmapent->type & BOOT_MMAP_RCLM);
92 }
93
94 #endif
95
96 #endif /* __LUNAIX_BOOT_GENERIC_H */