:: commit 385af687b3d6ae004b57eae6f0a805bfa606806b

mintsuki <mintsuki@protonmail.com> — 2021-08-16 22:06

parents: 19ecfe9c1e

vga_textmode: Replace BIOS calls to enable and disable hardware cursor with direct VGA port IO

diff --git a/stage23/drivers/vga_textmode.s2.c b/stage23/drivers/vga_textmode.s2.c
index b6bee3ad..75fb49ec 100644
--- a/stage23/drivers/vga_textmode.s2.c
+++ b/stage23/drivers/vga_textmode.s2.c
@@ -173,22 +173,22 @@ void init_vga_textmode(size_t *_rows, size_t *_cols, bool managed) {
     *_rows = VD_ROWS;
     *_cols = VD_COLS / 2;
 
-    struct rm_regs r;
+    // VGA cursor code taken from: https://wiki.osdev.org/Text_Mode_Cursor
 
     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);
+
+        outb(0x3d4, 0x0a);
+        outb(0x3d5, (inb(0x3d5) & 0xc0) | 14);
+        outb(0x3d4, 0x0b);
+        outb(0x3d5, (inb(0x3d5) & 0xe0) | 15);
+        outb(0x3d4, 0x0f);
+        outb(0x3d5, 0);
+        outb(0x3d4, 0x0e);
+        outb(0x3d5, 0);
     } else {
-        r = (struct rm_regs){0};
-        r.eax = 0x0100;
-        r.ecx = 0x2706;
-        rm_int(0x10, &r, &r);
+        outb(0x3d4, 0x0a);
+        outb(0x3d5, 0x20);
     }
 }
 
diff --git a/test/e9print.c b/test/e9print.c
index 2895b1bf..e9a515ef 100644
--- a/test/e9print.c
+++ b/test/e9print.c
@@ -8,7 +8,7 @@ static const char CONVERSION_TABLE[] = "0123456789abcdef";
 void e9_putc(char c) {
     if (stivale2_print != NULL)
         stivale2_print(&c, 1);
-    asm volatile ("outb %0, %1" :: "a" (c), "Nd" (0xe9) : "memory");
+    //asm volatile ("outb %0, %1" :: "a" (c), "Nd" (0xe9) : "memory");
 }
 
 void e9_print(const char *msg) {
diff --git a/test/limine.cfg b/test/limine.cfg
index 8ae4363b..b1b09b54 100644
--- a/test/limine.cfg
+++ b/test/limine.cfg
@@ -1,6 +1,6 @@
 DEFAULT_ENTRY=1
 TIMEOUT=3
-GRAPHICS=yes
+#GRAPHICS=yes
 MENU_FONT=boot:///boot/font.bin
 VERBOSE=yes
 
diff --git a/test/stivale.c b/test/stivale.c
index 89133092..ea913406 100644
--- a/test/stivale.c
+++ b/test/stivale.c
@@ -12,7 +12,7 @@ struct stivale_header header = {
     .framebuffer_bpp    = 0,
     .framebuffer_width  = 0,
     .framebuffer_height = 0,
-    .flags              = 1 | (1 << 3),
+    .flags              = (1 << 3),
     .entry_point        = (uint64_t)(uintptr_t)stivale_main
 };
 
tab: 248 wrap: offon