aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/graphics/vesa.c
diff options
context:
space:
mode:
authorMarvin Borner2019-09-25 19:33:29 +0200
committerMarvin Borner2019-09-25 19:33:29 +0200
commit16b8a48d1de16a5982cf983a282832fd4ed01f85 (patch)
tree1a0294b9f96fe8ffc788ce7ef600c9ff8eb4f856 /src/kernel/graphics/vesa.c
parent64ec44ba4575686849ba2597cf8bc9054af3d376 (diff)
Started integrating vesa resolution finder
Diffstat (limited to 'src/kernel/graphics/vesa.c')
-rw-r--r--src/kernel/graphics/vesa.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/kernel/graphics/vesa.c b/src/kernel/graphics/vesa.c
index af2502b..cab6c70 100644
--- a/src/kernel/graphics/vesa.c
+++ b/src/kernel/graphics/vesa.c
@@ -1,4 +1,12 @@
#include "vesa.h"
+#include "graphics.h"
+#include "../sound/sound.h"
+#include "../lib/lib.h"
+#include "../acpi/acpi.h"
+
+void switch_to_vga() {
+ terminal_initialize();
+}
vbe_mode_info *vbe_set_mode(unsigned short mode) {
regs16_t regs;
@@ -13,7 +21,7 @@ vbe_mode_info *vbe_set_mode(unsigned short mode) {
regs.es = 0xA000;
int32(0x10, &regs);
if (regs.ax != 0x004F) {
- // Add VGA redirect
+ switch_to_vga();
}
vbe_mode_info *vbe_info = (vbe_mode_info *) 0xA0000;
@@ -24,8 +32,10 @@ vbe_mode_info *vbe_set_mode(unsigned short mode) {
vbe_pitch = vbe_info->pitch;
char *fb = (char *) vbe_info->framebuffer;
- for (int i = 0; i < 640 * 480 * 3; i++) {
+ for (int i = 0; i < vbe_width * vbe_height * vbe_bpp; i++) {
fb[i] = 100;
+ fb[i + 1] = 100;
+ fb[i + 2] = 100;
}
regs.ax = 0x0000;
int32(0x16, &regs);
@@ -34,9 +44,32 @@ vbe_mode_info *vbe_set_mode(unsigned short mode) {
return vbe_info;
} else {
- // Add VGA redirect
+ switch_to_vga();
}
vbe_mode_info vbe_info;
return &vbe_info;
}
+
+void set_optimal_resolution() {
+ extern vbe_info *vbe_init_structure;
+ regs16_t regs;
+ regs.ax = 0x4F01;
+ regs.cx = vbe_init_structure;
+ regs.di = 0x0000;
+ regs.es = 0xA000;
+ int32(0x10, &regs);
+
+ if (regs.ax != 0x004F) {
+ switch_to_vga();
+ }
+
+ vbe_info *vbe_modes = (vbe_info *) 0xA0000;
+ if (strcmp(vbe_modes->signature, "VESA") == 0) {
+ loop:
+ asm volatile ("hlt");
+ goto loop;
+ } else {
+ acpi_poweroff();
+ }
+} \ No newline at end of file