diff options
author | Danny Holman <dholman@gymli.org> | 2024-05-27 13:59:41 -0500 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2024-05-27 13:59:41 -0500 |
commit | fc70ab53e4868c84cb56a5353c3ec2cc5cf827eb (patch) | |
tree | 9f16a0c00dc244e303588df6833b311c59275a37 /arch/i386/kernel | |
parent | 61760f9301427ea56a62ec02af3d0d8ae4745be7 (diff) |
arch: i386: pass entry page directory to entry func
Add a third argument to i386_entry. This argument is the bootstrap page
directory. Pages can be temporarily mapped in during the initialization
of the paging system.
Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'arch/i386/kernel')
-rw-r--r-- | arch/i386/kernel/multiboot.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/arch/i386/kernel/multiboot.c b/arch/i386/kernel/multiboot.c index 720866b..87b5e32 100644 --- a/arch/i386/kernel/multiboot.c +++ b/arch/i386/kernel/multiboot.c @@ -5,40 +5,46 @@ #include <kernel/pic.h> #include <kernel/paging.h> #include <kernel/pmem.h> -#include <kernel/keyboard.h> -#include <kernel/framebuffer.h> #include <kernel/timer.h> #include <kernel/panic.h> -#include <kernel/io.h> +#include <kernel/video/framebuffer.h> +#include <libk/io.h> +#include <libk/string.h> extern void kernel_main(char *cmdline); +extern uintptr_t *kpgdir; -void i386_entry(uint32_t mboot_magic, struct mboot_info *header) { - paging_init(); - fb_init(); - gdt_install(); - idt_install(); - pic_remap(); - timer_init(); - - register_irq_handler(1, keyboard_handler); +void i386_entry(uint32_t mboot_magic, struct mboot_info *header, uintptr_t *entry_pd) { + kpgdir = entry_pd; + fb_init(); if (mboot_magic != MBOOT_LOADER_MAGIC) { - fb_write("NOT BOOTED WITH MULTIBOOT BOOTLOADER\n", 37); - fb_write("RESET PC!\n", 10); + kprintf("NOT BOOTED WITH MULTIBOOT BOOTLOADER\n"); + kprintf("RESET PC!\n"); disable_ints(); while (1); } - map_page(NULL, (uintptr_t)header, (uintptr_t)header, PD_PRES); + map_page(NULL, (uintptr_t)header, (uintptr_t)GET_VADDR(header), PD_PRES); if (!(header->flags >> 6 & 0x1)) { - fb_write("NO MEMORY MAP FROM BOOTLOADER\n", 30); - fb_write("RESET PC!\n", 10); + kprintf("NO MEMORY MAP FROM BOOTLOADER\n"); + kprintf("RESET PC!\n"); disable_ints(); while (1); } - pfa_init(header); - enable_ints(); + struct mboot_info hcopy; + memcpy(&hcopy, header, sizeof(struct mboot_info)); + unmap_page(NULL, (uintptr_t)header); + + pfa_init(&hcopy); + paging_init(); + kmalloc_init(); + gdt_install(); + idt_install(); + pic_remap(); + timer_init(); + + //enable_ints(); kernel_main((char*)header->cmdline); while (1); |