summaryrefslogtreecommitdiff
path: root/src/kernel/arch/amd64/boot.c
blob: 0e61ed36eaee4a4e38144b40f38f3299ee1882ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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);
}