aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/paging/paging.c
diff options
context:
space:
mode:
authorMarvin Borner2020-01-16 17:15:53 +0100
committerMarvin Borner2020-01-16 17:15:53 +0100
commitcd3ad989210dc8a3f5805dd5d4c4a6bd74e281db (patch)
tree015fa67057b1ca14a86a8faf4d1cabb0356467b2 /src/kernel/paging/paging.c
parent602b98247e9c87e38870e39abf1d8b13aeae5d0f (diff)
Quite a different approach to userspace paging
Hope this works soon!
Diffstat (limited to 'src/kernel/paging/paging.c')
-rw-r--r--src/kernel/paging/paging.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/kernel/paging/paging.c b/src/kernel/paging/paging.c
index 6f7833d..c4a2940 100644
--- a/src/kernel/paging/paging.c
+++ b/src/kernel/paging/paging.c
@@ -12,11 +12,8 @@ uint32_t kernel_page_tables[1024][1024] __attribute__((aligned(4096)));
uint32_t user_page_directory[1024] __attribute__((aligned(4096)));
uint32_t user_page_tables[1024][1024] __attribute__((aligned(4096)));
-void paging_install()
+void paging_init()
{
- current_page_directory = kernel_page_directory;
- current_page_tables = kernel_page_tables;
-
for (uint32_t i = 0; i < 1024; i++) {
for (uint32_t j = 0; j < 1024; j++) {
current_page_tables[i][j] = ((j * 0x1000) + (i * 0x400000)) | PT_RW;
@@ -27,7 +24,19 @@ void paging_install()
current_page_directory[i] = ((uint32_t) current_page_tables[i]) | PD_RW | PD_PRESENT;
}
- paging_set_present(0, memory_get_all() >> 2); // /4
+ paging_set_present(0, memory_get_all() >> 3); // /4
+}
+
+void paging_install()
+{
+ // User paging
+ paging_switch_directory(1);
+ paging_init();
+ paging_set_user(0, memory_get_all() >> 3);
+
+ // Kernel paging
+ paging_switch_directory(0);
+ paging_init();
paging_set_used(0, ((uint32_t) ASM_KERNEL_END >> 12) + 1); // /4096
paging_enable();
@@ -44,9 +53,9 @@ void paging_disable()
paging_enabled = 0;
}
-void paging_switch_directory()
+void paging_switch_directory(int user)
{
- if (current_page_tables == kernel_page_tables) {
+ if (user == 1) {
current_page_tables = user_page_tables;
current_page_directory = user_page_directory;
} else {