Add: framebuffer color output functions
This commit is contained in:
Binary file not shown.
BIN
kernel.elf
BIN
kernel.elf
Binary file not shown.
23
kmain.c
23
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;
|
||||
}
|
||||
|
||||
36
stdio.c
36
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;
|
||||
|
||||
2
stdio.h
2
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
|
||||
|
||||
Reference in New Issue
Block a user