diff --git a/bootloader/bootloader.asm b/bootloader/bootloader.asm index 09432ff..520aa6f 100644 --- a/bootloader/bootloader.asm +++ b/bootloader/bootloader.asm @@ -87,7 +87,7 @@ load_kernel: stat_pm_init: db "Entering 32bit Protected Mode...", ASCII_END stat_kernel_load: db "Loading kernel into memory...", ASCII_END -stat_boot_success: db "Booting complete!", ASCII_END +stat_boot_success: db "Booting finished. Loading kernel...", ASCII_END BOOT_DRIVE: db 0 diff --git a/bootloader/pm/vga/print.asm b/bootloader/pm/vga/print.asm index 6d1031e..c444f9c 100644 --- a/bootloader/pm/vga/print.asm +++ b/bootloader/pm/vga/print.asm @@ -3,7 +3,7 @@ ; VGA base address: 0xb8000 ; Charpos = 0xb8000 + 2(row*80 + col) -vga_color_buf: db 0x0f ; Buffer to be changed so that we can choose colors! +vga_color_buf: db 0x7f ; Buffer to be changed so that we can choose colors! vga_print: pusha diff --git a/drivers/vga.c b/drivers/vga.c index 48dfa60..45096a0 100644 --- a/drivers/vga.c +++ b/drivers/vga.c @@ -12,7 +12,10 @@ void vga_init() { port_outb(0x3d5, 0x20); // Clear screen - clear_screen(); + // clear_row(0); + // clear_screen(); + + set_cursor_pos(0, 11); } /* @@ -23,8 +26,9 @@ char* get_memory_charpos(unsigned int col, unsigned int row) { } void writechar(char c, unsigned int col, unsigned int row, int attribute_byte) { + if( !attribute_byte ) - attribute_byte = 0x0f; + attribute_byte = DEFAULT_COLOR; char* mem = get_memory_charpos(col, row); *mem = c; // Write the character @@ -41,10 +45,15 @@ void set_cursor_pos(unsigned int col, unsigned int row) { /* Graphics Functions */ +void clear_row(unsigned int row) { + for( int c = 0; c < MAX_COLS; c++ ) + writechar(0x20, c, row, 0x0); +} + + void clear_screen() { - for( int c = 0; c < MAX_COLS; c++ ) - for( int r = 0; r < MAX_ROWS; r++ ) - writechar(0x20, c, r, 0xf0); + for( int r = 0; r < MAX_ROWS; r++ ) + clear_row(r); } /* diff --git a/drivers/vga.h b/drivers/vga.h index 04306ae..82c5af4 100644 --- a/drivers/vga.h +++ b/drivers/vga.h @@ -1,6 +1,7 @@ #define VGA_ADDRESS (char*)0xb8000 #define VGA_ADDRESS_MAX (char*)0xb8fa0 +#define DEFAULT_COLOR 0x07 #define MAX_ROWS 25 #define MAX_COLS 80 @@ -12,6 +13,7 @@ enum align {LEFT, RIGHT, MIDDLE}; char* get_memory_charpos(unsigned int col, unsigned int row); void writechar(char c, unsigned int col, unsigned int row, int colorcode); void clear_screen(); +void clear_row(unsigned int row); void set_cursor_pos(); void print(); void println(); diff --git a/kernel/kernel.c b/kernel/kernel.c index 517032e..343a8da 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -1,24 +1,35 @@ +#include "kernel.h" #include "memory.h" #include "../drivers/vga.h" #include "../lib/str.h" #include "../lib/strf.h" -void main() { +void display_status(char* status_text) { + clear_row(0); + set_cursor_pos(0, 0); + + print(status_text, 0x7f); +} + +void init() { + display_status("Kernel loaded"); + vga_init(); // Initialize the screen first // i.e. clear the screen et cetera. char* title = "eOS Version 0.2 2021"; - set_cursor_pos(0, 2); - printalign(title, 0xf0, MIDDLE); + println(title, DEFAULT_COLOR); char* subtitle = "A x86 operating system, licenced under GPL-2.0"; - set_cursor_pos(0, 3); - printalign(subtitle, 0xf8, MIDDLE); + println(subtitle, DEFAULT_COLOR); + /* + print("Kernel offset: ", DEFAULT_COLOR); + println("0x1000", DEFAULT_COLOR); + */ - char* strbuf = "String concat: "; - char* str2 = "WORKS! :D"; + char* strbuf = "Concat test: "; + char* str2 = "Works!"; strbuf = strcat(strbuf, str2); - set_cursor_pos(0, 0); - println(strbuf, 0xf0); + println(strbuf, DEFAULT_COLOR); } diff --git a/kernel/kernel.h b/kernel/kernel.h new file mode 100644 index 0000000..4ef9269 --- /dev/null +++ b/kernel/kernel.h @@ -0,0 +1,2 @@ +void init(); +void display_status(char*); diff --git a/kernel/kernel_entry.asm b/kernel/kernel_entry.asm index 3d2fa88..13b7cd7 100644 --- a/kernel/kernel_entry.asm +++ b/kernel/kernel_entry.asm @@ -1,5 +1,5 @@ [bits 32] -[extern main] +[extern init] -call main +call init jmp $ diff --git a/kernel/memory.c b/kernel/memory.c index 8986d54..8c5815e 100644 --- a/kernel/memory.c +++ b/kernel/memory.c @@ -1,9 +1,2 @@ #include "memory.h" -char* malloc(unsigned int size) { - return " "; -} - -void mfree(char* p) { - -}