Sync/kernel/kernel.c
Jenny Curle 31d2e10b69 Implement a GDT, IDT with ISR and IRQ
Basically, added error handling, interrupts and basic hardware communication is now possible. Yay.
2019-04-07 23:43:09 +01:00

52 lines
1.3 KiB
C

//#include <stdio.h>
#include <kernel/tty.h>
#include <kernel/descriptor_tables.h>
#include <kernel/serial.h>
int kernel_main(void) {
// Prepare the screen, and blank it out.
screen_initialize();
// Prepare the serial console.
init_serial();
serial_print(0x3F8, "[INFO] Serial ready.\r\n");
// Prepare the GDT
serial_print(0x3F8, "[INFO] Beginning GDT subroutine.\r\n");
gdt_install();
serial_print(0x3F8, "[INFO] GDT subroutine complete.\r\n");
// Prepare interrupts
serial_print(0x3F8, "[INFO] Beginning IDT subroutine.\r\n");
idt_install();
serial_print(0x3F8, "[INFO] IDT subroutine complete.\r\n[INFO] Enabling interrupts.\r\n");
asm volatile("sti");
serial_print(0x3F8, "[INFO] Starting System Clock.\r\n");
timer_install();
serial_print(0x3F8, "[INFO] All subsystems ready. Printing message.\r\n");
//Print a copyright message.
term_writes("(c)");
term_setcolor(GREEN);
term_writes(" Project");
term_setcolor(RED);
term_writes("RED");
term_setcolor(WHITE);
term_writes(", 2019\n");
serial_print(0x3F8, "[INFO] All operations complete. Checking for other tasks...\r\n");
for(size_t i = 0; i < 3000; i++) {}
serial_print(0x3F8, "[DEBUG] Attempting a Divide by Zero error.\r\n");
//term_putchar(5/0);
serial_print(0x3F8, "[DEBUG] Survived the error!\r\n");
for(;;) {}
return 0;
}