summaryrefslogtreecommitdiff
path: root/src/kernel/paging.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/paging.c')
-rw-r--r--src/kernel/paging.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/kernel/paging.c b/src/kernel/paging.c
index 4672788..0432ab6 100644
--- a/src/kernel/paging.c
+++ b/src/kernel/paging.c
@@ -132,7 +132,8 @@ void init_paging() {
__attribute__ ((pure))
void *vma_to_pma(void *pd, const void *vma) {
- return (void *)(((uint32_t *)(((uint32_t *)pd)[(uint32_t)vma >> 22] & PE_ADDR_MASK))[((uint32_t)vma >> 12) % 1024] & PE_ADDR_MASK) + (uint32_t)vma % 4096;
+ //this is maybe not good - in the case where pd is zero, vma is returned unconsted. hopefully this doesn't become a problem.
+ return pd ? (void *)(((uint32_t *)(((uint32_t *)pd)[(uint32_t)vma >> 22] & PE_ADDR_MASK))[((uint32_t)vma >> 12) % 1024] & PE_ADDR_MASK) + (uint32_t)vma % 4096 : (void *)(uint32_t)vma;
}
void switch_to_kernel_cr3() {
@@ -143,7 +144,8 @@ void switch_to_kernel_cr3() {
}
void switch_to_task_cr3() {
- asm volatile (
- "mov %0, %%cr3"
- : : "a" (active_task->page_directory));
+ if (active_task->page_directory)
+ asm volatile (
+ "mov %0, %%cr3"
+ : : "a" (active_task->page_directory));
} \ No newline at end of file