diff options
Diffstat (limited to 'src/kernel/paging.c')
-rw-r--r-- | src/kernel/paging.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/kernel/paging.c b/src/kernel/paging.c index b92e037..36fb8a7 100644 --- a/src/kernel/paging.c +++ b/src/kernel/paging.c @@ -45,7 +45,8 @@ void pd_map(void *pd, uint32_t physical_addr, uint32_t virtual_addr, bool writab ((uint32_t *)(*ptp & PE_ADDR_MASK))[(virtual_addr >> 12) % 1024] = physical_addr | PE_USER | PE_PRESENT | (PE_WRITABLE * writable); } -bool pd_is_mapped(void *pd, uint32_t vma) { +__attribute__ ((pure)) +static bool pd_is_mapped(void *pd, uint32_t vma) { uint32_t pde = ((uint32_t *)pd)[vma >> 22]; return (pde & PE_PRESENT) && (((uint32_t *)(pde & PE_ADDR_MASK))[(vma >> 12) % 1024] & PE_PRESENT); } @@ -85,7 +86,7 @@ void *pd_user_allocate(void *pd, uint32_t vma, uint32_t pages, bool writable) { void *pd_user_allocate_anywhere_writable(void *pd, uint32_t pages) { uint32_t run = 0; for (void *vma = (void *)KERNEL_END; vma; vma += 4096) { - if (pd_is_mapped(pd, vma)) + if (pd_is_mapped(pd, (uint32_t)vma)) run = 0; else if (++run == pages) { vma -= (pages - 1) * 4096; @@ -94,6 +95,7 @@ void *pd_user_allocate_anywhere_writable(void *pd, uint32_t pages) { return vma; } } + return 0; } #define KPAGE_DIR ((uint32_t *)0x00005000) |