X-Git-Url: http://git.dujemihanovic.xyz/posts?a=blobdiff_plain;f=kernel%2Fkernel.c;h=4c6efd8692da90d7ab15cf782846b3194e9483f7;hb=94770e6354578485b2aed68dcc3064e5d6862645;hp=7ac2ad72d79127aa2c942ca62a3561b3a8da9cb6;hpb=6c6312e540a570d376aae5551626128fcc1cd1c6;p=nameless-os.git diff --git a/kernel/kernel.c b/kernel/kernel.c index 7ac2ad7..4c6efd8 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -1,17 +1,31 @@ #include +#include +#include +#include +#include -const char *string = "Hello there!\n\n\ -Hopefully your machine manages to print this text.\n\ -If it did, that's great news because I managed to write a partial VGA driver.\n\n\ -Right now, the short-term roadmap is as follows:\n\n\ -* Complete the text-mode part of the VGA driver.\n\ -* Enable interrupts using the PIC.\n\ -* Write a driver for the Intel 8042 PS/2 controller so the OS can receive keystrokes.\n\ -* Once all that is done, it would be desirable to start the switch to userspace so the OS can actually be remotely usable.\n\n\ -Feel free to mess around with the code, although I doubt it will be very interesting at the moment.\n"; +extern void double_fault(struct abort_frame *frame); +extern void keyb_handler(struct interrupt_frame *frame); +struct idt_descriptor idt[256] __attribute__((aligned(0x10))); +struct idtr idtr __attribute__((aligned(0x10))); -void _start(void) +void kmain(void) { screen_clear(); - kprint(string); + kprint("Welcome to Nameless OS!\nRunning revision: ", 0); + kprint(GIT_COMMIT, 0); + kprint("\n", 0); + kprint("Preparing IDT...\n", 0); + idt_set_descriptor(idt, 0x8, 0x8, (uint32_t) double_fault, IDT_TRAP_GATE, 0x0); + idt_set_descriptor(idt, 0x21, 0x8, (uint32_t) keyb_handler, IDT_INTERRUPT_GATE, 0x0); + kprint("IDT prepared, loading...\n", 0); + populate_idtr(&idtr, idt); + load_idt(idtr); + kprint("IDT loaded, enabling interrupts...\n", 0); + pic_init(0x20, 0x28); + pic_mask_all(); + pic_unmask(1); + asm volatile ("sti"); + kprint("All done\n", 0); + while(1); }