fix compilation issues in aarch64 ports
[lunaix-os.git] / lunaix-os / arch / aarch64 / boot / kremap.c
1 #include <lunaix/sections.h>
2
3 #include <asm/mm_defs.h>
4 #include <asm-generic/init_pagetable.h>
5 #include <asm/boot_stage.h>
6
7 #include "init.h"
8
9 static pte_t kpt[LEVEL_SIZE][32];
10
11 ptr_t
12 kremap()
13 {
14     struct pt_alloc alloc;
15     struct ptw_state ptw;
16     pte_t pte;
17     unsigned long nr;
18
19     init_pt_alloc(&alloc, to_kphysical(&kpt), sizeof(kpt));
20     init_ptw_state(&ptw, &alloc, kpt_alloc_table(&alloc));
21
22     pte = mkpte(bootsec_start, KERNEL_DATA);
23     pte = pte_mkexec(pte);
24     nr  = leaf_count(bootsec_end - bootsec_start);
25     kpt_set_ptes(&ptw, bootsec_start, pte, LFT_SIZE, nr);
26
27     kpt_mktable_at(&ptw, VMAP, L0T_SIZE);
28     kpt_mktable_at(&ptw, PMAP, L2T_SIZE);
29     kpt_mktable_at(&ptw, KMAP, LFT_SIZE);
30
31     kpt_migrate_highmem(&ptw);
32
33     pte = mkpte(__ptr(ptw.root), KERNEL_PGTAB);
34     kpt_set_ptes(&ptw, VMS_SELF, pte, L0T_SIZE, 1);
35
36     return __ptr(ptw.root);
37 }