Commenting improvements

Even more preparing for UEFI.
This commit is contained in:
Curle 2019-07-22 22:32:35 +01:00
parent 272d98f42e
commit 04e70ab274
2 changed files with 45 additions and 45 deletions

View File

@ -3,88 +3,84 @@
*** Sync *** *** Sync ***
***********************/ ***********************/
/* This file contains the entry point /*
* to the kernel. This section consists * Sync main..
* mainly of bootloading functions. *
* Going off the back of Syncboot, the UEFI bootloader which currently only supports x86_64,
* this kernel is to be rewritten. The kernel is started in Long Mode, with interrupts enabled.
*
* Therefore, most of the checks are no longer needed, as they are performed by Syncboot for us.
* So, this becomes an exercise in time saving.
*
* *
* Graphics and memory will be setup
* at later stages.
*/ */
//#include <stdio.h> //#include <stdio.h>
#include <kernel.h> #include <kernel.h>
#include <kernel/tty.h>
#include <kernel/serial.h>
#include <kernel/descriptor_tables.h>
void gdb_end() {} /* GDB Debugging stump */ void gdb_end() {} /* GDB Debugging stump */
int kernel_main(void) { int kernel_main(void) {
/* The kernel is started in 32-bit protected mode by the ASM. */ /* The kernel is started in 64-bit Long Mode by Syncboot. */
/* Here, we start by enabling the screen, then loading a GDT and IDT into the actual places they need to be. */ /* Here, we start by drawing a splash, then loading a GDT and IDT into the placeholder UEFI gives us. */
/* Black the screen out. */ /* Not sure how well serial would work in UEFI. */
screen_initialize(); // TODO: look at this.
/* Prepare the serial line for our debug output. */ //init_serial();
init_serial(); //serial_print(0x3F8, "[INFO] Serial ready.\r\n");
serial_print(0x3F8, "[INFO] Serial ready.\r\n");
serial_print(0x3F8, "[INFO] Beginning GDT subroutine.\r\n"); //serial_print(0x3F8, "[INFO] Beginning GDT subroutine.\r\n");
/* term_writes: writes a string to the terminal. */ /* term_writes: writes a string to the terminal. */
term_writes("GDT..."); //term_writes("GDT...");
/* Prepares the Global Descriptor Table, called from gdt.c */ /* Prepares the Global Descriptor Table, called from gdt.c */
gdt_install(); gdt_install();
/* puts: writes a line to the terminal. */ /* puts: writes a line to the terminal. */
puts("GDT Ready."); //puts("GDT Ready.");
serial_print(0x3F8, "[INFO] GDT subroutine complete.\r\n"); //serial_print(0x3F8, "[INFO] GDT subroutine complete.\r\n");
/* Prepare the Interrupt Descriptor Table. */ /* Prepare the Interrupt Descriptor Table. */
serial_print(0x3F8, "[INFO] Beginning IDT subroutine.\r\n"); //serial_print(0x3F8, "[INFO] Beginning IDT subroutine.\r\n");
term_writes("IDT..."); //term_writes("IDT...");
idt_install(); idt_install();
puts("IDT Ready."); //puts("IDT Ready.");
serial_print(0x3F8, "[INFO] IDT subroutine complete.\r\n[INFO] Enabling interrupts.\r\n"); //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. */ gdb_end(); /* The first important step. Waypoint it for gdb debugging. */
term_writes("Memory available:"); //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. */ /* The first important thing: start the system clock immediately. */
serial_print(0x3F8, "[INFO] Starting System Clock.\r\n"); //serial_print(0x3F8, "[INFO] Starting System Clock.\r\n");
term_writes("Timer..."); //term_writes("Timer...");
timer_install(); timer_install();
puts("Timer Ready."); //puts("Timer Ready.");
serial_print(0x3F8, "[INFO] All subsystems ready. Printing message.\r\n"); //serial_print(0x3F8, "[INFO] All subsystems ready. Printing message.\r\n");
/* Everything is ready; print a pretty message. */ /* Everything is ready; print a pretty message. */
term_setcolor(RED); //term_setcolor(RED);
term_writes("\n(c)"); //term_writes("\n(c)");
term_setcolor(GREEN); //term_setcolor(GREEN);
term_writes(" Sync"); //term_writes(" Sync");
term_setcolor(WHITE); //term_setcolor(WHITE);
term_writes(", 2019\n"); //term_writes(", 2019\n");
serial_print(0x3F8, "[INFO] All operations complete. Checking for other tasks...\r\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. */ /* Here are a series of tests for the ANSI escape code and CSI implementations. */
term_writes("\x1b[BA"); /* Down a line, then A. */ //term_writes("\x1b[BA"); /* Down a line, then A. */
/* A stub causing a Divide by Zero error. */ /* A stub causing a Divide by Zero error. */
serial_print(0x3F8, "[DEBUG] Attempting a Divide by Zero error.\r\n"); //serial_print(0x3F8, "[DEBUG] Attempting a Divide by Zero error.\r\n");
char div = (5 / 0); //char div = (5 / 0);
serial_print(0x3F8, "[DEBUG] Survived the error!\r\n"); //serial_print(0x3F8, "[DEBUG] Survived the error!\r\n");
gdb_end(); /* Everything is done. The last debug routine. */ gdb_end(); /* Everything is done. The last debug routine. */
return 0; return 0;

View File

@ -8,6 +8,10 @@
* a text buffer, or a file, but this code should work on * a text buffer, or a file, but this code should work on
* hardware with an actual serial port and monitor. */ * hardware with an actual serial port and monitor. */
/* After the development of Syncboot, this becomes a little bit harder.
* Some testing will be needed to know for certain whether this will work.
* Until then, this is to be put on hold. 21/07/19 - Curle */
#include <kernel/utils.h> #include <kernel/utils.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdint.h> #include <stdint.h>