From 912d2e3c7eb1baa71dda2c0a28aa5809eaa96f27 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 16 Jul 2022 13:33:00 +0200 Subject: amd64: barely boot into kernel code --- src/kernel/arch/amd64/boot.c | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/kernel/arch/amd64/boot.c (limited to 'src/kernel/arch/amd64/boot.c') diff --git a/src/kernel/arch/amd64/boot.c b/src/kernel/arch/amd64/boot.c new file mode 100644 index 0000000..0e61ed3 --- /dev/null +++ b/src/kernel/arch/amd64/boot.c @@ -0,0 +1,51 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void find_init(struct multiboot_info *multiboot, struct kmain_info *info) +{ + struct multiboot_mod *module = (void*)multiboot->mods; + kprintf("mods count 0x%x", multiboot->mods_count); + if (multiboot->mods_count < 1) { + kprintf("can't find init! "); + panic_invalid_state(); + } + info->init.at = module->start; + info->init.size = module->end - module->start; +} + +void kmain_early(struct multiboot_info *multiboot) { + struct kmain_info info; + + tty_init(); + kprintf("idt..."); + idt_init(); + kprintf("irq..."); + irq_init(); + + info.memtop = (void*) (multiboot->mem_upper * 1024); + find_init(multiboot, &info); + kprintf("mem...\n"); + mem_init(&info); + + kprintf("rootfs..."); + vfs_root_init(); + ps2_init(); + serial_init(); + + kprintf("ata..."); + ata_init(); + + kmain(info); +} -- cgit v1.2.3