-
Notifications
You must be signed in to change notification settings - Fork 2
/
kernel.c
77 lines (55 loc) · 1.71 KB
/
kernel.c
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
#include "multiboot.h"
#include "printk.h"
#include "serial.h"
#include "types.h"
#include "string.h"
#include "boot_log.h"
#include "timer.h"
#include "gdt.h"
#include "ports.h"
#include "idt.h"
#include "isr.h"
#include "vm.h"
#include "kbd.h"
void kmain(struct multiboot *mboot, uintptr_t mboot_magic, uintptr_t esp);
void
kmain(struct multiboot *mboot, uintptr_t mboot_magic, uintptr_t esp)
{
int i;
printk__init();
printk(INFO, "Booting....\n");
printk(INFO, "Enabling serial\n");
serial__init();
printk(INFO, "Turning on serial prink\n");
printk__register_handler(&serial__puts);
printk(INFO, "Enabling gdt\n");
gdt__init();
printk(INFO, "Enabling idt\n");
idt__init();
printk(INFO, "Enabling timer\n");
timer__init(100);
printk(INFO, "Enabling keyboard\n");
kbd__init();
boot_log("Initalizing Multiboot");
boot_log_finish(BOOT_OK);
if (mboot_magic == MULTIBOOT_EAX_MAGIC) {
printk(INFO, "Multiboot kernel\n");
if ((char *)mboot->cmdline != NULL)
printk(INFO, "cmdline: %s\n", (char *)mboot->cmdline);
printk(INFO, "Mem Size: %d\n", mboot->mem_lower + mboot->mem_upper);
paging__init(mboot->mem_lower + mboot->mem_upper);
}
printk(INFO, "Hello World\n");
printk(CRITICAL, "Hello World\n");
printk(WARN, "This is a multiline kernel\n");
for (i = 0; i < 8; i++)
printk(ERROR, "Hello bob %d\n", i);
printk(INFO, "Enabling interrupts\n");
asm volatile ("sti");
#ifdef FORCE_PAGE_FAULT
printk(INFO, "Forcing page fault\n");
uintptr_t *ptr = (uintptr_t *)0xA0000000;
printk(INFO, "pfault %d\n", *ptr);
#endif
while (1);
}