Architectural Support: x86_64 (#37)
[lunaix-os.git] / lunaix-os / arch / x86 / boot / boot_helper.c
1 #include <lunaix/boot_generic.h>
2 #include <lunaix/mm/pagetable.h>
3
4 #include "sys/mm/mm_defs.h"
5
6 #ifdef CONFIG_ARCH_X86_64
7
8 void
9 boot_begin_arch_reserve(struct boot_handoff* bhctx)
10 {
11     return;
12 }
13
14
15 void
16 boot_clean_arch_reserve(struct boot_handoff* bhctx)
17 {
18     return;
19 }
20
21 #else
22
23 #include <lunaix/mm/vmm.h>
24
25 void
26 boot_begin_arch_reserve(struct boot_handoff* bhctx)
27 {
28     // Identity-map the first 3GiB address spaces
29     pte_t* ptep  = mkl0tep(mkptep_va(VMS_SELF, 0));
30     pte_t pte    = mkpte_prot(KERNEL_DATA);
31     size_t count = page_count(KERNEL_RESIDENT, L0T_SIZE);
32
33     vmm_set_ptes_contig(ptep, pte_mkhuge(pte), L0T_SIZE, count);
34 }
35
36
37 void
38 boot_clean_arch_reserve(struct boot_handoff* bhctx)
39 {
40     pte_t* ptep  = mkl0tep(mkptep_va(VMS_SELF, 0));
41     size_t count = page_count(KERNEL_RESIDENT, L0T_SIZE);
42     vmm_unset_ptes(ptep, count);
43 }
44
45
46 #endif