diff options
Diffstat (limited to 'src/kernel/graphics/vesa.c')
-rw-r--r-- | src/kernel/graphics/vesa.c | 39 |
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, ®s); 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, ®s); @@ -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, ®s); + + 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 |