Curle
022884e20d
Including a new, rewritten and restructured boot.s file, plus automagical Protected Mode.
88 lines
2.6 KiB
C
88 lines
2.6 KiB
C
/////////////////////////////
|
|
/// ///
|
|
/// Team Kitty, 2019 ///
|
|
/// ProjectRED ///
|
|
/// ///
|
|
/////////////////////////////
|
|
|
|
//#include <stdio.h>
|
|
|
|
#include <kernel/tty.h>
|
|
#include <kernel/descriptor_tables.h>
|
|
#include <kernel/serial.h>
|
|
|
|
void gdb_end() {} /* GDB Debugging stump */
|
|
|
|
int kernel_main(void) {
|
|
/* The kernel is started in 32-bit protected mode by the ASM. */
|
|
/* Here, we start by enabling the screen, then loading a GDT and IDT into the actual places they need to be. */
|
|
|
|
/* Black the screen out. */
|
|
screen_initialize();
|
|
|
|
/* Prepare the serial line for our debug output. */
|
|
init_serial();
|
|
serial_print(0x3F8, "[INFO] Serial ready.\r\n");
|
|
|
|
|
|
serial_print(0x3F8, "[INFO] Beginning GDT subroutine.\r\n");
|
|
|
|
/* term_writes: writes a string to the terminal. */
|
|
term_writes("GDT...");
|
|
|
|
/* Prepares the Global Descriptor Table, called from gdt.c */
|
|
gdt_install();
|
|
|
|
/* puts: writes a line to the terminal. */
|
|
puts("GDT Ready.");
|
|
serial_print(0x3F8, "[INFO] GDT subroutine complete.\r\n");
|
|
|
|
/* Prepare the Interrupt Descriptor Table. */
|
|
serial_print(0x3F8, "[INFO] Beginning IDT subroutine.\r\n");
|
|
term_writes("IDT...");
|
|
idt_install();
|
|
puts("IDT Ready.");
|
|
serial_print(0x3F8, "[INFO] IDT subroutine complete.\r\n[INFO] Enabling interrupts.\r\n");
|
|
|
|
gdb_end(); /* The first important step. Waypoint it for gdb debugging. */
|
|
|
|
term_writes("Memory available:");
|
|
/* TODO: implement check_a20, which double-triple checks the state of the A20 line. */
|
|
|
|
//if(check_a20())
|
|
puts(" 4GB");
|
|
serial_print(0x3F8, "[INFO] A20 enabled. 4GB memory available.");
|
|
|
|
/* The first important thing: start the system clock immediately. */
|
|
serial_print(0x3F8, "[INFO] Starting System Clock.\r\n");
|
|
term_writes("Timer...");
|
|
timer_install();
|
|
puts("Timer Ready.");
|
|
|
|
serial_print(0x3F8, "[INFO] All subsystems ready. Printing message.\r\n");
|
|
|
|
/* Everything is ready; print a pretty message. */
|
|
term_writes("\n(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");
|
|
|
|
/* Here are a series of tests for the ANSI escape code and CSI implementations. */
|
|
term_writes("\x1b[BA"); /* Down a line, then A. */
|
|
|
|
|
|
/* A stub causing a Divide by Zero error. */
|
|
//serial_print(0x3F8, "[DEBUG] Attempting a Divide by Zero error.\r\n");
|
|
//char div = (5 / 0);
|
|
//serial_print(0x3F8, "[DEBUG] Survived the error!\r\n");
|
|
|
|
gdb_end(); /* Everything is done. The last debug routine. */
|
|
return 0;
|
|
}
|
|
|