diff options
author | Marvin Borner | 2019-10-14 17:20:25 +0200 |
---|---|---|
committer | Marvin Borner | 2019-10-14 17:20:25 +0200 |
commit | aca116a82c7b9ef715ec9e7ed6d2f97d56715327 (patch) | |
tree | 7bac857da5f8244cc08adffc4660bacf4f27a73f /src/kernel/paging | |
parent | 8754542ce074bef0984f91ce1b1cd8aff9b3d5e9 (diff) |
Trying some things
Diffstat (limited to 'src/kernel/paging')
-rw-r--r-- | src/kernel/paging/paging.c | 12 | ||||
-rw-r--r-- | src/kernel/paging/paging.h | 12 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/kernel/paging/paging.c b/src/kernel/paging/paging.c index 4bb69d0..1712f7e 100644 --- a/src/kernel/paging/paging.c +++ b/src/kernel/paging/paging.c @@ -105,6 +105,18 @@ void initialise_paging() { switch_page_directory(current_directory); } +void disable_paging() { + uint32_t cr0; + asm volatile("mov %%cr0, %0": "=r"(cr0)); + cr0 &= 0x7fffffff; + asm volatile("mov %0, %%cr0"::"r"(cr0)); +} + +void enable_paging() { + switch_page_directory(kernel_directory); + switch_page_directory(current_directory); +} + void switch_page_directory(page_directory_t *dir) { current_directory = dir; asm volatile("mov %0, %%cr3"::"r"(dir->physicalAddr)); diff --git a/src/kernel/paging/paging.h b/src/kernel/paging/paging.h index 51f407f..681b84e 100644 --- a/src/kernel/paging/paging.h +++ b/src/kernel/paging/paging.h @@ -25,11 +25,21 @@ typedef struct page_directory { } page_directory_t; /** - * Initialize the environment and enables paging + * Initialize the environment and enable paging */ void initialise_paging(); /** + * Enable paging bit in CR0 (without initializing) + */ +void enable_paging(); + +/** + * Disable paging bit in CR0 + */ +void disable_paging(); + +/** * Load the page directory into the CR3 register * @param new The page directory */ |