summaryrefslogtreecommitdiff
path: root/kernel/main.c
blob: c15c38d66dccb671572d2cedef98e808d45f8fef (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
54
55
56
57
58
59
#include <comus/cpu.h>
#include <comus/memory.h>
#include <comus/mboot.h>
#include <comus/efi.h>
#include <comus/drivers.h>
#include <comus/drivers/acpi.h>
#include <comus/drivers/pci.h>
#include <comus/drivers/gpu.h>
#include <comus/drivers/ata.h>
#include <comus/user.h>
#include <comus/fs.h>
#include <comus/procs.h>
#include <lib.h>

void kreport(void)
{
	cpu_report();
	memory_report();
	acpi_report();
	pci_report();
	ata_report();
	gpu_report();
}

__attribute__((noreturn)) void main(long magic, volatile void *mboot)
{
	// initalize idt and pic
	cpu_init();

	// load multiboot information
	mboot_init(magic, mboot);

	// load efi structures
	efi_init(mboot_get_efi_hdl(), mboot_get_efi_st());

	// initalize memory
	memory_init();

	// initalize devices
	drivers_init();

	// load file systems
	fs_init();

	// initalize processes
	pcb_init();

	// report system state
	kreport();

	// load init process
	pcb_alloc(&init_pcb);
	if (user_load(init_pcb, &fs_disks[0]))
		panic("failed to load init");

	// schedule and dispatch init
	schedule(init_pcb);
	dispatch();
}