aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/kernel.c
blob: 384762718cd8642a0113497bde1c684be6901591 (plain) (blame)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <kernel/multiboot.h>
#include <kernel/graphics/vesa.h>
#include <kernel/gdt/gdt.h>
#include <kernel/interrupts/interrupts.h>
#include <kernel/io/io.h>
#include <kernel/timer/timer.h>
#include <kernel/memory/paging.h>
#include <kernel/input/input.h>
#include <kernel/acpi/acpi.h>
#include <kernel/lib/lib.h>
#include <kernel/syscall/syscall.h>
#include <kernel/pci/pci.h>
#include <kernel/net/network.h>
#include <kernel/tasks/task.h>
#include <kernel/fs/load.h>
#include <kernel/fs/elf.h>
#include <kernel/lib/stdio.h>
#include <kernel/fs/ata.h>
#include <kernel/fs/ext2.h>
#include <kernel/cmos/rtc.h>
#include <kernel/memory/alloc.h>

void kernel_main(uint32_t magic, uint32_t multiboot_address)
{
	if (magic != MULTIBOOT_BOOTLOADER_MAGIC) {
		vga_log("Invalid boot magic!");
		halt_loop();
	}

	if (multiboot_address & 7) {
		vga_log("Unaligned mbi!");
		halt_loop();
	}

	vga_log("Installing basic features of Melvix...");

	// Install features
	gdt_install();
	init_serial();
	idt_install();
	isrs_install();
	irq_install();
	paging_install(multiboot_address);

	multiboot_parse(multiboot_address);

	// Install drivers
	cli();
	timer_install();
	mouse_install();
	keyboard_install();
	pci_remap();
	network_install();
	sti();

	memory_print();
	rtc_print();

	ata_init();
	ext2_init_fs();
	ext2_mount(fs_root);

	load_binaries();
	set_optimal_resolution();

	// tasking_install();

#ifdef INSTALL_MELVIX
	panic("Installation isn't supported right now!");
#endif

	// load_elf((char *)userspace);

	// syscalls_install();
	// exec(userspace);

	// panic("This should NOT happen!");

	// asm ("div %0" :: "r"(0)); // Exception testing x/0
}