diff options
Diffstat (limited to 'src/kernel/arch/i386/pagedir.c')
-rw-r--r-- | src/kernel/arch/i386/pagedir.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/kernel/arch/i386/pagedir.c b/src/kernel/arch/i386/pagedir.c index 2fc96f4..770ff4e 100644 --- a/src/kernel/arch/i386/pagedir.c +++ b/src/kernel/arch/i386/pagedir.c @@ -46,11 +46,12 @@ struct pagedir *pagedir_new(void) { return dir; } -void pagedir_map(struct pagedir *dir, user_ptr virt, void *phys, +void pagedir_map(struct pagedir *dir, void __user *virt, void *phys, bool user, bool writeable) { - uint32_t pd_idx = virt >> 22; - uint32_t pt_idx = virt >> 12 & 0x03FF; + uintptr_t virt_cast = (uintptr_t) virt; + uint32_t pd_idx = virt_cast >> 22; + uint32_t pt_idx = virt_cast >> 12 & 0x03FF; struct pagetable_entry *pagetable; if (dir->e[pd_idx].present) { @@ -124,12 +125,13 @@ struct pagedir *pagedir_copy(const struct pagedir *orig) { return clone; } -void *pagedir_virt2phys(struct pagedir *dir, const user_ptr virt, +void *pagedir_virt2phys(struct pagedir *dir, const void __user *virt, bool user, bool writeable) { + uintptr_t virt_cast = (uintptr_t) virt; uintptr_t phys; - uint32_t pd_idx = virt >> 22; - uint32_t pt_idx = virt >> 12 & 0x03FF; + uint32_t pd_idx = virt_cast >> 22; + uint32_t pt_idx = virt_cast >> 12 & 0x03FF; struct pagetable_entry *pagetable, page; /* DOESN'T CHECK PERMISSIONS ON PAGE DIRS, TODO @@ -146,6 +148,6 @@ void *pagedir_virt2phys(struct pagedir *dir, const user_ptr virt, if (writeable && !page.writeable) return 0; phys = page.address << 11; - phys |= virt & 0xFFF; + phys |= virt_cast & 0xFFF; return (void*)phys; } |