]> git.dujemihanovic.xyz Git - nameless-os.git/blob - kernel/kernel.c
Enable paging in bootloader
[nameless-os.git] / kernel / kernel.c
1 #include <tty.h>
2 #include <io.h>
3 #include <irq/idt.h>
4 #include <irq/i8259a.h>
5 #include <stdint.h>
6 #include <mm/paging.h>
7
8 extern void double_fault(struct abort_frame *frame);
9 extern void keyb_handler(struct interrupt_frame *frame);
10 extern void pf_handler(struct fault_frame *frame);
11 static struct idt_descriptor idt[256] __attribute__((aligned(0x10)));
12 static struct idtr idtr __attribute__((aligned(0x10)));
13
14
15 void kmain(void)
16 {
17 screen_clear();
18 kprint("Welcome to Nameless OS!\nRunning revision: ", 0);
19 kprint(GIT_COMMIT, 0);
20 kprint("\n", 0);
21 kprint("Preparing IDT...\n", 0);
22 idt_set_descriptor(idt, 8, 0x8, (uint32_t) double_fault, IDT_INTERRUPT_GATE, 0x0);
23 idt_set_descriptor(idt, 14, 0x8, (uint32_t) pf_handler, IDT_INTERRUPT_GATE, 0x0);
24 idt_set_descriptor(idt, 33, 0x8, (uint32_t) keyb_handler, IDT_INTERRUPT_GATE, 0x0);
25 kprint("IDT prepared, loading...\n", 0);
26 populate_idtr(&idtr, idt);
27 load_idt(idtr);
28 kprint("IDT loaded, enabling interrupts...\n", 0);
29 pic_init(0x20, 0x28);
30 pic_mask_all();
31 pic_unmask(1);
32 asm volatile ("sti");
33 kprint("All done\n", 0);
34 while(1);
35 }