vt: Add support for switching vt state
authorAlan Cox <alan@linux.intel.com>
Sun, 14 Dec 2014 18:24:43 +0000 (18:24 +0000)
committerAlan Cox <alan@linux.intel.com>
Sun, 14 Dec 2014 18:24:43 +0000 (18:24 +0000)
We need this for the MTX512 but it will also be useful later for MSX, as the
MSX also has a load of VDP RAM that we can use to support multiple text
consoles just like Xenix and later Linux did on a PC.

Kernel/include/vt.h
Kernel/vt.c

index 6aecef7..709bed0 100644 (file)
 #define VT_INITIAL_LINE 0
 #endif
 
+struct vt_switch {
+  uint8_t vtmode;
+  signed char cursorx;
+  signed char cursory;
+  signed char ncursory;
+};
+
 /* Core functions */
 void vtoutput(unsigned char *p, unsigned int len);
 void vtinit(void);
+/* Mode switcher functions */
+void vt_save(struct vt_switch *vt);
+void vt_load(struct vt_switch *vt);
 /* Platform functions */
 void clear_lines(int8_t y, int8_t ct);
 void clear_across(int8_t y, int8_t x, int16_t l);
index 81ffb65..901e413 100644 (file)
@@ -1,5 +1,6 @@
 #include <kernel.h>
 #include <vt.h>
+#include <devtty.h>
 
 #ifdef CONFIG_VT
 /*
  */
 
 
-static int vtmode;
+static uint8_t vtmode;
 static signed char cursorx;
 static signed char cursory = VT_INITIAL_LINE;
-static int ncursory;
+static signed char ncursory;
 
 static void cursor_fix(void)
 {
@@ -188,6 +189,26 @@ void vtinit(void)
        cursor_on(0, 0);
 }
 
+#ifdef CONFIG_VT_MULTI
+
+void vt_save(struct vt_switch *vt)
+{
+       cursor_off();
+       vt->vtmode = vtmode;
+       vt->cursorx = cursorx;
+       vt->cursory = cursory;
+       vt->ncursory = ncursory;
+}
+
+void vt_load(struct vt_switch *vt)
+{
+       vtmode = vt->vtmode;
+       cursorx = vt->cursorx;
+       cursory = vt->cursory;
+       ncursory = vt->ncursory;
+       cursor_on(cursory, cursorx);
+}
+#endif
 
 #ifdef CONFIG_VT_SIMPLE