summaryrefslogtreecommitdiff
path: root/src/kernel/arch/amd64/boot.c
diff options
context:
space:
mode:
authordzwdz2022-07-16 13:33:00 +0200
committerdzwdz2022-07-16 13:33:00 +0200
commit912d2e3c7eb1baa71dda2c0a28aa5809eaa96f27 (patch)
tree4e27f3538466d5fd63a311d50916039a7a15a485 /src/kernel/arch/amd64/boot.c
parent1eeb66af44ab335888410d716d604e569f20866e (diff)
amd64: barely boot into kernel code
Diffstat (limited to 'src/kernel/arch/amd64/boot.c')
-rw-r--r--src/kernel/arch/amd64/boot.c51
1 files changed, 51 insertions, 0 deletions
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 <kernel/arch/generic.h>
+#include <kernel/arch/amd64/32/gdt.h>
+#include <kernel/arch/amd64/ata.h>
+#include <kernel/arch/amd64/boot.h>
+#include <kernel/arch/amd64/driver/fsroot.h>
+#include <kernel/arch/amd64/driver/ps2.h>
+#include <kernel/arch/amd64/driver/serial.h>
+#include <kernel/arch/amd64/interrupts/idt.h>
+#include <kernel/arch/amd64/interrupts/irq.h>
+#include <kernel/arch/amd64/multiboot.h>
+#include <kernel/arch/amd64/tty/tty.h>
+#include <kernel/main.h>
+#include <kernel/mem/alloc.h>
+#include <kernel/panic.h>
+
+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);
+}