diff options
author | Marvin Borner | 2019-09-25 22:57:33 +0200 |
---|---|---|
committer | Marvin Borner | 2019-09-25 22:57:33 +0200 |
commit | 8ebf584bbb43584b671b79d5166e00268a7c9661 (patch) | |
tree | 466abea4e6da201e7b432d7394e1bf21cbbe1d98 /src/kernel/graphics | |
parent | 16b8a48d1de16a5982cf983a282832fd4ed01f85 (diff) |
Fixed several TTY bugs and improved VESA detection
Diffstat (limited to 'src/kernel/graphics')
-rw-r--r-- | src/kernel/graphics/graphics.h | 2 | ||||
-rw-r--r-- | src/kernel/graphics/vesa.c | 27 | ||||
-rw-r--r-- | src/kernel/graphics/vesa.h | 54 | ||||
-rw-r--r-- | src/kernel/graphics/vga.c | 22 |
4 files changed, 61 insertions, 44 deletions
diff --git a/src/kernel/graphics/graphics.h b/src/kernel/graphics/graphics.h index b28b550..3136b1e 100644 --- a/src/kernel/graphics/graphics.h +++ b/src/kernel/graphics/graphics.h @@ -18,6 +18,8 @@ void terminal_write_string(const char *data); void terminal_put_char(char c); +void terminal_put_keyboard_char(char c); + void terminal_write_line(const char *data); #endif
\ No newline at end of file diff --git a/src/kernel/graphics/vesa.c b/src/kernel/graphics/vesa.c index cab6c70..35e96c6 100644 --- a/src/kernel/graphics/vesa.c +++ b/src/kernel/graphics/vesa.c @@ -1,11 +1,16 @@ #include "vesa.h" #include "graphics.h" -#include "../sound/sound.h" #include "../lib/lib.h" -#include "../acpi/acpi.h" +#include "../input/input.h" +#include "../system.h" void switch_to_vga() { - terminal_initialize(); + regs16_t regs; + regs.ax = 0x0003; + int32(0x10, ®s); + init(); + terminal_write_line("FAILED!"); + keyboard_install(); } vbe_mode_info *vbe_set_mode(unsigned short mode) { @@ -54,9 +59,8 @@ vbe_mode_info *vbe_set_mode(unsigned short mode) { 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.ax = 0x4F00; + regs.di = vbe_init_structure; regs.es = 0xA000; int32(0x10, ®s); @@ -65,11 +69,14 @@ void set_optimal_resolution() { } vbe_info *vbe_modes = (vbe_info *) 0xA0000; + if (strcmp(vbe_modes->signature, "VESA") == 0) { - loop: - asm volatile ("hlt"); - goto loop; + init(); + terminal_write_string("SUCCESS!\n"); + keyboard_install(); } else { - acpi_poweroff(); + init(); + terminal_write_string("FAILED!\n"); + keyboard_install(); } }
\ No newline at end of file diff --git a/src/kernel/graphics/vesa.h b/src/kernel/graphics/vesa.h index dd67123..7458a47 100644 --- a/src/kernel/graphics/vesa.h +++ b/src/kernel/graphics/vesa.h @@ -4,39 +4,39 @@ #include <stdint.h> typedef struct __attribute__ ((packed)) { - char signature[4]; // must be "VESA" to indicate valid VBE support - uint32_t version; // VBE version; high byte is major version, low byte is minor version - uint32_t oem; // segment:offset pointer to OEM - uint32_t capabilities; // bitfield that describes card capabilities - uint32_t video_modes; // segment:offset pointer to list of supported video modes - uint32_t video_memory; // amount of video memory in 64KB blocks - uint32_t software_rev; // software revision - uint32_t vendor; // segment:offset to card vendor string - uint32_t product_name; // segment:offset to card model name - uint32_t product_rev; // segment:offset pointer to product revision - char reserved[222]; // reserved for future expansion - char oem_data[256]; // OEM BIOSes store their strings in this area + char signature[4]; + uint32_t version; + uint32_t oem; + uint32_t capabilities; + uint32_t video_modes; + uint32_t video_memory; + uint32_t software_rev; + uint32_t vendor; + uint32_t product_name; + uint32_t product_rev; + char reserved[222]; + char oem_data[256]; } vbe_info; typedef struct __attribute__ ((packed)) { - uint16_t attributes; // deprecated, only bit 7 should be of interest to you, and it indicates the mode supports a linear frame buffer. - uint8_t window_a; // deprecated - uint8_t window_b; // deprecated - uint16_t granularity; // deprecated; used while calculating bank numbers + uint16_t attributes; + uint8_t window_a; + uint8_t window_b; + uint16_t granularity; uint16_t window_size; uint16_t segment_a; uint16_t segment_b; - uint32_t win_func_ptr; // deprecated; used to switch banks from protected mode without returning to real mode - uint16_t pitch; // number of bytes per horizontal line - uint16_t width; // width in pixels - uint16_t height; // height in pixels - uint8_t w_char; // unused... - uint8_t y_char; // ... + uint32_t win_func_ptr; + uint16_t pitch; + uint16_t width; + uint16_t height; + uint8_t w_char; + uint8_t y_char; uint8_t planes; - uint8_t bpp; // bits per pixel in this mode - uint8_t banks; // deprecated; total number of banks in this mode + uint8_t bpp; + uint8_t banks; uint8_t memory_model; - uint8_t bank_size; // deprecated; size of a bank, almost always 64 KB but may be 16 KB... + uint8_t bank_size; uint8_t image_pages; uint8_t reserved0; @@ -50,9 +50,9 @@ typedef struct __attribute__ ((packed)) { uint8_t reserved_position; uint8_t direct_color_attributes; - uint32_t framebuffer; // physical address of the linear frame buffer; write here to draw to the screen + uint32_t framebuffer; uint32_t off_screen_mem_off; - uint16_t off_screen_mem_size; // size of memory in the framebuffer but not being displayed on the screen + uint16_t off_screen_mem_size; uint8_t reserved1[206]; } vbe_mode_info; diff --git a/src/kernel/graphics/vga.c b/src/kernel/graphics/vga.c index 3e910f1..fa1f330 100644 --- a/src/kernel/graphics/vga.c +++ b/src/kernel/graphics/vga.c @@ -107,15 +107,10 @@ void terminal_put_char(char c) { } else if (c == '\r') { terminal_column = 0; } else if (c == '\n') { - if (irq_is_installed(1)) exec_command(text); - memory_set(text, 0, sizeof(text)); - terminal_column = 0; terminal_row++; + terminal_column = 0; terminal_scroll(); - terminal_put_entry_at('$', terminal_color, terminal_column, terminal_row); - terminal_column = 2; } else if (c >= ' ') { // Any printable character - strcat(text, &c); terminal_put_entry_at(c, terminal_color, terminal_column, terminal_row); terminal_column++; } @@ -135,12 +130,25 @@ void terminal_write(const char *data, size_t size) { terminal_put_char(data[i]); } +void terminal_put_keyboard_char(char c) { + terminal_put_char(c); + if (c == '\n' && irq_is_installed(1)) { + exec_command(text); + memory_set(text, 0, sizeof(text)); + terminal_column = 0; + terminal_row++; + terminal_scroll(); + terminal_put_entry_at('$', terminal_color, terminal_column, terminal_row); + terminal_column = 2; + terminal_update_cursor(); + } else if (c >= ' ' && irq_is_installed(1)) strcat(text, &c); +} + void terminal_write_string(const char *data) { terminal_write(data, strlen(data)); } void terminal_write_line(const char *data) { - terminal_row++; terminal_column = 0; terminal_write_string(data); terminal_column = 0; |