working on exposing vga to userspace
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
#include "drivers/serial/serial.h"
|
||||
|
||||
#include <lib/console.h>
|
||||
#include <lib/font.h>
|
||||
#include <lib/print.h>
|
||||
|
||||
#include <drivers/vga/vga.h>
|
||||
|
||||
@@ -7,10 +10,13 @@ static psf_font_t* font;
|
||||
|
||||
static uint32_t console_row;
|
||||
static uint32_t console_col;
|
||||
static uint32_t console_width;
|
||||
static uint32_t console_height;
|
||||
static uint32_t console_text_color;
|
||||
static uint32_t console_backgrnd_color;
|
||||
|
||||
static void write_vga_char(char c) {
|
||||
print_serial("write_vga_char invoked\r\n");
|
||||
uint32_t vga_pitch = vga_get_pitch();
|
||||
uint8_t* glyph = (uint8_t*)font->glyphs + (c * font->hdr->charsz);
|
||||
|
||||
@@ -34,7 +40,14 @@ static void write_vga_char(char c) {
|
||||
|
||||
int set_console_font(const char* path) {
|
||||
font = load_font(path);
|
||||
return font != NULL;
|
||||
if (!font) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
console_width = vga_get_width() / 8;
|
||||
console_height = vga_get_height() / font->hdr->charsz;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void set_console_fg(uint32_t color) {
|
||||
@@ -48,10 +61,35 @@ void set_console_bg(uint32_t color) {
|
||||
void console_init() {
|
||||
console_row = 0;
|
||||
console_col = 0;
|
||||
|
||||
set_console_fg(0xFFFFFFFF);
|
||||
vga_clear_scrn(0x000000FF);
|
||||
set_console_bg(0xFF6c7482);
|
||||
vga_clear_scrn(console_backgrnd_color);
|
||||
}
|
||||
|
||||
void console_putchar(char c) {
|
||||
if (!font) return;
|
||||
|
||||
if (c == '\n') {
|
||||
print_serial("\r\n");
|
||||
console_col = 0;
|
||||
console_row++;
|
||||
if (console_row >= console_height) {
|
||||
console_row = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
write_serial(c);
|
||||
write_vga_char(c);
|
||||
|
||||
console_col++;
|
||||
if (console_col >= console_width) {
|
||||
console_col = 0;
|
||||
console_row++;
|
||||
}
|
||||
|
||||
if (console_row >= console_height) {
|
||||
console_row = 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user