1 #include <lunaix/mm/pmm.h>
2 #include <lunaix/mm/valloc.h>
3 #include <lunaix/mm/vmm.h>
4 #include <lunaix/spike.h>
5 #include <lunaix/syslog.h>
7 #include <sys/mm/mempart.h>
9 static ptr_t start = VMAP;
10 static volatile ptr_t prev_va = 0;
13 __alloc_contig_ptes(pte_t* ptep, size_t base_sz, int n)
17 ptr_t va = page_addr(ptep_pfn(ptep));
21 while (_n < n && va < VMAP_END) {
23 if (pte_isnull(pte)) {
26 else if ((sz / LEVEL_SIZE) < base_sz) {
31 ptep = ptep_step_into(ptep);
35 if (ptep_vfn(ptep) + 1 == LEVEL_SIZE) {
36 ptep = ptep_step_out(++ptep);
55 return mkptep_va(ptep_vm_mnt(ptep), va);
59 vmap_ptes_at(pte_t pte, size_t lvl_size, int n)
61 pte_t* ptep = mkptep_va(VMS_SELF, start);
62 ptep = __alloc_contig_ptes(ptep, lvl_size, n);
68 vmm_set_ptes_contig(ptep, pte, lvl_size, n);
70 return page_addr(ptep_pfn(ptep));