diff --git a/drivers/vga.c b/drivers/vga.c index 333ef52..8821fe7 100644 --- a/drivers/vga.c +++ b/drivers/vga.c @@ -10,6 +10,9 @@ static uint cursor_row = 0; static uint cursor_col = 0; void vga_init() { + // Allocate VGA memory range + pm_alloc_range(VGA_ADDRESS, VGA_ADDRESS_MAX, true); // force alloc the VGA range + // Disable cursor port_outb(0x3d4, 0x0a); port_outb(0x3d5, 0x20); @@ -19,8 +22,6 @@ void vga_init() { clear_screen(); set_cursor_pos(0, 0); - - pm_alloc_range(VGA_ADDRESS, VGA_ADDRESS_MAX, true); // force alloc the VGA range } /* diff --git a/drivers/vga.h b/drivers/vga.h index 3777623..0ba4f1f 100644 --- a/drivers/vga.h +++ b/drivers/vga.h @@ -2,6 +2,9 @@ #define VGA_ADDRESS_MAX 0xb8fa0 #define DEFAULT_COLOR 0x07 +#define URGET_COLOR 0x0c +#define SUCCESS_COLOR 0x0a + #define MAX_ROWS 25 #define MAX_COLS 80 diff --git a/kernel/kernel.c b/kernel/kernel.c index 446c01d..2005a4d 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -9,7 +9,7 @@ void init() { vga_init(); // Initialize the screen first // i.e. clear the screen et cetera. - println("Kernel loaded", DEFAULT_COLOR); + println("Kernel loaded", SUCCESS_COLOR); // enable_paging(); @@ -26,6 +26,14 @@ void init() { */ + char* intbuf = "xxxx"; + int num = 1234; + intbuf = int_to_str(num, intbuf); + print("TEST NUM: ", DEFAULT_COLOR); + println(intbuf, DEFAULT_COLOR); + + /* + // Memory allocation testing printalign("-- PMM Tests --", DEFAULT_COLOR, MIDDLE); @@ -47,4 +55,5 @@ void init() { char* str2 = "Works!"; strbuf = strcat(strbuf, str2); println(strbuf, DEFAULT_COLOR); + */ } diff --git a/kernel/memory.c b/kernel/memory.c index 20c9030..265121e 100644 --- a/kernel/memory.c +++ b/kernel/memory.c @@ -36,7 +36,7 @@ pointer block_alloc(uint blockidx) { block_bflag = CHECK_BITMAP(bitmap, blockidx); if( block_bflag == BM_FREE ) { // check if block is free - println("Alloc!", DEFAULT_COLOR); + println("Allocating block...", DEFAULT_COLOR); mod_bitmap(blockidx, 1); last_block = blockidx; diff --git a/lib/conv.c b/lib/conv.c index b9654c5..2ba09b2 100644 --- a/lib/conv.c +++ b/lib/conv.c @@ -1,6 +1,7 @@ #include "conv.h" +#include "../drivers/vga.h" -void int_to_str(int i, char* buf) { +char* int_to_str(int i, char* buf) { ulong num = (ulong)i; // convert to ulong uint len = ulong_len(num); // number of digits @@ -9,6 +10,8 @@ void int_to_str(int i, char* buf) { int j; for(j = 0; j < len; j++) // iterate over each digit and assign it to the buffer // super dangerous memory write + println("char!", DEFAULT_COLOR); *(buf+j) = (char)(ndigit(num, len-1-j) + ASCII_OFFSET); // apply the ascii offset so that i becomes a char - + + return buf; } diff --git a/lib/conv.h b/lib/conv.h index 42becfc..8c14438 100644 --- a/lib/conv.h +++ b/lib/conv.h @@ -3,4 +3,4 @@ #define ASCII_OFFSET 0x30 -void int_to_str(int i, char* buf); +char* int_to_str(int i, char* buf); diff --git a/lib/math.c b/lib/math.c index fc4415a..bfded6f 100644 --- a/lib/math.c +++ b/lib/math.c @@ -4,7 +4,7 @@ long pow(int num, uint expon) { long prod = 1; while(expon > 0) prod *= num; - --expon; + expon--; return prod; } diff --git a/lib/util.c b/lib/util.c index efdd22d..ba9b2d2 100644 --- a/lib/util.c +++ b/lib/util.c @@ -1,4 +1,5 @@ #include "util.h" +#include "math.h" uint ulong_len(ulong n) { // get the digit length of a number int len = 0;