diff options
author | Benji Dial <benji6283@gmail.com> | 2021-02-17 09:11:39 -0500 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2021-02-17 09:11:39 -0500 |
commit | 49d76d30a55707e2bf95fd9ba03296489fac8d1d (patch) | |
tree | da8b7f9b0fcf5fbe7d8a84fbdf9f51d35c5dfe61 /src/kernel/paging.c | |
parent | 642c3c69a69220170e2f68c2bf6c898e6cb5b20b (diff) | |
download | portland-os-49d76d30a55707e2bf95fd9ba03296489fac8d1d.tar.gz |
making win+space work when no tasks are running
Diffstat (limited to 'src/kernel/paging.c')
-rw-r--r-- | src/kernel/paging.c | 10 |
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 |