diff options
author | Danny Holman <dholman@gymli.org> | 2024-05-29 00:26:59 -0500 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2024-05-29 00:26:59 -0500 |
commit | ffc782f8740027d21793c37c6094ebed06d1dfd2 (patch) | |
tree | fadd5544ed493d9935d6c4052a442f70c17030fd /arch/i386/kernel/multiboot.c | |
parent | 5fb0ba537ab15f9c83afd9a939cf57c84d443856 (diff) |
arch: i386: fix several bugs in paging subsystem
Fix several triple-faulting bugs in the paging initialization routines.
These include causing a page fault during physical memory manager
initialization, causing a page fault during paging initialization and
other double-faulting and triple-faulting bugs.
Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'arch/i386/kernel/multiboot.c')
-rw-r--r-- | arch/i386/kernel/multiboot.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/arch/i386/kernel/multiboot.c b/arch/i386/kernel/multiboot.c index 87b5e32..f56910a 100644 --- a/arch/i386/kernel/multiboot.c +++ b/arch/i386/kernel/multiboot.c @@ -10,6 +10,7 @@ #include <kernel/video/framebuffer.h> #include <libk/io.h> #include <libk/string.h> +#include <libk/kmalloc.h> extern void kernel_main(char *cmdline); extern uintptr_t *kpgdir; @@ -19,22 +20,20 @@ void i386_entry(uint32_t mboot_magic, struct mboot_info *header, uintptr_t *entr fb_init(); if (mboot_magic != MBOOT_LOADER_MAGIC) { - kprintf("NOT BOOTED WITH MULTIBOOT BOOTLOADER\n"); - kprintf("RESET PC!\n"); disable_ints(); - while (1); + panic("Not booted with multiboot bootloader"); } - map_page(NULL, (uintptr_t)header, (uintptr_t)GET_VADDR(header), PD_PRES); + map_page(NULL, (uintptr_t)header, (uintptr_t)header, PD_PRES); if (!(header->flags >> 6 & 0x1)) { - kprintf("NO MEMORY MAP FROM BOOTLOADER\n"); - kprintf("RESET PC!\n"); disable_ints(); - while (1); + panic("Physical memory map not provided by bootloader"); } struct mboot_info hcopy; + char cmdcopy[1024]; memcpy(&hcopy, header, sizeof(struct mboot_info)); - unmap_page(NULL, (uintptr_t)header); + map_page(NULL, (uintptr_t)header->cmdline, (uintptr_t)header->cmdline, PD_PRES); + strcpy(cmdcopy, header->cmdline); pfa_init(&hcopy); paging_init(); @@ -44,8 +43,8 @@ void i386_entry(uint32_t mboot_magic, struct mboot_info *header, uintptr_t *entr pic_remap(); timer_init(); - //enable_ints(); - kernel_main((char*)header->cmdline); + enable_ints(); + kernel_main(cmdcopy); while (1); } |