summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--share/man/man4/keyboard.49
-rw-r--r--share/man/man4/man4.i386/keyboard.49
-rw-r--r--share/man/man4/man4.i386/screen.48
-rw-r--r--share/man/man4/screen.48
-rw-r--r--sys/alpha/include/console.h9
-rw-r--r--sys/dev/kbd/kbdtables.h63
-rw-r--r--sys/dev/syscons/syscons.c1095
-rw-r--r--sys/i386/include/console.h9
-rw-r--r--sys/i386/isa/kbdtables.h63
-rw-r--r--sys/i386/isa/syscons.c1095
-rw-r--r--sys/isa/kbdtables.h63
-rw-r--r--sys/isa/syscons.c1095
12 files changed, 1753 insertions, 1773 deletions
diff --git a/share/man/man4/keyboard.4 b/share/man/man4/keyboard.4
index 0a8b0d5..f74b5ec 100644
--- a/share/man/man4/keyboard.4
+++ b/share/man/man4/keyboard.4
@@ -6,7 +6,7 @@
.Nd pc keyboard interface
.Sh DESCRIPTION
-The PC keyboard is use as the console character input device. The keyboard
+The PC keyboard is used as the console character input device. The keyboard
is owned by the current virtual console.
To switch between the virtual consoles use the sequence
.Ar ALT+Fn
@@ -20,7 +20,8 @@ present on the keyboard via a special keysequence.
To use this facility press and hold down ALT,
then enter a decimal number from 0-255 via the numerical keypad, then
release ALT. The entered value is then used as the ASCII value for one
-character. This way it is possible to enter any ASCII value.
+character. This way it is possible to enter any ASCII value, not present
+on the keyboard.
The keyboard is configurable to suit the individual user and the different
national layout.
@@ -130,5 +131,5 @@ The function keys are numbered like this:
.Ed
.Pp
.Sh AUTHOR
- S_ren Schmidt
- Email: (baukno@login.dkuug.dk -or- sos@kmd-ac.dk)
+ Søren Schmidt
+ Email: (sos@login.dkuug.dk -or- sos@kmd-ac.dk)
diff --git a/share/man/man4/man4.i386/keyboard.4 b/share/man/man4/man4.i386/keyboard.4
index 0a8b0d5..f74b5ec 100644
--- a/share/man/man4/man4.i386/keyboard.4
+++ b/share/man/man4/man4.i386/keyboard.4
@@ -6,7 +6,7 @@
.Nd pc keyboard interface
.Sh DESCRIPTION
-The PC keyboard is use as the console character input device. The keyboard
+The PC keyboard is used as the console character input device. The keyboard
is owned by the current virtual console.
To switch between the virtual consoles use the sequence
.Ar ALT+Fn
@@ -20,7 +20,8 @@ present on the keyboard via a special keysequence.
To use this facility press and hold down ALT,
then enter a decimal number from 0-255 via the numerical keypad, then
release ALT. The entered value is then used as the ASCII value for one
-character. This way it is possible to enter any ASCII value.
+character. This way it is possible to enter any ASCII value, not present
+on the keyboard.
The keyboard is configurable to suit the individual user and the different
national layout.
@@ -130,5 +131,5 @@ The function keys are numbered like this:
.Ed
.Pp
.Sh AUTHOR
- S_ren Schmidt
- Email: (baukno@login.dkuug.dk -or- sos@kmd-ac.dk)
+ Søren Schmidt
+ Email: (sos@login.dkuug.dk -or- sos@kmd-ac.dk)
diff --git a/share/man/man4/man4.i386/screen.4 b/share/man/man4/man4.i386/screen.4
index 6b9773c..1d93268 100644
--- a/share/man/man4/man4.i386/screen.4
+++ b/share/man/man4/man4.i386/screen.4
@@ -28,7 +28,7 @@ To switch between the virtual consoles one uses the sequence
virtual console with the same number as the function key is then
selected as the current virtual console, and given exclusive use of
the keyboard and display. This switch sequence can be changed via
-the keyboard mapping ioctl call (see keyboard.man)
+the keyboard mapping ioctl call (see keyboard.4)
.Pp
The number of virtual consoles is changeable in the system config
file, and need recompilation of the kernel to take any effect. The
@@ -57,7 +57,7 @@ CUF E[nC move cursor right n characters nd (kr)
CUB E[nD move cursor left n characters bs (kl)
-HPA E[n` move cursor character position n --
+HPA E[n` move cursor to character position n --
HPR E[na move cursor right n characters --
@@ -153,5 +153,5 @@ note: the first E in the sequences stands for ESC (0x1b)
.Ed
.Pp
.Sh AUTHOR
- S_ren Schmidt
- Email: (baukno@login.dkuug.dk -or- sos@kmd-ac.dk)
+ Søren Schmidt
+ Email: (sos@login.dkuug.dk -or- sos@kmd-ac.dk)
diff --git a/share/man/man4/screen.4 b/share/man/man4/screen.4
index 6b9773c..1d93268 100644
--- a/share/man/man4/screen.4
+++ b/share/man/man4/screen.4
@@ -28,7 +28,7 @@ To switch between the virtual consoles one uses the sequence
virtual console with the same number as the function key is then
selected as the current virtual console, and given exclusive use of
the keyboard and display. This switch sequence can be changed via
-the keyboard mapping ioctl call (see keyboard.man)
+the keyboard mapping ioctl call (see keyboard.4)
.Pp
The number of virtual consoles is changeable in the system config
file, and need recompilation of the kernel to take any effect. The
@@ -57,7 +57,7 @@ CUF E[nC move cursor right n characters nd (kr)
CUB E[nD move cursor left n characters bs (kl)
-HPA E[n` move cursor character position n --
+HPA E[n` move cursor to character position n --
HPR E[na move cursor right n characters --
@@ -153,5 +153,5 @@ note: the first E in the sequences stands for ESC (0x1b)
.Ed
.Pp
.Sh AUTHOR
- S_ren Schmidt
- Email: (baukno@login.dkuug.dk -or- sos@kmd-ac.dk)
+ Søren Schmidt
+ Email: (sos@login.dkuug.dk -or- sos@kmd-ac.dk)
diff --git a/sys/alpha/include/console.h b/sys/alpha/include/console.h
index 9d0d8e3..ce0cc9b 100644
--- a/sys/alpha/include/console.h
+++ b/sys/alpha/include/console.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1992, 1993 Søren Schmidt
+ * Copyright (C) 1992, 1993, 1994 Søren Schmidt
*
* This program is free software; you may redistribute it and/or
* modify it, provided that it retain the above copyright notice
@@ -9,11 +9,12 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * Søren Schmidt Email: sos@kmd-ac.dk
- * Tritonvej 36 UUCP: ...uunet!dkuug!kmd-ac!sos
+ * Søren Schmidt Email: sos@login.dkuug.dk
+ * Tritonvej 36 UUCP: ...uunet!dkuug!login!sos
* DK9210 Aalborg SO Phone: +45 9814 8076
*
- * $Id$
+ * from:@(#)console.h 1.1 940105
+ * $Id: console.h,v 1.5 1993/10/28 06:11:38 rgrimes Exp $
*/
#ifndef _CONSOLE_H_
diff --git a/sys/dev/kbd/kbdtables.h b/sys/dev/kbd/kbdtables.h
index a3a7c81..33e2b36 100644
--- a/sys/dev/kbd/kbdtables.h
+++ b/sys/dev/kbd/kbdtables.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1992, 1993 Søren Schmidt
+ * Copyright (C) 1992, 1993, 1994 Søren Schmidt
*
* This program is free software; you may redistribute it and/or
* modify it, provided that it retain the above copyright notice
@@ -9,11 +9,12 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * Søren Schmidt Email: sos@kmd-ac.dk
- * Tritonvej 36 UUCP: ...uunet!dkuug!kmd-ac!sos
+ * Søren Schmidt Email: sos@login.dkuug.dk
+ * Tritonvej 36 UUCP: ...uunet!dkuug!login!sos
* DK9210 Aalborg SO Phone: +45 9814 8076
*
- * $Id: kbdtables.h,v 1.8 1994/01/18 05:31:37 nate Exp $
+ * @(#)kbdtables.h 1.3 940123
+ * $Id: kbdtables.h,v 1.9 1994/01/24 05:22:27 ache Exp $
*/
#define SET8 0x80 /* eight bit for emacs SET8-key */
@@ -26,7 +27,7 @@ keymap_t key_map = { 0x69, /* DK iso8859 keymap */
* ---------------------------------------------------------------------------
*/
/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, NOP, NOP, 0x1B, 0x1B, NOP, NOP, 0x33, 0x00,
+/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, 0x02, 0x00,
/* sc=02 */ '1', '!', NOP, NOP, '1', '!', NOP, NOP, 0x33, 0x00,
/* sc=03 */ '2', '"', 0x00, 0x00, '@', '"', 0x00, 0x00, 0x00, 0x00,
/* sc=04 */ '3', '#', NOP, NOP, 0x9E, '#', NOP, NOP, 0x33, 0x00,
@@ -108,7 +109,7 @@ keymap_t key_map = { 0x69, /* DK iso8859 keymap */
/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02,
-/* sc=53 */ 0x7F, '.', '.', '.', '.', '.', RBT, '.', 0x02, 0x02,
+/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, RBT, 0x7F, 0x02, 0x02,
/* sc=54 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ '<', '>', 0x1C, 0x1C, '\\', '>', 0x1C, 0x1C, 0x00, 0x00,
@@ -128,7 +129,7 @@ keymap_t key_map = { 0x69, /* DK iso8859 keymap */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00,
+/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT, F(54), 0xFF, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
#endif
@@ -141,7 +142,7 @@ keymap_t key_map = { 0x69, /* uk iso8859 keymap */
* ---------------------------------------------------------------------------
*/
/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00,
+/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, 0x02, 0x00,
/* sc=02 */ '1', '!', NOP, NOP, '`', '`', NOP, NOP, 0x33, 0x00,
/* sc=03 */ '2', '"', 0x00, 0x00, '@', '@', 0x00, 0x00, 0x00, 0x00,
/* sc=04 */ '3', 0xA3, NOP, NOP, '#', '#', NOP, NOP, 0x33, 0x00,
@@ -223,8 +224,8 @@ keymap_t key_map = { 0x69, /* uk iso8859 keymap */
/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02,
-/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02,
-/* sc=54 */ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00,
+/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, RBT, 0x7F, 0x02, 0x02,
+/* sc=54 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ '\\', '|', 0x1C, 0x1C, '\\', '|', 0x1C, 0x1C, 0x00, 0x00,
/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00,
@@ -243,7 +244,7 @@ keymap_t key_map = { 0x69, /* uk iso8859 keymap */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00,
+/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT, F(54), 0xFF, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
#endif
@@ -256,7 +257,7 @@ keymap_t key_map = { 0x69, /* german iso8859 keymap */
* ---------------------------------------------------------------------------
*/
/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00,
+/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, 0x02, 0x00,
/* sc=02 */ '1', '!', NOP, NOP, '`', '`', NOP, NOP, 0x33, 0x00,
/* sc=03 */ '2', '"', 0x00, 0x00, '@', '@', 0x00, 0x00, 0x00, 0x00,
/* sc=04 */ '3', 0xA7, NOP, NOP, '#', '#', NOP, NOP, 0x33, 0x00,
@@ -338,7 +339,7 @@ keymap_t key_map = { 0x69, /* german iso8859 keymap */
/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02,
-/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02,
+/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, RBT, 0x7F, 0x02, 0x02,
/* sc=54 */ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -358,7 +359,7 @@ keymap_t key_map = { 0x69, /* german iso8859 keymap */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00,
+/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT, F(54), 0xFF, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
#endif
@@ -371,7 +372,7 @@ keymap_t key_map = { 0x69, /* swedish iso8859 keymap */
* ---------------------------------------------------------------------------
*/
/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00,
+/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, 0x02, 0x00,
/* sc=02 */ '1', '!', NOP, NOP, NOP, NOP, NOP, NOP, 0x3F, 0x00,
/* sc=03 */ '2', '"', NOP, NOP, NOP, '@', NOP, NOP, 0x3B, 0x00,
/* sc=04 */ '3', 0xA3, NOP, NOP, NOP, '#', NOP, NOP, 0x3B, 0x00,
@@ -453,7 +454,7 @@ keymap_t key_map = { 0x69, /* swedish iso8859 keymap */
/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02,
-/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02,
+/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, RBT, 0x7F, 0x02, 0x02,
/* sc=54 */ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -473,7 +474,7 @@ keymap_t key_map = { 0x69, /* swedish iso8859 keymap */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00,
+/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT, F(54), 0xFF, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
#endif
@@ -539,7 +540,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=33 */ ',', '<', NOP, NOP, SET8|',', SET8|'<', NOP, NOP, 0x33, 0x00,
/* sc=34 */ '.', '>', NOP, NOP, SET8|'.', SET8|'>', NOP, NOP, 0x33, 0x00,
/* sc=35 */ '/', '?', NOP, NOP, SET8|'/', SET8|'?', NOP, NOP, 0x33, 0x00,
-/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
+/* sc=36 */ ASH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
/* sc=37 */ '*', '*', 0x0A, 0x0A, SET8|'*', SET8|'*', SET8|0x0A, SET8|0x0A, 0x00, 0x00,
/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00,
/* sc=39 */ ' ', ' ', ' ', ' ', SET8|' ', SET8|' ', SET8|' ', SET8|' ', 0x00, 0x00,
@@ -568,7 +569,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=50 */ F(58), '2', '2', '2', SET8|'2', SET8|'2', SET8|'2', SET8|'2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', SET8|'3', SET8|'3', SET8|'3', SET8|'3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', SET8|'0', SET8|'0', SET8|'0', SET8|'0', 0x80, 0x02,
-/* sc=53 */ F(54), '.', 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, RBT, SET8|0x7F, 0x82, 0x02,
+/* sc=53 */ F(54), '.', 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, 0x80, 0x02,
/* sc=54 */ ALK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -577,7 +578,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=59 */ 0x0D, 0x0D, 0x0A, 0x0A, SET8|0x0D, SET8|0x0D, SET8|0x0A, SET8|0x0A, 0x00, 0x00,
/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00,
/* sc=5b */ '/', '/', NOP, NOP, SET8|'/', SET8|'/', NOP, NOP, 0x33, 0x00,
-/* sc=5c */ NEXT, NOP, DBG, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
+/* sc=5c */ CLK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00,
/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00,
/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00,
/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00,
@@ -588,7 +589,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, RBT, SET8|0x7F, 0xC2, 0x00,
+/* sc=67 */ F(54), F(54), 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, 0xC0, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
/* sc=69 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=6a */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -626,8 +627,8 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=09 */ '*', '8', NOP, NOP, SET8|'8', SET8|'*', NOP, NOP, 0x33, 0x00,
/* sc=0a */ '(', '9', NOP, NOP, SET8|'9', SET8|'(', NOP, NOP, 0x33, 0x00,
/* sc=0b */ ')', '0', NOP, NOP, SET8|'0', SET8|')', NOP, NOP, 0x33, 0x00,
-/* sc=0c */ '-', '_', 0x1F, 0x1F, SET8|'-', SET8|'_', SET8|0x1F, SET8|0x1F, 0x00, 0x00,
-/* sc=0d */ '=', '+', NOP, NOP, SET8|'=', SET8|'+', NOP, NOP, 0x33, 0x00,
+/* sc=0c */ '_', '-', 0x1F, 0x1F, SET8|'-', SET8|'_', SET8|0x1F, SET8|0x1F, 0x00, 0x00,
+/* sc=0d */ '+', '=', NOP, NOP, SET8|'=', SET8|'+', NOP, NOP, 0x33, 0x00,
/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, SET8|0x08, SET8|0x08, SET8|0x7F, SET8|0x7F, 0x00, 0x00,
/* sc=0f */ 0x09, F(16), NOP, NOP, SET8|0x09, F(16), NOP, NOP, 0x77, 0x00,
/* sc=10 */ 0xca, 0xea, 0x11, 0x11, SET8|'q', SET8|'Q', SET8|0x11, SET8|0x11, 0x00, 0x01,
@@ -668,7 +669,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=33 */ 0xc2, 0xe2, NOP, NOP, SET8|',', SET8|'<', NOP, NOP, 0x33, 0x01,
/* sc=34 */ 0xc0, 0xe0, NOP, NOP, SET8|'.', SET8|'>', NOP, NOP, 0x33, 0x01,
/* sc=35 */ '/', '?', NOP, NOP, SET8|'/', SET8|'?', NOP, NOP, 0x33, 0x00,
-/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
+/* sc=36 */ ASH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
/* sc=37 */ '*', '*', 0x0A, 0x0A, SET8|'*', SET8|'*', SET8|0x0A, SET8|0x0A, 0x00, 0x00,
/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00,
/* sc=39 */ ' ', ' ', ' ', ' ', SET8|' ', SET8|' ', SET8|' ', SET8|' ', 0x00, 0x00,
@@ -697,7 +698,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=50 */ F(58), '2', '2', '2', SET8|'2', SET8|'2', SET8|'2', SET8|'2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', SET8|'3', SET8|'3', SET8|'3', SET8|'3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', SET8|'0', SET8|'0', SET8|'0', SET8|'0', 0x80, 0x02,
-/* sc=53 */ F(54), '.', 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, RBT, SET8|0x7F, 0x82, 0x02,
+/* sc=53 */ F(54), '.', 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, 0x80, 0x02,
/* sc=54 */ ALK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -706,7 +707,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=59 */ 0x0D, 0x0D, 0x0A, 0x0A, SET8|0x0D, SET8|0x0D, SET8|0x0A, SET8|0x0A, 0x00, 0x00,
/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00,
/* sc=5b */ '/', '/', NOP, NOP, SET8|'/', SET8|'/', NOP, NOP, 0x33, 0x00,
-/* sc=5c */ NEXT, NOP, DBG, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
+/* sc=5c */ CLK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00,
/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00,
/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00,
/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00,
@@ -717,7 +718,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, RBT, SET8|0x7F, 0xC2, 0x00,
+/* sc=67 */ F(54), F(54), 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, 0xC0, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
@@ -731,7 +732,7 @@ keymap_t key_map = { 0x69, /* US iso8859 keymap */
* ---------------------------------------------------------------------------
*/
/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, NOP, NOP, 0x1B, 0x1B, DBG, NOP, 0x33, 0x00,
+/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, 0x02, 0x00,
/* sc=02 */ '1', '!', NOP, NOP, '1', '!', NOP, NOP, 0x33, 0x00,
/* sc=03 */ '2', '@', 0x00, 0x00, '2', '@', 0x00, 0x00, 0x00, 0x00,
/* sc=04 */ '3', '#', NOP, NOP, '3', '#', NOP, NOP, 0x33, 0x00,
@@ -813,7 +814,7 @@ keymap_t key_map = { 0x69, /* US iso8859 keymap */
/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02,
-/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02,
+/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, RBT, 0x7F, 0x02, 0x02,
/* sc=54 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -833,8 +834,8 @@ keymap_t key_map = { 0x69, /* US iso8859 keymap */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT , F(54), 0xFF, 0x00,
-/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
+/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT, F(54), 0xFF, 0x00,
+/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
#endif
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index 6cad5c1..56ef759 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -1,4 +1,5 @@
/*-
+ * Copyright (c) 1992-1994 Søren Schmidt
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
@@ -33,15 +34,19 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)pccons.c 5.11 (Berkeley) 5/21/91
- * from: @(#)syscons.c 1.1 931021
- * $Id: syscons.c,v 1.25 1994/01/14 16:24:18 davidg Exp $
+ * from:@(#)syscons.c 1.3 940129
+ * $Id: syscons.c,v 1.26 1994/01/18 05:33:34 nate Exp $
*
- * Heavily modified by Sxren Schmidt (sos@login.dkuug.dk) to provide:
- *
- * virtual consoles, SYSV ioctl's, ANSI emulation ....
*/
+/* #define FADE_SAVER */
+/* #define BLANK_SAVER */
+#define STAR_SAVER
+
+#if !defined(__FreeBSD__)
+#define FAT_CURSOR
+#endif
+
#include "param.h"
#include "conf.h"
#include "ioctl.h"
@@ -55,7 +60,6 @@
#include "syslog.h"
#include "errno.h"
#include "malloc.h"
-#include "i386/isa/icu.h"
#include "i386/isa/isa.h"
#include "i386/isa/isa_device.h"
#include "i386/isa/timerreg.h"
@@ -64,20 +68,13 @@
#include "machine/psl.h"
#include "machine/frame.h"
#include "machine/pc/display.h"
-#include "sc.h"
#include "iso8859.font"
#include "kbdtables.h"
-
-#if !defined(NetBSD)
-#include "ddb.h"
-#if NDDB > 0
-#define DDB 1
-#endif
-#endif
+#include "sc.h"
#if NSC > 0
-#ifndef NCONS
+#if !defined(NCONS)
#define NCONS 12
#endif
@@ -89,12 +86,7 @@
#define SWITCH_WAIT_REL 0x00040
#define SWITCH_WAIT_ACQ 0x00080
-/* virtual video memory addresses */
-#if !defined(NetBSD)
-#define MONO_BUF (KERNBASE+0xB0000)
-#define CGA_BUF (KERNBASE+0xB8000)
-#define VGA_BUF (KERNBASE+0xA0000)
-#endif
+/* video hardware memory addresses */
#define VIDEOMEM 0x000A0000
/* misc defines */
@@ -103,7 +95,7 @@
#define TEXT80x50 2
#define COL 80
#define ROW 25
-#define BELL_DURATION 10
+#define BELL_DURATION 5
#define BELL_PITCH 800
#define TIMER_FREQ 1193182 /* should be in isa.h */
#define PCBURST 128
@@ -121,27 +113,35 @@
#define GDCIDX IO_VGA+0x0E /* graph data controller idx */
#define GDCREG IO_VGA+0x0F /* graph data controller data */
+/* special characters */
+#define cntlc 0x03
+#define cntld 0x04
+#define bs 0x08
+#define lf 0x0a
+#define cr 0x0d
+#define del 0x7f
+
typedef struct term_stat {
int esc; /* processing escape sequence */
- int n_par; /* # of parameters to ESC */
- int last_par; /* last parameter # */
- int par[MAX_ESC_PAR]; /* contains ESC parameters */
- int attr; /* current attributes */
+ int num_param; /* # of parameters to ESC */
+ int last_param; /* last parameter # */
+ int param[MAX_ESC_PAR]; /* contains ESC parameters */
+ int cur_attr; /* current attributes */
int std_attr; /* normal attributes */
int rev_attr; /* reverse attributes */
} term_stat;
typedef struct scr_stat {
u_short *crt_base; /* address of screen memory */
- u_short *scr; /* buffer when off screen */
+ u_short *scr_buf; /* buffer when off screen */
u_short *crtat; /* cursor address */
- int posx; /* current X position */
- int posy; /* current Y position */
- int max_posx; /* X size */
- int max_posy; /* X size */
+ int xpos; /* current X position */
+ int ypos; /* current Y position */
+ int xsize; /* X size */
+ int ysize; /* Y size */
term_stat term; /* terminal emulation stuff */
char cursor_start; /* cursor start line # */
- char cursor_end; /* cursor start end # */
+ char cursor_end; /* cursor end line # */
u_char border; /* border color */
u_short bell_duration;
u_short bell_pitch;
@@ -183,35 +183,15 @@ static const u_int n_fkey_tab = sizeof(fkey_tab) / sizeof(*fkey_tab);
static int cur_cursor_pos = -1;
static char in_putc = 0;
static char polling = 0;
-static int nx_scr;
+static int delayed_next_scr;
static char saved_console = -1; /* saved console number */
static long scrn_blank_time = 0; /* screen saver timout value */
static int scrn_blanked = 0; /* screen saver active flag */
static long scrn_time_stamp;
static u_char scr_map[256];
-static struct tty *cur_tty = NULL;
-
-#if defined(NetBSD)
-extern u_short *Crtat;
-struct tty *pc_tty[NCONS];
-int ttrstrt();
-#else
-u_short *Crtat = (u_short *)MONO_BUF;
-struct tty pccons[NCONS];
-#define timeout_t caddr_t
-#endif
-
extern int hz;
extern struct timeval time;
-/* special characters */
-#define cntlc 0x03
-#define cntld 0x04
-#define bs 0x08
-#define lf 0x0a
-#define cr 0x0d
-#define del 0x7f
-
/* function prototypes */
int pcprobe(struct isa_device *dev);
int pcattach(struct isa_device *dev);
@@ -223,36 +203,38 @@ int pcparam(struct tty *tp, struct termios *t);
int pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p);
void pcxint(dev_t dev);
void pcstart(struct tty *tp);
-int pccnprobe(struct consdev *cp);
-int pccninit(struct consdev *cp);
+void pccnprobe(struct consdev *cp);
+void pccninit(struct consdev *cp);
void pccnputc(dev_t dev, char c);
int pccngetc(dev_t dev);
-void scintr(dev_t dev, int irq, int cpl);
+void scintr(int unit);
int pcmmap(dev_t dev, int offset, int nprot);
u_int sgetc(int noblock);
int getchar(void);
-static void reset_cpu(void);
+static void scinit(void);
+static void scput(u_char c);
+static u_int scgetc(int noblock);
static void scrn_saver(int test);
static struct tty *get_tty_ptr(dev_t dev);
static scr_stat *get_scr_stat(dev_t dev);
-static int get_scr_num(scr_stat *scp);
+static int get_scr_num();
static void cursor_shape(int start, int end);
static void get_cursor_shape(int *start, int *end);
-static int cursor_pos(void);
+static void cursor_pos(int force);
static void clear_screen(scr_stat *scp);
-static switch_scr(u_int next_scr);
+static int switch_scr(u_int next_scr);
static void exchange_scr(void);
static void move_crsr(scr_stat *scp, int x, int y);
static void move_up(u_short *s, u_short *d, u_int len);
static void move_down(u_short *s, u_short *d, u_int len);
static void scan_esc(scr_stat *scp, u_char c);
static void ansi_put(scr_stat *scp, u_char c);
-static void scinit(void);
-static void sput(u_char c);
static u_char *get_fstr(u_int c, u_int *len);
static void update_leds(int which);
static void kbd_wait(void);
static void kbd_cmd(u_char command);
+static void kbd_cmd2(u_char command, u_char arg);
+static int kbd_reply(void);
static void set_mode(scr_stat *scp);
static void set_border(int color);
static void load_font(int segment, int size, char* font);
@@ -260,38 +242,68 @@ static void save_palette(void);
static void load_palette(void);
static void change_winsize(struct tty *tp, int x, int y);
+
+/* OS specific stuff */
+
+#if defined(NetBSD)
+#define VIRTUAL_TTY(x) pc_tty[x] ? (pc_tty[x]) : (pc_tty[x] = ttymalloc())
+#define CONSOLE_TTY pc_tty[NCONS] ? (pc_tty[NCONS]) : (pc_tty[NCONS] = ttymalloc())
+#define frametype struct trapframe
+#define eflags tf_eflags
+extern u_short *Crtat;
+struct tty *pc_tty[NCONS+1];
+int ttrstrt();
+#endif
+
+#if defined(__FreeBSD__)
+#define frametype struct trapframe
+#define eflags tf_eflags
+#define timeout_t timeout_func_t
+#define MONO_BUF (KERNBASE+0xB0000)
+#define CGA_BUF (KERNBASE+0xB8000)
+#endif
+
+#if defined(__386BSD__) && !defined(__FreeBSD__)
+#define frametype struct syscframe
+#define eflags sf_eflags
+#define timeout_t caddr_t
+#define MONO_BUF (0xFE0B0000)
+#define CGA_BUF (0xFE0B8000)
+#endif
+
+#if defined(__386BSD__) || defined(__FreeBSD__)
+#define VIRTUAL_TTY(x) &pccons[x]
+#define CONSOLE_TTY &pccons[NCONS]
+u_short *Crtat = (u_short *)MONO_BUF;
+struct tty pccons[NCONS+1];
+void consinit(void) {scinit();}
+#include "ddb.h"
+#if NDDB > 0
+#define DDB 1
+#endif
+#endif
+
+
struct isa_driver scdriver = {
pcprobe, pcattach, "sc",
};
-#if !defined(NetBSD)
-void consinit(void)
-{
- scinit();
-}
-#endif
int pcprobe(struct isa_device *dev)
{
- u_char c;
- int again = 0;
-
/* Enable interrupts and keyboard controller */
kbd_wait();
outb(KB_STAT, KB_WRITE);
kbd_cmd(0x4D);
/* Start keyboard stuff RESET */
- kbd_cmd(KB_RESET);
- while ((c=inb(KB_DATA)) != KB_ACK) {
- if ((c == 0xFE) || (c == 0xFF)) {
- if (!again)
- printf("KEYBOARD disconnected: RECONNECT \n");
- kbd_cmd(KB_RESET);
- again = 1;
- }
+ for (;;) {
+ kbd_cmd(KB_RESET);
+ if (kbd_reply() == KB_ACK && /* command accepted */
+ kbd_reply() == 0xaa) /* self test passed */
+ break;
+ printf("Keyboard reset failed\n");
}
- kbd_wait();
return (IO_KBDSIZE);
}
@@ -317,7 +329,7 @@ int pcattach(struct isa_device *dev)
printf(" <%d virtual consoles>\n", NCONS);
else
printf("\n");
-#ifdef FAT_CURSOR
+#if defined(FAT_CURSOR)
start = 0;
end = 18;
if (crtc_vga) {
@@ -333,17 +345,17 @@ int pcattach(struct isa_device *dev)
current_default = &user_default;
for (i = 0; i < NCONS; i++) {
scp = &console[i];
- scp->scr = (u_short *)malloc(COL * ROW * 2, M_DEVBUF, M_NOWAIT);
+ scp->scr_buf = (u_short *)malloc(COL * ROW * 2, M_DEVBUF, M_NOWAIT);
scp->mode = TEXT80x25;
scp->term.esc = 0;
scp->term.std_attr = current_default->std_attr;
scp->term.rev_attr = current_default->rev_attr;
- scp->term.attr = scp->term.std_attr;
+ scp->term.cur_attr = scp->term.std_attr;
scp->border = BG_BLACK;
scp->cursor_start = start;
scp->cursor_end = end;
- scp->max_posx = COL;
- scp->max_posy = ROW;
+ scp->xsize = COL;
+ scp->ysize = ROW;
scp->bell_pitch = BELL_PITCH;
scp->bell_duration = BELL_DURATION;
scp->status = 0;
@@ -351,18 +363,17 @@ int pcattach(struct isa_device *dev)
scp->proc = NULL;
scp->smode.mode = VT_AUTO;
if (i > 0) {
- scp->crt_base = scp->crtat = scp->scr;
- fillw(scp->term.attr|scr_map[0x20],
- scp->scr, COL*ROW);
+ scp->crt_base = scp->crtat = scp->scr_buf;
+ fillw(scp->term.cur_attr|scr_map[0x20], scp->scr_buf, COL*ROW);
}
}
/* get cursor going */
-#ifdef FAT_CURSOR
+#if defined(FAT_CURSOR)
cursor_shape(console[0].cursor_start,
console[0].cursor_end);
#endif
- cursor_pos();
- return (1);
+ cursor_pos(1);
+ return 0;
}
@@ -370,15 +381,11 @@ static struct tty *get_tty_ptr(dev_t dev)
{
int unit = minor(dev);
- if (unit >= NCONS)
+ if (unit > NCONS)
return(NULL);
-#if defined(NetBSD)
- if (!pc_tty[unit])
- pc_tty[unit] = ttymalloc();
- return(pc_tty[unit]);
-#else
- return(&pccons[unit]);
-#endif
+ if (unit == NCONS)
+ return(CONSOLE_TTY);
+ return(VIRTUAL_TTY(unit));
}
@@ -386,33 +393,33 @@ static scr_stat *get_scr_stat(dev_t dev)
{
int unit = minor(dev);
- if (unit >= NCONS)
+ if (unit > NCONS)
return(NULL);
+ if (unit == NCONS)
+ return(&console[0]);
return(&console[unit]);
}
-static int get_scr_num(scr_stat *scp) /* allways call with legal scp !! */
+static int get_scr_num()
{
int i = 0;
while ((i < NCONS) && (cur_console != &console[i])) i++;
- return i;
+ return i < NCONS ? i : 0;
}
-int
-pcopen(dev_t dev, int flag, int mode, struct proc *p)
+int pcopen(dev_t dev, int flag, int mode, struct proc *p)
{
struct tty *tp = get_tty_ptr(dev);
if (!tp)
return(ENXIO);
- if (!cur_tty)
- cur_tty = tp;
- tp->t_oproc = (void*)pcstart;
+
+ tp->t_oproc = pcstart;
tp->t_param = pcparam;
tp->t_dev = dev;
- if ((tp->t_state & TS_ISOPEN) == 0) {
+ if (!(tp->t_state & TS_ISOPEN)) {
tp->t_state |= TS_WOPEN;
ttychars(tp);
tp->t_iflag = TTYDEF_IFLAG;
@@ -425,30 +432,37 @@ pcopen(dev_t dev, int flag, int mode, struct proc *p)
} else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0)
return(EBUSY);
tp->t_state |= TS_CARR_ON;
+ tp->t_cflag |= CLOCAL;
+#if defined(__FreeBSD__)
return((*linesw[tp->t_line].l_open)(dev, tp, 0));
+#else
+ return((*linesw[tp->t_line].l_open)(dev, tp));
+#endif
}
-int
-pcclose(dev_t dev, int flag, int mode, struct proc *p)
+int pcclose(dev_t dev, int flag, int mode, struct proc *p)
{
struct tty *tp = get_tty_ptr(dev);
struct scr_stat *scp;
if (!tp)
return(ENXIO);
- scp = get_scr_stat(tp->t_dev);
- scp->pid = 0;
- scp->proc = NULL;
- scp->smode.mode = VT_AUTO;
+ if (minor(dev) < NCONS) {
+ scp = get_scr_stat(tp->t_dev);
+ if (scp->status & SWITCH_WAIT_ACQ)
+ wakeup((caddr_t)&scp->smode);
+ scp->pid = 0;
+ scp->proc = NULL;
+ scp->smode.mode = VT_AUTO;
+ }
(*linesw[tp->t_line].l_close)(tp, flag);
ttyclose(tp);
return(0);
}
-int
-pcread(dev_t dev, struct uio *uio, int flag)
+int pcread(dev_t dev, struct uio *uio, int flag)
{
struct tty *tp = get_tty_ptr(dev);
@@ -458,8 +472,7 @@ pcread(dev_t dev, struct uio *uio, int flag)
}
-int
-pcwrite(dev_t dev, struct uio *uio, int flag)
+int pcwrite(dev_t dev, struct uio *uio, int flag)
{
struct tty *tp = get_tty_ptr(dev);
@@ -473,9 +486,9 @@ pcwrite(dev_t dev, struct uio *uio, int flag)
* Got a console interrupt, keyboard action !
* Catch the character, and see who it goes to.
*/
-void
-scintr(dev_t dev, int irq, int cpl)
+void scintr(int unit)
{
+ static struct tty *cur_tty;
int c, len;
u_char *cp;
@@ -484,10 +497,13 @@ scintr(dev_t dev, int irq, int cpl)
if (scrn_blanked)
scrn_saver(0);
- c = sgetc(1);
- if (!cur_tty)
- return;
- if ((cur_tty->t_state & TS_ISOPEN) == 0 || polling)
+ c = scgetc(1);
+
+ cur_tty = VIRTUAL_TTY(get_scr_num());
+ if (!(cur_tty->t_state & TS_ISOPEN))
+ cur_tty = CONSOLE_TTY;
+
+ if (!(cur_tty->t_state & TS_ISOPEN) || polling)
return;
switch (c & 0xff00) {
@@ -495,7 +511,7 @@ scintr(dev_t dev, int irq, int cpl)
(*linesw[cur_tty->t_line].l_rint)(c & 0xFF, cur_tty);
break;
case NOKEY: /* nothing there */
- return;
+ break;
case FKEY: /* function key, return string */
if (cp = get_fstr((u_int)c, (u_int *)&len)) {
while (len-- > 0)
@@ -514,8 +530,7 @@ scintr(dev_t dev, int irq, int cpl)
/*
* Set line parameters
*/
-int
-pcparam(struct tty *tp, struct termios *t)
+int pcparam(struct tty *tp, struct termios *t)
{
int cflag = t->c_cflag;
@@ -523,14 +538,11 @@ pcparam(struct tty *tp, struct termios *t)
tp->t_ispeed = t->c_ispeed;
tp->t_ospeed = t->c_ospeed;
tp->t_cflag = cflag;
- return(0);
+ return 0;
}
-#define frametype struct trapframe
-#define eflags tf_eflags
-int
-pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
+int pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
{
int i, error;
struct tty *tp;
@@ -552,44 +564,44 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
if (!crtc_vga)
return ENXIO;
scp->mode = TEXT80x25;
- scp->max_posy = 25;
- free(scp->scr, M_DEVBUF);
- scp->scr = (u_short *)malloc(scp->max_posx*scp->max_posy*2,
+ scp->ysize = 25;
+ free(scp->scr_buf, M_DEVBUF);
+ scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*2,
M_DEVBUF, M_NOWAIT);
if (scp != cur_console)
- scp->crt_base = scp->scr;
+ scp->crt_base = scp->scr_buf;
set_mode(scp);
clear_screen(scp);
- change_winsize(tp, scp->max_posx, scp->max_posy);
+ change_winsize(tp, scp->xsize, scp->ysize);
return 0;
case CONS_80x50TEXT: /* set 80x50 text mode */
if (!crtc_vga)
return ENXIO;
scp->mode = TEXT80x50;
- scp->max_posy = 50;
- free(scp->scr, M_DEVBUF);
- scp->scr = (u_short *)malloc(scp->max_posx*scp->max_posy*2,
+ scp->ysize = 50;
+ free(scp->scr_buf, M_DEVBUF);
+ scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*2,
M_DEVBUF, M_NOWAIT);
if (scp != cur_console)
- scp->crt_base = scp->scr;
+ scp->crt_base = scp->scr_buf;
set_mode(scp);
clear_screen(scp);
- change_winsize(tp, scp->max_posx, scp->max_posy);
+ change_winsize(tp, scp->xsize, scp->ysize);
return 0;
case CONS_GETVERS: /* get version number */
- *(int*)data = 0x100; /* version 1.0 */
+ *(int*)data = 0x103; /* version 1.3 */
return 0;
case CONS_GETINFO: /* get current (virtual) console info */
if (*data == sizeof(struct vid_info)) {
vid_info_t *ptr = (vid_info_t*)data;
- ptr->m_num = get_scr_num(scp);
- ptr->mv_col = scp->posx;
- ptr->mv_row = scp->posy;
- ptr->mv_csz = scp->max_posx;
- ptr->mv_rsz = scp->max_posy;
+ ptr->m_num = get_scr_num();
+ ptr->mv_col = scp->xpos;
+ ptr->mv_row = scp->ypos;
+ ptr->mv_csz = scp->xsize;
+ ptr->mv_rsz = scp->ysize;
ptr->mv_norm.fore = (scp->term.std_attr & 0x0f00)>>8;
ptr->mv_norm.back = (scp->term.std_attr & 0xf000)>>12;
ptr->mv_rev.fore = (scp->term.rev_attr & 0x0f00)>>8;
@@ -653,17 +665,14 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
/* NOT REACHED */
case VT_OPENQRY: /* return free virtual console */
- for (i = 0; i < NCONS; i++)
-#if defined(NetBSD)
- if (!(pc_tty[i]->t_state & TS_ISOPEN)) {
-#else
- if (!(pccons[i].t_state & TS_ISOPEN)) {
-#endif
+ for (i = 0; i < NCONS; i++) {
+ tp = VIRTUAL_TTY(i);
+ if (!(tp->t_state & TS_ISOPEN)) {
*data = i + 1;
return 0;
}
+ }
return EINVAL;
- /* NOT REACHED */
case VT_ACTIVATE: /* switch to screen *data */
return switch_scr((*data) - 1);
@@ -681,12 +690,12 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
}
else
while ((error=tsleep(
- (caddr_t)&console[*data-1].smode,
+ (caddr_t)&console[*(data-1)].smode,
PZERO|PCATCH, "waitvt", 0)) == ERESTART) ;
return error;
case VT_GETACTIVE:
- *data = get_scr_num(scp)+1;
+ *data = get_scr_num()+1;
return 0;
case KDENABIO: /* allow io operations */
@@ -753,12 +762,10 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
return 0;
case KDSETRAD: /* set keyboard repeat & delay rates */
- if (*(u_char*)data < 0x80) {
- kbd_cmd(KB_SETRAD);
- kbd_cmd(*data & 0x7f);
- return 0;
- }
- return EINVAL;
+ if (*data & 0x80)
+ return EINVAL;
+ kbd_cmd2(KB_SETRAD, *data);
+ return 0;
case KDSKBMODE: /* set keyboard mode */
switch (*data) {
@@ -767,6 +774,8 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
return 0;
case K_XLATE: /* switch to XLT ascii mode */
+ if (scp == cur_console && scp->status == KBD_RAW_MODE)
+ shfts = ctls = alts = agrs = metas = 0;
scp->status &= ~KBD_RAW_MODE;
return 0;
default:
@@ -902,7 +911,7 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
case CONSOLE_X_MODE_ON: /* just to be compatible */
if (saved_console < 0) {
- saved_console = get_scr_num(cur_console);
+ saved_console = get_scr_num();
switch_scr(minor(dev));
fp = (frametype *)p->p_regs;
fp->eflags |= PSL_IOPL;
@@ -956,31 +965,21 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
}
-void
-pcxint(dev_t dev)
+void pcxint(dev_t dev)
{
- int unit = minor(dev);
+ struct tty *tp = get_tty_ptr(dev);
-#if defined(NetBSD)
- if (!pc_tty[unit])
+ if (!tp)
return;
- pc_tty[unit]->t_state &= ~TS_BUSY;
- if (pc_tty[unit]->t_line)
- (*linesw[pc_tty[unit]->t_line].l_start)(pc_tty[unit]);
+ tp->t_state &= ~TS_BUSY;
+ if (tp->t_line)
+ (*linesw[tp->t_line].l_start)(tp);
else
- pcstart(pc_tty[unit]);
-#else
- pccons[unit].t_state &= ~TS_BUSY;
- if (pccons[unit].t_line)
- (*linesw[pccons[unit].t_line].l_start)(&pccons[unit]);
- else
- pcstart(&pccons[unit]);
-#endif
+ pcstart(tp);
}
-void
-pcstart(struct tty *tp)
+void pcstart(struct tty *tp)
{
#if defined(NetBSD)
struct clist *rbp;
@@ -1011,13 +1010,16 @@ pcstart(struct tty *tp)
}
selwakeup(&tp->t_wsel);
}
-
}
splx(s);
-#else
+
+#else /* __FreeBSD__ & __386BSD__ */
+
int c, s;
scr_stat *scp = get_scr_stat(tp->t_dev);
+ if (scp->status & SLKED)
+ return;
s = spltty();
if (!(tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)))
for (;;) {
@@ -1049,73 +1051,91 @@ pcstart(struct tty *tp)
}
-int
-pccnprobe(struct consdev *cp)
+void pccnprobe(struct consdev *cp)
{
int maj;
/* locate the major number */
for (maj = 0; maj < nchrdev; maj++)
- if ((void*) cdevsw[maj].d_open == (void*) pcopen)
+ if ((void*)cdevsw[maj].d_open == (void*)pcopen)
break;
/* initialize required fields */
- cp->cn_dev = makedev(maj, 0);
-#if !defined(NetBSD)
- cp->cn_tp = &pccons[0];
-#endif
+ cp->cn_dev = makedev(maj, NCONS);
cp->cn_pri = CN_INTERNAL;
- return (1);
+#if defined(__FreeBSD__) || defined(__386BSD__)
+ cp->cn_tp = CONSOLE_TTY;
+#endif
}
-int
-pccninit(struct consdev *cp)
+void pccninit(struct consdev *cp)
{
scinit();
- return (1);
}
-void
-pccnputc(dev_t dev, char c)
+void pccnputc(dev_t dev, char c)
{
- int pos;
-
- if (cur_console->status & UNKNOWN_MODE)
- return;
if (c == '\n')
- sput('\r');
- sput(c);
- pos = cur_console->crtat - cur_console->crt_base;
- if (pos != cur_cursor_pos) {
- cur_cursor_pos = pos;
- outb(crtc_addr,14);
- outb(crtc_addr+1,pos >> 8);
- outb(crtc_addr,15);
- outb(crtc_addr+1,pos&0xff);
+ scput('\r');
+ scput(c);
+ if (cur_console == &console[0]) {
+ int pos = cur_console->crtat - cur_console->crt_base;
+ if (pos != cur_cursor_pos) {
+ cur_cursor_pos = pos;
+ outb(crtc_addr,14);
+ outb(crtc_addr+1,pos >> 8);
+ outb(crtc_addr,15);
+ outb(crtc_addr+1,pos&0xff);
+ }
}
}
-int
-pccngetc(dev_t dev)
+int pccngetc(dev_t dev)
{
- int c, s;
-
- s = spltty(); /* block scintr while we poll */
- c = sgetc(0);
+ int s = spltty(); /* block scintr while we poll */
+ int c = scgetc(0);
splx(s);
if (c == '\r') c = '\n';
return(c);
}
-#if !defined(STAR_SAVER) && !defined(SNAKE_SAVER)
-
+#if defined(FADE_SAVER)
static void scrn_saver(int test)
{
- u_char val;
+ static int count = 0;
+ int i;
+
+ if (test) {
+ scrn_blanked = 1;
+ if (count < 64) {
+ outb(PIXMASK, 0xFF); /* no pixelmask */
+ outb(PALWADR, 0x00);
+ outb(PALDATA, 0);
+ outb(PALDATA, 0);
+ outb(PALDATA, 0);
+ for (i = 3; i < 768; i++) {
+ if (palette[i] - count > 15)
+ outb(PALDATA, palette[i]-count);
+ else
+ outb(PALDATA, 15);
+ }
+ inb(crtc_addr+6); /* reset flip/flop */
+ outb(ATC, 0x20); /* enable palette */
+ count++;
+ }
+ }
+ else {
+ count = scrn_blanked = 0;
+ load_palette();
+ }
+}
+#endif
+#if defined(BLANK_SAVER)
+ u_char val;
if (test) {
scrn_blanked = 1;
outb(TSIDX, 0x01); val = inb(TSREG);
@@ -1126,18 +1146,16 @@ static void scrn_saver(int test)
outb(TSIDX, 0x01); val = inb(TSREG);
outb(TSIDX, 0x01); outb(TSREG, val & 0xDF);
}
-}
#endif
-#if defined(STAR_SAVER) || defined(SNAKE_SAVER)
+#if defined(STAR_SAVER)
static u_long rand_next = 1;
static int rand()
{
return ((rand_next = rand_next * 1103515245 + 12345) & 0x7FFFFFFF);
}
-#endif
-#if defined(STAR_SAVER) && !defined(SNAKE_SAVER)
+
/*
* Alternate saver that got its inspiration from a well known utility
* package for an unfamous OS.
@@ -1156,12 +1174,12 @@ static void scrn_saver(int test)
if (test) {
if (!scrn_blanked) {
- bcopy(Crtat, scp->scr,
- scp->max_posx * scp->max_posy * 2);
- fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20],
- Crtat, scp->max_posx * scp->max_posy);
+ bcopy(Crtat, scp->scr_buf,
+ scp->xsize * scp->ysize * 2);
+ fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20], Crtat,
+ scp->xsize * scp->ysize);
set_border(0);
- i = scp->max_posy * scp->max_posx + 5;
+ i = scp->ysize * scp->xsize + 5;
outb(crtc_addr, 14);
outb(crtc_addr+1, i >> 8);
outb(crtc_addr, 15);
@@ -1169,7 +1187,7 @@ static void scrn_saver(int test)
scrn_blanked = 1;
for(i=0; i<NUM_STARS; i++) {
stars[i][0] =
- rand() % (scp->max_posx*scp->max_posy);
+ rand() % (scp->xsize*scp->ysize);
stars[i][1] = 0;
}
}
@@ -1178,13 +1196,13 @@ static void scrn_saver(int test)
scr_map[pattern[stars[cell][1]]] |
colors[rand()%sizeof(colors)] << 8;
if ((stars[cell][1]+=(rand()%4)) >= sizeof(pattern)-1) {
- stars[cell][0] = rand() % (scp->max_posx*scp->max_posy);
+ stars[cell][0] = rand() % (scp->xsize*scp->ysize);
stars[cell][1] = 0;
}
}
else {
if (scrn_blanked) {
- bcopy(scp->scr, Crtat, scp->max_posx*scp->max_posy*2);
+ bcopy(scp->scr_buf, Crtat, scp->xsize*scp->ysize*2);
cur_cursor_pos = -1;
set_border(scp->border);
scrn_blanked = 0;
@@ -1192,70 +1210,7 @@ static void scrn_saver(int test)
}
}
#endif
-#if defined(SNAKE_SAVER) && !defined(STAR_SAVER)
-/*
- * alternative screen saver for cards that do not like blanking
- */
-static void scrn_saver(int test)
-{
- const char saves[] = {"FreeBSD"};
- static u_char *savs[sizeof(saves)-1];
- static int dirx, diry;
- int f;
- scr_stat *scp = cur_console;
-
- if (test) {
- if (!scrn_blanked) {
- bcopy(Crtat, scp->scr,
- scp->max_posx * scp->max_posy * 2);
- fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20],
- Crtat, scp->max_posx * scp->max_posy);
- set_border(0);
- dirx = (scp->posx ? 1 : -1);
- diry = (scp->posy ?
- scp->max_posx : -scp->max_posx);
- for (f=0; f< sizeof(saves)-1; f++)
- savs[f] = (u_char *)Crtat + 2 *
- (scp->posx+scp->posy*scp->max_posx);
- *(savs[0]) = scr_map[*saves];
- f = scp->max_posy * scp->max_posx + 5;
- outb(crtc_addr, 14);
- outb(crtc_addr+1, f >> 8);
- outb(crtc_addr, 15);
- outb(crtc_addr+1, f & 0xff);
- scrn_blanked = 1;
- }
- if (scrn_blanked++ < 4)
- return;
- scrn_blanked = 1;
- *(savs[sizeof(saves)-2]) = scr_map[0x20];
- for (f=sizeof(saves)-2; f > 0; f--)
- savs[f] = savs[f-1];
- f = (savs[0] - (u_char *)Crtat) / 2;
- if ((f % scp->max_posx) == 0 ||
- (f % scp->max_posx) == scp->max_posx - 1 ||
- (rand() % 50) == 0)
- dirx = -dirx;
- if ((f / scp->max_posx) == 0 ||
- (f / scp->max_posx) == scp->max_posy - 1 ||
- (rand() % 20) == 0)
- diry = -diry;
- savs[0] += 2*dirx + 2*diry;
- for (f=sizeof(saves)-2; f>=0; f--)
- *(savs[f]) = scr_map[saves[f]];
- }
- else {
- if (scrn_blanked) {
- bcopy(scp->scr, Crtat,
- scp->max_posx * scp->max_posy * 2);
- cur_cursor_pos = -1;
- set_border(scp->border);
- scrn_blanked = 0;
- }
- }
-}
-#endif
static void cursor_shape(int start, int end)
{
@@ -1266,6 +1221,7 @@ static void cursor_shape(int start, int end)
}
+#if !defined(FAT_CURSOR)
static void get_cursor_shape(int *start, int *end)
{
outb(crtc_addr, 10);
@@ -1273,50 +1229,61 @@ static void get_cursor_shape(int *start, int *end)
outb(crtc_addr, 11);
*end = inb(crtc_addr+1) & 0x1F;
}
+#endif
-int cursor_pos(void)
+static void cursor_pos(int force)
{
int pos;
if (cur_console->status & UNKNOWN_MODE)
- return (0);
+ return;
if (scrn_blank_time && (time.tv_sec > scrn_time_stamp+scrn_blank_time))
scrn_saver(1);
pos = cur_console->crtat - cur_console->crt_base;
- if (!scrn_blanked && pos != cur_cursor_pos) {
+ if (force || (!scrn_blanked && pos != cur_cursor_pos)) {
cur_cursor_pos = pos;
outb(crtc_addr, 14);
outb(crtc_addr+1, pos>>8);
outb(crtc_addr, 15);
outb(crtc_addr+1, pos&0xff);
}
- timeout((timeout_func_t)cursor_pos, 0, hz/20);
- return (0);
+ timeout((timeout_t)cursor_pos, 0, hz/20);
}
static void clear_screen(scr_stat *scp)
{
move_crsr(scp, 0, 0);
- fillw(scp->term.attr | scr_map[0x20], scp->crt_base,
- scp->max_posx * scp->max_posy);
+ fillw(scp->term.cur_attr | scr_map[0x20], scp->crt_base,
+ scp->xsize * scp->ysize);
}
static int switch_scr(u_int next_scr)
{
- if (in_putc) { /* don't switch if in putc */
- nx_scr = next_scr+1;
+ if (in_putc) { /* delay switch if in putc */
+ delayed_next_scr = next_scr+1;
return 0;
}
if (switch_in_progress &&
(cur_console->proc != pfind(cur_console->pid)))
switch_in_progress = 0;
- if (next_scr >= NCONS || switch_in_progress) {
+
+ if (next_scr >= NCONS || switch_in_progress) {
sysbeep(BELL_PITCH, BELL_DURATION);
return EINVAL;
}
+
+ /* is the wanted virtual console open ? */
+ if (next_scr) {
+ struct tty *tp = VIRTUAL_TTY(next_scr);
+ if (!(tp->t_state & TS_ISOPEN)) {
+ sysbeep(BELL_PITCH, BELL_DURATION);
+ return EINVAL;
+ }
+ }
+
switch_in_progress = 1;
old_scp = cur_console;
new_scp = &console[next_scr];
@@ -1352,33 +1319,30 @@ static int switch_scr(u_int next_scr)
static void exchange_scr(void)
{
- bcopy(Crtat, old_scp->scr, old_scp->max_posx * old_scp->max_posy * 2);
- old_scp->crt_base = old_scp->scr;
- move_crsr(old_scp, old_scp->posx, old_scp->posy);
+ struct tty *tp;
+
+ bcopy(Crtat, old_scp->scr_buf, old_scp->xsize * old_scp->ysize * 2);
+ old_scp->crt_base = old_scp->scr_buf;
+ move_crsr(old_scp, old_scp->xpos, old_scp->ypos);
cur_console = new_scp;
-#if defined(NetBSD)
- cur_tty = pc_tty[get_scr_num(new_scp)];
-#else
- cur_tty = &pccons[get_scr_num(new_scp)];
-#endif
- if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE)
- shfts = ctls = alts = agrs = metas = 0;
- update_leds(new_scp->status & LED_MASK);
set_mode(new_scp);
new_scp->crt_base = Crtat;
- move_crsr(new_scp, new_scp->posx, new_scp->posy);
- bcopy(new_scp->scr, Crtat, new_scp->max_posx * new_scp->max_posy * 2);
- nx_scr = 0;
+ move_crsr(new_scp, new_scp->xpos, new_scp->ypos);
+ bcopy(new_scp->scr_buf, Crtat, new_scp->xsize * new_scp->ysize * 2);
+ update_leds(new_scp->status & LED_MASK);
+ if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE)
+ shfts = ctls = alts = agrs = metas = 0;
+ delayed_next_scr = 0;
}
static void move_crsr(scr_stat *scp, int x, int y)
{
- if (x < 0 || y < 0 || x >= scp->max_posx || y >= scp->max_posy)
+ if (x < 0 || y < 0 || x >= scp->xsize || y >= scp->ysize)
return;
- scp->posx = x;
- scp->posy = y;
- scp->crtat = scp->crt_base + scp->posy * scp->max_posx + scp->posx;
+ scp->xpos = x;
+ scp->ypos = y;
+ scp->crtat = scp->crt_base + scp->ypos * scp->xsize + scp->xpos;
}
@@ -1410,21 +1374,21 @@ static void scan_esc(scr_stat *scp, u_char c)
case '[': /* Start ESC [ sequence */
scp->term.esc = 2;
- scp->term.last_par = -1;
- for (i = scp->term.n_par; i < MAX_ESC_PAR; i++)
- scp->term.par[i] = 1;
- scp->term.n_par = 0;
+ scp->term.last_param = -1;
+ for (i = scp->term.num_param; i < MAX_ESC_PAR; i++)
+ scp->term.param[i] = 1;
+ scp->term.num_param = 0;
return;
case 'M': /* Move cursor up 1 line, scroll if at top */
- if (scp->posy > 0)
- move_crsr(scp, scp->posx, scp->posy - 1);
+ if (scp->ypos > 0)
+ move_crsr(scp, scp->xpos, scp->ypos - 1);
else {
move_up(scp->crt_base,
- scp->crt_base + scp->max_posx,
- (scp->max_posy - 1) * scp->max_posx);
- fillw(scp->term.attr | scr_map[0x20],
- scp->crt_base, scp->max_posx);
+ scp->crt_base + scp->xsize,
+ (scp->ysize - 1) * scp->xsize);
+ fillw(scp->term.cur_attr | scr_map[0x20],
+ scp->crt_base, scp->xsize);
}
break;
#if notyet
@@ -1439,86 +1403,86 @@ static void scan_esc(scr_stat *scp, u_char c)
}
else if (scp->term.esc == 2) {
if (c >= '0' && c <= '9') {
- if (scp->term.n_par < MAX_ESC_PAR) {
- if (scp->term.last_par != scp->term.n_par) {
- scp->term.last_par = scp->term.n_par;
- scp->term.par[scp->term.n_par] = 0;
+ if (scp->term.num_param < MAX_ESC_PAR) {
+ if (scp->term.last_param != scp->term.num_param) {
+ scp->term.last_param = scp->term.num_param;
+ scp->term.param[scp->term.num_param] = 0;
}
else
- scp->term.par[scp->term.n_par] *= 10;
- scp->term.par[scp->term.n_par] += c - '0';
+ scp->term.param[scp->term.num_param] *= 10;
+ scp->term.param[scp->term.num_param] += c - '0';
return;
}
}
- scp->term.n_par = scp->term.last_par + 1;
+ scp->term.num_param = scp->term.last_param + 1;
switch (c) {
case ';':
- if (scp->term.n_par < MAX_ESC_PAR)
+ if (scp->term.num_param < MAX_ESC_PAR)
return;
break;
case '=':
scp->term.esc = 3;
- scp->term.last_par = -1;
- for (i = scp->term.n_par; i < MAX_ESC_PAR; i++)
- scp->term.par[i] = 1;
- scp->term.n_par = 0;
+ scp->term.last_param = -1;
+ for (i = scp->term.num_param; i < MAX_ESC_PAR; i++)
+ scp->term.param[i] = 1;
+ scp->term.num_param = 0;
return;
case 'A': /* up n rows */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx, scp->posy - n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos, scp->ypos - n);
break;
case 'B': /* down n rows */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx, scp->posy + n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos, scp->ypos + n);
break;
case 'C': /* right n columns */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx + n, scp->posy);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos + n, scp->ypos);
break;
case 'D': /* left n columns */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx - n, scp->posy);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos - n, scp->ypos);
break;
case 'E': /* cursor to start of line n lines down */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, 0, scp->posy + n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, 0, scp->ypos + n);
break;
case 'F': /* cursor to start of line n lines up */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, 0, scp->posy - n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, 0, scp->ypos - n);
break;
case 'f': /* System V consoles .. */
case 'H': /* Cursor move */
- if (scp->term.n_par == 0)
+ if (scp->term.num_param == 0)
move_crsr(scp, 0, 0);
- else if (scp->term.n_par == 2)
- move_crsr(scp, scp->term.par[1] - 1,
- scp->term.par[0] - 1);
+ else if (scp->term.num_param == 2)
+ move_crsr(scp, scp->term.param[1] - 1,
+ scp->term.param[0] - 1);
break;
case 'J': /* Clear all or part of display */
- if (scp->term.n_par == 0)
+ if (scp->term.num_param == 0)
n = 0;
else
- n = scp->term.par[0];
+ n = scp->term.param[0];
switch (n) {
case 0: /* clear form cursor to end of display */
- fillw(scp->term.attr | scr_map[0x20],
+ fillw(scp->term.cur_attr | scr_map[0x20],
scp->crtat, scp->crt_base +
- scp->max_posx * scp->max_posy -
+ scp->xsize * scp->ysize -
scp->crtat);
break;
case 1: /* clear from beginning of display to cursor */
- fillw(scp->term.attr | scr_map[0x20],
+ fillw(scp->term.cur_attr | scr_map[0x20],
scp->crt_base,
scp->crtat - scp->crt_base);
break;
@@ -1529,259 +1493,259 @@ static void scan_esc(scr_stat *scp, u_char c)
break;
case 'K': /* Clear all or part of line */
- if (scp->term.n_par == 0)
+ if (scp->term.num_param == 0)
n = 0;
else
- n = scp->term.par[0];
+ n = scp->term.param[0];
switch (n) {
case 0: /* clear form cursor to end of line */
- fillw(scp->term.attr | scr_map[0x20],
- scp->crtat, scp->max_posx - scp->posx);
+ fillw(scp->term.cur_attr | scr_map[0x20],
+ scp->crtat, scp->xsize - scp->xpos);
break;
case 1: /* clear from beginning of line to cursor */
- fillw(scp->term.attr|scr_map[0x20],
- scp->crtat - (scp->max_posx - scp->posx),
- (scp->max_posx - scp->posx) + 1);
+ fillw(scp->term.cur_attr|scr_map[0x20],
+ scp->crtat - (scp->xsize - scp->xpos),
+ (scp->xsize - scp->xpos) + 1);
break;
case 2: /* clear entire line */
- fillw(scp->term.attr|scr_map[0x20],
- scp->crtat - (scp->max_posx - scp->posx),
- scp->max_posx);
+ fillw(scp->term.cur_attr|scr_map[0x20],
+ scp->crtat - (scp->xsize - scp->xpos),
+ scp->xsize);
break;
}
break;
case 'L': /* Insert n lines */
- n = scp->term.par[0]; if (n < 1) n = 1;
- if (n > scp->max_posy - scp->posy)
- n = scp->max_posy - scp->posy;
- src = scp->crt_base + scp->posy * scp->max_posx;
- dst = src + n * scp->max_posx;
- count = scp->max_posy - (scp->posy + n);
- move_up(src, dst, count * scp->max_posx);
- fillw(scp->term.attr | scr_map[0x20], src,
- n * scp->max_posx);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ if (n > scp->ysize - scp->ypos)
+ n = scp->ysize - scp->ypos;
+ src = scp->crt_base + scp->ypos * scp->xsize;
+ dst = src + n * scp->xsize;
+ count = scp->ysize - (scp->ypos + n);
+ move_up(src, dst, count * scp->xsize);
+ fillw(scp->term.cur_attr | scr_map[0x20], src,
+ n * scp->xsize);
break;
case 'M': /* Delete n lines */
- n = scp->term.par[0]; if (n < 1) n = 1;
- if (n > scp->max_posy - scp->posy)
- n = scp->max_posy - scp->posy;
- dst = scp->crt_base + scp->posy * scp->max_posx;
- src = dst + n * scp->max_posx;
- count = scp->max_posy - (scp->posy + n);
- move_down(src, dst, count * scp->max_posx);
- src = dst + count * scp->max_posx;
- fillw(scp->term.attr | scr_map[0x20], src,
- n * scp->max_posx);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ if (n > scp->ysize - scp->ypos)
+ n = scp->ysize - scp->ypos;
+ dst = scp->crt_base + scp->ypos * scp->xsize;
+ src = dst + n * scp->xsize;
+ count = scp->ysize - (scp->ypos + n);
+ move_down(src, dst, count * scp->xsize);
+ src = dst + count * scp->xsize;
+ fillw(scp->term.cur_attr | scr_map[0x20], src,
+ n * scp->xsize);
break;
case 'P': /* Delete n chars */
- n = scp->term.par[0]; if (n < 1) n = 1;
- if (n > scp->max_posx - scp->posx)
- n = scp->max_posx - scp->posx;
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ if (n > scp->xsize - scp->xpos)
+ n = scp->xsize - scp->xpos;
dst = scp->crtat;
src = dst + n;
- count = scp->max_posx - (scp->posx + n);
+ count = scp->xsize - (scp->xpos + n);
move_down(src, dst, count);
src = dst + count;
- fillw(scp->term.attr | scr_map[0x20], src, n);
+ fillw(scp->term.cur_attr | scr_map[0x20], src, n);
break;
case '@': /* Insert n chars */
- n = scp->term.par[0]; if (n < 1) n = 1;
- if (n > scp->max_posx - scp->posx)
- n = scp->max_posx - scp->posx;
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ if (n > scp->xsize - scp->xpos)
+ n = scp->xsize - scp->xpos;
src = scp->crtat;
dst = src + n;
- count = scp->max_posx - (scp->posx + n);
+ count = scp->xsize - (scp->xpos + n);
move_up(src, dst, count);
- fillw(scp->term.attr | scr_map[0x20], src, n);
+ fillw(scp->term.cur_attr | scr_map[0x20], src, n);
break;
case 'S': /* scroll up n lines */
- n = scp->term.par[0]; if (n < 1) n = 1;
- bcopy(scp->crt_base + (scp->max_posx * n),
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ bcopy(scp->crt_base + (scp->xsize * n),
scp->crt_base,
- scp->max_posx * (scp->max_posy - n) *
+ scp->xsize * (scp->ysize - n) *
sizeof(u_short));
- fillw(scp->term.attr | scr_map[0x20],
- scp->crt_base + scp->max_posx *
- (scp->max_posy - 1),
- scp->max_posx);
+ fillw(scp->term.cur_attr | scr_map[0x20],
+ scp->crt_base + scp->xsize *
+ (scp->ysize - 1),
+ scp->xsize);
break;
case 'T': /* scroll down n lines */
- n = scp->term.par[0]; if (n < 1) n = 1;
+ n = scp->term.param[0]; if (n < 1) n = 1;
bcopy(scp->crt_base,
- scp->crt_base + (scp->max_posx * n),
- scp->max_posx * (scp->max_posy - n) *
+ scp->crt_base + (scp->xsize * n),
+ scp->xsize * (scp->ysize - n) *
sizeof(u_short));
- fillw(scp->term.attr | scr_map[0x20],
- scp->crt_base, scp->max_posx);
+ fillw(scp->term.cur_attr | scr_map[0x20], scp->crt_base,
+ scp->xsize);
break;
case 'X': /* delete n characters in line */
- n = scp->term.par[0]; if (n < 1) n = 1;
- fillw(scp->term.attr | scr_map[0x20],
- scp->crt_base + scp->posx +
- ((scp->max_posx*scp->posy) * sizeof(u_short)), n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ fillw(scp->term.cur_attr | scr_map[0x20],
+ scp->crt_base + scp->xpos +
+ ((scp->xsize*scp->ypos) * sizeof(u_short)), n);
break;
case 'Z': /* move n tabs backwards */
- n = scp->term.par[0]; if (n < 1) n = 1;
- if ((i = scp->posx & 0xf8) == scp->posx)
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ if ((i = scp->xpos & 0xf8) == scp->xpos)
i -= 8*n;
else
i -= 8*(n-1);
if (i < 0)
i = 0;
- move_crsr(scp, i, scp->posy);
+ move_crsr(scp, i, scp->ypos);
break;
case '`': /* move cursor to column n */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, n, scp->posy);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, n, scp->ypos);
break;
case 'a': /* move cursor n columns to the right */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx + n, scp->posy);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos + n, scp->ypos);
break;
case 'd': /* move cursor to row n */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx, n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos, n);
break;
case 'e': /* move cursor n rows down */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx, scp->posy + n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos, scp->ypos + n);
break;
case 'm': /* change attribute */
- if (scp->term.n_par == 0)
+ if (scp->term.num_param == 0)
n = 0;
else
- n = scp->term.par[0];
+ n = scp->term.param[0];
switch (n) {
case 0: /* back to normal */
- scp->term.attr = scp->term.std_attr;
+ scp->term.cur_attr = scp->term.std_attr;
break;
case 1: /* highlight (bold) */
- scp->term.attr &= 0xFF00;
- scp->term.attr |= 0x0800;
+ scp->term.cur_attr &= 0xFF00;
+ scp->term.cur_attr |= 0x0800;
break;
case 4: /* highlight (underline) */
- scp->term.attr &= 0x0F00;
- scp->term.attr |= 0x0800;
+ scp->term.cur_attr &= 0x0F00;
+ scp->term.cur_attr |= 0x0800;
break;
case 5: /* blink */
- scp->term.attr &= 0xFF00;
- scp->term.attr |= 0x8000;
+ scp->term.cur_attr &= 0xFF00;
+ scp->term.cur_attr |= 0x8000;
break;
case 7: /* reverse video */
- scp->term.attr = scp->term.rev_attr;
+ scp->term.cur_attr = scp->term.rev_attr;
break;
case 30: case 31: case 32: case 33: /* set fg color */
case 34: case 35: case 36: case 37:
- scp->term.attr = (scp->term.attr & 0xF0FF)
+ scp->term.cur_attr = (scp->term.cur_attr & 0xF0FF)
| (ansi_col[(n - 30) & 7] << 8);
break;
case 40: case 41: case 42: case 43: /* set bg color */
case 44: case 45: case 46: case 47:
- scp->term.attr = (scp->term.attr & 0x0FFF)
+ scp->term.cur_attr = (scp->term.cur_attr & 0x0FFF)
| (ansi_col[(n - 40) & 7] << 12);
break;
}
break;
case 'x':
- if (scp->term.n_par == 0)
+ if (scp->term.num_param == 0)
n = 0;
else
- n = scp->term.par[0];
+ n = scp->term.param[0];
switch (n) {
case 0: /* reset attributes */
- scp->term.attr = scp->term.std_attr =
+ scp->term.cur_attr = scp->term.std_attr =
current_default->std_attr;
scp->term.rev_attr = current_default->rev_attr;
break;
case 1: /* set ansi background */
- scp->term.attr = scp->term.std_attr =
+ scp->term.cur_attr = scp->term.std_attr =
(scp->term.std_attr & 0x0F00) |
- (ansi_col[(scp->term.par[1])&0x0F]<<12);
+ (ansi_col[(scp->term.param[1])&0x0F]<<12);
break;
case 2: /* set ansi foreground */
- scp->term.attr = scp->term.std_attr =
+ scp->term.cur_attr = scp->term.std_attr =
(scp->term.std_attr & 0xF000) |
- (ansi_col[(scp->term.par[1])&0x0F]<<8);
+ (ansi_col[(scp->term.param[1])&0x0F]<<8);
break;
case 3: /* set ansi attribute directly */
- scp->term.attr = scp->term.std_attr =
- (scp->term.par[1]&0xFF)<<8;
+ scp->term.cur_attr = scp->term.std_attr =
+ (scp->term.param[1]&0xFF)<<8;
break;
case 5: /* set ansi reverse video background */
scp->term.rev_attr =
(scp->term.rev_attr & 0x0F00) |
- (ansi_col[(scp->term.par[1])&0x0F]<<12);
+ (ansi_col[(scp->term.param[1])&0x0F]<<12);
break;
case 6: /* set ansi reverse video foreground */
scp->term.rev_attr =
(scp->term.rev_attr & 0xF000) |
- (ansi_col[(scp->term.par[1])&0x0F]<<8);
+ (ansi_col[(scp->term.param[1])&0x0F]<<8);
break;
case 7: /* set ansi reverse video directly */
- scp->term.rev_attr = (scp->term.par[1]&0xFF)<<8;
+ scp->term.rev_attr = (scp->term.param[1]&0xFF)<<8;
break;
}
break;
case 'z': /* switch to (virtual) console n */
- if (scp->term.n_par == 1)
- switch_scr(scp->term.par[0]);
+ if (scp->term.num_param == 1)
+ switch_scr(scp->term.param[0]);
break;
}
}
else if (scp->term.esc == 3) {
if (c >= '0' && c <= '9') {
- if (scp->term.n_par < MAX_ESC_PAR) {
- if (scp->term.last_par != scp->term.n_par) {
- scp->term.last_par = scp->term.n_par;
- scp->term.par[scp->term.n_par] = 0;
+ if (scp->term.num_param < MAX_ESC_PAR) {
+ if (scp->term.last_param != scp->term.num_param) {
+ scp->term.last_param = scp->term.num_param;
+ scp->term.param[scp->term.num_param] = 0;
}
else
- scp->term.par[scp->term.n_par] *= 10;
- scp->term.par[scp->term.n_par] += c - '0';
+ scp->term.param[scp->term.num_param] *= 10;
+ scp->term.param[scp->term.num_param] += c - '0';
return;
}
}
- scp->term.n_par = scp->term.last_par + 1;
+ scp->term.num_param = scp->term.last_param + 1;
switch (c) {
case ';':
- if (scp->term.n_par < MAX_ESC_PAR)
+ if (scp->term.num_param < MAX_ESC_PAR)
return;
break;
case 'A': /* set display border color */
- if (scp->term.n_par == 1)
- scp->border=scp->term.par[0] & 0xff;
+ if (scp->term.num_param == 1)
+ scp->border=scp->term.param[0] & 0xff;
if (scp == cur_console)
set_border(scp->border);
break;
case 'B': /* set bell pitch and duration */
- if (scp->term.n_par == 2) {
- scp->bell_pitch = scp->term.par[0];
- scp->bell_duration = scp->term.par[1]*10;
+ if (scp->term.num_param == 2) {
+ scp->bell_pitch = scp->term.param[0];
+ scp->bell_duration = scp->term.param[1]*10;
}
break;
case 'C': /* set cursor shape (start & end line) */
- if (scp->term.n_par == 2) {
- scp->cursor_start = scp->term.par[0] & 0x1F;
- scp->cursor_end = scp->term.par[1] & 0x1F;
+ if (scp->term.num_param == 2) {
+ scp->cursor_start = scp->term.param[0] & 0x1F;
+ scp->cursor_end = scp->term.param[1] & 0x1F;
if (scp == cur_console)
cursor_shape(scp->cursor_start,
scp->cursor_end);
@@ -1789,31 +1753,31 @@ static void scan_esc(scr_stat *scp, u_char c)
break;
case 'F': /* set ansi foreground */
- if (scp->term.n_par == 1)
- scp->term.attr = scp->term.std_attr =
+ if (scp->term.num_param == 1)
+ scp->term.cur_attr = scp->term.std_attr =
(scp->term.std_attr & 0xF000)
- | ((scp->term.par[0] & 0x0F) << 8);
+ | ((scp->term.param[0] & 0x0F) << 8);
break;
case 'G': /* set ansi background */
- if (scp->term.n_par == 1)
- scp->term.attr = scp->term.std_attr =
+ if (scp->term.num_param == 1)
+ scp->term.cur_attr = scp->term.std_attr =
(scp->term.std_attr & 0x0F00)
- | ((scp->term.par[0] & 0x0F) << 12);
+ | ((scp->term.param[0] & 0x0F) << 12);
break;
case 'H': /* set ansi reverse video foreground */
- if (scp->term.n_par == 1)
+ if (scp->term.num_param == 1)
scp->term.rev_attr =
(scp->term.rev_attr & 0xF000)
- | ((scp->term.par[0] & 0x0F) << 8);
+ | ((scp->term.param[0] & 0x0F) << 8);
break;
case 'I': /* set ansi reverse video background */
- if (scp->term.n_par == 1)
+ if (scp->term.num_param == 1)
scp->term.rev_attr =
(scp->term.rev_attr & 0x0F00)
- | ((scp->term.par[0] & 0x0F) << 12);
+ | ((scp->term.param[0] & 0x0F) << 12);
break;
}
}
@@ -1826,71 +1790,73 @@ static void ansi_put(scr_stat *scp, u_char c)
if (scp->status & UNKNOWN_MODE)
return;
+#if defined(STAR_SAVER)
/* make screensaver happy */
if (scp == cur_console) {
scrn_time_stamp = time.tv_sec;
if (scrn_blanked)
scrn_saver(0);
}
+#endif
in_putc++;
if (scp->term.esc)
scan_esc(scp, c);
else switch(c) {
case 0x1B: /* start escape sequence */
scp->term.esc = 1;
- scp->term.n_par = 0;
+ scp->term.num_param = 0;
break;
case 0x07:
if (scp == cur_console)
sysbeep(scp->bell_pitch, scp->bell_duration);
break;
case '\t': /* non-destructive tab */
- scp->crtat += (8 - scp->posx % 8);
- scp->posx += (8 - scp->posx % 8);
+ scp->crtat += (8 - scp->xpos % 8);
+ scp->xpos += (8 - scp->xpos % 8);
break;
case '\b': /* non-destructive backspace */
if (scp->crtat > scp->crt_base) {
scp->crtat--;
- if (scp->posx > 0)
- scp->posx--;
+ if (scp->xpos > 0)
+ scp->xpos--;
else {
- scp->posx += scp->max_posx - 1;
- scp->posy--;
+ scp->xpos += scp->xsize - 1;
+ scp->ypos--;
}
}
break;
case '\r': /* return to pos 0 */
- move_crsr(scp, 0, scp->posy);
+ move_crsr(scp, 0, scp->ypos);
break;
case '\n': /* newline, same pos */
- scp->crtat += scp->max_posx;
- scp->posy++;
+ scp->crtat += scp->xsize;
+ scp->ypos++;
break;
case '\f': /* form feed, clears screen */
clear_screen(scp);
break;
default:
/* Print only printables */
- *scp->crtat = (scp->term.attr | scr_map[c]);
+ *scp->crtat = (scp->term.cur_attr | scr_map[c]);
scp->crtat++;
- if (++scp->posx >= scp->max_posx) {
- scp->posx = 0;
- scp->posy++;
+ if (++scp->xpos >= scp->xsize) {
+ scp->xpos = 0;
+ scp->ypos++;
}
break;
}
- if (scp->crtat >= scp->crt_base + scp->max_posy * scp->max_posx) {
- bcopy(scp->crt_base + scp->max_posx, scp->crt_base,
- scp->max_posx * (scp->max_posy - 1) * sizeof(u_short));
- fillw(scp->term.attr | scr_map[0x20],
- scp->crt_base + scp->max_posx
- * (scp->max_posy - 1), scp->max_posx);
- scp->crtat -= scp->max_posx;
- scp->posy--;
+ if (scp->crtat >= scp->crt_base + scp->ysize * scp->xsize) {
+ bcopy(scp->crt_base + scp->xsize, scp->crt_base,
+ scp->xsize * (scp->ysize - 1) * sizeof(u_short));
+ fillw(scp->term.cur_attr | scr_map[0x20],
+ scp->crt_base + scp->xsize * (scp->ysize - 1),
+ scp->xsize);
+ scp->crtat -= scp->xsize;
+ scp->ypos--;
}
in_putc--;
- if (nx_scr)
- switch_scr(nx_scr - 1);
+ if (delayed_next_scr)
+ switch_scr(delayed_next_scr - 1);
}
static void scinit(void)
@@ -1908,7 +1874,7 @@ static void scinit(void)
/*
* Crtat initialized to point to MONO buffer, if not present change
* to CGA_BUF offset. ONLY ADD the difference since locore.s adds
- * in the remapped offset at the right time
+ * in the remapped offset at the "right" time
*/
was = *cp;
*cp = (u_short) 0xA55A;
@@ -1938,12 +1904,12 @@ static void scinit(void)
console[0].term.esc = 0;
console[0].term.std_attr = current_default->std_attr;
console[0].term.rev_attr = current_default->rev_attr;
- console[0].term.attr = current_default->std_attr;
- console[0].posx = cursorat % COL;
- console[0].posy = cursorat / COL;
+ console[0].term.cur_attr = current_default->std_attr;
+ console[0].xpos = cursorat % COL;
+ console[0].ypos = cursorat / COL;
console[0].border = BG_BLACK;;
- console[0].max_posx = COL;
- console[0].max_posy = ROW;
+ console[0].xsize = COL;
+ console[0].ysize = ROW;
console[0].status = 0;
console[0].pid = 0;
console[0].proc = NULL;
@@ -1953,15 +1919,15 @@ static void scinit(void)
kernel_console.esc = 0;
kernel_console.std_attr = kernel_default.std_attr;
kernel_console.rev_attr = kernel_default.rev_attr;
- kernel_console.attr = kernel_default.std_attr;
- /* initialize mapscrn array to */
+ kernel_console.cur_attr = kernel_default.std_attr;
+ /* initialize mapscrn array to a one to one map */
for (i=0; i<sizeof(scr_map); i++)
scr_map[i] = i;
clear_screen(&console[0]);
}
-static void sput(u_char c)
+static void scput(u_char c)
{
scr_stat *scp = &console[0];
term_stat save;
@@ -1994,29 +1960,17 @@ static u_char *get_fstr(u_int c, u_int *len)
static void update_leds(int which)
{
- u_char xlate_leds[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
-
- kbd_cmd(KB_SETLEDS); /* LED Command */
- kbd_cmd(xlate_leds[which & LED_MASK]);
- kbd_wait();
-}
-
+ static u_char xlate_leds[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
-static volatile void reset_cpu(void)
-{
- while (1) {
- kbd_cmd(KB_RESET_CPU); /* Reset Command */
- DELAY(4000000);
- kbd_cmd(KB_RESET); /* Keyboard Reset Command */
- }
+ kbd_cmd2(KB_SETLEDS, xlate_leds[which & LED_MASK]);
}
-
-
+
+
/*
- * sgetc(noblock) : get a character from the keyboard.
+ * scgetc(noblock) : get a character from the keyboard.
* If noblock = 0 wait until a key is gotten. Otherwise return NOKEY.
*/
-u_int sgetc(int noblock)
+u_int scgetc(int noblock)
{
u_char val, code, release;
u_int state, action;
@@ -2221,7 +2175,7 @@ next_code:
if (chr && !compose) {
action = chr;
chr = 0;
- return (action);
+ return(action);
}
} else {
/* key pressed */
@@ -2253,11 +2207,7 @@ next_code:
slkcnt++;
if (cur_console->status & SLKED) {
cur_console->status &= ~SLKED;
-#if defined(NetBSD)
- pcstart(pc_tty[get_scr_num(cur_console)]);
-#else
- pcstart(&pccons[get_scr_num(cur_console)]);
-#endif
+ pcstart(VIRTUAL_TTY(get_scr_num()));
}
else
cur_console->status |= SLKED;
@@ -2278,14 +2228,18 @@ next_code:
case NOP:
break;
case RBT:
+#if defined(__FreeBSD__)
shutdown_nice();
+#else
+ cpu_reset();
+#endif
break;
case DBG:
#if DDB > 0 /* try to switch to console 0 */
if (cur_console->smode.mode == VT_AUTO &&
console[0].smode.mode == VT_AUTO)
switch_scr(0);
- Debugger("manual escape to debugger");
+ Debugger();
return(NOKEY);
#else
printf("No debugger in kernel\n");
@@ -2316,7 +2270,7 @@ next_code:
metas = 1;
break;
case NEXT:
- switch_scr((get_scr_num(cur_console)+1)%NCONS);
+ switch_scr((get_scr_num()+1)%NCONS);
break;
default:
if (action >= F_SCR && action <= L_SCR) {
@@ -2345,30 +2299,35 @@ int getchar(void)
polling = 1;
s = splhigh();
- sput('>');
- thechar = (u_char) sgetc(0);
+ scput('>');
+ thechar = (u_char) scgetc(0);
polling = 0;
splx(s);
switch (thechar) {
default:
if (thechar >= scr_map[0x20])
- sput(thechar);
+ scput(thechar);
return(thechar);
case cr:
case lf:
- sput(cr); sput(lf);
+ scput(cr); scput(lf);
return(lf);
case bs:
case del:
- sput(bs); sput(scr_map[0x20]); sput(bs);
+ scput(bs); scput(scr_map[0x20]); scput(bs);
return(thechar);
case cntld:
- sput('^'); sput('D'); sput('\r'); sput('\n');
+ scput('^'); scput('D'); scput('\r'); scput('\n');
return(0);
}
}
+u_int sgetc(int noblock)
+{
+ return (scgetc(noblock & 0xff);
+}
+
int pcmmap(dev_t dev, int offset, int nprot)
{
if (offset > 0x20000)
@@ -2380,9 +2339,12 @@ int pcmmap(dev_t dev, int offset, int nprot)
static void kbd_wait(void)
{
int i;
- for (i=0; i<10000; i++)
+
+ for (i=0; i<1000; i++) { /* up to 10 msec */
if ((inb(KB_STAT) & KB_READY) == 0)
break;
+ DELAY (10);
+ }
}
@@ -2393,6 +2355,35 @@ static void kbd_cmd(u_char command)
}
+static void kbd_cmd2(u_char command, u_char arg)
+{
+ int r, s = spltty();
+ do {
+ kbd_cmd(command);
+ r = kbd_reply();
+ if (r == KB_ACK) {
+ kbd_cmd(arg & 0x7f);
+ r = kbd_reply();
+ }
+ } while (r != KB_ACK);
+ splx(s);
+}
+
+
+static int kbd_reply()
+{
+ int i;
+
+ kbd_wait();
+ for (i=0; i<50000; i++) { /* at least 300 msec, 500 msec enough */
+ if (inb(KB_STAT) & KB_BUF_FULL)
+ return ((u_char) inb(KB_DATA));
+ DELAY (10);
+ }
+ return(-1);
+}
+
+
static void set_mode(scr_stat *scp)
{
u_char byte;
@@ -2402,8 +2393,8 @@ static void set_mode(scr_stat *scp)
return;
/* (re)activate cursor */
- untimeout((timeout_func_t)cursor_pos, 0);
- cursor_pos();
+ untimeout((timeout_t)cursor_pos, 0);
+ cursor_pos(1);
/* change cursor type if set */
if (scp->cursor_start != -1 && scp->cursor_end != -1)
diff --git a/sys/i386/include/console.h b/sys/i386/include/console.h
index 9d0d8e3..ce0cc9b 100644
--- a/sys/i386/include/console.h
+++ b/sys/i386/include/console.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1992, 1993 Søren Schmidt
+ * Copyright (C) 1992, 1993, 1994 Søren Schmidt
*
* This program is free software; you may redistribute it and/or
* modify it, provided that it retain the above copyright notice
@@ -9,11 +9,12 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * Søren Schmidt Email: sos@kmd-ac.dk
- * Tritonvej 36 UUCP: ...uunet!dkuug!kmd-ac!sos
+ * Søren Schmidt Email: sos@login.dkuug.dk
+ * Tritonvej 36 UUCP: ...uunet!dkuug!login!sos
* DK9210 Aalborg SO Phone: +45 9814 8076
*
- * $Id$
+ * from:@(#)console.h 1.1 940105
+ * $Id: console.h,v 1.5 1993/10/28 06:11:38 rgrimes Exp $
*/
#ifndef _CONSOLE_H_
diff --git a/sys/i386/isa/kbdtables.h b/sys/i386/isa/kbdtables.h
index a3a7c81..33e2b36 100644
--- a/sys/i386/isa/kbdtables.h
+++ b/sys/i386/isa/kbdtables.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1992, 1993 Søren Schmidt
+ * Copyright (C) 1992, 1993, 1994 Søren Schmidt
*
* This program is free software; you may redistribute it and/or
* modify it, provided that it retain the above copyright notice
@@ -9,11 +9,12 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * Søren Schmidt Email: sos@kmd-ac.dk
- * Tritonvej 36 UUCP: ...uunet!dkuug!kmd-ac!sos
+ * Søren Schmidt Email: sos@login.dkuug.dk
+ * Tritonvej 36 UUCP: ...uunet!dkuug!login!sos
* DK9210 Aalborg SO Phone: +45 9814 8076
*
- * $Id: kbdtables.h,v 1.8 1994/01/18 05:31:37 nate Exp $
+ * @(#)kbdtables.h 1.3 940123
+ * $Id: kbdtables.h,v 1.9 1994/01/24 05:22:27 ache Exp $
*/
#define SET8 0x80 /* eight bit for emacs SET8-key */
@@ -26,7 +27,7 @@ keymap_t key_map = { 0x69, /* DK iso8859 keymap */
* ---------------------------------------------------------------------------
*/
/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, NOP, NOP, 0x1B, 0x1B, NOP, NOP, 0x33, 0x00,
+/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, 0x02, 0x00,
/* sc=02 */ '1', '!', NOP, NOP, '1', '!', NOP, NOP, 0x33, 0x00,
/* sc=03 */ '2', '"', 0x00, 0x00, '@', '"', 0x00, 0x00, 0x00, 0x00,
/* sc=04 */ '3', '#', NOP, NOP, 0x9E, '#', NOP, NOP, 0x33, 0x00,
@@ -108,7 +109,7 @@ keymap_t key_map = { 0x69, /* DK iso8859 keymap */
/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02,
-/* sc=53 */ 0x7F, '.', '.', '.', '.', '.', RBT, '.', 0x02, 0x02,
+/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, RBT, 0x7F, 0x02, 0x02,
/* sc=54 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ '<', '>', 0x1C, 0x1C, '\\', '>', 0x1C, 0x1C, 0x00, 0x00,
@@ -128,7 +129,7 @@ keymap_t key_map = { 0x69, /* DK iso8859 keymap */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00,
+/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT, F(54), 0xFF, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
#endif
@@ -141,7 +142,7 @@ keymap_t key_map = { 0x69, /* uk iso8859 keymap */
* ---------------------------------------------------------------------------
*/
/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00,
+/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, 0x02, 0x00,
/* sc=02 */ '1', '!', NOP, NOP, '`', '`', NOP, NOP, 0x33, 0x00,
/* sc=03 */ '2', '"', 0x00, 0x00, '@', '@', 0x00, 0x00, 0x00, 0x00,
/* sc=04 */ '3', 0xA3, NOP, NOP, '#', '#', NOP, NOP, 0x33, 0x00,
@@ -223,8 +224,8 @@ keymap_t key_map = { 0x69, /* uk iso8859 keymap */
/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02,
-/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02,
-/* sc=54 */ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00,
+/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, RBT, 0x7F, 0x02, 0x02,
+/* sc=54 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ '\\', '|', 0x1C, 0x1C, '\\', '|', 0x1C, 0x1C, 0x00, 0x00,
/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00,
@@ -243,7 +244,7 @@ keymap_t key_map = { 0x69, /* uk iso8859 keymap */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00,
+/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT, F(54), 0xFF, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
#endif
@@ -256,7 +257,7 @@ keymap_t key_map = { 0x69, /* german iso8859 keymap */
* ---------------------------------------------------------------------------
*/
/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00,
+/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, 0x02, 0x00,
/* sc=02 */ '1', '!', NOP, NOP, '`', '`', NOP, NOP, 0x33, 0x00,
/* sc=03 */ '2', '"', 0x00, 0x00, '@', '@', 0x00, 0x00, 0x00, 0x00,
/* sc=04 */ '3', 0xA7, NOP, NOP, '#', '#', NOP, NOP, 0x33, 0x00,
@@ -338,7 +339,7 @@ keymap_t key_map = { 0x69, /* german iso8859 keymap */
/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02,
-/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02,
+/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, RBT, 0x7F, 0x02, 0x02,
/* sc=54 */ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -358,7 +359,7 @@ keymap_t key_map = { 0x69, /* german iso8859 keymap */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00,
+/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT, F(54), 0xFF, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
#endif
@@ -371,7 +372,7 @@ keymap_t key_map = { 0x69, /* swedish iso8859 keymap */
* ---------------------------------------------------------------------------
*/
/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00,
+/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, 0x02, 0x00,
/* sc=02 */ '1', '!', NOP, NOP, NOP, NOP, NOP, NOP, 0x3F, 0x00,
/* sc=03 */ '2', '"', NOP, NOP, NOP, '@', NOP, NOP, 0x3B, 0x00,
/* sc=04 */ '3', 0xA3, NOP, NOP, NOP, '#', NOP, NOP, 0x3B, 0x00,
@@ -453,7 +454,7 @@ keymap_t key_map = { 0x69, /* swedish iso8859 keymap */
/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02,
-/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02,
+/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, RBT, 0x7F, 0x02, 0x02,
/* sc=54 */ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -473,7 +474,7 @@ keymap_t key_map = { 0x69, /* swedish iso8859 keymap */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00,
+/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT, F(54), 0xFF, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
#endif
@@ -539,7 +540,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=33 */ ',', '<', NOP, NOP, SET8|',', SET8|'<', NOP, NOP, 0x33, 0x00,
/* sc=34 */ '.', '>', NOP, NOP, SET8|'.', SET8|'>', NOP, NOP, 0x33, 0x00,
/* sc=35 */ '/', '?', NOP, NOP, SET8|'/', SET8|'?', NOP, NOP, 0x33, 0x00,
-/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
+/* sc=36 */ ASH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
/* sc=37 */ '*', '*', 0x0A, 0x0A, SET8|'*', SET8|'*', SET8|0x0A, SET8|0x0A, 0x00, 0x00,
/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00,
/* sc=39 */ ' ', ' ', ' ', ' ', SET8|' ', SET8|' ', SET8|' ', SET8|' ', 0x00, 0x00,
@@ -568,7 +569,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=50 */ F(58), '2', '2', '2', SET8|'2', SET8|'2', SET8|'2', SET8|'2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', SET8|'3', SET8|'3', SET8|'3', SET8|'3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', SET8|'0', SET8|'0', SET8|'0', SET8|'0', 0x80, 0x02,
-/* sc=53 */ F(54), '.', 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, RBT, SET8|0x7F, 0x82, 0x02,
+/* sc=53 */ F(54), '.', 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, 0x80, 0x02,
/* sc=54 */ ALK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -577,7 +578,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=59 */ 0x0D, 0x0D, 0x0A, 0x0A, SET8|0x0D, SET8|0x0D, SET8|0x0A, SET8|0x0A, 0x00, 0x00,
/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00,
/* sc=5b */ '/', '/', NOP, NOP, SET8|'/', SET8|'/', NOP, NOP, 0x33, 0x00,
-/* sc=5c */ NEXT, NOP, DBG, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
+/* sc=5c */ CLK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00,
/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00,
/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00,
/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00,
@@ -588,7 +589,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, RBT, SET8|0x7F, 0xC2, 0x00,
+/* sc=67 */ F(54), F(54), 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, 0xC0, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
/* sc=69 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=6a */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -626,8 +627,8 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=09 */ '*', '8', NOP, NOP, SET8|'8', SET8|'*', NOP, NOP, 0x33, 0x00,
/* sc=0a */ '(', '9', NOP, NOP, SET8|'9', SET8|'(', NOP, NOP, 0x33, 0x00,
/* sc=0b */ ')', '0', NOP, NOP, SET8|'0', SET8|')', NOP, NOP, 0x33, 0x00,
-/* sc=0c */ '-', '_', 0x1F, 0x1F, SET8|'-', SET8|'_', SET8|0x1F, SET8|0x1F, 0x00, 0x00,
-/* sc=0d */ '=', '+', NOP, NOP, SET8|'=', SET8|'+', NOP, NOP, 0x33, 0x00,
+/* sc=0c */ '_', '-', 0x1F, 0x1F, SET8|'-', SET8|'_', SET8|0x1F, SET8|0x1F, 0x00, 0x00,
+/* sc=0d */ '+', '=', NOP, NOP, SET8|'=', SET8|'+', NOP, NOP, 0x33, 0x00,
/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, SET8|0x08, SET8|0x08, SET8|0x7F, SET8|0x7F, 0x00, 0x00,
/* sc=0f */ 0x09, F(16), NOP, NOP, SET8|0x09, F(16), NOP, NOP, 0x77, 0x00,
/* sc=10 */ 0xca, 0xea, 0x11, 0x11, SET8|'q', SET8|'Q', SET8|0x11, SET8|0x11, 0x00, 0x01,
@@ -668,7 +669,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=33 */ 0xc2, 0xe2, NOP, NOP, SET8|',', SET8|'<', NOP, NOP, 0x33, 0x01,
/* sc=34 */ 0xc0, 0xe0, NOP, NOP, SET8|'.', SET8|'>', NOP, NOP, 0x33, 0x01,
/* sc=35 */ '/', '?', NOP, NOP, SET8|'/', SET8|'?', NOP, NOP, 0x33, 0x00,
-/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
+/* sc=36 */ ASH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
/* sc=37 */ '*', '*', 0x0A, 0x0A, SET8|'*', SET8|'*', SET8|0x0A, SET8|0x0A, 0x00, 0x00,
/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00,
/* sc=39 */ ' ', ' ', ' ', ' ', SET8|' ', SET8|' ', SET8|' ', SET8|' ', 0x00, 0x00,
@@ -697,7 +698,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=50 */ F(58), '2', '2', '2', SET8|'2', SET8|'2', SET8|'2', SET8|'2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', SET8|'3', SET8|'3', SET8|'3', SET8|'3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', SET8|'0', SET8|'0', SET8|'0', SET8|'0', 0x80, 0x02,
-/* sc=53 */ F(54), '.', 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, RBT, SET8|0x7F, 0x82, 0x02,
+/* sc=53 */ F(54), '.', 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, 0x80, 0x02,
/* sc=54 */ ALK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -706,7 +707,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=59 */ 0x0D, 0x0D, 0x0A, 0x0A, SET8|0x0D, SET8|0x0D, SET8|0x0A, SET8|0x0A, 0x00, 0x00,
/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00,
/* sc=5b */ '/', '/', NOP, NOP, SET8|'/', SET8|'/', NOP, NOP, 0x33, 0x00,
-/* sc=5c */ NEXT, NOP, DBG, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
+/* sc=5c */ CLK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00,
/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00,
/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00,
/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00,
@@ -717,7 +718,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, RBT, SET8|0x7F, 0xC2, 0x00,
+/* sc=67 */ F(54), F(54), 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, 0xC0, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
@@ -731,7 +732,7 @@ keymap_t key_map = { 0x69, /* US iso8859 keymap */
* ---------------------------------------------------------------------------
*/
/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, NOP, NOP, 0x1B, 0x1B, DBG, NOP, 0x33, 0x00,
+/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, 0x02, 0x00,
/* sc=02 */ '1', '!', NOP, NOP, '1', '!', NOP, NOP, 0x33, 0x00,
/* sc=03 */ '2', '@', 0x00, 0x00, '2', '@', 0x00, 0x00, 0x00, 0x00,
/* sc=04 */ '3', '#', NOP, NOP, '3', '#', NOP, NOP, 0x33, 0x00,
@@ -813,7 +814,7 @@ keymap_t key_map = { 0x69, /* US iso8859 keymap */
/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02,
-/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02,
+/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, RBT, 0x7F, 0x02, 0x02,
/* sc=54 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -833,8 +834,8 @@ keymap_t key_map = { 0x69, /* US iso8859 keymap */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT , F(54), 0xFF, 0x00,
-/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
+/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT, F(54), 0xFF, 0x00,
+/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
#endif
diff --git a/sys/i386/isa/syscons.c b/sys/i386/isa/syscons.c
index 6cad5c1..56ef759 100644
--- a/sys/i386/isa/syscons.c
+++ b/sys/i386/isa/syscons.c
@@ -1,4 +1,5 @@
/*-
+ * Copyright (c) 1992-1994 Søren Schmidt
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
@@ -33,15 +34,19 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)pccons.c 5.11 (Berkeley) 5/21/91
- * from: @(#)syscons.c 1.1 931021
- * $Id: syscons.c,v 1.25 1994/01/14 16:24:18 davidg Exp $
+ * from:@(#)syscons.c 1.3 940129
+ * $Id: syscons.c,v 1.26 1994/01/18 05:33:34 nate Exp $
*
- * Heavily modified by Sxren Schmidt (sos@login.dkuug.dk) to provide:
- *
- * virtual consoles, SYSV ioctl's, ANSI emulation ....
*/
+/* #define FADE_SAVER */
+/* #define BLANK_SAVER */
+#define STAR_SAVER
+
+#if !defined(__FreeBSD__)
+#define FAT_CURSOR
+#endif
+
#include "param.h"
#include "conf.h"
#include "ioctl.h"
@@ -55,7 +60,6 @@
#include "syslog.h"
#include "errno.h"
#include "malloc.h"
-#include "i386/isa/icu.h"
#include "i386/isa/isa.h"
#include "i386/isa/isa_device.h"
#include "i386/isa/timerreg.h"
@@ -64,20 +68,13 @@
#include "machine/psl.h"
#include "machine/frame.h"
#include "machine/pc/display.h"
-#include "sc.h"
#include "iso8859.font"
#include "kbdtables.h"
-
-#if !defined(NetBSD)
-#include "ddb.h"
-#if NDDB > 0
-#define DDB 1
-#endif
-#endif
+#include "sc.h"
#if NSC > 0
-#ifndef NCONS
+#if !defined(NCONS)
#define NCONS 12
#endif
@@ -89,12 +86,7 @@
#define SWITCH_WAIT_REL 0x00040
#define SWITCH_WAIT_ACQ 0x00080
-/* virtual video memory addresses */
-#if !defined(NetBSD)
-#define MONO_BUF (KERNBASE+0xB0000)
-#define CGA_BUF (KERNBASE+0xB8000)
-#define VGA_BUF (KERNBASE+0xA0000)
-#endif
+/* video hardware memory addresses */
#define VIDEOMEM 0x000A0000
/* misc defines */
@@ -103,7 +95,7 @@
#define TEXT80x50 2
#define COL 80
#define ROW 25
-#define BELL_DURATION 10
+#define BELL_DURATION 5
#define BELL_PITCH 800
#define TIMER_FREQ 1193182 /* should be in isa.h */
#define PCBURST 128
@@ -121,27 +113,35 @@
#define GDCIDX IO_VGA+0x0E /* graph data controller idx */
#define GDCREG IO_VGA+0x0F /* graph data controller data */
+/* special characters */
+#define cntlc 0x03
+#define cntld 0x04
+#define bs 0x08
+#define lf 0x0a
+#define cr 0x0d
+#define del 0x7f
+
typedef struct term_stat {
int esc; /* processing escape sequence */
- int n_par; /* # of parameters to ESC */
- int last_par; /* last parameter # */
- int par[MAX_ESC_PAR]; /* contains ESC parameters */
- int attr; /* current attributes */
+ int num_param; /* # of parameters to ESC */
+ int last_param; /* last parameter # */
+ int param[MAX_ESC_PAR]; /* contains ESC parameters */
+ int cur_attr; /* current attributes */
int std_attr; /* normal attributes */
int rev_attr; /* reverse attributes */
} term_stat;
typedef struct scr_stat {
u_short *crt_base; /* address of screen memory */
- u_short *scr; /* buffer when off screen */
+ u_short *scr_buf; /* buffer when off screen */
u_short *crtat; /* cursor address */
- int posx; /* current X position */
- int posy; /* current Y position */
- int max_posx; /* X size */
- int max_posy; /* X size */
+ int xpos; /* current X position */
+ int ypos; /* current Y position */
+ int xsize; /* X size */
+ int ysize; /* Y size */
term_stat term; /* terminal emulation stuff */
char cursor_start; /* cursor start line # */
- char cursor_end; /* cursor start end # */
+ char cursor_end; /* cursor end line # */
u_char border; /* border color */
u_short bell_duration;
u_short bell_pitch;
@@ -183,35 +183,15 @@ static const u_int n_fkey_tab = sizeof(fkey_tab) / sizeof(*fkey_tab);
static int cur_cursor_pos = -1;
static char in_putc = 0;
static char polling = 0;
-static int nx_scr;
+static int delayed_next_scr;
static char saved_console = -1; /* saved console number */
static long scrn_blank_time = 0; /* screen saver timout value */
static int scrn_blanked = 0; /* screen saver active flag */
static long scrn_time_stamp;
static u_char scr_map[256];
-static struct tty *cur_tty = NULL;
-
-#if defined(NetBSD)
-extern u_short *Crtat;
-struct tty *pc_tty[NCONS];
-int ttrstrt();
-#else
-u_short *Crtat = (u_short *)MONO_BUF;
-struct tty pccons[NCONS];
-#define timeout_t caddr_t
-#endif
-
extern int hz;
extern struct timeval time;
-/* special characters */
-#define cntlc 0x03
-#define cntld 0x04
-#define bs 0x08
-#define lf 0x0a
-#define cr 0x0d
-#define del 0x7f
-
/* function prototypes */
int pcprobe(struct isa_device *dev);
int pcattach(struct isa_device *dev);
@@ -223,36 +203,38 @@ int pcparam(struct tty *tp, struct termios *t);
int pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p);
void pcxint(dev_t dev);
void pcstart(struct tty *tp);
-int pccnprobe(struct consdev *cp);
-int pccninit(struct consdev *cp);
+void pccnprobe(struct consdev *cp);
+void pccninit(struct consdev *cp);
void pccnputc(dev_t dev, char c);
int pccngetc(dev_t dev);
-void scintr(dev_t dev, int irq, int cpl);
+void scintr(int unit);
int pcmmap(dev_t dev, int offset, int nprot);
u_int sgetc(int noblock);
int getchar(void);
-static void reset_cpu(void);
+static void scinit(void);
+static void scput(u_char c);
+static u_int scgetc(int noblock);
static void scrn_saver(int test);
static struct tty *get_tty_ptr(dev_t dev);
static scr_stat *get_scr_stat(dev_t dev);
-static int get_scr_num(scr_stat *scp);
+static int get_scr_num();
static void cursor_shape(int start, int end);
static void get_cursor_shape(int *start, int *end);
-static int cursor_pos(void);
+static void cursor_pos(int force);
static void clear_screen(scr_stat *scp);
-static switch_scr(u_int next_scr);
+static int switch_scr(u_int next_scr);
static void exchange_scr(void);
static void move_crsr(scr_stat *scp, int x, int y);
static void move_up(u_short *s, u_short *d, u_int len);
static void move_down(u_short *s, u_short *d, u_int len);
static void scan_esc(scr_stat *scp, u_char c);
static void ansi_put(scr_stat *scp, u_char c);
-static void scinit(void);
-static void sput(u_char c);
static u_char *get_fstr(u_int c, u_int *len);
static void update_leds(int which);
static void kbd_wait(void);
static void kbd_cmd(u_char command);
+static void kbd_cmd2(u_char command, u_char arg);
+static int kbd_reply(void);
static void set_mode(scr_stat *scp);
static void set_border(int color);
static void load_font(int segment, int size, char* font);
@@ -260,38 +242,68 @@ static void save_palette(void);
static void load_palette(void);
static void change_winsize(struct tty *tp, int x, int y);
+
+/* OS specific stuff */
+
+#if defined(NetBSD)
+#define VIRTUAL_TTY(x) pc_tty[x] ? (pc_tty[x]) : (pc_tty[x] = ttymalloc())
+#define CONSOLE_TTY pc_tty[NCONS] ? (pc_tty[NCONS]) : (pc_tty[NCONS] = ttymalloc())
+#define frametype struct trapframe
+#define eflags tf_eflags
+extern u_short *Crtat;
+struct tty *pc_tty[NCONS+1];
+int ttrstrt();
+#endif
+
+#if defined(__FreeBSD__)
+#define frametype struct trapframe
+#define eflags tf_eflags
+#define timeout_t timeout_func_t
+#define MONO_BUF (KERNBASE+0xB0000)
+#define CGA_BUF (KERNBASE+0xB8000)
+#endif
+
+#if defined(__386BSD__) && !defined(__FreeBSD__)
+#define frametype struct syscframe
+#define eflags sf_eflags
+#define timeout_t caddr_t
+#define MONO_BUF (0xFE0B0000)
+#define CGA_BUF (0xFE0B8000)
+#endif
+
+#if defined(__386BSD__) || defined(__FreeBSD__)
+#define VIRTUAL_TTY(x) &pccons[x]
+#define CONSOLE_TTY &pccons[NCONS]
+u_short *Crtat = (u_short *)MONO_BUF;
+struct tty pccons[NCONS+1];
+void consinit(void) {scinit();}
+#include "ddb.h"
+#if NDDB > 0
+#define DDB 1
+#endif
+#endif
+
+
struct isa_driver scdriver = {
pcprobe, pcattach, "sc",
};
-#if !defined(NetBSD)
-void consinit(void)
-{
- scinit();
-}
-#endif
int pcprobe(struct isa_device *dev)
{
- u_char c;
- int again = 0;
-
/* Enable interrupts and keyboard controller */
kbd_wait();
outb(KB_STAT, KB_WRITE);
kbd_cmd(0x4D);
/* Start keyboard stuff RESET */
- kbd_cmd(KB_RESET);
- while ((c=inb(KB_DATA)) != KB_ACK) {
- if ((c == 0xFE) || (c == 0xFF)) {
- if (!again)
- printf("KEYBOARD disconnected: RECONNECT \n");
- kbd_cmd(KB_RESET);
- again = 1;
- }
+ for (;;) {
+ kbd_cmd(KB_RESET);
+ if (kbd_reply() == KB_ACK && /* command accepted */
+ kbd_reply() == 0xaa) /* self test passed */
+ break;
+ printf("Keyboard reset failed\n");
}
- kbd_wait();
return (IO_KBDSIZE);
}
@@ -317,7 +329,7 @@ int pcattach(struct isa_device *dev)
printf(" <%d virtual consoles>\n", NCONS);
else
printf("\n");
-#ifdef FAT_CURSOR
+#if defined(FAT_CURSOR)
start = 0;
end = 18;
if (crtc_vga) {
@@ -333,17 +345,17 @@ int pcattach(struct isa_device *dev)
current_default = &user_default;
for (i = 0; i < NCONS; i++) {
scp = &console[i];
- scp->scr = (u_short *)malloc(COL * ROW * 2, M_DEVBUF, M_NOWAIT);
+ scp->scr_buf = (u_short *)malloc(COL * ROW * 2, M_DEVBUF, M_NOWAIT);
scp->mode = TEXT80x25;
scp->term.esc = 0;
scp->term.std_attr = current_default->std_attr;
scp->term.rev_attr = current_default->rev_attr;
- scp->term.attr = scp->term.std_attr;
+ scp->term.cur_attr = scp->term.std_attr;
scp->border = BG_BLACK;
scp->cursor_start = start;
scp->cursor_end = end;
- scp->max_posx = COL;
- scp->max_posy = ROW;
+ scp->xsize = COL;
+ scp->ysize = ROW;
scp->bell_pitch = BELL_PITCH;
scp->bell_duration = BELL_DURATION;
scp->status = 0;
@@ -351,18 +363,17 @@ int pcattach(struct isa_device *dev)
scp->proc = NULL;
scp->smode.mode = VT_AUTO;
if (i > 0) {
- scp->crt_base = scp->crtat = scp->scr;
- fillw(scp->term.attr|scr_map[0x20],
- scp->scr, COL*ROW);
+ scp->crt_base = scp->crtat = scp->scr_buf;
+ fillw(scp->term.cur_attr|scr_map[0x20], scp->scr_buf, COL*ROW);
}
}
/* get cursor going */
-#ifdef FAT_CURSOR
+#if defined(FAT_CURSOR)
cursor_shape(console[0].cursor_start,
console[0].cursor_end);
#endif
- cursor_pos();
- return (1);
+ cursor_pos(1);
+ return 0;
}
@@ -370,15 +381,11 @@ static struct tty *get_tty_ptr(dev_t dev)
{
int unit = minor(dev);
- if (unit >= NCONS)
+ if (unit > NCONS)
return(NULL);
-#if defined(NetBSD)
- if (!pc_tty[unit])
- pc_tty[unit] = ttymalloc();
- return(pc_tty[unit]);
-#else
- return(&pccons[unit]);
-#endif
+ if (unit == NCONS)
+ return(CONSOLE_TTY);
+ return(VIRTUAL_TTY(unit));
}
@@ -386,33 +393,33 @@ static scr_stat *get_scr_stat(dev_t dev)
{
int unit = minor(dev);
- if (unit >= NCONS)
+ if (unit > NCONS)
return(NULL);
+ if (unit == NCONS)
+ return(&console[0]);
return(&console[unit]);
}
-static int get_scr_num(scr_stat *scp) /* allways call with legal scp !! */
+static int get_scr_num()
{
int i = 0;
while ((i < NCONS) && (cur_console != &console[i])) i++;
- return i;
+ return i < NCONS ? i : 0;
}
-int
-pcopen(dev_t dev, int flag, int mode, struct proc *p)
+int pcopen(dev_t dev, int flag, int mode, struct proc *p)
{
struct tty *tp = get_tty_ptr(dev);
if (!tp)
return(ENXIO);
- if (!cur_tty)
- cur_tty = tp;
- tp->t_oproc = (void*)pcstart;
+
+ tp->t_oproc = pcstart;
tp->t_param = pcparam;
tp->t_dev = dev;
- if ((tp->t_state & TS_ISOPEN) == 0) {
+ if (!(tp->t_state & TS_ISOPEN)) {
tp->t_state |= TS_WOPEN;
ttychars(tp);
tp->t_iflag = TTYDEF_IFLAG;
@@ -425,30 +432,37 @@ pcopen(dev_t dev, int flag, int mode, struct proc *p)
} else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0)
return(EBUSY);
tp->t_state |= TS_CARR_ON;
+ tp->t_cflag |= CLOCAL;
+#if defined(__FreeBSD__)
return((*linesw[tp->t_line].l_open)(dev, tp, 0));
+#else
+ return((*linesw[tp->t_line].l_open)(dev, tp));
+#endif
}
-int
-pcclose(dev_t dev, int flag, int mode, struct proc *p)
+int pcclose(dev_t dev, int flag, int mode, struct proc *p)
{
struct tty *tp = get_tty_ptr(dev);
struct scr_stat *scp;
if (!tp)
return(ENXIO);
- scp = get_scr_stat(tp->t_dev);
- scp->pid = 0;
- scp->proc = NULL;
- scp->smode.mode = VT_AUTO;
+ if (minor(dev) < NCONS) {
+ scp = get_scr_stat(tp->t_dev);
+ if (scp->status & SWITCH_WAIT_ACQ)
+ wakeup((caddr_t)&scp->smode);
+ scp->pid = 0;
+ scp->proc = NULL;
+ scp->smode.mode = VT_AUTO;
+ }
(*linesw[tp->t_line].l_close)(tp, flag);
ttyclose(tp);
return(0);
}
-int
-pcread(dev_t dev, struct uio *uio, int flag)
+int pcread(dev_t dev, struct uio *uio, int flag)
{
struct tty *tp = get_tty_ptr(dev);
@@ -458,8 +472,7 @@ pcread(dev_t dev, struct uio *uio, int flag)
}
-int
-pcwrite(dev_t dev, struct uio *uio, int flag)
+int pcwrite(dev_t dev, struct uio *uio, int flag)
{
struct tty *tp = get_tty_ptr(dev);
@@ -473,9 +486,9 @@ pcwrite(dev_t dev, struct uio *uio, int flag)
* Got a console interrupt, keyboard action !
* Catch the character, and see who it goes to.
*/
-void
-scintr(dev_t dev, int irq, int cpl)
+void scintr(int unit)
{
+ static struct tty *cur_tty;
int c, len;
u_char *cp;
@@ -484,10 +497,13 @@ scintr(dev_t dev, int irq, int cpl)
if (scrn_blanked)
scrn_saver(0);
- c = sgetc(1);
- if (!cur_tty)
- return;
- if ((cur_tty->t_state & TS_ISOPEN) == 0 || polling)
+ c = scgetc(1);
+
+ cur_tty = VIRTUAL_TTY(get_scr_num());
+ if (!(cur_tty->t_state & TS_ISOPEN))
+ cur_tty = CONSOLE_TTY;
+
+ if (!(cur_tty->t_state & TS_ISOPEN) || polling)
return;
switch (c & 0xff00) {
@@ -495,7 +511,7 @@ scintr(dev_t dev, int irq, int cpl)
(*linesw[cur_tty->t_line].l_rint)(c & 0xFF, cur_tty);
break;
case NOKEY: /* nothing there */
- return;
+ break;
case FKEY: /* function key, return string */
if (cp = get_fstr((u_int)c, (u_int *)&len)) {
while (len-- > 0)
@@ -514,8 +530,7 @@ scintr(dev_t dev, int irq, int cpl)
/*
* Set line parameters
*/
-int
-pcparam(struct tty *tp, struct termios *t)
+int pcparam(struct tty *tp, struct termios *t)
{
int cflag = t->c_cflag;
@@ -523,14 +538,11 @@ pcparam(struct tty *tp, struct termios *t)
tp->t_ispeed = t->c_ispeed;
tp->t_ospeed = t->c_ospeed;
tp->t_cflag = cflag;
- return(0);
+ return 0;
}
-#define frametype struct trapframe
-#define eflags tf_eflags
-int
-pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
+int pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
{
int i, error;
struct tty *tp;
@@ -552,44 +564,44 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
if (!crtc_vga)
return ENXIO;
scp->mode = TEXT80x25;
- scp->max_posy = 25;
- free(scp->scr, M_DEVBUF);
- scp->scr = (u_short *)malloc(scp->max_posx*scp->max_posy*2,
+ scp->ysize = 25;
+ free(scp->scr_buf, M_DEVBUF);
+ scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*2,
M_DEVBUF, M_NOWAIT);
if (scp != cur_console)
- scp->crt_base = scp->scr;
+ scp->crt_base = scp->scr_buf;
set_mode(scp);
clear_screen(scp);
- change_winsize(tp, scp->max_posx, scp->max_posy);
+ change_winsize(tp, scp->xsize, scp->ysize);
return 0;
case CONS_80x50TEXT: /* set 80x50 text mode */
if (!crtc_vga)
return ENXIO;
scp->mode = TEXT80x50;
- scp->max_posy = 50;
- free(scp->scr, M_DEVBUF);
- scp->scr = (u_short *)malloc(scp->max_posx*scp->max_posy*2,
+ scp->ysize = 50;
+ free(scp->scr_buf, M_DEVBUF);
+ scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*2,
M_DEVBUF, M_NOWAIT);
if (scp != cur_console)
- scp->crt_base = scp->scr;
+ scp->crt_base = scp->scr_buf;
set_mode(scp);
clear_screen(scp);
- change_winsize(tp, scp->max_posx, scp->max_posy);
+ change_winsize(tp, scp->xsize, scp->ysize);
return 0;
case CONS_GETVERS: /* get version number */
- *(int*)data = 0x100; /* version 1.0 */
+ *(int*)data = 0x103; /* version 1.3 */
return 0;
case CONS_GETINFO: /* get current (virtual) console info */
if (*data == sizeof(struct vid_info)) {
vid_info_t *ptr = (vid_info_t*)data;
- ptr->m_num = get_scr_num(scp);
- ptr->mv_col = scp->posx;
- ptr->mv_row = scp->posy;
- ptr->mv_csz = scp->max_posx;
- ptr->mv_rsz = scp->max_posy;
+ ptr->m_num = get_scr_num();
+ ptr->mv_col = scp->xpos;
+ ptr->mv_row = scp->ypos;
+ ptr->mv_csz = scp->xsize;
+ ptr->mv_rsz = scp->ysize;
ptr->mv_norm.fore = (scp->term.std_attr & 0x0f00)>>8;
ptr->mv_norm.back = (scp->term.std_attr & 0xf000)>>12;
ptr->mv_rev.fore = (scp->term.rev_attr & 0x0f00)>>8;
@@ -653,17 +665,14 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
/* NOT REACHED */
case VT_OPENQRY: /* return free virtual console */
- for (i = 0; i < NCONS; i++)
-#if defined(NetBSD)
- if (!(pc_tty[i]->t_state & TS_ISOPEN)) {
-#else
- if (!(pccons[i].t_state & TS_ISOPEN)) {
-#endif
+ for (i = 0; i < NCONS; i++) {
+ tp = VIRTUAL_TTY(i);
+ if (!(tp->t_state & TS_ISOPEN)) {
*data = i + 1;
return 0;
}
+ }
return EINVAL;
- /* NOT REACHED */
case VT_ACTIVATE: /* switch to screen *data */
return switch_scr((*data) - 1);
@@ -681,12 +690,12 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
}
else
while ((error=tsleep(
- (caddr_t)&console[*data-1].smode,
+ (caddr_t)&console[*(data-1)].smode,
PZERO|PCATCH, "waitvt", 0)) == ERESTART) ;
return error;
case VT_GETACTIVE:
- *data = get_scr_num(scp)+1;
+ *data = get_scr_num()+1;
return 0;
case KDENABIO: /* allow io operations */
@@ -753,12 +762,10 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
return 0;
case KDSETRAD: /* set keyboard repeat & delay rates */
- if (*(u_char*)data < 0x80) {
- kbd_cmd(KB_SETRAD);
- kbd_cmd(*data & 0x7f);
- return 0;
- }
- return EINVAL;
+ if (*data & 0x80)
+ return EINVAL;
+ kbd_cmd2(KB_SETRAD, *data);
+ return 0;
case KDSKBMODE: /* set keyboard mode */
switch (*data) {
@@ -767,6 +774,8 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
return 0;
case K_XLATE: /* switch to XLT ascii mode */
+ if (scp == cur_console && scp->status == KBD_RAW_MODE)
+ shfts = ctls = alts = agrs = metas = 0;
scp->status &= ~KBD_RAW_MODE;
return 0;
default:
@@ -902,7 +911,7 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
case CONSOLE_X_MODE_ON: /* just to be compatible */
if (saved_console < 0) {
- saved_console = get_scr_num(cur_console);
+ saved_console = get_scr_num();
switch_scr(minor(dev));
fp = (frametype *)p->p_regs;
fp->eflags |= PSL_IOPL;
@@ -956,31 +965,21 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
}
-void
-pcxint(dev_t dev)
+void pcxint(dev_t dev)
{
- int unit = minor(dev);
+ struct tty *tp = get_tty_ptr(dev);
-#if defined(NetBSD)
- if (!pc_tty[unit])
+ if (!tp)
return;
- pc_tty[unit]->t_state &= ~TS_BUSY;
- if (pc_tty[unit]->t_line)
- (*linesw[pc_tty[unit]->t_line].l_start)(pc_tty[unit]);
+ tp->t_state &= ~TS_BUSY;
+ if (tp->t_line)
+ (*linesw[tp->t_line].l_start)(tp);
else
- pcstart(pc_tty[unit]);
-#else
- pccons[unit].t_state &= ~TS_BUSY;
- if (pccons[unit].t_line)
- (*linesw[pccons[unit].t_line].l_start)(&pccons[unit]);
- else
- pcstart(&pccons[unit]);
-#endif
+ pcstart(tp);
}
-void
-pcstart(struct tty *tp)
+void pcstart(struct tty *tp)
{
#if defined(NetBSD)
struct clist *rbp;
@@ -1011,13 +1010,16 @@ pcstart(struct tty *tp)
}
selwakeup(&tp->t_wsel);
}
-
}
splx(s);
-#else
+
+#else /* __FreeBSD__ & __386BSD__ */
+
int c, s;
scr_stat *scp = get_scr_stat(tp->t_dev);
+ if (scp->status & SLKED)
+ return;
s = spltty();
if (!(tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)))
for (;;) {
@@ -1049,73 +1051,91 @@ pcstart(struct tty *tp)
}
-int
-pccnprobe(struct consdev *cp)
+void pccnprobe(struct consdev *cp)
{
int maj;
/* locate the major number */
for (maj = 0; maj < nchrdev; maj++)
- if ((void*) cdevsw[maj].d_open == (void*) pcopen)
+ if ((void*)cdevsw[maj].d_open == (void*)pcopen)
break;
/* initialize required fields */
- cp->cn_dev = makedev(maj, 0);
-#if !defined(NetBSD)
- cp->cn_tp = &pccons[0];
-#endif
+ cp->cn_dev = makedev(maj, NCONS);
cp->cn_pri = CN_INTERNAL;
- return (1);
+#if defined(__FreeBSD__) || defined(__386BSD__)
+ cp->cn_tp = CONSOLE_TTY;
+#endif
}
-int
-pccninit(struct consdev *cp)
+void pccninit(struct consdev *cp)
{
scinit();
- return (1);
}
-void
-pccnputc(dev_t dev, char c)
+void pccnputc(dev_t dev, char c)
{
- int pos;
-
- if (cur_console->status & UNKNOWN_MODE)
- return;
if (c == '\n')
- sput('\r');
- sput(c);
- pos = cur_console->crtat - cur_console->crt_base;
- if (pos != cur_cursor_pos) {
- cur_cursor_pos = pos;
- outb(crtc_addr,14);
- outb(crtc_addr+1,pos >> 8);
- outb(crtc_addr,15);
- outb(crtc_addr+1,pos&0xff);
+ scput('\r');
+ scput(c);
+ if (cur_console == &console[0]) {
+ int pos = cur_console->crtat - cur_console->crt_base;
+ if (pos != cur_cursor_pos) {
+ cur_cursor_pos = pos;
+ outb(crtc_addr,14);
+ outb(crtc_addr+1,pos >> 8);
+ outb(crtc_addr,15);
+ outb(crtc_addr+1,pos&0xff);
+ }
}
}
-int
-pccngetc(dev_t dev)
+int pccngetc(dev_t dev)
{
- int c, s;
-
- s = spltty(); /* block scintr while we poll */
- c = sgetc(0);
+ int s = spltty(); /* block scintr while we poll */
+ int c = scgetc(0);
splx(s);
if (c == '\r') c = '\n';
return(c);
}
-#if !defined(STAR_SAVER) && !defined(SNAKE_SAVER)
-
+#if defined(FADE_SAVER)
static void scrn_saver(int test)
{
- u_char val;
+ static int count = 0;
+ int i;
+
+ if (test) {
+ scrn_blanked = 1;
+ if (count < 64) {
+ outb(PIXMASK, 0xFF); /* no pixelmask */
+ outb(PALWADR, 0x00);
+ outb(PALDATA, 0);
+ outb(PALDATA, 0);
+ outb(PALDATA, 0);
+ for (i = 3; i < 768; i++) {
+ if (palette[i] - count > 15)
+ outb(PALDATA, palette[i]-count);
+ else
+ outb(PALDATA, 15);
+ }
+ inb(crtc_addr+6); /* reset flip/flop */
+ outb(ATC, 0x20); /* enable palette */
+ count++;
+ }
+ }
+ else {
+ count = scrn_blanked = 0;
+ load_palette();
+ }
+}
+#endif
+#if defined(BLANK_SAVER)
+ u_char val;
if (test) {
scrn_blanked = 1;
outb(TSIDX, 0x01); val = inb(TSREG);
@@ -1126,18 +1146,16 @@ static void scrn_saver(int test)
outb(TSIDX, 0x01); val = inb(TSREG);
outb(TSIDX, 0x01); outb(TSREG, val & 0xDF);
}
-}
#endif
-#if defined(STAR_SAVER) || defined(SNAKE_SAVER)
+#if defined(STAR_SAVER)
static u_long rand_next = 1;
static int rand()
{
return ((rand_next = rand_next * 1103515245 + 12345) & 0x7FFFFFFF);
}
-#endif
-#if defined(STAR_SAVER) && !defined(SNAKE_SAVER)
+
/*
* Alternate saver that got its inspiration from a well known utility
* package for an unfamous OS.
@@ -1156,12 +1174,12 @@ static void scrn_saver(int test)
if (test) {
if (!scrn_blanked) {
- bcopy(Crtat, scp->scr,
- scp->max_posx * scp->max_posy * 2);
- fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20],
- Crtat, scp->max_posx * scp->max_posy);
+ bcopy(Crtat, scp->scr_buf,
+ scp->xsize * scp->ysize * 2);
+ fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20], Crtat,
+ scp->xsize * scp->ysize);
set_border(0);
- i = scp->max_posy * scp->max_posx + 5;
+ i = scp->ysize * scp->xsize + 5;
outb(crtc_addr, 14);
outb(crtc_addr+1, i >> 8);
outb(crtc_addr, 15);
@@ -1169,7 +1187,7 @@ static void scrn_saver(int test)
scrn_blanked = 1;
for(i=0; i<NUM_STARS; i++) {
stars[i][0] =
- rand() % (scp->max_posx*scp->max_posy);
+ rand() % (scp->xsize*scp->ysize);
stars[i][1] = 0;
}
}
@@ -1178,13 +1196,13 @@ static void scrn_saver(int test)
scr_map[pattern[stars[cell][1]]] |
colors[rand()%sizeof(colors)] << 8;
if ((stars[cell][1]+=(rand()%4)) >= sizeof(pattern)-1) {
- stars[cell][0] = rand() % (scp->max_posx*scp->max_posy);
+ stars[cell][0] = rand() % (scp->xsize*scp->ysize);
stars[cell][1] = 0;
}
}
else {
if (scrn_blanked) {
- bcopy(scp->scr, Crtat, scp->max_posx*scp->max_posy*2);
+ bcopy(scp->scr_buf, Crtat, scp->xsize*scp->ysize*2);
cur_cursor_pos = -1;
set_border(scp->border);
scrn_blanked = 0;
@@ -1192,70 +1210,7 @@ static void scrn_saver(int test)
}
}
#endif
-#if defined(SNAKE_SAVER) && !defined(STAR_SAVER)
-/*
- * alternative screen saver for cards that do not like blanking
- */
-static void scrn_saver(int test)
-{
- const char saves[] = {"FreeBSD"};
- static u_char *savs[sizeof(saves)-1];
- static int dirx, diry;
- int f;
- scr_stat *scp = cur_console;
-
- if (test) {
- if (!scrn_blanked) {
- bcopy(Crtat, scp->scr,
- scp->max_posx * scp->max_posy * 2);
- fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20],
- Crtat, scp->max_posx * scp->max_posy);
- set_border(0);
- dirx = (scp->posx ? 1 : -1);
- diry = (scp->posy ?
- scp->max_posx : -scp->max_posx);
- for (f=0; f< sizeof(saves)-1; f++)
- savs[f] = (u_char *)Crtat + 2 *
- (scp->posx+scp->posy*scp->max_posx);
- *(savs[0]) = scr_map[*saves];
- f = scp->max_posy * scp->max_posx + 5;
- outb(crtc_addr, 14);
- outb(crtc_addr+1, f >> 8);
- outb(crtc_addr, 15);
- outb(crtc_addr+1, f & 0xff);
- scrn_blanked = 1;
- }
- if (scrn_blanked++ < 4)
- return;
- scrn_blanked = 1;
- *(savs[sizeof(saves)-2]) = scr_map[0x20];
- for (f=sizeof(saves)-2; f > 0; f--)
- savs[f] = savs[f-1];
- f = (savs[0] - (u_char *)Crtat) / 2;
- if ((f % scp->max_posx) == 0 ||
- (f % scp->max_posx) == scp->max_posx - 1 ||
- (rand() % 50) == 0)
- dirx = -dirx;
- if ((f / scp->max_posx) == 0 ||
- (f / scp->max_posx) == scp->max_posy - 1 ||
- (rand() % 20) == 0)
- diry = -diry;
- savs[0] += 2*dirx + 2*diry;
- for (f=sizeof(saves)-2; f>=0; f--)
- *(savs[f]) = scr_map[saves[f]];
- }
- else {
- if (scrn_blanked) {
- bcopy(scp->scr, Crtat,
- scp->max_posx * scp->max_posy * 2);
- cur_cursor_pos = -1;
- set_border(scp->border);
- scrn_blanked = 0;
- }
- }
-}
-#endif
static void cursor_shape(int start, int end)
{
@@ -1266,6 +1221,7 @@ static void cursor_shape(int start, int end)
}
+#if !defined(FAT_CURSOR)
static void get_cursor_shape(int *start, int *end)
{
outb(crtc_addr, 10);
@@ -1273,50 +1229,61 @@ static void get_cursor_shape(int *start, int *end)
outb(crtc_addr, 11);
*end = inb(crtc_addr+1) & 0x1F;
}
+#endif
-int cursor_pos(void)
+static void cursor_pos(int force)
{
int pos;
if (cur_console->status & UNKNOWN_MODE)
- return (0);
+ return;
if (scrn_blank_time && (time.tv_sec > scrn_time_stamp+scrn_blank_time))
scrn_saver(1);
pos = cur_console->crtat - cur_console->crt_base;
- if (!scrn_blanked && pos != cur_cursor_pos) {
+ if (force || (!scrn_blanked && pos != cur_cursor_pos)) {
cur_cursor_pos = pos;
outb(crtc_addr, 14);
outb(crtc_addr+1, pos>>8);
outb(crtc_addr, 15);
outb(crtc_addr+1, pos&0xff);
}
- timeout((timeout_func_t)cursor_pos, 0, hz/20);
- return (0);
+ timeout((timeout_t)cursor_pos, 0, hz/20);
}
static void clear_screen(scr_stat *scp)
{
move_crsr(scp, 0, 0);
- fillw(scp->term.attr | scr_map[0x20], scp->crt_base,
- scp->max_posx * scp->max_posy);
+ fillw(scp->term.cur_attr | scr_map[0x20], scp->crt_base,
+ scp->xsize * scp->ysize);
}
static int switch_scr(u_int next_scr)
{
- if (in_putc) { /* don't switch if in putc */
- nx_scr = next_scr+1;
+ if (in_putc) { /* delay switch if in putc */
+ delayed_next_scr = next_scr+1;
return 0;
}
if (switch_in_progress &&
(cur_console->proc != pfind(cur_console->pid)))
switch_in_progress = 0;
- if (next_scr >= NCONS || switch_in_progress) {
+
+ if (next_scr >= NCONS || switch_in_progress) {
sysbeep(BELL_PITCH, BELL_DURATION);
return EINVAL;
}
+
+ /* is the wanted virtual console open ? */
+ if (next_scr) {
+ struct tty *tp = VIRTUAL_TTY(next_scr);
+ if (!(tp->t_state & TS_ISOPEN)) {
+ sysbeep(BELL_PITCH, BELL_DURATION);
+ return EINVAL;
+ }
+ }
+
switch_in_progress = 1;
old_scp = cur_console;
new_scp = &console[next_scr];
@@ -1352,33 +1319,30 @@ static int switch_scr(u_int next_scr)
static void exchange_scr(void)
{
- bcopy(Crtat, old_scp->scr, old_scp->max_posx * old_scp->max_posy * 2);
- old_scp->crt_base = old_scp->scr;
- move_crsr(old_scp, old_scp->posx, old_scp->posy);
+ struct tty *tp;
+
+ bcopy(Crtat, old_scp->scr_buf, old_scp->xsize * old_scp->ysize * 2);
+ old_scp->crt_base = old_scp->scr_buf;
+ move_crsr(old_scp, old_scp->xpos, old_scp->ypos);
cur_console = new_scp;
-#if defined(NetBSD)
- cur_tty = pc_tty[get_scr_num(new_scp)];
-#else
- cur_tty = &pccons[get_scr_num(new_scp)];
-#endif
- if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE)
- shfts = ctls = alts = agrs = metas = 0;
- update_leds(new_scp->status & LED_MASK);
set_mode(new_scp);
new_scp->crt_base = Crtat;
- move_crsr(new_scp, new_scp->posx, new_scp->posy);
- bcopy(new_scp->scr, Crtat, new_scp->max_posx * new_scp->max_posy * 2);
- nx_scr = 0;
+ move_crsr(new_scp, new_scp->xpos, new_scp->ypos);
+ bcopy(new_scp->scr_buf, Crtat, new_scp->xsize * new_scp->ysize * 2);
+ update_leds(new_scp->status & LED_MASK);
+ if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE)
+ shfts = ctls = alts = agrs = metas = 0;
+ delayed_next_scr = 0;
}
static void move_crsr(scr_stat *scp, int x, int y)
{
- if (x < 0 || y < 0 || x >= scp->max_posx || y >= scp->max_posy)
+ if (x < 0 || y < 0 || x >= scp->xsize || y >= scp->ysize)
return;
- scp->posx = x;
- scp->posy = y;
- scp->crtat = scp->crt_base + scp->posy * scp->max_posx + scp->posx;
+ scp->xpos = x;
+ scp->ypos = y;
+ scp->crtat = scp->crt_base + scp->ypos * scp->xsize + scp->xpos;
}
@@ -1410,21 +1374,21 @@ static void scan_esc(scr_stat *scp, u_char c)
case '[': /* Start ESC [ sequence */
scp->term.esc = 2;
- scp->term.last_par = -1;
- for (i = scp->term.n_par; i < MAX_ESC_PAR; i++)
- scp->term.par[i] = 1;
- scp->term.n_par = 0;
+ scp->term.last_param = -1;
+ for (i = scp->term.num_param; i < MAX_ESC_PAR; i++)
+ scp->term.param[i] = 1;
+ scp->term.num_param = 0;
return;
case 'M': /* Move cursor up 1 line, scroll if at top */
- if (scp->posy > 0)
- move_crsr(scp, scp->posx, scp->posy - 1);
+ if (scp->ypos > 0)
+ move_crsr(scp, scp->xpos, scp->ypos - 1);
else {
move_up(scp->crt_base,
- scp->crt_base + scp->max_posx,
- (scp->max_posy - 1) * scp->max_posx);
- fillw(scp->term.attr | scr_map[0x20],
- scp->crt_base, scp->max_posx);
+ scp->crt_base + scp->xsize,
+ (scp->ysize - 1) * scp->xsize);
+ fillw(scp->term.cur_attr | scr_map[0x20],
+ scp->crt_base, scp->xsize);
}
break;
#if notyet
@@ -1439,86 +1403,86 @@ static void scan_esc(scr_stat *scp, u_char c)
}
else if (scp->term.esc == 2) {
if (c >= '0' && c <= '9') {
- if (scp->term.n_par < MAX_ESC_PAR) {
- if (scp->term.last_par != scp->term.n_par) {
- scp->term.last_par = scp->term.n_par;
- scp->term.par[scp->term.n_par] = 0;
+ if (scp->term.num_param < MAX_ESC_PAR) {
+ if (scp->term.last_param != scp->term.num_param) {
+ scp->term.last_param = scp->term.num_param;
+ scp->term.param[scp->term.num_param] = 0;
}
else
- scp->term.par[scp->term.n_par] *= 10;
- scp->term.par[scp->term.n_par] += c - '0';
+ scp->term.param[scp->term.num_param] *= 10;
+ scp->term.param[scp->term.num_param] += c - '0';
return;
}
}
- scp->term.n_par = scp->term.last_par + 1;
+ scp->term.num_param = scp->term.last_param + 1;
switch (c) {
case ';':
- if (scp->term.n_par < MAX_ESC_PAR)
+ if (scp->term.num_param < MAX_ESC_PAR)
return;
break;
case '=':
scp->term.esc = 3;
- scp->term.last_par = -1;
- for (i = scp->term.n_par; i < MAX_ESC_PAR; i++)
- scp->term.par[i] = 1;
- scp->term.n_par = 0;
+ scp->term.last_param = -1;
+ for (i = scp->term.num_param; i < MAX_ESC_PAR; i++)
+ scp->term.param[i] = 1;
+ scp->term.num_param = 0;
return;
case 'A': /* up n rows */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx, scp->posy - n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos, scp->ypos - n);
break;
case 'B': /* down n rows */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx, scp->posy + n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos, scp->ypos + n);
break;
case 'C': /* right n columns */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx + n, scp->posy);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos + n, scp->ypos);
break;
case 'D': /* left n columns */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx - n, scp->posy);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos - n, scp->ypos);
break;
case 'E': /* cursor to start of line n lines down */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, 0, scp->posy + n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, 0, scp->ypos + n);
break;
case 'F': /* cursor to start of line n lines up */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, 0, scp->posy - n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, 0, scp->ypos - n);
break;
case 'f': /* System V consoles .. */
case 'H': /* Cursor move */
- if (scp->term.n_par == 0)
+ if (scp->term.num_param == 0)
move_crsr(scp, 0, 0);
- else if (scp->term.n_par == 2)
- move_crsr(scp, scp->term.par[1] - 1,
- scp->term.par[0] - 1);
+ else if (scp->term.num_param == 2)
+ move_crsr(scp, scp->term.param[1] - 1,
+ scp->term.param[0] - 1);
break;
case 'J': /* Clear all or part of display */
- if (scp->term.n_par == 0)
+ if (scp->term.num_param == 0)
n = 0;
else
- n = scp->term.par[0];
+ n = scp->term.param[0];
switch (n) {
case 0: /* clear form cursor to end of display */
- fillw(scp->term.attr | scr_map[0x20],
+ fillw(scp->term.cur_attr | scr_map[0x20],
scp->crtat, scp->crt_base +
- scp->max_posx * scp->max_posy -
+ scp->xsize * scp->ysize -
scp->crtat);
break;
case 1: /* clear from beginning of display to cursor */
- fillw(scp->term.attr | scr_map[0x20],
+ fillw(scp->term.cur_attr | scr_map[0x20],
scp->crt_base,
scp->crtat - scp->crt_base);
break;
@@ -1529,259 +1493,259 @@ static void scan_esc(scr_stat *scp, u_char c)
break;
case 'K': /* Clear all or part of line */
- if (scp->term.n_par == 0)
+ if (scp->term.num_param == 0)
n = 0;
else
- n = scp->term.par[0];
+ n = scp->term.param[0];
switch (n) {
case 0: /* clear form cursor to end of line */
- fillw(scp->term.attr | scr_map[0x20],
- scp->crtat, scp->max_posx - scp->posx);
+ fillw(scp->term.cur_attr | scr_map[0x20],
+ scp->crtat, scp->xsize - scp->xpos);
break;
case 1: /* clear from beginning of line to cursor */
- fillw(scp->term.attr|scr_map[0x20],
- scp->crtat - (scp->max_posx - scp->posx),
- (scp->max_posx - scp->posx) + 1);
+ fillw(scp->term.cur_attr|scr_map[0x20],
+ scp->crtat - (scp->xsize - scp->xpos),
+ (scp->xsize - scp->xpos) + 1);
break;
case 2: /* clear entire line */
- fillw(scp->term.attr|scr_map[0x20],
- scp->crtat - (scp->max_posx - scp->posx),
- scp->max_posx);
+ fillw(scp->term.cur_attr|scr_map[0x20],
+ scp->crtat - (scp->xsize - scp->xpos),
+ scp->xsize);
break;
}
break;
case 'L': /* Insert n lines */
- n = scp->term.par[0]; if (n < 1) n = 1;
- if (n > scp->max_posy - scp->posy)
- n = scp->max_posy - scp->posy;
- src = scp->crt_base + scp->posy * scp->max_posx;
- dst = src + n * scp->max_posx;
- count = scp->max_posy - (scp->posy + n);
- move_up(src, dst, count * scp->max_posx);
- fillw(scp->term.attr | scr_map[0x20], src,
- n * scp->max_posx);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ if (n > scp->ysize - scp->ypos)
+ n = scp->ysize - scp->ypos;
+ src = scp->crt_base + scp->ypos * scp->xsize;
+ dst = src + n * scp->xsize;
+ count = scp->ysize - (scp->ypos + n);
+ move_up(src, dst, count * scp->xsize);
+ fillw(scp->term.cur_attr | scr_map[0x20], src,
+ n * scp->xsize);
break;
case 'M': /* Delete n lines */
- n = scp->term.par[0]; if (n < 1) n = 1;
- if (n > scp->max_posy - scp->posy)
- n = scp->max_posy - scp->posy;
- dst = scp->crt_base + scp->posy * scp->max_posx;
- src = dst + n * scp->max_posx;
- count = scp->max_posy - (scp->posy + n);
- move_down(src, dst, count * scp->max_posx);
- src = dst + count * scp->max_posx;
- fillw(scp->term.attr | scr_map[0x20], src,
- n * scp->max_posx);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ if (n > scp->ysize - scp->ypos)
+ n = scp->ysize - scp->ypos;
+ dst = scp->crt_base + scp->ypos * scp->xsize;
+ src = dst + n * scp->xsize;
+ count = scp->ysize - (scp->ypos + n);
+ move_down(src, dst, count * scp->xsize);
+ src = dst + count * scp->xsize;
+ fillw(scp->term.cur_attr | scr_map[0x20], src,
+ n * scp->xsize);
break;
case 'P': /* Delete n chars */
- n = scp->term.par[0]; if (n < 1) n = 1;
- if (n > scp->max_posx - scp->posx)
- n = scp->max_posx - scp->posx;
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ if (n > scp->xsize - scp->xpos)
+ n = scp->xsize - scp->xpos;
dst = scp->crtat;
src = dst + n;
- count = scp->max_posx - (scp->posx + n);
+ count = scp->xsize - (scp->xpos + n);
move_down(src, dst, count);
src = dst + count;
- fillw(scp->term.attr | scr_map[0x20], src, n);
+ fillw(scp->term.cur_attr | scr_map[0x20], src, n);
break;
case '@': /* Insert n chars */
- n = scp->term.par[0]; if (n < 1) n = 1;
- if (n > scp->max_posx - scp->posx)
- n = scp->max_posx - scp->posx;
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ if (n > scp->xsize - scp->xpos)
+ n = scp->xsize - scp->xpos;
src = scp->crtat;
dst = src + n;
- count = scp->max_posx - (scp->posx + n);
+ count = scp->xsize - (scp->xpos + n);
move_up(src, dst, count);
- fillw(scp->term.attr | scr_map[0x20], src, n);
+ fillw(scp->term.cur_attr | scr_map[0x20], src, n);
break;
case 'S': /* scroll up n lines */
- n = scp->term.par[0]; if (n < 1) n = 1;
- bcopy(scp->crt_base + (scp->max_posx * n),
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ bcopy(scp->crt_base + (scp->xsize * n),
scp->crt_base,
- scp->max_posx * (scp->max_posy - n) *
+ scp->xsize * (scp->ysize - n) *
sizeof(u_short));
- fillw(scp->term.attr | scr_map[0x20],
- scp->crt_base + scp->max_posx *
- (scp->max_posy - 1),
- scp->max_posx);
+ fillw(scp->term.cur_attr | scr_map[0x20],
+ scp->crt_base + scp->xsize *
+ (scp->ysize - 1),
+ scp->xsize);
break;
case 'T': /* scroll down n lines */
- n = scp->term.par[0]; if (n < 1) n = 1;
+ n = scp->term.param[0]; if (n < 1) n = 1;
bcopy(scp->crt_base,
- scp->crt_base + (scp->max_posx * n),
- scp->max_posx * (scp->max_posy - n) *
+ scp->crt_base + (scp->xsize * n),
+ scp->xsize * (scp->ysize - n) *
sizeof(u_short));
- fillw(scp->term.attr | scr_map[0x20],
- scp->crt_base, scp->max_posx);
+ fillw(scp->term.cur_attr | scr_map[0x20], scp->crt_base,
+ scp->xsize);
break;
case 'X': /* delete n characters in line */
- n = scp->term.par[0]; if (n < 1) n = 1;
- fillw(scp->term.attr | scr_map[0x20],
- scp->crt_base + scp->posx +
- ((scp->max_posx*scp->posy) * sizeof(u_short)), n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ fillw(scp->term.cur_attr | scr_map[0x20],
+ scp->crt_base + scp->xpos +
+ ((scp->xsize*scp->ypos) * sizeof(u_short)), n);
break;
case 'Z': /* move n tabs backwards */
- n = scp->term.par[0]; if (n < 1) n = 1;
- if ((i = scp->posx & 0xf8) == scp->posx)
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ if ((i = scp->xpos & 0xf8) == scp->xpos)
i -= 8*n;
else
i -= 8*(n-1);
if (i < 0)
i = 0;
- move_crsr(scp, i, scp->posy);
+ move_crsr(scp, i, scp->ypos);
break;
case '`': /* move cursor to column n */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, n, scp->posy);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, n, scp->ypos);
break;
case 'a': /* move cursor n columns to the right */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx + n, scp->posy);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos + n, scp->ypos);
break;
case 'd': /* move cursor to row n */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx, n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos, n);
break;
case 'e': /* move cursor n rows down */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx, scp->posy + n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos, scp->ypos + n);
break;
case 'm': /* change attribute */
- if (scp->term.n_par == 0)
+ if (scp->term.num_param == 0)
n = 0;
else
- n = scp->term.par[0];
+ n = scp->term.param[0];
switch (n) {
case 0: /* back to normal */
- scp->term.attr = scp->term.std_attr;
+ scp->term.cur_attr = scp->term.std_attr;
break;
case 1: /* highlight (bold) */
- scp->term.attr &= 0xFF00;
- scp->term.attr |= 0x0800;
+ scp->term.cur_attr &= 0xFF00;
+ scp->term.cur_attr |= 0x0800;
break;
case 4: /* highlight (underline) */
- scp->term.attr &= 0x0F00;
- scp->term.attr |= 0x0800;
+ scp->term.cur_attr &= 0x0F00;
+ scp->term.cur_attr |= 0x0800;
break;
case 5: /* blink */
- scp->term.attr &= 0xFF00;
- scp->term.attr |= 0x8000;
+ scp->term.cur_attr &= 0xFF00;
+ scp->term.cur_attr |= 0x8000;
break;
case 7: /* reverse video */
- scp->term.attr = scp->term.rev_attr;
+ scp->term.cur_attr = scp->term.rev_attr;
break;
case 30: case 31: case 32: case 33: /* set fg color */
case 34: case 35: case 36: case 37:
- scp->term.attr = (scp->term.attr & 0xF0FF)
+ scp->term.cur_attr = (scp->term.cur_attr & 0xF0FF)
| (ansi_col[(n - 30) & 7] << 8);
break;
case 40: case 41: case 42: case 43: /* set bg color */
case 44: case 45: case 46: case 47:
- scp->term.attr = (scp->term.attr & 0x0FFF)
+ scp->term.cur_attr = (scp->term.cur_attr & 0x0FFF)
| (ansi_col[(n - 40) & 7] << 12);
break;
}
break;
case 'x':
- if (scp->term.n_par == 0)
+ if (scp->term.num_param == 0)
n = 0;
else
- n = scp->term.par[0];
+ n = scp->term.param[0];
switch (n) {
case 0: /* reset attributes */
- scp->term.attr = scp->term.std_attr =
+ scp->term.cur_attr = scp->term.std_attr =
current_default->std_attr;
scp->term.rev_attr = current_default->rev_attr;
break;
case 1: /* set ansi background */
- scp->term.attr = scp->term.std_attr =
+ scp->term.cur_attr = scp->term.std_attr =
(scp->term.std_attr & 0x0F00) |
- (ansi_col[(scp->term.par[1])&0x0F]<<12);
+ (ansi_col[(scp->term.param[1])&0x0F]<<12);
break;
case 2: /* set ansi foreground */
- scp->term.attr = scp->term.std_attr =
+ scp->term.cur_attr = scp->term.std_attr =
(scp->term.std_attr & 0xF000) |
- (ansi_col[(scp->term.par[1])&0x0F]<<8);
+ (ansi_col[(scp->term.param[1])&0x0F]<<8);
break;
case 3: /* set ansi attribute directly */
- scp->term.attr = scp->term.std_attr =
- (scp->term.par[1]&0xFF)<<8;
+ scp->term.cur_attr = scp->term.std_attr =
+ (scp->term.param[1]&0xFF)<<8;
break;
case 5: /* set ansi reverse video background */
scp->term.rev_attr =
(scp->term.rev_attr & 0x0F00) |
- (ansi_col[(scp->term.par[1])&0x0F]<<12);
+ (ansi_col[(scp->term.param[1])&0x0F]<<12);
break;
case 6: /* set ansi reverse video foreground */
scp->term.rev_attr =
(scp->term.rev_attr & 0xF000) |
- (ansi_col[(scp->term.par[1])&0x0F]<<8);
+ (ansi_col[(scp->term.param[1])&0x0F]<<8);
break;
case 7: /* set ansi reverse video directly */
- scp->term.rev_attr = (scp->term.par[1]&0xFF)<<8;
+ scp->term.rev_attr = (scp->term.param[1]&0xFF)<<8;
break;
}
break;
case 'z': /* switch to (virtual) console n */
- if (scp->term.n_par == 1)
- switch_scr(scp->term.par[0]);
+ if (scp->term.num_param == 1)
+ switch_scr(scp->term.param[0]);
break;
}
}
else if (scp->term.esc == 3) {
if (c >= '0' && c <= '9') {
- if (scp->term.n_par < MAX_ESC_PAR) {
- if (scp->term.last_par != scp->term.n_par) {
- scp->term.last_par = scp->term.n_par;
- scp->term.par[scp->term.n_par] = 0;
+ if (scp->term.num_param < MAX_ESC_PAR) {
+ if (scp->term.last_param != scp->term.num_param) {
+ scp->term.last_param = scp->term.num_param;
+ scp->term.param[scp->term.num_param] = 0;
}
else
- scp->term.par[scp->term.n_par] *= 10;
- scp->term.par[scp->term.n_par] += c - '0';
+ scp->term.param[scp->term.num_param] *= 10;
+ scp->term.param[scp->term.num_param] += c - '0';
return;
}
}
- scp->term.n_par = scp->term.last_par + 1;
+ scp->term.num_param = scp->term.last_param + 1;
switch (c) {
case ';':
- if (scp->term.n_par < MAX_ESC_PAR)
+ if (scp->term.num_param < MAX_ESC_PAR)
return;
break;
case 'A': /* set display border color */
- if (scp->term.n_par == 1)
- scp->border=scp->term.par[0] & 0xff;
+ if (scp->term.num_param == 1)
+ scp->border=scp->term.param[0] & 0xff;
if (scp == cur_console)
set_border(scp->border);
break;
case 'B': /* set bell pitch and duration */
- if (scp->term.n_par == 2) {
- scp->bell_pitch = scp->term.par[0];
- scp->bell_duration = scp->term.par[1]*10;
+ if (scp->term.num_param == 2) {
+ scp->bell_pitch = scp->term.param[0];
+ scp->bell_duration = scp->term.param[1]*10;
}
break;
case 'C': /* set cursor shape (start & end line) */
- if (scp->term.n_par == 2) {
- scp->cursor_start = scp->term.par[0] & 0x1F;
- scp->cursor_end = scp->term.par[1] & 0x1F;
+ if (scp->term.num_param == 2) {
+ scp->cursor_start = scp->term.param[0] & 0x1F;
+ scp->cursor_end = scp->term.param[1] & 0x1F;
if (scp == cur_console)
cursor_shape(scp->cursor_start,
scp->cursor_end);
@@ -1789,31 +1753,31 @@ static void scan_esc(scr_stat *scp, u_char c)
break;
case 'F': /* set ansi foreground */
- if (scp->term.n_par == 1)
- scp->term.attr = scp->term.std_attr =
+ if (scp->term.num_param == 1)
+ scp->term.cur_attr = scp->term.std_attr =
(scp->term.std_attr & 0xF000)
- | ((scp->term.par[0] & 0x0F) << 8);
+ | ((scp->term.param[0] & 0x0F) << 8);
break;
case 'G': /* set ansi background */
- if (scp->term.n_par == 1)
- scp->term.attr = scp->term.std_attr =
+ if (scp->term.num_param == 1)
+ scp->term.cur_attr = scp->term.std_attr =
(scp->term.std_attr & 0x0F00)
- | ((scp->term.par[0] & 0x0F) << 12);
+ | ((scp->term.param[0] & 0x0F) << 12);
break;
case 'H': /* set ansi reverse video foreground */
- if (scp->term.n_par == 1)
+ if (scp->term.num_param == 1)
scp->term.rev_attr =
(scp->term.rev_attr & 0xF000)
- | ((scp->term.par[0] & 0x0F) << 8);
+ | ((scp->term.param[0] & 0x0F) << 8);
break;
case 'I': /* set ansi reverse video background */
- if (scp->term.n_par == 1)
+ if (scp->term.num_param == 1)
scp->term.rev_attr =
(scp->term.rev_attr & 0x0F00)
- | ((scp->term.par[0] & 0x0F) << 12);
+ | ((scp->term.param[0] & 0x0F) << 12);
break;
}
}
@@ -1826,71 +1790,73 @@ static void ansi_put(scr_stat *scp, u_char c)
if (scp->status & UNKNOWN_MODE)
return;
+#if defined(STAR_SAVER)
/* make screensaver happy */
if (scp == cur_console) {
scrn_time_stamp = time.tv_sec;
if (scrn_blanked)
scrn_saver(0);
}
+#endif
in_putc++;
if (scp->term.esc)
scan_esc(scp, c);
else switch(c) {
case 0x1B: /* start escape sequence */
scp->term.esc = 1;
- scp->term.n_par = 0;
+ scp->term.num_param = 0;
break;
case 0x07:
if (scp == cur_console)
sysbeep(scp->bell_pitch, scp->bell_duration);
break;
case '\t': /* non-destructive tab */
- scp->crtat += (8 - scp->posx % 8);
- scp->posx += (8 - scp->posx % 8);
+ scp->crtat += (8 - scp->xpos % 8);
+ scp->xpos += (8 - scp->xpos % 8);
break;
case '\b': /* non-destructive backspace */
if (scp->crtat > scp->crt_base) {
scp->crtat--;
- if (scp->posx > 0)
- scp->posx--;
+ if (scp->xpos > 0)
+ scp->xpos--;
else {
- scp->posx += scp->max_posx - 1;
- scp->posy--;
+ scp->xpos += scp->xsize - 1;
+ scp->ypos--;
}
}
break;
case '\r': /* return to pos 0 */
- move_crsr(scp, 0, scp->posy);
+ move_crsr(scp, 0, scp->ypos);
break;
case '\n': /* newline, same pos */
- scp->crtat += scp->max_posx;
- scp->posy++;
+ scp->crtat += scp->xsize;
+ scp->ypos++;
break;
case '\f': /* form feed, clears screen */
clear_screen(scp);
break;
default:
/* Print only printables */
- *scp->crtat = (scp->term.attr | scr_map[c]);
+ *scp->crtat = (scp->term.cur_attr | scr_map[c]);
scp->crtat++;
- if (++scp->posx >= scp->max_posx) {
- scp->posx = 0;
- scp->posy++;
+ if (++scp->xpos >= scp->xsize) {
+ scp->xpos = 0;
+ scp->ypos++;
}
break;
}
- if (scp->crtat >= scp->crt_base + scp->max_posy * scp->max_posx) {
- bcopy(scp->crt_base + scp->max_posx, scp->crt_base,
- scp->max_posx * (scp->max_posy - 1) * sizeof(u_short));
- fillw(scp->term.attr | scr_map[0x20],
- scp->crt_base + scp->max_posx
- * (scp->max_posy - 1), scp->max_posx);
- scp->crtat -= scp->max_posx;
- scp->posy--;
+ if (scp->crtat >= scp->crt_base + scp->ysize * scp->xsize) {
+ bcopy(scp->crt_base + scp->xsize, scp->crt_base,
+ scp->xsize * (scp->ysize - 1) * sizeof(u_short));
+ fillw(scp->term.cur_attr | scr_map[0x20],
+ scp->crt_base + scp->xsize * (scp->ysize - 1),
+ scp->xsize);
+ scp->crtat -= scp->xsize;
+ scp->ypos--;
}
in_putc--;
- if (nx_scr)
- switch_scr(nx_scr - 1);
+ if (delayed_next_scr)
+ switch_scr(delayed_next_scr - 1);
}
static void scinit(void)
@@ -1908,7 +1874,7 @@ static void scinit(void)
/*
* Crtat initialized to point to MONO buffer, if not present change
* to CGA_BUF offset. ONLY ADD the difference since locore.s adds
- * in the remapped offset at the right time
+ * in the remapped offset at the "right" time
*/
was = *cp;
*cp = (u_short) 0xA55A;
@@ -1938,12 +1904,12 @@ static void scinit(void)
console[0].term.esc = 0;
console[0].term.std_attr = current_default->std_attr;
console[0].term.rev_attr = current_default->rev_attr;
- console[0].term.attr = current_default->std_attr;
- console[0].posx = cursorat % COL;
- console[0].posy = cursorat / COL;
+ console[0].term.cur_attr = current_default->std_attr;
+ console[0].xpos = cursorat % COL;
+ console[0].ypos = cursorat / COL;
console[0].border = BG_BLACK;;
- console[0].max_posx = COL;
- console[0].max_posy = ROW;
+ console[0].xsize = COL;
+ console[0].ysize = ROW;
console[0].status = 0;
console[0].pid = 0;
console[0].proc = NULL;
@@ -1953,15 +1919,15 @@ static void scinit(void)
kernel_console.esc = 0;
kernel_console.std_attr = kernel_default.std_attr;
kernel_console.rev_attr = kernel_default.rev_attr;
- kernel_console.attr = kernel_default.std_attr;
- /* initialize mapscrn array to */
+ kernel_console.cur_attr = kernel_default.std_attr;
+ /* initialize mapscrn array to a one to one map */
for (i=0; i<sizeof(scr_map); i++)
scr_map[i] = i;
clear_screen(&console[0]);
}
-static void sput(u_char c)
+static void scput(u_char c)
{
scr_stat *scp = &console[0];
term_stat save;
@@ -1994,29 +1960,17 @@ static u_char *get_fstr(u_int c, u_int *len)
static void update_leds(int which)
{
- u_char xlate_leds[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
-
- kbd_cmd(KB_SETLEDS); /* LED Command */
- kbd_cmd(xlate_leds[which & LED_MASK]);
- kbd_wait();
-}
-
+ static u_char xlate_leds[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
-static volatile void reset_cpu(void)
-{
- while (1) {
- kbd_cmd(KB_RESET_CPU); /* Reset Command */
- DELAY(4000000);
- kbd_cmd(KB_RESET); /* Keyboard Reset Command */
- }
+ kbd_cmd2(KB_SETLEDS, xlate_leds[which & LED_MASK]);
}
-
-
+
+
/*
- * sgetc(noblock) : get a character from the keyboard.
+ * scgetc(noblock) : get a character from the keyboard.
* If noblock = 0 wait until a key is gotten. Otherwise return NOKEY.
*/
-u_int sgetc(int noblock)
+u_int scgetc(int noblock)
{
u_char val, code, release;
u_int state, action;
@@ -2221,7 +2175,7 @@ next_code:
if (chr && !compose) {
action = chr;
chr = 0;
- return (action);
+ return(action);
}
} else {
/* key pressed */
@@ -2253,11 +2207,7 @@ next_code:
slkcnt++;
if (cur_console->status & SLKED) {
cur_console->status &= ~SLKED;
-#if defined(NetBSD)
- pcstart(pc_tty[get_scr_num(cur_console)]);
-#else
- pcstart(&pccons[get_scr_num(cur_console)]);
-#endif
+ pcstart(VIRTUAL_TTY(get_scr_num()));
}
else
cur_console->status |= SLKED;
@@ -2278,14 +2228,18 @@ next_code:
case NOP:
break;
case RBT:
+#if defined(__FreeBSD__)
shutdown_nice();
+#else
+ cpu_reset();
+#endif
break;
case DBG:
#if DDB > 0 /* try to switch to console 0 */
if (cur_console->smode.mode == VT_AUTO &&
console[0].smode.mode == VT_AUTO)
switch_scr(0);
- Debugger("manual escape to debugger");
+ Debugger();
return(NOKEY);
#else
printf("No debugger in kernel\n");
@@ -2316,7 +2270,7 @@ next_code:
metas = 1;
break;
case NEXT:
- switch_scr((get_scr_num(cur_console)+1)%NCONS);
+ switch_scr((get_scr_num()+1)%NCONS);
break;
default:
if (action >= F_SCR && action <= L_SCR) {
@@ -2345,30 +2299,35 @@ int getchar(void)
polling = 1;
s = splhigh();
- sput('>');
- thechar = (u_char) sgetc(0);
+ scput('>');
+ thechar = (u_char) scgetc(0);
polling = 0;
splx(s);
switch (thechar) {
default:
if (thechar >= scr_map[0x20])
- sput(thechar);
+ scput(thechar);
return(thechar);
case cr:
case lf:
- sput(cr); sput(lf);
+ scput(cr); scput(lf);
return(lf);
case bs:
case del:
- sput(bs); sput(scr_map[0x20]); sput(bs);
+ scput(bs); scput(scr_map[0x20]); scput(bs);
return(thechar);
case cntld:
- sput('^'); sput('D'); sput('\r'); sput('\n');
+ scput('^'); scput('D'); scput('\r'); scput('\n');
return(0);
}
}
+u_int sgetc(int noblock)
+{
+ return (scgetc(noblock & 0xff);
+}
+
int pcmmap(dev_t dev, int offset, int nprot)
{
if (offset > 0x20000)
@@ -2380,9 +2339,12 @@ int pcmmap(dev_t dev, int offset, int nprot)
static void kbd_wait(void)
{
int i;
- for (i=0; i<10000; i++)
+
+ for (i=0; i<1000; i++) { /* up to 10 msec */
if ((inb(KB_STAT) & KB_READY) == 0)
break;
+ DELAY (10);
+ }
}
@@ -2393,6 +2355,35 @@ static void kbd_cmd(u_char command)
}
+static void kbd_cmd2(u_char command, u_char arg)
+{
+ int r, s = spltty();
+ do {
+ kbd_cmd(command);
+ r = kbd_reply();
+ if (r == KB_ACK) {
+ kbd_cmd(arg & 0x7f);
+ r = kbd_reply();
+ }
+ } while (r != KB_ACK);
+ splx(s);
+}
+
+
+static int kbd_reply()
+{
+ int i;
+
+ kbd_wait();
+ for (i=0; i<50000; i++) { /* at least 300 msec, 500 msec enough */
+ if (inb(KB_STAT) & KB_BUF_FULL)
+ return ((u_char) inb(KB_DATA));
+ DELAY (10);
+ }
+ return(-1);
+}
+
+
static void set_mode(scr_stat *scp)
{
u_char byte;
@@ -2402,8 +2393,8 @@ static void set_mode(scr_stat *scp)
return;
/* (re)activate cursor */
- untimeout((timeout_func_t)cursor_pos, 0);
- cursor_pos();
+ untimeout((timeout_t)cursor_pos, 0);
+ cursor_pos(1);
/* change cursor type if set */
if (scp->cursor_start != -1 && scp->cursor_end != -1)
diff --git a/sys/isa/kbdtables.h b/sys/isa/kbdtables.h
index a3a7c81..33e2b36 100644
--- a/sys/isa/kbdtables.h
+++ b/sys/isa/kbdtables.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1992, 1993 Søren Schmidt
+ * Copyright (C) 1992, 1993, 1994 Søren Schmidt
*
* This program is free software; you may redistribute it and/or
* modify it, provided that it retain the above copyright notice
@@ -9,11 +9,12 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * Søren Schmidt Email: sos@kmd-ac.dk
- * Tritonvej 36 UUCP: ...uunet!dkuug!kmd-ac!sos
+ * Søren Schmidt Email: sos@login.dkuug.dk
+ * Tritonvej 36 UUCP: ...uunet!dkuug!login!sos
* DK9210 Aalborg SO Phone: +45 9814 8076
*
- * $Id: kbdtables.h,v 1.8 1994/01/18 05:31:37 nate Exp $
+ * @(#)kbdtables.h 1.3 940123
+ * $Id: kbdtables.h,v 1.9 1994/01/24 05:22:27 ache Exp $
*/
#define SET8 0x80 /* eight bit for emacs SET8-key */
@@ -26,7 +27,7 @@ keymap_t key_map = { 0x69, /* DK iso8859 keymap */
* ---------------------------------------------------------------------------
*/
/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, NOP, NOP, 0x1B, 0x1B, NOP, NOP, 0x33, 0x00,
+/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, 0x02, 0x00,
/* sc=02 */ '1', '!', NOP, NOP, '1', '!', NOP, NOP, 0x33, 0x00,
/* sc=03 */ '2', '"', 0x00, 0x00, '@', '"', 0x00, 0x00, 0x00, 0x00,
/* sc=04 */ '3', '#', NOP, NOP, 0x9E, '#', NOP, NOP, 0x33, 0x00,
@@ -108,7 +109,7 @@ keymap_t key_map = { 0x69, /* DK iso8859 keymap */
/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02,
-/* sc=53 */ 0x7F, '.', '.', '.', '.', '.', RBT, '.', 0x02, 0x02,
+/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, RBT, 0x7F, 0x02, 0x02,
/* sc=54 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ '<', '>', 0x1C, 0x1C, '\\', '>', 0x1C, 0x1C, 0x00, 0x00,
@@ -128,7 +129,7 @@ keymap_t key_map = { 0x69, /* DK iso8859 keymap */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00,
+/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT, F(54), 0xFF, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
#endif
@@ -141,7 +142,7 @@ keymap_t key_map = { 0x69, /* uk iso8859 keymap */
* ---------------------------------------------------------------------------
*/
/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00,
+/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, 0x02, 0x00,
/* sc=02 */ '1', '!', NOP, NOP, '`', '`', NOP, NOP, 0x33, 0x00,
/* sc=03 */ '2', '"', 0x00, 0x00, '@', '@', 0x00, 0x00, 0x00, 0x00,
/* sc=04 */ '3', 0xA3, NOP, NOP, '#', '#', NOP, NOP, 0x33, 0x00,
@@ -223,8 +224,8 @@ keymap_t key_map = { 0x69, /* uk iso8859 keymap */
/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02,
-/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02,
-/* sc=54 */ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00,
+/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, RBT, 0x7F, 0x02, 0x02,
+/* sc=54 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ '\\', '|', 0x1C, 0x1C, '\\', '|', 0x1C, 0x1C, 0x00, 0x00,
/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00,
@@ -243,7 +244,7 @@ keymap_t key_map = { 0x69, /* uk iso8859 keymap */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00,
+/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT, F(54), 0xFF, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
#endif
@@ -256,7 +257,7 @@ keymap_t key_map = { 0x69, /* german iso8859 keymap */
* ---------------------------------------------------------------------------
*/
/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00,
+/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, 0x02, 0x00,
/* sc=02 */ '1', '!', NOP, NOP, '`', '`', NOP, NOP, 0x33, 0x00,
/* sc=03 */ '2', '"', 0x00, 0x00, '@', '@', 0x00, 0x00, 0x00, 0x00,
/* sc=04 */ '3', 0xA7, NOP, NOP, '#', '#', NOP, NOP, 0x33, 0x00,
@@ -338,7 +339,7 @@ keymap_t key_map = { 0x69, /* german iso8859 keymap */
/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02,
-/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02,
+/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, RBT, 0x7F, 0x02, 0x02,
/* sc=54 */ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -358,7 +359,7 @@ keymap_t key_map = { 0x69, /* german iso8859 keymap */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00,
+/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT, F(54), 0xFF, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
#endif
@@ -371,7 +372,7 @@ keymap_t key_map = { 0x69, /* swedish iso8859 keymap */
* ---------------------------------------------------------------------------
*/
/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00,
+/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, 0x02, 0x00,
/* sc=02 */ '1', '!', NOP, NOP, NOP, NOP, NOP, NOP, 0x3F, 0x00,
/* sc=03 */ '2', '"', NOP, NOP, NOP, '@', NOP, NOP, 0x3B, 0x00,
/* sc=04 */ '3', 0xA3, NOP, NOP, NOP, '#', NOP, NOP, 0x3B, 0x00,
@@ -453,7 +454,7 @@ keymap_t key_map = { 0x69, /* swedish iso8859 keymap */
/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02,
-/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02,
+/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, RBT, 0x7F, 0x02, 0x02,
/* sc=54 */ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -473,7 +474,7 @@ keymap_t key_map = { 0x69, /* swedish iso8859 keymap */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00,
+/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT, F(54), 0xFF, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
#endif
@@ -539,7 +540,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=33 */ ',', '<', NOP, NOP, SET8|',', SET8|'<', NOP, NOP, 0x33, 0x00,
/* sc=34 */ '.', '>', NOP, NOP, SET8|'.', SET8|'>', NOP, NOP, 0x33, 0x00,
/* sc=35 */ '/', '?', NOP, NOP, SET8|'/', SET8|'?', NOP, NOP, 0x33, 0x00,
-/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
+/* sc=36 */ ASH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
/* sc=37 */ '*', '*', 0x0A, 0x0A, SET8|'*', SET8|'*', SET8|0x0A, SET8|0x0A, 0x00, 0x00,
/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00,
/* sc=39 */ ' ', ' ', ' ', ' ', SET8|' ', SET8|' ', SET8|' ', SET8|' ', 0x00, 0x00,
@@ -568,7 +569,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=50 */ F(58), '2', '2', '2', SET8|'2', SET8|'2', SET8|'2', SET8|'2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', SET8|'3', SET8|'3', SET8|'3', SET8|'3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', SET8|'0', SET8|'0', SET8|'0', SET8|'0', 0x80, 0x02,
-/* sc=53 */ F(54), '.', 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, RBT, SET8|0x7F, 0x82, 0x02,
+/* sc=53 */ F(54), '.', 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, 0x80, 0x02,
/* sc=54 */ ALK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -577,7 +578,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=59 */ 0x0D, 0x0D, 0x0A, 0x0A, SET8|0x0D, SET8|0x0D, SET8|0x0A, SET8|0x0A, 0x00, 0x00,
/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00,
/* sc=5b */ '/', '/', NOP, NOP, SET8|'/', SET8|'/', NOP, NOP, 0x33, 0x00,
-/* sc=5c */ NEXT, NOP, DBG, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
+/* sc=5c */ CLK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00,
/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00,
/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00,
/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00,
@@ -588,7 +589,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, RBT, SET8|0x7F, 0xC2, 0x00,
+/* sc=67 */ F(54), F(54), 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, 0xC0, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
/* sc=69 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=6a */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -626,8 +627,8 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=09 */ '*', '8', NOP, NOP, SET8|'8', SET8|'*', NOP, NOP, 0x33, 0x00,
/* sc=0a */ '(', '9', NOP, NOP, SET8|'9', SET8|'(', NOP, NOP, 0x33, 0x00,
/* sc=0b */ ')', '0', NOP, NOP, SET8|'0', SET8|')', NOP, NOP, 0x33, 0x00,
-/* sc=0c */ '-', '_', 0x1F, 0x1F, SET8|'-', SET8|'_', SET8|0x1F, SET8|0x1F, 0x00, 0x00,
-/* sc=0d */ '=', '+', NOP, NOP, SET8|'=', SET8|'+', NOP, NOP, 0x33, 0x00,
+/* sc=0c */ '_', '-', 0x1F, 0x1F, SET8|'-', SET8|'_', SET8|0x1F, SET8|0x1F, 0x00, 0x00,
+/* sc=0d */ '+', '=', NOP, NOP, SET8|'=', SET8|'+', NOP, NOP, 0x33, 0x00,
/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, SET8|0x08, SET8|0x08, SET8|0x7F, SET8|0x7F, 0x00, 0x00,
/* sc=0f */ 0x09, F(16), NOP, NOP, SET8|0x09, F(16), NOP, NOP, 0x77, 0x00,
/* sc=10 */ 0xca, 0xea, 0x11, 0x11, SET8|'q', SET8|'Q', SET8|0x11, SET8|0x11, 0x00, 0x01,
@@ -668,7 +669,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=33 */ 0xc2, 0xe2, NOP, NOP, SET8|',', SET8|'<', NOP, NOP, 0x33, 0x01,
/* sc=34 */ 0xc0, 0xe0, NOP, NOP, SET8|'.', SET8|'>', NOP, NOP, 0x33, 0x01,
/* sc=35 */ '/', '?', NOP, NOP, SET8|'/', SET8|'?', NOP, NOP, 0x33, 0x00,
-/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
+/* sc=36 */ ASH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
/* sc=37 */ '*', '*', 0x0A, 0x0A, SET8|'*', SET8|'*', SET8|0x0A, SET8|0x0A, 0x00, 0x00,
/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00,
/* sc=39 */ ' ', ' ', ' ', ' ', SET8|' ', SET8|' ', SET8|' ', SET8|' ', 0x00, 0x00,
@@ -697,7 +698,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=50 */ F(58), '2', '2', '2', SET8|'2', SET8|'2', SET8|'2', SET8|'2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', SET8|'3', SET8|'3', SET8|'3', SET8|'3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', SET8|'0', SET8|'0', SET8|'0', SET8|'0', 0x80, 0x02,
-/* sc=53 */ F(54), '.', 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, RBT, SET8|0x7F, 0x82, 0x02,
+/* sc=53 */ F(54), '.', 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, 0x80, 0x02,
/* sc=54 */ ALK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -706,7 +707,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=59 */ 0x0D, 0x0D, 0x0A, 0x0A, SET8|0x0D, SET8|0x0D, SET8|0x0A, SET8|0x0A, 0x00, 0x00,
/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00,
/* sc=5b */ '/', '/', NOP, NOP, SET8|'/', SET8|'/', NOP, NOP, 0x33, 0x00,
-/* sc=5c */ NEXT, NOP, DBG, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
+/* sc=5c */ CLK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00,
/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00,
/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00,
/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00,
@@ -717,7 +718,7 @@ keymap_t key_map = { 0xe9, /* keys number */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, RBT, SET8|0x7F, 0xC2, 0x00,
+/* sc=67 */ F(54), F(54), 0x7F, 0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, SET8|0x7F, 0xC0, 0x00,
/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
@@ -731,7 +732,7 @@ keymap_t key_map = { 0x69, /* US iso8859 keymap */
* ---------------------------------------------------------------------------
*/
/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, NOP, NOP, 0x1B, 0x1B, DBG, NOP, 0x33, 0x00,
+/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, 0x02, 0x00,
/* sc=02 */ '1', '!', NOP, NOP, '1', '!', NOP, NOP, 0x33, 0x00,
/* sc=03 */ '2', '@', 0x00, 0x00, '2', '@', 0x00, 0x00, 0x00, 0x00,
/* sc=04 */ '3', '#', NOP, NOP, '3', '#', NOP, NOP, 0x33, 0x00,
@@ -813,7 +814,7 @@ keymap_t key_map = { 0x69, /* US iso8859 keymap */
/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02,
/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02,
/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02,
-/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02,
+/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, RBT, 0x7F, 0x02, 0x02,
/* sc=54 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
@@ -833,8 +834,8 @@ keymap_t key_map = { 0x69, /* US iso8859 keymap */
/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT , F(54), 0xFF, 0x00,
-/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
+/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), RBT, F(54), 0xFF, 0x00,
+/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
};
#endif
diff --git a/sys/isa/syscons.c b/sys/isa/syscons.c
index 6cad5c1..56ef759 100644
--- a/sys/isa/syscons.c
+++ b/sys/isa/syscons.c
@@ -1,4 +1,5 @@
/*-
+ * Copyright (c) 1992-1994 Søren Schmidt
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
@@ -33,15 +34,19 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)pccons.c 5.11 (Berkeley) 5/21/91
- * from: @(#)syscons.c 1.1 931021
- * $Id: syscons.c,v 1.25 1994/01/14 16:24:18 davidg Exp $
+ * from:@(#)syscons.c 1.3 940129
+ * $Id: syscons.c,v 1.26 1994/01/18 05:33:34 nate Exp $
*
- * Heavily modified by Sxren Schmidt (sos@login.dkuug.dk) to provide:
- *
- * virtual consoles, SYSV ioctl's, ANSI emulation ....
*/
+/* #define FADE_SAVER */
+/* #define BLANK_SAVER */
+#define STAR_SAVER
+
+#if !defined(__FreeBSD__)
+#define FAT_CURSOR
+#endif
+
#include "param.h"
#include "conf.h"
#include "ioctl.h"
@@ -55,7 +60,6 @@
#include "syslog.h"
#include "errno.h"
#include "malloc.h"
-#include "i386/isa/icu.h"
#include "i386/isa/isa.h"
#include "i386/isa/isa_device.h"
#include "i386/isa/timerreg.h"
@@ -64,20 +68,13 @@
#include "machine/psl.h"
#include "machine/frame.h"
#include "machine/pc/display.h"
-#include "sc.h"
#include "iso8859.font"
#include "kbdtables.h"
-
-#if !defined(NetBSD)
-#include "ddb.h"
-#if NDDB > 0
-#define DDB 1
-#endif
-#endif
+#include "sc.h"
#if NSC > 0
-#ifndef NCONS
+#if !defined(NCONS)
#define NCONS 12
#endif
@@ -89,12 +86,7 @@
#define SWITCH_WAIT_REL 0x00040
#define SWITCH_WAIT_ACQ 0x00080
-/* virtual video memory addresses */
-#if !defined(NetBSD)
-#define MONO_BUF (KERNBASE+0xB0000)
-#define CGA_BUF (KERNBASE+0xB8000)
-#define VGA_BUF (KERNBASE+0xA0000)
-#endif
+/* video hardware memory addresses */
#define VIDEOMEM 0x000A0000
/* misc defines */
@@ -103,7 +95,7 @@
#define TEXT80x50 2
#define COL 80
#define ROW 25
-#define BELL_DURATION 10
+#define BELL_DURATION 5
#define BELL_PITCH 800
#define TIMER_FREQ 1193182 /* should be in isa.h */
#define PCBURST 128
@@ -121,27 +113,35 @@
#define GDCIDX IO_VGA+0x0E /* graph data controller idx */
#define GDCREG IO_VGA+0x0F /* graph data controller data */
+/* special characters */
+#define cntlc 0x03
+#define cntld 0x04
+#define bs 0x08
+#define lf 0x0a
+#define cr 0x0d
+#define del 0x7f
+
typedef struct term_stat {
int esc; /* processing escape sequence */
- int n_par; /* # of parameters to ESC */
- int last_par; /* last parameter # */
- int par[MAX_ESC_PAR]; /* contains ESC parameters */
- int attr; /* current attributes */
+ int num_param; /* # of parameters to ESC */
+ int last_param; /* last parameter # */
+ int param[MAX_ESC_PAR]; /* contains ESC parameters */
+ int cur_attr; /* current attributes */
int std_attr; /* normal attributes */
int rev_attr; /* reverse attributes */
} term_stat;
typedef struct scr_stat {
u_short *crt_base; /* address of screen memory */
- u_short *scr; /* buffer when off screen */
+ u_short *scr_buf; /* buffer when off screen */
u_short *crtat; /* cursor address */
- int posx; /* current X position */
- int posy; /* current Y position */
- int max_posx; /* X size */
- int max_posy; /* X size */
+ int xpos; /* current X position */
+ int ypos; /* current Y position */
+ int xsize; /* X size */
+ int ysize; /* Y size */
term_stat term; /* terminal emulation stuff */
char cursor_start; /* cursor start line # */
- char cursor_end; /* cursor start end # */
+ char cursor_end; /* cursor end line # */
u_char border; /* border color */
u_short bell_duration;
u_short bell_pitch;
@@ -183,35 +183,15 @@ static const u_int n_fkey_tab = sizeof(fkey_tab) / sizeof(*fkey_tab);
static int cur_cursor_pos = -1;
static char in_putc = 0;
static char polling = 0;
-static int nx_scr;
+static int delayed_next_scr;
static char saved_console = -1; /* saved console number */
static long scrn_blank_time = 0; /* screen saver timout value */
static int scrn_blanked = 0; /* screen saver active flag */
static long scrn_time_stamp;
static u_char scr_map[256];
-static struct tty *cur_tty = NULL;
-
-#if defined(NetBSD)
-extern u_short *Crtat;
-struct tty *pc_tty[NCONS];
-int ttrstrt();
-#else
-u_short *Crtat = (u_short *)MONO_BUF;
-struct tty pccons[NCONS];
-#define timeout_t caddr_t
-#endif
-
extern int hz;
extern struct timeval time;
-/* special characters */
-#define cntlc 0x03
-#define cntld 0x04
-#define bs 0x08
-#define lf 0x0a
-#define cr 0x0d
-#define del 0x7f
-
/* function prototypes */
int pcprobe(struct isa_device *dev);
int pcattach(struct isa_device *dev);
@@ -223,36 +203,38 @@ int pcparam(struct tty *tp, struct termios *t);
int pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p);
void pcxint(dev_t dev);
void pcstart(struct tty *tp);
-int pccnprobe(struct consdev *cp);
-int pccninit(struct consdev *cp);
+void pccnprobe(struct consdev *cp);
+void pccninit(struct consdev *cp);
void pccnputc(dev_t dev, char c);
int pccngetc(dev_t dev);
-void scintr(dev_t dev, int irq, int cpl);
+void scintr(int unit);
int pcmmap(dev_t dev, int offset, int nprot);
u_int sgetc(int noblock);
int getchar(void);
-static void reset_cpu(void);
+static void scinit(void);
+static void scput(u_char c);
+static u_int scgetc(int noblock);
static void scrn_saver(int test);
static struct tty *get_tty_ptr(dev_t dev);
static scr_stat *get_scr_stat(dev_t dev);
-static int get_scr_num(scr_stat *scp);
+static int get_scr_num();
static void cursor_shape(int start, int end);
static void get_cursor_shape(int *start, int *end);
-static int cursor_pos(void);
+static void cursor_pos(int force);
static void clear_screen(scr_stat *scp);
-static switch_scr(u_int next_scr);
+static int switch_scr(u_int next_scr);
static void exchange_scr(void);
static void move_crsr(scr_stat *scp, int x, int y);
static void move_up(u_short *s, u_short *d, u_int len);
static void move_down(u_short *s, u_short *d, u_int len);
static void scan_esc(scr_stat *scp, u_char c);
static void ansi_put(scr_stat *scp, u_char c);
-static void scinit(void);
-static void sput(u_char c);
static u_char *get_fstr(u_int c, u_int *len);
static void update_leds(int which);
static void kbd_wait(void);
static void kbd_cmd(u_char command);
+static void kbd_cmd2(u_char command, u_char arg);
+static int kbd_reply(void);
static void set_mode(scr_stat *scp);
static void set_border(int color);
static void load_font(int segment, int size, char* font);
@@ -260,38 +242,68 @@ static void save_palette(void);
static void load_palette(void);
static void change_winsize(struct tty *tp, int x, int y);
+
+/* OS specific stuff */
+
+#if defined(NetBSD)
+#define VIRTUAL_TTY(x) pc_tty[x] ? (pc_tty[x]) : (pc_tty[x] = ttymalloc())
+#define CONSOLE_TTY pc_tty[NCONS] ? (pc_tty[NCONS]) : (pc_tty[NCONS] = ttymalloc())
+#define frametype struct trapframe
+#define eflags tf_eflags
+extern u_short *Crtat;
+struct tty *pc_tty[NCONS+1];
+int ttrstrt();
+#endif
+
+#if defined(__FreeBSD__)
+#define frametype struct trapframe
+#define eflags tf_eflags
+#define timeout_t timeout_func_t
+#define MONO_BUF (KERNBASE+0xB0000)
+#define CGA_BUF (KERNBASE+0xB8000)
+#endif
+
+#if defined(__386BSD__) && !defined(__FreeBSD__)
+#define frametype struct syscframe
+#define eflags sf_eflags
+#define timeout_t caddr_t
+#define MONO_BUF (0xFE0B0000)
+#define CGA_BUF (0xFE0B8000)
+#endif
+
+#if defined(__386BSD__) || defined(__FreeBSD__)
+#define VIRTUAL_TTY(x) &pccons[x]
+#define CONSOLE_TTY &pccons[NCONS]
+u_short *Crtat = (u_short *)MONO_BUF;
+struct tty pccons[NCONS+1];
+void consinit(void) {scinit();}
+#include "ddb.h"
+#if NDDB > 0
+#define DDB 1
+#endif
+#endif
+
+
struct isa_driver scdriver = {
pcprobe, pcattach, "sc",
};
-#if !defined(NetBSD)
-void consinit(void)
-{
- scinit();
-}
-#endif
int pcprobe(struct isa_device *dev)
{
- u_char c;
- int again = 0;
-
/* Enable interrupts and keyboard controller */
kbd_wait();
outb(KB_STAT, KB_WRITE);
kbd_cmd(0x4D);
/* Start keyboard stuff RESET */
- kbd_cmd(KB_RESET);
- while ((c=inb(KB_DATA)) != KB_ACK) {
- if ((c == 0xFE) || (c == 0xFF)) {
- if (!again)
- printf("KEYBOARD disconnected: RECONNECT \n");
- kbd_cmd(KB_RESET);
- again = 1;
- }
+ for (;;) {
+ kbd_cmd(KB_RESET);
+ if (kbd_reply() == KB_ACK && /* command accepted */
+ kbd_reply() == 0xaa) /* self test passed */
+ break;
+ printf("Keyboard reset failed\n");
}
- kbd_wait();
return (IO_KBDSIZE);
}
@@ -317,7 +329,7 @@ int pcattach(struct isa_device *dev)
printf(" <%d virtual consoles>\n", NCONS);
else
printf("\n");
-#ifdef FAT_CURSOR
+#if defined(FAT_CURSOR)
start = 0;
end = 18;
if (crtc_vga) {
@@ -333,17 +345,17 @@ int pcattach(struct isa_device *dev)
current_default = &user_default;
for (i = 0; i < NCONS; i++) {
scp = &console[i];
- scp->scr = (u_short *)malloc(COL * ROW * 2, M_DEVBUF, M_NOWAIT);
+ scp->scr_buf = (u_short *)malloc(COL * ROW * 2, M_DEVBUF, M_NOWAIT);
scp->mode = TEXT80x25;
scp->term.esc = 0;
scp->term.std_attr = current_default->std_attr;
scp->term.rev_attr = current_default->rev_attr;
- scp->term.attr = scp->term.std_attr;
+ scp->term.cur_attr = scp->term.std_attr;
scp->border = BG_BLACK;
scp->cursor_start = start;
scp->cursor_end = end;
- scp->max_posx = COL;
- scp->max_posy = ROW;
+ scp->xsize = COL;
+ scp->ysize = ROW;
scp->bell_pitch = BELL_PITCH;
scp->bell_duration = BELL_DURATION;
scp->status = 0;
@@ -351,18 +363,17 @@ int pcattach(struct isa_device *dev)
scp->proc = NULL;
scp->smode.mode = VT_AUTO;
if (i > 0) {
- scp->crt_base = scp->crtat = scp->scr;
- fillw(scp->term.attr|scr_map[0x20],
- scp->scr, COL*ROW);
+ scp->crt_base = scp->crtat = scp->scr_buf;
+ fillw(scp->term.cur_attr|scr_map[0x20], scp->scr_buf, COL*ROW);
}
}
/* get cursor going */
-#ifdef FAT_CURSOR
+#if defined(FAT_CURSOR)
cursor_shape(console[0].cursor_start,
console[0].cursor_end);
#endif
- cursor_pos();
- return (1);
+ cursor_pos(1);
+ return 0;
}
@@ -370,15 +381,11 @@ static struct tty *get_tty_ptr(dev_t dev)
{
int unit = minor(dev);
- if (unit >= NCONS)
+ if (unit > NCONS)
return(NULL);
-#if defined(NetBSD)
- if (!pc_tty[unit])
- pc_tty[unit] = ttymalloc();
- return(pc_tty[unit]);
-#else
- return(&pccons[unit]);
-#endif
+ if (unit == NCONS)
+ return(CONSOLE_TTY);
+ return(VIRTUAL_TTY(unit));
}
@@ -386,33 +393,33 @@ static scr_stat *get_scr_stat(dev_t dev)
{
int unit = minor(dev);
- if (unit >= NCONS)
+ if (unit > NCONS)
return(NULL);
+ if (unit == NCONS)
+ return(&console[0]);
return(&console[unit]);
}
-static int get_scr_num(scr_stat *scp) /* allways call with legal scp !! */
+static int get_scr_num()
{
int i = 0;
while ((i < NCONS) && (cur_console != &console[i])) i++;
- return i;
+ return i < NCONS ? i : 0;
}
-int
-pcopen(dev_t dev, int flag, int mode, struct proc *p)
+int pcopen(dev_t dev, int flag, int mode, struct proc *p)
{
struct tty *tp = get_tty_ptr(dev);
if (!tp)
return(ENXIO);
- if (!cur_tty)
- cur_tty = tp;
- tp->t_oproc = (void*)pcstart;
+
+ tp->t_oproc = pcstart;
tp->t_param = pcparam;
tp->t_dev = dev;
- if ((tp->t_state & TS_ISOPEN) == 0) {
+ if (!(tp->t_state & TS_ISOPEN)) {
tp->t_state |= TS_WOPEN;
ttychars(tp);
tp->t_iflag = TTYDEF_IFLAG;
@@ -425,30 +432,37 @@ pcopen(dev_t dev, int flag, int mode, struct proc *p)
} else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0)
return(EBUSY);
tp->t_state |= TS_CARR_ON;
+ tp->t_cflag |= CLOCAL;
+#if defined(__FreeBSD__)
return((*linesw[tp->t_line].l_open)(dev, tp, 0));
+#else
+ return((*linesw[tp->t_line].l_open)(dev, tp));
+#endif
}
-int
-pcclose(dev_t dev, int flag, int mode, struct proc *p)
+int pcclose(dev_t dev, int flag, int mode, struct proc *p)
{
struct tty *tp = get_tty_ptr(dev);
struct scr_stat *scp;
if (!tp)
return(ENXIO);
- scp = get_scr_stat(tp->t_dev);
- scp->pid = 0;
- scp->proc = NULL;
- scp->smode.mode = VT_AUTO;
+ if (minor(dev) < NCONS) {
+ scp = get_scr_stat(tp->t_dev);
+ if (scp->status & SWITCH_WAIT_ACQ)
+ wakeup((caddr_t)&scp->smode);
+ scp->pid = 0;
+ scp->proc = NULL;
+ scp->smode.mode = VT_AUTO;
+ }
(*linesw[tp->t_line].l_close)(tp, flag);
ttyclose(tp);
return(0);
}
-int
-pcread(dev_t dev, struct uio *uio, int flag)
+int pcread(dev_t dev, struct uio *uio, int flag)
{
struct tty *tp = get_tty_ptr(dev);
@@ -458,8 +472,7 @@ pcread(dev_t dev, struct uio *uio, int flag)
}
-int
-pcwrite(dev_t dev, struct uio *uio, int flag)
+int pcwrite(dev_t dev, struct uio *uio, int flag)
{
struct tty *tp = get_tty_ptr(dev);
@@ -473,9 +486,9 @@ pcwrite(dev_t dev, struct uio *uio, int flag)
* Got a console interrupt, keyboard action !
* Catch the character, and see who it goes to.
*/
-void
-scintr(dev_t dev, int irq, int cpl)
+void scintr(int unit)
{
+ static struct tty *cur_tty;
int c, len;
u_char *cp;
@@ -484,10 +497,13 @@ scintr(dev_t dev, int irq, int cpl)
if (scrn_blanked)
scrn_saver(0);
- c = sgetc(1);
- if (!cur_tty)
- return;
- if ((cur_tty->t_state & TS_ISOPEN) == 0 || polling)
+ c = scgetc(1);
+
+ cur_tty = VIRTUAL_TTY(get_scr_num());
+ if (!(cur_tty->t_state & TS_ISOPEN))
+ cur_tty = CONSOLE_TTY;
+
+ if (!(cur_tty->t_state & TS_ISOPEN) || polling)
return;
switch (c & 0xff00) {
@@ -495,7 +511,7 @@ scintr(dev_t dev, int irq, int cpl)
(*linesw[cur_tty->t_line].l_rint)(c & 0xFF, cur_tty);
break;
case NOKEY: /* nothing there */
- return;
+ break;
case FKEY: /* function key, return string */
if (cp = get_fstr((u_int)c, (u_int *)&len)) {
while (len-- > 0)
@@ -514,8 +530,7 @@ scintr(dev_t dev, int irq, int cpl)
/*
* Set line parameters
*/
-int
-pcparam(struct tty *tp, struct termios *t)
+int pcparam(struct tty *tp, struct termios *t)
{
int cflag = t->c_cflag;
@@ -523,14 +538,11 @@ pcparam(struct tty *tp, struct termios *t)
tp->t_ispeed = t->c_ispeed;
tp->t_ospeed = t->c_ospeed;
tp->t_cflag = cflag;
- return(0);
+ return 0;
}
-#define frametype struct trapframe
-#define eflags tf_eflags
-int
-pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
+int pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
{
int i, error;
struct tty *tp;
@@ -552,44 +564,44 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
if (!crtc_vga)
return ENXIO;
scp->mode = TEXT80x25;
- scp->max_posy = 25;
- free(scp->scr, M_DEVBUF);
- scp->scr = (u_short *)malloc(scp->max_posx*scp->max_posy*2,
+ scp->ysize = 25;
+ free(scp->scr_buf, M_DEVBUF);
+ scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*2,
M_DEVBUF, M_NOWAIT);
if (scp != cur_console)
- scp->crt_base = scp->scr;
+ scp->crt_base = scp->scr_buf;
set_mode(scp);
clear_screen(scp);
- change_winsize(tp, scp->max_posx, scp->max_posy);
+ change_winsize(tp, scp->xsize, scp->ysize);
return 0;
case CONS_80x50TEXT: /* set 80x50 text mode */
if (!crtc_vga)
return ENXIO;
scp->mode = TEXT80x50;
- scp->max_posy = 50;
- free(scp->scr, M_DEVBUF);
- scp->scr = (u_short *)malloc(scp->max_posx*scp->max_posy*2,
+ scp->ysize = 50;
+ free(scp->scr_buf, M_DEVBUF);
+ scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*2,
M_DEVBUF, M_NOWAIT);
if (scp != cur_console)
- scp->crt_base = scp->scr;
+ scp->crt_base = scp->scr_buf;
set_mode(scp);
clear_screen(scp);
- change_winsize(tp, scp->max_posx, scp->max_posy);
+ change_winsize(tp, scp->xsize, scp->ysize);
return 0;
case CONS_GETVERS: /* get version number */
- *(int*)data = 0x100; /* version 1.0 */
+ *(int*)data = 0x103; /* version 1.3 */
return 0;
case CONS_GETINFO: /* get current (virtual) console info */
if (*data == sizeof(struct vid_info)) {
vid_info_t *ptr = (vid_info_t*)data;
- ptr->m_num = get_scr_num(scp);
- ptr->mv_col = scp->posx;
- ptr->mv_row = scp->posy;
- ptr->mv_csz = scp->max_posx;
- ptr->mv_rsz = scp->max_posy;
+ ptr->m_num = get_scr_num();
+ ptr->mv_col = scp->xpos;
+ ptr->mv_row = scp->ypos;
+ ptr->mv_csz = scp->xsize;
+ ptr->mv_rsz = scp->ysize;
ptr->mv_norm.fore = (scp->term.std_attr & 0x0f00)>>8;
ptr->mv_norm.back = (scp->term.std_attr & 0xf000)>>12;
ptr->mv_rev.fore = (scp->term.rev_attr & 0x0f00)>>8;
@@ -653,17 +665,14 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
/* NOT REACHED */
case VT_OPENQRY: /* return free virtual console */
- for (i = 0; i < NCONS; i++)
-#if defined(NetBSD)
- if (!(pc_tty[i]->t_state & TS_ISOPEN)) {
-#else
- if (!(pccons[i].t_state & TS_ISOPEN)) {
-#endif
+ for (i = 0; i < NCONS; i++) {
+ tp = VIRTUAL_TTY(i);
+ if (!(tp->t_state & TS_ISOPEN)) {
*data = i + 1;
return 0;
}
+ }
return EINVAL;
- /* NOT REACHED */
case VT_ACTIVATE: /* switch to screen *data */
return switch_scr((*data) - 1);
@@ -681,12 +690,12 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
}
else
while ((error=tsleep(
- (caddr_t)&console[*data-1].smode,
+ (caddr_t)&console[*(data-1)].smode,
PZERO|PCATCH, "waitvt", 0)) == ERESTART) ;
return error;
case VT_GETACTIVE:
- *data = get_scr_num(scp)+1;
+ *data = get_scr_num()+1;
return 0;
case KDENABIO: /* allow io operations */
@@ -753,12 +762,10 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
return 0;
case KDSETRAD: /* set keyboard repeat & delay rates */
- if (*(u_char*)data < 0x80) {
- kbd_cmd(KB_SETRAD);
- kbd_cmd(*data & 0x7f);
- return 0;
- }
- return EINVAL;
+ if (*data & 0x80)
+ return EINVAL;
+ kbd_cmd2(KB_SETRAD, *data);
+ return 0;
case KDSKBMODE: /* set keyboard mode */
switch (*data) {
@@ -767,6 +774,8 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
return 0;
case K_XLATE: /* switch to XLT ascii mode */
+ if (scp == cur_console && scp->status == KBD_RAW_MODE)
+ shfts = ctls = alts = agrs = metas = 0;
scp->status &= ~KBD_RAW_MODE;
return 0;
default:
@@ -902,7 +911,7 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
case CONSOLE_X_MODE_ON: /* just to be compatible */
if (saved_console < 0) {
- saved_console = get_scr_num(cur_console);
+ saved_console = get_scr_num();
switch_scr(minor(dev));
fp = (frametype *)p->p_regs;
fp->eflags |= PSL_IOPL;
@@ -956,31 +965,21 @@ pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
}
-void
-pcxint(dev_t dev)
+void pcxint(dev_t dev)
{
- int unit = minor(dev);
+ struct tty *tp = get_tty_ptr(dev);
-#if defined(NetBSD)
- if (!pc_tty[unit])
+ if (!tp)
return;
- pc_tty[unit]->t_state &= ~TS_BUSY;
- if (pc_tty[unit]->t_line)
- (*linesw[pc_tty[unit]->t_line].l_start)(pc_tty[unit]);
+ tp->t_state &= ~TS_BUSY;
+ if (tp->t_line)
+ (*linesw[tp->t_line].l_start)(tp);
else
- pcstart(pc_tty[unit]);
-#else
- pccons[unit].t_state &= ~TS_BUSY;
- if (pccons[unit].t_line)
- (*linesw[pccons[unit].t_line].l_start)(&pccons[unit]);
- else
- pcstart(&pccons[unit]);
-#endif
+ pcstart(tp);
}
-void
-pcstart(struct tty *tp)
+void pcstart(struct tty *tp)
{
#if defined(NetBSD)
struct clist *rbp;
@@ -1011,13 +1010,16 @@ pcstart(struct tty *tp)
}
selwakeup(&tp->t_wsel);
}
-
}
splx(s);
-#else
+
+#else /* __FreeBSD__ & __386BSD__ */
+
int c, s;
scr_stat *scp = get_scr_stat(tp->t_dev);
+ if (scp->status & SLKED)
+ return;
s = spltty();
if (!(tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)))
for (;;) {
@@ -1049,73 +1051,91 @@ pcstart(struct tty *tp)
}
-int
-pccnprobe(struct consdev *cp)
+void pccnprobe(struct consdev *cp)
{
int maj;
/* locate the major number */
for (maj = 0; maj < nchrdev; maj++)
- if ((void*) cdevsw[maj].d_open == (void*) pcopen)
+ if ((void*)cdevsw[maj].d_open == (void*)pcopen)
break;
/* initialize required fields */
- cp->cn_dev = makedev(maj, 0);
-#if !defined(NetBSD)
- cp->cn_tp = &pccons[0];
-#endif
+ cp->cn_dev = makedev(maj, NCONS);
cp->cn_pri = CN_INTERNAL;
- return (1);
+#if defined(__FreeBSD__) || defined(__386BSD__)
+ cp->cn_tp = CONSOLE_TTY;
+#endif
}
-int
-pccninit(struct consdev *cp)
+void pccninit(struct consdev *cp)
{
scinit();
- return (1);
}
-void
-pccnputc(dev_t dev, char c)
+void pccnputc(dev_t dev, char c)
{
- int pos;
-
- if (cur_console->status & UNKNOWN_MODE)
- return;
if (c == '\n')
- sput('\r');
- sput(c);
- pos = cur_console->crtat - cur_console->crt_base;
- if (pos != cur_cursor_pos) {
- cur_cursor_pos = pos;
- outb(crtc_addr,14);
- outb(crtc_addr+1,pos >> 8);
- outb(crtc_addr,15);
- outb(crtc_addr+1,pos&0xff);
+ scput('\r');
+ scput(c);
+ if (cur_console == &console[0]) {
+ int pos = cur_console->crtat - cur_console->crt_base;
+ if (pos != cur_cursor_pos) {
+ cur_cursor_pos = pos;
+ outb(crtc_addr,14);
+ outb(crtc_addr+1,pos >> 8);
+ outb(crtc_addr,15);
+ outb(crtc_addr+1,pos&0xff);
+ }
}
}
-int
-pccngetc(dev_t dev)
+int pccngetc(dev_t dev)
{
- int c, s;
-
- s = spltty(); /* block scintr while we poll */
- c = sgetc(0);
+ int s = spltty(); /* block scintr while we poll */
+ int c = scgetc(0);
splx(s);
if (c == '\r') c = '\n';
return(c);
}
-#if !defined(STAR_SAVER) && !defined(SNAKE_SAVER)
-
+#if defined(FADE_SAVER)
static void scrn_saver(int test)
{
- u_char val;
+ static int count = 0;
+ int i;
+
+ if (test) {
+ scrn_blanked = 1;
+ if (count < 64) {
+ outb(PIXMASK, 0xFF); /* no pixelmask */
+ outb(PALWADR, 0x00);
+ outb(PALDATA, 0);
+ outb(PALDATA, 0);
+ outb(PALDATA, 0);
+ for (i = 3; i < 768; i++) {
+ if (palette[i] - count > 15)
+ outb(PALDATA, palette[i]-count);
+ else
+ outb(PALDATA, 15);
+ }
+ inb(crtc_addr+6); /* reset flip/flop */
+ outb(ATC, 0x20); /* enable palette */
+ count++;
+ }
+ }
+ else {
+ count = scrn_blanked = 0;
+ load_palette();
+ }
+}
+#endif
+#if defined(BLANK_SAVER)
+ u_char val;
if (test) {
scrn_blanked = 1;
outb(TSIDX, 0x01); val = inb(TSREG);
@@ -1126,18 +1146,16 @@ static void scrn_saver(int test)
outb(TSIDX, 0x01); val = inb(TSREG);
outb(TSIDX, 0x01); outb(TSREG, val & 0xDF);
}
-}
#endif
-#if defined(STAR_SAVER) || defined(SNAKE_SAVER)
+#if defined(STAR_SAVER)
static u_long rand_next = 1;
static int rand()
{
return ((rand_next = rand_next * 1103515245 + 12345) & 0x7FFFFFFF);
}
-#endif
-#if defined(STAR_SAVER) && !defined(SNAKE_SAVER)
+
/*
* Alternate saver that got its inspiration from a well known utility
* package for an unfamous OS.
@@ -1156,12 +1174,12 @@ static void scrn_saver(int test)
if (test) {
if (!scrn_blanked) {
- bcopy(Crtat, scp->scr,
- scp->max_posx * scp->max_posy * 2);
- fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20],
- Crtat, scp->max_posx * scp->max_posy);
+ bcopy(Crtat, scp->scr_buf,
+ scp->xsize * scp->ysize * 2);
+ fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20], Crtat,
+ scp->xsize * scp->ysize);
set_border(0);
- i = scp->max_posy * scp->max_posx + 5;
+ i = scp->ysize * scp->xsize + 5;
outb(crtc_addr, 14);
outb(crtc_addr+1, i >> 8);
outb(crtc_addr, 15);
@@ -1169,7 +1187,7 @@ static void scrn_saver(int test)
scrn_blanked = 1;
for(i=0; i<NUM_STARS; i++) {
stars[i][0] =
- rand() % (scp->max_posx*scp->max_posy);
+ rand() % (scp->xsize*scp->ysize);
stars[i][1] = 0;
}
}
@@ -1178,13 +1196,13 @@ static void scrn_saver(int test)
scr_map[pattern[stars[cell][1]]] |
colors[rand()%sizeof(colors)] << 8;
if ((stars[cell][1]+=(rand()%4)) >= sizeof(pattern)-1) {
- stars[cell][0] = rand() % (scp->max_posx*scp->max_posy);
+ stars[cell][0] = rand() % (scp->xsize*scp->ysize);
stars[cell][1] = 0;
}
}
else {
if (scrn_blanked) {
- bcopy(scp->scr, Crtat, scp->max_posx*scp->max_posy*2);
+ bcopy(scp->scr_buf, Crtat, scp->xsize*scp->ysize*2);
cur_cursor_pos = -1;
set_border(scp->border);
scrn_blanked = 0;
@@ -1192,70 +1210,7 @@ static void scrn_saver(int test)
}
}
#endif
-#if defined(SNAKE_SAVER) && !defined(STAR_SAVER)
-/*
- * alternative screen saver for cards that do not like blanking
- */
-static void scrn_saver(int test)
-{
- const char saves[] = {"FreeBSD"};
- static u_char *savs[sizeof(saves)-1];
- static int dirx, diry;
- int f;
- scr_stat *scp = cur_console;
-
- if (test) {
- if (!scrn_blanked) {
- bcopy(Crtat, scp->scr,
- scp->max_posx * scp->max_posy * 2);
- fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20],
- Crtat, scp->max_posx * scp->max_posy);
- set_border(0);
- dirx = (scp->posx ? 1 : -1);
- diry = (scp->posy ?
- scp->max_posx : -scp->max_posx);
- for (f=0; f< sizeof(saves)-1; f++)
- savs[f] = (u_char *)Crtat + 2 *
- (scp->posx+scp->posy*scp->max_posx);
- *(savs[0]) = scr_map[*saves];
- f = scp->max_posy * scp->max_posx + 5;
- outb(crtc_addr, 14);
- outb(crtc_addr+1, f >> 8);
- outb(crtc_addr, 15);
- outb(crtc_addr+1, f & 0xff);
- scrn_blanked = 1;
- }
- if (scrn_blanked++ < 4)
- return;
- scrn_blanked = 1;
- *(savs[sizeof(saves)-2]) = scr_map[0x20];
- for (f=sizeof(saves)-2; f > 0; f--)
- savs[f] = savs[f-1];
- f = (savs[0] - (u_char *)Crtat) / 2;
- if ((f % scp->max_posx) == 0 ||
- (f % scp->max_posx) == scp->max_posx - 1 ||
- (rand() % 50) == 0)
- dirx = -dirx;
- if ((f / scp->max_posx) == 0 ||
- (f / scp->max_posx) == scp->max_posy - 1 ||
- (rand() % 20) == 0)
- diry = -diry;
- savs[0] += 2*dirx + 2*diry;
- for (f=sizeof(saves)-2; f>=0; f--)
- *(savs[f]) = scr_map[saves[f]];
- }
- else {
- if (scrn_blanked) {
- bcopy(scp->scr, Crtat,
- scp->max_posx * scp->max_posy * 2);
- cur_cursor_pos = -1;
- set_border(scp->border);
- scrn_blanked = 0;
- }
- }
-}
-#endif
static void cursor_shape(int start, int end)
{
@@ -1266,6 +1221,7 @@ static void cursor_shape(int start, int end)
}
+#if !defined(FAT_CURSOR)
static void get_cursor_shape(int *start, int *end)
{
outb(crtc_addr, 10);
@@ -1273,50 +1229,61 @@ static void get_cursor_shape(int *start, int *end)
outb(crtc_addr, 11);
*end = inb(crtc_addr+1) & 0x1F;
}
+#endif
-int cursor_pos(void)
+static void cursor_pos(int force)
{
int pos;
if (cur_console->status & UNKNOWN_MODE)
- return (0);
+ return;
if (scrn_blank_time && (time.tv_sec > scrn_time_stamp+scrn_blank_time))
scrn_saver(1);
pos = cur_console->crtat - cur_console->crt_base;
- if (!scrn_blanked && pos != cur_cursor_pos) {
+ if (force || (!scrn_blanked && pos != cur_cursor_pos)) {
cur_cursor_pos = pos;
outb(crtc_addr, 14);
outb(crtc_addr+1, pos>>8);
outb(crtc_addr, 15);
outb(crtc_addr+1, pos&0xff);
}
- timeout((timeout_func_t)cursor_pos, 0, hz/20);
- return (0);
+ timeout((timeout_t)cursor_pos, 0, hz/20);
}
static void clear_screen(scr_stat *scp)
{
move_crsr(scp, 0, 0);
- fillw(scp->term.attr | scr_map[0x20], scp->crt_base,
- scp->max_posx * scp->max_posy);
+ fillw(scp->term.cur_attr | scr_map[0x20], scp->crt_base,
+ scp->xsize * scp->ysize);
}
static int switch_scr(u_int next_scr)
{
- if (in_putc) { /* don't switch if in putc */
- nx_scr = next_scr+1;
+ if (in_putc) { /* delay switch if in putc */
+ delayed_next_scr = next_scr+1;
return 0;
}
if (switch_in_progress &&
(cur_console->proc != pfind(cur_console->pid)))
switch_in_progress = 0;
- if (next_scr >= NCONS || switch_in_progress) {
+
+ if (next_scr >= NCONS || switch_in_progress) {
sysbeep(BELL_PITCH, BELL_DURATION);
return EINVAL;
}
+
+ /* is the wanted virtual console open ? */
+ if (next_scr) {
+ struct tty *tp = VIRTUAL_TTY(next_scr);
+ if (!(tp->t_state & TS_ISOPEN)) {
+ sysbeep(BELL_PITCH, BELL_DURATION);
+ return EINVAL;
+ }
+ }
+
switch_in_progress = 1;
old_scp = cur_console;
new_scp = &console[next_scr];
@@ -1352,33 +1319,30 @@ static int switch_scr(u_int next_scr)
static void exchange_scr(void)
{
- bcopy(Crtat, old_scp->scr, old_scp->max_posx * old_scp->max_posy * 2);
- old_scp->crt_base = old_scp->scr;
- move_crsr(old_scp, old_scp->posx, old_scp->posy);
+ struct tty *tp;
+
+ bcopy(Crtat, old_scp->scr_buf, old_scp->xsize * old_scp->ysize * 2);
+ old_scp->crt_base = old_scp->scr_buf;
+ move_crsr(old_scp, old_scp->xpos, old_scp->ypos);
cur_console = new_scp;
-#if defined(NetBSD)
- cur_tty = pc_tty[get_scr_num(new_scp)];
-#else
- cur_tty = &pccons[get_scr_num(new_scp)];
-#endif
- if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE)
- shfts = ctls = alts = agrs = metas = 0;
- update_leds(new_scp->status & LED_MASK);
set_mode(new_scp);
new_scp->crt_base = Crtat;
- move_crsr(new_scp, new_scp->posx, new_scp->posy);
- bcopy(new_scp->scr, Crtat, new_scp->max_posx * new_scp->max_posy * 2);
- nx_scr = 0;
+ move_crsr(new_scp, new_scp->xpos, new_scp->ypos);
+ bcopy(new_scp->scr_buf, Crtat, new_scp->xsize * new_scp->ysize * 2);
+ update_leds(new_scp->status & LED_MASK);
+ if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE)
+ shfts = ctls = alts = agrs = metas = 0;
+ delayed_next_scr = 0;
}
static void move_crsr(scr_stat *scp, int x, int y)
{
- if (x < 0 || y < 0 || x >= scp->max_posx || y >= scp->max_posy)
+ if (x < 0 || y < 0 || x >= scp->xsize || y >= scp->ysize)
return;
- scp->posx = x;
- scp->posy = y;
- scp->crtat = scp->crt_base + scp->posy * scp->max_posx + scp->posx;
+ scp->xpos = x;
+ scp->ypos = y;
+ scp->crtat = scp->crt_base + scp->ypos * scp->xsize + scp->xpos;
}
@@ -1410,21 +1374,21 @@ static void scan_esc(scr_stat *scp, u_char c)
case '[': /* Start ESC [ sequence */
scp->term.esc = 2;
- scp->term.last_par = -1;
- for (i = scp->term.n_par; i < MAX_ESC_PAR; i++)
- scp->term.par[i] = 1;
- scp->term.n_par = 0;
+ scp->term.last_param = -1;
+ for (i = scp->term.num_param; i < MAX_ESC_PAR; i++)
+ scp->term.param[i] = 1;
+ scp->term.num_param = 0;
return;
case 'M': /* Move cursor up 1 line, scroll if at top */
- if (scp->posy > 0)
- move_crsr(scp, scp->posx, scp->posy - 1);
+ if (scp->ypos > 0)
+ move_crsr(scp, scp->xpos, scp->ypos - 1);
else {
move_up(scp->crt_base,
- scp->crt_base + scp->max_posx,
- (scp->max_posy - 1) * scp->max_posx);
- fillw(scp->term.attr | scr_map[0x20],
- scp->crt_base, scp->max_posx);
+ scp->crt_base + scp->xsize,
+ (scp->ysize - 1) * scp->xsize);
+ fillw(scp->term.cur_attr | scr_map[0x20],
+ scp->crt_base, scp->xsize);
}
break;
#if notyet
@@ -1439,86 +1403,86 @@ static void scan_esc(scr_stat *scp, u_char c)
}
else if (scp->term.esc == 2) {
if (c >= '0' && c <= '9') {
- if (scp->term.n_par < MAX_ESC_PAR) {
- if (scp->term.last_par != scp->term.n_par) {
- scp->term.last_par = scp->term.n_par;
- scp->term.par[scp->term.n_par] = 0;
+ if (scp->term.num_param < MAX_ESC_PAR) {
+ if (scp->term.last_param != scp->term.num_param) {
+ scp->term.last_param = scp->term.num_param;
+ scp->term.param[scp->term.num_param] = 0;
}
else
- scp->term.par[scp->term.n_par] *= 10;
- scp->term.par[scp->term.n_par] += c - '0';
+ scp->term.param[scp->term.num_param] *= 10;
+ scp->term.param[scp->term.num_param] += c - '0';
return;
}
}
- scp->term.n_par = scp->term.last_par + 1;
+ scp->term.num_param = scp->term.last_param + 1;
switch (c) {
case ';':
- if (scp->term.n_par < MAX_ESC_PAR)
+ if (scp->term.num_param < MAX_ESC_PAR)
return;
break;
case '=':
scp->term.esc = 3;
- scp->term.last_par = -1;
- for (i = scp->term.n_par; i < MAX_ESC_PAR; i++)
- scp->term.par[i] = 1;
- scp->term.n_par = 0;
+ scp->term.last_param = -1;
+ for (i = scp->term.num_param; i < MAX_ESC_PAR; i++)
+ scp->term.param[i] = 1;
+ scp->term.num_param = 0;
return;
case 'A': /* up n rows */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx, scp->posy - n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos, scp->ypos - n);
break;
case 'B': /* down n rows */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx, scp->posy + n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos, scp->ypos + n);
break;
case 'C': /* right n columns */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx + n, scp->posy);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos + n, scp->ypos);
break;
case 'D': /* left n columns */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx - n, scp->posy);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos - n, scp->ypos);
break;
case 'E': /* cursor to start of line n lines down */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, 0, scp->posy + n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, 0, scp->ypos + n);
break;
case 'F': /* cursor to start of line n lines up */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, 0, scp->posy - n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, 0, scp->ypos - n);
break;
case 'f': /* System V consoles .. */
case 'H': /* Cursor move */
- if (scp->term.n_par == 0)
+ if (scp->term.num_param == 0)
move_crsr(scp, 0, 0);
- else if (scp->term.n_par == 2)
- move_crsr(scp, scp->term.par[1] - 1,
- scp->term.par[0] - 1);
+ else if (scp->term.num_param == 2)
+ move_crsr(scp, scp->term.param[1] - 1,
+ scp->term.param[0] - 1);
break;
case 'J': /* Clear all or part of display */
- if (scp->term.n_par == 0)
+ if (scp->term.num_param == 0)
n = 0;
else
- n = scp->term.par[0];
+ n = scp->term.param[0];
switch (n) {
case 0: /* clear form cursor to end of display */
- fillw(scp->term.attr | scr_map[0x20],
+ fillw(scp->term.cur_attr | scr_map[0x20],
scp->crtat, scp->crt_base +
- scp->max_posx * scp->max_posy -
+ scp->xsize * scp->ysize -
scp->crtat);
break;
case 1: /* clear from beginning of display to cursor */
- fillw(scp->term.attr | scr_map[0x20],
+ fillw(scp->term.cur_attr | scr_map[0x20],
scp->crt_base,
scp->crtat - scp->crt_base);
break;
@@ -1529,259 +1493,259 @@ static void scan_esc(scr_stat *scp, u_char c)
break;
case 'K': /* Clear all or part of line */
- if (scp->term.n_par == 0)
+ if (scp->term.num_param == 0)
n = 0;
else
- n = scp->term.par[0];
+ n = scp->term.param[0];
switch (n) {
case 0: /* clear form cursor to end of line */
- fillw(scp->term.attr | scr_map[0x20],
- scp->crtat, scp->max_posx - scp->posx);
+ fillw(scp->term.cur_attr | scr_map[0x20],
+ scp->crtat, scp->xsize - scp->xpos);
break;
case 1: /* clear from beginning of line to cursor */
- fillw(scp->term.attr|scr_map[0x20],
- scp->crtat - (scp->max_posx - scp->posx),
- (scp->max_posx - scp->posx) + 1);
+ fillw(scp->term.cur_attr|scr_map[0x20],
+ scp->crtat - (scp->xsize - scp->xpos),
+ (scp->xsize - scp->xpos) + 1);
break;
case 2: /* clear entire line */
- fillw(scp->term.attr|scr_map[0x20],
- scp->crtat - (scp->max_posx - scp->posx),
- scp->max_posx);
+ fillw(scp->term.cur_attr|scr_map[0x20],
+ scp->crtat - (scp->xsize - scp->xpos),
+ scp->xsize);
break;
}
break;
case 'L': /* Insert n lines */
- n = scp->term.par[0]; if (n < 1) n = 1;
- if (n > scp->max_posy - scp->posy)
- n = scp->max_posy - scp->posy;
- src = scp->crt_base + scp->posy * scp->max_posx;
- dst = src + n * scp->max_posx;
- count = scp->max_posy - (scp->posy + n);
- move_up(src, dst, count * scp->max_posx);
- fillw(scp->term.attr | scr_map[0x20], src,
- n * scp->max_posx);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ if (n > scp->ysize - scp->ypos)
+ n = scp->ysize - scp->ypos;
+ src = scp->crt_base + scp->ypos * scp->xsize;
+ dst = src + n * scp->xsize;
+ count = scp->ysize - (scp->ypos + n);
+ move_up(src, dst, count * scp->xsize);
+ fillw(scp->term.cur_attr | scr_map[0x20], src,
+ n * scp->xsize);
break;
case 'M': /* Delete n lines */
- n = scp->term.par[0]; if (n < 1) n = 1;
- if (n > scp->max_posy - scp->posy)
- n = scp->max_posy - scp->posy;
- dst = scp->crt_base + scp->posy * scp->max_posx;
- src = dst + n * scp->max_posx;
- count = scp->max_posy - (scp->posy + n);
- move_down(src, dst, count * scp->max_posx);
- src = dst + count * scp->max_posx;
- fillw(scp->term.attr | scr_map[0x20], src,
- n * scp->max_posx);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ if (n > scp->ysize - scp->ypos)
+ n = scp->ysize - scp->ypos;
+ dst = scp->crt_base + scp->ypos * scp->xsize;
+ src = dst + n * scp->xsize;
+ count = scp->ysize - (scp->ypos + n);
+ move_down(src, dst, count * scp->xsize);
+ src = dst + count * scp->xsize;
+ fillw(scp->term.cur_attr | scr_map[0x20], src,
+ n * scp->xsize);
break;
case 'P': /* Delete n chars */
- n = scp->term.par[0]; if (n < 1) n = 1;
- if (n > scp->max_posx - scp->posx)
- n = scp->max_posx - scp->posx;
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ if (n > scp->xsize - scp->xpos)
+ n = scp->xsize - scp->xpos;
dst = scp->crtat;
src = dst + n;
- count = scp->max_posx - (scp->posx + n);
+ count = scp->xsize - (scp->xpos + n);
move_down(src, dst, count);
src = dst + count;
- fillw(scp->term.attr | scr_map[0x20], src, n);
+ fillw(scp->term.cur_attr | scr_map[0x20], src, n);
break;
case '@': /* Insert n chars */
- n = scp->term.par[0]; if (n < 1) n = 1;
- if (n > scp->max_posx - scp->posx)
- n = scp->max_posx - scp->posx;
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ if (n > scp->xsize - scp->xpos)
+ n = scp->xsize - scp->xpos;
src = scp->crtat;
dst = src + n;
- count = scp->max_posx - (scp->posx + n);
+ count = scp->xsize - (scp->xpos + n);
move_up(src, dst, count);
- fillw(scp->term.attr | scr_map[0x20], src, n);
+ fillw(scp->term.cur_attr | scr_map[0x20], src, n);
break;
case 'S': /* scroll up n lines */
- n = scp->term.par[0]; if (n < 1) n = 1;
- bcopy(scp->crt_base + (scp->max_posx * n),
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ bcopy(scp->crt_base + (scp->xsize * n),
scp->crt_base,
- scp->max_posx * (scp->max_posy - n) *
+ scp->xsize * (scp->ysize - n) *
sizeof(u_short));
- fillw(scp->term.attr | scr_map[0x20],
- scp->crt_base + scp->max_posx *
- (scp->max_posy - 1),
- scp->max_posx);
+ fillw(scp->term.cur_attr | scr_map[0x20],
+ scp->crt_base + scp->xsize *
+ (scp->ysize - 1),
+ scp->xsize);
break;
case 'T': /* scroll down n lines */
- n = scp->term.par[0]; if (n < 1) n = 1;
+ n = scp->term.param[0]; if (n < 1) n = 1;
bcopy(scp->crt_base,
- scp->crt_base + (scp->max_posx * n),
- scp->max_posx * (scp->max_posy - n) *
+ scp->crt_base + (scp->xsize * n),
+ scp->xsize * (scp->ysize - n) *
sizeof(u_short));
- fillw(scp->term.attr | scr_map[0x20],
- scp->crt_base, scp->max_posx);
+ fillw(scp->term.cur_attr | scr_map[0x20], scp->crt_base,
+ scp->xsize);
break;
case 'X': /* delete n characters in line */
- n = scp->term.par[0]; if (n < 1) n = 1;
- fillw(scp->term.attr | scr_map[0x20],
- scp->crt_base + scp->posx +
- ((scp->max_posx*scp->posy) * sizeof(u_short)), n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ fillw(scp->term.cur_attr | scr_map[0x20],
+ scp->crt_base + scp->xpos +
+ ((scp->xsize*scp->ypos) * sizeof(u_short)), n);
break;
case 'Z': /* move n tabs backwards */
- n = scp->term.par[0]; if (n < 1) n = 1;
- if ((i = scp->posx & 0xf8) == scp->posx)
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ if ((i = scp->xpos & 0xf8) == scp->xpos)
i -= 8*n;
else
i -= 8*(n-1);
if (i < 0)
i = 0;
- move_crsr(scp, i, scp->posy);
+ move_crsr(scp, i, scp->ypos);
break;
case '`': /* move cursor to column n */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, n, scp->posy);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, n, scp->ypos);
break;
case 'a': /* move cursor n columns to the right */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx + n, scp->posy);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos + n, scp->ypos);
break;
case 'd': /* move cursor to row n */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx, n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos, n);
break;
case 'e': /* move cursor n rows down */
- n = scp->term.par[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->posx, scp->posy + n);
+ n = scp->term.param[0]; if (n < 1) n = 1;
+ move_crsr(scp, scp->xpos, scp->ypos + n);
break;
case 'm': /* change attribute */
- if (scp->term.n_par == 0)
+ if (scp->term.num_param == 0)
n = 0;
else
- n = scp->term.par[0];
+ n = scp->term.param[0];
switch (n) {
case 0: /* back to normal */
- scp->term.attr = scp->term.std_attr;
+ scp->term.cur_attr = scp->term.std_attr;
break;
case 1: /* highlight (bold) */
- scp->term.attr &= 0xFF00;
- scp->term.attr |= 0x0800;
+ scp->term.cur_attr &= 0xFF00;
+ scp->term.cur_attr |= 0x0800;
break;
case 4: /* highlight (underline) */
- scp->term.attr &= 0x0F00;
- scp->term.attr |= 0x0800;
+ scp->term.cur_attr &= 0x0F00;
+ scp->term.cur_attr |= 0x0800;
break;
case 5: /* blink */
- scp->term.attr &= 0xFF00;
- scp->term.attr |= 0x8000;
+ scp->term.cur_attr &= 0xFF00;
+ scp->term.cur_attr |= 0x8000;
break;
case 7: /* reverse video */
- scp->term.attr = scp->term.rev_attr;
+ scp->term.cur_attr = scp->term.rev_attr;
break;
case 30: case 31: case 32: case 33: /* set fg color */
case 34: case 35: case 36: case 37:
- scp->term.attr = (scp->term.attr & 0xF0FF)
+ scp->term.cur_attr = (scp->term.cur_attr & 0xF0FF)
| (ansi_col[(n - 30) & 7] << 8);
break;
case 40: case 41: case 42: case 43: /* set bg color */
case 44: case 45: case 46: case 47:
- scp->term.attr = (scp->term.attr & 0x0FFF)
+ scp->term.cur_attr = (scp->term.cur_attr & 0x0FFF)
| (ansi_col[(n - 40) & 7] << 12);
break;
}
break;
case 'x':
- if (scp->term.n_par == 0)
+ if (scp->term.num_param == 0)
n = 0;
else
- n = scp->term.par[0];
+ n = scp->term.param[0];
switch (n) {
case 0: /* reset attributes */
- scp->term.attr = scp->term.std_attr =
+ scp->term.cur_attr = scp->term.std_attr =
current_default->std_attr;
scp->term.rev_attr = current_default->rev_attr;
break;
case 1: /* set ansi background */
- scp->term.attr = scp->term.std_attr =
+ scp->term.cur_attr = scp->term.std_attr =
(scp->term.std_attr & 0x0F00) |
- (ansi_col[(scp->term.par[1])&0x0F]<<12);
+ (ansi_col[(scp->term.param[1])&0x0F]<<12);
break;
case 2: /* set ansi foreground */
- scp->term.attr = scp->term.std_attr =
+ scp->term.cur_attr = scp->term.std_attr =
(scp->term.std_attr & 0xF000) |
- (ansi_col[(scp->term.par[1])&0x0F]<<8);
+ (ansi_col[(scp->term.param[1])&0x0F]<<8);
break;
case 3: /* set ansi attribute directly */
- scp->term.attr = scp->term.std_attr =
- (scp->term.par[1]&0xFF)<<8;
+ scp->term.cur_attr = scp->term.std_attr =
+ (scp->term.param[1]&0xFF)<<8;
break;
case 5: /* set ansi reverse video background */
scp->term.rev_attr =
(scp->term.rev_attr & 0x0F00) |
- (ansi_col[(scp->term.par[1])&0x0F]<<12);
+ (ansi_col[(scp->term.param[1])&0x0F]<<12);
break;
case 6: /* set ansi reverse video foreground */
scp->term.rev_attr =
(scp->term.rev_attr & 0xF000) |
- (ansi_col[(scp->term.par[1])&0x0F]<<8);
+ (ansi_col[(scp->term.param[1])&0x0F]<<8);
break;
case 7: /* set ansi reverse video directly */
- scp->term.rev_attr = (scp->term.par[1]&0xFF)<<8;
+ scp->term.rev_attr = (scp->term.param[1]&0xFF)<<8;
break;
}
break;
case 'z': /* switch to (virtual) console n */
- if (scp->term.n_par == 1)
- switch_scr(scp->term.par[0]);
+ if (scp->term.num_param == 1)
+ switch_scr(scp->term.param[0]);
break;
}
}
else if (scp->term.esc == 3) {
if (c >= '0' && c <= '9') {
- if (scp->term.n_par < MAX_ESC_PAR) {
- if (scp->term.last_par != scp->term.n_par) {
- scp->term.last_par = scp->term.n_par;
- scp->term.par[scp->term.n_par] = 0;
+ if (scp->term.num_param < MAX_ESC_PAR) {
+ if (scp->term.last_param != scp->term.num_param) {
+ scp->term.last_param = scp->term.num_param;
+ scp->term.param[scp->term.num_param] = 0;
}
else
- scp->term.par[scp->term.n_par] *= 10;
- scp->term.par[scp->term.n_par] += c - '0';
+ scp->term.param[scp->term.num_param] *= 10;
+ scp->term.param[scp->term.num_param] += c - '0';
return;
}
}
- scp->term.n_par = scp->term.last_par + 1;
+ scp->term.num_param = scp->term.last_param + 1;
switch (c) {
case ';':
- if (scp->term.n_par < MAX_ESC_PAR)
+ if (scp->term.num_param < MAX_ESC_PAR)
return;
break;
case 'A': /* set display border color */
- if (scp->term.n_par == 1)
- scp->border=scp->term.par[0] & 0xff;
+ if (scp->term.num_param == 1)
+ scp->border=scp->term.param[0] & 0xff;
if (scp == cur_console)
set_border(scp->border);
break;
case 'B': /* set bell pitch and duration */
- if (scp->term.n_par == 2) {
- scp->bell_pitch = scp->term.par[0];
- scp->bell_duration = scp->term.par[1]*10;
+ if (scp->term.num_param == 2) {
+ scp->bell_pitch = scp->term.param[0];
+ scp->bell_duration = scp->term.param[1]*10;
}
break;
case 'C': /* set cursor shape (start & end line) */
- if (scp->term.n_par == 2) {
- scp->cursor_start = scp->term.par[0] & 0x1F;
- scp->cursor_end = scp->term.par[1] & 0x1F;
+ if (scp->term.num_param == 2) {
+ scp->cursor_start = scp->term.param[0] & 0x1F;
+ scp->cursor_end = scp->term.param[1] & 0x1F;
if (scp == cur_console)
cursor_shape(scp->cursor_start,
scp->cursor_end);
@@ -1789,31 +1753,31 @@ static void scan_esc(scr_stat *scp, u_char c)
break;
case 'F': /* set ansi foreground */
- if (scp->term.n_par == 1)
- scp->term.attr = scp->term.std_attr =
+ if (scp->term.num_param == 1)
+ scp->term.cur_attr = scp->term.std_attr =
(scp->term.std_attr & 0xF000)
- | ((scp->term.par[0] & 0x0F) << 8);
+ | ((scp->term.param[0] & 0x0F) << 8);
break;
case 'G': /* set ansi background */
- if (scp->term.n_par == 1)
- scp->term.attr = scp->term.std_attr =
+ if (scp->term.num_param == 1)
+ scp->term.cur_attr = scp->term.std_attr =
(scp->term.std_attr & 0x0F00)
- | ((scp->term.par[0] & 0x0F) << 12);
+ | ((scp->term.param[0] & 0x0F) << 12);
break;
case 'H': /* set ansi reverse video foreground */
- if (scp->term.n_par == 1)
+ if (scp->term.num_param == 1)
scp->term.rev_attr =
(scp->term.rev_attr & 0xF000)
- | ((scp->term.par[0] & 0x0F) << 8);
+ | ((scp->term.param[0] & 0x0F) << 8);
break;
case 'I': /* set ansi reverse video background */
- if (scp->term.n_par == 1)
+ if (scp->term.num_param == 1)
scp->term.rev_attr =
(scp->term.rev_attr & 0x0F00)
- | ((scp->term.par[0] & 0x0F) << 12);
+ | ((scp->term.param[0] & 0x0F) << 12);
break;
}
}
@@ -1826,71 +1790,73 @@ static void ansi_put(scr_stat *scp, u_char c)
if (scp->status & UNKNOWN_MODE)
return;
+#if defined(STAR_SAVER)
/* make screensaver happy */
if (scp == cur_console) {
scrn_time_stamp = time.tv_sec;
if (scrn_blanked)
scrn_saver(0);
}
+#endif
in_putc++;
if (scp->term.esc)
scan_esc(scp, c);
else switch(c) {
case 0x1B: /* start escape sequence */
scp->term.esc = 1;
- scp->term.n_par = 0;
+ scp->term.num_param = 0;
break;
case 0x07:
if (scp == cur_console)
sysbeep(scp->bell_pitch, scp->bell_duration);
break;
case '\t': /* non-destructive tab */
- scp->crtat += (8 - scp->posx % 8);
- scp->posx += (8 - scp->posx % 8);
+ scp->crtat += (8 - scp->xpos % 8);
+ scp->xpos += (8 - scp->xpos % 8);
break;
case '\b': /* non-destructive backspace */
if (scp->crtat > scp->crt_base) {
scp->crtat--;
- if (scp->posx > 0)
- scp->posx--;
+ if (scp->xpos > 0)
+ scp->xpos--;
else {
- scp->posx += scp->max_posx - 1;
- scp->posy--;
+ scp->xpos += scp->xsize - 1;
+ scp->ypos--;
}
}
break;
case '\r': /* return to pos 0 */
- move_crsr(scp, 0, scp->posy);
+ move_crsr(scp, 0, scp->ypos);
break;
case '\n': /* newline, same pos */
- scp->crtat += scp->max_posx;
- scp->posy++;
+ scp->crtat += scp->xsize;
+ scp->ypos++;
break;
case '\f': /* form feed, clears screen */
clear_screen(scp);
break;
default:
/* Print only printables */
- *scp->crtat = (scp->term.attr | scr_map[c]);
+ *scp->crtat = (scp->term.cur_attr | scr_map[c]);
scp->crtat++;
- if (++scp->posx >= scp->max_posx) {
- scp->posx = 0;
- scp->posy++;
+ if (++scp->xpos >= scp->xsize) {
+ scp->xpos = 0;
+ scp->ypos++;
}
break;
}
- if (scp->crtat >= scp->crt_base + scp->max_posy * scp->max_posx) {
- bcopy(scp->crt_base + scp->max_posx, scp->crt_base,
- scp->max_posx * (scp->max_posy - 1) * sizeof(u_short));
- fillw(scp->term.attr | scr_map[0x20],
- scp->crt_base + scp->max_posx
- * (scp->max_posy - 1), scp->max_posx);
- scp->crtat -= scp->max_posx;
- scp->posy--;
+ if (scp->crtat >= scp->crt_base + scp->ysize * scp->xsize) {
+ bcopy(scp->crt_base + scp->xsize, scp->crt_base,
+ scp->xsize * (scp->ysize - 1) * sizeof(u_short));
+ fillw(scp->term.cur_attr | scr_map[0x20],
+ scp->crt_base + scp->xsize * (scp->ysize - 1),
+ scp->xsize);
+ scp->crtat -= scp->xsize;
+ scp->ypos--;
}
in_putc--;
- if (nx_scr)
- switch_scr(nx_scr - 1);
+ if (delayed_next_scr)
+ switch_scr(delayed_next_scr - 1);
}
static void scinit(void)
@@ -1908,7 +1874,7 @@ static void scinit(void)
/*
* Crtat initialized to point to MONO buffer, if not present change
* to CGA_BUF offset. ONLY ADD the difference since locore.s adds
- * in the remapped offset at the right time
+ * in the remapped offset at the "right" time
*/
was = *cp;
*cp = (u_short) 0xA55A;
@@ -1938,12 +1904,12 @@ static void scinit(void)
console[0].term.esc = 0;
console[0].term.std_attr = current_default->std_attr;
console[0].term.rev_attr = current_default->rev_attr;
- console[0].term.attr = current_default->std_attr;
- console[0].posx = cursorat % COL;
- console[0].posy = cursorat / COL;
+ console[0].term.cur_attr = current_default->std_attr;
+ console[0].xpos = cursorat % COL;
+ console[0].ypos = cursorat / COL;
console[0].border = BG_BLACK;;
- console[0].max_posx = COL;
- console[0].max_posy = ROW;
+ console[0].xsize = COL;
+ console[0].ysize = ROW;
console[0].status = 0;
console[0].pid = 0;
console[0].proc = NULL;
@@ -1953,15 +1919,15 @@ static void scinit(void)
kernel_console.esc = 0;
kernel_console.std_attr = kernel_default.std_attr;
kernel_console.rev_attr = kernel_default.rev_attr;
- kernel_console.attr = kernel_default.std_attr;
- /* initialize mapscrn array to */
+ kernel_console.cur_attr = kernel_default.std_attr;
+ /* initialize mapscrn array to a one to one map */
for (i=0; i<sizeof(scr_map); i++)
scr_map[i] = i;
clear_screen(&console[0]);
}
-static void sput(u_char c)
+static void scput(u_char c)
{
scr_stat *scp = &console[0];
term_stat save;
@@ -1994,29 +1960,17 @@ static u_char *get_fstr(u_int c, u_int *len)
static void update_leds(int which)
{
- u_char xlate_leds[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
-
- kbd_cmd(KB_SETLEDS); /* LED Command */
- kbd_cmd(xlate_leds[which & LED_MASK]);
- kbd_wait();
-}
-
+ static u_char xlate_leds[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
-static volatile void reset_cpu(void)
-{
- while (1) {
- kbd_cmd(KB_RESET_CPU); /* Reset Command */
- DELAY(4000000);
- kbd_cmd(KB_RESET); /* Keyboard Reset Command */
- }
+ kbd_cmd2(KB_SETLEDS, xlate_leds[which & LED_MASK]);
}
-
-
+
+
/*
- * sgetc(noblock) : get a character from the keyboard.
+ * scgetc(noblock) : get a character from the keyboard.
* If noblock = 0 wait until a key is gotten. Otherwise return NOKEY.
*/
-u_int sgetc(int noblock)
+u_int scgetc(int noblock)
{
u_char val, code, release;
u_int state, action;
@@ -2221,7 +2175,7 @@ next_code:
if (chr && !compose) {
action = chr;
chr = 0;
- return (action);
+ return(action);
}
} else {
/* key pressed */
@@ -2253,11 +2207,7 @@ next_code:
slkcnt++;
if (cur_console->status & SLKED) {
cur_console->status &= ~SLKED;
-#if defined(NetBSD)
- pcstart(pc_tty[get_scr_num(cur_console)]);
-#else
- pcstart(&pccons[get_scr_num(cur_console)]);
-#endif
+ pcstart(VIRTUAL_TTY(get_scr_num()));
}
else
cur_console->status |= SLKED;
@@ -2278,14 +2228,18 @@ next_code:
case NOP:
break;
case RBT:
+#if defined(__FreeBSD__)
shutdown_nice();
+#else
+ cpu_reset();
+#endif
break;
case DBG:
#if DDB > 0 /* try to switch to console 0 */
if (cur_console->smode.mode == VT_AUTO &&
console[0].smode.mode == VT_AUTO)
switch_scr(0);
- Debugger("manual escape to debugger");
+ Debugger();
return(NOKEY);
#else
printf("No debugger in kernel\n");
@@ -2316,7 +2270,7 @@ next_code:
metas = 1;
break;
case NEXT:
- switch_scr((get_scr_num(cur_console)+1)%NCONS);
+ switch_scr((get_scr_num()+1)%NCONS);
break;
default:
if (action >= F_SCR && action <= L_SCR) {
@@ -2345,30 +2299,35 @@ int getchar(void)
polling = 1;
s = splhigh();
- sput('>');
- thechar = (u_char) sgetc(0);
+ scput('>');
+ thechar = (u_char) scgetc(0);
polling = 0;
splx(s);
switch (thechar) {
default:
if (thechar >= scr_map[0x20])
- sput(thechar);
+ scput(thechar);
return(thechar);
case cr:
case lf:
- sput(cr); sput(lf);
+ scput(cr); scput(lf);
return(lf);
case bs:
case del:
- sput(bs); sput(scr_map[0x20]); sput(bs);
+ scput(bs); scput(scr_map[0x20]); scput(bs);
return(thechar);
case cntld:
- sput('^'); sput('D'); sput('\r'); sput('\n');
+ scput('^'); scput('D'); scput('\r'); scput('\n');
return(0);
}
}
+u_int sgetc(int noblock)
+{
+ return (scgetc(noblock & 0xff);
+}
+
int pcmmap(dev_t dev, int offset, int nprot)
{
if (offset > 0x20000)
@@ -2380,9 +2339,12 @@ int pcmmap(dev_t dev, int offset, int nprot)
static void kbd_wait(void)
{
int i;
- for (i=0; i<10000; i++)
+
+ for (i=0; i<1000; i++) { /* up to 10 msec */
if ((inb(KB_STAT) & KB_READY) == 0)
break;
+ DELAY (10);
+ }
}
@@ -2393,6 +2355,35 @@ static void kbd_cmd(u_char command)
}
+static void kbd_cmd2(u_char command, u_char arg)
+{
+ int r, s = spltty();
+ do {
+ kbd_cmd(command);
+ r = kbd_reply();
+ if (r == KB_ACK) {
+ kbd_cmd(arg & 0x7f);
+ r = kbd_reply();
+ }
+ } while (r != KB_ACK);
+ splx(s);
+}
+
+
+static int kbd_reply()
+{
+ int i;
+
+ kbd_wait();
+ for (i=0; i<50000; i++) { /* at least 300 msec, 500 msec enough */
+ if (inb(KB_STAT) & KB_BUF_FULL)
+ return ((u_char) inb(KB_DATA));
+ DELAY (10);
+ }
+ return(-1);
+}
+
+
static void set_mode(scr_stat *scp)
{
u_char byte;
@@ -2402,8 +2393,8 @@ static void set_mode(scr_stat *scp)
return;
/* (re)activate cursor */
- untimeout((timeout_func_t)cursor_pos, 0);
- cursor_pos();
+ untimeout((timeout_t)cursor_pos, 0);
+ cursor_pos(1);
/* change cursor type if set */
if (scp->cursor_start != -1 && scp->cursor_end != -1)
OpenPOWER on IntegriCloud