-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkernel.c
35 lines (26 loc) · 871 Bytes
/
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
/* kernel.c */
#include "screen.h"
#include "init.h"
#include "keyboard.h"
#include "isr.h"
#include "task.h"
void gp_fault_handler(registers_t* regs) {
screen_print("GPF: "); screen_print_hex(regs->err_code); screen_put_char('\n');
screen_print_hex(regs->cs); screen_put_char(' '); screen_print_hex(regs->ss);
screen_put_char(' '); screen_print_hex(regs->ds); screen_put_char('\n');
screen_print("EIP: "); screen_print_hex(regs->eip); screen_put_char('\n');
__asm__ volatile ("cli");
__asm__ volatile ("hlt");
}
void kernel_main () {
const char *msg = "Hello from kernel.c\n";
screen_clear();
screen_print(msg);
init_kernel();
register_interrupt_handler(0xD, &gp_fault_handler);
__asm__ volatile ("sti");
screen_print("start process");
start_process();
// we should never reach this line, and should instead be in kernel_idle_task
for (;;) {}
}