mirror of
https://github.com/limine-bootloader/limine
synced 2024-12-11 17:24:08 +03:00
video: Wire in new textmode modesetting logic; use BIOS instead of VGA ports to enable and disable hardware textmode cursor
This commit is contained in:
parent
49ac7572d1
commit
98fdd625c4
@ -3,7 +3,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
void init_vga_textmode(int *rows, int *cols);
|
||||
void init_vga_textmode(int *rows, int *cols, bool managed);
|
||||
|
||||
void text_putchar(uint8_t c);
|
||||
void text_clear(bool move);
|
||||
|
@ -73,9 +73,7 @@ void text_disable_cursor(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
// VGA cursor code taken from: https://wiki.osdev.org/Text_Mode_Cursor
|
||||
|
||||
void init_vga_textmode(int *_rows, int *_cols) {
|
||||
void init_vga_textmode(int *_rows, int *_cols, bool managed) {
|
||||
if (current_video_mode != -1) {
|
||||
struct rm_regs r = {0};
|
||||
r.eax = 0x0003;
|
||||
@ -84,8 +82,6 @@ void init_vga_textmode(int *_rows, int *_cols) {
|
||||
current_video_mode = -1;
|
||||
}
|
||||
|
||||
outb(0x3d4, 0x0a);
|
||||
outb(0x3d5, 0x20);
|
||||
|
||||
cursor_offset = 0;
|
||||
cursor_status = 1;
|
||||
@ -98,6 +94,24 @@ void init_vga_textmode(int *_rows, int *_cols) {
|
||||
|
||||
*_rows = VD_ROWS;
|
||||
*_cols = VD_COLS / 2;
|
||||
|
||||
struct rm_regs r;
|
||||
|
||||
if (!managed) {
|
||||
text_disable_cursor();
|
||||
r = (struct rm_regs){0};
|
||||
r.eax = 0x0200;
|
||||
rm_int(0x10, &r, &r);
|
||||
r = (struct rm_regs){0};
|
||||
r.eax = 0x0100;
|
||||
r.ecx = 0x0607;
|
||||
rm_int(0x10, &r, &r);
|
||||
} else {
|
||||
r = (struct rm_regs){0};
|
||||
r.eax = 0x0100;
|
||||
r.ecx = 0x2706;
|
||||
rm_int(0x10, &r, &r);
|
||||
}
|
||||
}
|
||||
|
||||
void text_double_buffer(bool state) {
|
||||
|
@ -7,8 +7,6 @@
|
||||
#include <lib/gterm.h>
|
||||
|
||||
void term_vbe(uint32_t *colours, int margin, int margin_gradient, struct image *background) {
|
||||
term_deinit();
|
||||
|
||||
if (!gterm_init(&term_rows, &term_cols, colours, margin, margin_gradient, background)) {
|
||||
#if defined (bios)
|
||||
// Failed to set VBE properly, default to text mode
|
||||
|
@ -19,7 +19,6 @@ extern void (*term_double_buffer_flush)(void);
|
||||
|
||||
void term_vbe(uint32_t *colours, int margin, int margin_gradient, struct image *background);
|
||||
void term_textmode(void);
|
||||
void term_deinit(void);
|
||||
void term_write(const char *buf, size_t count);
|
||||
|
||||
extern int term_rows, term_cols;
|
||||
|
@ -27,7 +27,7 @@ int term_rows, term_cols;
|
||||
|
||||
#if defined (bios)
|
||||
void term_textmode(void) {
|
||||
init_vga_textmode(&term_rows, &term_cols);
|
||||
init_vga_textmode(&term_rows, &term_cols, true);
|
||||
|
||||
raw_putchar = text_putchar;
|
||||
clear = text_clear;
|
||||
@ -45,10 +45,6 @@ void term_textmode(void) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void term_deinit(void) {
|
||||
term_backend = NOT_READY;
|
||||
}
|
||||
|
||||
static void term_putchar(uint8_t c);
|
||||
|
||||
void term_write(const char *buf, size_t count) {
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <lib/term.h>
|
||||
#include <mm/mtrr.h>
|
||||
#include <sys/idt.h>
|
||||
#include <drivers/vga_textmode.h>
|
||||
|
||||
__attribute__((noinline))
|
||||
__attribute__((section(".realmode")))
|
||||
@ -85,7 +86,8 @@ void chainload(char *config) {
|
||||
drive = (val - 1) + 0x80;
|
||||
}
|
||||
|
||||
term_deinit();
|
||||
int rows, cols;
|
||||
init_vga_textmode(&rows, &cols, false);
|
||||
|
||||
struct volume *p = volume_get_by_coord(drive, part);
|
||||
|
||||
|
@ -482,8 +482,6 @@ void linux_load(char *config, char *cmdline) {
|
||||
// Video
|
||||
///////////////////////////////////////
|
||||
|
||||
term_deinit();
|
||||
|
||||
mtrr_restore();
|
||||
|
||||
struct screen_info *screen_info = &boot_params->screen_info;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <mm/pmm.h>
|
||||
#include <mm/mtrr.h>
|
||||
#include <stivale/stivale.h>
|
||||
#include <drivers/vga_textmode.h>
|
||||
|
||||
struct stivale_struct stivale_struct = {0};
|
||||
|
||||
@ -157,8 +158,6 @@ void stivale_load(char *config, char *cmdline) {
|
||||
print("stivale: Current epoch: %U\n", stivale_struct.epoch);
|
||||
|
||||
if (stivale_hdr.flags & (1 << 0)) {
|
||||
term_deinit();
|
||||
|
||||
int req_width = stivale_hdr.framebuffer_width;
|
||||
int req_height = stivale_hdr.framebuffer_height;
|
||||
int req_bpp = stivale_hdr.framebuffer_bpp;
|
||||
@ -186,9 +185,10 @@ void stivale_load(char *config, char *cmdline) {
|
||||
} else {
|
||||
#if defined (uefi)
|
||||
panic("stivale: Cannot use text mode with UEFI.");
|
||||
#elif defined (bios)
|
||||
int rows, cols;
|
||||
init_vga_textmode(&rows, &cols, false);
|
||||
#endif
|
||||
|
||||
term_deinit();
|
||||
}
|
||||
|
||||
#if defined (uefi)
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <stivale/stivale2.h>
|
||||
#include <pxe/tftp.h>
|
||||
#include <drivers/edid.h>
|
||||
#include <drivers/vga_textmode.h>
|
||||
|
||||
struct stivale2_struct stivale2_struct = {0};
|
||||
|
||||
@ -263,8 +264,6 @@ void stivale2_load(char *config, char *cmdline, bool pxe, void *efi_system_table
|
||||
struct stivale2_header_tag_framebuffer *hdrtag = get_tag(&stivale2_hdr, STIVALE2_HEADER_TAG_FRAMEBUFFER_ID);
|
||||
|
||||
if (hdrtag != NULL) {
|
||||
term_deinit();
|
||||
|
||||
int req_width = hdrtag->framebuffer_width;
|
||||
int req_height = hdrtag->framebuffer_height;
|
||||
int req_bpp = hdrtag->framebuffer_bpp;
|
||||
@ -309,9 +308,10 @@ void stivale2_load(char *config, char *cmdline, bool pxe, void *efi_system_table
|
||||
} else {
|
||||
#if defined (uefi)
|
||||
panic("stivale2: Cannot use text mode with UEFI.");
|
||||
#elif defined (bios)
|
||||
int rows, cols;
|
||||
init_vga_textmode(&rows, &cols, false);
|
||||
#endif
|
||||
|
||||
term_deinit();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user