aboutsummaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/graphics/vesa.c20
-rw-r--r--src/kernel/graphics/vesa.h3
-rw-r--r--src/kernel/system.c9
-rw-r--r--src/kernel/system.h5
4 files changed, 22 insertions, 15 deletions
diff --git a/src/kernel/graphics/vesa.c b/src/kernel/graphics/vesa.c
index ba8d84b..1cc508f 100644
--- a/src/kernel/graphics/vesa.c
+++ b/src/kernel/graphics/vesa.c
@@ -18,18 +18,20 @@ void switch_to_vga() {
}
struct edid_data get_edid() {
- struct edid_data *edid = (struct edid_data *) kmalloc(sizeof(struct edid_data));
-
regs16_t regs;
regs.ax = 0x4F15;
- regs.bx = 0x01; // BL
+ regs.bx = 0x1; // BL
regs.es = 0;
- regs.di = (uintptr_t) &edid;
+ regs.di = 0x7E00;
paging_disable();
int32(0x10, &regs);
paging_enable();
- kfree(edid);
+ if ((regs.ax & 0xFF) != 0x4F) {
+ warn("No EDID available!");
+ }
+
+ struct edid_data *edid = (struct edid_data *) 0x7E00;
return *(struct edid_data *) edid;
}
@@ -167,10 +169,10 @@ void set_optimal_resolution() {
switch_to_vga();
} else vga_log("Mode detection succeeded", 11);
- // timer_wait(500);
-
vbe_set_mode(highest);
+ vesa_draw_string(vga_buffer);
+
if (vbe_height > 1440) vesa_set_font(32);
else if (vbe_height > 720) vesa_set_font(24);
else vesa_set_font(16);
@@ -198,8 +200,8 @@ const uint32_t default_text_color = vesa_white;
const uint32_t default_background_color = vesa_black;
uint32_t terminal_color[3] = {0xab, 0xb2, 0xbf};
uint32_t terminal_background[3] = {0x1d, 0x1f, 0x24};
-uint16_t terminal_x = 1;
-uint16_t terminal_y = 1;
+uint16_t terminal_x = 0;
+uint16_t terminal_y = 0;
int font_width;
int font_height;
diff --git a/src/kernel/graphics/vesa.h b/src/kernel/graphics/vesa.h
index 3fcef24..8a16516 100644
--- a/src/kernel/graphics/vesa.h
+++ b/src/kernel/graphics/vesa.h
@@ -17,7 +17,7 @@ struct edid_data {
uint8_t max_horizontal_size;
uint8_t max_vertical_size;
uint8_t gamma_factor;
- uint8_t dpms_flags;
+ uint8_t dpms_flags; // power management features
uint8_t chroma_information[10];
uint8_t timings_1;
uint8_t timings_2;
@@ -160,6 +160,7 @@ void vesa_set_color(uint32_t color);
/**
* An enum with vesa colors
+ * From https://github.com/joshdick/onedark.vim/ License: MIT
*/
enum vesa_color {
vesa_black = 0x1d1f24,
diff --git a/src/kernel/system.c b/src/kernel/system.c
index 2de1183..3b3cf95 100644
--- a/src/kernel/system.c
+++ b/src/kernel/system.c
@@ -1,15 +1,16 @@
-#ifndef MELVIX_SYSTEM_H
-#define MELVIX_SYSTEM_H
-
#include <kernel/timer/timer.h>
#include <kernel/io/io.h>
#include <kernel/graphics/vesa.h>
#include <kernel/lib/lib.h>
+char *vga_buffer = (char *) 0x500;
+
void vga_log(char *msg, int line) {
uint16_t *terminal_buffer = (uint16_t *) 0xB8000;
for (size_t i = 0; i < strlen(msg); i++)
terminal_buffer[line * 80 + i] = (uint16_t) msg[i] | (uint16_t) 0x700;
+ strcpy(msg, "\n");
+ memcpy(vga_buffer, msg, sizeof(msg));
}
void kernel_time() {
@@ -62,5 +63,3 @@ void assert(int x) {
panic("Assertion failed");
}
}
-
-#endif
diff --git a/src/kernel/system.h b/src/kernel/system.h
index d431a9e..f87a8d5 100644
--- a/src/kernel/system.h
+++ b/src/kernel/system.h
@@ -27,6 +27,11 @@ typedef struct __attribute__ ((packed)) {
extern void int32(unsigned char intnum, regs16_t *regs);
/**
+ * The vga log buffer to transfer the logs to VESA
+ */
+char *vga_buffer;
+
+/**
* Log a message before VESA has been initialized
* @param msg The message
* @param line The hardcoded linenumber