diff options
author | Benji Dial <benji6283@gmail.com> | 2020-09-06 01:26:56 -0400 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2020-09-06 01:26:56 -0400 |
commit | cbc85f6e897808b29e2f712156e2fa4d073d8277 (patch) | |
tree | 9b27640a6e91b5d3f3ae2ec597cc276aea1c8ab9 /src/kernel/paging.c | |
parent | e8c6577617bffa4402c07c7aa20e3c24f03c1c20 (diff) | |
download | portland-os-cbc85f6e897808b29e2f712156e2fa4d073d8277.tar.gz |
small fixes
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) |