From c37c25b36ab7a0e244132f1556781e82e006ffa1 Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Fri, 16 Feb 2024 13:03:06 -0600 Subject: arch: i386: multiboot: move arch-specific inits here Move all the architecture-specific initialization calls to this file. This frees up the main function to initialize other parts of the kernel. Signed-off-by: Danny Holman --- arch/i386/kernel/multiboot.c | 46 +++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'arch/i386/kernel') diff --git a/arch/i386/kernel/multiboot.c b/arch/i386/kernel/multiboot.c index d7f0a65..87876f0 100644 --- a/arch/i386/kernel/multiboot.c +++ b/arch/i386/kernel/multiboot.c @@ -1,23 +1,43 @@ #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +extern void kernel_main(char *cmdline); + void i386_entry(uint32_t mboot_magic, struct mboot_info *header) { paging_init(); - tty_init(); + fb_init(); + gdt_install(); + idt_install(); + pic_remap(); + timer_init(); - struct mboot_info *vheader = get_vaddr(header); - mark_bitmap(header, 1); - map_page(header, vheader, 0x003); + register_irq_handler(1, keyboard_handler); + enable_ints(); - if (mboot_magic != MBOOT_LOADER_MAGIC) - panic("NOT BOOTED WITH MULTIBOOT BOOTLOADER"); - if (!(vheader->flags >> 6 & 0x1)) - panic("NO MEMORY MAP FROM BOOTLOADER"); + if (mboot_magic != MBOOT_LOADER_MAGIC) { + fb_write("NOT BOOTED WITH MULTIBOOT BOOTLOADER\n", 37); + fb_write("RESET PC!\n", 10); + disable_ints(); + while (1); + } + if (!(header->flags >> 6 & 0x1)) { + fb_write("NO MEMORY MAP FROM BOOTLOADER\n", 30); + fb_write("RESET PC!\n", 10); + disable_ints(); + while (1); + } - gdt_install(); - idt_install(); - alloc_init(vheader); - kernel_main(vheader->cmdline); + kernel_main((char*)header->cmdline); + + while (1); } -- cgit v1.2.3