summaryrefslogtreecommitdiff
path: root/src/arch/i386/boot.c
blob: fa35c01fdaca9c7c225a1a934892eb0b41ada16d (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
52
53
#include <arch/generic.h>
#include <arch/i386/gdt.h>
#include <arch/i386/interrupts/idt.h>
#include <arch/i386/multiboot.h>
#include <arch/i386/sysenter.h>
#include <arch/i386/tty.h>
#include <kernel/main.h>
#include <kernel/panic.h>

void module_test(struct multiboot_info *multiboot) {
	log_const("module test...");
	struct multiboot_mod mod = multiboot->mods[0];
	log_write(mod.start, mod.end - mod.start - 1);

	extern void _bss_end;
	long ptr = &_bss_end;
	log_const("_bss_end ");
	log_var_dont_use(ptr);
	extern void _data_end;
	ptr = &_data_end;
	log_const(" _data_end ");
	log_var_dont_use(ptr);
	log_const(" mod.start ");
	log_var_dont_use(mod.start);
	log_const(" mod.end ");
	log_var_dont_use(mod.end);
}

void kmain_early(struct multiboot_info *multiboot) {
	struct kmain_info info;

	// setup some basic stuff
	tty_clear();
	log_const("gdt...");
	gdt_init();
	log_const("idt...");
	idt_init();
	log_const("sysenter...");
	sysenter_setup();
	module_test(multiboot);
	
	{ // find the init module
		struct multiboot_mod *module = &multiboot->mods[0];
		if (multiboot->mods_count < 1) {
			log_const("can't find init! ");
			panic();
		}
		info.init.at   = module->start;
		info.init.size = module->end - module->start;
	}
	
	kmain(info);
}