diff --git a/com1.out b/com1.out index c02424c..ecf28e3 100644 Binary files a/com1.out and b/com1.out differ diff --git a/iso/boot/kernel.elf b/iso/boot/kernel.elf index 774221a..620fe76 100755 Binary files a/iso/boot/kernel.elf and b/iso/boot/kernel.elf differ diff --git a/kernel.elf b/kernel.elf index 774221a..620fe76 100755 Binary files a/kernel.elf and b/kernel.elf differ diff --git a/kmain.c b/kmain.c index 37cc297..de43e15 100644 --- a/kmain.c +++ b/kmain.c @@ -7,25 +7,24 @@ int kmain(int retvalue) { - gdt_install(); - idt_install(); - isr_install(); - - // serial testing - init_serial(); - log("serial connection established", 3); + gdt_install(); log("initialized GDT entries", 2); - log("kernel started", 2); + idt_install(); log("initialized IDT", 2); + isr_install(); log("initialized ISRs", 3); + + log("kernel started", 2); clear(); // printf testing // TODO: Framebuffer upgrade: color output + // TODO: Serial printf to dump registers on kernel panic + // TODO: Fix scrolling bug (framebuffer driver) int age = 34; int problems = 124; @@ -41,10 +40,14 @@ int kmain(int retvalue) printf("such hex %x %X\n", 0xcafe, 0xdeadbeef); printf("such pointer %p\n", (void*)0xcafe1234); - + + for (int i=0; i<10; i++) + { + colorputs("hello colorful world!!\n", i); + } // Div by zero exception - printf("Lalala, what a beautiful day! %d", 4/0); + //printf("Lalala, what a beautiful day! %d", 4/0); return retvalue; } diff --git a/os.iso b/os.iso index 8d5f667..3f8b453 100644 Binary files a/os.iso and b/os.iso differ diff --git a/stdio.c b/stdio.c index 27e43d0..1a7b730 100644 --- a/stdio.c +++ b/stdio.c @@ -102,6 +102,33 @@ void putc(char c) move_cursor(VGA_X, VGA_Y); } +void colorputc(char c, unsigned int color) +{ + switch(c) + { + case '\n': + VGA_X = 0; + VGA_Y++; + break; + case '\r': + VGA_X = 0; + break; + default: + putchar(VGA_X, VGA_Y, c); + putcolor(VGA_X, VGA_Y, color); + VGA_X++; + break; + } + + if (VGA_X >= VGA_WIDTH) + { + VGA_Y++; + VGA_X = 0; + } + if (VGA_Y >= VGA_HEIGHT) scroll(1); + move_cursor(VGA_X, VGA_Y); +} + void puts(const char* str) { while (*str) @@ -111,6 +138,15 @@ void puts(const char* str) } } +void colorputs(const char* str, unsigned int color) +{ + while (*str) + { + colorputc(*str, color); + str++; + } +} + void printf(const char* fmt, ...) { int* argp = (int*) &fmt; diff --git a/stdio.h b/stdio.h index f1c2106..c89d3fc 100644 --- a/stdio.h +++ b/stdio.h @@ -14,12 +14,14 @@ void move_cursor(int x, int y); void putchar(int x, int y, char c); void puts(const char* str); +void colorputs(const char* str, unsigned int color); void clear(void); void putcolor(int x, int y, unsigned int color); char getchar(int x, int y); unsigned int getcolor(int x, int y); void scroll(int lines); void putc(char c); +void colorputc(char c, unsigned int color); #define PRINTF_STATE_START 0 #define PRINTF_STATE_LENGTH 1