aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/graphics
diff options
context:
space:
mode:
authorMarvin Borner2019-10-12 23:28:01 +0200
committerMarvin Borner2019-10-12 23:31:27 +0200
commit876df2125f4f24803d5471894e5308e7425ebfd2 (patch)
treea91b066e93c6694c41384ae8f2e296167715768c /src/kernel/graphics
parentb2f80382659e739d5e37eefff1ebcdfd023bb9fb (diff)
Paging and heap rewrite
VESA drawing causes a Page fault because it tries to use a pointer to the framebuffer which was created before the paging has been initialized. If the resolution is set after the paging has been initialized the CPU throws a triple fault because the int32 call can not happen with paging turned on. To be fixed soon!
Diffstat (limited to 'src/kernel/graphics')
-rw-r--r--src/kernel/graphics/vesa.c18
-rw-r--r--src/kernel/graphics/vga.c8
2 files changed, 11 insertions, 15 deletions
diff --git a/src/kernel/graphics/vesa.c b/src/kernel/graphics/vesa.c
index 9cfcd66..03c189f 100644
--- a/src/kernel/graphics/vesa.c
+++ b/src/kernel/graphics/vesa.c
@@ -7,7 +7,7 @@
#include "font.h"
void switch_to_vga() {
- write_serial("Force switch to VGA!");
+ serial_write("Force switch to VGA!\n");
vesa_available = 0;
regs16_t regs;
regs.ax = 0x0003;
@@ -15,7 +15,7 @@ void switch_to_vga() {
}
struct edid_data get_edid() {
- struct edid_data *edid = umalloc(sizeof(struct edid_data));
+ /*struct edid_data *edid = umalloc(sizeof(struct edid_data));
regs16_t regs;
regs.ax = 0x4F15;
@@ -26,11 +26,11 @@ struct edid_data get_edid() {
ufree(edid);
- return *edid;
+ return *edid;*/
}
struct vbe_mode_info *vbe_set_mode(unsigned short mode) {
- write_serial("Setting VBE mode!");
+ serial_write("Setting VBE mode!\n");
vesa_available = 0;
regs16_t regs;
regs.ax = 0x4F02;
@@ -142,12 +142,11 @@ void vesa_set_pixel(uint16_t x, uint16_t y, uint32_t color) {
}
void vesa_draw_char(char ch, int x, int y) {
- int cx, cy;
int mask[8] = {1, 2, 4, 8, 16, 32, 64, 128};
unsigned char *glyph = font[ch - 32];
- for (cy = 0; cy < 13; cy++) {
- for (cx = 0; cx < 8; cx++) {
+ for (int cy = 0; cy < 13; cy++) {
+ for (int cx = 0; cx < 8; cx++) {
if (glyph[cy] & mask[cx]) {
vesa_set_pixel(x + 8 - cx, y + 13 - cy, terminal_color);
}
@@ -156,14 +155,13 @@ void vesa_draw_char(char ch, int x, int y) {
}
void vesa_draw_rectangle(int x1, int y1, int x2, int y2, int color) {
- int i, j;
char blue = color & 255;
char green = (color >> 8) & 255;
char red = (color >> 16) & 255;
int pos1 = x1 * vbe_bpp + y1 * vbe_pitch;
char *draw = &fb[pos1];
- for (i = 0; i <= y2 - y1; i++) {
- for (j = 0; j <= x2 - x1; j++) {
+ for (int i = 0; i <= y2 - y1; i++) {
+ for (int j = 0; j <= x2 - x1; j++) {
draw[vbe_bpp * j] = blue;
draw[vbe_bpp * j + 1] = green;
draw[vbe_bpp * j + 2] = red;
diff --git a/src/kernel/graphics/vga.c b/src/kernel/graphics/vga.c
index da2a7f4..a470af8 100644
--- a/src/kernel/graphics/vga.c
+++ b/src/kernel/graphics/vga.c
@@ -146,18 +146,16 @@ void terminal_put_keyboard_char(char c) {
void terminal_write_string(const char *data) {
// terminal_write(data, strlen(data));
- write_serial(data);
+ serial_write(data);
}
void terminal_write_number(int data) {
- char converted[128];
- itoa(data, converted, 10);
- write_serial(converted);
+ serial_write_dec(data);
// terminal_write(converted, strlen(converted));
}
void terminal_write_line(const char *data) {
- write_serial(data);
+ serial_write(data);
terminal_column = 0;
// terminal_write_string(data);
terminal_column = 0;