Added demand paging support
[akaros.git] / kern / arch / sparc / pmap.c
index de473e4..4121a8d 100644 (file)
@@ -123,7 +123,7 @@ int get_va_perms(pde_t *pgdir, const void *SNT va)
 
 void *get_free_va_range(pde_t *pgdir, uintptr_t addr, size_t len)
 {
-       addr = ROUNDUP(MIN(addr,UMMAP_START),PGSIZE);
+       addr = ROUNDUP(MAX(addr,UMMAP_START),PGSIZE);
        len = ROUNDUP(len,PGSIZE);
 
        for(char* a = (char*)addr; a < (char*)USTACKBOT; a += PGSIZE)
@@ -131,7 +131,7 @@ void *get_free_va_range(pde_t *pgdir, uintptr_t addr, size_t len)
                for(char* b = a; b < a+len; b += PGSIZE)
                {
                        pte_t* pte = pgdir_walk(pgdir,b,0);
-                       if(pte && (*pte & PTE_P))
+                       if(pte && !PAGE_UNMAPPED(*pte))
                        {
                                a = b;
                                break;