aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/memory
diff options
context:
space:
mode:
authorMarvin Borner2020-04-28 20:59:57 +0200
committerMarvin Borner2020-04-28 20:59:57 +0200
commit5f8b5ce7efb7738eaebad43f9648975788ae19ff (patch)
treeab8fc4d4baa4adb99dc90461df689650acf34cef /src/kernel/memory
parentbfe16de4be67565f1a1e7b1331fcbe3aedf9c54e (diff)
Fixed userspace entering...
Many other fixes too, but I won't mention them because I don't want to :)
Diffstat (limited to 'src/kernel/memory')
-rw-r--r--src/kernel/memory/paging.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/kernel/memory/paging.c b/src/kernel/memory/paging.c
index 0789c2a..9075d1d 100644
--- a/src/kernel/memory/paging.c
+++ b/src/kernel/memory/paging.c
@@ -102,21 +102,6 @@ void paging_map_user(struct page_directory *dir, uint32_t phys, uint32_t virt)
}
}
-void page_fault(struct regs *regs)
-{
- cli();
- if (current_proc != NULL) {
- memcpy(&current_proc->registers, regs, sizeof(struct regs));
- process_suspend(current_proc->pid);
- warn("Segfault, halting process %d", current_proc->pid);
- scheduler(regs);
- } else {
- warn("Page fault before multitasking started!");
- // fault_handler(regs);
- halt_loop();
- }
-}
-
void paging_install()
{
kheap_init();
@@ -124,11 +109,19 @@ void paging_install()
paging_current_directory = paging_make_directory();
paging_root_directory = paging_current_directory;
- isr_install_handler(14, page_fault);
for (uint32_t i = 0; i < 0xF0000000; i += PAGE_S)
paging_map(paging_root_directory, i, i);
paging_switch_directory(paging_root_directory);
info("Installed paging");
+
+ // Test mallocing
+ uintptr_t a = (uintptr_t)kmalloc(4096); // TODO: Fix "can't collapse top of heap"
+ uintptr_t b = (uintptr_t)kmalloc(4096);
+ kfree((void *)b);
+ kfree((void *)a);
+ uintptr_t c = (uintptr_t)kmalloc(2048);
+ assert(a == c);
+ info("kmalloc test succeeded!");
}
void paging_convert_page(struct page_directory *kdir)