diff options
author | Danny Holman <dholman@gymli.org> | 2024-06-22 02:50:47 -0500 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2024-06-22 02:50:47 -0500 |
commit | cea371e824adb1650b0797e9943f6dcf3bd179eb (patch) | |
tree | b3856ae3c5bfc74868af1cb5fed88c291decd44d /arch/i386 | |
parent | 0e8081d8e9db8b9482da7e92a72194bfa927223d (diff) |
arch: i386: multiboot: refactor i386_entry
Refactor the i386_entry function such that it is in line with how the
paging and memory systems operate. Further, the kernel command line must
now be copied before calling the physical memory initialization routines
due to an address conflict that cannot be resolved otherwise.
Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'arch/i386')
-rw-r--r-- | arch/i386/kernel/multiboot.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/arch/i386/kernel/multiboot.c b/arch/i386/kernel/multiboot.c index f56910a..dedf163 100644 --- a/arch/i386/kernel/multiboot.c +++ b/arch/i386/kernel/multiboot.c @@ -7,44 +7,43 @@ #include <kernel/pmem.h> #include <kernel/timer.h> #include <kernel/panic.h> +#include <kernel/vmem.h> #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; - -void i386_entry(uint32_t mboot_magic, struct mboot_info *header, uintptr_t *entry_pd) { - kpgdir = entry_pd; +void kernel_main(char *cmdline); +void i386_entry(uint32_t mboot_magic, struct mboot_info *header) { + map_page(0xB8000, (uintptr_t)VGA_MEMORY, PD_RW); fb_init(); + if (mboot_magic != MBOOT_LOADER_MAGIC) { disable_ints(); panic("Not booted with multiboot bootloader"); } - map_page(NULL, (uintptr_t)header, (uintptr_t)header, PD_PRES); + + map_page(0x9000, 0x9000, PD_RW); if (!(header->flags >> 6 & 0x1)) { disable_ints(); panic("Physical memory map not provided by bootloader"); } - struct mboot_info hcopy; - char cmdcopy[1024]; - memcpy(&hcopy, header, sizeof(struct mboot_info)); - map_page(NULL, (uintptr_t)header->cmdline, (uintptr_t)header->cmdline, PD_PRES); - strcpy(cmdcopy, header->cmdline); - - pfa_init(&hcopy); - paging_init(); - kmalloc_init(); + char cmdline[4096]; + map_page(header->cmdline, PAGE_TMP_MAP, 0); + memcpy(cmdline, (char*)PAGE_TMP_MAP, strlen((char*)PAGE_TMP_MAP)); + unmap_page(PAGE_TMP_MAP); + pfa_init(header); gdt_install(); idt_install(); + paging_init(); + map_page(0xB8000, (uintptr_t)VGA_MEMORY, PD_RW); pic_remap(); timer_init(); enable_ints(); - kernel_main(cmdcopy); + kernel_main(cmdline); while (1); } |