diff --git a/chroma/inc/kernel/boot/boot.h b/chroma/inc/kernel/boot/boot.h index 7f21343..7c0f9e7 100644 --- a/chroma/inc/kernel/boot/boot.h +++ b/chroma/inc/kernel/boot/boot.h @@ -2,6 +2,11 @@ #ifndef _BOOTLOADER_H_ #define _BOOTLOADER_H_ +/************************ + *** Team Kitty, 2020 *** + *** Chroma *** + ***********************/ + #ifdef __cplusplus extern "C" { #endif diff --git a/chroma/inc/kernel/chroma.h b/chroma/inc/kernel/chroma.h index 0f3000b..b9e1eb7 100644 --- a/chroma/inc/kernel/chroma.h +++ b/chroma/inc/kernel/chroma.h @@ -1,9 +1,14 @@ #pragma once /************************ *** Team Kitty, 2020 *** - *** Sync *** + *** Chroma *** ***********************/ +/* This file serves as the central kernel header. Every file in the kernel should include this header. + * It provides functionality to every core component of the system, and provides unrestricted cross-communication between modules. + * It also provides the symbols for the framebuffer and configuration file, which are both equually important. + */ + #include #include #include @@ -12,6 +17,7 @@ #include #include #include +#include extern size_t LoadAddr; extern bootinfo bootldr; diff --git a/chroma/inc/kernel/system/descriptors.h b/chroma/inc/kernel/system/descriptors.h index 3d71caa..0832045 100644 --- a/chroma/inc/kernel/system/descriptors.h +++ b/chroma/inc/kernel/system/descriptors.h @@ -1,6 +1,11 @@ #include #include +/************************ + *** Team Kitty, 2020 *** + *** Chroma *** + ***********************/ + typedef struct __attribute__((packed)) { uint16_t LowLimit; uint16_t BaseLow; diff --git a/chroma/inc/kernel/system/heap.h b/chroma/inc/kernel/system/heap.h index a0a2cc2..91adb33 100644 --- a/chroma/inc/kernel/system/heap.h +++ b/chroma/inc/kernel/system/heap.h @@ -1,9 +1,12 @@ -#ifndef KHEAP_H -#define KHEAP_H +#pragma once + +/************************ + *** Team Kitty, 2020 *** + *** Chroma *** + ***********************/ #include #include uint8_t HeapEnabled = 0; -#endif diff --git a/chroma/inc/kernel/system/interrupts.h b/chroma/inc/kernel/system/interrupts.h index f381c40..0522f0a 100644 --- a/chroma/inc/kernel/system/interrupts.h +++ b/chroma/inc/kernel/system/interrupts.h @@ -1,6 +1,11 @@ #pragma once #include +/************************ + *** Team Kitty, 2020 *** + *** Chroma *** + ***********************/ + extern const char* ExceptionStrings[]; diff --git a/chroma/inc/kernel/system/io.h b/chroma/inc/kernel/system/io.h index 91ed1ad..909eef8 100644 --- a/chroma/inc/kernel/system/io.h +++ b/chroma/inc/kernel/system/io.h @@ -1,5 +1,10 @@ #include +/************************ + *** Team Kitty, 2020 *** + *** Chroma *** + ***********************/ + uint8_t kbdSBuffer[8]; uint8_t InputBuffer[128]; diff --git a/chroma/inc/kernel/system/memory.h b/chroma/inc/kernel/system/memory.h index e65b05f..2151d77 100644 --- a/chroma/inc/kernel/system/memory.h +++ b/chroma/inc/kernel/system/memory.h @@ -2,6 +2,11 @@ #include #include +/************************ + *** Team Kitty, 2020 *** + *** Chroma *** + ***********************/ + #define PAGE_SIZE 4096 #define PAGES_PER_BUCKET 8 diff --git a/chroma/inc/kernel/video/bitmapfont.h b/chroma/inc/kernel/video/bitmapfont.h index ab347c6..d39b806 100644 --- a/chroma/inc/kernel/video/bitmapfont.h +++ b/chroma/inc/kernel/video/bitmapfont.h @@ -1,6 +1,6 @@ /************************ - *** Team Kitty, 2019 *** - *** Sync *** + *** Team Kitty, 2020 *** + *** Chroma *** ***********************/ // This file contains all of the bitmap fonts made by me (Curle) and taken from the public domain diff --git a/chroma/kernel.c b/chroma/kernel.c index 6422b9d..e2a484d 100644 --- a/chroma/kernel.c +++ b/chroma/kernel.c @@ -1,5 +1,17 @@ #include +/************************ + *** Team Kitty, 2020 *** + *** Chroma *** + ***********************/ + +/* This file is the entry point to the system. + * It dictates the order of operations of everything the kernel actually does. + * If a function isn't fired here, directly or indirectly, it is not run. + */ + + + size_t KernelAddr = (size_t) &LoadAddr; size_t KernelEnd = (size_t) &end; diff --git a/chroma/system/cpu.c b/chroma/system/cpu.c index b191728..8d142f2 100644 --- a/chroma/system/cpu.c +++ b/chroma/system/cpu.c @@ -1,6 +1,23 @@ #include #include +/************************ + *** Team Kitty, 2020 *** + *** Chroma *** + ***********************/ + +/* This class provides functions for setting up and preparing the CPU for the things the kernel will do. + * Mainly, it allows you to: + * + * Set up and install the GDT and IDT + * Refresh the Code Segment to force ourselves into our own GDT + * Install new ISR and IRQ handlers. + + * It also has (unused) functionality for extra stacks, to be used with Non-Maskable Interrupt, Double Fault, Machine Check and Breakpoint Exceptions. + * //TODO + * + */ + #define NMI_STACK 4096 #define DF_STACK 4096 #define MC_STACK 4096 diff --git a/chroma/system/drivers/keyboard.c b/chroma/system/drivers/keyboard.c index cf52ea6..fd2cb6e 100644 --- a/chroma/system/drivers/keyboard.c +++ b/chroma/system/drivers/keyboard.c @@ -1,5 +1,20 @@ #include +/************************ + *** Team Kitty, 2020 *** + *** Chroma *** + ***********************/ + +/* This file contains (mostly unused) implementations of a full PS/2 keyboard driver. + * + * It provides provisions for full 2-way communication, as well as auxiliary key commands. + * //TODO: Media keys? + * + * Once this driver is to a workable state, I would like to start adding a proper keyboard buffer, + * which will integrate with a window system. + * + */ + char keys[128] = { 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', diff --git a/chroma/system/interrupts.c b/chroma/system/interrupts.c index 409e453..879ab63 100644 --- a/chroma/system/interrupts.c +++ b/chroma/system/interrupts.c @@ -1,6 +1,6 @@ /************************ - *** Team Kitty, 2019 *** - *** Sync *** + *** Team Kitty, 2020 *** + *** Chroma *** ***********************/ /* This file contains all of the ISR and IRQ diff --git a/chroma/system/memory/paging.c b/chroma/system/memory/paging.c index 6d3fb4a..108c148 100644 --- a/chroma/system/memory/paging.c +++ b/chroma/system/memory/paging.c @@ -1,5 +1,25 @@ #include +/************************ + *** Team Kitty, 2020 *** + *** Chroma *** + ***********************/ + +/**************************************** + * W O R K I N P R O G R E S S * + **************************************** + * + * This file contains functions for virtual memory management. + * + * Virtual Memory Management is still a work in progress. + * The functions here are hold-offs from old versions of the software implemented here, as well as from the EFI version of Chroma, called Sync. + * + * There, these functions worked, but here, under BIOS, it's a lot more difficult. + * It will take some time to get these functions working. + * + */ + + //__attribute__((aligned(4096))) static size_t Pagetable[512] = {0}; #define LAST_ENTRY 0xFF8 diff --git a/chroma/system/memory/physmem.c b/chroma/system/memory/physmem.c index 4cc442a..e2e9d87 100644 --- a/chroma/system/memory/physmem.c +++ b/chroma/system/memory/physmem.c @@ -1,6 +1,27 @@ #include #include +/************************ + *** Team Kitty, 2020 *** + *** Chroma *** + ***********************/ + +/* This file contains functions for physical memory management. + * + * This is also called blocking, or block memory allocation. + * It mostly deals with the memory map handed to us by the bootloader. + * + * It is useful in virtual memory management, because it allows us to map one block of physical memory to one page of virtual memory. + * + * Most of the processing here is done with a bitwise mapping of blocks to allocations, normally called a memory bitmap. + * See heap.h for the implementation. + * + * This file also contains memory manipulation functions, like memset and memcpy. + * //TODO: replace these functions with SSE2 equivalent. + * + */ + + uint8_t* Memory = ((uint8_t*)(&end)); uint8_t* MemoryStart; size_t MemoryBuckets; diff --git a/chroma/system/rw.c b/chroma/system/rw.c index f86ca02..aa161ea 100644 --- a/chroma/system/rw.c +++ b/chroma/system/rw.c @@ -1,5 +1,14 @@ #include +/************************ + *** Team Kitty, 2020 *** + *** Chroma *** + ***********************/ + +/* This file serves to allow us to communicate with the computer through raw I/O. + * It provides interfaces for Ports and commonly used Registers (Control Registers, Model-Specific Registers, GDT, IDT..) + */ + uint32_t ReadPort(uint16_t Port, int Length) { uint32_t Data = 0; uint16_t Data16 = 0; diff --git a/chroma/system/serial.c b/chroma/system/serial.c index 10e8856..4968b3c 100644 --- a/chroma/system/serial.c +++ b/chroma/system/serial.c @@ -1,4 +1,12 @@ #include +/************************ + *** Team Kitty, 2020 *** + *** Chroma *** + ***********************/ + +/* This file provides functions related to the Serial port. + * Through this file, you send and receive text and extra debugging information if available. + */ #define SERIAL_DATA(base) (base) #define SERIAL_DLAB(base) (base + 1) diff --git a/chroma/video/draw.c b/chroma/video/draw.c index e145c3f..10e77ef 100644 --- a/chroma/video/draw.c +++ b/chroma/video/draw.c @@ -1,6 +1,24 @@ #include #include +/************************ + *** Team Kitty, 2020 *** + *** Chroma *** + ***********************/ + +/* This file contains all of the draw-to-screen routines. + * It (currently; 23/08/20) handles the keyboard input test routine, + * moving the current character back and forth, up and down. + * + * It also handles filling the screen with color in the case of an event, + * and will be hooked into Vector and Shape of lainlib to eventually provide + * geometry. + * + * It will also eventually be plugged into stb_image to provide a way to draw PNGs + * and JPGs from disk. + */ + + #define FONT bitfont_latin static size_t strlen(const char* String) { diff --git a/chroma/video/print.c b/chroma/video/print.c index 2a7ba12..d7146b7 100644 --- a/chroma/video/print.c +++ b/chroma/video/print.c @@ -1,5 +1,18 @@ #include +/************************ + *** Team Kitty, 2020 *** + *** Chroma *** + ***********************/ + +/* This file contains all of the String / Print related functions + * that are required by the core of the kernel. + * + * There will be a proper C++ std::string implementation in lainlib. + * + * This file also provides SerialPrintf. + */ + static size_t strlen(const char* String) { size_t Len = 0; while(String[Len] != '\0') {