[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH 2/2] plat/kvm: Update VGA console cursor location



Update the location of the cursor as data is written to the console.
Note that this does not set the cursor location registers, hence all we
get is the blinking underline character, not the full-size block
character.

Signed-off-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>
---
 plat/kvm/x86/vga_console.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/plat/kvm/x86/vga_console.c b/plat/kvm/x86/vga_console.c
index a1b5cf7..efcddde 100644
--- a/plat/kvm/x86/vga_console.c
+++ b/plat/kvm/x86/vga_console.c
@@ -29,6 +29,8 @@
 #include <sys/types.h>
 #include <stdint.h>
 #include <string.h>
+#include <x86/cpu.h>
+#include <x86/irq.h>
 #include <kvm-x86/vga_console.h>
 
 /* Hardware text mode color constants. */
@@ -109,6 +111,36 @@ static void vga_scroll(void)
                        = vga_entry(' ', terminal_color);
 }
 
+static void vga_update_cursor(void)
+{
+       unsigned long irq_flags;
+       uint8_t old;
+       uint8_t ioas;  // VGA Input/Output select
+       uint16_t areg; // VGA address register
+       uint16_t dreg; // VGA data register
+
+       local_irq_save(irq_flags);
+       /* Location of the address and data registers is variable and denoted
+        * by the least significant bit in the Input/Output register.
+        */
+       ioas = inb(0x3cc) & 0x1;
+       if (ioas) {
+               areg = 0x3d4;
+               dreg = 0x3d5;
+       } else {
+               areg = 0x3b4;
+               dreg = 0x3b5;
+       }
+
+       old = inb(areg);
+       outb(areg, 0x0e); // Cursor Location High
+       outb(dreg, ((terminal_row * VGA_WIDTH) + terminal_column) >> 8);
+       outb(areg, 0x0f); // Cursor Location Low
+       outb(dreg, ((terminal_row * VGA_WIDTH) + terminal_column) & 0xff);
+       outb(areg, old);
+       local_irq_restore(irq_flags);
+}
+
 static void vga_newline(void)
 {
        if (terminal_row == VGA_HEIGHT - 1)
@@ -160,4 +192,5 @@ void _libkvmplat_vga_putc(char c)
                }
                break;
        }
+       vga_update_cursor();
 }
-- 
2.18.0


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.