From fc70ab53e4868c84cb56a5353c3ec2cc5cf827eb Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Mon, 27 May 2024 13:59:41 -0500 Subject: 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 --- arch/i386/kernel/multiboot.c | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'arch/i386/kernel') 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 #include #include -#include -#include #include #include -#include +#include +#include +#include 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); -- cgit v1.2.3