diff options
author | Danny Holman <dholman@gymli.org> | 2024-02-16 13:03:06 -0600 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2024-02-16 13:03:06 -0600 |
commit | c37c25b36ab7a0e244132f1556781e82e006ffa1 (patch) | |
tree | 46691bd7f0e4517213c699db34b3ecd5e6a24957 /arch/i386 | |
parent | bcb79aaff44f126064c4698ea74ffe2b68baeb0e (diff) |
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 <dholman@gymli.org>
Diffstat (limited to 'arch/i386')
-rw-r--r-- | arch/i386/kernel/multiboot.c | 46 |
1 files changed, 33 insertions, 13 deletions
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 <kernel/multiboot.h> -#include <kernel/tty.h> +#include <kernel/asm.h> +#include <kernel/gdt.h> +#include <kernel/idt.h> +#include <kernel/pic.h> +#include <kernel/paging.h> +#include <kernel/mem.h> +#include <kernel/keyboard.h> +#include <kernel/framebuffer.h> +#include <kernel/timer.h> #include <kernel/panic.h> #include <kernel/io.h> +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); } |