-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel.cpp
More file actions
71 lines (59 loc) · 1.88 KB
/
kernel.cpp
File metadata and controls
71 lines (59 loc) · 1.88 KB
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
#include "kernel.hpp"
void motd()
{
term.printk("%11g\n");
term.printk(" \n");
term.printk(" _ _ _ \n");
term.printk(" _ __ | |_(_) |__ _ ___ __ \n");
term.printk(" | '_ \\| __| | '_ \\| | | \\ \\/ / \n");
term.printk(" | | | | |_| | |_) | |_| |> < \n");
term.printk(" |_| |_|\\__|_|_.__/ \\__,_/_/\\_\\ \n");
term.printk("%g\n");
}
static void shell()
{
interpreter interp;
char buf[MAX_LINE_LEN];
size_t len;
int ret;
while (1)
{
term.reset_color();
term.tputs("> ");
len = term.tread_line(buf, MAX_LINE_LEN);
buf[len] = 0;
ret = interp.interpret(buf);
if (ret)
{
/* do smth */
}
}
}
extern "C" void kernel_main(struct multiboot_info *mboot, u32 magic)
{
term.init();
term.set_vga_buffer((u16*)0xb8000);
term.set_default_color(vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK));
term.set_cursor(vga_entry(' ', vga_entry_color(VGA_COLOR_BLACK, VGA_COLOR_LIGHT_GREY)));
term.clear();
term.set_log_level(LL_DEBUG);
motd();
if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
{
LOG(KERN_CRIT "multiboot magic not matching... (%p)\n", magic);
return ;
}
if (mboot->cmdline && *(char*)mboot->cmdline)
LOG(KERN_INFO "booting %9g%s%r\n", mboot->cmdline);
else
LOG(KERN_WARNING "no cmdline\n");
debug.init(mboot);
gdt.init();
mem.init(mboot->mem_upper);
idt.init();
timer.init();
sched.init();
set_interrupts_handlers();
push_ints();
shell();
}