aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/graphics/vesa.c
diff options
context:
space:
mode:
authorMarvin Borner2019-09-26 20:22:39 +0200
committerMarvin Borner2019-09-26 20:22:39 +0200
commit181947c70d7a6c5ff769243885d76f3af39560ce (patch)
treeffaca16d00fa5636eb10607b206530067606b244 /src/kernel/graphics/vesa.c
parent8ebf584bbb43584b671b79d5166e00268a7c9661 (diff)
Added working support for segment:offset pointer
Diffstat (limited to 'src/kernel/graphics/vesa.c')
-rw-r--r--src/kernel/graphics/vesa.c49
1 files changed, 38 insertions, 11 deletions
diff --git a/src/kernel/graphics/vesa.c b/src/kernel/graphics/vesa.c
index 35e96c6..f3fd865 100644
--- a/src/kernel/graphics/vesa.c
+++ b/src/kernel/graphics/vesa.c
@@ -1,6 +1,5 @@
#include "vesa.h"
#include "graphics.h"
-#include "../lib/lib.h"
#include "../input/input.h"
#include "../system.h"
@@ -13,7 +12,7 @@ void switch_to_vga() {
keyboard_install();
}
-vbe_mode_info *vbe_set_mode(unsigned short mode) {
+struct vbe_mode_info *vbe_set_mode(unsigned short mode) {
regs16_t regs;
regs.ax = 0x4F02;
regs.bx = mode | (1 << 14);
@@ -29,7 +28,7 @@ vbe_mode_info *vbe_set_mode(unsigned short mode) {
switch_to_vga();
}
- vbe_mode_info *vbe_info = (vbe_mode_info *) 0xA0000;
+ struct vbe_mode_info *vbe_info = (struct vbe_mode_info *) 0xA0000;
vbe_width = vbe_info->width;
vbe_height = vbe_info->height;
@@ -52,31 +51,59 @@ vbe_mode_info *vbe_set_mode(unsigned short mode) {
switch_to_vga();
}
- vbe_mode_info vbe_info;
+ struct vbe_mode_info vbe_info;
return &vbe_info;
}
void set_optimal_resolution() {
- extern vbe_info *vbe_init_structure;
+ init();
+ terminal_write_string("SUCCESS!\n");
+ keyboard_install();
+
+ struct vbe_info *info;
+ struct vbe_mode_info *mode_info;
+
+ info->signature[0] = 'V';
+ info->signature[1] = 'B';
+ info->signature[2] = 'E';
+ info->signature[3] = '2';
+
regs16_t regs;
regs.ax = 0x4F00;
- regs.di = vbe_init_structure;
- regs.es = 0xA000;
+ regs.es = get_segment(info);
+ regs.di = get_offset(info);
int32(0x10, &regs);
if (regs.ax != 0x004F) {
switch_to_vga();
}
- vbe_info *vbe_modes = (vbe_info *) 0xA0000;
+ uint16_t *mode_ptr = get_ptr(info->video_modes);
+ uint16_t mode;
+ struct vbe_mode_info *highest;
+ while ((mode = *mode_ptr++) != 0xFFFF) {
+ mode &= 0x1FF;
+ regs16_t regs2;
+ regs2.ax = 0x4F01;
+ regs2.cx = mode;
+ regs2.es = get_segment(mode_info);
+ regs2.di = get_offset(mode_info);
+ int32(0x10, &regs2);
- if (strcmp(vbe_modes->signature, "VESA") == 0) {
+ if ((mode_info->attributes & 0x90) != 0x90) continue;
+ if (mode_info->height >= highest->height) {
+ highest = mode_info;
+ }
+ }
+
+ /*if (strcmp((const char *) info->version, (const char *) 0x300) == 0) {
init();
terminal_write_string("SUCCESS!\n");
+ terminal_write_line((const char *) &info->vendor);
keyboard_install();
} else {
init();
terminal_write_string("FAILED!\n");
- keyboard_install();
- }
+ keyboard_install(); // Find out why commands only work when keyboard gets reinstalled after write
+ }*/
} \ No newline at end of file