diff --git a/core/irq_handler.c b/core/irq_handler.c index 1bd1297..e5f9331 100644 --- a/core/irq_handler.c +++ b/core/irq_handler.c @@ -25,5 +25,5 @@ __attribute__((interrupt)) void timer_handler(struct interrupt_frame *frame) __attribute__((interrupt)) void serial_handler(struct interrupt_frame *frame) { EOIIrq(IRQ_COM1); - serial_do_irq(frame); + serialDoIrq(frame); } diff --git a/core/main.c b/core/main.c index 789309e..182341c 100644 --- a/core/main.c +++ b/core/main.c @@ -10,6 +10,9 @@ #include "pit.h" #include "serial.h" #include "stdarg.h" +#ifdef RUN_TEST +#include "test.h" +#endif #include "vga.h" #define CHECK_FLAG(flags, bit) ((flags) & (1 << (bit))) @@ -23,12 +26,13 @@ void cpuid(int code, uint32_t *a, uint32_t *d) void kmain(unsigned long magic, unsigned long addr) { unsigned long upper_mem = 0; - initVGA(BLACK, GREEN); - printf("Setting up IDT\n"); + VGASetup(BLACK, GREEN); + + printf("Setting up Interruptions\n"); gdtSetup(); idtSetup(); irqSetup(); - initPit(100); + pitSetup(100); if (magic == MULTIBOOT_BOOTLOADER_MAGIC) { // Get loaded by Grub wuth mutliboot version 1 multiboot_info_t *mbi = (multiboot_info_t *)addr; @@ -53,16 +57,23 @@ void kmain(unsigned long magic, unsigned long addr) printf("Cannot get upper phy mem bound. Using default value 32MB\n"); upper_mem = 32 * 1024; } - memInit(upper_mem); + + printf("Setting up Pagination\n"); + memSetup(upper_mem); printf("Setting up IRQ handlers\n"); irqSetRoutine(IRQ_KEYBOARD, keyboard_handler); + printf("Enabling HW interrupts\n"); exceptionSetRoutine(EXCEPTION_DOUBLE_FAULT, print_handler); // Enabling the HW interrupts asm volatile("sti\n"); - printf("Init Serial\n"); - initSerial(115200); + + printf("Setting up Serial link (115200)\n"); + serialSetup(115200); +#ifdef RUN_TEST + run_test(); +#endif int count = 0; while (1) { diff --git a/core/mem.c b/core/mem.c index 4a11ad3..09712a0 100644 --- a/core/mem.c +++ b/core/mem.c @@ -9,7 +9,7 @@ static unsigned long bottom_mem; static unsigned long top_mem; -int memInit(unsigned long upper_mem) +int memSetup(unsigned long upper_mem) { printf("Free Mem going from %d to %d\n", &__ld_kernel_end, upper_mem * 1024); unsigned long memdesc_end = diff --git a/core/mem.h b/core/mem.h index e0929df..084c214 100644 --- a/core/mem.h +++ b/core/mem.h @@ -16,6 +16,6 @@ struct mem_desc{ }; -int memInit(unsigned long upper_mem); +int memSetup(unsigned long upper_mem); unsigned long allocPage(void); int unrefPage(unsigned long addr); diff --git a/drivers/pit.c b/drivers/pit.c index d53f301..697d76c 100644 --- a/drivers/pit.c +++ b/drivers/pit.c @@ -2,7 +2,7 @@ #include "io.h" #include "irq.h" -int initPit(unsigned int freq) +int pitSetup(unsigned int freq) { unsigned int divisor = PIT_FREQ / freq; if (divisor > 65535) diff --git a/drivers/pit.h b/drivers/pit.h index 2e5f85c..e2901b0 100644 --- a/drivers/pit.h +++ b/drivers/pit.h @@ -12,5 +12,5 @@ // 5-4: access mode. 0 -> latch count; 1 -> low value only; 2 -> high value only; // 3 -> low then high 3-1: mode. See https://wiki.osdev.org/PIT -int initPit(unsigned int freq); +int pitSetup(unsigned int freq); diff --git a/drivers/serial.c b/drivers/serial.c index a564b9c..5f32738 100644 --- a/drivers/serial.c +++ b/drivers/serial.c @@ -21,7 +21,7 @@ #define UART_1_STOP_BIT 0x00 #define UART_2_STOP_BITS 0x04 -void initSerial(int speed) +void serialSetup(int speed) { unsigned short div = SERIAL_MAX_SPEED / speed; outb(PORT + 1, 0x00); // Disable all interrupts @@ -40,7 +40,7 @@ int isTransmitEmpty() return (inb(PORT + 5) & 0x20); } -void writeSerial(char a) +void serialWrite(char a) { while (isTransmitEmpty() == 0) ; @@ -48,9 +48,9 @@ void writeSerial(char a) outb(PORT, a); } -void serial_do_irq(struct interrupt_frame *level) +void serialDoIrq(struct interrupt_frame *level) { (void)level; char c = inb(PORT); - writeSerial(c); + serialWrite(c); } diff --git a/drivers/serial.h b/drivers/serial.h index 8b94ad9..15db74a 100644 --- a/drivers/serial.h +++ b/drivers/serial.h @@ -1,6 +1,6 @@ #pragma once #include "irq.h" -void initSerial(int speed); -void writeSerial(char a); -void serial_do_irq(struct interrupt_frame *frame); +void serialSetup(int speed); +void serialWrite(char a); +void serialDoIrq(struct interrupt_frame *frame); diff --git a/drivers/vga.c b/drivers/vga.c index 193d1cc..d02f503 100644 --- a/drivers/vga.c +++ b/drivers/vga.c @@ -6,7 +6,7 @@ static uint vgaBgColor; static uint vgaColor; static int line, col; -int initVGA(uint bgColor, uint color) +int VGASetup(uint bgColor, uint color) { vgaBgColor = bgColor; vgaColor = color; diff --git a/drivers/vga.h b/drivers/vga.h index bcb933b..e21969d 100644 --- a/drivers/vga.h +++ b/drivers/vga.h @@ -18,7 +18,7 @@ void vprintf(const char *format, va_list ap); void printf(const char *format, ...); -int initVGA(uint bgColor, uint color); +int VGASetup(uint bgColor, uint color); void clearScreen(uint bgColor); void printInt(int integer); void printIntDetails(int integer, uint color, uint bgColor, int startX, int startY);