summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>1999-01-23 16:53:30 +0000
committerdfr <dfr@FreeBSD.org>1999-01-23 16:53:30 +0000
commit126561435c15a39d8ef4a4269cd6203289c0ac1e (patch)
tree12e378e698803d82b0aceefe2bbd78cbab6a1245
parenta46648c3bc9b84e02e9017422ad131332206a603 (diff)
downloadFreeBSD-src-126561435c15a39d8ef4a4269cd6203289c0ac1e.zip
FreeBSD-src-126561435c15a39d8ef4a4269cd6203289c0ac1e.tar.gz
Update the alpha port to use the new syscons.
Submitted by: Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> (partly)
-rw-r--r--sys/alpha/conf/GENERIC13
-rw-r--r--sys/alpha/conf/NOTES13
-rw-r--r--sys/alpha/conf/files.alpha21
-rw-r--r--sys/alpha/conf/options.alpha21
-rw-r--r--sys/alpha/include/cons.h14
-rw-r--r--sys/alpha/include/console.h101
-rw-r--r--sys/alpha/isa/isa.c25
-rw-r--r--sys/conf/files.alpha21
-rw-r--r--sys/conf/options.alpha21
-rw-r--r--sys/dev/atkbdc/atkbd_atkbdc.c119
-rw-r--r--sys/dev/atkbdc/atkbd_isa.c119
-rw-r--r--sys/dev/atkbdc/atkbdc_isa.c242
-rw-r--r--sys/dev/atkbdc/atkbdc_subr.c242
-rw-r--r--sys/dev/atkbdc/psm.c21
-rw-r--r--sys/isa/atkbd_isa.c119
-rw-r--r--sys/isa/atkbdc_isa.c242
-rw-r--r--sys/isa/kbdio.c1039
-rw-r--r--sys/isa/kbdio.h207
-rw-r--r--sys/isa/kbdtables.h1333
-rw-r--r--sys/isa/psm.c21
-rw-r--r--sys/isa/scvidctl.c489
-rw-r--r--sys/isa/syscons.c4671
-rw-r--r--sys/isa/syscons.h258
-rw-r--r--sys/isa/syscons_isa.c80
-rw-r--r--sys/isa/timerreg.h111
-rw-r--r--sys/isa/vga_isa.c2239
-rw-r--r--sys/isa/videoio.c1628
-rw-r--r--sys/isa/videoio.h108
28 files changed, 3632 insertions, 9906 deletions
diff --git a/sys/alpha/conf/GENERIC b/sys/alpha/conf/GENERIC
index 6c84ce8..bd4ae6b 100644
--- a/sys/alpha/conf/GENERIC
+++ b/sys/alpha/conf/GENERIC
@@ -11,7 +11,7 @@
# device lines is present in the ./LINT configuration file. If you are
# in doubt as to the purpose or necessity of a line, check first in LINT.
#
-# $Id: GENERIC,v 1.13 1998/12/29 03:59:49 gpalmer Exp $
+# $Id: GENERIC,v 1.14 1999/01/18 20:26:50 gallatin Exp $
machine "alpha"
cpu "EV4"
@@ -78,8 +78,17 @@ device cd0
# real time clock
device mcclock0 at isa0 port 0x70
+controller atkbdc0 at isa? port IO_KBD
+device atkbd0 at atkbdc? irq 1
+device psm0 at atkbdc? irq 12
+
+device vga0 at isa? port ? conflicts
+
+# splash screen/screen saver
+pseudo-device splash
+
# syscons is the default console driver, resembling an SCO console
-device sc0 at isa0 port "IO_KBD" irq 1
+device sc0 at isa?
device sio0 at isa0 port "IO_COM1" irq 4
device sio1 at isa0 port "IO_COM2" irq 3 flags 0x50
diff --git a/sys/alpha/conf/NOTES b/sys/alpha/conf/NOTES
index 6c84ce8..bd4ae6b 100644
--- a/sys/alpha/conf/NOTES
+++ b/sys/alpha/conf/NOTES
@@ -11,7 +11,7 @@
# device lines is present in the ./LINT configuration file. If you are
# in doubt as to the purpose or necessity of a line, check first in LINT.
#
-# $Id: GENERIC,v 1.13 1998/12/29 03:59:49 gpalmer Exp $
+# $Id: GENERIC,v 1.14 1999/01/18 20:26:50 gallatin Exp $
machine "alpha"
cpu "EV4"
@@ -78,8 +78,17 @@ device cd0
# real time clock
device mcclock0 at isa0 port 0x70
+controller atkbdc0 at isa? port IO_KBD
+device atkbd0 at atkbdc? irq 1
+device psm0 at atkbdc? irq 12
+
+device vga0 at isa? port ? conflicts
+
+# splash screen/screen saver
+pseudo-device splash
+
# syscons is the default console driver, resembling an SCO console
-device sc0 at isa0 port "IO_KBD" irq 1
+device sc0 at isa?
device sio0 at isa0 port "IO_COM1" irq 4
device sio1 at isa0 port "IO_COM2" irq 3 flags 0x50
diff --git a/sys/alpha/conf/files.alpha b/sys/alpha/conf/files.alpha
index 6c6d2b5..104ab35 100644
--- a/sys/alpha/conf/files.alpha
+++ b/sys/alpha/conf/files.alpha
@@ -1,7 +1,7 @@
# This file tells config what files go into building a kernel,
# files marked standard are always included.
#
-# $Id: files.alpha,v 1.14 1998/12/04 10:52:47 dfr Exp $
+# $Id: files.alpha,v 1.15 1999/01/18 20:26:50 gallatin Exp $
#
# The long compile-with and dependency lines are required because of
# limitations in config: backslash-newline doesn't work in strings, and
@@ -138,9 +138,18 @@ libkern/alpha/htons.S standard
libkern/alpha/ntohl.S standard
libkern/alpha/ntohs.S standard
isa/sio.c optional sio device-driver
-isa/kbdio.c optional psm device-driver
+dev/fb/fb.c optional fb device-driver
+dev/fb/fb.c optional vga device-driver
+isa/vga_isa.c optional vga device-driver
+dev/fb/splash.c optional splash
+dev/kbd/atkbd.c optional atkbd device-driver
+isa/atkbd_isa.c optional atkbd device-driver
+dev/kbd/atkbdc.c optional atkbdc device-driver
+isa/atkbdc_isa.c optional atkbdc device-driver
+dev/kbd/kbd.c optional atkbd device-driver
+dev/kbd/kbd.c optional kbd device-driver
+#dev/kbd/kbd.c optional ukbd device-driver
+dev/syscons/syscons.c optional sc device-driver
+dev/syscons/scvidctl.c optional sc device-driver
+isa/syscons_isa.c optional sc device-driver
isa/psm.c optional psm device-driver
-isa/kbdio.c optional sc device-driver
-isa/videoio.c optional sc device-driver
-isa/syscons.c optional sc device-driver
-isa/scvidctl.c optional sc device-driver
diff --git a/sys/alpha/conf/options.alpha b/sys/alpha/conf/options.alpha
index 44add99..e6b7f13 100644
--- a/sys/alpha/conf/options.alpha
+++ b/sys/alpha/conf/options.alpha
@@ -1,4 +1,4 @@
-# $Id: options.alpha,v 1.7 1998/09/16 08:22:09 dfr Exp $
+# $Id: options.alpha,v 1.8 1999/01/18 20:26:50 gallatin Exp $
EV5 opt_global.h
EV4 opt_global.h
@@ -28,13 +28,24 @@ SC_HISTORY_SIZE opt_syscons.h
SC_DISABLE_REBOOT opt_syscons.h
SC_MOUSE_CHAR opt_syscons.h
+VGA_ALT_SEQACCESS opt_vga.h
+VGA_DEBUG opt_vga.h
+VGA_NO_FONT_LOADING opt_vga.h
+VGA_NO_MODE_CHANGE opt_vga.h
+VGA_SLOW_IOACCESS opt_vga.h
+
PSM_HOOKAPM opt_psm.h
PSM_RESETAFTERSUSPEND opt_psm.h
PSM_DEBUG opt_psm.h
-KBD_RESETDELAY opt_kbdio.h
-KBD_MAXRETRY opt_kbdio.h
-KBD_MAXWAIT opt_kbdio.h
-KBDIO_DEBUG opt_kbdio.h
+# Fb options
+FB_INSTALL_CDEV opt_fb.h
+
+# Kbd options
+KBD_INSTALL_CDEV opt_kbd.h
+KBD_MAXRETRY opt_kbd.h
+KBD_MAXWAIT opt_kbd.h
+KBD_RESETDELAY opt_kbd.h
+KBDIO_DEBUG opt_kbd.h
BREAK_TO_DEBUGGER opt_comconsole.h
diff --git a/sys/alpha/include/cons.h b/sys/alpha/include/cons.h
index df135cc..057a2fa 100644
--- a/sys/alpha/include/cons.h
+++ b/sys/alpha/include/cons.h
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)cons.h 7.2 (Berkeley) 5/9/91
- * $Id: cons.h,v 1.17 1997/07/01 00:54:37 bde Exp $
+ * $Id: cons.h,v 1.1 1998/06/10 10:54:42 dfr Exp $
*/
#ifndef _MACHINE_CONS_H_
@@ -54,18 +54,6 @@ typedef void cn_putc_t __P((dev_t, int));
* XXX public functions in drivers should be declared in headers produced
* by `config', not here.
*/
-cn_probe_t pccnprobe;
-cn_init_t pccninit;
-cn_getc_t pccngetc;
-cn_checkc_t pccncheckc;
-cn_putc_t pccnputc;
-
-cn_probe_t sccnprobe;
-cn_init_t sccninit;
-cn_getc_t sccngetc;
-cn_checkc_t sccncheckc;
-cn_putc_t sccnputc;
-
cn_probe_t siocnprobe;
cn_init_t siocninit;
cn_getc_t siocngetc;
diff --git a/sys/alpha/include/console.h b/sys/alpha/include/console.h
index 52ef8d1..5a140d6 100644
--- a/sys/alpha/include/console.h
+++ b/sys/alpha/include/console.h
@@ -25,8 +25,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: console.h,v 1.40 1998/09/17 09:38:36 dfr Exp $
- * from: i386/include console.h,v 1.39
+ * $Id: console.h,v 1.41 1999/01/01 14:38:29 des Exp $
+ * from: i386/include console.h,v 1.43
*/
#ifndef _MACHINE_CONSOLE_H_
@@ -53,6 +53,7 @@
#define KDSETLED _IO('K', 66 /*, int */)
#define KDSETRAD _IO('K', 67 /*, int */)
#define KDRASTER _IOW('K', 100, scr_size_t)
+#define KDGKBINFO _IOR('K', 101, keyboard_info_t)
#define GETFKEY _IOWR('k', 0, fkeyarg_t)
#define SETFKEY _IOWR('k', 1, fkeyarg_t)
@@ -62,6 +63,8 @@
#define PIO_KEYMAP _IOW('k', 7, keymap_t)
#define GIO_DEADKEYMAP _IOR('k', 8, accentmap_t)
#define PIO_DEADKEYMAP _IOW('k', 9, accentmap_t)
+#define GIO_KEYMAPENT _IOWR('k', 10, keyarg_t)
+#define PIO_KEYMAPENT _IOW('k', 11, keyarg_t)
#define GIO_ATTR _IOR('a', 0, int)
#define GIO_COLOR _IOR('c', 0, int)
@@ -87,11 +90,14 @@
#define CONS_GETINFO _IOWR('c', 73, vid_info_t)
#define CONS_GETVERS _IOR('c', 74, int)
#define CONS_CURRENTADP _IOR('c', 100, int)
-#define CONS_ADPINFO _IOWR('c', 101, video_adapter_t)
+#define CONS_ADPINFO _IOWR('c', 101, video_adapter_info_t)
#define CONS_MODEINFO _IOWR('c', 102, video_info_t)
#define CONS_FINDMODE _IOWR('c', 103, video_info_t)
#define CONS_SETWINORG _IO('c', 104 /* u_int */)
+#define CONS_SETKBD _IO('c', 110 /* int */)
+#define CONS_RELKBD _IO('c', 111)
+
/* CONS_SAVERMODE */
#define CONS_LKM_SAVER 0
#define CONS_USR_SAVER 1
@@ -190,9 +196,11 @@ struct mouse_info {
#define NLKED 2 /* Num locked */
#define SLKED 4 /* Scroll locked */
#define ALKED 8 /* AltGr locked */
+#define LOCK_MASK (CLKED | NLKED | SLKED | ALKED)
#define LED_CAP 1 /* Caps lock LED */
#define LED_NUM 2 /* Num lock LED */
#define LED_SCR 4 /* Scroll lock LED */
+#define LED_MASK (LED_CAP | LED_NUM | LED_SCR)
/* possible flag values */
#define FLAG_LOCK_O 0
@@ -205,7 +213,7 @@ struct mouse_info {
#ifndef _KEYMAP_DECLARED
#define _KEYMAP_DECLARED
-struct key_t {
+struct keyent_t {
u_char map[NUM_STATES];
u_char spcl;
u_char flgs;
@@ -213,10 +221,17 @@ struct key_t {
struct keymap {
u_short n_keys;
- struct key_t key[NUM_KEYS];
+ struct keyent_t key[NUM_KEYS];
};
typedef struct keymap keymap_t;
+
+struct keyarg {
+ u_short keynum;
+ struct keyent_t key;
+};
+
+typedef struct keyarg keyarg_t;
#endif /* !_KEYMAP_DECLARED */
#define NUM_DEADKEYS 15 /* number of accent keys */
@@ -275,6 +290,9 @@ struct ssaver {
struct video_adapter {
int va_index;
int va_type;
+ char *va_name;
+ int va_unit;
+ int va_minor;
int va_flags;
#define V_ADP_COLOR (1<<0)
#define V_ADP_MODECHANGE (1<<1)
@@ -284,7 +302,14 @@ struct video_adapter {
#define V_ADP_PALETTE (1<<5)
#define V_ADP_BORDER (1<<6)
#define V_ADP_VESA (1<<7)
+#define V_ADP_PROBED (1<<16)
+#define V_ADP_INITIALIZED (1<<17)
+#define V_ADP_REGISTERED (1<<18)
+ int va_io_base;
+ int va_io_size;
int va_crtc_addr;
+ int va_mem_base;
+ int va_mem_size;
u_int va_window; /* virtual address */
size_t va_window_size;
size_t va_window_gran;
@@ -293,6 +318,30 @@ struct video_adapter {
int va_initial_mode;
int va_initial_bios_mode;
int va_mode;
+ int va_mode_flags; /* copy of vi_flags */
+ void *va_token;
+};
+
+struct video_adapter_info {
+ int va_index;
+ int va_type;
+ char va_name[16];
+ int va_unit;
+ int va_flags;
+ int va_io_base;
+ int va_io_size;
+ int va_crtc_addr;
+ int va_mem_base;
+ int va_mem_size;
+ u_int va_window; /* virtual address */
+ size_t va_window_size;
+ size_t va_window_gran;
+ u_int va_buffer; /* virtual address */
+ size_t va_buffer_size;
+ int va_initial_mode;
+ int va_initial_bios_mode;
+ int va_mode;
+ int va_mode_flags;
};
#define V_ADP_PRIMARY 0
@@ -320,6 +369,15 @@ struct video_info {
/* XXX pixel format, memory model,... */
};
+struct keyboard_info {
+ int kb_index; /* kbdio index# */
+ char kb_name[16]; /* driver name */
+ int kb_unit; /* unit# */
+ int kb_type; /* KB_84, KB_101, KB_OTHER,... */
+ int kb_config; /* device configuration flags */
+ int kb_flags; /* internal flags */
+};
+
typedef struct accentmap accentmap_t;
typedef struct fkeytab fkeytab_t;
typedef struct fkeyarg fkeyarg_t;
@@ -331,7 +389,9 @@ typedef struct {char fnt8x14[14*256];} fnt14_t;
typedef struct {char fnt8x16[16*256];} fnt16_t;
typedef struct ssaver ssaver_t;
typedef struct video_adapter video_adapter_t;
+typedef struct video_adapter_info video_adapter_info_t;
typedef struct video_info video_info_t;
+typedef struct keyboard_info keyboard_info_t;
typedef struct {int scr_size[3];} scr_size_t;
/* defines for "special" keys (spcl bit set in keymap) */
@@ -389,6 +449,13 @@ typedef struct {int scr_size[3];} scr_size_t;
#define MKEY 0x400 /* meta key marker (prepend ESC)*/
#define BKEY 0x800 /* backtab (ESC [ Z) */
+#define SPCLKEY 0x8000 /* special key */
+#define RELKEY 0x4000 /* key released */
+#define ERRKEY 0x2000 /* error */
+
+#define KEYCHAR(c) ((c) & 0x00ff)
+#define KEYFLAGS(c) ((c) & ~0x00ff)
+
/* video mode definitions */
#define M_B40x25 0 /* black & white 40 columns */
#define M_C40x25 1 /* color 40 columns */
@@ -438,6 +505,17 @@ typedef struct {int scr_size[3];} scr_size_t;
#define M_HGC_P1 0xe1 /* hercules graphics - page 1 @ B8000 */
#define M_MCA_MODE 0xff /* monochrome adapter mode */
+#define M_TEXT_80x25 200 /* generic text modes */
+#define M_TEXT_80x30 201
+#define M_TEXT_80x43 202
+#define M_TEXT_80x50 203
+#define M_TEXT_80x60 204
+#define M_TEXT_132x25 205
+#define M_TEXT_132x30 206
+#define M_TEXT_132x43 207
+#define M_TEXT_132x50 208
+#define M_TEXT_132x60 209
+
#define SW_PC98_80x25 _IO('S', M_PC98_80x25)
#define SW_PC98_80x30 _IO('S', M_PC98_80x30)
#define SW_B40x25 _IO('S', M_B40x25)
@@ -479,6 +557,17 @@ typedef struct {int scr_size[3];} scr_size_t;
#define SW_VGA_CG640 _IO('S', M_VGA_CG640)
#define SW_VGA_MODEX _IO('S', M_VGA_MODEX)
+#define SW_TEXT_80x25 _IO('S', M_TEXT_80x25)
+#define SW_TEXT_80x30 _IO('S', M_TEXT_80x30)
+#define SW_TEXT_80x43 _IO('S', M_TEXT_80x43)
+#define SW_TEXT_80x50 _IO('S', M_TEXT_80x50)
+#define SW_TEXT_80x60 _IO('S', M_TEXT_80x60)
+#define SW_TEXT_132x25 _IO('S', M_TEXT_132x25)
+#define SW_TEXT_132x30 _IO('S', M_TEXT_132x30)
+#define SW_TEXT_132x43 _IO('S', M_TEXT_132x43)
+#define SW_TEXT_132x50 _IO('S', M_TEXT_132x50)
+#define SW_TEXT_132x60 _IO('S', M_TEXT_132x60)
+
#define M_VESA_BASE 0x100 /* VESA mode number base */
#define M_VESA_CG640x400 0x100 /* 640x400, 256 color */
@@ -510,7 +599,6 @@ typedef struct {int scr_size[3];} scr_size_t;
#define M_VESA_64K_1280 0x11a /* 1280x1024, 5:6:5 */
#define M_VESA_FULL_1280 0x11b /* 1280x1024, 8:8:8 */
#define M_VESA_MODE_MAX 0x1ff
-#define M_VESA_USER 0x1ff
#define SW_VESA_CG640x400 _IO('V', M_VESA_CG640x400 - M_VESA_BASE)
#define SW_VESA_CG640x480 _IO('V', M_VESA_CG640x480 - M_VESA_BASE)
@@ -540,7 +628,6 @@ typedef struct {int scr_size[3];} scr_size_t;
#define SW_VESA_32K_1280 _IO('V', M_VESA_32K_1280 - M_VESA_BASE)
#define SW_VESA_64K_1280 _IO('V', M_VESA_64K_1280 - M_VESA_BASE)
#define SW_VESA_FULL_1280 _IO('V', M_VESA_FULL_1280 - M_VESA_BASE)
-#define SW_VESA_USER _IO('V', M_VESA_USER - M_VESA_BASE)
#endif /* !_MACHINE_CONSOLE_H_ */
diff --git a/sys/alpha/isa/isa.c b/sys/alpha/isa/isa.c
index 32894e6..56df551 100644
--- a/sys/alpha/isa/isa.c
+++ b/sys/alpha/isa/isa.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: isa.c,v 1.7 1998/11/18 23:53:11 dfr Exp $
+ * $Id: isa.c,v 1.8 1998/11/28 09:55:16 dfr Exp $
*/
#include <sys/param.h>
@@ -246,6 +246,16 @@ isa_probe(device_t dev)
resource_query_unit(i));
}
+ /*
+ * and isa?
+ */
+ for (i = resource_query_string(-1, "at", "isa");
+ i != -1;
+ i = resource_query_string(i, "at", "isa")) {
+ isa_add_device(dev, resource_query_name(i),
+ resource_query_unit(i));
+ }
+
isa_irq_rman.rm_start = 0;
isa_irq_rman.rm_end = 15;
isa_irq_rman.rm_type = RMAN_ARRAY;
@@ -471,9 +481,16 @@ isa_alloc_resource(device_t bus, device_t child, int type, int *rid,
struct resource *rv, **rvp;
struct isa_device *id;
- if (child)
- id = DEVTOISA(child);
- else
+ if (child) {
+ /*
+ * If this is our child, then use the isa_device to find
+ * defaults and to record results.
+ */
+ if (device_get_devclass(device_get_parent(child)) == isa_devclass)
+ id = DEVTOISA(child);
+ else
+ id = NULL;
+ } else
id = NULL;
isdefault = (start == 0UL && end == ~0UL && *rid == 0);
if (*rid > 1)
diff --git a/sys/conf/files.alpha b/sys/conf/files.alpha
index 6c6d2b5..104ab35 100644
--- a/sys/conf/files.alpha
+++ b/sys/conf/files.alpha
@@ -1,7 +1,7 @@
# This file tells config what files go into building a kernel,
# files marked standard are always included.
#
-# $Id: files.alpha,v 1.14 1998/12/04 10:52:47 dfr Exp $
+# $Id: files.alpha,v 1.15 1999/01/18 20:26:50 gallatin Exp $
#
# The long compile-with and dependency lines are required because of
# limitations in config: backslash-newline doesn't work in strings, and
@@ -138,9 +138,18 @@ libkern/alpha/htons.S standard
libkern/alpha/ntohl.S standard
libkern/alpha/ntohs.S standard
isa/sio.c optional sio device-driver
-isa/kbdio.c optional psm device-driver
+dev/fb/fb.c optional fb device-driver
+dev/fb/fb.c optional vga device-driver
+isa/vga_isa.c optional vga device-driver
+dev/fb/splash.c optional splash
+dev/kbd/atkbd.c optional atkbd device-driver
+isa/atkbd_isa.c optional atkbd device-driver
+dev/kbd/atkbdc.c optional atkbdc device-driver
+isa/atkbdc_isa.c optional atkbdc device-driver
+dev/kbd/kbd.c optional atkbd device-driver
+dev/kbd/kbd.c optional kbd device-driver
+#dev/kbd/kbd.c optional ukbd device-driver
+dev/syscons/syscons.c optional sc device-driver
+dev/syscons/scvidctl.c optional sc device-driver
+isa/syscons_isa.c optional sc device-driver
isa/psm.c optional psm device-driver
-isa/kbdio.c optional sc device-driver
-isa/videoio.c optional sc device-driver
-isa/syscons.c optional sc device-driver
-isa/scvidctl.c optional sc device-driver
diff --git a/sys/conf/options.alpha b/sys/conf/options.alpha
index 44add99..e6b7f13 100644
--- a/sys/conf/options.alpha
+++ b/sys/conf/options.alpha
@@ -1,4 +1,4 @@
-# $Id: options.alpha,v 1.7 1998/09/16 08:22:09 dfr Exp $
+# $Id: options.alpha,v 1.8 1999/01/18 20:26:50 gallatin Exp $
EV5 opt_global.h
EV4 opt_global.h
@@ -28,13 +28,24 @@ SC_HISTORY_SIZE opt_syscons.h
SC_DISABLE_REBOOT opt_syscons.h
SC_MOUSE_CHAR opt_syscons.h
+VGA_ALT_SEQACCESS opt_vga.h
+VGA_DEBUG opt_vga.h
+VGA_NO_FONT_LOADING opt_vga.h
+VGA_NO_MODE_CHANGE opt_vga.h
+VGA_SLOW_IOACCESS opt_vga.h
+
PSM_HOOKAPM opt_psm.h
PSM_RESETAFTERSUSPEND opt_psm.h
PSM_DEBUG opt_psm.h
-KBD_RESETDELAY opt_kbdio.h
-KBD_MAXRETRY opt_kbdio.h
-KBD_MAXWAIT opt_kbdio.h
-KBDIO_DEBUG opt_kbdio.h
+# Fb options
+FB_INSTALL_CDEV opt_fb.h
+
+# Kbd options
+KBD_INSTALL_CDEV opt_kbd.h
+KBD_MAXRETRY opt_kbd.h
+KBD_MAXWAIT opt_kbd.h
+KBD_RESETDELAY opt_kbd.h
+KBDIO_DEBUG opt_kbd.h
BREAK_TO_DEBUGGER opt_comconsole.h
diff --git a/sys/dev/atkbdc/atkbd_atkbdc.c b/sys/dev/atkbdc/atkbd_atkbdc.c
new file mode 100644
index 0000000..4513049
--- /dev/null
+++ b/sys/dev/atkbdc/atkbd_atkbdc.c
@@ -0,0 +1,119 @@
+/*-
+ * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer as
+ * the first lines of this file unmodified.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: $
+ */
+
+#include "atkbd.h"
+#include "opt_kbd.h"
+
+#if NATKBD > 0
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/conf.h>
+#include <sys/tty.h>
+#include <sys/bus.h>
+#include <sys/rman.h>
+
+#include <machine/resource.h>
+
+#include <dev/kbd/kbdreg.h>
+#include <dev/kbd/atkbdreg.h>
+#include <dev/kbd/atkbdcreg.h>
+
+#include <isa/isareg.h>
+#include <isa/isavar.h>
+
+devclass_t atkbd_devclass;
+
+static int atkbdprobe(device_t dev);
+static int atkbdattach(device_t dev);
+
+static device_method_t atkbd_methods[] = {
+ DEVMETHOD(device_probe, atkbdprobe),
+ DEVMETHOD(device_attach, atkbdattach),
+ { 0, 0 }
+};
+
+static driver_t atkbd_driver = {
+ ATKBD_DRIVER_NAME,
+ atkbd_methods,
+ DRIVER_TYPE_TTY,
+ sizeof(atkbd_softc_t),
+};
+
+static int
+atkbdprobe(device_t dev)
+{
+ atkbd_softc_t *sc;
+ u_long port;
+ u_long irq;
+ u_long flags;
+
+ sc = (atkbd_softc_t *)device_get_softc(dev);
+
+ device_set_desc(dev, "AT Keyboard");
+
+ /* obtain parameters */
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
+
+ /* probe the device */
+ return atkbd_probe_unit(device_get_unit(dev), sc, port, irq, flags);
+}
+
+static int
+atkbdattach(device_t dev)
+{
+ atkbd_softc_t *sc;
+ u_long irq;
+ struct resource *res;
+ void *ih;
+ int zero = 0;
+ int error;
+
+ sc = (atkbd_softc_t *)device_get_softc(dev);
+
+ error = atkbd_attach_unit(device_get_unit(dev), sc);
+ if (error)
+ return error;
+
+ /* declare our interrupt handler */
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
+ res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1,
+ RF_SHAREABLE | RF_ACTIVE);
+ BUS_SETUP_INTR(device_get_parent(dev), dev, res,
+ (driver_intr_t *) kbdsw[sc->kbd->kb_index]->intr, sc->kbd,
+ &ih);
+
+ return 0;
+}
+
+DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0);
+
+#endif /* NATKBD > 0 */
diff --git a/sys/dev/atkbdc/atkbd_isa.c b/sys/dev/atkbdc/atkbd_isa.c
new file mode 100644
index 0000000..4513049
--- /dev/null
+++ b/sys/dev/atkbdc/atkbd_isa.c
@@ -0,0 +1,119 @@
+/*-
+ * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer as
+ * the first lines of this file unmodified.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: $
+ */
+
+#include "atkbd.h"
+#include "opt_kbd.h"
+
+#if NATKBD > 0
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/conf.h>
+#include <sys/tty.h>
+#include <sys/bus.h>
+#include <sys/rman.h>
+
+#include <machine/resource.h>
+
+#include <dev/kbd/kbdreg.h>
+#include <dev/kbd/atkbdreg.h>
+#include <dev/kbd/atkbdcreg.h>
+
+#include <isa/isareg.h>
+#include <isa/isavar.h>
+
+devclass_t atkbd_devclass;
+
+static int atkbdprobe(device_t dev);
+static int atkbdattach(device_t dev);
+
+static device_method_t atkbd_methods[] = {
+ DEVMETHOD(device_probe, atkbdprobe),
+ DEVMETHOD(device_attach, atkbdattach),
+ { 0, 0 }
+};
+
+static driver_t atkbd_driver = {
+ ATKBD_DRIVER_NAME,
+ atkbd_methods,
+ DRIVER_TYPE_TTY,
+ sizeof(atkbd_softc_t),
+};
+
+static int
+atkbdprobe(device_t dev)
+{
+ atkbd_softc_t *sc;
+ u_long port;
+ u_long irq;
+ u_long flags;
+
+ sc = (atkbd_softc_t *)device_get_softc(dev);
+
+ device_set_desc(dev, "AT Keyboard");
+
+ /* obtain parameters */
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
+
+ /* probe the device */
+ return atkbd_probe_unit(device_get_unit(dev), sc, port, irq, flags);
+}
+
+static int
+atkbdattach(device_t dev)
+{
+ atkbd_softc_t *sc;
+ u_long irq;
+ struct resource *res;
+ void *ih;
+ int zero = 0;
+ int error;
+
+ sc = (atkbd_softc_t *)device_get_softc(dev);
+
+ error = atkbd_attach_unit(device_get_unit(dev), sc);
+ if (error)
+ return error;
+
+ /* declare our interrupt handler */
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
+ res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1,
+ RF_SHAREABLE | RF_ACTIVE);
+ BUS_SETUP_INTR(device_get_parent(dev), dev, res,
+ (driver_intr_t *) kbdsw[sc->kbd->kb_index]->intr, sc->kbd,
+ &ih);
+
+ return 0;
+}
+
+DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0);
+
+#endif /* NATKBD > 0 */
diff --git a/sys/dev/atkbdc/atkbdc_isa.c b/sys/dev/atkbdc/atkbdc_isa.c
new file mode 100644
index 0000000..4435e1e
--- /dev/null
+++ b/sys/dev/atkbdc/atkbdc_isa.c
@@ -0,0 +1,242 @@
+/*-
+ * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer as
+ * the first lines of this file unmodified.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: $
+ */
+
+#include "atkbdc.h"
+#include "opt_kbd.h"
+
+#if NATKBDC > 0
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/malloc.h>
+
+#include <dev/kbd/atkbdcreg.h>
+
+#include <isa/isareg.h>
+#include <isa/isavar.h>
+
+MALLOC_DEFINE(M_ATKBDDEV, "atkbddev", "AT Keyboard device");
+
+/* children */
+typedef struct atkbdc_device {
+ int flags; /* configuration flags */
+ int port; /* port number (same as the controller's) */
+ int irq; /* ISA IRQ mask */
+} atkbdc_device_t;
+
+/* kbdc */
+devclass_t atkbdc_devclass;
+
+static int atkbdc_probe(device_t dev);
+static int atkbdc_attach(device_t dev);
+static void atkbdc_print_child(device_t bus, device_t dev);
+static int atkbdc_read_ivar(device_t bus, device_t dev, int index,
+ u_long *val);
+static int atkbdc_write_ivar(device_t bus, device_t dev, int index,
+ u_long val);
+
+static device_method_t atkbdc_methods[] = {
+ DEVMETHOD(device_probe, atkbdc_probe),
+ DEVMETHOD(device_attach, atkbdc_attach),
+
+ DEVMETHOD(bus_print_child, atkbdc_print_child),
+ DEVMETHOD(bus_read_ivar, atkbdc_read_ivar),
+ DEVMETHOD(bus_write_ivar, atkbdc_write_ivar),
+ DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
+ DEVMETHOD(bus_release_resource, bus_generic_release_resource),
+ DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
+ DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
+ DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
+ DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
+
+ { 0, 0 }
+};
+
+static driver_t atkbdc_driver = {
+ ATKBDC_DRIVER_NAME,
+ atkbdc_methods,
+ DRIVER_TYPE_MISC,
+ sizeof(atkbdc_softc_t *),
+};
+
+static int
+atkbdc_probe(device_t dev)
+{
+ atkbdc_softc_t *sc;
+ int unit;
+ int error;
+
+ unit = device_get_unit(dev);
+ sc = *(atkbdc_softc_t **)device_get_softc(dev);
+ if (sc == NULL) {
+ /*
+ * We have to maintain two copies of the kbdc_softc struct,
+ * as the low-level console needs to have access to the
+ * keyboard controller before kbdc is probed and attached.
+ * kbdc_soft[] contains the default entry for that purpose.
+ * See atkbdc.c. XXX
+ */
+ sc = atkbdc_get_softc(unit);
+ if (sc == NULL)
+ return ENOMEM;
+ }
+
+ device_set_desc(dev, "keyboard controller (i8042)");
+
+ error = atkbdc_probe_unit(sc, unit, isa_get_port(dev));
+ if (error == 0)
+ *(atkbdc_softc_t **)device_get_softc(dev) = sc;
+
+ return error;
+}
+
+static void
+atkbdc_add_device(device_t dev, const char *name, int unit)
+{
+ atkbdc_softc_t *sc = *(atkbdc_softc_t **)device_get_softc(dev);
+ atkbdc_device_t *kdev;
+ device_t child;
+ int t;
+
+ kdev = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, M_NOWAIT);
+ if (!kdev)
+ return;
+ bzero(kdev, sizeof *kdev);
+
+ kdev->port = sc->port;
+
+ if (resource_int_value(name, unit, "irq", &t) == 0)
+ kdev->irq = t;
+ else
+ kdev->irq = -1;
+
+ if (resource_int_value(name, unit, "flags", &t) == 0)
+ kdev->flags = t;
+ else
+ kdev->flags = 0;
+
+ child = device_add_child(dev, name, unit, kdev);
+}
+
+static int
+atkbdc_attach(device_t dev)
+{
+ atkbdc_softc_t *sc;
+ int i;
+
+ sc = *(atkbdc_softc_t **)device_get_softc(dev);
+ if ((sc == NULL) || (sc->port <= 0))
+ return ENXIO;
+
+ /*
+ * Add all devices configured to be attached to atkbdc0.
+ */
+ for (i = resource_query_string(-1, "at", "atkbdc0");
+ i != -1;
+ i = resource_query_string(i, "at", "atkbdc0")) {
+ atkbdc_add_device(dev, resource_query_name(i),
+ resource_query_unit(i));
+ }
+
+ /*
+ * and atkbdc?
+ */
+ for (i = resource_query_string(-1, "at", "atkbdc");
+ i != -1;
+ i = resource_query_string(i, "at", "atkbdc")) {
+ atkbdc_add_device(dev, resource_query_name(i),
+ resource_query_unit(i));
+ }
+
+ bus_generic_attach(dev);
+
+ return 0;
+}
+
+static void
+atkbdc_print_child(device_t bus, device_t dev)
+{
+ atkbdc_device_t *kbdcdev;
+
+ kbdcdev = (atkbdc_device_t *)device_get_ivars(dev);
+
+ if (kbdcdev->flags != 0)
+ printf(" flags 0x%x", kbdcdev->flags);
+
+ printf(" on %s%d", device_get_name(bus), device_get_unit(bus));
+}
+
+static int
+atkbdc_read_ivar(device_t bus, device_t dev, int index, u_long *val)
+{
+ atkbdc_device_t *ivar;
+
+ ivar = (atkbdc_device_t *)device_get_ivars(dev);
+ switch (index) {
+ case KBDC_IVAR_PORT:
+ *val = (u_long)ivar->port;
+ break;
+ case KBDC_IVAR_IRQ:
+ *val = (u_long)ivar->irq;
+ break;
+ case KBDC_IVAR_FLAGS:
+ *val = (u_long)ivar->flags;
+ break;
+ default:
+ return ENOENT;
+ }
+ return 0;
+}
+
+static int
+atkbdc_write_ivar(device_t bus, device_t dev, int index, u_long val)
+{
+ atkbdc_device_t *ivar;
+
+ ivar = (atkbdc_device_t *)device_get_ivars(dev);
+ switch (index) {
+ case KBDC_IVAR_PORT:
+ ivar->port = (int)val;
+ break;
+ case KBDC_IVAR_IRQ:
+ ivar->irq = (int)val;
+ break;
+ case KBDC_IVAR_FLAGS:
+ ivar->flags = (int)val;
+ break;
+ default:
+ return ENOENT;
+ }
+ return 0;
+}
+
+DRIVER_MODULE(atkbdc, isa, atkbdc_driver, atkbdc_devclass, 0, 0);
+
+#endif /* NATKBDC > 0 */
diff --git a/sys/dev/atkbdc/atkbdc_subr.c b/sys/dev/atkbdc/atkbdc_subr.c
new file mode 100644
index 0000000..4435e1e
--- /dev/null
+++ b/sys/dev/atkbdc/atkbdc_subr.c
@@ -0,0 +1,242 @@
+/*-
+ * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer as
+ * the first lines of this file unmodified.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: $
+ */
+
+#include "atkbdc.h"
+#include "opt_kbd.h"
+
+#if NATKBDC > 0
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/malloc.h>
+
+#include <dev/kbd/atkbdcreg.h>
+
+#include <isa/isareg.h>
+#include <isa/isavar.h>
+
+MALLOC_DEFINE(M_ATKBDDEV, "atkbddev", "AT Keyboard device");
+
+/* children */
+typedef struct atkbdc_device {
+ int flags; /* configuration flags */
+ int port; /* port number (same as the controller's) */
+ int irq; /* ISA IRQ mask */
+} atkbdc_device_t;
+
+/* kbdc */
+devclass_t atkbdc_devclass;
+
+static int atkbdc_probe(device_t dev);
+static int atkbdc_attach(device_t dev);
+static void atkbdc_print_child(device_t bus, device_t dev);
+static int atkbdc_read_ivar(device_t bus, device_t dev, int index,
+ u_long *val);
+static int atkbdc_write_ivar(device_t bus, device_t dev, int index,
+ u_long val);
+
+static device_method_t atkbdc_methods[] = {
+ DEVMETHOD(device_probe, atkbdc_probe),
+ DEVMETHOD(device_attach, atkbdc_attach),
+
+ DEVMETHOD(bus_print_child, atkbdc_print_child),
+ DEVMETHOD(bus_read_ivar, atkbdc_read_ivar),
+ DEVMETHOD(bus_write_ivar, atkbdc_write_ivar),
+ DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
+ DEVMETHOD(bus_release_resource, bus_generic_release_resource),
+ DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
+ DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
+ DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
+ DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
+
+ { 0, 0 }
+};
+
+static driver_t atkbdc_driver = {
+ ATKBDC_DRIVER_NAME,
+ atkbdc_methods,
+ DRIVER_TYPE_MISC,
+ sizeof(atkbdc_softc_t *),
+};
+
+static int
+atkbdc_probe(device_t dev)
+{
+ atkbdc_softc_t *sc;
+ int unit;
+ int error;
+
+ unit = device_get_unit(dev);
+ sc = *(atkbdc_softc_t **)device_get_softc(dev);
+ if (sc == NULL) {
+ /*
+ * We have to maintain two copies of the kbdc_softc struct,
+ * as the low-level console needs to have access to the
+ * keyboard controller before kbdc is probed and attached.
+ * kbdc_soft[] contains the default entry for that purpose.
+ * See atkbdc.c. XXX
+ */
+ sc = atkbdc_get_softc(unit);
+ if (sc == NULL)
+ return ENOMEM;
+ }
+
+ device_set_desc(dev, "keyboard controller (i8042)");
+
+ error = atkbdc_probe_unit(sc, unit, isa_get_port(dev));
+ if (error == 0)
+ *(atkbdc_softc_t **)device_get_softc(dev) = sc;
+
+ return error;
+}
+
+static void
+atkbdc_add_device(device_t dev, const char *name, int unit)
+{
+ atkbdc_softc_t *sc = *(atkbdc_softc_t **)device_get_softc(dev);
+ atkbdc_device_t *kdev;
+ device_t child;
+ int t;
+
+ kdev = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, M_NOWAIT);
+ if (!kdev)
+ return;
+ bzero(kdev, sizeof *kdev);
+
+ kdev->port = sc->port;
+
+ if (resource_int_value(name, unit, "irq", &t) == 0)
+ kdev->irq = t;
+ else
+ kdev->irq = -1;
+
+ if (resource_int_value(name, unit, "flags", &t) == 0)
+ kdev->flags = t;
+ else
+ kdev->flags = 0;
+
+ child = device_add_child(dev, name, unit, kdev);
+}
+
+static int
+atkbdc_attach(device_t dev)
+{
+ atkbdc_softc_t *sc;
+ int i;
+
+ sc = *(atkbdc_softc_t **)device_get_softc(dev);
+ if ((sc == NULL) || (sc->port <= 0))
+ return ENXIO;
+
+ /*
+ * Add all devices configured to be attached to atkbdc0.
+ */
+ for (i = resource_query_string(-1, "at", "atkbdc0");
+ i != -1;
+ i = resource_query_string(i, "at", "atkbdc0")) {
+ atkbdc_add_device(dev, resource_query_name(i),
+ resource_query_unit(i));
+ }
+
+ /*
+ * and atkbdc?
+ */
+ for (i = resource_query_string(-1, "at", "atkbdc");
+ i != -1;
+ i = resource_query_string(i, "at", "atkbdc")) {
+ atkbdc_add_device(dev, resource_query_name(i),
+ resource_query_unit(i));
+ }
+
+ bus_generic_attach(dev);
+
+ return 0;
+}
+
+static void
+atkbdc_print_child(device_t bus, device_t dev)
+{
+ atkbdc_device_t *kbdcdev;
+
+ kbdcdev = (atkbdc_device_t *)device_get_ivars(dev);
+
+ if (kbdcdev->flags != 0)
+ printf(" flags 0x%x", kbdcdev->flags);
+
+ printf(" on %s%d", device_get_name(bus), device_get_unit(bus));
+}
+
+static int
+atkbdc_read_ivar(device_t bus, device_t dev, int index, u_long *val)
+{
+ atkbdc_device_t *ivar;
+
+ ivar = (atkbdc_device_t *)device_get_ivars(dev);
+ switch (index) {
+ case KBDC_IVAR_PORT:
+ *val = (u_long)ivar->port;
+ break;
+ case KBDC_IVAR_IRQ:
+ *val = (u_long)ivar->irq;
+ break;
+ case KBDC_IVAR_FLAGS:
+ *val = (u_long)ivar->flags;
+ break;
+ default:
+ return ENOENT;
+ }
+ return 0;
+}
+
+static int
+atkbdc_write_ivar(device_t bus, device_t dev, int index, u_long val)
+{
+ atkbdc_device_t *ivar;
+
+ ivar = (atkbdc_device_t *)device_get_ivars(dev);
+ switch (index) {
+ case KBDC_IVAR_PORT:
+ ivar->port = (int)val;
+ break;
+ case KBDC_IVAR_IRQ:
+ ivar->irq = (int)val;
+ break;
+ case KBDC_IVAR_FLAGS:
+ ivar->flags = (int)val;
+ break;
+ default:
+ return ENOENT;
+ }
+ return 0;
+}
+
+DRIVER_MODULE(atkbdc, isa, atkbdc_driver, atkbdc_devclass, 0, 0);
+
+#endif /* NATKBDC > 0 */
diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c
index 5b999e1..e7eb469 100644
--- a/sys/dev/atkbdc/psm.c
+++ b/sys/dev/atkbdc/psm.c
@@ -20,7 +20,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: psm.c,v 1.1 1998/11/08 18:43:03 dfr Exp $
+ * $Id: psm.c,v 1.2 1998/11/15 18:25:17 dfr Exp $
*/
/*
@@ -90,7 +90,7 @@
#include <isa/isareg.h>
#include <isa/isavar.h>
-#include <isa/kbdio.h>
+#include <dev/kbd/atkbdcreg.h>
/*
* Driver specific options: the following options may be set by
@@ -740,6 +740,8 @@ psmprobe(device_t dev)
{
int unit = device_get_unit(dev);
struct psm_softc *sc = device_get_softc(dev);
+ u_long port;
+ u_long flags;
int stat[3];
int command_byte;
int mask;
@@ -748,13 +750,18 @@ psmprobe(device_t dev)
#if 0
kbdc_debug(TRUE);
#endif
- sc->addr = isa_get_port(dev);
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
+
+ sc->addr = port;
sc->kbdc = kbdc_open(sc->addr);
- sc->config = isa_get_flags(dev) & PSM_CONFIG_FLAGS;
+ sc->config = flags & PSM_CONFIG_FLAGS;
sc->flags = 0;
if (bootverbose)
++verbose;
+ device_set_desc(dev, "PS/2 Mouse");
+
if (!kbdc_lock(sc->kbdc, TRUE)) {
printf("psm%d: unable to lock the controller.\n", unit);
if (bootverbose)
@@ -984,6 +991,7 @@ psmattach(device_t dev)
struct psm_softc *sc = device_get_softc(dev);
void *ih;
struct resource *res;
+ u_long irq;
int zero = 0;
if (sc == NULL) /* shouldn't happen */
@@ -1027,7 +1035,8 @@ psmattach(device_t dev)
if (bootverbose)
--verbose;
- res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, 0ul, ~0ul, 1,
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
+ res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1,
RF_SHAREABLE | RF_ACTIVE);
BUS_SETUP_INTR(device_get_parent(dev), dev, res, psmintr, sc,
&ih);
@@ -2216,7 +2225,7 @@ psmresume(void *dummy)
}
#endif /* PSM_HOOKAPM */
-CDEV_DRIVER_MODULE(psm, isa, psm_driver, psm_devclass,
+CDEV_DRIVER_MODULE(psm, atkbdc, psm_driver, psm_devclass,
CDEV_MAJOR, psm_cdevsw, 0, 0);
#endif /* NPSM > 0 */
diff --git a/sys/isa/atkbd_isa.c b/sys/isa/atkbd_isa.c
new file mode 100644
index 0000000..4513049
--- /dev/null
+++ b/sys/isa/atkbd_isa.c
@@ -0,0 +1,119 @@
+/*-
+ * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer as
+ * the first lines of this file unmodified.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: $
+ */
+
+#include "atkbd.h"
+#include "opt_kbd.h"
+
+#if NATKBD > 0
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/conf.h>
+#include <sys/tty.h>
+#include <sys/bus.h>
+#include <sys/rman.h>
+
+#include <machine/resource.h>
+
+#include <dev/kbd/kbdreg.h>
+#include <dev/kbd/atkbdreg.h>
+#include <dev/kbd/atkbdcreg.h>
+
+#include <isa/isareg.h>
+#include <isa/isavar.h>
+
+devclass_t atkbd_devclass;
+
+static int atkbdprobe(device_t dev);
+static int atkbdattach(device_t dev);
+
+static device_method_t atkbd_methods[] = {
+ DEVMETHOD(device_probe, atkbdprobe),
+ DEVMETHOD(device_attach, atkbdattach),
+ { 0, 0 }
+};
+
+static driver_t atkbd_driver = {
+ ATKBD_DRIVER_NAME,
+ atkbd_methods,
+ DRIVER_TYPE_TTY,
+ sizeof(atkbd_softc_t),
+};
+
+static int
+atkbdprobe(device_t dev)
+{
+ atkbd_softc_t *sc;
+ u_long port;
+ u_long irq;
+ u_long flags;
+
+ sc = (atkbd_softc_t *)device_get_softc(dev);
+
+ device_set_desc(dev, "AT Keyboard");
+
+ /* obtain parameters */
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
+
+ /* probe the device */
+ return atkbd_probe_unit(device_get_unit(dev), sc, port, irq, flags);
+}
+
+static int
+atkbdattach(device_t dev)
+{
+ atkbd_softc_t *sc;
+ u_long irq;
+ struct resource *res;
+ void *ih;
+ int zero = 0;
+ int error;
+
+ sc = (atkbd_softc_t *)device_get_softc(dev);
+
+ error = atkbd_attach_unit(device_get_unit(dev), sc);
+ if (error)
+ return error;
+
+ /* declare our interrupt handler */
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
+ res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1,
+ RF_SHAREABLE | RF_ACTIVE);
+ BUS_SETUP_INTR(device_get_parent(dev), dev, res,
+ (driver_intr_t *) kbdsw[sc->kbd->kb_index]->intr, sc->kbd,
+ &ih);
+
+ return 0;
+}
+
+DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0);
+
+#endif /* NATKBD > 0 */
diff --git a/sys/isa/atkbdc_isa.c b/sys/isa/atkbdc_isa.c
new file mode 100644
index 0000000..4435e1e
--- /dev/null
+++ b/sys/isa/atkbdc_isa.c
@@ -0,0 +1,242 @@
+/*-
+ * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer as
+ * the first lines of this file unmodified.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: $
+ */
+
+#include "atkbdc.h"
+#include "opt_kbd.h"
+
+#if NATKBDC > 0
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/malloc.h>
+
+#include <dev/kbd/atkbdcreg.h>
+
+#include <isa/isareg.h>
+#include <isa/isavar.h>
+
+MALLOC_DEFINE(M_ATKBDDEV, "atkbddev", "AT Keyboard device");
+
+/* children */
+typedef struct atkbdc_device {
+ int flags; /* configuration flags */
+ int port; /* port number (same as the controller's) */
+ int irq; /* ISA IRQ mask */
+} atkbdc_device_t;
+
+/* kbdc */
+devclass_t atkbdc_devclass;
+
+static int atkbdc_probe(device_t dev);
+static int atkbdc_attach(device_t dev);
+static void atkbdc_print_child(device_t bus, device_t dev);
+static int atkbdc_read_ivar(device_t bus, device_t dev, int index,
+ u_long *val);
+static int atkbdc_write_ivar(device_t bus, device_t dev, int index,
+ u_long val);
+
+static device_method_t atkbdc_methods[] = {
+ DEVMETHOD(device_probe, atkbdc_probe),
+ DEVMETHOD(device_attach, atkbdc_attach),
+
+ DEVMETHOD(bus_print_child, atkbdc_print_child),
+ DEVMETHOD(bus_read_ivar, atkbdc_read_ivar),
+ DEVMETHOD(bus_write_ivar, atkbdc_write_ivar),
+ DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
+ DEVMETHOD(bus_release_resource, bus_generic_release_resource),
+ DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
+ DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
+ DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
+ DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
+
+ { 0, 0 }
+};
+
+static driver_t atkbdc_driver = {
+ ATKBDC_DRIVER_NAME,
+ atkbdc_methods,
+ DRIVER_TYPE_MISC,
+ sizeof(atkbdc_softc_t *),
+};
+
+static int
+atkbdc_probe(device_t dev)
+{
+ atkbdc_softc_t *sc;
+ int unit;
+ int error;
+
+ unit = device_get_unit(dev);
+ sc = *(atkbdc_softc_t **)device_get_softc(dev);
+ if (sc == NULL) {
+ /*
+ * We have to maintain two copies of the kbdc_softc struct,
+ * as the low-level console needs to have access to the
+ * keyboard controller before kbdc is probed and attached.
+ * kbdc_soft[] contains the default entry for that purpose.
+ * See atkbdc.c. XXX
+ */
+ sc = atkbdc_get_softc(unit);
+ if (sc == NULL)
+ return ENOMEM;
+ }
+
+ device_set_desc(dev, "keyboard controller (i8042)");
+
+ error = atkbdc_probe_unit(sc, unit, isa_get_port(dev));
+ if (error == 0)
+ *(atkbdc_softc_t **)device_get_softc(dev) = sc;
+
+ return error;
+}
+
+static void
+atkbdc_add_device(device_t dev, const char *name, int unit)
+{
+ atkbdc_softc_t *sc = *(atkbdc_softc_t **)device_get_softc(dev);
+ atkbdc_device_t *kdev;
+ device_t child;
+ int t;
+
+ kdev = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, M_NOWAIT);
+ if (!kdev)
+ return;
+ bzero(kdev, sizeof *kdev);
+
+ kdev->port = sc->port;
+
+ if (resource_int_value(name, unit, "irq", &t) == 0)
+ kdev->irq = t;
+ else
+ kdev->irq = -1;
+
+ if (resource_int_value(name, unit, "flags", &t) == 0)
+ kdev->flags = t;
+ else
+ kdev->flags = 0;
+
+ child = device_add_child(dev, name, unit, kdev);
+}
+
+static int
+atkbdc_attach(device_t dev)
+{
+ atkbdc_softc_t *sc;
+ int i;
+
+ sc = *(atkbdc_softc_t **)device_get_softc(dev);
+ if ((sc == NULL) || (sc->port <= 0))
+ return ENXIO;
+
+ /*
+ * Add all devices configured to be attached to atkbdc0.
+ */
+ for (i = resource_query_string(-1, "at", "atkbdc0");
+ i != -1;
+ i = resource_query_string(i, "at", "atkbdc0")) {
+ atkbdc_add_device(dev, resource_query_name(i),
+ resource_query_unit(i));
+ }
+
+ /*
+ * and atkbdc?
+ */
+ for (i = resource_query_string(-1, "at", "atkbdc");
+ i != -1;
+ i = resource_query_string(i, "at", "atkbdc")) {
+ atkbdc_add_device(dev, resource_query_name(i),
+ resource_query_unit(i));
+ }
+
+ bus_generic_attach(dev);
+
+ return 0;
+}
+
+static void
+atkbdc_print_child(device_t bus, device_t dev)
+{
+ atkbdc_device_t *kbdcdev;
+
+ kbdcdev = (atkbdc_device_t *)device_get_ivars(dev);
+
+ if (kbdcdev->flags != 0)
+ printf(" flags 0x%x", kbdcdev->flags);
+
+ printf(" on %s%d", device_get_name(bus), device_get_unit(bus));
+}
+
+static int
+atkbdc_read_ivar(device_t bus, device_t dev, int index, u_long *val)
+{
+ atkbdc_device_t *ivar;
+
+ ivar = (atkbdc_device_t *)device_get_ivars(dev);
+ switch (index) {
+ case KBDC_IVAR_PORT:
+ *val = (u_long)ivar->port;
+ break;
+ case KBDC_IVAR_IRQ:
+ *val = (u_long)ivar->irq;
+ break;
+ case KBDC_IVAR_FLAGS:
+ *val = (u_long)ivar->flags;
+ break;
+ default:
+ return ENOENT;
+ }
+ return 0;
+}
+
+static int
+atkbdc_write_ivar(device_t bus, device_t dev, int index, u_long val)
+{
+ atkbdc_device_t *ivar;
+
+ ivar = (atkbdc_device_t *)device_get_ivars(dev);
+ switch (index) {
+ case KBDC_IVAR_PORT:
+ ivar->port = (int)val;
+ break;
+ case KBDC_IVAR_IRQ:
+ ivar->irq = (int)val;
+ break;
+ case KBDC_IVAR_FLAGS:
+ ivar->flags = (int)val;
+ break;
+ default:
+ return ENOENT;
+ }
+ return 0;
+}
+
+DRIVER_MODULE(atkbdc, isa, atkbdc_driver, atkbdc_devclass, 0, 0);
+
+#endif /* NATKBDC > 0 */
diff --git a/sys/isa/kbdio.c b/sys/isa/kbdio.c
deleted file mode 100644
index 5243d42..0000000
--- a/sys/isa/kbdio.c
+++ /dev/null
@@ -1,1039 +0,0 @@
-/*-
- * Copyright (c) 1996 Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id: kbdio.c,v 1.13 1998/08/06 09:15:53 dfr Exp $
- * from: i386/isa kbdio.c,v 1.12
- */
-
-#include "sc.h"
-/* #include "vt.h" */
-#define NVT 0
-#include "psm.h"
-#include "opt_kbdio.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/syslog.h>
-#include <machine/clock.h>
-#include <isa/kbdio.h>
-
-/*
- * driver specific options: the following options may be set by
- * `options' statements in the kernel configuration file.
- */
-
-/* retry count */
-#ifndef KBD_MAXRETRY
-#define KBD_MAXRETRY 3
-#endif
-
-/* timing parameters */
-#ifndef KBD_RESETDELAY
-#define KBD_RESETDELAY 200 /* wait 200msec after kbd/mouse reset */
-#endif
-#ifndef KBD_MAXWAIT
-#define KBD_MAXWAIT 5 /* wait 5 times at most after reset */
-#endif
-
-/* I/O recovery time */
-#ifdef PC98
-#define KBDC_DELAYTIME 37
-#define KBDD_DELAYTIME 37
-#else
-#define KBDC_DELAYTIME 20
-#define KBDD_DELAYTIME 7
-#endif
-
-/* debug option */
-#ifndef KBDIO_DEBUG
-#define KBDIO_DEBUG 0
-#endif
-
-/* end of driver specific options */
-
-/* constants */
-
-#define NKBDC MAX(MAX(NSC, NVT), NPSM)
-#define KBDQ_BUFSIZE 32
-
-/* macros */
-
-#ifndef MAX
-#define MAX(x, y) ((x) > (y) ? (x) : (y))
-#endif
-
-#define kbdcp(p) ((struct kbdc_softc *)(p))
-#define nextq(i) (((i) + 1) % KBDQ_BUFSIZE)
-#define availq(q) ((q)->head != (q)->tail)
-#if KBDIO_DEBUG >= 2
-#define emptyq(q) ((q)->tail = (q)->head = (q)->qcount = 0)
-#else
-#define emptyq(q) ((q)->tail = (q)->head = 0)
-#endif
-
-/* local variables */
-
-typedef struct _kqueue {
- int head;
- int tail;
- unsigned char q[KBDQ_BUFSIZE];
-#if KBDIO_DEBUG >= 2
- int call_count;
- int qcount;
- int max_qcount;
-#endif
-} kqueue;
-
-struct kbdc_softc {
- int port; /* base port address */
- int command_byte; /* current command byte value */
- int command_mask; /* command byte mask bits for kbd/aux devices */
- int lock; /* FIXME: XXX not quite a semaphore... */
- kqueue kbd; /* keyboard data queue */
- kqueue aux; /* auxiliary data queue */
-};
-
-static struct kbdc_softc kbdc_softc[NKBDC] = { { 0 }, };
-
-static int verbose = KBDIO_DEBUG;
-
-/* function prototypes */
-
-#ifndef PC98
-static int addq(kqueue *q, int c);
-static int removeq(kqueue *q);
-static int wait_while_controller_busy(struct kbdc_softc *kbdc);
-static int wait_for_data(struct kbdc_softc *kbdc);
-#endif
-static int wait_for_kbd_data(struct kbdc_softc *kbdc);
-#ifndef PC98
-static int wait_for_kbd_ack(struct kbdc_softc *kbdc);
-static int wait_for_aux_data(struct kbdc_softc *kbdc);
-static int wait_for_aux_ack(struct kbdc_softc *kbdc);
-#endif
-
-/* associate a port number with a KBDC */
-
-KBDC
-kbdc_open(int port)
-{
-#ifdef PC98
- if (NKBDC) {
- /* PC-98 has only one keyboard I/F */
- kbdc_softc[0].port = port;
- kbdc_softc[0].lock = FALSE;
- return (KBDC)&kbdc_softc[0];
- }
- return NULL; /* You didn't include sc driver in your config file */
-#else
- int s;
- int i;
-
- s = spltty();
- for (i = 0; i < NKBDC; ++i) {
- if (kbdc_softc[i].port == port) {
- splx(s);
- return (KBDC) &kbdc_softc[i];
- }
- if (kbdc_softc[i].port <= 0) {
- kbdc_softc[i].port = port;
- kbdc_softc[i].command_byte = -1;
- kbdc_softc[i].command_mask = 0;
- kbdc_softc[i].lock = FALSE;
- kbdc_softc[i].kbd.head = kbdc_softc[i].kbd.tail = 0;
- kbdc_softc[i].aux.head = kbdc_softc[i].aux.tail = 0;
-#if KBDIO_DEBUG >= 2
- kbdc_softc[i].kbd.call_count = 0;
- kbdc_softc[i].kbd.qcount = kbdc_softc[i].kbd.max_qcount = 0;
- kbdc_softc[i].aux.call_count = 0;
- kbdc_softc[i].aux.qcount = kbdc_softc[i].aux.max_qcount = 0;
-#endif
- splx(s);
- return (KBDC) &kbdc_softc[i];
- }
- }
- splx(s);
- return NULL;
-#endif
-}
-
-/*
- * I/O access arbitration in `kbdio'
- *
- * The `kbdio' module uses a simplistic convention to arbitrate
- * I/O access to the controller/keyboard/mouse. The convention requires
- * close cooperation of the calling device driver.
- *
- * The device driver which utilizes the `kbdio' module are assumed to
- * have the following set of routines.
- * a. An interrupt handler (the bottom half of the driver).
- * b. Timeout routines which may briefly polls the keyboard controller.
- * c. Routines outside interrupt context (the top half of the driver).
- * They should follow the rules below:
- * 1. The interrupt handler may assume that it always has full access
- * to the controller/keyboard/mouse.
- * 2. The other routines must issue `spltty()' if they wish to
- * prevent the interrupt handler from accessing
- * the controller/keyboard/mouse.
- * 3. The timeout routines and the top half routines of the device driver
- * arbitrate I/O access by observing the lock flag in `kbdio'.
- * The flag is manipulated via `kbdc_lock()'; when one wants to
- * perform I/O, call `kbdc_lock(kbdc, TRUE)' and proceed only if
- * the call returns with TRUE. Otherwise the caller must back off.
- * Call `kbdc_lock(kbdc, FALSE)' when necessary I/O operaion
- * is finished. This mechanism does not prevent the interrupt
- * handler from being invoked at any time and carrying out I/O.
- * Therefore, `spltty()' must be strategically placed in the device
- * driver code. Also note that the timeout routine may interrupt
- * `kbdc_lock()' called by the top half of the driver, but this
- * interruption is OK so long as the timeout routine observes the
- * the rule 4 below.
- * 4. The interrupt and timeout routines should not extend I/O operation
- * across more than one interrupt or timeout; they must complete
- * necessary I/O operation within one invokation of the routine.
- * This measns that if the timeout routine acquires the lock flag,
- * it must reset the flag to FALSE before it returns.
- */
-
-/* set/reset polling lock */
-int
-kbdc_lock(KBDC p, int lock)
-{
- int prevlock;
-
- prevlock = kbdcp(p)->lock;
- kbdcp(p)->lock = lock;
-
- return (prevlock != lock);
-}
-
-/* check if any data is waiting to be processed */
-int
-kbdc_data_ready(KBDC p)
-{
-#ifdef PC98
- return (inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_ANY_BUFFER_FULL);
-#else
- return (availq(&kbdcp(p)->kbd) || availq(&kbdcp(p)->aux)
- || (inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_ANY_BUFFER_FULL));
-#endif
-}
-
-#ifndef PC98
-/* queuing functions */
-
-static int
-addq(kqueue *q, int c)
-{
- if (nextq(q->tail) != q->head) {
- q->q[q->tail] = c;
- q->tail = nextq(q->tail);
-#if KBDIO_DEBUG >= 2
- ++q->call_count;
- ++q->qcount;
- if (q->qcount > q->max_qcount)
- q->max_qcount = q->qcount;
-#endif
- return TRUE;
- }
- return FALSE;
-}
-
-static int
-removeq(kqueue *q)
-{
- int c;
-
- if (q->tail != q->head) {
- c = q->q[q->head];
- q->head = nextq(q->head);
-#if KBDIO_DEBUG >= 2
- --q->qcount;
-#endif
- return c;
- }
- return -1;
-}
-
-/*
- * device I/O routines
- */
-static int
-wait_while_controller_busy(struct kbdc_softc *kbdc)
-{
- /* CPU will stay inside the loop for 100msec at most */
- int retry = 5000;
- int port = kbdc->port;
- int f;
-
- while ((f = inb(port + KBD_STATUS_PORT)) & KBDS_INPUT_BUFFER_FULL) {
- if ((f & KBDS_BUFFER_FULL) == KBDS_KBD_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- addq(&kbdc->kbd, inb(port + KBD_DATA_PORT));
- } else if ((f & KBDS_BUFFER_FULL) == KBDS_AUX_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- addq(&kbdc->aux, inb(port + KBD_DATA_PORT));
- }
- DELAY(KBDC_DELAYTIME);
- if (--retry < 0)
- return FALSE;
- }
- return TRUE;
-}
-
-/*
- * wait for any data; whether it's from the controller,
- * the keyboard, or the aux device.
- */
-static int
-wait_for_data(struct kbdc_softc *kbdc)
-{
- /* CPU will stay inside the loop for 200msec at most */
- int retry = 10000;
- int port = kbdc->port;
- int f;
-
- while ((f = inb(port + KBD_STATUS_PORT) & KBDS_ANY_BUFFER_FULL) == 0) {
- DELAY(KBDC_DELAYTIME);
- if (--retry < 0)
- return 0;
- }
- DELAY(KBDD_DELAYTIME);
- return f;
-}
-#endif /* !PC98 */
-
-/* wait for data from the keyboard */
-static int
-wait_for_kbd_data(struct kbdc_softc *kbdc)
-{
- /* CPU will stay inside the loop for 200msec at most */
- int retry = 10000;
- int port = kbdc->port;
- int f;
-
- while ((f = inb(port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL)
- != KBDS_KBD_BUFFER_FULL) {
-#ifdef PC98
- DELAY(KBDD_DELAYTIME);
-#else
- if (f == KBDS_AUX_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- addq(&kbdc->aux, inb(port + KBD_DATA_PORT));
- }
-#endif
- DELAY(KBDC_DELAYTIME);
- if (--retry < 0)
- return 0;
- }
- DELAY(KBDD_DELAYTIME);
- return f;
-}
-
-#ifndef PC98
-/*
- * wait for an ACK(FAh), RESEND(FEh), or RESET_FAIL(FCh) from the keyboard.
- * queue anything else.
- */
-static int
-wait_for_kbd_ack(struct kbdc_softc *kbdc)
-{
- /* CPU will stay inside the loop for 200msec at most */
- int retry = 10000;
- int port = kbdc->port;
- int f;
- int b;
-
- while (retry-- > 0) {
- if ((f = inb(port + KBD_STATUS_PORT)) & KBDS_ANY_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- b = inb(port + KBD_DATA_PORT);
- if ((f & KBDS_BUFFER_FULL) == KBDS_KBD_BUFFER_FULL) {
- if ((b == KBD_ACK) || (b == KBD_RESEND)
- || (b == KBD_RESET_FAIL))
- return b;
- addq(&kbdc->kbd, b);
- } else if ((f & KBDS_BUFFER_FULL) == KBDS_AUX_BUFFER_FULL) {
- addq(&kbdc->aux, b);
- }
- }
- DELAY(KBDC_DELAYTIME);
- }
- return -1;
-}
-
-/* wait for data from the aux device */
-static int
-wait_for_aux_data(struct kbdc_softc *kbdc)
-{
- /* CPU will stay inside the loop for 200msec at most */
- int retry = 10000;
- int port = kbdc->port;
- int f;
-
- while ((f = inb(port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL)
- != KBDS_AUX_BUFFER_FULL) {
- if (f == KBDS_KBD_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- addq(&kbdc->kbd, inb(port + KBD_DATA_PORT));
- }
- DELAY(KBDC_DELAYTIME);
- if (--retry < 0)
- return 0;
- }
- DELAY(KBDD_DELAYTIME);
- return f;
-}
-
-/*
- * wait for an ACK(FAh), RESEND(FEh), or RESET_FAIL(FCh) from the aux device.
- * queue anything else.
- */
-static int
-wait_for_aux_ack(struct kbdc_softc *kbdc)
-{
- /* CPU will stay inside the loop for 200msec at most */
- int retry = 10000;
- int port = kbdc->port;
- int f;
- int b;
-
- while (retry-- > 0) {
- if ((f = inb(port + KBD_STATUS_PORT)) & KBDS_ANY_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- b = inb(port + KBD_DATA_PORT);
- if ((f & KBDS_BUFFER_FULL) == KBDS_AUX_BUFFER_FULL) {
- if ((b == PSM_ACK) || (b == PSM_RESEND)
- || (b == PSM_RESET_FAIL))
- return b;
- addq(&kbdc->aux, b);
- } else if ((f & KBDS_BUFFER_FULL) == KBDS_KBD_BUFFER_FULL) {
- addq(&kbdc->kbd, b);
- }
- }
- DELAY(KBDC_DELAYTIME);
- }
- return -1;
-}
-
-/* write a one byte command to the controller */
-int
-write_controller_command(KBDC p, int c)
-{
- if (!wait_while_controller_busy(kbdcp(p)))
- return FALSE;
- outb(kbdcp(p)->port + KBD_COMMAND_PORT, c);
- return TRUE;
-}
-
-/* write a one byte data to the controller */
-int
-write_controller_data(KBDC p, int c)
-{
- if (!wait_while_controller_busy(kbdcp(p)))
- return FALSE;
- outb(kbdcp(p)->port + KBD_DATA_PORT, c);
- return TRUE;
-}
-
-/* write a one byte keyboard command */
-int
-write_kbd_command(KBDC p, int c)
-{
- if (!wait_while_controller_busy(kbdcp(p)))
- return FALSE;
- outb(kbdcp(p)->port + KBD_DATA_PORT, c);
- return TRUE;
-}
-
-/* write a one byte auxiliary device command */
-int
-write_aux_command(KBDC p, int c)
-{
- if (!write_controller_command(p, KBDC_WRITE_TO_AUX))
- return FALSE;
- return write_controller_data(p, c);
-}
-
-/* send a command to the keyboard and wait for ACK */
-int
-send_kbd_command(KBDC p, int c)
-{
- int retry = KBD_MAXRETRY;
- int res = -1;
-
- while (retry-- > 0) {
- if (!write_kbd_command(p, c))
- continue;
- res = wait_for_kbd_ack(kbdcp(p));
- if (res == KBD_ACK)
- break;
- }
- return res;
-}
-
-/* send a command to the auxiliary device and wait for ACK */
-int
-send_aux_command(KBDC p, int c)
-{
- int retry = KBD_MAXRETRY;
- int res = -1;
-
- while (retry-- > 0) {
- if (!write_aux_command(p, c))
- continue;
- /*
- * FIXME: XXX
- * The aux device may have already sent one or two bytes of
- * status data, when a command is received. It will immediately
- * stop data transmission, thus, leaving an incomplete data
- * packet in our buffer. We have to discard any unprocessed
- * data in order to remove such packets. Well, we may remove
- * unprocessed, but necessary data byte as well...
- */
- emptyq(&kbdcp(p)->aux);
- res = wait_for_aux_ack(kbdcp(p));
- if (res == PSM_ACK)
- break;
- }
- return res;
-}
-
-/* send a command and a data to the keyboard, wait for ACKs */
-int
-send_kbd_command_and_data(KBDC p, int c, int d)
-{
- int retry;
- int res = -1;
-
- for (retry = KBD_MAXRETRY; retry > 0; --retry) {
- if (!write_kbd_command(p, c))
- continue;
- res = wait_for_kbd_ack(kbdcp(p));
- if (res == KBD_ACK)
- break;
- else if (res != KBD_RESEND)
- return res;
- }
- if (retry <= 0)
- return res;
-
- for (retry = KBD_MAXRETRY, res = -1; retry > 0; --retry) {
- if (!write_kbd_command(p, d))
- continue;
- res = wait_for_kbd_ack(kbdcp(p));
- if (res != KBD_RESEND)
- break;
- }
- return res;
-}
-
-/* send a command and a data to the auxiliary device, wait for ACKs */
-int
-send_aux_command_and_data(KBDC p, int c, int d)
-{
- int retry;
- int res = -1;
-
- for (retry = KBD_MAXRETRY; retry > 0; --retry) {
- if (!write_aux_command(p, c))
- continue;
- emptyq(&kbdcp(p)->aux);
- res = wait_for_aux_ack(kbdcp(p));
- if (res == PSM_ACK)
- break;
- else if (res != PSM_RESEND)
- return res;
- }
- if (retry <= 0)
- return res;
-
- for (retry = KBD_MAXRETRY, res = -1; retry > 0; --retry) {
- if (!write_aux_command(p, d))
- continue;
- res = wait_for_aux_ack(kbdcp(p));
- if (res != PSM_RESEND)
- break;
- }
- return res;
-}
-
-/*
- * read one byte from any source; whether from the controller,
- * the keyboard, or the aux device
- */
-int
-read_controller_data(KBDC p)
-{
- if (availq(&kbdcp(p)->kbd))
- return removeq(&kbdcp(p)->kbd);
- if (availq(&kbdcp(p)->aux))
- return removeq(&kbdcp(p)->aux);
- if (!wait_for_data(kbdcp(p)))
- return -1; /* timeout */
- return inb(kbdcp(p)->port + KBD_DATA_PORT);
-}
-#endif /* !PC98 */
-
-#if KBDIO_DEBUG >= 2
-static int call = 0;
-#endif
-
-/* read one byte from the keyboard */
-int
-read_kbd_data(KBDC p)
-{
-#ifndef PC98
-#if KBDIO_DEBUG >= 2
- if (++call > 2000) {
- call = 0;
- log(LOG_DEBUG, "KBDIO: kbd q: %d calls, max %d chars, "
- "aux q: %d calls, max %d chars\n",
- kbdcp(p)->kbd.call_count, kbdcp(p)->kbd.max_qcount,
- kbdcp(p)->aux.call_count, kbdcp(p)->aux.max_qcount);
- }
-#endif
-
- if (availq(&kbdcp(p)->kbd))
- return removeq(&kbdcp(p)->kbd);
-#endif /* !PC98 */
- if (!wait_for_kbd_data(kbdcp(p)))
- return -1; /* timeout */
-#ifdef PC98
- DELAY(KBDC_DELAYTIME);
-#endif
- return inb(kbdcp(p)->port + KBD_DATA_PORT);
-}
-
-/* read one byte from the keyboard, but return immediately if
- * no data is waiting
- */
-int
-read_kbd_data_no_wait(KBDC p)
-{
- int f;
-
-#ifdef PC98
- f = inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL;
-#else
-#if KBDIO_DEBUG >= 2
- if (++call > 2000) {
- call = 0;
- log(LOG_DEBUG, "KBDIO: kbd q: %d calls, max %d chars, "
- "aux q: %d calls, max %d chars\n",
- kbdcp(p)->kbd.call_count, kbdcp(p)->kbd.max_qcount,
- kbdcp(p)->aux.call_count, kbdcp(p)->aux.max_qcount);
- }
-#endif
-
- if (availq(&kbdcp(p)->kbd))
- return removeq(&kbdcp(p)->kbd);
- f = inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL;
- if (f == KBDS_AUX_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- addq(&kbdcp(p)->aux, inb(kbdcp(p)->port + KBD_DATA_PORT));
- f = inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL;
- }
-#endif /* PC98 */
- if (f == KBDS_KBD_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- return inb(kbdcp(p)->port + KBD_DATA_PORT);
- }
- return -1; /* no data */
-}
-
-#ifndef PC98
-/* read one byte from the aux device */
-int
-read_aux_data(KBDC p)
-{
- if (availq(&kbdcp(p)->aux))
- return removeq(&kbdcp(p)->aux);
- if (!wait_for_aux_data(kbdcp(p)))
- return -1; /* timeout */
- return inb(kbdcp(p)->port + KBD_DATA_PORT);
-}
-
-/* read one byte from the aux device, but return immediately if
- * no data is waiting
- */
-int
-read_aux_data_no_wait(KBDC p)
-{
- int f;
-
- if (availq(&kbdcp(p)->aux))
- return removeq(&kbdcp(p)->aux);
- f = inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL;
- if (f == KBDS_KBD_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- addq(&kbdcp(p)->kbd, inb(kbdcp(p)->port + KBD_DATA_PORT));
- f = inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL;
- }
- if (f == KBDS_AUX_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- return inb(kbdcp(p)->port + KBD_DATA_PORT);
- }
- return -1; /* no data */
-}
-
-/* discard data from the keyboard */
-void
-empty_kbd_buffer(KBDC p, int wait)
-{
- int t;
- int b;
- int f;
-#if KBDIO_DEBUG >= 2
- int c1 = 0;
- int c2 = 0;
-#endif
- int delta = 2;
-
- for (t = wait; t > 0; ) {
- if ((f = inb(kbdcp(p)->port + KBD_STATUS_PORT)) & KBDS_ANY_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- b = inb(kbdcp(p)->port + KBD_DATA_PORT);
- if ((f & KBDS_BUFFER_FULL) == KBDS_AUX_BUFFER_FULL) {
- addq(&kbdcp(p)->aux, b);
-#if KBDIO_DEBUG >= 2
- ++c2;
- } else {
- ++c1;
-#endif
- }
- t = wait;
- } else {
- t -= delta;
- }
- DELAY(delta*1000);
- }
-#if KBDIO_DEBUG >= 2
- if ((c1 > 0) || (c2 > 0))
- log(LOG_DEBUG, "kbdio: %d:%d char read (empty_kbd_buffer)\n", c1, c2);
-#endif
-
- emptyq(&kbdcp(p)->kbd);
-}
-
-/* discard data from the aux device */
-void
-empty_aux_buffer(KBDC p, int wait)
-{
- int t;
- int b;
- int f;
-#if KBDIO_DEBUG >= 2
- int c1 = 0;
- int c2 = 0;
-#endif
- int delta = 2;
-
- for (t = wait; t > 0; ) {
- if ((f = inb(kbdcp(p)->port + KBD_STATUS_PORT)) & KBDS_ANY_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- b = inb(kbdcp(p)->port + KBD_DATA_PORT);
- if ((f & KBDS_BUFFER_FULL) == KBDS_KBD_BUFFER_FULL) {
- addq(&kbdcp(p)->kbd, b);
-#if KBDIO_DEBUG >= 2
- ++c1;
- } else {
- ++c2;
-#endif
- }
- t = wait;
- } else {
- t -= delta;
- }
- DELAY(delta*1000);
- }
-#if KBDIO_DEBUG >= 2
- if ((c1 > 0) || (c2 > 0))
- log(LOG_DEBUG, "kbdio: %d:%d char read (empty_aux_buffer)\n", c1, c2);
-#endif
-
- emptyq(&kbdcp(p)->aux);
-}
-
-/* discard any data from the keyboard or the aux device */
-void
-empty_both_buffers(KBDC p, int wait)
-{
- int t;
- int f;
-#if KBDIO_DEBUG >= 2
- int c1 = 0;
- int c2 = 0;
-#endif
- int delta = 2;
-
- for (t = wait; t > 0; ) {
- if ((f = inb(kbdcp(p)->port + KBD_STATUS_PORT)) & KBDS_ANY_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- (void)inb(kbdcp(p)->port + KBD_DATA_PORT);
-#if KBDIO_DEBUG >= 2
- if ((f & KBDS_BUFFER_FULL) == KBDS_KBD_BUFFER_FULL)
- ++c1;
- else
- ++c2;
-#endif
- t = wait;
- } else {
- t -= delta;
- }
- DELAY(delta*1000);
- }
-#if KBDIO_DEBUG >= 2
- if ((c1 > 0) || (c2 > 0))
- log(LOG_DEBUG, "kbdio: %d:%d char read (empty_both_buffers)\n", c1, c2);
-#endif
-
- emptyq(&kbdcp(p)->kbd);
- emptyq(&kbdcp(p)->aux);
-}
-
-/* keyboard and mouse device control */
-
-/* NOTE: enable the keyboard port but disable the keyboard
- * interrupt before calling "reset_kbd()".
- */
-int
-reset_kbd(KBDC p)
-{
- int retry = KBD_MAXRETRY;
- int again = KBD_MAXWAIT;
- int c = KBD_RESEND; /* keep the compiler happy */
-
- while (retry-- > 0) {
- empty_both_buffers(p, 10);
- if (!write_kbd_command(p, KBDC_RESET_KBD))
- continue;
- emptyq(&kbdcp(p)->kbd);
- c = read_controller_data(p);
- if (verbose || bootverbose)
- log(LOG_DEBUG, "kbdio: RESET_KBD return code:%04x\n", c);
- if (c == KBD_ACK) /* keyboard has agreed to reset itself... */
- break;
- }
- if (retry < 0)
- return FALSE;
-
- while (again-- > 0) {
- /* wait awhile, well, in fact we must wait quite loooooooooooong */
- DELAY(KBD_RESETDELAY*1000);
- c = read_controller_data(p); /* RESET_DONE/RESET_FAIL */
- if (c != -1) /* wait again if the controller is not ready */
- break;
- }
- if (verbose || bootverbose)
- log(LOG_DEBUG, "kbdio: RESET_KBD status:%04x\n", c);
- if (c != KBD_RESET_DONE)
- return FALSE;
- return TRUE;
-}
-
-/* NOTE: enable the aux port but disable the aux interrupt
- * before calling `reset_aux_dev()'.
- */
-int
-reset_aux_dev(KBDC p)
-{
- int retry = KBD_MAXRETRY;
- int again = KBD_MAXWAIT;
- int c = PSM_RESEND; /* keep the compiler happy */
-
- while (retry-- > 0) {
- empty_both_buffers(p, 10);
- if (!write_aux_command(p, PSMC_RESET_DEV))
- continue;
- emptyq(&kbdcp(p)->aux);
- /* NOTE: Compaq Armada laptops require extra delay here. XXX */
- for (again = KBD_MAXWAIT; again > 0; --again) {
- DELAY(KBD_RESETDELAY*1000);
- c = read_aux_data_no_wait(p);
- if (c != -1)
- break;
- }
- if (verbose || bootverbose)
- log(LOG_DEBUG, "kbdio: RESET_AUX return code:%04x\n", c);
- if (c == PSM_ACK) /* aux dev is about to reset... */
- break;
- }
- if (retry < 0)
- return FALSE;
-
- for (again = KBD_MAXWAIT; again > 0; --again) {
- /* wait awhile, well, quite looooooooooooong */
- DELAY(KBD_RESETDELAY*1000);
- c = read_aux_data_no_wait(p); /* RESET_DONE/RESET_FAIL */
- if (c != -1) /* wait again if the controller is not ready */
- break;
- }
- if (verbose || bootverbose)
- log(LOG_DEBUG, "kbdio: RESET_AUX status:%04x\n", c);
- if (c != PSM_RESET_DONE) /* reset status */
- return FALSE;
-
- c = read_aux_data(p); /* device ID */
- if (verbose || bootverbose)
- log(LOG_DEBUG, "kbdio: RESET_AUX ID:%04x\n", c);
- /* NOTE: we could check the device ID now, but leave it later... */
- return TRUE;
-}
-
-/* controller diagnostics and setup */
-
-int
-test_controller(KBDC p)
-{
- int retry = KBD_MAXRETRY;
- int again = KBD_MAXWAIT;
- int c = KBD_DIAG_FAIL;
-
- while (retry-- > 0) {
- empty_both_buffers(p, 10);
- if (write_controller_command(p, KBDC_DIAGNOSE))
- break;
- }
- if (retry < 0)
- return FALSE;
-
- emptyq(&kbdcp(p)->kbd);
- while (again-- > 0) {
- /* wait awhile */
- DELAY(KBD_RESETDELAY*1000);
- c = read_controller_data(p); /* DIAG_DONE/DIAG_FAIL */
- if (c != -1) /* wait again if the controller is not ready */
- break;
- }
- if (verbose || bootverbose)
- log(LOG_DEBUG, "kbdio: DIAGNOSE status:%04x\n", c);
- return (c == KBD_DIAG_DONE);
-}
-
-int
-test_kbd_port(KBDC p)
-{
- int retry = KBD_MAXRETRY;
- int again = KBD_MAXWAIT;
- int c = -1;
-
- while (retry-- > 0) {
- empty_both_buffers(p, 10);
- if (write_controller_command(p, KBDC_TEST_KBD_PORT))
- break;
- }
- if (retry < 0)
- return FALSE;
-
- emptyq(&kbdcp(p)->kbd);
- while (again-- > 0) {
- c = read_controller_data(p);
- if (c != -1) /* try again if the controller is not ready */
- break;
- }
- if (verbose || bootverbose)
- log(LOG_DEBUG, "kbdio: TEST_KBD_PORT status:%04x\n", c);
- return c;
-}
-
-int
-test_aux_port(KBDC p)
-{
- int retry = KBD_MAXRETRY;
- int again = KBD_MAXWAIT;
- int c = -1;
-
- while (retry-- > 0) {
- empty_both_buffers(p, 10);
- if (write_controller_command(p, KBDC_TEST_AUX_PORT))
- break;
- }
- if (retry < 0)
- return FALSE;
-
- emptyq(&kbdcp(p)->kbd);
- while (again-- > 0) {
- c = read_controller_data(p);
- if (c != -1) /* try again if the controller is not ready */
- break;
- }
- if (verbose || bootverbose)
- log(LOG_DEBUG, "kbdio: TEST_AUX_PORT status:%04x\n", c);
- return c;
-}
-
-int
-kbdc_get_device_mask(KBDC p)
-{
- return kbdcp(p)->command_mask;
-}
-
-void
-kbdc_set_device_mask(KBDC p, int mask)
-{
- kbdcp(p)->command_mask =
- mask & (KBD_KBD_CONTROL_BITS | KBD_AUX_CONTROL_BITS);
-}
-
-int
-get_controller_command_byte(KBDC p)
-{
- if (kbdcp(p)->command_byte != -1)
- return kbdcp(p)->command_byte;
- if (!write_controller_command(p, KBDC_GET_COMMAND_BYTE))
- return -1;
- emptyq(&kbdcp(p)->kbd);
- kbdcp(p)->command_byte = read_controller_data(p);
- return kbdcp(p)->command_byte;
-}
-
-int
-set_controller_command_byte(KBDC p, int mask, int command)
-{
- if (get_controller_command_byte(p) == -1)
- return FALSE;
-
- command = (kbdcp(p)->command_byte & ~mask) | (command & mask);
- if (command & KBD_DISABLE_KBD_PORT) {
- if (!write_controller_command(p, KBDC_DISABLE_KBD_PORT))
- return FALSE;
- }
- if (!write_controller_command(p, KBDC_SET_COMMAND_BYTE))
- return FALSE;
- if (!write_controller_data(p, command))
- return FALSE;
- kbdcp(p)->command_byte = command;
-
- if (verbose)
- log(LOG_DEBUG, "kbdio: new command byte:%04x (set_controller...)\n",
- command);
-
- return TRUE;
-}
-#endif /* !PC98 */
diff --git a/sys/isa/kbdio.h b/sys/isa/kbdio.h
deleted file mode 100644
index 3aa0a03..0000000
--- a/sys/isa/kbdio.h
+++ /dev/null
@@ -1,207 +0,0 @@
-/*-
- * Copyright (c) 1996 Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id: kbdio.h,v 1.9 1999/01/06 05:49:30 yokota Exp $
- * from: i386/isa kbdio.h,v 1.7
- */
-
-#ifndef _ISA_KBDIO_H_
-#define _ISA_KBDIO_H_
-
-/* constants */
-
-/* I/O ports */
-#ifdef PC98
-#define KBD_STATUS_PORT 2 /* status port, read */
-#define KBD_COMMAND_PORT 2 /* controller command port, write */
-#define KBD_DATA_PORT 0 /* data port, read/write
- * also used as keyboard command
- * and mouse command port
- */
-#else
-#define KBD_STATUS_PORT 4 /* status port, read */
-#define KBD_COMMAND_PORT 4 /* controller command port, write */
-#define KBD_DATA_PORT 0 /* data port, read/write
- * also used as keyboard command
- * and mouse command port
- */
-#endif /* PC98 */
-
-/* controller commands (sent to KBD_COMMAND_PORT) */
-#define KBDC_SET_COMMAND_BYTE 0x0060
-#define KBDC_GET_COMMAND_BYTE 0x0020
-#define KBDC_WRITE_TO_AUX 0x00d4
-#define KBDC_DISABLE_AUX_PORT 0x00a7
-#define KBDC_ENABLE_AUX_PORT 0x00a8
-#define KBDC_TEST_AUX_PORT 0x00a9
-#define KBDC_DIAGNOSE 0x00aa
-#define KBDC_TEST_KBD_PORT 0x00ab
-#define KBDC_DISABLE_KBD_PORT 0x00ad
-#define KBDC_ENABLE_KBD_PORT 0x00ae
-
-/* controller command byte (set by KBDC_SET_COMMAND_BYTE) */
-#define KBD_TRANSLATION 0x0040
-#define KBD_RESERVED_BITS 0x0004
-#define KBD_OVERRIDE_KBD_LOCK 0x0008
-#define KBD_ENABLE_KBD_PORT 0x0000
-#define KBD_DISABLE_KBD_PORT 0x0010
-#define KBD_ENABLE_AUX_PORT 0x0000
-#define KBD_DISABLE_AUX_PORT 0x0020
-#define KBD_ENABLE_AUX_INT 0x0002
-#define KBD_DISABLE_AUX_INT 0x0000
-#define KBD_ENABLE_KBD_INT 0x0001
-#define KBD_DISABLE_KBD_INT 0x0000
-#define KBD_KBD_CONTROL_BITS (KBD_DISABLE_KBD_PORT | KBD_ENABLE_KBD_INT)
-#define KBD_AUX_CONTROL_BITS (KBD_DISABLE_AUX_PORT | KBD_ENABLE_AUX_INT)
-
-/* keyboard device commands (sent to KBD_DATA_PORT) */
-#define KBDC_RESET_KBD 0x00ff
-#define KBDC_ENABLE_KBD 0x00f4
-#define KBDC_DISABLE_KBD 0x00f5
-#define KBDC_SET_DEFAULTS 0x00f6
-#define KBDC_SEND_DEV_ID 0x00f2
-#define KBDC_SET_LEDS 0x00ed
-#define KBDC_ECHO 0x00ee
-#define KBDC_SET_SCANCODE_SET 0x00f0
-#define KBDC_SET_TYPEMATIC 0x00f3
-
-/* aux device commands (sent to KBD_DATA_PORT) */
-#define PSMC_RESET_DEV 0x00ff
-#define PSMC_ENABLE_DEV 0x00f4
-#define PSMC_DISABLE_DEV 0x00f5
-#define PSMC_SET_DEFAULTS 0x00f6
-#define PSMC_SEND_DEV_ID 0x00f2
-#define PSMC_SEND_DEV_STATUS 0x00e9
-#define PSMC_SEND_DEV_DATA 0x00eb
-#define PSMC_SET_SCALING11 0x00e6
-#define PSMC_SET_SCALING21 0x00e7
-#define PSMC_SET_RESOLUTION 0x00e8
-#define PSMC_SET_STREAM_MODE 0x00ea
-#define PSMC_SET_REMOTE_MODE 0x00f0
-#define PSMC_SET_SAMPLING_RATE 0x00f3
-
-/* PSMC_SET_RESOLUTION argument */
-#define PSMD_RES_LOW 0 /* typically 25ppi */
-#define PSMD_RES_MEDIUM_LOW 1 /* typically 50ppi */
-#define PSMD_RES_MEDIUM_HIGH 2 /* typically 100ppi (default) */
-#define PSMD_RES_HIGH 3 /* typically 200ppi */
-#define PSMD_MAX_RESOLUTION PSMD_RES_HIGH
-
-/* PSMC_SET_SAMPLING_RATE */
-#define PSMD_MAX_RATE 255 /* FIXME: not sure if it's possible */
-
-/* status bits (KBD_STATUS_PORT) */
-#ifdef PC98
-#define KBDS_BUFFER_FULL 0x0002
-#define KBDS_ANY_BUFFER_FULL 0x0002
-#define KBDS_KBD_BUFFER_FULL 0x0002
-#define KBDS_AUX_BUFFER_FULL 0x0002
-#else
-#define KBDS_BUFFER_FULL 0x0021
-#define KBDS_ANY_BUFFER_FULL 0x0001
-#define KBDS_KBD_BUFFER_FULL 0x0001
-#define KBDS_AUX_BUFFER_FULL 0x0021
-#endif
-#define KBDS_INPUT_BUFFER_FULL 0x0002
-
-/* return code */
-#define KBD_ACK 0x00fa
-#define KBD_RESEND 0x00fe
-#define KBD_RESET_DONE 0x00aa
-#define KBD_RESET_FAIL 0x00fc
-#define KBD_DIAG_DONE 0x0055
-#define KBD_DIAG_FAIL 0x00fd
-#define KBD_ECHO 0x00ee
-
-#define PSM_ACK 0x00fa
-#define PSM_RESEND 0x00fe
-#define PSM_RESET_DONE 0x00aa
-#define PSM_RESET_FAIL 0x00fc
-
-/* aux device ID */
-#define PSM_MOUSE_ID 0
-#define PSM_BALLPOINT_ID 2
-#define PSM_INTELLI_ID 3
-
-#ifdef KERNEL
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-/* types/structures */
-
-typedef caddr_t KBDC;
-
-/* function prototypes */
-
-KBDC kbdc_open __P((int port));
-
-int kbdc_lock __P((KBDC kbdc, int lock));
-
-int kbdc_data_ready __P((KBDC kbdc));
-
-int write_controller_command __P((KBDC kbdc,int c));
-int write_controller_data __P((KBDC kbdc,int c));
-
-int write_kbd_command __P((KBDC kbdc,int c));
-int write_aux_command __P((KBDC kbdc,int c));
-int send_kbd_command __P((KBDC kbdc,int c));
-int send_aux_command __P((KBDC kbdc,int c));
-int send_kbd_command_and_data __P((KBDC kbdc,int c,int d));
-int send_aux_command_and_data __P((KBDC kbdc,int c,int d));
-
-int read_controller_data __P((KBDC kbdc));
-int read_kbd_data __P((KBDC kbdc));
-int read_kbd_data_no_wait __P((KBDC kbdc));
-int read_aux_data __P((KBDC kbdc));
-int read_aux_data_no_wait __P((KBDC kbdc));
-
-void empty_kbd_buffer __P((KBDC kbdc, int t));
-void empty_aux_buffer __P((KBDC kbdc, int t));
-void empty_both_buffers __P((KBDC kbdc, int t));
-
-int reset_kbd __P((KBDC kbdc));
-int reset_aux_dev __P((KBDC kbdc));
-
-int test_controller __P((KBDC kbdc));
-int test_kbd_port __P((KBDC kbdc));
-int test_aux_port __P((KBDC kbdc));
-
-int kbdc_get_device_mask __P((KBDC kbdc));
-void kbdc_set_device_mask __P((KBDC kbdc, int mask));
-
-int get_controller_command_byte __P((KBDC kbdc));
-int set_controller_command_byte __P((KBDC kbdc, int command, int flag));
-
-#endif /* KERNEL */
-
-#endif /* !_ISA_KBDIO_H_ */
diff --git a/sys/isa/kbdtables.h b/sys/isa/kbdtables.h
deleted file mode 100644
index 6a1241f..0000000
--- a/sys/isa/kbdtables.h
+++ /dev/null
@@ -1,1333 +0,0 @@
-/*-
- * Copyright (c) 1992-1995 Søren Schmidt
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer
- * in this position and unchanged.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software withough specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $Id$
- * from: i386/isa kbdtables.h,v 1.40
- */
-
-#define SET8 0x80 /* set eight bit on */
-
-#ifdef PC98
-#define NO_ACCENTCHARS
-/* PC-9801 keymap by kuribo@isl.melco.co.jp */
-static keymap_t key_map = { 0x80, /* PC98 keymap */
-/* alt
- * scan cntrl alt alt cntrl
- * code base shift cntrl shift alt shift cntrl shift spcl flgs
- * ---------------------------------------------------------------------------
- */
-/* sc=00 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, 0x02, 0x00,
-/* sc=01 */ '1', '!', '!', '!', '1', '!', '!', '!', 0x00, 0x00,
-/* sc=02 */ '2', '\"', 0x1A, 0x1A, '2', '@', 0x00, 0x00, 0x00, 0x00,
-/* sc=03 */ '3', '#', 0x1B, 0x1B, '3', '#', 0x1B, 0x1B, 0x00, 0x00,
-/* sc=04 */ '4', '$', 0x1C, 0x1C, '4', '$', 0x1C, 0x1C, 0x00, 0x00,
-/* sc=05 */ '5', '%', 0x1D, 0x1D, '5', '%', 0x1D, 0x1D, 0x00, 0x00,
-/* sc=06 */ '6', '&', 0x1E, 0x1E, '6', '^', 0x1E, 0x1E, 0x00, 0x00,
-/* sc=07 */ '7', '\'', 0x1F, 0x1F, '7', '&', '&', '&', 0x00, 0x00,
-/* sc=08 */ '8', '(', 0x7F, 0x7F, '8', '*', 0x08, 0x08, 0x00, 0x00,
-/* sc=09 */ '9', ')', '9', '9', '9', '(', '(', '(', 0x00, 0x00,
-/* sc=0a */ '0', NOP, '0', '0', '0', ')', ')', ')', 0x40, 0x00,
-/* sc=0b */ '-', '=', '-', '-', '-', '_', 0x1F, 0x1F, 0x00, 0x00,
-/* sc=0c */ '^', '`', 0x1E, 0x1E, '=', '+', '+', '+', 0x00, 0x00,
-/* sc=0d */ '\\', '|', 0x1C, 0x1C, '\\', '|', 0x1C, 0x1C, 0x00, 0x00,
-/* sc=0e */ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
-/* sc=0f */ '\t', '\t', '\t', '\t', '\t', '\t', '\t', '\t', 0x00, 0x00,
-/* sc=10 */ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, 0x00, 0x01,
-/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01,
-/* sc=12 */ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, 0x00, 0x01,
-/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01,
-/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01,
-/* sc=15 */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, 0x00, 0x01,
-/* sc=16 */ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, 0x00, 0x01,
-/* sc=17 */ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, 0x00, 0x01,
-/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, 0x00, 0x01,
-/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01,
-/* sc=1a */ '@', '~', 0x00, 0x00, '[', '{', 0x1B, 0x1B, 0x00, 0x00,
-/* sc=1b */ '[', '{', 0x1B, 0x1B, ']', '}', 0x1D, 0x1D, 0x00, 0x00,
-/* sc=1c */ '\r', '\r', '\n', '\n', '\r', '\r', '\n', '\n', 0x00, 0x00,
-/* sc=1d */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01,
-/* sc=1e */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01,
-/* sc=1f */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01,
-/* sc=20 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01,
-/* sc=21 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01,
-/* sc=22 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01,
-/* sc=23 */ 'j', 'J', '\n', '\n', 'j', 'J', '\n', '\n', 0x00, 0x01,
-/* sc=24 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01,
-/* sc=25 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01,
-/* sc=26 */ ';', '+', ';', ';', ';', ':', ';', ';', 0x00, 0x00,
-/* sc=27 */ ':', '*', ':', ':', '\'', '\"', '\'', '\'', 0x00, 0x00,
-/* sc=28 */ ']', '}', 0x1D, 0x1D, '`', '~', '~', '~', 0x00, 0x00,
-/* sc=29 */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, 0x00, 0x01,
-/* sc=2a */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01,
-/* sc=2b */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01,
-/* sc=2c */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01,
-/* sc=2d */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01,
-/* sc=2e */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01,
-/* sc=2f */ 'm', 'M', '\r', '\r', 'm', 'M', '\r', '\r', 0x00, 0x01,
-/* sc=30 */ ',', '<', '<', '<', ',', '<', '<', '<', 0x00, 0x00,
-/* sc=31 */ '.', '>', '>', '>', '.', '>', '>', '>', 0x00, 0x00,
-/* sc=32 */ '/', '?', 0x7F, 0x7F, '/', '?', 0x7F, 0x7F, 0x00, 0x00,
-/* sc=33 */ NOP, '_', 0x1F, 0x1F, '\\', '|', 0x1C, 0x1C, 0x80, 0x00,
-/* sc=34 */ ' ', ' ', 0x00, 0x00, ' ', ' ', 0x00, 0x00, 0x00, 0x00,
-/* sc=35 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00,
-/* sc=36 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00,
-/* sc=37 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00,
-/* sc=38 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00,
-/* sc=39 */ 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, RBT, RBT, 0x03, 0x02,
-/* sc=3a */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00,
-/* sc=3b */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00,
-/* sc=3c */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00,
-/* sc=3d */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00,
-/* sc=3e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00,
-/* sc=3f */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=40 */ '-', '-', '-', '-', '-', '-', '-', '-', 0x00, 0x00,
-/* sc=41 */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x00,
-/* sc=42 */ '7', '7', '7', '7', '7', '7', '7', '7', 0x00, 0x00,
-/* sc=43 */ '8', '8', '8', '8', '8', '8', '8', '8', 0x00, 0x00,
-/* sc=44 */ '9', '9', '9', '9', '9', '9', '9', '9', 0x00, 0x00,
-/* sc=45 */ '*', '*', '*', '*', '*', '*', '*', '*', 0x00, 0x00,
-/* sc=46 */ '4', '4', '4', '4', '4', '4', '4', '4', 0x00, 0x00,
-/* sc=47 */ '5', '5', '5', '5', '5', '5', '5', '5', 0x00, 0x00,
-/* sc=48 */ '6', '6', '6', '6', '6', '6', '6', '6', 0x00, 0x00,
-/* sc=49 */ '+', '+', '+', '+', '+', '+', '+', '+', 0x00, 0x00,
-/* sc=4a */ '1', '1', '1', '1', '1', '1', '1', '1', 0x00, 0x00,
-/* sc=4b */ '2', '2', '2', '2', '2', '2', '2', '2', 0x00, 0x00,
-/* sc=4c */ '3', '3', '3', '3', '3', '3', '3', '3', 0x00, 0x00,
-/* sc=4d */ '=', '=', '=', '=', '=', '=', '=', '=', 0x00, 0x00,
-/* sc=4e */ '0', '0', '0', '0', '0', '0', '0', '0', 0x00, 0x00,
-/* sc=4f */ ',', ',', ',', ',', ',', ',', ',', ',', 0x00, 0x00,
-/* sc=50 */ '.', '.', '.', '.', '.', '.', '.', '.', 0x00, 0x00,
-/* sc=51 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00,
-/* sc=52 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00,
-/* sc=53 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00,
-/* sc=54 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 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,
-/* sc=57 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=58 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=59 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=5a */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=5b */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=5c */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=5d */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=5e */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=5f */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=60 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00,
-/* sc=61 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=62 */ F( 1), F(13), F(25), F(37), S( 1), S( 1), S( 1), S( 1), 0xFF, 0x00,
-/* sc=63 */ F( 2), F(14), F(26), F(38), S( 2), S( 2), S( 2), S( 2), 0xFF, 0x00,
-/* sc=64 */ F( 3), F(15), F(27), F(39), S( 3), S( 3), S( 3), S( 3), 0xFF, 0x00,
-/* sc=65 */ F( 4), F(16), F(28), F(40), S( 4), S( 4), S( 4), S( 4), 0xFF, 0x00,
-/* sc=66 */ F( 5), F(17), F(29), F(41), S( 5), S( 5), S( 5), S( 5), 0xFF, 0x00,
-/* sc=67 */ F( 6), F(18), F(30), F(42), S( 6), S( 6), S( 6), S( 6), 0xFF, 0x00,
-/* sc=68 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00,
-/* sc=69 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00,
-/* sc=6a */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00,
-/* sc=6b */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00,
-/* sc=6c */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=6d */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=6e */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=6f */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=70 */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00,
-/* sc=71 */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00,
-/* sc=72 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00,
-/* sc=73 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00,
-/* sc=74 */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00,
-/* sc=75 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=76 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=77 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=78 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=79 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=7a */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=7b */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=7c */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=7d */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=7e */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=7f */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-};
-#endif
-
-#ifdef DKKEYMAP
-#define ISO_ACCENTCHARS
-static keymap_t key_map = { 0x6C, /* DK iso8859 keymap */
-/* alt
- * scan cntrl alt alt cntrl
- * code base shift cntrl shift alt shift cntrl shift spcl flgs
- * ---------------------------------------------------------------------------
- */
-/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 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,
-/* sc=05 */ '4', 0xA4, NOP, NOP, '$', 0xA4, NOP, NOP, 0x33, 0x00,
-/* sc=06 */ '5', '%', NOP, NOP, '5', '%', NOP, NOP, 0x33, 0x00,
-/* sc=07 */ '6', '&', NOP, NOP, '6', '&', NOP, NOP, 0x33, 0x00,
-/* sc=08 */ '7', '/', NOP, NOP, '{', '/', NOP, NOP, 0x33, 0x00,
-/* sc=09 */ '8', '(', 0x1B, 0x1B, '[', '(', 0x1B, 0x1B, 0x00, 0x00,
-/* sc=0a */ '9', ')', 0x1D, 0x1D, ']', ')', 0x1D, 0x1D, 0x00, 0x00,
-/* sc=0b */ '0', '=', NOP, NOP, '}', '=', NOP, NOP, 0x33, 0x00,
-/* sc=0c */ '+', '?', NOP, NOP, '+', '?', NOP, NOP, 0x33, 0x00,
-/* sc=0d */ '\'', '`', NOP, NOP, '|', '`', NOP, NOP, 0x33, 0x00,
-/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x00, 0x00,
-/* sc=0f */ 0x09, BTAB, NOP, NOP, 0x09, BTAB, NOP, NOP, 0x77, 0x00,
-/* sc=10 */ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, 0x00, 0x01,
-/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01,
-/* sc=12 */ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, 0x00, 0x01,
-/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01,
-/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01,
-/* sc=15 */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, 0x00, 0x01,
-/* sc=16 */ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, 0x00, 0x01,
-/* sc=17 */ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, 0x00, 0x01,
-/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, 0x00, 0x01,
-/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01,
-/* sc=1a */ 0xE5, 0xC5, NOP, NOP, 0x86, 0x8F, NOP, NOP, 0x33, 0x01,
-/* sc=1b */ '"', '^', 0x1E, 0x1E, '~', '^', 0x1E, 0x1E, 0x00, 0x00,
-/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00,
-/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00,
-/* sc=1e */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01,
-/* sc=1f */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01,
-/* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01,
-/* sc=21 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01,
-/* sc=22 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01,
-/* sc=23 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01,
-/* sc=24 */ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, 0x00, 0x01,
-/* sc=25 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01,
-/* sc=26 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01,
-/* sc=27 */ 0xE6, 0xC6, NOP, NOP, 0x91, 0x92, NOP, NOP, 0x33, 0x01,
-/* sc=28 */ 0xF8, 0xD8, NOP, NOP, 0x9B, 0x9D, NOP, NOP, 0x33, 0x01,
-/* sc=29 */ 0xBD, 0xA7, NOP, NOP, 0xBD, 0xA7, NOP, NOP, 0x33, 0x00,
-/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00,
-/* sc=2b */ '\'', '*', NOP, NOP, '\'', '*', NOP, NOP, 0x33, 0x00,
-/* sc=2c */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, 0x00, 0x01,
-/* sc=2d */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01,
-/* sc=2e */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01,
-/* sc=2f */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01,
-/* sc=30 */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01,
-/* sc=31 */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01,
-/* sc=32 */ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, 0x00, 0x01,
-/* sc=33 */ ',', ';', NOP, NOP, ',', ';', NOP, NOP, 0x33, 0x00,
-/* sc=34 */ '.', ':', NOP, NOP, '.', ':', NOP, NOP, 0x33, 0x00,
-/* sc=35 */ '-', '_', 0x1F, 0x1F, '-', '_', 0x1F, 0x1F, 0x00, 0x00,
-/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
-/* sc=37 */ '*', '*', '*', '*', '*', '*', '*', '*', 0x00, 0x00,
-/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00,
-/* sc=39 */ ' ', ' ', 0x00, ' ', ' ', ' ', SUSP, ' ', 0x02, 0x00,
-/* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00,
-/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00,
-/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00,
-/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00,
-/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00,
-/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00,
-/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00,
-/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00,
-/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00,
-/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00,
-/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00,
-/* sc=45 */ NLK, NLK, NLK, NLK, NLK, NLK, NLK, NLK, 0xFF, 0x00,
-/* sc=46 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
-/* sc=47 */ F(49), '7', '7', '7', '7', '7', '7', '7', 0x80, 0x02,
-/* sc=48 */ F(50), '8', '8', '8', '8', '8', '8', '8', 0x80, 0x02,
-/* sc=49 */ F(51), '9', '9', '9', '9', '9', '9', '9', 0x80, 0x02,
-/* sc=4a */ F(52), '-', '-', '-', '-', '-', '-', '-', 0x80, 0x02,
-/* sc=4b */ F(53), '4', '4', '4', '4', '4', '4', '4', 0x80, 0x02,
-/* sc=4c */ F(54), '5', '5', '5', '5', '5', '5', '5', 0x80, 0x02,
-/* sc=4d */ F(55), '6', '6', '6', '6', '6', '6', '6', 0x80, 0x02,
-/* sc=4e */ F(56), '+', '+', '+', '+', '+', '+', '+', 0x80, 0x02,
-/* sc=4f */ F(57), '1', '1', '1', '1', '1', '1', '1', 0x80, 0x02,
-/* 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, RBT, 0x03, 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,
-/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00,
-/* sc=59 */ 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x02,
-/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00,
-/* sc=5b */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x00,
-/* sc=5c */ NEXT, NOP, DBG, NOP, NOP, NOP, NOP, NOP, 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,
-/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00,
-/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00,
-/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00,
-/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00,
-/* 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(61), F(61), F(61), F(61), F(61), F(61), RBT, F(61), 0xFF, 0x00,
-/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
-/* sc=69 */ F(62), F(62), F(62), F(62), F(62), F(62), F(62), F(62), 0xFF, 0x00,
-/* sc=6a */ F(63), F(63), F(63), F(63), F(63), F(63), F(63), F(63), 0xFF, 0x00,
-/* sc=6b */ F(64), F(64), F(64), F(64), F(64), F(64), F(64), F(64), 0xFF, 0x00,
-};
-#endif
-
-#ifdef UKKEYMAP
-#define ISO_ACCENTCHARS
-static keymap_t key_map = { 0x6C, /* uk iso8859 keymap */
-/* alt
- * scan cntrl alt alt cntrl
- * code base shift cntrl shift alt shift cntrl shift spcl flgs
- * ---------------------------------------------------------------------------
- */
-/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 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,
-/* sc=05 */ '4', '$', NOP, NOP, '4', '$', NOP, NOP, 0x33, 0x00,
-/* sc=06 */ '5', '%', NOP, NOP, '5', '%', NOP, NOP, 0x33, 0x00,
-/* sc=07 */ '6', '^', 0x1E, 0x1E, '^', '^', 0x1E, 0x1E, 0x00, 0x00,
-/* sc=08 */ '7', '&', NOP, NOP, '[', '[', 0x1B, 0x1B, 0x30, 0x00,
-/* sc=09 */ '8', '*', NOP, NOP, '8', '*', NOP, NOP, 0x33, 0x00,
-/* sc=0a */ '9', '(', NOP, NOP, ']', ']', 0x1D, 0x1D, 0x30, 0x00,
-/* sc=0b */ '0', ')', NOP, NOP, '{', '{', NOP, NOP, 0x33, 0x00,
-/* sc=0c */ '-', '_', 0x1F, 0x1F, '|', '|', 0x1F, 0x1F, 0x00, 0x00,
-/* sc=0d */ '=', '+', NOP, NOP, '}', '}', NOP, NOP, 0x33, 0x00,
-/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x00, 0x00,
-/* sc=0f */ 0x09, BTAB, NOP, NOP, 0x09, BTAB, NOP, NOP, 0x77, 0x00,
-/* sc=10 */ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, 0x00, 0x01,
-/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01,
-/* sc=12 */ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, 0x00, 0x01,
-/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01,
-/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01,
-/* sc=15 */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, 0x00, 0x01,
-/* sc=16 */ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, 0x00, 0x01,
-/* sc=17 */ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, 0x00, 0x01,
-/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, 0x00, 0x01,
-/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01,
-/* sc=1a */ '[', '{', 0x1B, 0x1B, '[', '{', 0x1B, 0x1B, 0x00, 0x00,
-/* sc=1b */ ']', '}', 0x1D, 0x1D, ']', '}', 0x1D, 0x1D, 0x00, 0x00,
-/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00,
-/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00,
-/* sc=1e */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01,
-/* sc=1f */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01,
-/* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01,
-/* sc=21 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01,
-/* sc=22 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01,
-/* sc=23 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01,
-/* sc=24 */ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, 0x00, 0x01,
-/* sc=25 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01,
-/* sc=26 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01,
-/* sc=27 */ ';', ':', NOP, NOP, ';', ':', NOP, NOP, 0x33, 0x00,
-/* sc=28 */ '\'', '@', 0x00, 0x00, '\'', '@', 0x00, 0x00, 0x00, 0x00,
-/* sc=29 */ '\\', '|', 0x1C, 0x1C, '\\', '\\', 0x1C, 0x1C, 0x00, 0x00,
-/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00,
-/* sc=2b */ '#', '~', NOP, NOP, '~', '~', NOP, NOP, 0x33, 0x00,
-/* sc=2c */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, 0x00, 0x01,
-/* sc=2d */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01,
-/* sc=2e */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01,
-/* sc=2f */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01,
-/* sc=30 */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01,
-/* sc=31 */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01,
-/* sc=32 */ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, 0x00, 0x01,
-/* sc=33 */ ',', '<', NOP, NOP, ',', '<', NOP, NOP, 0x33, 0x00,
-/* sc=34 */ '.', '>', NOP, NOP, '.', '>', NOP, NOP, 0x33, 0x00,
-/* sc=35 */ '/', '?', NOP, NOP, '/', '?', NOP, NOP, 0x33, 0x00,
-/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
-/* sc=37 */ '*', '*', 0x0A, 0x0A, '*', '*', 0x0A, 0x0A, 0x33, 0x00,
-/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00,
-/* sc=39 */ ' ', ' ', 0x00, ' ', ' ', ' ', SUSP, ' ', 0x02, 0x00,
-/* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00,
-/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00,
-/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00,
-/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00,
-/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00,
-/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00,
-/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00,
-/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00,
-/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00,
-/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00,
-/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00,
-/* sc=45 */ NLK, NLK, 0x13, 0x13, NLK, NLK, 0x13, 0x13, 0xCC, 0x00,
-/* sc=46 */ SLK, SLK, 0x7F, 0x7F, SLK, SLK, 0x7F, 0x7F, 0xCC, 0x00,
-/* sc=47 */ F(49), '7', '7', '7', '7', '7', '7', '7', 0x80, 0x02,
-/* sc=48 */ F(50), '8', '8', '8', '8', '8', '8', '8', 0x80, 0x02,
-/* sc=49 */ F(51), '9', '9', '9', '9', '9', '9', '9', 0x80, 0x02,
-/* sc=4a */ F(52), '-', 0x1F, 0x1F, '-', '-', '-', '-', 0x80, 0x02,
-/* sc=4b */ F(53), '4', '4', '4', '4', '4', '4', '4', 0x80, 0x02,
-/* sc=4c */ F(54), '5', '5', '5', '5', '5', '5', '5', 0x80, 0x02,
-/* sc=4d */ F(55), '6', 0x1E, 0x1E, '6', '6', '6', '6', 0x80, 0x02,
-/* sc=4e */ F(56), '+', '+', '+', '+', '+', '+', '+', 0x80, 0x02,
-/* sc=4f */ F(57), '1', '1', '1', '1', '1', '1', '1', 0x80, 0x02,
-/* 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, RBT, 0x03, 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,
-/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00,
-/* sc=59 */ 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0xFF, 0x02,
-/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00,
-/* sc=5b */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x02,
-/* sc=5c */ NEXT, NOP, DBG, NOP, NOP, NOP, NOP, NOP, 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,
-/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00,
-/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00,
-/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00,
-/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00,
-/* 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(61), F(61), F(61), F(61), F(61), F(61), RBT, F(61), 0xFF, 0x00,
-/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
-/* sc=69 */ F(62), F(62), F(62), F(62), F(62), F(62), F(62), F(62), 0xFF, 0x00,
-/* sc=6a */ F(63), F(63), F(63), F(63), F(63), F(63), F(63), F(63), 0xFF, 0x00,
-/* sc=6b */ F(64), F(64), F(64), F(64), F(64), F(64), F(64), F(64), 0xFF, 0x00,
-};
-#endif
-
-#ifdef GRKEYMAP
-#define ISO_ACCENTCHARS
-static keymap_t key_map = { 0x6C, /* german iso8859 keymap */
-/* alt
- * scan cntrl alt alt cntrl
- * code base shift cntrl shift alt shift cntrl shift spcl flgs
- * ---------------------------------------------------------------------------
- */
-/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 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,
-/* sc=05 */ '4', '$', NOP, NOP, '4', '$', NOP, NOP, 0x33, 0x00,
-/* sc=06 */ '5', '%', NOP, NOP, '5', '%', NOP, NOP, 0x33, 0x00,
-/* sc=07 */ '6', '&', 0x1E, 0x1E, '^', '^', 0x1E, 0x1E, 0x00, 0x00,
-/* sc=08 */ '7', '/', 0x1B, 0x1B, '[', '[', 0x1B, 0x1B, 0x00, 0x00,
-/* sc=09 */ '8', '(', NOP, NOP, '8', '(', NOP, NOP, 0x33, 0x00,
-/* sc=0a */ '9', ')', 0x1D, 0x1D, ']', ']', 0x1D, 0x1D, 0x00, 0x00,
-/* sc=0b */ '0', '=', NOP, NOP, '{', '{', NOP, NOP, 0x33, 0x00,
-/* sc=0c */ 0xDF, '?', NOP, NOP, '|', '|', NOP, NOP, 0x33, 0x00,
-/* sc=0d */ 0x92, 0x93, NOP, NOP, '\'', '`', NOP, NOP, 0x33, 0x00,
-/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x00, 0x00,
-/* sc=0f */ 0x09, BTAB, NOP, NOP, 0x09, BTAB, NOP, NOP, 0x77, 0x00,
-/* sc=10 */ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, 0x00, 0x01,
-/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01,
-/* sc=12 */ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, 0x00, 0x01,
-/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01,
-/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01,
-/* sc=15 */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, 0x00, 0x01,
-/* sc=16 */ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, 0x00, 0x01,
-/* sc=17 */ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, 0x00, 0x01,
-/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, 0x00, 0x01,
-/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01,
-/* sc=1a */ 0xFC, 0xDC, 0x1B, 0x1B, '[', '{', 0x1B, 0x1B, 0x00, 0x01,
-/* sc=1b */ '+', '*', 0x1D, 0x1D, ']', '}', 0x1D, 0x1D, 0x00, 0x00,
-/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00,
-/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00,
-/* sc=1e */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01,
-/* sc=1f */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01,
-/* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01,
-/* sc=21 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01,
-/* sc=22 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01,
-/* sc=23 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01,
-/* sc=24 */ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, 0x00, 0x01,
-/* sc=25 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01,
-/* sc=26 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01,
-/* sc=27 */ 0xF6, 0xD6, NOP, NOP, 0xF6, 0xD6, NOP, NOP, 0x33, 0x01,
-/* sc=28 */ 0xE4, 0xC4, NOP, NOP, 0xE4, 0xC4, NOP, NOP, 0x33, 0x01,
-/* sc=29 */ '<', '>', 0x1C, 0x1C, '\\', '|', 0x1C, 0x1C, 0x00, 0x00,
-/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00,
-/* sc=2b */ '#', '^', 0x1E, 0x1E, '`', '~', 0x1E, 0x1E, 0x00, 0x00,
-/* sc=2c */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, 0x00, 0x01,
-/* sc=2d */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01,
-/* sc=2e */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01,
-/* sc=2f */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01,
-/* sc=30 */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01,
-/* sc=31 */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01,
-/* sc=32 */ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, 0x00, 0x01,
-/* sc=33 */ ',', ';', NOP, NOP, ',', ';', NOP, NOP, 0x33, 0x00,
-/* sc=34 */ '.', ':', NOP, NOP, '.', ':', NOP, NOP, 0x33, 0x00,
-/* sc=35 */ '-', '_', 0x1F, 0x1F, '-', '_', 0x1F, 0x1F, 0x00, 0x00,
-/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
-/* sc=37 */ '*', '*', 0x0A, 0x0A, '*', '*', 0x0A, 0x0A, 0x33, 0x00,
-/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00,
-/* sc=39 */ ' ', ' ', 0x00, ' ', ' ', ' ', SUSP, ' ', 0x02, 0x00,
-/* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00,
-/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00,
-/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00,
-/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00,
-/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00,
-/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00,
-/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00,
-/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00,
-/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00,
-/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00,
-/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00,
-/* sc=45 */ NLK, NLK, 0x13, 0x13, NLK, NLK, 0x13, 0x13, 0xCC, 0x00,
-/* sc=46 */ SLK, SLK, 0x7F, 0x7F, SLK, SLK, 0x7F, 0x7F, 0xCC, 0x00,
-/* sc=47 */ F(49), '7', '7', '7', '7', '7', '7', '7', 0x80, 0x02,
-/* sc=48 */ F(50), '8', '8', '8', '8', '8', '8', '8', 0x80, 0x02,
-/* sc=49 */ F(51), '9', '9', '9', '9', '9', '9', '9', 0x80, 0x02,
-/* sc=4a */ F(52), '-', 0x1F, 0x1F, '-', '-', '-', '-', 0x80, 0x02,
-/* sc=4b */ F(53), '4', '4', '4', '4', '4', '4', '4', 0x80, 0x02,
-/* sc=4c */ F(54), '5', '5', '5', '5', '5', '5', '5', 0x80, 0x02,
-/* sc=4d */ F(55), '6', 0x1E, 0x1E, '6', '6', '6', '6', 0x80, 0x02,
-/* sc=4e */ F(56), '+', '+', '+', '+', '+', '+', '+', 0x80, 0x02,
-/* sc=4f */ F(57), '1', '1', '1', '1', '1', '1', '1', 0x80, 0x02,
-/* 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, RBT, 0x03, 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,
-/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00,
-/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00,
-/* sc=59 */ 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0xFF, 0x02,
-/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00,
-/* sc=5b */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x02,
-/* sc=5c */ NEXT, NOP, DBG, NOP, NOP, NOP, NOP, NOP, 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,
-/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00,
-/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00,
-/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00,
-/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00,
-/* 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(61), F(61), F(61), F(61), F(61), F(61), RBT, F(61), 0xFF, 0x00,
-/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
-/* sc=69 */ F(62), F(62), F(62), F(62), F(62), F(62), F(62), F(62), 0xFF, 0x00,
-/* sc=6a */ F(63), F(63), F(63), F(63), F(63), F(63), F(63), F(63), 0xFF, 0x00,
-/* sc=6b */ F(64), F(64), F(64), F(64), F(64), F(64), F(64), F(64), 0xFF, 0x00,
-};
-#endif
-
-#ifdef SWKEYMAP
-#define ISO_ACCENTCHARS
-static keymap_t key_map = { 0x6C, /* swedish iso8859 keymap */
-/* alt
- * scan cntrl alt alt cntrl
- * code base shift cntrl shift alt shift cntrl shift spcl flgs
- * ---------------------------------------------------------------------------
- */
-/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 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', '"', 0x00, 0x00, '@', '@', 0x00, 0x00, 0x00, 0x00,
-/* sc=04 */ '3', '#', NOP, NOP, 0xA3, NOP, NOP, NOP, 0x37, 0x00,
-/* sc=05 */ '4', '$', NOP, NOP, 0xA4, NOP, NOP, NOP, 0x37, 0x00,
-/* sc=06 */ '5', '%', NOP, NOP, NOP, NOP, NOP, NOP, 0x3F, 0x00,
-/* sc=07 */ '6', '&', NOP, NOP, NOP, NOP, NOP, NOP, 0x3F, 0x00,
-/* sc=08 */ '7', '/', NOP, NOP, '{', NOP, NOP, NOP, 0x37, 0x00,
-/* sc=09 */ '8', '(', NOP, NOP, '[', NOP, NOP, NOP, 0x37, 0x00,
-/* sc=0a */ '9', ')', NOP, NOP, ']', NOP, NOP, NOP, 0x37, 0x00,
-/* sc=0b */ '0', '=', NOP, NOP, '}', NOP, NOP, NOP, 0x37, 0x00,
-/* sc=0c */ '+', '?', NOP, NOP, '\\', NOP, 0x1C, NOP, 0x35, 0x00,
-/* sc=0d */ 0x180, '`', NOP, NOP, NOP, NOP, NOP, NOP, 0x3F, 0x00,
-/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x00, 0x00,
-/* sc=0f */ 0x09, BTAB, NOP, NOP, 0x09, BTAB, NOP, NOP, 0x77, 0x00,
-/* sc=10 */ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, 0x00, 0x01,
-/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01,
-/* sc=12 */ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, 0x00, 0x01,
-/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01,
-/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01,
-/* sc=15 */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, 0x00, 0x01,
-/* sc=16 */ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, 0x00, 0x01,
-/* sc=17 */ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, 0x00, 0x01,
-/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, 0x00, 0x01,
-/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01,
-/* sc=1a */ 0xE5, 0xC5, NOP, NOP, '}', ']', NOP, NOP, 0x33, 0x01,
-/* sc=1b */ 0xA8, '^', NOP, NOP, '~', NOP, NOP, NOP, 0x37, 0x00,
-/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00,
-/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00,
-/* sc=1e */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01,
-/* sc=1f */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01,
-/* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01,
-/* sc=21 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01,
-/* sc=22 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01,
-/* sc=23 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01,
-/* sc=24 */ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, 0x00, 0x01,
-/* sc=25 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01,
-/* sc=26 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01,
-/* sc=27 */ 0xF6, 0xD6, NOP, NOP, '|', '\\', NOP, NOP, 0x33, 0x01,
-/* sc=28 */ 0xE4, 0xC4, NOP, NOP, '{', '[', NOP, NOP, 0x33, 0x01,
-/* sc=29 */ 0xA7, 0xBD, NOP, NOP, '\\', '|', NOP, NOP, 0x33, 0x00,
-/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00,
-/* sc=2b */ '\'', '*', NOP, NOP, NOP, NOP, NOP, NOP, 0x3F, 0x00,
-/* sc=2c */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, 0x00, 0x01,
-/* sc=2d */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01,
-/* sc=2e */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01,
-/* sc=2f */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01,
-/* sc=30 */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01,
-/* sc=31 */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01,
-/* sc=32 */ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, 0x00, 0x01,
-/* sc=33 */ ',', ';', NOP, NOP, NOP, '<', NOP, NOP, 0x3B, 0x00,
-/* sc=34 */ '.', ':', NOP, NOP, NOP, '>', NOP, NOP, 0x3B, 0x00,
-/* sc=35 */ '-', '_', 0x1F, NOP, '/', '?', NOP, NOP, 0x13, 0x00,
-/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
-/* sc=37 */ '*', '*', 0x0A, 0x0A, '*', '*', 0x0A, 0x0A, 0x33, 0x00,
-/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00,
-/* sc=39 */ ' ', ' ', 0x00, ' ', ' ', ' ', SUSP, ' ', 0x02, 0x00,
-/* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00,
-/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00,
-/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00,
-/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00,
-/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00,
-/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00,
-/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00,
-/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00,
-/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00,
-/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00,
-/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00,
-/* sc=45 */ NLK, NLK, 0x13, 0x13, NLK, NLK, 0x13, 0x13, 0xCC, 0x00,
-/* sc=46 */ SLK, SLK, 0x7F, 0x7F, SLK, SLK, 0x7F, 0x7F, 0xCC, 0x00,
-/* sc=47 */ F(49), '7', '7', '7', '7', '7', '7', '7', 0x80, 0x02,
-/* sc=48 */ F(50), '8', '8', '8', '8', '8', '8', '8', 0x80, 0x02,
-/* sc=49 */ F(51), '9', '9', '9', '9', '9', '9', '9', 0x80, 0x02,
-/* sc=4a */ F(52), '-', 0x1F, 0x1F, '-', '-', '-', '-', 0x80, 0x02,
-/* sc=4b */ F(53), '4', '4', '4', '4', '4', '4', '4', 0x80, 0x02,
-/* sc=4c */ F(54), '5', '5', '5', '5', '5', '5', '5', 0x80, 0x02,
-/* sc=4d */ F(55), '6', 0x1E, 0x1E, '6', '6', '6', '6', 0x80, 0x02,
-/* sc=4e */ F(56), '+', '+', '+', '+', '+', '+', '+', 0x80, 0x02,
-/* sc=4f */ F(57), '1', '1', '1', '1', '1', '1', '1', 0x80, 0x02,
-/* 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, RBT, 0x03, 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, 0x37, 0x00,
-/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00,
-/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00,
-/* sc=59 */ 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0xFF, 0x02,
-/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00,
-/* sc=5b */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x02,
-/* sc=5c */ NEXT, NOP, DBG, NOP, NOP, NOP, NOP, NOP, 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,
-/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00,
-/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00,
-/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00,
-/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00,
-/* 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(61), F(61), F(61), F(61), F(61), F(61), RBT, F(61), 0xFF, 0x00,
-/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
-/* sc=69 */ F(62), F(62), F(62), F(62), F(62), F(62), F(62), F(62), 0xFF, 0x00,
-/* sc=6a */ F(63), F(63), F(63), F(63), F(63), F(63), F(63), F(63), 0xFF, 0x00,
-/* sc=6b */ F(64), F(64), F(64), F(64), F(64), F(64), F(64), F(64), 0xFF, 0x00,
-};
-#endif
-
-#ifdef RUKEYMAP
-#define NO_ACCENTCHARS
-static keymap_t key_map = { 0xEC, /* keys number */
-/* alt
- * scan cntrl alt alt cntrl
- * code base shift cntrl shift alt shift cntrl shift spcl flgs
- * -------------------------------------------------------------------------------------------
- */
-/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, NOP, NOP, SET8|0x1B, SET8|0x1B, DBG, NOP, 0x33, 0x00,
-/* sc=02 */ '1', '!', NOP, NOP, SET8|'1', SET8|'!', NOP, NOP, 0x33, 0x00,
-/* sc=03 */ '2', '@', 0x00, 0x00, SET8|'2', SET8|'@', SET8|0x00, SET8|0x00, 0x00, 0x00,
-/* sc=04 */ '3', '#', NOP, NOP, SET8|'3', SET8|'#', NOP, NOP, 0x33, 0x00,
-/* sc=05 */ '4', '$', NOP, NOP, SET8|'4', SET8|'$', NOP, NOP, 0x33, 0x00,
-/* sc=06 */ '5', '%', NOP, NOP, SET8|'5', SET8|'%', NOP, NOP, 0x33, 0x00,
-/* sc=07 */ '6', '^', 0x1E, 0x1E, SET8|'6', SET8|'^', SET8|0x1E, SET8|0x1E, 0x00, 0x00,
-/* sc=08 */ '7', '&', NOP, NOP, SET8|'7', SET8|'&', NOP, NOP, 0x33, 0x00,
-/* 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=0e */ 0x08, 0x08, 0x7F, 0x7F, SET8|0x08, SET8|0x08, SET8|0x7F, SET8|0x7F, 0x00, 0x00,
-/* sc=0f */ 0x09, BTAB, NOP, NOP, SET8|0x09, BTAB, NOP, NOP, 0x77, 0x00,
-/* sc=10 */ 'q', 'Q', 0x11, 0x11, SET8|'q', SET8|'Q', SET8|0x11, SET8|0x11, 0x00, 0x01,
-/* sc=11 */ 'w', 'W', 0x17, 0x17, SET8|'w', SET8|'W', SET8|0x17, SET8|0x17, 0x00, 0x01,
-/* sc=12 */ 'e', 'E', 0x05, 0x05, SET8|'e', SET8|'E', SET8|0x05, SET8|0x05, 0x00, 0x01,
-/* sc=13 */ 'r', 'R', 0x12, 0x12, SET8|'r', SET8|'R', SET8|0x12, SET8|0x12, 0x00, 0x01,
-/* sc=14 */ 't', 'T', 0x14, 0x14, SET8|'t', SET8|'T', SET8|0x14, SET8|0x14, 0x00, 0x01,
-/* sc=15 */ 'y', 'Y', 0x19, 0x19, SET8|'y', SET8|'Y', SET8|0x19, SET8|0x19, 0x00, 0x01,
-/* sc=16 */ 'u', 'U', 0x15, 0x15, SET8|'u', SET8|'U', SET8|0x15, SET8|0x15, 0x00, 0x01,
-/* sc=17 */ 'i', 'I', 0x09, 0x09, SET8|'i', SET8|'I', SET8|0x09, SET8|0x09, 0x00, 0x01,
-/* sc=18 */ 'o', 'O', 0x0F, 0x0F, SET8|'o', SET8|'O', SET8|0x0F, SET8|0x0F, 0x00, 0x01,
-/* sc=19 */ 'p', 'P', 0x10, 0x10, SET8|'p', SET8|'P', SET8|0x10, SET8|0x10, 0x00, 0x01,
-/* sc=1a */ '[', '{', 0x1B, 0x1B, SET8|'[', SET8|'{', SET8|0x1B, SET8|0x1B, 0x00, 0x00,
-/* sc=1b */ ']', '}', 0x1D, 0x1D, SET8|']', SET8|'}', SET8|0x1D, SET8|0x1D, 0x00, 0x00,
-/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, SET8|0x0D, SET8|0x0D, SET8|0x0A, SET8|0x0A, 0x00, 0x00,
-/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00,
-/* sc=1e */ 'a', 'A', 0x01, 0x01, SET8|'a', SET8|'A', SET8|0x01, SET8|0x01, 0x00, 0x01,
-/* sc=1f */ 's', 'S', 0x13, 0x13, SET8|'s', SET8|'S', SET8|0x13, SET8|0x13, 0x00, 0x01,
-/* sc=20 */ 'd', 'D', 0x04, 0x04, SET8|'d', SET8|'D', SET8|0x04, SET8|0x04, 0x00, 0x01,
-/* sc=21 */ 'f', 'F', 0x06, 0x06, SET8|'f', SET8|'F', SET8|0x06, SET8|0x06, 0x00, 0x01,
-/* sc=22 */ 'g', 'G', 0x07, 0x07, SET8|'g', SET8|'G', SET8|0x07, SET8|0x07, 0x00, 0x01,
-/* sc=23 */ 'h', 'H', 0x08, 0x08, SET8|'h', SET8|'H', SET8|0x08, SET8|0x08, 0x00, 0x01,
-/* sc=24 */ 'j', 'J', 0x0A, 0x0A, SET8|'j', SET8|'J', SET8|0x0A, SET8|0x0A, 0x00, 0x01,
-/* sc=25 */ 'k', 'K', 0x0B, 0x0B, SET8|'k', SET8|'K', SET8|0x0B, SET8|0x0B, 0x00, 0x01,
-/* sc=26 */ 'l', 'L', 0x0C, 0x0C, SET8|'l', SET8|'L', SET8|0x0C, SET8|0x0C, 0x00, 0x01,
-/* sc=27 */ ';', ':', NOP, NOP, SET8|';', SET8|':', NOP, NOP, 0x33, 0x00,
-/* sc=28 */ '\'', '"', NOP, NOP, SET8|'\'', SET8|'"', NOP, NOP, 0x33, 0x00,
-/* sc=29 */ '`', '~', NOP, NOP, SET8|'`', SET8|'~', NOP, NOP, 0x33, 0x00,
-/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00,
-/* sc=2b */ '\\', '|', 0x1C, 0x1C, SET8|'\\', SET8|'|', SET8|0x1C, SET8|0x1C, 0x00, 0x00,
-/* sc=2c */ 'z', 'Z', 0x1A, 0x1A, SET8|'z', SET8|'Z', SET8|0x1A, SET8|0x1A, 0x00, 0x01,
-/* sc=2d */ 'x', 'X', 0x18, 0x18, SET8|'x', SET8|'X', SET8|0x18, SET8|0x18, 0x00, 0x01,
-/* sc=2e */ 'c', 'C', 0x03, 0x03, SET8|'c', SET8|'C', SET8|0x03, SET8|0x03, 0x00, 0x01,
-/* sc=2f */ 'v', 'V', 0x16, 0x16, SET8|'v', SET8|'V', SET8|0x16, SET8|0x16, 0x00, 0x01,
-/* sc=30 */ 'b', 'B', 0x02, 0x02, SET8|'b', SET8|'B', SET8|0x02, SET8|0x02, 0x00, 0x01,
-/* sc=31 */ 'n', 'N', 0x0E, 0x0E, SET8|'n', SET8|'N', SET8|0x0E, SET8|0x0E, 0x00, 0x01,
-/* sc=32 */ 'm', 'M', 0x0D, 0x0D, SET8|'m', SET8|'M', SET8|0x0D, SET8|0x0D, 0x00, 0x01,
-/* 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=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 */ ' ', ' ', 0x00, ' ', SET8|' ', SET8|' ', SUSP, SET8|' ', 0x00, 0x00,
-/* sc=3a */ ALK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00,
-/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00,
-/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00,
-/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00,
-/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00,
-/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00,
-/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00,
-/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00,
-/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00,
-/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00,
-/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00,
-/* sc=45 */ NLK, NLK, NLK, NLK, NLK, NLK, NLK, NLK, 0xFF, 0x00,
-/* sc=46 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
-/* sc=47 */ F(49), '7', '7', '7', SET8|'7', SET8|'7', SET8|'7', SET8|'7', 0x80, 0x02,
-/* sc=48 */ F(50), '8', '8', '8', SET8|'8', SET8|'8', SET8|'8', SET8|'8', 0x80, 0x02,
-/* sc=49 */ F(51), '9', '9', '9', SET8|'9', SET8|'9', SET8|'9', SET8|'9', 0x80, 0x02,
-/* sc=4a */ F(52), '-', '-', '-', SET8|'-', SET8|'-', SET8|'-', SET8|'-', 0x80, 0x02,
-/* sc=4b */ F(53), '4', '4', '4', SET8|'4', SET8|'4', SET8|'4', SET8|'4', 0x80, 0x02,
-/* sc=4c */ F(54), '5', '5', '5', SET8|'5', SET8|'5', SET8|'5', SET8|'5', 0x80, 0x02,
-/* sc=4d */ F(55), '6', '6', '6', SET8|'6', SET8|'6', SET8|'6', SET8|'6', 0x80, 0x02,
-/* sc=4e */ F(56), '+', '+', '+', SET8|'+', SET8|'+', SET8|'+', SET8|'+', 0x80, 0x02,
-/* sc=4f */ F(57), '1', '1', '1', SET8|'1', SET8|'1', SET8|'1', SET8|'1', 0x80, 0x02,
-/* 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 */ 0x7F, '.', '.', '.', SET8|'.', SET8|'.', RBT, RBT, 0x03, 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,
-/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00,
-/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00,
-/* 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=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,
-/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00,
-/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00,
-/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00,
-/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00,
-/* 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(61), F(61), F(61), F(61), F(61), F(61), RBT, F(61), 0xFF, 0x00,
-/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
-/* sc=69 */ F(62), F(62), F(62), F(62), F(62), F(62), F(62), F(62), 0xFF, 0x00,
-/* sc=6a */ F(63), F(63), F(63), F(63), F(63), F(63), F(63), F(63), 0xFF, 0x00,
-/* sc=6b */ F(64), F(64), F(64), F(64), F(64), F(64), F(64), F(64), 0xFF, 0x00,
-/* sc=6c */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=6d */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=6e */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=6f */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=70 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=71 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=72 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=73 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=74 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=75 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=76 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=77 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=78 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=79 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=7a */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=7b */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=7c */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=7d */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=7e */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=7f */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* extended (ALTGR LOCK keys) */
-/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, NOP, NOP, SET8|0x1B, SET8|0x1B, DBG, NOP, 0x33, 0x00,
-/* sc=02 */ '!', '1', NOP, NOP, SET8|'1', SET8|'!', NOP, NOP, 0x33, 0x00,
-/* sc=03 */ '"', '2', 0x00, 0x00, SET8|'2', SET8|'@', SET8|0x00, SET8|0x00, 0x00, 0x00,
-/* sc=04 */ '\'', '3', NOP, NOP, SET8|'3', SET8|'#', NOP, NOP, 0x33, 0x00,
-/* sc=05 */ '*', '4', NOP, NOP, SET8|'4', SET8|'$', NOP, NOP, 0x33, 0x00,
-/* sc=06 */ ':', '5', NOP, NOP, SET8|'5', SET8|'%', NOP, NOP, 0x33, 0x00,
-/* sc=07 */ ',', '6', 0x1E, 0x1E, SET8|'6', SET8|'^', SET8|0x1E, SET8|0x1E, 0x00, 0x00,
-/* sc=08 */ '.', '7', NOP, NOP, SET8|'7', SET8|'&', NOP, NOP, 0x33, 0x00,
-/* 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=0e */ 0x08, 0x08, 0x7F, 0x7F, SET8|0x08, SET8|0x08, SET8|0x7F, SET8|0x7F, 0x00, 0x00,
-/* sc=0f */ 0x09, BTAB, NOP, NOP, SET8|0x09, BTAB, NOP, NOP, 0x77, 0x00,
-/* sc=10 */ 0xca, 0xea, 0x11, 0x11, SET8|'q', SET8|'Q', SET8|0x11, SET8|0x11, 0x00, 0x01,
-/* sc=11 */ 0xc3, 0xe3, 0x17, 0x17, SET8|'w', SET8|'W', SET8|0x17, SET8|0x17, 0x00, 0x01,
-/* sc=12 */ 0xd5, 0xf5, 0x05, 0x05, SET8|'e', SET8|'E', SET8|0x05, SET8|0x05, 0x00, 0x01,
-/* sc=13 */ 0xcb, 0xeb, 0x12, 0x12, SET8|'r', SET8|'R', SET8|0x12, SET8|0x12, 0x00, 0x01,
-/* sc=14 */ 0xc5, 0xe5, 0x14, 0x14, SET8|'t', SET8|'T', SET8|0x14, SET8|0x14, 0x00, 0x01,
-/* sc=15 */ 0xce, 0xee, 0x19, 0x19, SET8|'y', SET8|'Y', SET8|0x19, SET8|0x19, 0x00, 0x01,
-/* sc=16 */ 0xc7, 0xe7, 0x15, 0x15, SET8|'u', SET8|'U', SET8|0x15, SET8|0x15, 0x00, 0x01,
-/* sc=17 */ 0xdb, 0xfb, 0x09, 0x09, SET8|'i', SET8|'I', SET8|0x09, SET8|0x09, 0x00, 0x01,
-/* sc=18 */ 0xdd, 0xfd, 0x0F, 0x0F, SET8|'o', SET8|'O', SET8|0x0F, SET8|0x0F, 0x00, 0x01,
-/* sc=19 */ 0xda, 0xfa, 0x10, 0x10, SET8|'p', SET8|'P', SET8|0x10, SET8|0x10, 0x00, 0x01,
-/* sc=1a */ 0xc8, 0xe8, 0x1B, 0x1B, SET8|'[', SET8|'{', SET8|0x1B, SET8|0x1B, 0x00, 0x01,
-/* sc=1b */ 0xdf, 0xff, 0x1D, 0x1D, SET8|']', SET8|'}', SET8|0x1D, SET8|0x1D, 0x00, 0x01,
-/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, SET8|0x0D, SET8|0x0D, SET8|0x0A, SET8|0x0A, 0x00, 0x00,
-/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00,
-/* sc=1e */ 0xc6, 0xe6, 0x01, 0x01, SET8|'a', SET8|'A', SET8|0x01, SET8|0x01, 0x00, 0x01,
-/* sc=1f */ 0xd9, 0xf9, 0x13, 0x13, SET8|'s', SET8|'S', SET8|0x13, SET8|0x13, 0x00, 0x01,
-/* sc=20 */ 0xd7, 0xf7, 0x04, 0x04, SET8|'d', SET8|'D', SET8|0x04, SET8|0x04, 0x00, 0x01,
-/* sc=21 */ 0xc1, 0xe1, 0x06, 0x06, SET8|'f', SET8|'F', SET8|0x06, SET8|0x06, 0x00, 0x01,
-/* sc=22 */ 0xd0, 0xf0, 0x07, 0x07, SET8|'g', SET8|'G', SET8|0x07, SET8|0x07, 0x00, 0x01,
-/* sc=23 */ 0xd2, 0xf2, 0x08, 0x08, SET8|'h', SET8|'H', SET8|0x08, SET8|0x08, 0x00, 0x01,
-/* sc=24 */ 0xcf, 0xef, 0x0A, 0x0A, SET8|'j', SET8|'J', SET8|0x0A, SET8|0x0A, 0x00, 0x01,
-/* sc=25 */ 0xcc, 0xec, 0x0B, 0x0B, SET8|'k', SET8|'K', SET8|0x0B, SET8|0x0B, 0x00, 0x01,
-/* sc=26 */ 0xc4, 0xe4, 0x0C, 0x0C, SET8|'l', SET8|'L', SET8|0x0C, SET8|0x0C, 0x00, 0x01,
-/* sc=27 */ 0xd6, 0xf6, NOP, NOP, SET8|';', SET8|':', NOP, NOP, 0x33, 0x01,
-/* sc=28 */ 0xdc, 0xfc, NOP, NOP, SET8|'\'', SET8|'"', NOP, NOP, 0x33, 0x01,
-/* sc=29 */ 0xa3, 0xb3, NOP, NOP, SET8|'`', SET8|'~', NOP, NOP, 0x33, 0x01,
-/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00,
-/* sc=2b */ '\\', '|', 0x1C, 0x1C, SET8|'\\', SET8|'|', SET8|0x1C, SET8|0x1C, 0x00, 0x00,
-/* sc=2c */ 0xd1, 0xf1, 0x1A, 0x1A, SET8|'z', SET8|'Z', SET8|0x1A, SET8|0x1A, 0x00, 0x01,
-/* sc=2d */ 0xde, 0xfe, 0x18, 0x18, SET8|'x', SET8|'X', SET8|0x18, SET8|0x18, 0x00, 0x01,
-/* sc=2e */ 0xd3, 0xf3, 0x03, 0x03, SET8|'c', SET8|'C', SET8|0x03, SET8|0x03, 0x00, 0x01,
-/* sc=2f */ 0xcd, 0xed, 0x16, 0x16, SET8|'v', SET8|'V', SET8|0x16, SET8|0x16, 0x00, 0x01,
-/* sc=30 */ 0xc9, 0xe9, 0x02, 0x02, SET8|'b', SET8|'B', SET8|0x02, SET8|0x02, 0x00, 0x01,
-/* sc=31 */ 0xd4, 0xf4, 0x0E, 0x0E, SET8|'n', SET8|'N', SET8|0x0E, SET8|0x0E, 0x00, 0x01,
-/* sc=32 */ 0xd8, 0xf8, 0x0D, 0x0D, SET8|'m', SET8|'M', SET8|0x0D, SET8|0x0D, 0x00, 0x01,
-/* 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=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 */ ' ', ' ', 0x00, ' ', SET8|' ', SET8|' ', SUSP, SET8|' ', 0x00, 0x00,
-/* sc=3a */ ALK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00,
-/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00,
-/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00,
-/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00,
-/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00,
-/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00,
-/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00,
-/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00,
-/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00,
-/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00,
-/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00,
-/* sc=45 */ NLK, NLK, NLK, NLK, NLK, NLK, NLK, NLK, 0xFF, 0x00,
-/* sc=46 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
-/* sc=47 */ F(49), '7', '7', '7', SET8|'7', SET8|'7', SET8|'7', SET8|'7', 0x80, 0x02,
-/* sc=48 */ F(50), '8', '8', '8', SET8|'8', SET8|'8', SET8|'8', SET8|'8', 0x80, 0x02,
-/* sc=49 */ F(51), '9', '9', '9', SET8|'9', SET8|'9', SET8|'9', SET8|'9', 0x80, 0x02,
-/* sc=4a */ F(52), '-', '-', '-', SET8|'-', SET8|'-', SET8|'-', SET8|'-', 0x80, 0x02,
-/* sc=4b */ F(53), '4', '4', '4', SET8|'4', SET8|'4', SET8|'4', SET8|'4', 0x80, 0x02,
-/* sc=4c */ F(54), '5', '5', '5', SET8|'5', SET8|'5', SET8|'5', SET8|'5', 0x80, 0x02,
-/* sc=4d */ F(55), '6', '6', '6', SET8|'6', SET8|'6', SET8|'6', SET8|'6', 0x80, 0x02,
-/* sc=4e */ F(56), '+', '+', '+', SET8|'+', SET8|'+', SET8|'+', SET8|'+', 0x80, 0x02,
-/* sc=4f */ F(57), '1', '1', '1', SET8|'1', SET8|'1', SET8|'1', SET8|'1', 0x80, 0x02,
-/* 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 */ 0x7F, '.', '.', '.', SET8|'.', SET8|'.', RBT, RBT, 0x03, 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,
-/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00,
-/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00,
-/* 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=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,
-/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00,
-/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00,
-/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00,
-/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00,
-/* 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(61), F(61), F(61), F(61), F(61), F(61), RBT, F(61), 0xFF, 0x00,
-/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
-/* sc=69 */ F(62), F(62), F(62), F(62), F(62), F(62), F(62), F(62), 0xFF, 0x00,
-/* sc=6a */ F(63), F(63), F(63), F(63), F(63), F(63), F(63), F(63), 0xFF, 0x00,
-/* sc=6b */ F(64), F(64), F(64), F(64), F(64), F(64), F(64), F(64), 0xFF, 0x00,
-};
-
-#endif
-
-#ifdef ESKEYMAP
-#define ISO_ACCENTCHARS
-static keymap_t key_map = { 0x69, /* spanish iso8859 keymap */
-/* alt
- * scan cntrl alt alt cntrl
- * code base shift cntrl shift alt shift cntrl shift spcl flgs
- * ---------------------------------------------------------------------------
- */
-/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00,
-/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, 0x00, 0x00,
-/* sc=02 */ '1', '!', NOP, NOP, '|', '|', NOP, NOP, 0x33, 0x00,
-/* sc=03 */ '2', '"', 0x00, 0x00, '@', '@', 0x00, 0x00, 0x00, 0x00,
-/* sc=04 */ '3', 0xB7, NOP, NOP, '#', '#', NOP, NOP, 0x33, 0x00,
-/* sc=05 */ '4', '$', NOP, NOP, '4', '4', NOP, NOP, 0x33, 0x00,
-/* sc=06 */ '5', '%', NOP, NOP, '5', '5', NOP, NOP, 0x33, 0x00,
-/* sc=07 */ '6', '&', 0x1E, 0x1E, 0xAC, 0xAC, 0x1E, 0x1E, 0x00, 0x00,
-/* sc=08 */ '7', '/', 0x1B, 0x1B, '7', '7', 0x1B, 0x1B, 0x00, 0x00,
-/* sc=09 */ '8', '(', NOP, NOP, '8', '8', NOP, NOP, 0x33, 0x00,
-/* sc=0a */ '9', ')', 0x1D, 0x1D, '8', '8', 0x1D, 0x1D, 0x00, 0x00,
-/* sc=0b */ '0', '=', NOP, NOP, '9', '9', NOP, NOP, 0x33, 0x00,
-/* sc=0c */ '\'', '?', NOP, NOP, '\'', '\'', NOP, NOP, 0x33, 0x00,
-/* sc=0d */ 0xA1, 0xBF, NOP, NOP, '\'', '`', NOP, NOP, 0x33, 0x00,
-/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x00, 0x00,
-/* sc=0f */ 0x09, BTAB, NOP, NOP, 0x09, BTAB, NOP, NOP, 0x77, 0x00,
-/* sc=10 */ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, 0x00, 0x01,
-/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01,
-/* sc=12 */ 'e', 'E', 0x05, 0x05, 0xE9, 0xC9, 0x05, 0x05, 0x00, 0x01,
-/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01,
-/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01,
-/* sc=15 */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x1A, 0x1A, 0x00, 0x01,
-/* sc=16 */ 'u', 'U', 0x15, 0x15, 0xFA, 0xDA, 0x15, 0x15, 0x00, 0x01,
-/* sc=17 */ 'i', 'I', 0x09, 0x09, 0xED, 0xCD, 0x09, 0x09, 0x00, 0x01,
-/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 0xF3, 0xD3, 0x0F, 0x0F, 0x00, 0x01,
-/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01,
-/* sc=1a */ DGRA, DCIR, 0x1B, 0x1B, '[', '[', 0x1B, 0x1B, 0xC0, 0x01,
-/* sc=1b */ '+', '*', 0x1D, 0x1D, ']', '[', 0x1D, 0x1D, 0x00, 0x00,
-/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00,
-/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00,
-/* sc=1e */ 'a', 'A', 0x01, 0x01, 0xE1, 0xC1, 0x01, 0x01, 0x00, 0x01,
-/* sc=1f */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01,
-/* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01,
-/* sc=21 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01,
-/* sc=22 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01,
-/* sc=23 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01,
-/* sc=24 */ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, 0x00, 0x01,
-/* sc=25 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01,
-/* sc=26 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01,
-/* sc=27 */ 0xF1, 0xD1, NOP, NOP, '~', NOP, NOP, NOP, 0x37, 0x01,
-/* sc=28 */ DACU, DUML, NOP, NOP, '{', '}', NOP, NOP, 0xF3, 0x01,
-/* sc=29 */ 0xBA, 0xAA, 0x1C, 0x1C, '\\', '\\', 0x1C, 0x1C, 0x00, 0x00,
-/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00,
-/* sc=2b */ 0xE7, 0xC7, 0x1E, 0x1E, '}', '}', 0x1E, 0x1E, 0x00, 0x00,
-/* sc=2c */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x19, 0x19, 0x00, 0x01,
-/* sc=2d */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01,
-/* sc=2e */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01,
-/* sc=2f */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01,
-/* sc=30 */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01,
-/* sc=31 */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01,
-/* sc=32 */ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, 0x00, 0x01,
-/* sc=33 */ ',', ';', NOP, NOP, ',', ';', NOP, NOP, 0x33, 0x00,
-/* sc=34 */ '.', ':', NOP, NOP, '.', ':', NOP, NOP, 0x33, 0x00,
-/* sc=35 */ '-', '_', 0x1F, 0x1F, '-', '_', 0x1F, 0x1F, 0x00, 0x00,
-/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
-/* sc=37 */ '*', '*', NEXT, NEXT, '*', '*', NEXT, NEXT, 0x33, 0x00,
-/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00,
-/* sc=39 */ ' ', ' ', 0x00, ' ', ' ', ' ', SUSP, ' ', 0x00, 0x00,
-/* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00,
-/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00,
-/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00,
-/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00,
-/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00,
-/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00,
-/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00,
-/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00,
-/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00,
-/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00,
-/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00,
-/* sc=45 */ NLK, NLK, 0x13, 0x13, NLK, NLK, 0x13, 0x13, 0xCC, 0x00,
-/* sc=46 */ SLK, SLK, 0x7F, 0x7F, SLK, SLK, 0x7F, 0x7F, 0xCC, 0x00,
-/* sc=47 */ F(49), '7', '7', '7', '7', '7', '7', '7', 0x80, 0x02,
-/* sc=48 */ F(50), '8', '8', '8', '8', '8', '8', '8', 0x80, 0x02,
-/* sc=49 */ F(51), '9', '9', '9', '9', '9', '9', '9', 0x80, 0x02,
-/* sc=4a */ F(52), '-', 0x1F, 0x1F, '-', '-', '-', '-', 0x80, 0x02,
-/* sc=4b */ F(53), '4', '4', '4', '4', '4', '4', '4', 0x80, 0x02,
-/* sc=4c */ F(54), '5', '5', '5', '5', '5', '5', '5', 0x80, 0x02,
-/* sc=4d */ F(55), '6', 0x1E, 0x1E, '6', '6', '6', '6', 0x80, 0x02,
-/* sc=4e */ F(56), '+', '+', '+', '+', '+', '+', '+', 0x80, 0x02,
-/* sc=4f */ F(57), '1', '1', '1', '1', '1', '1', '1', 0x80, 0x02,
-/* 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=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,
-/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00,
-/* sc=59 */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00,
-/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00,
-/* sc=5b */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x02,
-/* sc=5c */ '*', '*', '*', '*', '*', '*', '*', '*', 0x00, 0x02,
-/* 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,
-/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00,
-/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00,
-/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00,
-/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00,
-/* 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,
-};
-#endif
-
-#ifdef ISKEYMAP
-#define ISO_ACCENTCHARS
-static keymap_t key_map = { 0x6C, /* icelandic iso8859 keymap */
-/* alt
- * scan cntrl alt alt cntrl
- * code base shift cntrl shift alt shift cntrl shift spcl flgs
- * ---------------------------------------------------------------------------
- */
-/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 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', '"', 0x00, 0x00, NOP, NOP, 0x00, 0x00, 0x0C, 0x00,
-/* sc=04 */ '3', '#', NOP, NOP, 0xA3, NOP, NOP, NOP, 0x37, 0x00,
-/* sc=05 */ '4', '$', NOP, NOP, 0xA4, NOP, NOP, NOP, 0x37, 0x00,
-/* sc=06 */ '5', '%', NOP, NOP, NOP, NOP, NOP, NOP, 0x3F, 0x00,
-/* sc=07 */ '6', '&', NOP, NOP, NOP, NOP, NOP, NOP, 0x3F, 0x00,
-/* sc=08 */ '7', '/', NOP, NOP, '{', NOP, NOP, NOP, 0x37, 0x00,
-/* sc=09 */ '8', '(', NOP, NOP, '[', NOP, NOP, NOP, 0x37, 0x00,
-/* sc=0a */ '9', ')', NOP, NOP, ']', NOP, NOP, NOP, 0x37, 0x00,
-/* sc=0b */ '0', '=', NOP, NOP, '}', NOP, NOP, NOP, 0x37, 0x00,
-/* sc=0c */ 0xF6, 0xD6, NOP, NOP, '\\', NOP, 0x1C, NOP, 0x35, 0x00,
-/* sc=0d */ '-', '_', NOP, NOP, NOP, NOP, NOP, NOP, 0x3F, 0x00,
-/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x00, 0x00,
-/* sc=0f */ 0x09, BTAB, NOP, NOP, 0x09, BTAB, NOP, NOP, 0x77, 0x00,
-/* sc=10 */ 'q', 'Q', 0x11, 0x11, '@', 'Q', 0x11, 0x11, 0x00, 0x01,
-/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01,
-/* sc=12 */ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, 0x00, 0x01,
-/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01,
-/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01,
-/* sc=15 */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, 0x00, 0x01,
-/* sc=16 */ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, 0x00, 0x01,
-/* sc=17 */ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, 0x00, 0x01,
-/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, 0x00, 0x01,
-/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01,
-/* sc=1a */ 0xF0, 0xD0, NOP, NOP, '}', ']', NOP, NOP, 0x33, 0x01,
-/* sc=1b */ '\'', '?', NOP, NOP, '~', NOP, NOP, NOP, 0x00, 0x01,
-/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00,
-/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00,
-/* sc=1e */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01,
-/* sc=1f */ 's', 'S', 0x13, 0x13, 0xDF, 'S', 0x13, 0x13, 0x00, 0x01,
-/* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01,
-/* sc=21 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01,
-/* sc=22 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01,
-/* sc=23 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01,
-/* sc=24 */ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, 0x00, 0x01,
-/* sc=25 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01,
-/* sc=26 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01,
-/* sc=27 */ 0xE6, 0xC6, NOP, NOP, '|', '\\', NOP, NOP, 0x33, 0x01,
-/* sc=28 */ DACU, DACU, NOP, NOP, DTIL, '[', NOP, NOP, 0xFB, 0x01,
-/* sc=29 */ DRIN, DDIA, NOP, NOP, DCIR, '*', NOP, NOP, 0xFB, 0x00,
-/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00,
-/* sc=2b */ '+', '*', NOP, NOP, '`', '*', NOP, NOP, 0x00, 0x01,
-/* sc=2c */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, 0x00, 0x01,
-/* sc=2d */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01,
-/* sc=2e */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01,
-/* sc=2f */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01,
-/* sc=30 */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01,
-/* sc=31 */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01,
-/* sc=32 */ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, 0x00, 0x01,
-/* sc=33 */ ',', ';', NOP, NOP, NOP, '<', NOP, NOP, 0x3B, 0x00,
-/* sc=34 */ '.', ':', NOP, NOP, NOP, '>', NOP, NOP, 0x3B, 0x00,
-/* sc=35 */ 0xFE, 0xDE, 0x1F, NOP, '/', '?', NOP, NOP, 0x13, 0x00,
-/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
-/* sc=37 */ '*', '*', 0x0A, 0x0A, '*', '*', 0x0A, 0x0A, 0x33, 0x00,
-/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00,
-/* sc=39 */ ' ', ' ', 0x00, ' ', ' ', ' ', SUSP, ' ', 0x02, 0x00,
-/* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00,
-/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00,
-/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00,
-/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00,
-/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00,
-/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00,
-/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00,
-/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00,
-/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00,
-/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00,
-/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00,
-/* sc=45 */ NLK, NLK, 0x13, 0x13, NLK, NLK, 0x13, 0x13, 0xCC, 0x00,
-/* sc=46 */ SLK, SLK, 0x7F, 0x7F, SLK, SLK, 0x7F, 0x7F, 0xCC, 0x00,
-/* sc=47 */ F(49), '7', '7', '7', '7', '7', '7', '7', 0x80, 0x02,
-/* sc=48 */ F(50), '8', '8', '8', '8', '8', '8', '8', 0x80, 0x02,
-/* sc=49 */ F(51), '9', '9', '9', '9', '9', '9', '9', 0x80, 0x02,
-/* sc=4a */ F(52), '-', 0x1F, 0x1F, '-', '-', '-', '-', 0x80, 0x02,
-/* sc=4b */ F(53), '4', '4', '4', '4', '4', '4', '4', 0x80, 0x02,
-/* sc=4c */ F(54), '5', '5', '5', '5', '5', '5', '5', 0x80, 0x02,
-/* sc=4d */ F(55), '6', 0x1E, 0x1E, '6', '6', '6', '6', 0x80, 0x02,
-/* sc=4e */ F(56), '+', '+', '+', '+', '+', '+', '+', 0x80, 0x02,
-/* sc=4f */ F(57), '1', '1', '1', '1', '1', '1', '1', 0x80, 0x02,
-/* 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, RBT, 0x03, 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, 0x37, 0x00,
-/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00,
-/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00,
-/* sc=59 */ 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0xFF, 0x02,
-/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00,
-/* sc=5b */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x02,
-/* sc=5c */ NEXT, NOP, DBG, NOP, NOP, NOP, NOP, NOP, 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,
-/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00,
-/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00,
-/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00,
-/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00,
-/* 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(61), F(61), F(61), F(61), F(61), F(61), RBT, F(61), 0xFF, 0x00,
-/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
-/* sc=69 */ F(62), F(62), F(62), F(62), F(62), F(62), F(62), F(62), 0xFF, 0x00,
-/* sc=6a */ F(63), F(63), F(63), F(63), F(63), F(63), F(63), F(63), 0xFF, 0x00,
-/* sc=6b */ F(64), F(64), F(64), F(64), F(64), F(64), F(64), F(64), 0xFF, 0x00,
-};
-#endif
-
-#if !defined(DKKEYMAP) && !defined(UKKEYMAP) && !defined(GRKEYMAP) && !defined(SWKEYMAP) && !defined(RUKEYMAP) && !defined(ISKEYMAP) && !defined(ESKEYMAP) && !defined(PC98)
-#define ISO_ACCENTCHARS
-static keymap_t key_map = { 0x6C, /* US iso8859 keymap */
-/* alt
- * scan cntrl alt alt cntrl
- * code base shift cntrl shift alt shift cntrl shift spcl flgs
- * ---------------------------------------------------------------------------
- */
-/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 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,
-/* sc=05 */ '4', '$', NOP, NOP, '4', '$', NOP, NOP, 0x33, 0x00,
-/* sc=06 */ '5', '%', NOP, NOP, '5', '%', NOP, NOP, 0x33, 0x00,
-/* sc=07 */ '6', '^', 0x1E, 0x1E, '6', '^', 0x1E, 0x1E, 0x00, 0x00,
-/* sc=08 */ '7', '&', NOP, NOP, '7', '&', NOP, NOP, 0x33, 0x00,
-/* sc=09 */ '8', '*', NOP, NOP, '8', '*', NOP, NOP, 0x33, 0x00,
-/* sc=0a */ '9', '(', NOP, NOP, '9', '(', NOP, NOP, 0x33, 0x00,
-/* sc=0b */ '0', ')', NOP, NOP, '0', ')', NOP, NOP, 0x33, 0x00,
-/* sc=0c */ '-', '_', 0x1F, 0x1F, '-', '_', 0x1F, 0x1F, 0x00, 0x00,
-/* sc=0d */ '=', '+', NOP, NOP, '=', '+', NOP, NOP, 0x33, 0x00,
-/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x00, 0x00,
-/* sc=0f */ 0x09, BTAB, NOP, NOP, 0x09, BTAB, NOP, NOP, 0x77, 0x00,
-/* sc=10 */ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, 0x00, 0x01,
-/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01,
-/* sc=12 */ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, 0x00, 0x01,
-/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01,
-/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01,
-/* sc=15 */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, 0x00, 0x01,
-/* sc=16 */ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, 0x00, 0x01,
-/* sc=17 */ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, 0x00, 0x01,
-/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, 0x00, 0x01,
-/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01,
-/* sc=1a */ '[', '{', 0x1B, 0x1B, '[', '{', 0x1B, 0x1B, 0x00, 0x00,
-/* sc=1b */ ']', '}', 0x1D, 0x1D, ']', '}', 0x1D, 0x1D, 0x00, 0x00,
-/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00,
-/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00,
-/* sc=1e */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01,
-/* sc=1f */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01,
-/* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01,
-/* sc=21 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01,
-/* sc=22 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01,
-/* sc=23 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01,
-/* sc=24 */ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, 0x00, 0x01,
-/* sc=25 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01,
-/* sc=26 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01,
-/* sc=27 */ ';', ':', NOP, NOP, ';', ':', NOP, NOP, 0x33, 0x00,
-/* sc=28 */ '\'', '"', NOP, NOP, '\'', '"', NOP, NOP, 0x33, 0x00,
-/* sc=29 */ '`', '~', NOP, NOP, '`', '~', NOP, NOP, 0x33, 0x00,
-/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00,
-/* sc=2b */ '\\', '|', 0x1C, 0x1C, '\\', '|', 0x1C, 0x1C, 0x00, 0x00,
-/* sc=2c */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, 0x00, 0x01,
-/* sc=2d */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01,
-/* sc=2e */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01,
-/* sc=2f */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01,
-/* sc=30 */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01,
-/* sc=31 */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01,
-/* sc=32 */ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, 0x00, 0x01,
-/* sc=33 */ ',', '<', NOP, NOP, ',', '<', NOP, NOP, 0x33, 0x00,
-/* sc=34 */ '.', '>', NOP, NOP, '.', '>', NOP, NOP, 0x33, 0x00,
-/* sc=35 */ '/', '?', NOP, NOP, '/', '?', NOP, NOP, 0x33, 0x00,
-/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00,
-/* sc=37 */ '*', '*', 0x0A, 0x0A, '*', '*', 0x0A, 0x0A, 0x33, 0x00,
-/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00,
-/* sc=39 */ ' ', ' ', 0x00, ' ', ' ', ' ', SUSP, ' ', 0x02, 0x00,
-/* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00,
-/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00,
-/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00,
-/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00,
-/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00,
-/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00,
-/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00,
-/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00,
-/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00,
-/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00,
-/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00,
-/* sc=45 */ NLK, NLK, NLK, NLK, NLK, NLK, NLK, NLK, 0xFF, 0x00,
-/* sc=46 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
-/* sc=47 */ F(49), '7', '7', '7', '7', '7', '7', '7', 0x80, 0x02,
-/* sc=48 */ F(50), '8', '8', '8', '8', '8', '8', '8', 0x80, 0x02,
-/* sc=49 */ F(51), '9', '9', '9', '9', '9', '9', '9', 0x80, 0x02,
-/* sc=4a */ F(52), '-', '-', '-', '-', '-', '-', '-', 0x80, 0x02,
-/* sc=4b */ F(53), '4', '4', '4', '4', '4', '4', '4', 0x80, 0x02,
-/* sc=4c */ F(54), '5', '5', '5', '5', '5', '5', '5', 0x80, 0x02,
-/* sc=4d */ F(55), '6', '6', '6', '6', '6', '6', '6', 0x80, 0x02,
-/* sc=4e */ F(56), '+', '+', '+', '+', '+', '+', '+', 0x80, 0x02,
-/* sc=4f */ F(57), '1', '1', '1', '1', '1', '1', '1', 0x80, 0x02,
-/* 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, RBT, 0x03, 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,
-/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00,
-/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00,
-/* sc=59 */ 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00,
-/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00,
-/* sc=5b */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x00,
-/* sc=5c */ NEXT, NOP, DBG, NOP, NOP, NOP, NOP, NOP, 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,
-/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00,
-/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00,
-/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00,
-/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00,
-/* 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(61), F(61), F(61), F(61), F(61), F(61), RBT, F(61), 0xFF, 0x00,
-/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00,
-/* sc=69 */ F(62), F(62), F(62), F(62), F(62), F(62), F(62), F(62), 0xFF, 0x00,
-/* sc=6a */ F(63), F(63), F(63), F(63), F(63), F(63), F(63), F(63), 0xFF, 0x00,
-/* sc=6b */ F(64), F(64), F(64), F(64), F(64), F(64), F(64), F(64), 0xFF, 0x00,
-};
-#endif
-
-#if defined(NO_ACCENTCHARS)
-static accentmap_t accent_map = { 0, /* empty accent map */
- {
- { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 },
- { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 },
- }
-};
-#endif
-
-#if defined(ISO_ACCENTCHARS)
-static accentmap_t accent_map = { 15, /* iso8859 accent map */
- {
- /* dgra=0 */
- { '`', { { 'a',0xe0 }, { 'A',0xc0 }, { 'e',0xe8 }, { 'E',0xc8 },
- { 'i',0xec }, { 'I',0xcc }, { 'o',0xf2 }, { 'O',0xd2 },
- { 'u',0xf9 }, { 'U',0xd9 }, }, },
- /* dacu=1 */
- { 0xb4, { { 'a',0xe1 }, { 'A',0xc1 }, { 'e',0xe9 }, { 'E',0xc9 },
- { 'i',0xed }, { 'I',0xcd }, { 'o',0xf3 }, { 'O',0xd3 },
- { 'u',0xfa }, { 'U',0xda }, { 'y',0xfd }, { 'Y',0xdd }, }, },
- /* dcir=2 */
- { '^', { { 'a',0xe2 }, { 'A',0xc2 }, { 'e',0xea }, { 'E',0xca },
- { 'i',0xee }, { 'I',0xce }, { 'o',0xf4 }, { 'O',0xd4 },
- { 'u',0xfb }, { 'U',0xdb }, }, },
- /* dtil=3 */
- { '~', { { 'a',0xe3 }, { 'A',0xc3 }, { 'n',0xf1 }, { 'N',0xd1 },
- { 'o',0xf5 }, { 'O',0xd5 }, }, },
- /* dmac=4 */
- { 0 },
- /* dbre=5 */
- { 0 },
- /* ddot=6 */
- { 0 },
- /* duml=7 */
- { 0xa8, { { 'a',0xe4 }, { 'A',0xc4 }, { 'e',0xeb }, { 'E',0xcb },
- { 'i',0xef }, { 'I',0xcf }, { 'o',0xf6 }, { 'O',0xd6 },
- { 'u',0xfc }, { 'U',0xdc }, { 'y',0xff }, }, },
- /* dsla=8 */
- { 0 },
- /* drin=9 */
- { 0xb0, { { 'a',0xe5 }, { 'A',0xc5 }, }, },
- /* dced=10 */
- { 0xb8, { { 'c',0xe7 }, { 'C',0xc7 }, }, },
- /* dapo=11 */
- { 0 },
- /* ddac=12 */
- { 0 },
- /* dogo=13 */
- { 0 },
- /* dcar=14 */
- { 0 },
- }
-};
-#endif /* ISO_ACCENTCHARS */
-
-static fkeytab_t fkey_tab[96] = {
-/* 01-04 */ {"\033[M", 3}, {"\033[N", 3}, {"\033[O", 3}, {"\033[P", 3},
-/* 05-08 */ {"\033[Q", 3}, {"\033[R", 3}, {"\033[S", 3}, {"\033[T", 3},
-/* 09-12 */ {"\033[U", 3}, {"\033[V", 3}, {"\033[W", 3}, {"\033[X", 3},
-/* 13-16 */ {"\033[Y", 3}, {"\033[Z", 3}, {"\033[a", 3}, {"\033[b", 3},
-/* 17-20 */ {"\033[c", 3}, {"\033[d", 3}, {"\033[e", 3}, {"\033[f", 3},
-/* 21-24 */ {"\033[g", 3}, {"\033[h", 3}, {"\033[i", 3}, {"\033[j", 3},
-/* 25-28 */ {"\033[k", 3}, {"\033[l", 3}, {"\033[m", 3}, {"\033[n", 3},
-/* 29-32 */ {"\033[o", 3}, {"\033[p", 3}, {"\033[q", 3}, {"\033[r", 3},
-/* 33-36 */ {"\033[s", 3}, {"\033[t", 3}, {"\033[u", 3}, {"\033[v", 3},
-/* 37-40 */ {"\033[w", 3}, {"\033[x", 3}, {"\033[y", 3}, {"\033[z", 3},
-/* 41-44 */ {"\033[@", 3}, {"\033[[", 3}, {"\033[\\",3}, {"\033[]", 3},
-/* 45-48 */ {"\033[^", 3}, {"\033[_", 3}, {"\033[`", 3}, {"\033[{", 3},
-/* 49-52 */ {"\033[H", 3}, {"\033[A", 3}, {"\033[I", 3}, {"-" , 1},
-/* 53-56 */ {"\033[D", 3}, {"\033[E", 3}, {"\033[C", 3}, {"+" , 1},
-/* 57-60 */ {"\033[F", 3}, {"\033[B", 3}, {"\033[G", 3}, {"\033[L", 3},
-/* 61-64 */ {"\177", 1}, {"\033[J", 3}, {"\033[~", 3}, {"\033[}", 3},
-/* 65-68 */ {"", 0} , {"", 0} , {"", 0} , {"", 0} ,
-/* 69-72 */ {"", 0} , {"", 0} , {"", 0} , {"", 0} ,
-/* 73-76 */ {"", 0} , {"", 0} , {"", 0} , {"", 0} ,
-/* 77-80 */ {"", 0} , {"", 0} , {"", 0} , {"", 0} ,
-/* 81-84 */ {"", 0} , {"", 0} , {"", 0} , {"", 0} ,
-/* 85-88 */ {"", 0} , {"", 0} , {"", 0} , {"", 0} ,
-/* 89-92 */ {"", 0} , {"", 0} , {"", 0} , {"", 0} ,
-/* 93-96 */ {"", 0} , {"", 0} , {"", 0} , {"", 0}
-};
diff --git a/sys/isa/psm.c b/sys/isa/psm.c
index 5b999e1..e7eb469 100644
--- a/sys/isa/psm.c
+++ b/sys/isa/psm.c
@@ -20,7 +20,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: psm.c,v 1.1 1998/11/08 18:43:03 dfr Exp $
+ * $Id: psm.c,v 1.2 1998/11/15 18:25:17 dfr Exp $
*/
/*
@@ -90,7 +90,7 @@
#include <isa/isareg.h>
#include <isa/isavar.h>
-#include <isa/kbdio.h>
+#include <dev/kbd/atkbdcreg.h>
/*
* Driver specific options: the following options may be set by
@@ -740,6 +740,8 @@ psmprobe(device_t dev)
{
int unit = device_get_unit(dev);
struct psm_softc *sc = device_get_softc(dev);
+ u_long port;
+ u_long flags;
int stat[3];
int command_byte;
int mask;
@@ -748,13 +750,18 @@ psmprobe(device_t dev)
#if 0
kbdc_debug(TRUE);
#endif
- sc->addr = isa_get_port(dev);
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
+
+ sc->addr = port;
sc->kbdc = kbdc_open(sc->addr);
- sc->config = isa_get_flags(dev) & PSM_CONFIG_FLAGS;
+ sc->config = flags & PSM_CONFIG_FLAGS;
sc->flags = 0;
if (bootverbose)
++verbose;
+ device_set_desc(dev, "PS/2 Mouse");
+
if (!kbdc_lock(sc->kbdc, TRUE)) {
printf("psm%d: unable to lock the controller.\n", unit);
if (bootverbose)
@@ -984,6 +991,7 @@ psmattach(device_t dev)
struct psm_softc *sc = device_get_softc(dev);
void *ih;
struct resource *res;
+ u_long irq;
int zero = 0;
if (sc == NULL) /* shouldn't happen */
@@ -1027,7 +1035,8 @@ psmattach(device_t dev)
if (bootverbose)
--verbose;
- res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, 0ul, ~0ul, 1,
+ BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
+ res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1,
RF_SHAREABLE | RF_ACTIVE);
BUS_SETUP_INTR(device_get_parent(dev), dev, res, psmintr, sc,
&ih);
@@ -2216,7 +2225,7 @@ psmresume(void *dummy)
}
#endif /* PSM_HOOKAPM */
-CDEV_DRIVER_MODULE(psm, isa, psm_driver, psm_devclass,
+CDEV_DRIVER_MODULE(psm, atkbdc, psm_driver, psm_devclass,
CDEV_MAJOR, psm_cdevsw, 0, 0);
#endif /* NPSM > 0 */
diff --git a/sys/isa/scvidctl.c b/sys/isa/scvidctl.c
deleted file mode 100644
index 5934bdf..0000000
--- a/sys/isa/scvidctl.c
+++ /dev/null
@@ -1,489 +0,0 @@
-/*-
- * Copyright (c) 1998 Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id$
- * from: i386/isa scvidctl.c,v 1.1
- */
-
-#include "sc.h"
-#include "opt_syscons.h"
-
-#if NSC > 0
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/signalvar.h>
-#include <sys/tty.h>
-#include <sys/kernel.h>
-
-#ifdef __i386__
-#include <machine/apm_bios.h>
-#endif
-#include <machine/console.h>
-
-#include <isa/videoio.h>
-#include <isa/syscons.h>
-
-/* video ioctl */
-
-extern scr_stat *cur_console;
-extern u_int32_t Crtat;
-extern int fonts_loaded;
-extern int sc_history_size;
-extern u_char palette[];
-
-int
-sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode, int xsize, int ysize,
- int fontsize)
-{
- video_adapter_t *adp;
- video_info_t info;
- int error;
- int s;
- int i;
-
- if ((*biosvidsw.get_info)(scp->adp, mode, &info))
- return ENODEV;
- adp = get_adapter(scp);
-
- /* adjust argument values */
- if (fontsize <= 0)
- fontsize = info.vi_cheight;
- if (fontsize < 14) {
- fontsize = 8;
- if (!(fonts_loaded & FONT_8))
- return EINVAL;
- } else if (fontsize >= 16) {
- fontsize = 16;
- if (!(fonts_loaded & FONT_16))
- return EINVAL;
- } else {
- fontsize = 14;
- if (!(fonts_loaded & FONT_14))
- return EINVAL;
- }
- if ((xsize <= 0) || (xsize > info.vi_width))
- xsize = info.vi_width;
- if ((ysize <= 0) || (ysize > info.vi_height))
- ysize = info.vi_height;
-
- /* stop screen saver, etc */
- s = spltty();
- if ((error = sc_clean_up(scp))) {
- splx(s);
- return error;
- }
-
- /* set up scp */
- if (scp->history != NULL)
- i = imax(scp->history_size / scp->xsize
- - imax(sc_history_size, scp->ysize), 0);
- else
- i = 0;
- /*
- * This is a kludge to fend off scrn_update() while we
- * muck around with scp. XXX
- */
- scp->status |= UNKNOWN_MODE;
- scp->status &= ~(GRAPHICS_MODE | PIXEL_MODE);
- scp->mode = mode;
- scp->font_size = fontsize;
- scp->xsize = xsize;
- scp->ysize = ysize;
- scp->xpixel = scp->xsize*8;
- scp->ypixel = scp->ysize*fontsize;
-
- /* allocate buffers */
- sc_alloc_scr_buffer(scp, TRUE, TRUE);
- if (ISMOUSEAVAIL(adp->va_flags))
- sc_alloc_cut_buffer(scp, FALSE);
- sc_alloc_history_buffer(scp, sc_history_size, i, FALSE);
- splx(s);
-
- if (scp == cur_console)
- set_mode(scp);
- scp->status &= ~UNKNOWN_MODE;
-
- if (tp == NULL)
- return 0;
- if (tp->t_winsize.ws_col != scp->xsize
- || tp->t_winsize.ws_row != scp->ysize) {
- tp->t_winsize.ws_col = scp->xsize;
- tp->t_winsize.ws_row = scp->ysize;
- pgsignal(tp->t_pgrp, SIGWINCH, 1);
- }
-
- return 0;
-}
-
-int
-sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode)
-{
- video_adapter_t *adp;
- video_info_t info;
- int error;
- int s;
-
- if ((*biosvidsw.get_info)(scp->adp, mode, &info))
- return ENODEV;
- adp = get_adapter(scp);
-
- /* stop screen saver, etc */
- s = spltty();
- if ((error = sc_clean_up(scp))) {
- splx(s);
- return error;
- }
-
- /* set up scp */
- scp->status |= (UNKNOWN_MODE | GRAPHICS_MODE);
- scp->status &= ~PIXEL_MODE;
- scp->mode = mode;
- scp->xpixel = info.vi_width;
- scp->ypixel = info.vi_height;
- scp->xsize = info.vi_width/8;
- scp->ysize = info.vi_height/info.vi_cheight;
- scp->font_size = FONT_NONE;
- /* move the mouse cursor at the center of the screen */
- sc_move_mouse(scp, scp->xpixel / 2, scp->ypixel / 2);
- splx(s);
-
- if (scp == cur_console)
- set_mode(scp);
- /* clear_graphics();*/
- scp->status &= ~UNKNOWN_MODE;
-
- if (tp == NULL)
- return 0;
- if (tp->t_winsize.ws_xpixel != scp->xpixel
- || tp->t_winsize.ws_ypixel != scp->ypixel) {
- tp->t_winsize.ws_xpixel = scp->xpixel;
- tp->t_winsize.ws_ypixel = scp->ypixel;
- pgsignal(tp->t_pgrp, SIGWINCH, 1);
- }
-
- return 0;
-}
-
-int
-sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize, int ysize,
- int fontsize)
-{
- video_adapter_t *adp;
- video_info_t info;
- int error;
- int s;
- int i;
-
- if ((*biosvidsw.get_info)(scp->adp, scp->mode, &info))
- return ENODEV; /* this shouldn't happen */
- adp = get_adapter(scp);
-
-#ifdef SC_VIDEO_DEBUG
- if (scp->scr_buf != NULL) {
- printf("set_pixel_mode(): mode:%x, col:%d, row:%d, font:%d\n",
- scp->mode, xsize, ysize, fontsize);
- }
-#endif
-
- /* adjust argument values */
- if ((fontsize <= 0) || (fontsize == FONT_NONE))
- fontsize = info.vi_cheight;
- if (fontsize < 14) {
- fontsize = 8;
- if (!(fonts_loaded & FONT_8))
- return EINVAL;
- } else if (fontsize >= 16) {
- fontsize = 16;
- if (!(fonts_loaded & FONT_16))
- return EINVAL;
- } else {
- fontsize = 14;
- if (!(fonts_loaded & FONT_14))
- return EINVAL;
- }
- if (xsize <= 0)
- xsize = info.vi_width/8;
- if (ysize <= 0)
- ysize = info.vi_height/fontsize;
-
-#ifdef SC_VIDEO_DEBUG
- if (scp->scr_buf != NULL) {
- printf("set_pixel_mode(): mode:%x, col:%d, row:%d, font:%d\n",
- scp->mode, xsize, ysize, fontsize);
- printf("set_pixel_mode(): Crtat:%x, %dx%d, xoff:%d, yoff:%d\n",
- Crtat, info.vi_width, info.vi_height,
- (info.vi_width/8 - xsize)/2,
- (info.vi_height/fontsize - ysize)/2);
- }
-#endif
-
- /* stop screen saver, etc */
- s = spltty();
- if ((error = sc_clean_up(scp))) {
- splx(s);
- return error;
- }
-
- /* set up scp */
- if (scp->history != NULL)
- i = imax(scp->history_size / scp->xsize
- - imax(sc_history_size, scp->ysize), 0);
- else
- i = 0;
- scp->status |= (UNKNOWN_MODE | PIXEL_MODE);
- scp->status &= ~(GRAPHICS_MODE | MOUSE_ENABLED);
- scp->xsize = xsize;
- scp->ysize = ysize;
- scp->font_size = fontsize;
- scp->xoff = (scp->xpixel/8 - xsize)/2;
- scp->yoff = (scp->ypixel/fontsize - ysize)/2;
-
- /* allocate buffers */
- sc_alloc_scr_buffer(scp, TRUE, TRUE);
- if (ISMOUSEAVAIL(adp->va_flags))
- sc_alloc_cut_buffer(scp, FALSE);
- sc_alloc_history_buffer(scp, sc_history_size, i, FALSE);
- splx(s);
-
- /* FIXME */
- if (scp == cur_console)
- memset_io(Crtat, 0, scp->xpixel*scp->ypixel/8);
-
- scp->status &= ~UNKNOWN_MODE;
-
-#ifdef SC_VIDEO_DEBUG
- printf("set_pixel_mode(): status:%x\n", scp->status);
-#endif
-
- if (tp == NULL)
- return 0;
- if (tp->t_winsize.ws_col != scp->xsize
- || tp->t_winsize.ws_row != scp->ysize) {
- tp->t_winsize.ws_col = scp->xsize;
- tp->t_winsize.ws_row = scp->ysize;
- pgsignal(tp->t_pgrp, SIGWINCH, 1);
- }
-
- return 0;
-}
-
-int
-sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p)
-{
- scr_stat *scp;
- video_adapter_t *adp;
- int error;
- int s;
-
- scp = sc_get_scr_stat(tp->t_dev);
-
- switch (cmd) {
-
- case CONS_CURRENT: /* get current adapter type */
- adp = get_adapter(scp);
- *(int *)data = adp->va_type;
- return 0;
-
- case CONS_CURRENTADP: /* get current adapter index */
- *(int *)data = scp->adp;
- return 0;
-
- case CONS_ADPINFO: /* adapter information */
- adp = (*biosvidsw.adapter)(((video_adapter_t *)data)->va_index);
- if (adp == NULL)
- return ENODEV;
- bcopy(adp, data, sizeof(*adp));
- return 0;
-
- case CONS_GET: /* get current video mode */
- *(int *)data = scp->mode;
- return 0;
-
- case CONS_MODEINFO: /* get mode information */
- return ((*biosvidsw.get_info)(scp->adp,
- ((video_info_t *)data)->vi_mode, (video_info_t *)data)
- ? ENODEV : 0);
-
- case CONS_FINDMODE: /* find a matching video mode */
- return ((*biosvidsw.query_mode)(scp->adp, (video_info_t *)data)
- ? ENODEV : 0);
-
- case CONS_SETWINORG:
- return ((*biosvidsw.set_win_org)(scp->adp, *(u_int *)data)
- ? ENODEV : 0);
-
- /* VGA TEXT MODES */
- case SW_VGA_C40x25:
- case SW_VGA_C80x25: case SW_VGA_M80x25:
- case SW_VGA_C80x30: case SW_VGA_M80x30:
- case SW_VGA_C80x50: case SW_VGA_M80x50:
- case SW_VGA_C80x60: case SW_VGA_M80x60:
- case SW_B40x25: case SW_C40x25:
- case SW_B80x25: case SW_C80x25:
- case SW_ENH_B40x25: case SW_ENH_C40x25:
- case SW_ENH_B80x25: case SW_ENH_C80x25:
- case SW_ENH_B80x43: case SW_ENH_C80x43:
- case SW_EGAMONO80x25:
- adp = get_adapter(scp);
- if (!(adp->va_flags & V_ADP_MODECHANGE))
- return ENODEV;
- return sc_set_text_mode(scp, tp, cmd & 0xff, 0, 0, 0);
-
- /* GRAPHICS MODES */
- case SW_BG320: case SW_BG640:
- case SW_CG320: case SW_CG320_D: case SW_CG640_E:
- case SW_CG640x350: case SW_ENH_CG640:
- case SW_BG640x480: case SW_CG640x480: case SW_VGA_CG320:
- case SW_VGA_MODEX:
- adp = get_adapter(scp);
- if (!(adp->va_flags & V_ADP_MODECHANGE))
- return ENODEV;
- return sc_set_graphics_mode(scp, tp, cmd & 0xff);
-
- case KDSETMODE: /* set current mode of this (virtual) console */
- switch (*data) {
- case KD_TEXT: /* switch to TEXT (known) mode */
- /*
- * If scp->mode is of graphics modes, we don't know which
- * text mode to switch back to...
- */
- if (scp->status & GRAPHICS_MODE)
- return EINVAL;
- /* restore fonts & palette ! */
-#if 0
- adp = get_adapter(scp);
- if (ISFONTAVAIL(adp->va_flags)
- && !(scp->status & (GRAPHICS_MODE | PIXEL_MODE)))
- /*
- * FONT KLUDGE
- * Don't load fonts for now... XXX
- */
- if (fonts_loaded & FONT_8)
- copy_font(scp, LOAD, 8, font_8);
- if (fonts_loaded & FONT_14)
- copy_font(scp, LOAD, 14, font_14);
- if (fonts_loaded & FONT_16)
- copy_font(scp, LOAD, 16, font_16);
- }
-#endif
- load_palette(scp, palette);
-
- /* move hardware cursor out of the way */
- (*biosvidsw.set_hw_cursor)(scp->adp, -1, -1);
-
- /* FALL THROUGH */
-
- case KD_TEXT1: /* switch to TEXT (known) mode */
- /*
- * If scp->mode is of graphics modes, we don't know which
- * text/pixel mode to switch back to...
- */
- if (scp->status & GRAPHICS_MODE)
- return EINVAL;
- s = spltty();
- if ((error = sc_clean_up(scp))) {
- splx(s);
- return error;
- }
- scp->status |= UNKNOWN_MODE;
- splx(s);
- /* no restore fonts & palette */
- if (scp == cur_console) {
- set_mode(scp);
- /* FIXME */
- if (scp->status & PIXEL_MODE)
- memset_io(Crtat, 0, scp->xpixel*scp->ypixel/8);
- }
- sc_clear_screen(scp);
- scp->status &= ~UNKNOWN_MODE;
- return 0;
-
- case KD_PIXEL: /* pixel (raster) display */
- if (!(scp->status & (GRAPHICS_MODE | PIXEL_MODE)))
- return EINVAL;
- if (!(scp->status & PIXEL_MODE))
- return sc_set_pixel_mode(scp, tp, scp->xsize, scp->ysize,
- scp->font_size);
- s = spltty();
- if ((error = sc_clean_up(scp))) {
- splx(s);
- return error;
- }
- scp->status |= (UNKNOWN_MODE | PIXEL_MODE);
- splx(s);
- if (scp == cur_console) {
- set_mode(scp);
- load_palette(scp, palette);
- /* FIXME */
- memset_io(Crtat, 0, scp->xpixel*scp->ypixel/8);
- }
- sc_clear_screen(scp);
- scp->status &= ~UNKNOWN_MODE;
- return 0;
-
- case KD_GRAPHICS: /* switch to GRAPHICS (unknown) mode */
- s = spltty();
- if ((error = sc_clean_up(scp))) {
- splx(s);
- return error;
- }
- scp->status |= UNKNOWN_MODE;
- splx(s);
- return 0;
-
- default:
- return EINVAL;
- }
- /* NOT REACHED */
-
- case KDRASTER: /* set pixel (raster) display mode */
- if (ISUNKNOWNSC(scp) || ISTEXTSC(scp))
- return ENODEV;
- return sc_set_pixel_mode(scp, tp, ((int *)data)[0], ((int *)data)[1],
- ((int *)data)[2]);
-
- case KDGETMODE: /* get current mode of this (virtual) console */
- /*
- * From the user program's point of view, KD_PIXEL is the same
- * as KD_TEXT...
- */
- *data = ISGRAPHSC(scp) ? KD_GRAPHICS : KD_TEXT;
- return 0;
-
- case KDSBORDER: /* set border color of this (virtual) console */
- scp->border = *data;
- if (scp == cur_console)
- set_border(cur_console, scp->border);
- return 0;
- }
-
- return ENOIOCTL;
-}
-
-#endif /* NSC > 0 */
diff --git a/sys/isa/syscons.c b/sys/isa/syscons.c
deleted file mode 100644
index e44fe37..0000000
--- a/sys/isa/syscons.c
+++ /dev/null
@@ -1,4671 +0,0 @@
-/*-
- * Copyright (c) 1992-1998 Søren Schmidt
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * without modification, immediately at the beginning of the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $Id: syscons.c,v 1.276 1998/11/08 12:39:04 dfr Exp $
- * from: i386/isa syscons.c,v 1.278
- */
-
-#include "sc.h"
-/* #include "apm.h" */
-#define NAPM 0
-
-#include "opt_ddb.h"
-#include "opt_devfs.h"
-#ifdef __i386__
-#include "opt_vesa.h"
-#include "opt_vm86.h"
-#endif
-#include "opt_syscons.h"
-
-#if NSC > 0
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/reboot.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-#include <sys/conf.h>
-#include <sys/proc.h>
-#include <sys/signalvar.h>
-#include <sys/tty.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/rman.h>
-#ifdef DEVFS
-#include <sys/devfsext.h>
-#endif
-
-#include <machine/resource.h>
-#include <machine/clock.h>
-#include <machine/cons.h>
-#include <machine/console.h>
-#include <machine/mouse.h>
-#include <machine/md_var.h>
-#include <machine/psl.h>
-#include <machine/frame.h>
-#include <machine/pc/display.h>
-#include <machine/pc/vesa.h>
-/* #include <machine/apm_bios.h> */
-/* #include <machine/random.h> */
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-
-#include <isa/isareg.h>
-#include <isa/isavar.h>
-#include <isa/timerreg.h>
-#include <isa/kbdtables.h>
-#include <isa/kbdio.h>
-#include <isa/videoio.h>
-#include <isa/syscons.h>
-
-#if !defined(MAXCONS)
-#define MAXCONS 16
-#endif
-
-#if !defined(SC_MAX_HISTORY_SIZE)
-#define SC_MAX_HISTORY_SIZE (1000 * MAXCONS)
-#endif
-
-#if !defined(SC_HISTORY_SIZE)
-#define SC_HISTORY_SIZE (ROW * 4)
-#endif
-
-#if (SC_HISTORY_SIZE * MAXCONS) > SC_MAX_HISTORY_SIZE
-#undef SC_MAX_HISTORY_SIZE
-#define SC_MAX_HISTORY_SIZE (SC_HISTORY_SIZE * MAXCONS)
-#endif
-
-#if !defined(SC_MOUSE_CHAR)
-#define SC_MOUSE_CHAR (0xd0)
-#endif
-
-#define COLD 0
-#define WARM 1
-
-#define DEFAULT_BLANKTIME (5*60) /* 5 minutes */
-#define MAX_BLANKTIME (7*24*60*60) /* 7 days!? */
-
-/* for backward compatibility */
-#define OLD_CONS_MOUSECTL _IOWR('c', 10, old_mouse_info_t)
-
-typedef struct old_mouse_data {
- int x;
- int y;
- int buttons;
-} old_mouse_data_t;
-
-typedef struct old_mouse_info {
- int operation;
- union {
- struct old_mouse_data data;
- struct mouse_mode mode;
- } u;
-} old_mouse_info_t;
-
-/* XXX use sc_bcopy where video memory is concerned */
-extern void generic_bcopy(const void *, void *, size_t);
-
-static default_attr user_default = {
- (FG_LIGHTGREY | BG_BLACK) << 8,
- (FG_BLACK | BG_LIGHTGREY) << 8
-};
-
-static default_attr kernel_default = {
- (FG_WHITE | BG_BLACK) << 8,
- (FG_BLACK | BG_LIGHTGREY) << 8
-};
-
-static scr_stat main_console;
-static scr_stat *console[MAXCONS];
-#ifdef DEVFS
-static void *sc_devfs_token[MAXCONS];
-static void *sc_mouse_devfs_token;
-static void *sc_console_devfs_token;
-#endif
- scr_stat *cur_console;
-static scr_stat *new_scp, *old_scp;
-static term_stat kernel_console;
-static default_attr *current_default;
-static int flags = 0;
-static int sc_port = IO_KBD;
-static KBDC sc_kbdc = NULL;
-static char init_done = COLD;
-static u_short sc_buffer[ROW*COL];
-static char shutdown_in_progress = FALSE;
-static char font_loading_in_progress = FALSE;
-static char switch_in_progress = FALSE;
-static char write_in_progress = FALSE;
-static char blink_in_progress = FALSE;
-static int blinkrate = 0;
- u_int crtc_addr = MONO_BASE;
- char crtc_type = KD_MONO;
- char crtc_vga = FALSE;
-static int adp_flags = 0;
-static u_char shfts = 0, ctls = 0, alts = 0, agrs = 0, metas = 0;
-static u_char accents = 0;
-static u_char nlkcnt = 0, clkcnt = 0, slkcnt = 0, alkcnt = 0;
-static const u_int n_fkey_tab = sizeof(fkey_tab) / sizeof(*fkey_tab);
-static int delayed_next_scr = FALSE;
-static long scrn_blank_time = 0; /* screen saver timeout value */
- int scrn_blanked = 0; /* screen saver active flag */
-static long scrn_time_stamp;
-static int saver_mode = CONS_LKM_SAVER; /* LKM/user saver */
-static int run_scrn_saver = FALSE; /* should run the saver? */
-static int scrn_idle = FALSE; /* about to run the saver */
- u_char scr_map[256];
- u_char scr_rmap[256];
-static int initial_video_mode; /* initial video mode # */
-static int bios_video_mode; /* video mode # set by BIOS */
- int fonts_loaded = 0
-#ifdef STD8X16FONT
- | FONT_16
-#endif
- ;
-
- u_char font_8[256*8];
- u_char font_14[256*14];
-#ifdef STD8X16FONT
-extern
-#endif
- u_char font_16[256*16];
- u_char palette[256*3];
-static u_char *cut_buffer = NULL;
-static int cut_buffer_size = 0;
-static int mouse_level = 0; /* sysmouse protocol level */
-static mousestatus_t mouse_status = { 0, 0, 0, 0, 0, 0 };
-static u_short mouse_and_mask[16] = {
- 0xc000, 0xe000, 0xf000, 0xf800,
- 0xfc00, 0xfe00, 0xff00, 0xff80,
- 0xfe00, 0x1e00, 0x1f00, 0x0f00,
- 0x0f00, 0x0000, 0x0000, 0x0000
- };
-static u_short mouse_or_mask[16] = {
- 0x0000, 0x4000, 0x6000, 0x7000,
- 0x7800, 0x7c00, 0x7e00, 0x6800,
- 0x0c00, 0x0c00, 0x0600, 0x0600,
- 0x0000, 0x0000, 0x0000, 0x0000
- };
-
- int sc_history_size = SC_HISTORY_SIZE;
-static int extra_history_size =
- SC_MAX_HISTORY_SIZE - SC_HISTORY_SIZE * MAXCONS;
-
-static void none_saver(int blank) { }
-static void (*current_saver)(int blank) = none_saver;
-static void (*default_saver)(int blank) = none_saver;
- int (*sc_user_ioctl)(dev_t dev, int cmd, caddr_t data,
- int flag, struct proc *p) = NULL;
-
-static int sticky_splash = FALSE;
-
-/* OS specific stuff */
-#ifdef not_yet_done
-#define VIRTUAL_TTY(x) (sccons[x] = ttymalloc(sccons[x]))
-struct CONSOLE_TTY (sccons[MAXCONS] = ttymalloc(sccons[MAXCONS]))
-struct MOUSE_TTY (sccons[MAXCONS+1] = ttymalloc(sccons[MAXCONS+1]))
-struct tty *sccons[MAXCONS+2];
-#else
-#define VIRTUAL_TTY(x) &sccons[x]
-#define CONSOLE_TTY &sccons[MAXCONS]
-#define MOUSE_TTY &sccons[MAXCONS+1]
-static struct tty sccons[MAXCONS+2];
-#endif
-#define SC_MOUSE 128
-#define SC_CONSOLE 255
-u_int32_t Crtat;
-static const int nsccons = MAXCONS+2;
-
-#define WRAPHIST(scp, pointer, offset)\
- ((scp->history) + ((((pointer) - (scp->history)) + (scp->history_size)\
- + (offset)) % (scp->history_size)))
-#define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG)
-
-/* prototypes */
-static int scattach(device_t dev);
-static int scparam(struct tty *tp, struct termios *t);
-static int scprobe(device_t dev);
-static void scintr(void *arg);
-static int scvidprobe(int unit, int flags);
-static int sckbdprobe(int unit, int flags);
-static void scstart(struct tty *tp);
-static void scmousestart(struct tty *tp);
-static void scinit(void);
-static void scshutdown(int howto, void *arg);
-static u_int scgetc(u_int flags);
-#define SCGETC_CN 1
-#define SCGETC_NONBLOCK 2
-static void sccnupdate(scr_stat *scp);
-static scr_stat *alloc_scp(void);
-static void init_scp(scr_stat *scp);
-static void sc_bcopy(scr_stat *scp, u_short *p, int from, int to, int mark);
-static int get_scr_num(void);
-static timeout_t scrn_timer;
-static void scrn_update(scr_stat *scp, int show_cursor);
-static void scrn_saver(void (*saver)(int), int blank);
-static void stop_scrn_saver(void (*saver)(int));
-static int wait_scrn_saver_stop(void);
-static int switch_scr(scr_stat *scp, u_int next_scr);
-static void exchange_scr(void);
-static void scan_esc(scr_stat *scp, u_char c);
-static void ansi_put(scr_stat *scp, u_char *buf, int len);
-static void draw_cursor_image(scr_stat *scp);
-static void remove_cursor_image(scr_stat *scp);
-static void move_crsr(scr_stat *scp, int x, int y);
-static u_char *get_fstr(u_int c, u_int *len);
-static void history_to_screen(scr_stat *scp);
-static int history_up_line(scr_stat *scp);
-static int history_down_line(scr_stat *scp);
-static int mask2attr(struct term_stat *term);
-static void set_keyboard(int command, int data);
-static void update_leds(int which);
-static void set_destructive_cursor(scr_stat *scp);
-static void set_mouse_pos(scr_stat *scp);
-static int skip_spc_right(scr_stat *scp, u_short *p);
-static int skip_spc_left(scr_stat *scp, u_short *p);
-static void mouse_cut(scr_stat *scp);
-static void mouse_cut_start(scr_stat *scp);
-static void mouse_cut_end(scr_stat *scp);
-static void mouse_cut_word(scr_stat *scp);
-static void mouse_cut_line(scr_stat *scp);
-static void mouse_cut_extend(scr_stat *scp);
-static void mouse_paste(scr_stat *scp);
-static void draw_mouse_image(scr_stat *scp);
-static void remove_mouse_image(scr_stat *scp);
-static void draw_cutmarking(scr_stat *scp);
-static void remove_cutmarking(scr_stat *scp);
-static void do_bell(scr_stat *scp, int pitch, int duration);
-static timeout_t blink_screen;
-#ifdef SC_SPLASH_SCREEN
-static void scsplash_init(scr_stat *scp);
-static void scsplash_saver(int show);
-#define scsplash_stick(stick) (sticky_splash = (stick))
-#else
-#define scsplash_stick(stick)
-#endif
-
-static device_method_t sc_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, scprobe),
- DEVMETHOD(device_attach, scattach),
-
- { 0, 0 }
-};
-
-static driver_t sc_driver = {
- "sc",
- sc_methods,
- DRIVER_TYPE_TTY,
- 1, /* XXX */
-};
-
-static devclass_t sc_devclass;
-
-static d_open_t scopen;
-static d_close_t scclose;
-static d_read_t scread;
-static d_write_t scwrite;
-static d_ioctl_t scioctl;
- d_devtotty_t scdevtotty;
-static d_mmap_t scmmap;
-
-#define CDEV_MAJOR 12
-static struct cdevsw sc_cdevsw = {
- scopen, scclose, scread, scwrite,
- scioctl, nullstop, noreset, scdevtotty,
- ttpoll, scmmap, nostrategy, "sc",
- NULL, -1, nodump, nopsize,
- D_TTY,
-};
-
-/*
- * These functions need to be before calls to them so they can be inlined.
- */
-
-#ifdef __alpha__
-
-static void fillw(int pat, void *base, size_t cnt)
-{
- u_short *sp = base;
- while (cnt--)
- *sp++ = pat;
-}
-
-static void fillw_io(int pat, u_int32_t base, size_t cnt)
-{
- while (cnt--) {
- writew(base, pat);
- base += 2;
- }
-}
-
-#endif
-
-static void
-draw_cursor_image(scr_stat *scp)
-{
- u_short cursor_image;
- u_int32_t ptr = Crtat + 2*(scp->cursor_pos - scp->scr_buf);
- u_short prev_image;
-
- if (ISPIXELSC(scp)) {
- sc_bcopy(scp, scp->scr_buf, scp->cursor_pos - scp->scr_buf,
- scp->cursor_pos - scp->scr_buf, 1);
- return;
- }
-
- /* do we have a destructive cursor ? */
- if (flags & CHAR_CURSOR) {
- prev_image = scp->cursor_saveunder;
- cursor_image = readw(ptr) & 0x00ff;
- if (cursor_image == DEAD_CHAR)
- cursor_image = prev_image & 0x00ff;
- cursor_image |= *(scp->cursor_pos) & 0xff00;
- scp->cursor_saveunder = cursor_image;
- /* update the cursor bitmap if the char under the cursor has changed */
- if (prev_image != cursor_image)
- set_destructive_cursor(scp);
- /* modify cursor_image */
- if (!(flags & BLINK_CURSOR)||((flags & BLINK_CURSOR)&&(blinkrate & 4))){
- /*
- * When the mouse pointer is at the same position as the cursor,
- * the cursor bitmap needs to be updated even if the char under
- * the cursor hasn't changed, because the mouse pionter may
- * have moved by a few dots within the cursor cel.
- */
- if ((prev_image == cursor_image)
- && (cursor_image != *(scp->cursor_pos)))
- set_destructive_cursor(scp);
- cursor_image &= 0xff00;
- cursor_image |= DEAD_CHAR;
- }
- } else {
- cursor_image = (readw(ptr) & 0x00ff) | *(scp->cursor_pos) & 0xff00;
- scp->cursor_saveunder = cursor_image;
- if (!(flags & BLINK_CURSOR)||((flags & BLINK_CURSOR)&&(blinkrate & 4))){
- if ((cursor_image & 0x7000) == 0x7000) {
- cursor_image &= 0x8fff;
- if(!(cursor_image & 0x0700))
- cursor_image |= 0x0700;
- } else {
- cursor_image |= 0x7000;
- if ((cursor_image & 0x0700) == 0x0700)
- cursor_image &= 0xf0ff;
- }
- }
- }
- writew(ptr, cursor_image);
-}
-
-static void
-remove_cursor_image(scr_stat *scp)
-{
- if (ISPIXELSC(scp))
- sc_bcopy(scp, scp->scr_buf, scp->cursor_oldpos - scp->scr_buf,
- scp->cursor_oldpos - scp->scr_buf, 0);
- else
- writew(Crtat + 2*(scp->cursor_oldpos - scp->scr_buf), scp->cursor_saveunder);
-}
-
-static void
-move_crsr(scr_stat *scp, int x, int y)
-{
- if (x < 0)
- x = 0;
- if (y < 0)
- y = 0;
- if (x >= scp->xsize)
- x = scp->xsize-1;
- if (y >= scp->ysize)
- y = scp->ysize-1;
- scp->xpos = x;
- scp->ypos = y;
- scp->cursor_pos = scp->scr_buf + scp->ypos * scp->xsize + scp->xpos;
-}
-
-static int
-scprobe(device_t dev)
-{
- if (!scvidprobe(device_get_unit(dev), isa_get_flags(dev))) {
- if (bootverbose)
- printf("sc%d: no video adapter is found.\n", device_get_unit(dev));
- return (ENXIO);
- }
- (*biosvidsw.diag)(bootverbose);
-#if defined(VESA) && defined(VM86)
- if (vesa_load())
- return ENXIO;
- (*biosvidsw.diag)(bootverbose);
-#endif
-
- sc_port = isa_get_port(dev);
- isa_set_portsize(dev, IO_KBDSIZE);
- if (sckbdprobe(device_get_unit(dev), isa_get_flags(dev)))
- return 0;
- else
- return ((isa_get_flags(dev) & DETECT_KBD) ? ENXIO : 0);
-}
-
-/* probe video adapters, return TRUE if found */
-static int
-scvidprobe(int unit, int flags)
-{
- video_adapter_t *adp;
-
- /* do this test only once */
- if (init_done != COLD)
- return (crtc_type != -1);
-
- if ((*biosvidsw.init)() <= 0)
- return FALSE;
- if ((adp = (*biosvidsw.adapter)(V_ADP_PRIMARY)) == NULL)
- return FALSE;
-
- crtc_type = adp->va_type;
- crtc_vga = (crtc_type == KD_VGA);
- crtc_addr = adp->va_crtc_addr;
- Crtat = adp->va_window;
- adp_flags = adp->va_flags;
- initial_video_mode = adp->va_initial_mode;
- bios_video_mode = adp->va_initial_bios_mode;
-
- return TRUE;
-}
-
-/* probe the keyboard, return TRUE if found */
-static int
-sckbdprobe(int unit, int flags)
-{
- int codeset;
- int c = -1;
- int m;
- int res, id;
-
- sc_kbdc = kbdc_open(sc_port);
-
- if (!kbdc_lock(sc_kbdc, TRUE)) {
- /* driver error? */
- printf("sc%d: unable to lock the controller.\n", unit);
- return ((flags & DETECT_KBD) ? FALSE : TRUE);
- }
-
- /* discard anything left after UserConfig */
- empty_both_buffers(sc_kbdc, 10);
-
- /* save the current keyboard controller command byte */
- m = kbdc_get_device_mask(sc_kbdc) & ~KBD_KBD_CONTROL_BITS;
- c = get_controller_command_byte(sc_kbdc);
- if (c == -1) {
- /* CONTROLLER ERROR */
- printf("sc%d: unable to get the current command byte value.\n", unit);
- goto fail;
- }
- if (bootverbose)
- printf("sc%d: the current keyboard controller command byte %04x\n",
- unit, c);
-#if 0
- /* override the keyboard lock switch */
- c |= KBD_OVERRIDE_KBD_LOCK;
-#endif
-
- /*
- * The keyboard may have been screwed up by the boot block.
- * We may just be able to recover from error by testing the controller
- * and the keyboard port. The controller command byte needs to be saved
- * before this recovery operation, as some controllers seem to set
- * the command byte to particular values.
- */
- test_controller(sc_kbdc);
- test_kbd_port(sc_kbdc);
-
- /* enable the keyboard port, but disable the keyboard intr. */
- if (!set_controller_command_byte(sc_kbdc,
- KBD_KBD_CONTROL_BITS,
- KBD_ENABLE_KBD_PORT | KBD_DISABLE_KBD_INT)) {
- /* CONTROLLER ERROR
- * there is very little we can do...
- */
- printf("sc%d: unable to set the command byte.\n", unit);
- goto fail;
- }
-
- /*
- * Check if we have an XT keyboard before we attempt to reset it.
- * The procedure assumes that the keyboard and the controller have
- * been set up properly by BIOS and have not been messed up
- * during the boot process.
- */
- codeset = -1;
- if (flags & XT_KEYBD)
- /* the user says there is a XT keyboard */
- codeset = 1;
-#ifdef DETECT_XT_KEYBOARD
- else if ((c & KBD_TRANSLATION) == 0) {
- /* SET_SCANCODE_SET is not always supported; ignore error */
- if (send_kbd_command_and_data(sc_kbdc, KBDC_SET_SCANCODE_SET, 0)
- == KBD_ACK)
- codeset = read_kbd_data(sc_kbdc);
- }
- if (bootverbose)
- printf("sc%d: keyboard scancode set %d\n", unit, codeset);
-#endif /* DETECT_XT_KEYBOARD */
-
- if (flags & KBD_NORESET) {
- write_kbd_command(sc_kbdc, KBDC_ECHO);
- if (read_kbd_data(sc_kbdc) != KBD_ECHO) {
- empty_both_buffers(sc_kbdc, 10);
- test_controller(sc_kbdc);
- test_kbd_port(sc_kbdc);
- if (bootverbose)
- printf("sc%d: failed to get response from the keyboard.\n",
- unit);
- goto fail;
- }
- } else {
- /* reset keyboard hardware */
- if (!reset_kbd(sc_kbdc)) {
- /* KEYBOARD ERROR
- * Keyboard reset may fail either because the keyboard doen't
- * exist, or because the keyboard doesn't pass the self-test,
- * or the keyboard controller on the motherboard and the keyboard
- * somehow fail to shake hands. It is just possible, particularly
- * in the last case, that the keyoard controller may be left
- * in a hung state. test_controller() and test_kbd_port() appear
- * to bring the keyboard controller back (I don't know why and
- * how, though.)
- */
- empty_both_buffers(sc_kbdc, 10);
- test_controller(sc_kbdc);
- test_kbd_port(sc_kbdc);
- /* We could disable the keyboard port and interrupt... but,
- * the keyboard may still exist (see above).
- */
- if (bootverbose)
- printf("sc%d: failed to reset the keyboard.\n", unit);
- goto fail;
- }
- }
-
- /*
- * Allow us to set the XT_KEYBD flag in UserConfig so that keyboards
- * such as those on the IBM ThinkPad laptop computers can be used
- * with the standard console driver.
- */
- if (codeset == 1) {
- if (send_kbd_command_and_data(
- sc_kbdc, KBDC_SET_SCANCODE_SET, codeset) == KBD_ACK) {
- /* XT kbd doesn't need scan code translation */
- c &= ~KBD_TRANSLATION;
- } else {
- /* KEYBOARD ERROR
- * The XT kbd isn't usable unless the proper scan code set
- * is selected.
- */
- printf("sc%d: unable to set the XT keyboard mode.\n", unit);
- goto fail;
- }
- }
-
-#ifdef __alpha__
- if (send_kbd_command_and_data(
- sc_kbdc, KBDC_SET_SCANCODE_SET, 2) != KBD_ACK) {
- printf("sc%d: can't set translation.\n", unit);
-
- }
- c |= KBD_TRANSLATION;
-#endif
-
- /* enable the keyboard port and intr. */
- if (!set_controller_command_byte(sc_kbdc,
- KBD_KBD_CONTROL_BITS | KBD_TRANSLATION | KBD_OVERRIDE_KBD_LOCK,
- (c & (KBD_TRANSLATION | KBD_OVERRIDE_KBD_LOCK))
- | KBD_ENABLE_KBD_PORT | KBD_ENABLE_KBD_INT)) {
- /* CONTROLLER ERROR
- * This is serious; we are left with the disabled keyboard intr.
- */
- printf("sc%d: unable to enable the keyboard port and intr.\n", unit);
- goto fail;
- }
-
- /* Get the ID of the keyboard, if any */
- empty_kbd_buffer(sc_kbdc, 5);
- res = send_kbd_command(sc_kbdc, KBDC_SEND_DEV_ID);
- if (res == KBD_ACK) {
- /* 10ms delay */
- DELAY(10000);
- id = (read_kbd_data(sc_kbdc) << 8) | read_kbd_data(sc_kbdc);
- if (bootverbose)
- printf("sc%d: keyboard device ID: %04x\n", unit, id);
- }
-
- kbdc_set_device_mask(sc_kbdc, m | KBD_KBD_CONTROL_BITS),
- kbdc_lock(sc_kbdc, FALSE);
- return TRUE;
-
-fail:
- if (c != -1)
- /* try to restore the command byte as before, if possible */
- set_controller_command_byte(sc_kbdc, 0xff, c);
- kbdc_set_device_mask(sc_kbdc,
- (flags & DETECT_KBD) ? m : m | KBD_KBD_CONTROL_BITS);
- kbdc_lock(sc_kbdc, FALSE);
- return FALSE;
-}
-
-#if NAPM > 0
-static int
-scresume(void *dummy)
-{
- shfts = ctls = alts = agrs = metas = accents = 0;
- return 0;
-}
-#endif
-
-static int
-scattach(device_t dev)
-{
- scr_stat *scp;
- video_info_t info;
- dev_t cdev = makedev(CDEV_MAJOR, 0);
-#ifdef DEVFS
- int vc;
-#endif
- void *ih;
- struct resource *res;
- int zero = 0;
-
- scinit();
- flags = isa_get_flags(dev);
- if (!ISFONTAVAIL(adp_flags))
- flags &= ~CHAR_CURSOR;
-
- scp = console[0];
-
- /* copy temporary buffer to final buffer */
- scp->scr_buf = NULL;
- sc_alloc_scr_buffer(scp, FALSE, FALSE);
- bcopy(sc_buffer, scp->scr_buf, scp->xsize*scp->ysize*sizeof(u_short));
-
- /* cut buffer is available only when the mouse pointer is used */
- if (ISMOUSEAVAIL(adp_flags))
- sc_alloc_cut_buffer(scp, FALSE);
-
- /* initialize history buffer & pointers */
- sc_alloc_history_buffer(scp, sc_history_size, 0, FALSE);
-
-#if defined(VESA) && defined(VM86)
- if ((flags & VESA800X600)
- && ((*biosvidsw.get_info)(scp->adp, M_VESA_800x600, &info) == 0)) {
- sc_set_graphics_mode(scp, NULL, M_VESA_800x600);
- sc_set_pixel_mode(scp, NULL, COL, ROW, 16);
- initial_video_mode = M_VESA_800x600;
- }
-#endif /* VESA && VM86 */
-
- /* initialize cursor stuff */
- if (!ISGRAPHSC(scp))
- draw_cursor_image(scp);
-
- /* get screen update going */
- scrn_timer((void *)TRUE);
-
- update_leds(scp->status);
-
- printf("sc%d: ", device_get_unit(dev));
- switch(crtc_type) {
- case KD_VGA:
- printf("VGA %s", (adp_flags & V_ADP_COLOR) ? "color" : "mono");
- break;
- case KD_EGA:
- printf("EGA %s", (adp_flags & V_ADP_COLOR) ? "color" : "mono");
- break;
- case KD_CGA:
- printf("CGA");
- break;
- case KD_MONO:
- case KD_HERCULES:
- default:
- printf("MDA/Hercules");
- break;
- }
- printf(" <%d virtual consoles, flags=0x%x>\n", MAXCONS, flags);
-
-#if NAPM > 0
- scp->r_hook.ah_fun = scresume;
- scp->r_hook.ah_arg = NULL;
- scp->r_hook.ah_name = "system keyboard";
- scp->r_hook.ah_order = APM_MID_ORDER;
- apm_hook_establish(APM_HOOK_RESUME , &scp->r_hook);
-#endif
-
- at_shutdown(scshutdown, NULL, SHUTDOWN_PRE_SYNC);
-
-#ifdef DEVFS
- for (vc = 0; vc < MAXCONS; vc++)
- sc_devfs_token[vc] = devfs_add_devswf(&sc_cdevsw, vc, DV_CHR,
- UID_ROOT, GID_WHEEL, 0600, "ttyv%r", vc);
- sc_mouse_devfs_token = devfs_add_devswf(&sc_cdevsw, SC_MOUSE, DV_CHR,
- UID_ROOT, GID_WHEEL, 0600, "sysmouse");
- sc_console_devfs_token = devfs_add_devswf(&sc_cdevsw, SC_CONSOLE, DV_CHR,
- UID_ROOT, GID_WHEEL, 0600, "consolectl");
-#endif
-
- res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, 0ul, ~0ul, 1,
- RF_SHAREABLE | RF_ACTIVE);
- BUS_SETUP_INTR(device_get_parent(dev), dev, res, scintr, 0,
- &ih);
-
- return 0;
-}
-
-struct tty
-*scdevtotty(dev_t dev)
-{
- int unit = minor(dev);
-
- if (init_done == COLD)
- return(NULL);
- if (unit == SC_CONSOLE)
- return CONSOLE_TTY;
- if (unit == SC_MOUSE)
- return MOUSE_TTY;
- if (unit >= MAXCONS || unit < 0)
- return(NULL);
- return VIRTUAL_TTY(unit);
-}
-
-int
-scopen(dev_t dev, int flag, int mode, struct proc *p)
-{
- struct tty *tp = scdevtotty(dev);
-
- if (!tp)
- return(ENXIO);
-
- tp->t_oproc = (minor(dev) == SC_MOUSE) ? scmousestart : scstart;
- tp->t_param = scparam;
- tp->t_dev = dev;
- if (!(tp->t_state & TS_ISOPEN)) {
- ttychars(tp);
- /* Use the current setting of the <-- key as default VERASE. */
- /* If the Delete key is preferable, an stty is necessary */
- tp->t_cc[VERASE] = key_map.key[0x0e].map[0];
- tp->t_iflag = TTYDEF_IFLAG;
- tp->t_oflag = TTYDEF_OFLAG;
- tp->t_cflag = TTYDEF_CFLAG;
- tp->t_lflag = TTYDEF_LFLAG;
- tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
- scparam(tp, &tp->t_termios);
- (*linesw[tp->t_line].l_modem)(tp, 1);
- if (minor(dev) == SC_MOUSE)
- mouse_level = 0; /* XXX */
- }
- else
- if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0)
- return(EBUSY);
- if (minor(dev) < MAXCONS && !console[minor(dev)]) {
- console[minor(dev)] = alloc_scp();
- if (ISGRAPHSC(console[minor(dev)]))
- sc_set_pixel_mode(console[minor(dev)], NULL, COL, ROW, 16);
- }
- if (minor(dev)<MAXCONS && !tp->t_winsize.ws_col && !tp->t_winsize.ws_row) {
- tp->t_winsize.ws_col = console[minor(dev)]->xsize;
- tp->t_winsize.ws_row = console[minor(dev)]->ysize;
- }
- return ((*linesw[tp->t_line].l_open)(dev, tp));
-}
-
-int
-scclose(dev_t dev, int flag, int mode, struct proc *p)
-{
- struct tty *tp = scdevtotty(dev);
- struct scr_stat *scp;
-
- if (!tp)
- return(ENXIO);
- if (minor(dev) < MAXCONS) {
- scp = sc_get_scr_stat(tp->t_dev);
- if (scp->status & SWITCH_WAIT_ACQ)
- wakeup((caddr_t)&scp->smode);
-#if not_yet_done
- if (scp == &main_console) {
- scp->pid = 0;
- scp->proc = NULL;
- scp->smode.mode = VT_AUTO;
- }
- else {
- free(scp->scr_buf, M_DEVBUF);
- if (scp->history != NULL) {
- free(scp->history, M_DEVBUF);
- if (scp->history_size / scp->xsize
- > imax(sc_history_size, scp->ysize))
- extra_history_size += scp->history_size / scp->xsize
- - imax(sc_history_size, scp->ysize);
- }
- free(scp, M_DEVBUF);
- console[minor(dev)] = NULL;
- }
-#else
- scp->pid = 0;
- scp->proc = NULL;
- scp->smode.mode = VT_AUTO;
-#endif
- }
- spltty();
- (*linesw[tp->t_line].l_close)(tp, flag);
- ttyclose(tp);
- spl0();
- return(0);
-}
-
-int
-scread(dev_t dev, struct uio *uio, int flag)
-{
- struct tty *tp = scdevtotty(dev);
-
- if (!tp)
- return(ENXIO);
- return((*linesw[tp->t_line].l_read)(tp, uio, flag));
-}
-
-int
-scwrite(dev_t dev, struct uio *uio, int flag)
-{
- struct tty *tp = scdevtotty(dev);
-
- if (!tp)
- return(ENXIO);
- return((*linesw[tp->t_line].l_write)(tp, uio, flag));
-}
-
-static void
-scintr(void *arg)
-{
- static struct tty *cur_tty;
- int c, len;
- u_char *cp;
-
- /*
- * Loop while there is still input to get from the keyboard.
- * I don't think this is nessesary, and it doesn't fix
- * the Xaccel-2.1 keyboard hang, but it can't hurt. XXX
- */
- while ((c = scgetc(SCGETC_NONBLOCK)) != NOKEY) {
-
- cur_tty = VIRTUAL_TTY(get_scr_num());
- if (!(cur_tty->t_state & TS_ISOPEN))
- if (!((cur_tty = CONSOLE_TTY)->t_state & TS_ISOPEN))
- continue;
-
- switch (c & 0xff00) {
- case 0x0000: /* normal key */
- (*linesw[cur_tty->t_line].l_rint)(c & 0xFF, cur_tty);
- break;
- case FKEY: /* function key, return string */
- if (cp = get_fstr((u_int)c, (u_int *)&len)) {
- while (len-- > 0)
- (*linesw[cur_tty->t_line].l_rint)(*cp++ & 0xFF, cur_tty);
- }
- break;
- case MKEY: /* meta is active, prepend ESC */
- (*linesw[cur_tty->t_line].l_rint)(0x1b, cur_tty);
- (*linesw[cur_tty->t_line].l_rint)(c & 0xFF, cur_tty);
- break;
- case BKEY: /* backtab fixed sequence (esc [ Z) */
- (*linesw[cur_tty->t_line].l_rint)(0x1b, cur_tty);
- (*linesw[cur_tty->t_line].l_rint)('[', cur_tty);
- (*linesw[cur_tty->t_line].l_rint)('Z', cur_tty);
- break;
- }
- }
-
-#if 0
- if (cur_console->status & MOUSE_ENABLED) {
- cur_console->status &= ~MOUSE_VISIBLE;
- remove_mouse_image(cur_console);
- }
-#else
- if (cur_console->status & MOUSE_VISIBLE) {
- remove_mouse_image(cur_console);
- cur_console->status &= ~MOUSE_VISIBLE;
- }
-#endif
-}
-
-static int
-scparam(struct tty *tp, struct termios *t)
-{
- tp->t_ispeed = t->c_ispeed;
- tp->t_ospeed = t->c_ospeed;
- tp->t_cflag = t->c_cflag;
- return 0;
-}
-
-int
-scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
-{
- int error;
- u_int i;
- struct tty *tp;
- scr_stat *scp;
- video_adapter_t *adp;
- int s;
-
- tp = scdevtotty(dev);
- if (!tp)
- return ENXIO;
- scp = sc_get_scr_stat(tp->t_dev);
-
- /* If there is a user_ioctl function call that first */
- if (sc_user_ioctl) {
- error = (*sc_user_ioctl)(dev, cmd, data, flag, p);
- if (error != ENOIOCTL)
- return error;
- }
-
- error = sc_vid_ioctl(tp, cmd, data, flag, p);
- if (error != ENOIOCTL)
- return error;
-
- switch (cmd) { /* process console hardware related ioctl's */
-
- case GIO_ATTR: /* get current attributes */
- *(int*)data = (scp->term.cur_attr >> 8) & 0xFF;
- return 0;
-
- case GIO_COLOR: /* is this a color console ? */
- *(int *)data = (adp_flags & V_ADP_COLOR) ? 1 : 0;
- return 0;
-
- case CONS_BLANKTIME: /* set screen saver timeout (0 = no saver) */
- if (*(int *)data < 0 || *(int *)data > MAX_BLANKTIME)
- return EINVAL;
- s = spltty();
- scrn_blank_time = *(int *)data;
- run_scrn_saver = (scrn_blank_time != 0);
- splx(s);
- return 0;
-
- case CONS_CURSORTYPE: /* set cursor type blink/noblink */
- if ((*(int*)data) & 0x01)
- flags |= BLINK_CURSOR;
- else
- flags &= ~BLINK_CURSOR;
- if ((*(int*)data) & 0x02) {
- if (!ISFONTAVAIL(get_adapter(scp)->va_flags))
- return ENXIO;
- flags |= CHAR_CURSOR;
- } else
- flags &= ~CHAR_CURSOR;
- /*
- * The cursor shape is global property; all virtual consoles
- * are affected. Update the cursor in the current console...
- */
- if (!ISGRAPHSC(cur_console)) {
- remove_cursor_image(cur_console);
- if (flags & CHAR_CURSOR)
- set_destructive_cursor(cur_console);
- draw_cursor_image(cur_console);
- }
- return 0;
-
- case CONS_BELLTYPE: /* set bell type sound/visual */
- if ((*(int *)data) & 0x01)
- flags |= VISUAL_BELL;
- else
- flags &= ~VISUAL_BELL;
- if ((*(int *)data) & 0x02)
- flags |= QUIET_BELL;
- else
- flags &= ~QUIET_BELL;
- return 0;
-
- case CONS_HISTORY: /* set history size */
- if (*(int *)data > 0) {
- int lines; /* buffer size to allocate */
- int lines0; /* current buffer size */
-
- lines = imax(*(int *)data, scp->ysize);
- lines0 = (scp->history != NULL) ?
- scp->history_size / scp->xsize : scp->ysize;
- if (lines0 > imax(sc_history_size, scp->ysize))
- i = lines0 - imax(sc_history_size, scp->ysize);
- else
- i = 0;
- /*
- * syscons unconditionally allocates buffers upto SC_HISTORY_SIZE
- * lines or scp->ysize lines, whichever is larger. A value
- * greater than that is allowed, subject to extra_history_size.
- */
- if (lines > imax(sc_history_size, scp->ysize))
- if (lines - imax(sc_history_size, scp->ysize) >
- extra_history_size + i)
- return EINVAL;
- if (cur_console->status & BUFFER_SAVED)
- return EBUSY;
- sc_alloc_history_buffer(scp, lines, i, TRUE);
- return 0;
- }
- else
- return EINVAL;
-
- case CONS_MOUSECTL: /* control mouse arrow */
- case OLD_CONS_MOUSECTL:
- {
- /* MOUSE_BUTTON?DOWN -> MOUSE_MSC_BUTTON?UP */
- static butmap[8] = {
- MOUSE_MSC_BUTTON1UP | MOUSE_MSC_BUTTON2UP
- | MOUSE_MSC_BUTTON3UP,
- MOUSE_MSC_BUTTON2UP | MOUSE_MSC_BUTTON3UP,
- MOUSE_MSC_BUTTON1UP | MOUSE_MSC_BUTTON3UP,
- MOUSE_MSC_BUTTON3UP,
- MOUSE_MSC_BUTTON1UP | MOUSE_MSC_BUTTON2UP,
- MOUSE_MSC_BUTTON2UP,
- MOUSE_MSC_BUTTON1UP,
- 0,
- };
- mouse_info_t *mouse = (mouse_info_t*)data;
- mouse_info_t buf;
-
- /* FIXME: */
- if (!ISMOUSEAVAIL(get_adapter(scp)->va_flags))
- return ENODEV;
-
- if (cmd == OLD_CONS_MOUSECTL) {
- static unsigned char swapb[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
- old_mouse_info_t *old_mouse = (old_mouse_info_t *)data;
-
- mouse = &buf;
- mouse->operation = old_mouse->operation;
- switch (mouse->operation) {
- case MOUSE_MODE:
- mouse->u.mode = old_mouse->u.mode;
- break;
- case MOUSE_SHOW:
- case MOUSE_HIDE:
- break;
- case MOUSE_MOVEABS:
- case MOUSE_MOVEREL:
- case MOUSE_ACTION:
- mouse->u.data.x = old_mouse->u.data.x;
- mouse->u.data.y = old_mouse->u.data.y;
- mouse->u.data.z = 0;
- mouse->u.data.buttons = swapb[old_mouse->u.data.buttons & 0x7];
- break;
- case MOUSE_GETINFO:
- old_mouse->u.data.x = scp->mouse_xpos;
- old_mouse->u.data.y = scp->mouse_ypos;
- old_mouse->u.data.buttons = swapb[scp->mouse_buttons & 0x7];
- break;
- default:
- return EINVAL;
- }
- }
-
- switch (mouse->operation) {
- case MOUSE_MODE:
- if (ISSIGVALID(mouse->u.mode.signal)) {
- scp->mouse_signal = mouse->u.mode.signal;
- scp->mouse_proc = p;
- scp->mouse_pid = p->p_pid;
- }
- else {
- scp->mouse_signal = 0;
- scp->mouse_proc = NULL;
- scp->mouse_pid = 0;
- }
- return 0;
-
- case MOUSE_SHOW:
- if (ISTEXTSC(scp) && !(scp->status & MOUSE_ENABLED)) {
- scp->status |= (MOUSE_ENABLED | MOUSE_VISIBLE);
- scp->mouse_oldpos = scp->mouse_pos;
- mark_all(scp);
- return 0;
- }
- else
- return EINVAL;
- break;
-
- case MOUSE_HIDE:
- if (ISTEXTSC(scp) && (scp->status & MOUSE_ENABLED)) {
- scp->status &= ~(MOUSE_ENABLED | MOUSE_VISIBLE);
- mark_all(scp);
- return 0;
- }
- else
- return EINVAL;
- break;
-
- case MOUSE_MOVEABS:
- scp->mouse_xpos = mouse->u.data.x;
- scp->mouse_ypos = mouse->u.data.y;
- set_mouse_pos(scp);
- break;
-
- case MOUSE_MOVEREL:
- scp->mouse_xpos += mouse->u.data.x;
- scp->mouse_ypos += mouse->u.data.y;
- set_mouse_pos(scp);
- break;
-
- case MOUSE_GETINFO:
- mouse->u.data.x = scp->mouse_xpos;
- mouse->u.data.y = scp->mouse_ypos;
- mouse->u.data.z = 0;
- mouse->u.data.buttons = scp->mouse_buttons;
- return 0;
-
- case MOUSE_ACTION:
- case MOUSE_MOTION_EVENT:
- /* this should maybe only be settable from /dev/consolectl SOS */
- /* send out mouse event on /dev/sysmouse */
-
- mouse_status.dx += mouse->u.data.x;
- mouse_status.dy += mouse->u.data.y;
- mouse_status.dz += mouse->u.data.z;
- if (mouse->operation == MOUSE_ACTION)
- mouse_status.button = mouse->u.data.buttons;
- mouse_status.flags |=
- ((mouse->u.data.x || mouse->u.data.y || mouse->u.data.z) ?
- MOUSE_POSCHANGED : 0)
- | (mouse_status.obutton ^ mouse_status.button);
- if (mouse_status.flags == 0)
- return 0;
-
- if (ISTEXTSC(cur_console) && (cur_console->status & MOUSE_ENABLED))
- cur_console->status |= MOUSE_VISIBLE;
-
- if ((MOUSE_TTY)->t_state & TS_ISOPEN) {
- u_char buf[MOUSE_SYS_PACKETSIZE];
- int j;
-
- /* the first five bytes are compatible with MouseSystems' */
- buf[0] = MOUSE_MSC_SYNC
- | butmap[mouse_status.button & MOUSE_STDBUTTONS];
- j = imax(imin(mouse->u.data.x, 255), -256);
- buf[1] = j >> 1;
- buf[3] = j - buf[1];
- j = -imax(imin(mouse->u.data.y, 255), -256);
- buf[2] = j >> 1;
- buf[4] = j - buf[2];
- for (j = 0; j < MOUSE_MSC_PACKETSIZE; j++)
- (*linesw[(MOUSE_TTY)->t_line].l_rint)(buf[j],MOUSE_TTY);
- if (mouse_level >= 1) { /* extended part */
- j = imax(imin(mouse->u.data.z, 127), -128);
- buf[5] = (j >> 1) & 0x7f;
- buf[6] = (j - (j >> 1)) & 0x7f;
- /* buttons 4-10 */
- buf[7] = (~mouse_status.button >> 3) & 0x7f;
- for (j = MOUSE_MSC_PACKETSIZE;
- j < MOUSE_SYS_PACKETSIZE; j++)
- (*linesw[(MOUSE_TTY)->t_line].l_rint)(buf[j],MOUSE_TTY);
- }
- }
-
- if (cur_console->mouse_signal) {
- cur_console->mouse_buttons = mouse->u.data.buttons;
- /* has controlling process died? */
- if (cur_console->mouse_proc &&
- (cur_console->mouse_proc != pfind(cur_console->mouse_pid))){
- cur_console->mouse_signal = 0;
- cur_console->mouse_proc = NULL;
- cur_console->mouse_pid = 0;
- }
- else
- psignal(cur_console->mouse_proc, cur_console->mouse_signal);
- }
- else if (mouse->operation == MOUSE_ACTION && cut_buffer != NULL) {
- /* process button presses */
- if ((cur_console->mouse_buttons ^ mouse->u.data.buttons) &&
- ISTEXTSC(cur_console)) {
- cur_console->mouse_buttons = mouse->u.data.buttons;
- if (cur_console->mouse_buttons & MOUSE_BUTTON1DOWN)
- mouse_cut_start(cur_console);
- else
- mouse_cut_end(cur_console);
- if (cur_console->mouse_buttons & MOUSE_BUTTON2DOWN ||
- cur_console->mouse_buttons & MOUSE_BUTTON3DOWN)
- mouse_paste(cur_console);
- }
- }
-
- if (mouse->u.data.x != 0 || mouse->u.data.y != 0) {
- cur_console->mouse_xpos += mouse->u.data.x;
- cur_console->mouse_ypos += mouse->u.data.y;
- set_mouse_pos(cur_console);
- }
-
- break;
-
- case MOUSE_BUTTON_EVENT:
- if ((mouse->u.event.id & MOUSE_BUTTONS) == 0)
- return EINVAL;
- if (mouse->u.event.value < 0)
- return EINVAL;
-
- if (mouse->u.event.value > 0) {
- cur_console->mouse_buttons |= mouse->u.event.id;
- mouse_status.button |= mouse->u.event.id;
- } else {
- cur_console->mouse_buttons &= ~mouse->u.event.id;
- mouse_status.button &= ~mouse->u.event.id;
- }
- mouse_status.flags |= mouse_status.obutton ^ mouse_status.button;
- if (mouse_status.flags == 0)
- return 0;
-
- if (ISTEXTSC(cur_console) && (cur_console->status & MOUSE_ENABLED))
- cur_console->status |= MOUSE_VISIBLE;
-
- if ((MOUSE_TTY)->t_state & TS_ISOPEN) {
- u_char buf[8];
- int i;
-
- buf[0] = MOUSE_MSC_SYNC
- | butmap[mouse_status.button & MOUSE_STDBUTTONS];
- buf[7] = (~mouse_status.button >> 3) & 0x7f;
- buf[1] = buf[2] = buf[3] = buf[4] = buf[5] = buf[6] = 0;
- for (i = 0;
- i < ((mouse_level >= 1) ? MOUSE_SYS_PACKETSIZE
- : MOUSE_MSC_PACKETSIZE); i++)
- (*linesw[(MOUSE_TTY)->t_line].l_rint)(buf[i],MOUSE_TTY);
- }
-
- if (cur_console->mouse_signal) {
- if (cur_console->mouse_proc &&
- (cur_console->mouse_proc != pfind(cur_console->mouse_pid))){
- cur_console->mouse_signal = 0;
- cur_console->mouse_proc = NULL;
- cur_console->mouse_pid = 0;
- }
- else
- psignal(cur_console->mouse_proc, cur_console->mouse_signal);
- break;
- }
-
- if (!ISTEXTSC(cur_console) || (cut_buffer == NULL))
- break;
-
- switch (mouse->u.event.id) {
- case MOUSE_BUTTON1DOWN:
- switch (mouse->u.event.value % 4) {
- case 0: /* up */
- mouse_cut_end(cur_console);
- break;
- case 1:
- mouse_cut_start(cur_console);
- break;
- case 2:
- mouse_cut_word(cur_console);
- break;
- case 3:
- mouse_cut_line(cur_console);
- break;
- }
- break;
- case MOUSE_BUTTON2DOWN:
- switch (mouse->u.event.value) {
- case 0: /* up */
- break;
- default:
- mouse_paste(cur_console);
- break;
- }
- break;
- case MOUSE_BUTTON3DOWN:
- switch (mouse->u.event.value) {
- case 0: /* up */
- if (!(cur_console->mouse_buttons & MOUSE_BUTTON1DOWN))
- mouse_cut_end(cur_console);
- break;
- default:
- mouse_cut_extend(cur_console);
- break;
- }
- break;
- }
- break;
-
- default:
- return EINVAL;
- }
- /* make screensaver happy */
- scsplash_stick(FALSE);
- run_scrn_saver = FALSE;
- return 0;
- }
-
- /* MOUSE_XXX: /dev/sysmouse ioctls */
- case MOUSE_GETHWINFO: /* get device information */
- {
- mousehw_t *hw = (mousehw_t *)data;
-
- if (tp != MOUSE_TTY)
- return ENOTTY;
- hw->buttons = 10; /* XXX unknown */
- hw->iftype = MOUSE_IF_SYSMOUSE;
- hw->type = MOUSE_MOUSE;
- hw->model = MOUSE_MODEL_GENERIC;
- hw->hwid = 0;
- return 0;
- }
-
- case MOUSE_GETMODE: /* get protocol/mode */
- {
- mousemode_t *mode = (mousemode_t *)data;
-
- if (tp != MOUSE_TTY)
- return ENOTTY;
- mode->level = mouse_level;
- switch (mode->level) {
- case 0:
- /* at this level, sysmouse emulates MouseSystems protocol */
- mode->protocol = MOUSE_PROTO_MSC;
- mode->rate = -1; /* unknown */
- mode->resolution = -1; /* unknown */
- mode->accelfactor = 0; /* disabled */
- mode->packetsize = MOUSE_MSC_PACKETSIZE;
- mode->syncmask[0] = MOUSE_MSC_SYNCMASK;
- mode->syncmask[1] = MOUSE_MSC_SYNC;
- break;
-
- case 1:
- /* at this level, sysmouse uses its own protocol */
- mode->protocol = MOUSE_PROTO_SYSMOUSE;
- mode->rate = -1;
- mode->resolution = -1;
- mode->accelfactor = 0;
- mode->packetsize = MOUSE_SYS_PACKETSIZE;
- mode->syncmask[0] = MOUSE_SYS_SYNCMASK;
- mode->syncmask[1] = MOUSE_SYS_SYNC;
- break;
- }
- return 0;
- }
-
- case MOUSE_SETMODE: /* set protocol/mode */
- {
- mousemode_t *mode = (mousemode_t *)data;
-
- if (tp != MOUSE_TTY)
- return ENOTTY;
- if ((mode->level < 0) || (mode->level > 1))
- return EINVAL;
- mouse_level = mode->level;
- return 0;
- }
-
- case MOUSE_GETLEVEL: /* get operation level */
- if (tp != MOUSE_TTY)
- return ENOTTY;
- *(int *)data = mouse_level;
- return 0;
-
- case MOUSE_SETLEVEL: /* set operation level */
- if (tp != MOUSE_TTY)
- return ENOTTY;
- if ((*(int *)data < 0) || (*(int *)data > 1))
- return EINVAL;
- mouse_level = *(int *)data;
- return 0;
-
- case MOUSE_GETSTATUS: /* get accumulated mouse events */
- if (tp != MOUSE_TTY)
- return ENOTTY;
- s = spltty();
- *(mousestatus_t *)data = mouse_status;
- mouse_status.flags = 0;
- mouse_status.obutton = mouse_status.button;
- mouse_status.dx = 0;
- mouse_status.dy = 0;
- mouse_status.dz = 0;
- splx(s);
- return 0;
-
-#if notyet
- case MOUSE_GETVARS: /* get internal mouse variables */
- case MOUSE_SETVARS: /* set internal mouse variables */
- if (tp != MOUSE_TTY)
- return ENOTTY;
- return ENODEV;
-#endif
-
- case MOUSE_READSTATE: /* read status from the device */
- case MOUSE_READDATA: /* read data from the device */
- if (tp != MOUSE_TTY)
- return ENOTTY;
- return ENODEV;
-
- case CONS_GETINFO: /* get current (virtual) console info */
- {
- vid_info_t *ptr = (vid_info_t*)data;
- if (ptr->size == sizeof(struct vid_info)) {
- 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_color & 0x0f00)>>8;
- ptr->mv_norm.back = (scp->term.std_color & 0xf000)>>12;
- ptr->mv_rev.fore = (scp->term.rev_color & 0x0f00)>>8;
- ptr->mv_rev.back = (scp->term.rev_color & 0xf000)>>12;
- ptr->mv_grfc.fore = 0; /* not supported */
- ptr->mv_grfc.back = 0; /* not supported */
- ptr->mv_ovscan = scp->border;
- ptr->mk_keylock = scp->status & LOCK_KEY_MASK;
- return 0;
- }
- return EINVAL;
- }
-
- case CONS_GETVERS: /* get version number */
- *(int*)data = 0x200; /* version 2.0 */
- return 0;
-
- case CONS_IDLE: /* see if the screen has been idle */
- /*
- * When the screen is in the GRAPHICS_MODE or UNKNOWN_MODE,
- * the user process may have been writing something on the
- * screen and syscons is not aware of it. Declare the screen
- * is NOT idle if it is in one of these modes. But there is
- * an exception to it; if a screen saver is running in the
- * graphics mode in the current screen, we should say that the
- * screen has been idle.
- */
- *(int *)data = scrn_idle
- && (!ISGRAPHSC(cur_console)
- || (cur_console->status & SAVER_RUNNING));
- return 0;
-
- case CONS_SAVERMODE: /* set saver mode */
- switch(*(int *)data) {
- case CONS_USR_SAVER:
- /* if a LKM screen saver is running, stop it first. */
- scsplash_stick(FALSE);
- saver_mode = *(int *)data;
- s = spltty();
- if ((error = wait_scrn_saver_stop())) {
- splx(s);
- return error;
- }
- scp->status |= SAVER_RUNNING;
- scsplash_stick(TRUE);
- splx(s);
- break;
- case CONS_LKM_SAVER:
- s = spltty();
- if ((saver_mode == CONS_USR_SAVER) && (scp->status & SAVER_RUNNING))
- scp->status &= ~SAVER_RUNNING;
- saver_mode = *(int *)data;
- splx(s);
- break;
- default:
- return EINVAL;
- }
- return 0;
-
- case CONS_SAVERSTART: /* immediately start/stop the screen saver */
- /*
- * Note that this ioctl does not guarantee the screen saver
- * actually starts or stops. It merely attempts to do so...
- */
- s = spltty();
- run_scrn_saver = (*(int *)data != 0);
- if (run_scrn_saver)
- scrn_time_stamp -= scrn_blank_time;
- splx(s);
- return 0;
-
- case VT_SETMODE: /* set screen switcher mode */
- {
- struct vt_mode *mode;
-
- mode = (struct vt_mode *)data;
- if (ISSIGVALID(mode->relsig) && ISSIGVALID(mode->acqsig) &&
- ISSIGVALID(mode->frsig)) {
- bcopy(data, &scp->smode, sizeof(struct vt_mode));
- if (scp->smode.mode == VT_PROCESS) {
- scp->proc = p;
- scp->pid = scp->proc->p_pid;
- }
- return 0;
- } else
- return EINVAL;
- }
-
- case VT_GETMODE: /* get screen switcher mode */
- bcopy(&scp->smode, data, sizeof(struct vt_mode));
- return 0;
-
- case VT_RELDISP: /* screen switcher ioctl */
- switch(*(int *)data) {
- case VT_FALSE: /* user refuses to release screen, abort */
- if (scp == old_scp && (scp->status & SWITCH_WAIT_REL)) {
- old_scp->status &= ~SWITCH_WAIT_REL;
- switch_in_progress = FALSE;
- return 0;
- }
- return EINVAL;
-
- case VT_TRUE: /* user has released screen, go on */
- if (scp == old_scp && (scp->status & SWITCH_WAIT_REL)) {
- scp->status &= ~SWITCH_WAIT_REL;
- exchange_scr();
- if (new_scp->smode.mode == VT_PROCESS) {
- new_scp->status |= SWITCH_WAIT_ACQ;
- psignal(new_scp->proc, new_scp->smode.acqsig);
- }
- else
- switch_in_progress = FALSE;
- return 0;
- }
- return EINVAL;
-
- case VT_ACKACQ: /* acquire acknowledged, switch completed */
- if (scp == new_scp && (scp->status & SWITCH_WAIT_ACQ)) {
- scp->status &= ~SWITCH_WAIT_ACQ;
- switch_in_progress = FALSE;
- return 0;
- }
- return EINVAL;
-
- default:
- return EINVAL;
- }
- /* NOT REACHED */
-
- case VT_OPENQRY: /* return free virtual console */
- for (i = 0; i < MAXCONS; i++) {
- tp = VIRTUAL_TTY(i);
- if (!(tp->t_state & TS_ISOPEN)) {
- *(int *)data = i + 1;
- return 0;
- }
- }
- return EINVAL;
-
- case VT_ACTIVATE: /* switch to screen *data */
- return switch_scr(scp, *(int *)data - 1);
-
- case VT_WAITACTIVE: /* wait for switch to occur */
- if (*(int *)data > MAXCONS || *(int *)data < 0)
- return EINVAL;
- if (minor(dev) == *(int *)data - 1)
- return 0;
- if (*(int *)data == 0) {
- if (scp == cur_console)
- return 0;
- }
- else
- scp = console[*(int *)data - 1];
- while ((error=tsleep((caddr_t)&scp->smode, PZERO|PCATCH,
- "waitvt", 0)) == ERESTART) ;
- return error;
-
- case VT_GETACTIVE:
- *(int *)data = get_scr_num()+1;
- return 0;
-
- case KDENABIO: /* allow io operations */
- error = suser(p->p_ucred, &p->p_acflag);
- if (error != 0)
- return error;
- if (securelevel > 0)
- return EPERM;
-#ifdef __i386__
- p->p_md.md_regs->tf_eflags |= PSL_IOPL;
-#endif
- return 0;
-
- case KDDISABIO: /* disallow io operations (default) */
-#ifdef __i386__
- p->p_md.md_regs->tf_eflags &= ~PSL_IOPL;
-#endif
- return 0;
-
- case KDSKBSTATE: /* set keyboard state (locks) */
- if (*(int *)data & ~LOCK_KEY_MASK)
- return EINVAL;
- scp->status &= ~LOCK_KEY_MASK;
- scp->status |= *(int *)data;
- if (scp == cur_console)
- update_leds(scp->status);
- return 0;
-
- case KDGKBSTATE: /* get keyboard state (locks) */
- *(int *)data = scp->status & LOCK_KEY_MASK;
- return 0;
-
- case KDSETRAD: /* set keyboard repeat & delay rates */
- if (*(int *)data & ~0x7f)
- return EINVAL;
- if (sc_kbdc != NULL)
- set_keyboard(KBDC_SET_TYPEMATIC, *(int *)data);
- return 0;
-
- case KDSKBMODE: /* set keyboard mode */
- switch (*(int *)data) {
- case K_RAW: /* switch to RAW scancode mode */
- scp->status &= ~KBD_CODE_MODE;
- scp->status |= KBD_RAW_MODE;
- return 0;
-
- case K_CODE: /* switch to CODE mode */
- scp->status &= ~KBD_RAW_MODE;
- scp->status |= KBD_CODE_MODE;
- return 0;
-
- case K_XLATE: /* switch to XLT ascii mode */
- if (scp == cur_console && scp->status & KBD_RAW_MODE)
- shfts = ctls = alts = agrs = metas = accents = 0;
- scp->status &= ~(KBD_RAW_MODE | KBD_CODE_MODE);
- return 0;
- default:
- return EINVAL;
- }
- /* NOT REACHED */
-
- case KDGKBMODE: /* get keyboard mode */
- *(int *)data = (scp->status & KBD_RAW_MODE) ? K_RAW :
- ((scp->status & KBD_CODE_MODE) ? K_CODE : K_XLATE);
- return 0;
-
- case KDMKTONE: /* sound the bell */
- if (*(int*)data)
- do_bell(scp, (*(int*)data)&0xffff,
- (((*(int*)data)>>16)&0xffff)*hz/1000);
- else
- do_bell(scp, scp->bell_pitch, scp->bell_duration);
- return 0;
-
- case KIOCSOUND: /* make tone (*data) hz */
- if (scp == cur_console) {
-#if 0
- if (*(int*)data) {
- int pitch = timer_freq / *(int*)data;
-
- /* set command for counter 2, 2 byte write */
- if (acquire_timer2(TIMER_16BIT|TIMER_SQWAVE))
- return EBUSY;
-
- /* set pitch */
- outb(TIMER_CNTR2, pitch);
- outb(TIMER_CNTR2, (pitch>>8));
-
- /* enable counter 2 output to speaker */
- outb(IO_PPI, inb(IO_PPI) | 3);
- }
- else {
- /* disable counter 2 output to speaker */
- outb(IO_PPI, inb(IO_PPI) & 0xFC);
- release_timer2();
- }
-#endif
- }
- return 0;
-
- case KDGKBTYPE: /* get keyboard type */
- *(int *)data = 0; /* type not known (yet) */
- return 0;
-
- case KDSETLED: /* set keyboard LED status */
- if (*(int *)data & ~LED_MASK)
- return EINVAL;
- scp->status &= ~LED_MASK;
- scp->status |= *(int *)data;
- if (scp == cur_console)
- update_leds(scp->status);
- return 0;
-
- case KDGETLED: /* get keyboard LED status */
- *(int *)data = scp->status & LED_MASK;
- return 0;
-
- case GETFKEY: /* get functionkey string */
- if (*(u_short*)data < n_fkey_tab) {
- fkeyarg_t *ptr = (fkeyarg_t*)data;
- bcopy(&fkey_tab[ptr->keynum].str, ptr->keydef,
- fkey_tab[ptr->keynum].len);
- ptr->flen = fkey_tab[ptr->keynum].len;
- return 0;
- }
- else
- return EINVAL;
-
- case SETFKEY: /* set functionkey string */
- if (*(u_short*)data < n_fkey_tab) {
- fkeyarg_t *ptr = (fkeyarg_t*)data;
- bcopy(ptr->keydef, &fkey_tab[ptr->keynum].str,
- min(ptr->flen, MAXFK));
- fkey_tab[ptr->keynum].len = min(ptr->flen, MAXFK);
- return 0;
- }
- else
- return EINVAL;
-
- case GIO_SCRNMAP: /* get output translation table */
- bcopy(&scr_map, data, sizeof(scr_map));
- return 0;
-
- case PIO_SCRNMAP: /* set output translation table */
- bcopy(data, &scr_map, sizeof(scr_map));
- for (i=0; i<sizeof(scr_map); i++)
- scr_rmap[scr_map[i]] = i;
- return 0;
-
- case GIO_KEYMAP: /* get keyboard translation table */
- bcopy(&key_map, data, sizeof(key_map));
- return 0;
-
- case PIO_KEYMAP: /* set keyboard translation table */
- accents = 0;
- bzero(&accent_map, sizeof(accent_map));
- bcopy(data, &key_map, sizeof(key_map));
- return 0;
-
- case GIO_DEADKEYMAP: /* get accent key translation table */
- bcopy(&accent_map, data, sizeof(accent_map));
- return 0;
-
- case PIO_DEADKEYMAP: /* set accent key translation table */
- accents = 0;
- bcopy(data, &accent_map, sizeof(accent_map));
- return 0;
-
- case PIO_FONT8x8: /* set 8x8 dot font */
- if (!ISFONTAVAIL(get_adapter(scp)->va_flags))
- return ENXIO;
- bcopy(data, font_8, 8*256);
- fonts_loaded |= FONT_8;
- /*
- * FONT KLUDGE
- * Always use the font page #0. XXX
- * Don't load if the current font size is not 8x8.
- */
- if (ISTEXTSC(cur_console) && (cur_console->font_size < 14))
- copy_font(cur_console, LOAD, 8, font_8);
- return 0;
-
- case GIO_FONT8x8: /* get 8x8 dot font */
- if (!ISFONTAVAIL(get_adapter(scp)->va_flags))
- return ENXIO;
- if (fonts_loaded & FONT_8) {
- bcopy(font_8, data, 8*256);
- return 0;
- }
- else
- return ENXIO;
-
- case PIO_FONT8x14: /* set 8x14 dot font */
- if (!ISFONTAVAIL(get_adapter(scp)->va_flags))
- return ENXIO;
- bcopy(data, font_14, 14*256);
- fonts_loaded |= FONT_14;
- /*
- * FONT KLUDGE
- * Always use the font page #0. XXX
- * Don't load if the current font size is not 8x14.
- */
- if (ISTEXTSC(cur_console)
- && (cur_console->font_size >= 14) && (cur_console->font_size < 16))
- copy_font(cur_console, LOAD, 14, font_14);
- return 0;
-
- case GIO_FONT8x14: /* get 8x14 dot font */
- if (!ISFONTAVAIL(get_adapter(scp)->va_flags))
- return ENXIO;
- if (fonts_loaded & FONT_14) {
- bcopy(font_14, data, 14*256);
- return 0;
- }
- else
- return ENXIO;
-
- case PIO_FONT8x16: /* set 8x16 dot font */
- if (!ISFONTAVAIL(get_adapter(scp)->va_flags))
- return ENXIO;
- bcopy(data, font_16, 16*256);
- fonts_loaded |= FONT_16;
- /*
- * FONT KLUDGE
- * Always use the font page #0. XXX
- * Don't load if the current font size is not 8x16.
- */
- if (ISTEXTSC(cur_console) && (cur_console->font_size >= 16))
- copy_font(cur_console, LOAD, 16, font_16);
- return 0;
-
- case GIO_FONT8x16: /* get 8x16 dot font */
- if (!ISFONTAVAIL(get_adapter(scp)->va_flags))
- return ENXIO;
- if (fonts_loaded & FONT_16) {
- bcopy(font_16, data, 16*256);
- return 0;
- }
- else
- return ENXIO;
- default:
- break;
- }
-
- error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
- if (error != ENOIOCTL)
- return(error);
- error = ttioctl(tp, cmd, data, flag);
- if (error != ENOIOCTL)
- return(error);
- return(ENOTTY);
-}
-
-static void
-scstart(struct tty *tp)
-{
- struct clist *rbp;
- int s, len;
- u_char buf[PCBURST];
- scr_stat *scp = sc_get_scr_stat(tp->t_dev);
-
- if (scp->status & SLKED || blink_in_progress)
- return; /* XXX who repeats the call when the above flags are cleared? */
- s = spltty();
- if (!(tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP))) {
- tp->t_state |= TS_BUSY;
- rbp = &tp->t_outq;
- while (rbp->c_cc) {
- len = q_to_b(rbp, buf, PCBURST);
- splx(s);
- ansi_put(scp, buf, len);
- s = spltty();
- }
- tp->t_state &= ~TS_BUSY;
- ttwwakeup(tp);
- }
- splx(s);
-}
-
-static void
-scmousestart(struct tty *tp)
-{
- struct clist *rbp;
- int s;
- u_char buf[PCBURST];
-
- s = spltty();
- if (!(tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP))) {
- tp->t_state |= TS_BUSY;
- rbp = &tp->t_outq;
- while (rbp->c_cc) {
- q_to_b(rbp, buf, PCBURST);
- }
- tp->t_state &= ~TS_BUSY;
- ttwwakeup(tp);
- }
- splx(s);
-}
-
-void
-sccnprobe(struct consdev *cp)
-{
-#if 0
- struct isa_device *dvp;
-
- /*
- * Take control if we are the highest priority enabled display device.
- */
- dvp = find_display();
- if (dvp == NULL || dvp->id_driver != &scdriver) {
- cp->cn_pri = CN_DEAD;
- return;
- }
-
- if (!scvidprobe(dvp->id_unit, dvp->id_flags)) {
- cp->cn_pri = CN_DEAD;
- return;
- }
-
- /* initialize required fields */
- cp->cn_dev = makedev(CDEV_MAJOR, SC_CONSOLE);
- cp->cn_pri = CN_INTERNAL;
-
- sc_kbdc = kbdc_open(sc_port);
-#endif
-}
-
-struct consdev sc_cons = {
- NULL, NULL, sccngetc, sccncheckc, sccnputc,
- NULL, makedev(CDEV_MAJOR, 0), CN_NORMAL,
-};
-
-extern struct consdev *cn_tab;
-
-void
-sccnattach(void)
-{
- if (!scvidprobe(0, 0) || !sckbdprobe(0, 0)) {
- return;
- }
-
- sc_kbdc = kbdc_open(sc_port);
- scinit();
-
- cn_tab = &sc_cons;
-}
-
-void
-sccninit(struct consdev *cp)
-{
- scinit();
-}
-
-void
-sccnputc(dev_t dev, int c)
-{
- u_char buf[1];
- int s;
- scr_stat *scp = console[0];
- term_stat save = scp->term;
-
- scp->term = kernel_console;
- current_default = &kernel_default;
- if (scp == cur_console && !ISGRAPHSC(scp))
- remove_cursor_image(scp);
- buf[0] = c;
- ansi_put(scp, buf, 1);
- kernel_console = scp->term;
- current_default = &user_default;
- scp->term = save;
-
- s = spltty(); /* block scintr and scrn_timer */
- sccnupdate(scp);
- splx(s);
-}
-
-int
-sccngetc(dev_t dev)
-{
- int s = spltty(); /* block scintr and scrn_timer while we poll */
- int c;
-
- /*
- * Stop the screen saver and update the screen if necessary.
- * What if we have been running in the screen saver code... XXX
- */
- scsplash_stick(FALSE);
- run_scrn_saver = FALSE;
- sccnupdate(cur_console);
-
- c = scgetc(SCGETC_CN);
- splx(s);
- return(c);
-}
-
-int
-sccncheckc(dev_t dev)
-{
- int s = spltty(); /* block scintr and scrn_timer while we poll */
- int c;
-
- scsplash_stick(FALSE);
- run_scrn_saver = FALSE;
- sccnupdate(cur_console);
-
- c = scgetc(SCGETC_CN | SCGETC_NONBLOCK);
- splx(s);
- return(c == NOKEY ? -1 : c); /* c == -1 can't happen */
-}
-
-static void
-sccnupdate(scr_stat *scp)
-{
- /* this is a cut-down version of scrn_timer()... */
-
- if (font_loading_in_progress)
- return;
-
- if (panicstr || shutdown_in_progress) {
- scsplash_stick(FALSE);
- run_scrn_saver = FALSE;
- } else if (scp != cur_console) {
- return;
- }
-
- if (!run_scrn_saver)
- scrn_idle = FALSE;
- if ((saver_mode != CONS_LKM_SAVER) || !scrn_idle)
- if (scp->status & SAVER_RUNNING)
- stop_scrn_saver(current_saver);
-
- if (scp != cur_console || blink_in_progress || switch_in_progress)
- return;
-
- if (!ISGRAPHSC(scp) && !(scp->status & SAVER_RUNNING))
- scrn_update(scp, TRUE);
-}
-
-scr_stat
-*sc_get_scr_stat(dev_t dev)
-{
- int unit = minor(dev);
-
- if (unit == SC_CONSOLE)
- return console[0];
- if (unit >= MAXCONS || unit < 0)
- return(NULL);
- return console[unit];
-}
-
-static int
-get_scr_num()
-{
- int i = 0;
-
- while ((i < MAXCONS) && (cur_console != console[i]))
- i++;
- return i < MAXCONS ? i : 0;
-}
-
-static void
-scrn_timer(void *arg)
-{
- struct timeval tv;
- scr_stat *scp;
- int s;
-
- /* don't do anything when we are touching font */
- if (font_loading_in_progress) {
- if (arg)
- timeout(scrn_timer, (void *)TRUE, hz / 10);
- return;
- }
- s = spltty();
-
- /*
- * With release 2.1 of the Xaccel server, the keyboard is left
- * hanging pretty often. Apparently an interrupt from the
- * keyboard is lost, and I don't know why (yet).
- * This ugly hack calls scintr if input is ready for the keyboard
- * and conveniently hides the problem. XXX
- */
- /* Try removing anything stuck in the keyboard controller; whether
- * it's a keyboard scan code or mouse data. `scintr()' doesn't
- * read the mouse data directly, but `kbdio' routines will, as a
- * side effect.
- */
- if (kbdc_lock(sc_kbdc, TRUE)) {
- /*
- * We have seen the lock flag is not set. Let's reset the flag early;
- * otherwise `update_led()' failes which may want the lock
- * during `scintr()'.
- */
- kbdc_lock(sc_kbdc, FALSE);
- if (kbdc_data_ready(sc_kbdc))
- scintr(0);
- }
-
- scp = cur_console;
-
- /* should we stop the screen saver? */
- getmicrouptime(&tv);
- if (panicstr || shutdown_in_progress) {
- scsplash_stick(FALSE);
- run_scrn_saver = FALSE;
- }
- if (run_scrn_saver) {
- scrn_idle = (tv.tv_sec > scrn_time_stamp + scrn_blank_time);
- } else {
- scrn_time_stamp = tv.tv_sec;
- scrn_idle = FALSE;
- if (scrn_blank_time > 0)
- run_scrn_saver = TRUE;
- }
- if ((saver_mode != CONS_LKM_SAVER) || !scrn_idle)
- if (scp->status & SAVER_RUNNING)
- stop_scrn_saver(current_saver);
-
- /* should we just return ? */
- if (blink_in_progress || switch_in_progress) {
- if (arg)
- timeout(scrn_timer, (void *)TRUE, hz / 10);
- splx(s);
- return;
- }
-
- /* Update the screen */
- if (!ISGRAPHSC(scp) && !(scp->status & SAVER_RUNNING))
- scrn_update(scp, TRUE);
-
- /* should we activate the screen saver? */
- if ((saver_mode == CONS_LKM_SAVER) && scrn_idle)
- if (!ISGRAPHSC(scp) || (scp->status & SAVER_RUNNING))
- scrn_saver(current_saver, TRUE);
-
- if (arg)
- timeout(scrn_timer, (void *)TRUE, hz / 25);
- splx(s);
-}
-
-static void
-scrn_update(scr_stat *scp, int show_cursor)
-{
- /* update screen image */
- if (scp->start <= scp->end)
- sc_bcopy(scp, scp->scr_buf, scp->start, scp->end, 0);
-
- /* we are not to show the cursor and the mouse pointer... */
- if (!show_cursor) {
- scp->end = 0;
- scp->start = scp->xsize*scp->ysize - 1;
- return;
- }
-
- /* update "pseudo" mouse pointer image */
- if (scp->status & MOUSE_VISIBLE) {
- /* did mouse move since last time ? */
- if (scp->status & MOUSE_MOVED) {
- /* do we need to remove old mouse pointer image ? */
- if (scp->mouse_cut_start != NULL ||
- (scp->mouse_pos-scp->scr_buf) <= scp->start ||
- (scp->mouse_pos+scp->xsize + 1 - scp->scr_buf) >= scp->end) {
- remove_mouse_image(scp);
- }
- scp->status &= ~MOUSE_MOVED;
- draw_mouse_image(scp);
- }
- else {
- /* mouse didn't move, has it been overwritten ? */
- if ((scp->mouse_pos+scp->xsize + 1 - scp->scr_buf) >= scp->start &&
- (scp->mouse_pos - scp->scr_buf) <= scp->end) {
- draw_mouse_image(scp);
- }
- }
- }
-
- /* update cursor image */
- if (scp->status & CURSOR_ENABLED) {
- /* did cursor move since last time ? */
- if (scp->cursor_pos != scp->cursor_oldpos) {
- /* do we need to remove old cursor image ? */
- if ((scp->cursor_oldpos - scp->scr_buf) < scp->start ||
- ((scp->cursor_oldpos - scp->scr_buf) > scp->end)) {
- remove_cursor_image(scp);
- }
- scp->cursor_oldpos = scp->cursor_pos;
- draw_cursor_image(scp);
- }
- else {
- /* cursor didn't move, has it been overwritten ? */
- if (scp->cursor_pos - scp->scr_buf >= scp->start &&
- scp->cursor_pos - scp->scr_buf <= scp->end) {
- draw_cursor_image(scp);
- } else {
- /* if its a blinking cursor, we may have to update it */
- if (flags & BLINK_CURSOR)
- draw_cursor_image(scp);
- }
- }
- blinkrate++;
- }
-
- if (scp->mouse_cut_start != NULL)
- draw_cutmarking(scp);
-
- scp->end = 0;
- scp->start = scp->xsize*scp->ysize - 1;
-}
-
-int
-add_scrn_saver(void (*this_saver)(int))
-{
-#ifdef SC_SPLASH_SCREEN
- if (current_saver == scsplash) {
- scsplash_stick(FALSE);
- stop_scrn_saver(scsplash);
- }
-#endif
-
- if (current_saver != default_saver)
- return EBUSY;
- run_scrn_saver = FALSE;
- saver_mode = CONS_LKM_SAVER;
- current_saver = this_saver;
- return 0;
-}
-
-int
-remove_scrn_saver(void (*this_saver)(int))
-{
- if (current_saver != this_saver)
- return EINVAL;
-
- /*
- * In order to prevent `current_saver' from being called by
- * the timeout routine `scrn_timer()' while we manipulate
- * the saver list, we shall set `current_saver' to `none_saver'
- * before stopping the current saver, rather than blocking by `splXX()'.
- */
- current_saver = none_saver;
- if (scrn_blanked > 0)
- stop_scrn_saver(this_saver);
-
- if (scrn_blanked > 0)
- return EBUSY; /* XXX */
-
- current_saver = default_saver;
- return 0;
-}
-
-static void
-scrn_saver(void (*saver)(int), int blank)
-{
- static int busy = FALSE;
-
- if (busy)
- return;
- busy = TRUE;
- (*saver)(blank);
- busy = FALSE;
-}
-
-static void
-stop_scrn_saver(void (*saver)(int))
-{
- scrn_saver(saver, FALSE);
- run_scrn_saver = FALSE;
- /* the screen saver may have chosen not to stop after all... */
- if (scrn_blanked > 0)
- return;
-
- mark_all(cur_console);
- if (delayed_next_scr)
- switch_scr(cur_console, delayed_next_scr - 1);
- wakeup((caddr_t)&scrn_blanked);
-}
-
-static int
-wait_scrn_saver_stop(void)
-{
- int error = 0;
-
- while (scrn_blanked > 0) {
- run_scrn_saver = FALSE;
- error = tsleep((caddr_t)&scrn_blanked, PZERO | PCATCH, "scrsav", 0);
- run_scrn_saver = FALSE;
- if (error != ERESTART)
- break;
- }
- return error;
-}
-
-void
-sc_clear_screen(scr_stat *scp)
-{
- move_crsr(scp, 0, 0);
- scp->cursor_oldpos = scp->cursor_pos;
- fillw(scp->term.cur_color | scr_map[0x20], scp->scr_buf,
- scp->xsize * scp->ysize);
- mark_all(scp);
- remove_cutmarking(scp);
-}
-
-static int
-switch_scr(scr_stat *scp, u_int next_scr)
-{
- /* delay switch if actively updating screen */
- if (scrn_blanked > 0 || write_in_progress || blink_in_progress) {
- scsplash_stick(FALSE);
- run_scrn_saver = FALSE;
- delayed_next_scr = next_scr+1;
- return 0;
- }
-
- if (switch_in_progress && (cur_console->proc != pfind(cur_console->pid)))
- switch_in_progress = FALSE;
-
- if (next_scr >= MAXCONS || switch_in_progress ||
- (cur_console->smode.mode == VT_AUTO && ISGRAPHSC(cur_console))) {
- do_bell(scp, 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)) {
- do_bell(scp, BELL_PITCH, BELL_DURATION);
- return EINVAL;
- }
- }
-
- switch_in_progress = TRUE;
- old_scp = cur_console;
- new_scp = console[next_scr];
- wakeup((caddr_t)&new_scp->smode);
- if (new_scp == old_scp) {
- switch_in_progress = FALSE;
- delayed_next_scr = FALSE;
- return 0;
- }
-
- /* has controlling process died? */
- if (old_scp->proc && (old_scp->proc != pfind(old_scp->pid)))
- old_scp->smode.mode = VT_AUTO;
- if (new_scp->proc && (new_scp->proc != pfind(new_scp->pid)))
- new_scp->smode.mode = VT_AUTO;
-
- /* check the modes and switch appropriately */
- if (old_scp->smode.mode == VT_PROCESS) {
- old_scp->status |= SWITCH_WAIT_REL;
- psignal(old_scp->proc, old_scp->smode.relsig);
- }
- else {
- exchange_scr();
- if (new_scp->smode.mode == VT_PROCESS) {
- new_scp->status |= SWITCH_WAIT_ACQ;
- psignal(new_scp->proc, new_scp->smode.acqsig);
- }
- else
- switch_in_progress = FALSE;
- }
- return 0;
-}
-
-static void
-exchange_scr(void)
-{
- move_crsr(old_scp, old_scp->xpos, old_scp->ypos);
- cur_console = new_scp;
- if (old_scp->mode != new_scp->mode || ISUNKNOWNSC(old_scp)) {
- if (adp_flags & V_ADP_MODECHANGE)
- set_mode(new_scp);
- }
- move_crsr(new_scp, new_scp->xpos, new_scp->ypos);
- if (ISTEXTSC(new_scp) && (flags & CHAR_CURSOR))
- set_destructive_cursor(new_scp);
- if (ISGRAPHSC(old_scp))
- load_palette(new_scp, palette);
- if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE ||
- old_scp->status & KBD_CODE_MODE || new_scp->status & KBD_CODE_MODE)
- shfts = ctls = alts = agrs = metas = accents = 0;
- set_border(new_scp, new_scp->border);
- update_leds(new_scp->status);
- delayed_next_scr = FALSE;
- mark_all(new_scp);
-
- /* FIXME: the screen size may be larger than a 64K segment. */
- if (ISPIXELSC(new_scp))
- memset_io(Crtat, 0, new_scp->xpixel*new_scp->ypixel/8);
-}
-
-static void
-scan_esc(scr_stat *scp, u_char c)
-{
- static u_char ansi_col[16] =
- {0, 4, 2, 6, 1, 5, 3, 7, 8, 12, 10, 14, 9, 13, 11, 15};
- int i, n;
- u_short *src, *dst, count;
-
- if (scp->term.esc == 1) { /* seen ESC */
- switch (c) {
-
- case '7': /* Save cursor position */
- scp->saved_xpos = scp->xpos;
- scp->saved_ypos = scp->ypos;
- break;
-
- case '8': /* Restore saved cursor position */
- if (scp->saved_xpos >= 0 && scp->saved_ypos >= 0)
- move_crsr(scp, scp->saved_xpos, scp->saved_ypos);
- break;
-
- case '[': /* Start ESC [ sequence */
- scp->term.esc = 2;
- 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->ypos > 0)
- move_crsr(scp, scp->xpos, scp->ypos - 1);
- else {
- bcopy(scp->scr_buf, scp->scr_buf + scp->xsize,
- (scp->ysize - 1) * scp->xsize * sizeof(u_short));
- fillw(scp->term.cur_color | scr_map[0x20],
- scp->scr_buf, scp->xsize);
- mark_all(scp);
- }
- break;
-#if notyet
- case 'Q':
- scp->term.esc = 4;
- return;
-#endif
- case 'c': /* Clear screen & home */
- sc_clear_screen(scp);
- break;
-
- case '(': /* iso-2022: designate 94 character set to G0 */
- scp->term.esc = 5;
- return;
- }
- }
- else if (scp->term.esc == 2) { /* seen ESC [ */
- if (c >= '0' && c <= '9') {
- 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.param[scp->term.num_param] *= 10;
- scp->term.param[scp->term.num_param] += c - '0';
- return;
- }
- }
- scp->term.num_param = scp->term.last_param + 1;
- switch (c) {
-
- case ';':
- if (scp->term.num_param < MAX_ESC_PAR)
- return;
- break;
-
- case '=':
- scp->term.esc = 3;
- 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.param[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->xpos, scp->ypos - n);
- break;
-
- case 'B': /* down n rows */
- 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.param[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->xpos + n, scp->ypos);
- break;
-
- case 'D': /* left n columns */
- 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.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.param[0]; if (n < 1) n = 1;
- move_crsr(scp, 0, scp->ypos - n);
- break;
-
- case 'f': /* Cursor move */
- case 'H':
- if (scp->term.num_param == 0)
- move_crsr(scp, 0, 0);
- 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.num_param == 0)
- n = 0;
- else
- n = scp->term.param[0];
- switch (n) {
- case 0: /* clear form cursor to end of display */
- fillw(scp->term.cur_color | scr_map[0x20],
- scp->cursor_pos,
- scp->scr_buf + scp->xsize * scp->ysize - scp->cursor_pos);
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
- mark_for_update(scp, scp->xsize * scp->ysize - 1);
- remove_cutmarking(scp);
- break;
- case 1: /* clear from beginning of display to cursor */
- fillw(scp->term.cur_color | scr_map[0x20],
- scp->scr_buf,
- scp->cursor_pos - scp->scr_buf);
- mark_for_update(scp, 0);
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
- remove_cutmarking(scp);
- break;
- case 2: /* clear entire display */
- fillw(scp->term.cur_color | scr_map[0x20], scp->scr_buf,
- scp->xsize * scp->ysize);
- mark_all(scp);
- remove_cutmarking(scp);
- break;
- }
- break;
-
- case 'K': /* Clear all or part of line */
- if (scp->term.num_param == 0)
- n = 0;
- else
- n = scp->term.param[0];
- switch (n) {
- case 0: /* clear form cursor to end of line */
- fillw(scp->term.cur_color | scr_map[0x20],
- scp->cursor_pos,
- scp->xsize - scp->xpos);
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf +
- scp->xsize - scp->xpos);
- break;
- case 1: /* clear from beginning of line to cursor */
- fillw(scp->term.cur_color | scr_map[0x20],
- scp->cursor_pos - scp->xpos,
- scp->xpos + 1);
- mark_for_update(scp, scp->ypos * scp->xsize);
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
- break;
- case 2: /* clear entire line */
- fillw(scp->term.cur_color | scr_map[0x20],
- scp->cursor_pos - scp->xpos,
- scp->xsize);
- mark_for_update(scp, scp->ypos * scp->xsize);
- mark_for_update(scp, (scp->ypos + 1) * scp->xsize);
- break;
- }
- break;
-
- case 'L': /* Insert n lines */
- n = scp->term.param[0]; if (n < 1) n = 1;
- if (n > scp->ysize - scp->ypos)
- n = scp->ysize - scp->ypos;
- src = scp->scr_buf + scp->ypos * scp->xsize;
- dst = src + n * scp->xsize;
- count = scp->ysize - (scp->ypos + n);
- bcopy(src, dst, count * scp->xsize * sizeof(u_short));
- fillw(scp->term.cur_color | scr_map[0x20], src,
- n * scp->xsize);
- mark_for_update(scp, scp->ypos * scp->xsize);
- mark_for_update(scp, scp->xsize * scp->ysize - 1);
- break;
-
- case 'M': /* Delete n lines */
- n = scp->term.param[0]; if (n < 1) n = 1;
- if (n > scp->ysize - scp->ypos)
- n = scp->ysize - scp->ypos;
- dst = scp->scr_buf + scp->ypos * scp->xsize;
- src = dst + n * scp->xsize;
- count = scp->ysize - (scp->ypos + n);
- bcopy(src, dst, count * scp->xsize * sizeof(u_short));
- src = dst + count * scp->xsize;
- fillw(scp->term.cur_color | scr_map[0x20], src,
- n * scp->xsize);
- mark_for_update(scp, scp->ypos * scp->xsize);
- mark_for_update(scp, scp->xsize * scp->ysize - 1);
- break;
-
- case 'P': /* Delete n chars */
- n = scp->term.param[0]; if (n < 1) n = 1;
- if (n > scp->xsize - scp->xpos)
- n = scp->xsize - scp->xpos;
- dst = scp->cursor_pos;
- src = dst + n;
- count = scp->xsize - (scp->xpos + n);
- bcopy(src, dst, count * sizeof(u_short));
- src = dst + count;
- fillw(scp->term.cur_color | scr_map[0x20], src, n);
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf + n + count);
- break;
-
- case '@': /* Insert n chars */
- n = scp->term.param[0]; if (n < 1) n = 1;
- if (n > scp->xsize - scp->xpos)
- n = scp->xsize - scp->xpos;
- src = scp->cursor_pos;
- dst = src + n;
- count = scp->xsize - (scp->xpos + n);
- bcopy(src, dst, count * sizeof(u_short));
- fillw(scp->term.cur_color | scr_map[0x20], src, n);
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf + n + count);
- break;
-
- case 'S': /* scroll up n lines */
- n = scp->term.param[0]; if (n < 1) n = 1;
- if (n > scp->ysize)
- n = scp->ysize;
- bcopy(scp->scr_buf + (scp->xsize * n),
- scp->scr_buf,
- scp->xsize * (scp->ysize - n) * sizeof(u_short));
- fillw(scp->term.cur_color | scr_map[0x20],
- scp->scr_buf + scp->xsize * (scp->ysize - n),
- scp->xsize * n);
- mark_all(scp);
- break;
-
- case 'T': /* scroll down n lines */
- n = scp->term.param[0]; if (n < 1) n = 1;
- if (n > scp->ysize)
- n = scp->ysize;
- bcopy(scp->scr_buf,
- scp->scr_buf + (scp->xsize * n),
- scp->xsize * (scp->ysize - n) *
- sizeof(u_short));
- fillw(scp->term.cur_color | scr_map[0x20],
- scp->scr_buf, scp->xsize * n);
- mark_all(scp);
- break;
-
- case 'X': /* erase n characters in line */
- n = scp->term.param[0]; if (n < 1) n = 1;
- if (n > scp->xsize - scp->xpos)
- n = scp->xsize - scp->xpos;
- fillw(scp->term.cur_color | scr_map[0x20],
- scp->cursor_pos, n);
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf + n);
- break;
-
- case 'Z': /* move n tabs backwards */
- 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->ypos);
- break;
-
- case '`': /* move cursor to column n */
- n = scp->term.param[0]; if (n < 1) n = 1;
- move_crsr(scp, n - 1, scp->ypos);
- break;
-
- case 'a': /* move cursor n columns to the right */
- 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.param[0]; if (n < 1) n = 1;
- move_crsr(scp, scp->xpos, n - 1);
- break;
-
- case 'e': /* move cursor n rows down */
- 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.num_param == 0) {
- scp->term.attr_mask = NORMAL_ATTR;
- scp->term.cur_attr =
- scp->term.cur_color = scp->term.std_color;
- break;
- }
- for (i = 0; i < scp->term.num_param; i++) {
- switch (n = scp->term.param[i]) {
- case 0: /* back to normal */
- scp->term.attr_mask = NORMAL_ATTR;
- scp->term.cur_attr =
- scp->term.cur_color = scp->term.std_color;
- break;
- case 1: /* bold */
- scp->term.attr_mask |= BOLD_ATTR;
- scp->term.cur_attr = mask2attr(&scp->term);
- break;
- case 4: /* underline */
- scp->term.attr_mask |= UNDERLINE_ATTR;
- scp->term.cur_attr = mask2attr(&scp->term);
- break;
- case 5: /* blink */
- scp->term.attr_mask |= BLINK_ATTR;
- scp->term.cur_attr = mask2attr(&scp->term);
- break;
- case 7: /* reverse video */
- scp->term.attr_mask |= REVERSE_ATTR;
- scp->term.cur_attr = mask2attr(&scp->term);
- break;
- case 30: case 31: /* set fg color */
- case 32: case 33: case 34:
- case 35: case 36: case 37:
- scp->term.attr_mask |= FOREGROUND_CHANGED;
- scp->term.cur_color =
- (scp->term.cur_color&0xF000) | (ansi_col[(n-30)&7]<<8);
- scp->term.cur_attr = mask2attr(&scp->term);
- break;
- case 40: case 41: /* set bg color */
- case 42: case 43: case 44:
- case 45: case 46: case 47:
- scp->term.attr_mask |= BACKGROUND_CHANGED;
- scp->term.cur_color =
- (scp->term.cur_color&0x0F00) | (ansi_col[(n-40)&7]<<12);
- scp->term.cur_attr = mask2attr(&scp->term);
- break;
- }
- }
- break;
-
- case 's': /* Save cursor position */
- scp->saved_xpos = scp->xpos;
- scp->saved_ypos = scp->ypos;
- break;
-
- case 'u': /* Restore saved cursor position */
- if (scp->saved_xpos >= 0 && scp->saved_ypos >= 0)
- move_crsr(scp, scp->saved_xpos, scp->saved_ypos);
- break;
-
- case 'x':
- if (scp->term.num_param == 0)
- n = 0;
- else
- n = scp->term.param[0];
- switch (n) {
- case 0: /* reset attributes */
- scp->term.attr_mask = NORMAL_ATTR;
- scp->term.cur_attr =
- scp->term.cur_color = scp->term.std_color =
- current_default->std_color;
- scp->term.rev_color = current_default->rev_color;
- break;
- case 1: /* set ansi background */
- scp->term.attr_mask &= ~BACKGROUND_CHANGED;
- scp->term.cur_color = scp->term.std_color =
- (scp->term.std_color & 0x0F00) |
- (ansi_col[(scp->term.param[1])&0x0F]<<12);
- scp->term.cur_attr = mask2attr(&scp->term);
- break;
- case 2: /* set ansi foreground */
- scp->term.attr_mask &= ~FOREGROUND_CHANGED;
- scp->term.cur_color = scp->term.std_color =
- (scp->term.std_color & 0xF000) |
- (ansi_col[(scp->term.param[1])&0x0F]<<8);
- scp->term.cur_attr = mask2attr(&scp->term);
- break;
- case 3: /* set ansi attribute directly */
- scp->term.attr_mask &= ~(FOREGROUND_CHANGED|BACKGROUND_CHANGED);
- scp->term.cur_color = scp->term.std_color =
- (scp->term.param[1]&0xFF)<<8;
- scp->term.cur_attr = mask2attr(&scp->term);
- break;
- case 5: /* set ansi reverse video background */
- scp->term.rev_color =
- (scp->term.rev_color & 0x0F00) |
- (ansi_col[(scp->term.param[1])&0x0F]<<12);
- scp->term.cur_attr = mask2attr(&scp->term);
- break;
- case 6: /* set ansi reverse video foreground */
- scp->term.rev_color =
- (scp->term.rev_color & 0xF000) |
- (ansi_col[(scp->term.param[1])&0x0F]<<8);
- scp->term.cur_attr = mask2attr(&scp->term);
- break;
- case 7: /* set ansi reverse video directly */
- scp->term.rev_color =
- (scp->term.param[1]&0xFF)<<8;
- scp->term.cur_attr = mask2attr(&scp->term);
- break;
- }
- break;
-
- case 'z': /* switch to (virtual) console n */
- if (scp->term.num_param == 1)
- switch_scr(scp, scp->term.param[0]);
- break;
- }
- }
- else if (scp->term.esc == 3) { /* seen ESC [0-9]+ = */
- if (c >= '0' && c <= '9') {
- 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.param[scp->term.num_param] *= 10;
- scp->term.param[scp->term.num_param] += c - '0';
- return;
- }
- }
- scp->term.num_param = scp->term.last_param + 1;
- switch (c) {
-
- case ';':
- if (scp->term.num_param < MAX_ESC_PAR)
- return;
- break;
-
- case 'A': /* set display border color */
- if (scp->term.num_param == 1) {
- scp->border=scp->term.param[0] & 0xff;
- if (scp == cur_console)
- set_border(cur_console, scp->border);
- }
- break;
-
- case 'B': /* set bell pitch and duration */
- if (scp->term.num_param == 2) {
- scp->bell_pitch = scp->term.param[0];
- scp->bell_duration = scp->term.param[1];
- }
- break;
-
- case 'C': /* set cursor type & shape */
- if (scp->term.num_param == 1) {
- if (scp->term.param[0] & 0x01)
- flags |= BLINK_CURSOR;
- else
- flags &= ~BLINK_CURSOR;
- if ((scp->term.param[0] & 0x02)
- && ISFONTAVAIL(get_adapter(scp)->va_flags))
- flags |= CHAR_CURSOR;
- else
- flags &= ~CHAR_CURSOR;
- }
- else if (scp->term.num_param == 2) {
- scp->cursor_start = scp->term.param[0] & 0x1F;
- scp->cursor_end = scp->term.param[1] & 0x1F;
- }
- /*
- * The cursor shape is global property; all virtual consoles
- * are affected. Update the cursor in the current console...
- */
- if (!ISGRAPHSC(cur_console)) {
- remove_cursor_image(cur_console);
- if (flags & CHAR_CURSOR)
- set_destructive_cursor(cur_console);
- draw_cursor_image(cur_console);
- }
- break;
-
- case 'F': /* set ansi foreground */
- if (scp->term.num_param == 1) {
- scp->term.attr_mask &= ~FOREGROUND_CHANGED;
- scp->term.cur_color = scp->term.std_color =
- (scp->term.std_color & 0xF000)
- | ((scp->term.param[0] & 0x0F) << 8);
- scp->term.cur_attr = mask2attr(&scp->term);
- }
- break;
-
- case 'G': /* set ansi background */
- if (scp->term.num_param == 1) {
- scp->term.attr_mask &= ~BACKGROUND_CHANGED;
- scp->term.cur_color = scp->term.std_color =
- (scp->term.std_color & 0x0F00)
- | ((scp->term.param[0] & 0x0F) << 12);
- scp->term.cur_attr = mask2attr(&scp->term);
- }
- break;
-
- case 'H': /* set ansi reverse video foreground */
- if (scp->term.num_param == 1) {
- scp->term.rev_color =
- (scp->term.rev_color & 0xF000)
- | ((scp->term.param[0] & 0x0F) << 8);
- scp->term.cur_attr = mask2attr(&scp->term);
- }
- break;
-
- case 'I': /* set ansi reverse video background */
- if (scp->term.num_param == 1) {
- scp->term.rev_color =
- (scp->term.rev_color & 0x0F00)
- | ((scp->term.param[0] & 0x0F) << 12);
- scp->term.cur_attr = mask2attr(&scp->term);
- }
- break;
- }
- }
-#if notyet
- else if (scp->term.esc == 4) { /* seen ESC Q */
- /* to be filled */
- }
-#endif
- else if (scp->term.esc == 5) { /* seen ESC ( */
- switch (c) {
- case 'B': /* iso-2022: desginate ASCII into G0 */
- break;
- /* other items to be filled */
- default:
- break;
- }
- }
- scp->term.esc = 0;
-}
-
-static void
-ansi_put(scr_stat *scp, u_char *buf, int len)
-{
- u_char *ptr = buf;
-
- /* make screensaver happy */
- if (!sticky_splash && scp == cur_console)
- run_scrn_saver = FALSE;
-
- write_in_progress++;
-outloop:
- if (scp->term.esc) {
- scan_esc(scp, *ptr++);
- len--;
- }
- else if (PRINTABLE(*ptr)) { /* Print only printables */
- int cnt = len <= (scp->xsize-scp->xpos) ? len : (scp->xsize-scp->xpos);
- u_short cur_attr = scp->term.cur_attr;
- u_short *cursor_pos = scp->cursor_pos;
- do {
- /*
- * gcc-2.6.3 generates poor (un)sign extension code. Casting the
- * pointers in the following to volatile should have no effect,
- * but in fact speeds up this inner loop from 26 to 18 cycles
- * (+ cache misses) on i486's.
- */
-#define UCVP(ucp) ((u_char volatile *)(ucp))
- *cursor_pos++ = UCVP(scr_map)[*UCVP(ptr)] | cur_attr;
- ptr++;
- cnt--;
- } while (cnt && PRINTABLE(*ptr));
- len -= (cursor_pos - scp->cursor_pos);
- scp->xpos += (cursor_pos - scp->cursor_pos);
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
- mark_for_update(scp, cursor_pos - scp->scr_buf);
- scp->cursor_pos = cursor_pos;
- if (scp->xpos >= scp->xsize) {
- scp->xpos = 0;
- scp->ypos++;
- }
- }
- else {
- switch(*ptr) {
- case 0x07:
- do_bell(scp, scp->bell_pitch, scp->bell_duration);
- break;
-
- case 0x08: /* non-destructive backspace */
- if (scp->cursor_pos > scp->scr_buf) {
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
- scp->cursor_pos--;
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
- if (scp->xpos > 0)
- scp->xpos--;
- else {
- scp->xpos += scp->xsize - 1;
- scp->ypos--;
- }
- }
- break;
-
- case 0x09: /* non-destructive tab */
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
- scp->cursor_pos += (8 - scp->xpos % 8u);
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
- if ((scp->xpos += (8 - scp->xpos % 8u)) >= scp->xsize) {
- scp->xpos = 0;
- scp->ypos++;
- }
- break;
-
- case 0x0a: /* newline, same pos */
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
- scp->cursor_pos += scp->xsize;
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
- scp->ypos++;
- break;
-
- case 0x0c: /* form feed, clears screen */
- sc_clear_screen(scp);
- break;
-
- case 0x0d: /* return, return to pos 0 */
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
- scp->cursor_pos -= scp->xpos;
- mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
- scp->xpos = 0;
- break;
-
- case 0x1b: /* start escape sequence */
- scp->term.esc = 1;
- scp->term.num_param = 0;
- break;
- }
- ptr++; len--;
- }
- /* do we have to scroll ?? */
- if (scp->cursor_pos >= scp->scr_buf + scp->ysize * scp->xsize) {
- remove_cutmarking(scp);
- if (scp->history) {
- bcopy(scp->scr_buf, scp->history_head,
- scp->xsize * sizeof(u_short));
- scp->history_head += scp->xsize;
- if (scp->history_head + scp->xsize >
- scp->history + scp->history_size)
- scp->history_head = scp->history;
- }
- bcopy(scp->scr_buf + scp->xsize, scp->scr_buf,
- scp->xsize * (scp->ysize - 1) * sizeof(u_short));
- fillw(scp->term.cur_color | scr_map[0x20],
- scp->scr_buf + scp->xsize * (scp->ysize - 1),
- scp->xsize);
- scp->cursor_pos -= scp->xsize;
- scp->ypos--;
- mark_all(scp);
- }
- if (len)
- goto outloop;
- write_in_progress--;
- if (delayed_next_scr)
- switch_scr(scp, delayed_next_scr - 1);
-}
-
-static void
-scinit(void)
-{
- int col;
- int row;
- u_int i;
-
- if (init_done != COLD)
- return;
- init_done = WARM;
-
- /* extract the hardware cursor location and move it out of the way */
- (*biosvidsw.read_hw_cursor)(V_ADP_PRIMARY, &col, &row);
- (*biosvidsw.set_hw_cursor)(V_ADP_PRIMARY, -1, -1);
-
- /* set up the first console */
- current_default = &user_default;
- console[0] = &main_console;
- init_scp(console[0]);
- cur_console = console[0];
-
- /* copy screen to temporary buffer */
- if (ISTEXTSC(console[0]))
- memcpy_fromio(sc_buffer, Crtat,
- console[0]->xsize * console[0]->ysize * sizeof(u_short));
-
- console[0]->scr_buf = console[0]->mouse_pos = console[0]->mouse_oldpos
- = sc_buffer;
- if (col >= console[0]->xsize)
- col = 0;
- if (row >= console[0]->ysize)
- row = console[0]->ysize - 1;
- console[0]->xpos = col;
- console[0]->ypos = row;
- console[0]->cursor_pos = console[0]->cursor_oldpos =
- sc_buffer + row*console[0]->xsize + col;
- console[0]->cursor_saveunder = *console[0]->cursor_pos;
- for (i=1; i<MAXCONS; i++)
- console[i] = NULL;
- kernel_console.esc = 0;
- kernel_console.attr_mask = NORMAL_ATTR;
- kernel_console.cur_attr =
- kernel_console.cur_color = kernel_console.std_color =
- kernel_default.std_color;
- kernel_console.rev_color = kernel_default.rev_color;
-
- /* initialize mapscrn arrays to a one to one map */
- for (i=0; i<sizeof(scr_map); i++) {
- scr_map[i] = scr_rmap[i] = i;
- }
-
- /* Save font and palette */
- if (ISFONTAVAIL(get_adapter(cur_console)->va_flags)) {
- if (fonts_loaded & FONT_16) {
- copy_font(cur_console, LOAD, 16, font_16);
- } else {
- copy_font(cur_console, SAVE, 16, font_16);
- fonts_loaded = FONT_16;
- set_destructive_cursor(cur_console);
- }
- /*
- * FONT KLUDGE
- * Always use the font page #0. XXX
- */
- (*biosvidsw.show_font)(cur_console->adp, 0);
- }
- save_palette(cur_console, palette);
-
-#ifdef SC_SPLASH_SCREEN
- /* put up the splash. */
- scsplash_init(cur_console);
-#endif
-}
-
-static void
-scshutdown(int howto, void *arg)
-{
- scsplash_stick(FALSE);
- run_scrn_saver = FALSE;
- if (!cold && cur_console->smode.mode == VT_AUTO
- && console[0]->smode.mode == VT_AUTO)
- switch_scr(cur_console, 0);
- shutdown_in_progress = TRUE;
-}
-
-int
-sc_clean_up(scr_stat *scp)
-{
- int error;
-
- if ((error = wait_scrn_saver_stop()))
- return error;
- scp->status &= ~MOUSE_VISIBLE;
- remove_cutmarking(scp);
- return 0;
-}
-
-void
-sc_alloc_scr_buffer(scr_stat *scp, int wait, int clear)
-{
- if (scp->scr_buf)
- free(scp->scr_buf, M_DEVBUF);
- scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*sizeof(u_short),
- M_DEVBUF, (wait) ? M_WAITOK : M_NOWAIT);
-
- if (clear) {
- /* clear the screen and move the text cursor to the top-left position */
- sc_clear_screen(scp);
- } else {
- /* retain the current cursor position, but adjust pointers */
- move_crsr(scp, scp->xpos, scp->ypos);
- scp->cursor_oldpos = scp->cursor_pos;
- }
-
- /* move the mouse cursor at the center of the screen */
- sc_move_mouse(scp, scp->xpixel / 2, scp->ypixel / 2);
-}
-
-void
-sc_alloc_cut_buffer(scr_stat *scp, int wait)
-{
- if ((cut_buffer == NULL)
- || (cut_buffer_size < scp->xsize * scp->ysize + 1)) {
- if (cut_buffer != NULL)
- free(cut_buffer, M_DEVBUF);
- cut_buffer_size = scp->xsize * scp->ysize + 1;
- cut_buffer = (u_char *)malloc(cut_buffer_size,
- M_DEVBUF, (wait) ? M_WAITOK : M_NOWAIT);
- if (cut_buffer != NULL)
- cut_buffer[0] = '\0';
- }
-}
-
-void
-sc_alloc_history_buffer(scr_stat *scp, int lines, int extra, int wait)
-{
- u_short *usp;
-
- if (lines < scp->ysize)
- lines = scp->ysize;
-
- usp = scp->history;
- scp->history = NULL;
- if (usp != NULL) {
- free(usp, M_DEVBUF);
- if (extra > 0)
- extra_history_size += extra;
- }
-
- scp->history_size = lines * scp->xsize;
- if (lines > imax(sc_history_size, scp->ysize))
- extra_history_size -= lines - imax(sc_history_size, scp->ysize);
- usp = (u_short *)malloc(scp->history_size * sizeof(u_short),
- M_DEVBUF, (wait) ? M_WAITOK : M_NOWAIT);
- if (usp != NULL)
- bzero(usp, scp->history_size * sizeof(u_short));
- scp->history_head = scp->history_pos = usp;
- scp->history = usp;
-}
-
-static scr_stat
-*alloc_scp()
-{
- scr_stat *scp;
-
- scp = (scr_stat *)malloc(sizeof(scr_stat), M_DEVBUF, M_WAITOK);
- init_scp(scp);
- sc_alloc_scr_buffer(scp, TRUE, TRUE);
- if (ISMOUSEAVAIL(get_adapter(scp)->va_flags))
- sc_alloc_cut_buffer(scp, TRUE);
- sc_alloc_history_buffer(scp, sc_history_size, 0, TRUE);
-/* SOS
- if (get_adapter(scp)->va_flags & V_ADP_MODECHANGE)
- set_mode(scp);
-*/
- sc_clear_screen(scp);
- scp->cursor_saveunder = *scp->cursor_pos;
- return scp;
-}
-
-static void
-init_scp(scr_stat *scp)
-{
- video_info_t info;
-
- scp->adp = V_ADP_PRIMARY;
- (*biosvidsw.get_info)(scp->adp, initial_video_mode, &info);
-
- scp->status = 0;
- scp->mode = scp->initial_mode = initial_video_mode;
- scp->scr_buf = NULL;
- if (info.vi_flags & V_INFO_GRAPHICS) {
- scp->status |= GRAPHICS_MODE;
- scp->xpixel = info.vi_width;
- scp->ypixel = info.vi_height;
- scp->xsize = info.vi_width/8;
- scp->ysize = info.vi_height/info.vi_cheight;
- scp->font_size = FONT_NONE;
- } else {
- scp->xsize = info.vi_width;
- scp->ysize = info.vi_height;
- scp->xpixel = scp->xsize*8;
- scp->ypixel = scp->ysize*info.vi_cheight;
- scp->font_size = info.vi_cheight;
- }
- scp->xoff = scp->yoff = 0;
- scp->xpos = scp->ypos = 0;
- scp->saved_xpos = scp->saved_ypos = -1;
- scp->start = scp->xsize * scp->ysize;
- scp->end = 0;
- scp->term.esc = 0;
- scp->term.attr_mask = NORMAL_ATTR;
- scp->term.cur_attr =
- scp->term.cur_color = scp->term.std_color =
- current_default->std_color;
- scp->term.rev_color = current_default->rev_color;
- scp->border = BG_BLACK;
- scp->cursor_start = readb(0x461);
- scp->cursor_end = readb(0x460);
- scp->mouse_xpos = scp->xsize*8/2;
- scp->mouse_ypos = scp->ysize*scp->font_size/2;
- scp->mouse_cut_start = scp->mouse_cut_end = NULL;
- scp->mouse_signal = 0;
- scp->mouse_pid = 0;
- scp->mouse_proc = NULL;
- scp->bell_pitch = BELL_PITCH;
- scp->bell_duration = BELL_DURATION;
- scp->status = (readb(0x417) & 0x20) ? NLKED : 0;
- scp->status |= CURSOR_ENABLED;
- scp->pid = 0;
- scp->proc = NULL;
- scp->smode.mode = VT_AUTO;
- scp->history_head = scp->history_pos = scp->history = NULL;
- scp->history_size = imax(sc_history_size, scp->ysize) * scp->xsize;
-}
-
-static u_char
-*get_fstr(u_int c, u_int *len)
-{
- u_int i;
-
- if (!(c & FKEY))
- return(NULL);
- i = (c & 0xFF) - F_FN;
- if (i > n_fkey_tab)
- return(NULL);
- *len = fkey_tab[i].len;
- return(fkey_tab[i].str);
-}
-
-static void
-history_to_screen(scr_stat *scp)
-{
- int i;
-
- for (i=0; i<scp->ysize; i++)
- bcopy(scp->history + (((scp->history_pos - scp->history) +
- scp->history_size-((i+1)*scp->xsize))%scp->history_size),
- scp->scr_buf + (scp->xsize * (scp->ysize-1 - i)),
- scp->xsize * sizeof(u_short));
- mark_all(scp);
-}
-
-static int
-history_up_line(scr_stat *scp)
-{
- if (WRAPHIST(scp, scp->history_pos, -(scp->xsize*scp->ysize)) !=
- scp->history_head) {
- scp->history_pos = WRAPHIST(scp, scp->history_pos, -scp->xsize);
- history_to_screen(scp);
- return 0;
- }
- else
- return -1;
-}
-
-static int
-history_down_line(scr_stat *scp)
-{
- if (scp->history_pos != scp->history_head) {
- scp->history_pos = WRAPHIST(scp, scp->history_pos, scp->xsize);
- history_to_screen(scp);
- return 0;
- }
- else
- return -1;
-}
-
-/*
- * scgetc(flags) - get character from keyboard.
- * If flags & SCGETC_CN, then avoid harmful side effects.
- * If flags & SCGETC_NONBLOCK, then wait until a key is pressed, else
- * return NOKEY if there is nothing there.
- */
-static u_int
-scgetc(u_int flags)
-{
- struct key_t *key;
- u_char scancode, keycode;
- u_int state, action;
- int c;
- static u_char esc_flag = 0, compose = 0;
- static u_int chr = 0;
-
-next_code:
- /* first see if there is something in the keyboard port */
- if (flags & SCGETC_NONBLOCK) {
- c = read_kbd_data_no_wait(sc_kbdc);
- if (c == -1)
- return(NOKEY);
- } else {
- do {
- c = read_kbd_data(sc_kbdc);
- } while(c == -1);
- }
- scancode = (u_char)c;
-
- /* make screensaver happy */
- if (!(scancode & 0x80)) {
- scsplash_stick(FALSE);
- run_scrn_saver = FALSE;
- }
-
- if (!(flags & SCGETC_CN)) {
- /* do the /dev/random device a favour */
-#if 0
- add_keyboard_randomness(scancode);
-#endif
-
- if (cur_console->status & KBD_RAW_MODE)
- return scancode;
- }
-
- keycode = scancode & 0x7F;
- switch (esc_flag) {
- case 0x00: /* normal scancode */
- switch(scancode) {
- case 0xB8: /* left alt (compose key) */
- if (compose) {
- compose = 0;
- if (chr > 255) {
- do_bell(cur_console,
- BELL_PITCH, BELL_DURATION);
- chr = 0;
- }
- }
- break;
- case 0x38:
- if (!compose) {
- compose = 1;
- chr = 0;
- }
- break;
- case 0xE0:
- case 0xE1:
- esc_flag = scancode;
- goto next_code;
- }
- break;
- case 0xE0: /* 0xE0 prefix */
- esc_flag = 0;
- switch (keycode) {
- case 0x1C: /* right enter key */
- keycode = 0x59;
- break;
- case 0x1D: /* right ctrl key */
- keycode = 0x5A;
- break;
- case 0x35: /* keypad divide key */
- keycode = 0x5B;
- break;
- case 0x37: /* print scrn key */
- keycode = 0x5C;
- break;
- case 0x38: /* right alt key (alt gr) */
- keycode = 0x5D;
- break;
- case 0x47: /* grey home key */
- keycode = 0x5E;
- break;
- case 0x48: /* grey up arrow key */
- keycode = 0x5F;
- break;
- case 0x49: /* grey page up key */
- keycode = 0x60;
- break;
- case 0x4B: /* grey left arrow key */
- keycode = 0x61;
- break;
- case 0x4D: /* grey right arrow key */
- keycode = 0x62;
- break;
- case 0x4F: /* grey end key */
- keycode = 0x63;
- break;
- case 0x50: /* grey down arrow key */
- keycode = 0x64;
- break;
- case 0x51: /* grey page down key */
- keycode = 0x65;
- break;
- case 0x52: /* grey insert key */
- keycode = 0x66;
- break;
- case 0x53: /* grey delete key */
- keycode = 0x67;
- break;
-
- /* the following 3 are only used on the MS "Natural" keyboard */
- case 0x5b: /* left Window key */
- keycode = 0x69;
- break;
- case 0x5c: /* right Window key */
- keycode = 0x6a;
- break;
- case 0x5d: /* menu key */
- keycode = 0x6b;
- break;
- default: /* ignore everything else */
- goto next_code;
- }
- break;
- case 0xE1: /* 0xE1 prefix */
- esc_flag = 0;
- if (keycode == 0x1D)
- esc_flag = 0x1D;
- goto next_code;
- /* NOT REACHED */
- case 0x1D: /* pause / break */
- esc_flag = 0;
- if (keycode != 0x45)
- goto next_code;
- keycode = 0x68;
- break;
- }
-
- if (!(flags & SCGETC_CN) && (cur_console->status & KBD_CODE_MODE))
- return (keycode | (scancode & 0x80));
-
- /* if scroll-lock pressed allow history browsing */
- if (cur_console->history && cur_console->status & SLKED) {
- int i;
-
- cur_console->status &= ~CURSOR_ENABLED;
- if (!(cur_console->status & BUFFER_SAVED)) {
- cur_console->status |= BUFFER_SAVED;
- cur_console->history_save = cur_console->history_head;
-
- /* copy screen into top of history buffer */
- for (i=0; i<cur_console->ysize; i++) {
- bcopy(cur_console->scr_buf + (cur_console->xsize * i),
- cur_console->history_head,
- cur_console->xsize * sizeof(u_short));
- cur_console->history_head += cur_console->xsize;
- if (cur_console->history_head + cur_console->xsize >
- cur_console->history + cur_console->history_size)
- cur_console->history_head=cur_console->history;
- }
- cur_console->history_pos = cur_console->history_head;
- history_to_screen(cur_console);
- }
- switch (scancode) {
- case 0x47: /* home key */
- cur_console->history_pos = cur_console->history_head;
- history_to_screen(cur_console);
- goto next_code;
-
- case 0x4F: /* end key */
- cur_console->history_pos =
- WRAPHIST(cur_console, cur_console->history_head,
- cur_console->xsize*cur_console->ysize);
- history_to_screen(cur_console);
- goto next_code;
-
- case 0x48: /* up arrow key */
- if (history_up_line(cur_console))
- do_bell(cur_console, BELL_PITCH, BELL_DURATION);
- goto next_code;
-
- case 0x50: /* down arrow key */
- if (history_down_line(cur_console))
- do_bell(cur_console, BELL_PITCH, BELL_DURATION);
- goto next_code;
-
- case 0x49: /* page up key */
- for (i=0; i<cur_console->ysize; i++)
- if (history_up_line(cur_console)) {
- do_bell(cur_console, BELL_PITCH, BELL_DURATION);
- break;
- }
- goto next_code;
-
- case 0x51: /* page down key */
- for (i=0; i<cur_console->ysize; i++)
- if (history_down_line(cur_console)) {
- do_bell(cur_console, BELL_PITCH, BELL_DURATION);
- break;
- }
- goto next_code;
- }
- }
-
- if (compose) {
- switch (scancode) {
- /* key pressed process it */
- case 0x47: case 0x48: case 0x49: /* keypad 7,8,9 */
- chr = (scancode - 0x40) + chr*10;
- goto next_code;
- case 0x4B: case 0x4C: case 0x4D: /* keypad 4,5,6 */
- chr = (scancode - 0x47) + chr*10;
- goto next_code;
- case 0x4F: case 0x50: case 0x51: /* keypad 1,2,3 */
- chr = (scancode - 0x4E) + chr*10;
- goto next_code;
- case 0x52: /* keypad 0 */
- chr *= 10;
- goto next_code;
-
- /* key release, no interest here */
- case 0xC7: case 0xC8: case 0xC9: /* keypad 7,8,9 */
- case 0xCB: case 0xCC: case 0xCD: /* keypad 4,5,6 */
- case 0xCF: case 0xD0: case 0xD1: /* keypad 1,2,3 */
- case 0xD2: /* keypad 0 */
- goto next_code;
-
- case 0x38: /* left alt key */
- break;
- default:
- if (chr) {
- compose = chr = 0;
- do_bell(cur_console, BELL_PITCH, BELL_DURATION);
- goto next_code;
- }
- break;
- }
- }
-
- state = (shfts ? 1 : 0 ) | (2 * (ctls ? 1 : 0)) | (4 * (alts ? 1 : 0));
- if ((!agrs && (cur_console->status & ALKED))
- || (agrs && !(cur_console->status & ALKED)))
- keycode += ALTGR_OFFSET;
- key = &key_map.key[keycode];
- if ( ((key->flgs & FLAG_LOCK_C) && (cur_console->status & CLKED))
- || ((key->flgs & FLAG_LOCK_N) && (cur_console->status & NLKED)) )
- state ^= 1;
-
- /* Check for make/break */
- action = key->map[state];
- if (scancode & 0x80) { /* key released */
- if (key->spcl & (0x80>>state)) {
- switch (action) {
- case LSH:
- shfts &= ~1;
- break;
- case RSH:
- shfts &= ~2;
- break;
- case LCTR:
- ctls &= ~1;
- break;
- case RCTR:
- ctls &= ~2;
- break;
- case LALT:
- alts &= ~1;
- break;
- case RALT:
- alts &= ~2;
- break;
- case NLK:
- nlkcnt = 0;
- break;
- case CLK:
- clkcnt = 0;
- break;
- case SLK:
- slkcnt = 0;
- break;
- case ASH:
- agrs = 0;
- break;
- case ALK:
- alkcnt = 0;
- break;
- case META:
- metas = 0;
- break;
- }
- }
- if (chr && !compose) {
- action = chr;
- chr = 0;
- return(action);
- }
- } else {
- /* key pressed */
- if (key->spcl & (0x80>>state)) {
- switch (action) {
- /* LOCKING KEYS */
- case NLK:
- if (!nlkcnt) {
- nlkcnt++;
- if (cur_console->status & NLKED)
- cur_console->status &= ~NLKED;
- else
- cur_console->status |= NLKED;
- update_leds(cur_console->status);
- }
- break;
- case CLK:
- if (!clkcnt) {
- clkcnt++;
- if (cur_console->status & CLKED)
- cur_console->status &= ~CLKED;
- else
- cur_console->status |= CLKED;
- update_leds(cur_console->status);
- }
- break;
- case SLK:
- if (!slkcnt) {
- slkcnt++;
- if (cur_console->status & SLKED) {
- cur_console->status &= ~SLKED;
- if (cur_console->status & BUFFER_SAVED){
- int i;
- u_short *ptr = cur_console->history_save;
-
- for (i=0; i<cur_console->ysize; i++) {
- bcopy(ptr,
- cur_console->scr_buf +
- (cur_console->xsize*i),
- cur_console->xsize * sizeof(u_short));
- ptr += cur_console->xsize;
- if (ptr + cur_console->xsize >
- cur_console->history +
- cur_console->history_size)
- ptr = cur_console->history;
- }
- cur_console->status &= ~BUFFER_SAVED;
- cur_console->history_head=cur_console->history_save;
- cur_console->status |= CURSOR_ENABLED;
- mark_all(cur_console);
- }
- scstart(VIRTUAL_TTY(get_scr_num()));
- }
- else
- cur_console->status |= SLKED;
- update_leds(cur_console->status);
- }
- break;
- case ALK:
- if (!alkcnt) {
- alkcnt++;
- if (cur_console->status & ALKED)
- cur_console->status &= ~ALKED;
- else
- cur_console->status |= ALKED;
- update_leds(cur_console->status);
- }
- break;
-
- /* NON-LOCKING KEYS */
- case NOP:
- break;
- case SPSC:
- /* force activatation/deactivation of the screen saver */
- accents = 0;
- if (scrn_blanked <= 0) {
- run_scrn_saver = TRUE;
- scrn_time_stamp -= scrn_blank_time;
- }
-#ifdef SC_SPLASH_SCREEN
- if (cold) {
- /*
- * While devices are being probed, the screen saver need
- * to be invoked explictly. XXX
- */
- if (scrn_blanked > 0) {
- scsplash_stick(FALSE);
- stop_scrn_saver(current_saver);
- } else {
- if (!ISGRAPHSC(cur_console)) {
- scsplash_stick(TRUE);
- scrn_saver(current_saver, TRUE);
- }
- }
- }
-#endif
- break;
- case RBT:
-#ifndef SC_DISABLE_REBOOT
- accents = 0;
- shutdown_nice();
-#endif
- break;
- case SUSP:
-#if NAPM > 0
- accents = 0;
- apm_suspend(PMST_SUSPEND);
-#endif
- break;
-
- case STBY:
-#if NAPM > 0
- accents = 0;
- apm_suspend(PMST_STANDBY);
-#endif
- break;
-
- case DBG:
-#ifdef DDB /* try to switch to console 0 */
- accents = 0;
- /*
- * TRY to make sure the screen saver is stopped,
- * and the screen is updated before switching to
- * the vty0.
- */
- scrn_timer((void *)FALSE);
- if (cur_console->smode.mode == VT_AUTO &&
- console[0]->smode.mode == VT_AUTO)
- switch_scr(cur_console, 0);
- Debugger("manual escape to debugger");
-#else
- printf("No debugger in kernel\n");
-#endif
- break;
- case LSH:
- shfts |= 1;
- break;
- case RSH:
- shfts |= 2;
- break;
- case LCTR:
- ctls |= 1;
- break;
- case RCTR:
- ctls |= 2;
- break;
- case LALT:
- alts |= 1;
- break;
- case RALT:
- alts |= 2;
- break;
- case ASH:
- agrs = 1;
- break;
- case META:
- metas = 1;
- break;
- case NEXT:
- {
- int next, this = get_scr_num();
- accents = 0;
- for (next = this+1; next != this; next = (next+1)%MAXCONS) {
- struct tty *tp = VIRTUAL_TTY(next);
- if (tp->t_state & TS_ISOPEN) {
- switch_scr(cur_console, next);
- break;
- }
- }
- }
- break;
- case BTAB:
- accents = 0;
- return(BKEY);
- default:
- if (action >= F_ACC && action <= L_ACC) {
- /* turn it into an index */
- action -= F_ACC - 1;
- if ((action > accent_map.n_accs)
- || (accent_map.acc[action - 1].accchar == 0)) {
- /*
- * The index is out of range or pointing to an
- * empty entry.
- */
- accents = 0;
- do_bell(cur_console, BELL_PITCH, BELL_DURATION);
- }
- /*
- * If the same accent key has been hit twice,
- * produce the accent char itself.
- */
- if (action == accents) {
- action = accent_map.acc[accents - 1].accchar;
- accents = 0;
- if (metas)
- action |= MKEY;
- return (action);
- }
- /* remember the index and wait for the next key stroke */
- accents = action;
- break;
- }
- if (accents > 0) {
- accents = 0;
- do_bell(cur_console, BELL_PITCH, BELL_DURATION);
- }
- if (action >= F_SCR && action <= L_SCR) {
- switch_scr(cur_console, action - F_SCR);
- break;
- }
- if (action >= F_FN && action <= L_FN)
- action |= FKEY;
- return(action);
- }
- }
- else {
- if (accents) {
- struct acc_t *acc;
- int i;
-
- acc = &accent_map.acc[accents - 1];
- accents = 0;
- /*
- * If the accent key is followed by the space key,
- * produce the accent char itself.
- */
- if (action == ' ') {
- action = acc->accchar;
- if (metas)
- action |= MKEY;
- return (action);
- }
- for (i = 0; i < NUM_ACCENTCHARS; ++i) {
- if (acc->map[i][0] == 0) /* end of the map entry */
- break;
- if (acc->map[i][0] == action) {
- action = acc->map[i][1];
- if (metas)
- action |= MKEY;
- return (action);
- }
- }
- do_bell(cur_console, BELL_PITCH, BELL_DURATION);
- goto next_code;
- }
- if (metas)
- action |= MKEY;
- return(action);
- }
- }
- goto next_code;
-}
-
-int
-scmmap(dev_t dev, vm_offset_t offset, int nprot)
-{
- if (offset > 0x20000 - PAGE_SIZE)
- return -1;
- return (VIDEOMEM + offset) >> PAGE_SHIFT;
-}
-
-/*
- * Calculate hardware attributes word using logical attributes mask and
- * hardware colors
- */
-
-static int
-mask2attr(struct term_stat *term)
-{
- int attr, mask = term->attr_mask;
-
- if (mask & REVERSE_ATTR) {
- attr = ((mask & FOREGROUND_CHANGED) ?
- ((term->cur_color & 0xF000) >> 4) :
- (term->rev_color & 0x0F00)) |
- ((mask & BACKGROUND_CHANGED) ?
- ((term->cur_color & 0x0F00) << 4) :
- (term->rev_color & 0xF000));
- } else
- attr = term->cur_color;
-
- /* XXX: underline mapping for Hercules adapter can be better */
- if (mask & (BOLD_ATTR | UNDERLINE_ATTR))
- attr ^= 0x0800;
- if (mask & BLINK_ATTR)
- attr ^= 0x8000;
-
- return attr;
-}
-
-static void
-set_keyboard(int command, int data)
-{
- int s;
-
- if (sc_kbdc == NULL)
- return;
-
- /* prevent the timeout routine from polling the keyboard */
- if (!kbdc_lock(sc_kbdc, TRUE))
- return;
-
- /* disable the keyboard and mouse interrupt */
- s = spltty();
-#if 0
- c = get_controller_command_byte(sc_kbdc);
- if ((c == -1)
- || !set_controller_command_byte(sc_kbdc,
- kbdc_get_device_mask(sc_kbdc),
- KBD_DISABLE_KBD_PORT | KBD_DISABLE_KBD_INT
- | KBD_DISABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
- /* CONTROLLER ERROR */
- kbdc_lock(sc_kbdc, FALSE);
- splx(s);
- return;
- }
- /*
- * Now that the keyboard controller is told not to generate
- * the keyboard and mouse interrupts, call `splx()' to allow
- * the other tty interrupts. The clock interrupt may also occur,
- * but the timeout routine (`scrn_timer()') will be blocked
- * by the lock flag set via `kbdc_lock()'
- */
- splx(s);
-#endif
-
- if (send_kbd_command_and_data(sc_kbdc, command, data) != KBD_ACK)
- send_kbd_command(sc_kbdc, KBDC_ENABLE_KBD);
-
-#if 0
- /* restore the interrupts */
- if (!set_controller_command_byte(sc_kbdc,
- kbdc_get_device_mask(sc_kbdc),
- c & (KBD_KBD_CONTROL_BITS | KBD_AUX_CONTROL_BITS))) {
- /* CONTROLLER ERROR */
- }
-#else
- splx(s);
-#endif
- kbdc_lock(sc_kbdc, FALSE);
-}
-
-static void
-update_leds(int which)
-{
- static u_char xlate_leds[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
-
- /* replace CAPS led with ALTGR led for ALTGR keyboards */
- if (key_map.n_keys > ALTGR_OFFSET) {
- if (which & ALKED)
- which |= CLKED;
- else
- which &= ~CLKED;
- }
-
- set_keyboard(KBDC_SET_LEDS, xlate_leds[which & LED_MASK]);
-}
-
-int
-set_mode(scr_stat *scp)
-{
- video_info_t info;
- video_adapter_t *adp;
-
- /* reject unsupported mode */
- if ((*biosvidsw.get_info)(scp->adp, scp->mode, &info))
- return 1;
-
- /* if this vty is not currently showing, do nothing */
- if (scp != cur_console)
- return 0;
-
- /* setup video hardware for the given mode */
- adp = get_adapter(scp);
- (*biosvidsw.set_mode)(scp->adp, scp->mode);
- Crtat = adp->va_window;
-
- if (!(scp->status & GRAPHICS_MODE)) {
- /* load appropriate font */
- if (!(scp->status & PIXEL_MODE)
- && ISFONTAVAIL(get_adapter(scp)->va_flags)) {
- if (scp->font_size < 14) {
- if (fonts_loaded & FONT_8)
- copy_font(scp, LOAD, 8, font_8);
- } else if (scp->font_size >= 16) {
- if (fonts_loaded & FONT_16)
- copy_font(scp, LOAD, 16, font_16);
- } else {
- if (fonts_loaded & FONT_14)
- copy_font(scp, LOAD, 14, font_14);
- }
- /*
- * FONT KLUDGE:
- * This is an interim kludge to display correct font.
- * Always use the font page #0 on the video plane 2.
- * Somehow we cannot show the font in other font pages on
- * some video cards... XXX
- */
- (*biosvidsw.show_font)(scp->adp, 0);
- }
- mark_all(scp);
- }
- set_border(scp, scp->border);
-
- /* move hardware cursor out of the way */
- (*biosvidsw.set_hw_cursor)(scp->adp, -1, -1);
-
- return 0;
-}
-
-void
-copy_font(scr_stat *scp, int operation, int font_size, u_char *buf)
-{
- /*
- * FONT KLUDGE:
- * This is an interim kludge to display correct font.
- * Always use the font page #0 on the video plane 2.
- * Somehow we cannot show the font in other font pages on
- * some video cards... XXX
- */
- font_loading_in_progress = TRUE;
- if (operation == LOAD) {
- (*biosvidsw.load_font)(scp->adp, 0, font_size, buf, 0, 256);
- if (flags & CHAR_CURSOR)
- set_destructive_cursor(scp);
- } else if (operation == SAVE) {
- (*biosvidsw.save_font)(scp->adp, 0, font_size, buf, 0, 256);
- }
- font_loading_in_progress = FALSE;
-}
-
-static void
-set_destructive_cursor(scr_stat *scp)
-{
- u_char cursor[32];
- u_char *font_buffer;
- int font_size;
- int i;
-
- if (!ISFONTAVAIL(get_adapter(scp)->va_flags) || !ISTEXTSC(scp))
- return;
-
- if (scp->font_size < 14) {
- font_buffer = font_8;
- font_size = 8;
- } else if (scp->font_size >= 16) {
- font_buffer = font_16;
- font_size = 16;
- } else {
- font_buffer = font_14;
- font_size = 14;
- }
-
- if (scp->status & MOUSE_VISIBLE) {
- if ((scp->cursor_saveunder & 0xff) == SC_MOUSE_CHAR)
- bcopy(&scp->mouse_cursor[0], cursor, scp->font_size);
- else if ((scp->cursor_saveunder & 0xff) == SC_MOUSE_CHAR + 1)
- bcopy(&scp->mouse_cursor[32], cursor, scp->font_size);
- else if ((scp->cursor_saveunder & 0xff) == SC_MOUSE_CHAR + 2)
- bcopy(&scp->mouse_cursor[64], cursor, scp->font_size);
- else if ((scp->cursor_saveunder & 0xff) == SC_MOUSE_CHAR + 3)
- bcopy(&scp->mouse_cursor[96], cursor, scp->font_size);
- else
- bcopy(font_buffer+((scp->cursor_saveunder & 0xff)*scp->font_size),
- cursor, scp->font_size);
- }
- else
- bcopy(font_buffer + ((scp->cursor_saveunder & 0xff) * scp->font_size),
- cursor, scp->font_size);
- for (i=0; i<32; i++)
- if ((i >= scp->cursor_start && i <= scp->cursor_end) ||
- (scp->cursor_start >= scp->font_size && i == scp->font_size - 1))
- cursor[i] |= 0xff;
-#if 1
- while (!(inb(crtc_addr+6) & 0x08)) /* wait for vertical retrace */ ;
-#endif
- font_loading_in_progress = TRUE;
- (*biosvidsw.load_font)(scp->adp, 0, font_size, cursor, DEAD_CHAR, 1);
- font_loading_in_progress = FALSE;
-}
-
-void
-sc_move_mouse(scr_stat *scp, int x, int y)
-{
- scp->mouse_xpos = x;
- scp->mouse_ypos = y;
- scp->mouse_pos = scp->mouse_oldpos =
- scp->scr_buf + (y / scp->font_size) * scp->xsize + x / 8;
-}
-
-static void
-set_mouse_pos(scr_stat *scp)
-{
- static int last_xpos = -1, last_ypos = -1;
-
- if (scp->mouse_xpos < 0)
- scp->mouse_xpos = 0;
- if (scp->mouse_ypos < 0)
- scp->mouse_ypos = 0;
- if (!ISTEXTSC(scp)) {
- if (scp->mouse_xpos > scp->xpixel-1)
- scp->mouse_xpos = scp->xpixel-1;
- if (scp->mouse_ypos > scp->ypixel-1)
- scp->mouse_ypos = scp->ypixel-1;
- return;
- }
- if (scp->mouse_xpos > (scp->xsize*8)-1)
- scp->mouse_xpos = (scp->xsize*8)-1;
- if (scp->mouse_ypos > (scp->ysize*scp->font_size)-1)
- scp->mouse_ypos = (scp->ysize*scp->font_size)-1;
-
- if (scp->mouse_xpos != last_xpos || scp->mouse_ypos != last_ypos) {
- scp->status |= MOUSE_MOVED;
-
- scp->mouse_pos = scp->scr_buf +
- ((scp->mouse_ypos/scp->font_size)*scp->xsize + scp->mouse_xpos/8);
-
- if ((scp->status & MOUSE_VISIBLE) && (scp->status & MOUSE_CUTTING))
- mouse_cut(scp);
- }
-}
-
-#define isspace(c) (((c) & 0xff) == ' ')
-
-static int
-skip_spc_right(scr_stat *scp, u_short *p)
-{
- int i;
-
- for (i = (p - scp->scr_buf) % scp->xsize; i < scp->xsize; ++i) {
- if (!isspace(*p))
- break;
- ++p;
- }
- return i;
-}
-
-static int
-skip_spc_left(scr_stat *scp, u_short *p)
-{
- int i;
-
- for (i = (p-- - scp->scr_buf) % scp->xsize - 1; i >= 0; --i) {
- if (!isspace(*p))
- break;
- --p;
- }
- return i;
-}
-
-static void
-mouse_cut(scr_stat *scp)
-{
- u_short *end;
- u_short *p;
- int i = 0;
- int j = 0;
-
- scp->mouse_cut_end = (scp->mouse_pos >= scp->mouse_cut_start) ?
- scp->mouse_pos + 1 : scp->mouse_pos;
- end = (scp->mouse_cut_start > scp->mouse_cut_end) ?
- scp->mouse_cut_start : scp->mouse_cut_end;
- for (p = (scp->mouse_cut_start > scp->mouse_cut_end) ?
- scp->mouse_cut_end : scp->mouse_cut_start; p < end; ++p) {
- cut_buffer[i] = *p & 0xff;
- /* remember the position of the last non-space char */
- if (!isspace(cut_buffer[i++]))
- j = i;
- /* trim trailing blank when crossing lines */
- if (((p - scp->scr_buf) % scp->xsize) == (scp->xsize - 1)) {
- cut_buffer[j++] = '\r';
- i = j;
- }
- }
- cut_buffer[i] = '\0';
-
- /* scan towards the end of the last line */
- --p;
- for (i = (p - scp->scr_buf) % scp->xsize; i < scp->xsize; ++i) {
- if (!isspace(*p))
- break;
- ++p;
- }
- /* if there is nothing but blank chars, trim them, but mark towards eol */
- if (i >= scp->xsize) {
- if (scp->mouse_cut_start > scp->mouse_cut_end)
- scp->mouse_cut_start = p;
- else
- scp->mouse_cut_end = p;
- cut_buffer[j++] = '\r';
- cut_buffer[j] = '\0';
- }
-
- mark_for_update(scp, scp->mouse_cut_start - scp->scr_buf);
- mark_for_update(scp, scp->mouse_cut_end - scp->scr_buf);
-}
-
-static void
-mouse_cut_start(scr_stat *scp)
-{
- int i;
-
- if (scp->status & MOUSE_VISIBLE) {
- if (scp->mouse_pos == scp->mouse_cut_start &&
- scp->mouse_cut_start == scp->mouse_cut_end - 1) {
- cut_buffer[0] = '\0';
- remove_cutmarking(scp);
- } else if (skip_spc_right(scp, scp->mouse_pos) >= scp->xsize) {
- /* if the pointer is on trailing blank chars, mark towards eol */
- i = skip_spc_left(scp, scp->mouse_pos) + 1;
- scp->mouse_cut_start = scp->scr_buf +
- ((scp->mouse_pos - scp->scr_buf) / scp->xsize) * scp->xsize + i;
- scp->mouse_cut_end = scp->scr_buf +
- ((scp->mouse_pos - scp->scr_buf) / scp->xsize + 1) * scp->xsize;
- cut_buffer[0] = '\r';
- cut_buffer[1] = '\0';
- scp->status |= MOUSE_CUTTING;
- } else {
- scp->mouse_cut_start = scp->mouse_pos;
- scp->mouse_cut_end = scp->mouse_cut_start + 1;
- cut_buffer[0] = *scp->mouse_cut_start & 0xff;
- cut_buffer[1] = '\0';
- scp->status |= MOUSE_CUTTING;
- }
- mark_all(scp);
- /* delete all other screens cut markings */
- for (i=0; i<MAXCONS; i++) {
- if (console[i] == NULL || console[i] == scp)
- continue;
- remove_cutmarking(console[i]);
- }
- }
-}
-
-static void
-mouse_cut_end(scr_stat *scp)
-{
- if (scp->status & MOUSE_VISIBLE) {
- scp->status &= ~MOUSE_CUTTING;
- }
-}
-
-static void
-mouse_cut_word(scr_stat *scp)
-{
- u_short *p;
- u_short *sol;
- u_short *eol;
- int i;
-
- /*
- * Because we don't have locale information in the kernel,
- * we only distinguish space char and non-space chars. Punctuation
- * chars, symbols and other regular chars are all treated alike.
- */
- if (scp->status & MOUSE_VISIBLE) {
- sol = scp->scr_buf
- + ((scp->mouse_pos - scp->scr_buf) / scp->xsize) * scp->xsize;
- eol = sol + scp->xsize;
- if (isspace(*scp->mouse_pos)) {
- for (p = scp->mouse_pos; p >= sol; --p)
- if (!isspace(*p))
- break;
- scp->mouse_cut_start = ++p;
- for (p = scp->mouse_pos; p < eol; ++p)
- if (!isspace(*p))
- break;
- scp->mouse_cut_end = p;
- } else {
- for (p = scp->mouse_pos; p >= sol; --p)
- if (isspace(*p))
- break;
- scp->mouse_cut_start = ++p;
- for (p = scp->mouse_pos; p < eol; ++p)
- if (isspace(*p))
- break;
- scp->mouse_cut_end = p;
- }
- for (i = 0, p = scp->mouse_cut_start; p < scp->mouse_cut_end; ++p)
- cut_buffer[i++] = *p & 0xff;
- cut_buffer[i] = '\0';
- scp->status |= MOUSE_CUTTING;
- }
-}
-
-static void
-mouse_cut_line(scr_stat *scp)
-{
- u_short *p;
- int i;
-
- if (scp->status & MOUSE_VISIBLE) {
- scp->mouse_cut_start = scp->scr_buf
- + ((scp->mouse_pos - scp->scr_buf) / scp->xsize) * scp->xsize;
- scp->mouse_cut_end = scp->mouse_cut_start + scp->xsize;
- for (i = 0, p = scp->mouse_cut_start; p < scp->mouse_cut_end; ++p)
- cut_buffer[i++] = *p & 0xff;
- cut_buffer[i++] = '\r';
- cut_buffer[i] = '\0';
- scp->status |= MOUSE_CUTTING;
- }
-}
-
-static void
-mouse_cut_extend(scr_stat *scp)
-{
- if ((scp->status & MOUSE_VISIBLE) && !(scp->status & MOUSE_CUTTING)
- && (scp->mouse_cut_start != NULL)) {
- mouse_cut(scp);
- scp->status |= MOUSE_CUTTING;
- }
-}
-
-static void
-mouse_paste(scr_stat *scp)
-{
- if (scp->status & MOUSE_VISIBLE) {
- struct tty *tp;
- u_char *ptr = cut_buffer;
-
- tp = VIRTUAL_TTY(get_scr_num());
- while (*ptr)
- (*linesw[tp->t_line].l_rint)(scr_rmap[*ptr++], tp);
- }
-}
-
-static void
-draw_mouse_image(scr_stat *scp)
-{
- u_short buffer[32];
- u_short xoffset, yoffset;
- u_int32_t crt_pos = Crtat + 2*(scp->mouse_pos - scp->scr_buf);
- u_char *font_buffer;
- int font_size;
- int i;
-
- if (scp->font_size < 14) {
- font_buffer = font_8;
- font_size = 8;
- } else if (scp->font_size >= 16) {
- font_buffer = font_16;
- font_size = 16;
- } else {
- font_buffer = font_14;
- font_size = 14;
- }
-
- xoffset = scp->mouse_xpos % 8;
- yoffset = scp->mouse_ypos % scp->font_size;
-
- /* prepare mousepointer char's bitmaps */
- bcopy(font_buffer + ((*(scp->mouse_pos) & 0xff) * font_size),
- &scp->mouse_cursor[0], font_size);
- bcopy(font_buffer + ((*(scp->mouse_pos+1) & 0xff) * font_size),
- &scp->mouse_cursor[32], font_size);
- bcopy(font_buffer + ((*(scp->mouse_pos+scp->xsize) & 0xff) * font_size),
- &scp->mouse_cursor[64], font_size);
- bcopy(font_buffer + ((*(scp->mouse_pos+scp->xsize+1) & 0xff) * font_size),
- &scp->mouse_cursor[96], font_size);
- for (i=0; i<font_size; i++) {
- buffer[i] = scp->mouse_cursor[i]<<8 | scp->mouse_cursor[i+32];
- buffer[i+font_size]=scp->mouse_cursor[i+64]<<8|scp->mouse_cursor[i+96];
- }
-
- /* now and-or in the mousepointer image */
- for (i=0; i<16; i++) {
- buffer[i+yoffset] =
- ( buffer[i+yoffset] & ~(mouse_and_mask[i] >> xoffset))
- | (mouse_or_mask[i] >> xoffset);
- }
- for (i=0; i<font_size; i++) {
- scp->mouse_cursor[i] = (buffer[i] & 0xff00) >> 8;
- scp->mouse_cursor[i+32] = buffer[i] & 0xff;
- scp->mouse_cursor[i+64] = (buffer[i+font_size] & 0xff00) >> 8;
- scp->mouse_cursor[i+96] = buffer[i+font_size] & 0xff;
- }
-
- scp->mouse_oldpos = scp->mouse_pos;
-
-#if 1
- /* wait for vertical retrace to avoid jitter on some videocards */
- while (!(inb(crtc_addr+6) & 0x08)) /* idle */ ;
-#endif
- font_loading_in_progress = TRUE;
- (*biosvidsw.load_font)(scp->adp, 0, 32, scp->mouse_cursor,
- SC_MOUSE_CHAR, 4);
- font_loading_in_progress = FALSE;
-
- writew(crt_pos, (*(scp->mouse_pos) & 0xff00) | SC_MOUSE_CHAR);
- writew(crt_pos+2*scp->xsize,
- (*(scp->mouse_pos + scp->xsize) & 0xff00) | (SC_MOUSE_CHAR + 2));
- if (scp->mouse_xpos < (scp->xsize-1)*8) {
- writew(crt_pos + 2, (*(scp->mouse_pos + 1) & 0xff00) | (SC_MOUSE_CHAR + 1));
- writew(crt_pos+2*scp->xsize + 2,
- (*(scp->mouse_pos + scp->xsize + 1) & 0xff00) | (SC_MOUSE_CHAR + 3));
- }
- mark_for_update(scp, scp->mouse_pos - scp->scr_buf);
- mark_for_update(scp, scp->mouse_pos + scp->xsize + 1 - scp->scr_buf);
-}
-
-static void
-remove_mouse_image(scr_stat *scp)
-{
- u_int32_t crt_pos = Crtat + 2*(scp->mouse_oldpos - scp->scr_buf);
-
- if (!ISTEXTSC(scp))
- return;
- writew(crt_pos, *(scp->mouse_oldpos));
- writew(crt_pos+2, *(scp->mouse_oldpos+1));
- writew(crt_pos+2*scp->xsize, *(scp->mouse_oldpos+scp->xsize));
- writew(crt_pos+2*scp->xsize+2, *(scp->mouse_oldpos+scp->xsize+1));
- mark_for_update(scp, scp->mouse_oldpos - scp->scr_buf);
- mark_for_update(scp, scp->mouse_oldpos + scp->xsize + 1 - scp->scr_buf);
-}
-
-static void
-draw_cutmarking(scr_stat *scp)
-{
- u_short *ptr;
- u_short och, nch;
-
- for (ptr=scp->scr_buf; ptr<=(scp->scr_buf+(scp->xsize*scp->ysize)); ptr++) {
- nch = och = readw(Crtat + 2*(ptr - scp->scr_buf));
- /* are we outside the selected area ? */
- if ( ptr < (scp->mouse_cut_start > scp->mouse_cut_end ?
- scp->mouse_cut_end : scp->mouse_cut_start) ||
- ptr >= (scp->mouse_cut_start > scp->mouse_cut_end ?
- scp->mouse_cut_start : scp->mouse_cut_end)) {
- if (ptr != scp->cursor_pos)
- nch = (och & 0xff) | (*ptr & 0xff00);
- }
- else {
- /* are we clear of the cursor image ? */
- if (ptr != scp->cursor_pos)
- nch = (och & 0x88ff) | (*ptr & 0x7000)>>4 | (*ptr & 0x0700)<<4;
- else {
- if (flags & CHAR_CURSOR)
- nch = (och & 0x88ff)|(*ptr & 0x7000)>>4|(*ptr & 0x0700)<<4;
- else
- if (!(flags & BLINK_CURSOR))
- nch = (och & 0xff) | (*ptr & 0xff00);
- }
- }
- if (nch != och)
- writew(Crtat + 2*(ptr - scp->scr_buf), nch);
- }
-}
-
-static void
-remove_cutmarking(scr_stat *scp)
-{
- scp->mouse_cut_start = scp->mouse_cut_end = NULL;
- scp->status &= ~MOUSE_CUTTING;
- mark_all(scp);
-}
-
-static void
-do_bell(scr_stat *scp, int pitch, int duration)
-{
- if (cold || shutdown_in_progress)
- return;
-
- if (scp != cur_console && (flags & QUIET_BELL))
- return;
-
- if (flags & VISUAL_BELL) {
- if (blink_in_progress)
- return;
- blink_in_progress = 4;
- if (scp != cur_console)
- blink_in_progress += 2;
- blink_screen(cur_console);
- } else {
- if (scp != cur_console)
- pitch *= 2;
- sysbeep(pitch, duration);
- }
-}
-
-static void
-blink_screen(void *arg)
-{
- scr_stat *scp = arg;
-
- if (!ISTEXTSC(scp) || (blink_in_progress <= 1)) {
- blink_in_progress = FALSE;
- mark_all(scp);
- if (delayed_next_scr)
- switch_scr(scp, delayed_next_scr - 1);
- }
- else {
- if (blink_in_progress & 1)
- fillw_io(kernel_default.std_color | scr_map[0x20],
- Crtat, scp->xsize * scp->ysize);
- else
- fillw_io(kernel_default.rev_color | scr_map[0x20],
- Crtat, scp->xsize * scp->ysize);
- blink_in_progress--;
- timeout(blink_screen, scp, hz / 10);
- }
-}
-
-void
-sc_bcopy(scr_stat *scp, u_short *p, int from, int to, int mark)
-{
- u_char *font;
- u_int32_t d, e;
- u_char *f;
- int font_size;
- int line_length;
- int xsize;
- int i, j;
-
- if (ISTEXTSC(scp)) {
- memcpy_toio(Crtat+2*from, p+from, (to-from+1)*sizeof (u_short));
- } else /* if ISPIXELSC(scp) */ {
- if (mark)
- mark = 255;
- font_size = scp->font_size;
- if (font_size < 14)
- font = font_8;
- else if (font_size >= 16)
- font = font_16;
- else
- font = font_14;
- line_length = scp->xpixel/8;
- xsize = scp->xsize;
- d = Crtat
- + scp->xoff + scp->yoff*font_size*line_length
- + (from%xsize) + font_size*line_length*(from/xsize);
- for (i = from ; i <= to ; i++) {
- e = d;
- f = &font[(p[i] & 0x00ff)*font_size];
- for (j = 0 ; j < font_size; j++, f++) {
- writeb(e, mark^*f);
- e += line_length;
- }
- d++;
- if ((i % xsize) == xsize - 1)
- d += scp->xoff*2 + (font_size - 1)*line_length;
- }
- }
-}
-
-#ifdef SC_SPLASH_SCREEN
-
-static void
-scsplash_init(scr_stat *scp)
-{
- video_info_t info;
-
- /*
- * We currently assume the splash screen always use
- * VGA_CG320 mode and abort installation if this mode is not
- * supported with this video card. XXX
- */
- if ((*biosvidsw.get_info)(scp->adp, M_VGA_CG320, &info))
- return;
-
- if (scsplash_load(scp) == 0 && add_scrn_saver(scsplash_saver) == 0) {
- default_saver = scsplash_saver;
- scrn_blank_time = DEFAULT_BLANKTIME;
- run_scrn_saver = TRUE;
- if (!(boothowto & (RB_VERBOSE | RB_CONFIG))) {
- scsplash_stick(TRUE);
- scsplash_saver(TRUE);
- }
- }
-}
-
-static void
-scsplash_saver(int show)
-{
- if (show)
- scsplash(TRUE);
- else if (!sticky_splash)
- scsplash(FALSE);
-}
-
-#endif /* SC_SPLASH_SCREEN */
-
-
-CDEV_DRIVER_MODULE(sc, isa, sc_driver, sc_devclass,
- CDEV_MAJOR, sc_cdevsw, 0, 0);
-
-#endif /* NSC */
diff --git a/sys/isa/syscons.h b/sys/isa/syscons.h
deleted file mode 100644
index e8f9461..0000000
--- a/sys/isa/syscons.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/*-
- * Copyright (c) 1995-1998 Søren Schmidt
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * without modification, immediately at the beginning of the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $Id: syscons.h,v 1.40 1998/08/06 09:15:53 dfr Exp $
- * from: i386/isa syscons.h,v 1.40
- */
-
-#ifndef _I386_ISA_SYSCONS_H_
-#define _I386_ISA_SYSCONS_H_
-
-/* vm things */
-#define ISMAPPED(pa, width) \
- (((pa) <= (u_long)0x1000 - (width)) \
- || ((pa) >= 0xa0000 && (pa) <= 0x100000 - (width)))
-
-#if 0
-#define pa_to_va(pa) (KERNBASE + (pa)) /* works if ISMAPPED(pa...) */
-#endif
-
-#ifdef __i386__
-#define WRITEB(pa, b) *(u_int8_t*)(KERNBASE + (pa)) = b
-#define READB(pa) *(u_int8_t*)(KERNBASE + (pa))
-#else
-#define WRITEB(pa, b) writeb(pa, b)
-#define READB(pa) readb(pa)
-#endif
-
-/* printable chars */
-#define PRINTABLE(ch) ((ch) > 0x1b || ((ch) > 0x0d && (ch) < 0x1b) \
- || (ch) < 0x07)
-
-/* macros for "intelligent" screen update */
-#define mark_for_update(scp, x) {\
- if ((x) < scp->start) scp->start = (x);\
- else if ((x) > scp->end) scp->end = (x);\
- }
-#define mark_all(scp) {\
- scp->start = 0;\
- scp->end = scp->xsize * scp->ysize - 1;\
- }
-
-/* status flags */
-#define LOCK_KEY_MASK 0x0000F
-#define LED_MASK 0x00007
-#define UNKNOWN_MODE 0x00010
-#define KBD_RAW_MODE 0x00020
-#define KBD_CODE_MODE 0x00040
-#define SWITCH_WAIT_REL 0x00080
-#define SWITCH_WAIT_ACQ 0x00100
-#define BUFFER_SAVED 0x00200
-#define CURSOR_ENABLED 0x00400
-#define MOUSE_ENABLED 0x00800
-#define MOUSE_MOVED 0x01000
-#define MOUSE_CUTTING 0x02000
-#define MOUSE_VISIBLE 0x04000
-#define GRAPHICS_MODE 0x08000
-#define PIXEL_MODE 0x10000
-#define SAVER_RUNNING 0x20000
-
-/* configuration flags */
-#define VISUAL_BELL 0x00001
-#define BLINK_CURSOR 0x00002
-#define CHAR_CURSOR 0x00004
-#define DETECT_KBD 0x00008
-#define XT_KEYBD 0x00010
-#define KBD_NORESET 0x00020
-#define QUIET_BELL 0x00040
-#define VESA800X600 0x00080
-
-/* attribute flags */
-#define NORMAL_ATTR 0x00
-#define BLINK_ATTR 0x01
-#define BOLD_ATTR 0x02
-#define UNDERLINE_ATTR 0x04
-#define REVERSE_ATTR 0x08
-#define FOREGROUND_CHANGED 0x10
-#define BACKGROUND_CHANGED 0x20
-
-/* misc defines */
-#define FALSE 0
-#define TRUE 1
-#define MAX_ESC_PAR 5
-#define LOAD 1
-#define SAVE 0
-#define COL 80
-#define ROW 25
-#define BELL_DURATION 5
-#define BELL_PITCH 800
-#define CONSOLE_BUFSIZE 1024
-#define PCBURST 128
-#define FONT_NONE 1
-#define FONT_8 2
-#define FONT_14 4
-#define FONT_16 8
-
-/* special characters */
-#define cntlc 0x03
-#define cntld 0x04
-#define bs 0x08
-#define lf 0x0a
-#define cr 0x0d
-#define del 0x7f
-
-#define DEAD_CHAR 0x07 /* char used for cursor */
-
-typedef struct term_stat {
- int esc; /* processing escape sequence */
- int num_param; /* # of parameters to ESC */
- int last_param; /* last parameter # */
- int param[MAX_ESC_PAR]; /* contains ESC parameters */
- int cur_attr; /* current hardware attr word */
- int attr_mask; /* current logical attr mask */
- int cur_color; /* current hardware color */
- int std_color; /* normal hardware color */
- int rev_color; /* reverse hardware color */
-} term_stat;
-
-typedef struct scr_stat {
- int adp; /* video adapter index */
- u_short *scr_buf; /* buffer when off screen */
- int xpos; /* current X position */
- int ypos; /* current Y position */
- int saved_xpos; /* saved X position */
- int saved_ypos; /* saved Y position */
- int xsize; /* X text size */
- int ysize; /* Y text size */
- int xpixel; /* X graphics size */
- int ypixel; /* Y graphics size */
- int xoff; /* X offset in pixel mode */
- int yoff; /* Y offset in pixel mode */
- int font_size; /* fontsize in Y direction */
- int start; /* modified area start */
- int end; /* modified area end */
- term_stat term; /* terminal emulation stuff */
- int status; /* status (bitfield) */
- u_short *cursor_pos; /* cursor buffer position */
- u_short *cursor_oldpos; /* cursor old buffer position */
- u_short cursor_saveunder; /* saved chars under cursor */
- char cursor_start; /* cursor start line # */
- char cursor_end; /* cursor end line # */
- u_short *mouse_pos; /* mouse buffer position */
- u_short *mouse_oldpos; /* mouse old buffer position */
- short mouse_xpos; /* mouse x coordinate */
- short mouse_ypos; /* mouse y coordinate */
- short mouse_buttons; /* mouse buttons */
- u_char mouse_cursor[128]; /* mouse cursor bitmap store */
- u_short *mouse_cut_start; /* mouse cut start pos */
- u_short *mouse_cut_end; /* mouse cut end pos */
- struct proc *mouse_proc; /* proc* of controlling proc */
- pid_t mouse_pid; /* pid of controlling proc */
- int mouse_signal; /* signal # to report with */
- u_short bell_duration;
- u_short bell_pitch;
- u_char border; /* border color */
- int initial_mode; /* initial mode */
- int mode; /* mode */
- pid_t pid; /* pid of controlling proc */
- struct proc *proc; /* proc* of controlling proc */
- struct vt_mode smode; /* switch mode */
- u_short *history; /* circular history buffer */
- u_short *history_head; /* current head position */
- u_short *history_pos; /* position shown on screen */
- u_short *history_save; /* save area index */
- int history_size; /* size of history buffer */
-#ifdef __i386__
- struct apmhook r_hook; /* reconfiguration support */
-#endif
-#ifdef SC_SPLASH_SCREEN
- int splash_save_mode; /* saved mode for splash screen */
- int splash_save_status; /* saved status for splash screen */
-#endif
-} scr_stat;
-
-typedef struct default_attr {
- int std_color; /* normal hardware color */
- int rev_color; /* reverse hardware color */
-} default_attr;
-
-
-#define ISTEXTSC(scp) (!((scp)->status \
- & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE)))
-#define ISGRAPHSC(scp) (((scp)->status \
- & (UNKNOWN_MODE | GRAPHICS_MODE)))
-#define ISPIXELSC(scp) (((scp)->status \
- & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE))\
- == PIXEL_MODE)
-#define ISUNKNOWNSC(scp) ((scp)->status & UNKNOWN_MODE)
-
-#define ISFONTAVAIL(af) ((af) & V_ADP_FONT)
-#define ISMOUSEAVAIL(af) ((af) & V_ADP_FONT)
-#define ISPALAVAIL(af) ((af) & V_ADP_PALETTE)
-
-/* misc prototypes used by different syscons related LKM's */
-
-/* syscons.c */
-extern int (*sc_user_ioctl)(dev_t dev, int cmd, caddr_t data, int flag,
- struct proc *p);
-
-int set_mode(scr_stat *scp);
-scr_stat *sc_get_scr_stat(dev_t dev);
-
-void copy_font(scr_stat *scp, int operation, int font_size, u_char *font_image);
-#define save_palette(scp, pal) (*biosvidsw.save_palette)((scp)->adp, pal)
-#define load_palette(scp, pal) (*biosvidsw.load_palette)((scp)->adp, pal)
-#define set_border(scp, col) (*biosvidsw.set_border)((scp)->adp, col)
-#define get_adapter(scp) (*biosvidsw.adapter)((scp)->adp)
-
-int add_scrn_saver(void (*this)(int));
-int remove_scrn_saver(void (*this)(int));
-
-void sc_clear_screen(scr_stat *scp);
-void sc_move_mouse(scr_stat *scp, int x, int y);
-int sc_clean_up(scr_stat *scp);
-void sc_alloc_scr_buffer(scr_stat *scp, int wait, int clear);
-void sc_alloc_cut_buffer(scr_stat *scp, int wait);
-void sc_alloc_history_buffer(scr_stat *scp, int lines, int extra, int wait);
-
-/* scvidctl.c */
-int sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode,
- int xsize, int ysize, int fontsize);
-int sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode);
-int sc_set_pixel_mode(scr_stat *scp, struct tty *tp,
- int xsize, int ysize, int fontsize);
-int sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
- struct proc *p);
-
-#ifdef SC_SPLASH_SCREEN
-/* splash.c */
-void scsplash(int);
-int scsplash_load(scr_stat *scp);
-int scsplash_unload(scr_stat *scp);
-#endif
-
-#endif /* !_I386_ISA_SYSCONS_H_ */
diff --git a/sys/isa/syscons_isa.c b/sys/isa/syscons_isa.c
new file mode 100644
index 0000000..9f61cec
--- /dev/null
+++ b/sys/isa/syscons_isa.c
@@ -0,0 +1,80 @@
+/*-
+ * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer as
+ * the first lines of this file unmodified.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id:$
+ */
+
+#include "sc.h"
+#include "opt_syscons.h"
+
+#if NSC > 0
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/bus.h>
+
+#include <machine/console.h>
+
+#include <dev/syscons/syscons.h>
+
+#include <isa/isareg.h>
+#include <isa/isavar.h>
+
+devclass_t sc_devclass;
+
+static int scprobe(device_t dev);
+static int scattach(device_t dev);
+
+static device_method_t sc_methods[] = {
+ DEVMETHOD(device_probe, scprobe),
+ DEVMETHOD(device_attach, scattach),
+ { 0, 0 }
+};
+
+static driver_t sc_driver = {
+ "sc",
+ sc_methods,
+ DRIVER_TYPE_TTY,
+ 1, /* XXX */
+};
+
+static int
+scprobe(device_t dev)
+{
+ device_set_desc(dev, "System console");
+ return sc_probe_unit(device_get_unit(dev), isa_get_flags(dev));
+}
+
+static int
+scattach(device_t dev)
+{
+ return sc_attach_unit(device_get_unit(dev), isa_get_flags(dev));
+}
+
+DRIVER_MODULE(sc, isa, sc_driver, sc_devclass, 0, 0);
+
+#endif /* NSC > 0 */
diff --git a/sys/isa/timerreg.h b/sys/isa/timerreg.h
deleted file mode 100644
index e429bf7..0000000
--- a/sys/isa/timerreg.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * Copyright (c) 1993 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: Header: timerreg.h,v 1.2 93/02/28 15:08:58 mccanne Exp
- * $Id$
- * from: i386/isa timerreg.h,v 1.5
- */
-
-/*
- *
- * Register definitions for the Intel 8253 Programmable Interval Timer.
- *
- * This chip has three independent 16-bit down counters that can be
- * read on the fly. There are three mode registers and three countdown
- * registers. The countdown registers are addressed directly, via the
- * first three I/O ports. The three mode registers are accessed via
- * the fourth I/O port, with two bits in the mode byte indicating the
- * register. (Why are hardware interfaces always so braindead?).
- *
- * To write a value into the countdown register, the mode register
- * is first programmed with a command indicating the which byte of
- * the two byte register is to be modified. The three possibilities
- * are load msb (TMR_MR_MSB), load lsb (TMR_MR_LSB), or load lsb then
- * msb (TMR_MR_BOTH).
- *
- * To read the current value ("on the fly") from the countdown register,
- * you write a "latch" command into the mode register, then read the stable
- * value from the corresponding I/O port. For example, you write
- * TMR_MR_LATCH into the corresponding mode register. Presumably,
- * after doing this, a write operation to the I/O port would result
- * in undefined behavior (but hopefully not fry the chip).
- * Reading in this manner has no side effects.
- *
- * [IBM-PC]
- * The outputs of the three timers are connected as follows:
- *
- * timer 0 -> irq 0
- * timer 1 -> dma chan 0 (for dram refresh)
- * timer 2 -> speaker (via keyboard controller)
- *
- * Timer 0 is used to call hardclock.
- * Timer 2 is used to generate console beeps.
- *
- * [PC-9801]
- * The outputs of the three timers are connected as follows:
- *
- * timer 0 -> irq 0
- * timer 1 -> speaker (via keyboard controller)
- * timer 2 -> RS232C
- *
- * Timer 0 is used to call hardclock.
- * Timer 1 is used to generate console beeps.
- */
-
-/*
- * Macros for specifying values to be written into a mode register.
- */
-#define TIMER_CNTR0 (IO_TIMER1 + 0) /* timer 0 counter port */
-#ifdef PC98
-#define TIMER_CNTR1 0x3fdb /* timer 1 counter port */
-#define TIMER_CNTR2 (IO_TIMER1 + 4) /* timer 2 counter port */
-#define TIMER_MODE (IO_TIMER1 + 6) /* timer mode port */
-#else
-#define TIMER_CNTR1 (IO_TIMER1 + 1) /* timer 1 counter port */
-#define TIMER_CNTR2 (IO_TIMER1 + 2) /* timer 2 counter port */
-#define TIMER_MODE (IO_TIMER1 + 3) /* timer mode port */
-#endif
-#define TIMER_SEL0 0x00 /* select counter 0 */
-#define TIMER_SEL1 0x40 /* select counter 1 */
-#define TIMER_SEL2 0x80 /* select counter 2 */
-#define TIMER_INTTC 0x00 /* mode 0, intr on terminal cnt */
-#define TIMER_ONESHOT 0x02 /* mode 1, one shot */
-#define TIMER_RATEGEN 0x04 /* mode 2, rate generator */
-#define TIMER_SQWAVE 0x06 /* mode 3, square wave */
-#define TIMER_SWSTROBE 0x08 /* mode 4, s/w triggered strobe */
-#define TIMER_HWSTROBE 0x0a /* mode 5, h/w triggered strobe */
-#define TIMER_LATCH 0x00 /* latch counter for reading */
-#define TIMER_LSB 0x10 /* r/w counter LSB */
-#define TIMER_MSB 0x20 /* r/w counter MSB */
-#define TIMER_16BIT 0x30 /* r/w counter 16 bits, LSB first */
-#define TIMER_BCD 0x01 /* count in BCD */
-
diff --git a/sys/isa/vga_isa.c b/sys/isa/vga_isa.c
new file mode 100644
index 0000000..24b677f
--- /dev/null
+++ b/sys/isa/vga_isa.c
@@ -0,0 +1,2239 @@
+/*-
+ * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
+ * Copyright (c) 1992-1998 Søren Schmidt
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer as
+ * the first lines of this file unmodified.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: vga_isa.c,v 1.1 1999/01/09 02:44:41 yokota Exp $
+ */
+
+#include "vga.h"
+#include "opt_vga.h"
+#include "opt_fb.h"
+#include "opt_syscons.h" /* should be removed in the future, XXX */
+
+#if NVGA > 0
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/malloc.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <machine/console.h>
+#include <machine/md_var.h>
+#include <machine/pc/bios.h>
+
+#include <dev/fb/fbreg.h>
+#include <dev/fb/vgareg.h>
+
+#ifndef __i386__
+#include <isa/isareg.h>
+#include <isa/isavar.h>
+#else
+#include <i386/isa/isa.h>
+#include <i386/isa/isa_device.h>
+#endif
+
+#define DRIVER_NAME "vga"
+
+/* cdev driver declaration */
+
+#define ISAVGA_UNIT(dev) minor(dev)
+#define ISAVGA_MKMINOR(unit) (unit)
+
+typedef struct isavga_softc {
+ video_adapter_t *adp;
+} isavga_softc_t;
+
+#ifndef __i386__
+
+#define ISAVGA_SOFTC(unit) \
+ ((isavga_softc_t *)devclass_get_softc(isavga_devclass, unit))
+
+devclass_t isavga_devclass;
+
+static int isavga_probe(device_t dev);
+static int isavga_attach(device_t dev);
+
+static device_method_t isavga_methods[] = {
+ DEVMETHOD(device_probe, isavga_probe),
+ DEVMETHOD(device_attach, isavga_attach),
+ { 0, 0 }
+};
+
+static driver_t isavga_driver = {
+ DRIVER_NAME,
+ isavga_methods,
+ DRIVER_TYPE_TTY,
+ sizeof(isavga_softc_t),
+};
+
+DRIVER_MODULE(vga, isa, isavga_driver, isavga_devclass, 0, 0);
+
+#else /* __i386__ */
+
+#define ISAVGA_SOFTC(unit) (isavga_softc[unit])
+
+static isavga_softc_t *isavga_softc[NVGA];
+
+static int isavga_probe(struct isa_device *dev);
+static int isavga_attach(struct isa_device *dev);
+
+struct isa_driver vgadriver = {
+ isavga_probe,
+ isavga_attach,
+ DRIVER_NAME,
+ 0,
+};
+
+#endif /* __i386__ */
+
+static int isavga_probe_unit(int unit, isavga_softc_t *sc,
+ int flags);
+static int isavga_attach_unit(int unit, isavga_softc_t *sc,
+ int flags);
+
+#ifdef FB_INSTALL_CDEV
+
+static d_open_t isavgaopen;
+static d_close_t isavgaclose;
+static d_read_t isavgaread;
+static d_ioctl_t isavgaioctl;
+
+static struct cdevsw vga_cdevsw = {
+ isavgaopen, isavgaclose, noread, nowrite, /* ?? */
+ isavgaioctl, nostop, nullreset, nodevtotty,
+ seltrue, nommap, NULL, DRIVER_NAME,
+ NULL, -1, nodump, nopsize,
+};
+
+#endif /* FB_INSTALL_CDEV */
+
+#ifndef __i386__
+
+static int
+isavga_probe(device_t dev)
+{
+ isavga_softc_t *sc;
+
+ device_set_desc(dev, "Generic ISA VGA");
+ sc = device_get_softc(dev);
+ return isavga_probe_unit(device_get_unit(dev), sc, isa_get_flags(dev));
+}
+
+static int
+isavga_attach(device_t dev)
+{
+ isavga_softc_t *sc;
+
+ sc = device_get_softc(dev);
+ return isavga_attach_unit(device_get_unit(dev), sc, isa_get_flags(dev));
+}
+
+#else /* __i386__ */
+
+static int
+isavga_probe(struct isa_device *dev)
+{
+ isavga_softc_t *sc;
+ int error;
+
+ if (dev->id_unit >= sizeof(isavga_softc)/sizeof(isavga_softc[0]))
+ return 0;
+ sc = isavga_softc[dev->id_unit]
+ = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT);
+ if (sc == NULL)
+ return 0;
+
+ error = isavga_probe_unit(dev->id_unit, sc, dev->id_flags);
+ if (error) {
+ isavga_softc[dev->id_unit] = NULL;
+ free(sc, M_DEVBUF);
+ return 0;
+ }
+
+ dev->id_iobase = sc->adp->va_io_base;
+ dev->id_maddr = (caddr_t)BIOS_PADDRTOVADDR(sc->adp->va_mem_base);
+ dev->id_msize = sc->adp->va_mem_size;
+
+ return sc->adp->va_io_size;
+}
+
+static int
+isavga_attach(struct isa_device *dev)
+{
+ isavga_softc_t *sc;
+
+ if (dev->id_unit >= sizeof(isavga_softc)/sizeof(isavga_softc[0]))
+ return 0;
+ sc = isavga_softc[dev->id_unit];
+ if (sc == NULL)
+ return 0;
+
+ return ((isavga_attach_unit(dev->id_unit, sc, dev->id_flags)) ? 0 : 1);
+}
+
+#endif /* __i386__ */
+
+static int
+isavga_probe_unit(int unit, isavga_softc_t *sc, int flags)
+{
+ video_switch_t *sw;
+
+ bzero(sc, sizeof(*sc));
+ sw = vid_get_switch(DRIVER_NAME);
+ if (sw == NULL)
+ return 0;
+ return (*sw->probe)(unit, &sc->adp, NULL, flags);
+}
+
+static int
+isavga_attach_unit(int unit, isavga_softc_t *sc, int flags)
+{
+ video_switch_t *sw;
+ int error;
+
+ sw = vid_get_switch(DRIVER_NAME);
+ if (sw == NULL)
+ return ENXIO;
+
+ error = (*sw->init)(unit, sc->adp, flags);
+ if (error)
+ return ENXIO;
+
+#ifdef FB_INSTALL_CDEV
+ /* attach a virtual frame buffer device */
+ error = fb_attach(makedev(0, ISAVGA_MKMINOR(unit)), scp->adp,
+ &vga_cdevsw);
+ if (error)
+ return error;
+#endif /* FB_INSTALL_CDEV */
+
+ if (bootverbose)
+ (*sw->diag)(sc->adp, bootverbose);
+
+ return 0;
+}
+
+/* LOW-LEVEL */
+
+#include <machine/clock.h>
+#include <machine/pc/vesa.h>
+
+#define probe_done(adp) ((adp)->va_flags & V_ADP_PROBED)
+#define init_done(adp) ((adp)->va_flags & V_ADP_INITIALIZED)
+#define config_done(adp) ((adp)->va_flags & V_ADP_REGISTERED)
+
+/* for compatibility with old kernel options */
+#ifdef SC_ALT_SEQACCESS
+#undef SC_ALT_SEQACCESS
+#undef VGA_ALT_SEQACCESS
+#define VGA_ALT_SEQACCESS 1
+#endif
+
+#ifdef SLOW_VGA
+#undef SLOW_VGA
+#undef VGA_SLOW_IOACCESS
+#define VGA_SLOW_IOACCESS 1
+#endif
+
+/* architecture dependent option */
+#ifdef __alpha__
+#define VGA_NO_BIOS 1
+#endif
+
+/* this should really be in `rtc.h' */
+#define RTC_EQUIPMENT 0x14
+
+/* various sizes */
+#define V_MODE_MAP_SIZE (M_VGA_CG320 + 1)
+#define V_MODE_PARAM_SIZE 64
+
+/* video adapter state buffer */
+struct adp_state {
+ int sig;
+#define V_STATE_SIG 0x736f6962
+ u_char regs[V_MODE_PARAM_SIZE];
+};
+typedef struct adp_state adp_state_t;
+
+/* video adapter information */
+#define DCC_MONO 0
+#define DCC_CGA40 1
+#define DCC_CGA80 2
+#define DCC_EGAMONO 3
+#define DCC_EGA40 4
+#define DCC_EGA80 5
+
+/*
+ * NOTE: `va_window' should have a virtual address, but is initialized
+ * with a physical address in the following table, as verify_adapter()
+ * will perform address conversion at run-time.
+ */
+static video_adapter_t adapter_init_value[] = {
+ /* DCC_MONO */
+ { 0, KD_MONO, "mda", 0, 0, 0, IO_MDA, IO_MDASIZE, MONO_CRTC,
+ MDA_BUF_BASE, MDA_BUF_SIZE, MDA_BUF_BASE, MDA_BUF_SIZE, MDA_BUF_SIZE,
+ 0, 0, 0, 7, 0, 0, NULL },
+ /* DCC_CGA40 */
+ { 0, KD_CGA, "cga", 0, 0, V_ADP_COLOR, IO_CGA, IO_CGASIZE, COLOR_CRTC,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE,
+ 0, 0, 0, 3, 0, 0, NULL },
+ /* DCC_CGA80 */
+ { 0, KD_CGA, "cga", 0, 0, V_ADP_COLOR, IO_CGA, IO_CGASIZE, COLOR_CRTC,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE,
+ 0, 0, 0, 3, 0, 0, NULL },
+ /* DCC_EGAMONO */
+ { 0, KD_EGA, "ega", 0, 0, 0, IO_MDA, 48, MONO_CRTC,
+ EGA_BUF_BASE, EGA_BUF_SIZE, MDA_BUF_BASE, MDA_BUF_SIZE, MDA_BUF_SIZE,
+ 0, 0, 0, 7, 0, 0, NULL },
+ /* DCC_EGA40 */
+ { 0, KD_EGA, "ega", 0, 0, V_ADP_COLOR, IO_MDA, 48, COLOR_CRTC,
+ EGA_BUF_BASE, EGA_BUF_SIZE, CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE,
+ 0, 0, 0, 3, 0, 0, NULL },
+ /* DCC_EGA80 */
+ { 0, KD_EGA, "ega", 0, 0, V_ADP_COLOR, IO_MDA, 48, COLOR_CRTC,
+ EGA_BUF_BASE, EGA_BUF_SIZE, CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE,
+ 0, 0, 0, 3, 0, 0, NULL },
+};
+
+static video_adapter_t biosadapter[2];
+static int biosadapters = 0;
+
+/* video driver declarations */
+static int vga_configure(int flags);
+ int (*vga_sub_configure)(int flags);
+static int vga_nop(void);
+static vi_probe_t vga_probe;
+static vi_init_t vga_init;
+static vi_get_info_t vga_get_info;
+static vi_query_mode_t vga_query_mode;
+static vi_set_mode_t vga_set_mode;
+static vi_save_font_t vga_save_font;
+static vi_load_font_t vga_load_font;
+static vi_show_font_t vga_show_font;
+static vi_save_palette_t vga_save_palette;
+static vi_load_palette_t vga_load_palette;
+static vi_set_border_t vga_set_border;
+static vi_save_state_t vga_save_state;
+static vi_load_state_t vga_load_state;
+static vi_set_win_org_t vga_set_origin;
+static vi_read_hw_cursor_t vga_read_hw_cursor;
+static vi_set_hw_cursor_t vga_set_hw_cursor;
+static vi_set_hw_cursor_shape_t vga_set_hw_cursor_shape;
+static vi_mmap_t vga_mmap;
+static vi_diag_t vga_diag;
+
+static video_switch_t vgavidsw = {
+ vga_probe,
+ vga_init,
+ vga_get_info,
+ vga_query_mode,
+ vga_set_mode,
+ vga_save_font,
+ vga_load_font,
+ vga_show_font,
+ vga_save_palette,
+ vga_load_palette,
+ vga_set_border,
+ vga_save_state,
+ vga_load_state,
+ vga_set_origin,
+ vga_read_hw_cursor,
+ vga_set_hw_cursor,
+ vga_set_hw_cursor_shape,
+ (vi_blank_display_t *)vga_nop,
+ vga_mmap,
+ vga_diag,
+};
+
+VIDEO_DRIVER(mda, vgavidsw, NULL);
+VIDEO_DRIVER(cga, vgavidsw, NULL);
+VIDEO_DRIVER(ega, vgavidsw, NULL);
+VIDEO_DRIVER(vga, vgavidsw, vga_configure);
+
+/* VGA BIOS standard video modes */
+#define EOT (-1)
+#define NA (-2)
+
+static video_info_t bios_vmode[] = {
+ /* CGA */
+ { M_B40x25, V_INFO_COLOR, 40, 25, 8, 8, 2, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+ { M_C40x25, V_INFO_COLOR, 40, 25, 8, 8, 4, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+ { M_B80x25, V_INFO_COLOR, 80, 25, 8, 8, 2, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+ { M_C80x25, V_INFO_COLOR, 80, 25, 8, 8, 4, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+ /* EGA */
+ { M_ENH_B40x25, V_INFO_COLOR, 40, 25, 8, 14, 2, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+ { M_ENH_C40x25, V_INFO_COLOR, 40, 25, 8, 14, 4, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+ { M_ENH_B80x25, V_INFO_COLOR, 80, 25, 8, 14, 2, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+ { M_ENH_C80x25, V_INFO_COLOR, 80, 25, 8, 14, 4, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+ /* VGA */
+ { M_VGA_C40x25, V_INFO_COLOR, 40, 25, 8, 16, 4, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+ { M_VGA_M80x25, 0, 80, 25, 8, 16, 2, 1,
+ MDA_BUF_BASE, MDA_BUF_SIZE, MDA_BUF_SIZE, 0, 0 },
+ { M_VGA_C80x25, V_INFO_COLOR, 80, 25, 8, 16, 4, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+ /* MDA */
+ { M_EGAMONO80x25, 0, 80, 25, 8, 14, 2, 1,
+ MDA_BUF_BASE, MDA_BUF_SIZE, MDA_BUF_SIZE, 0, 0 },
+ /* EGA */
+ { M_ENH_B80x43, V_INFO_COLOR, 80, 43, 8, 8, 2, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+ { M_ENH_C80x43, V_INFO_COLOR, 80, 43, 8, 8, 4, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+ /* VGA */
+ { M_VGA_M80x30, 0, 80, 30, 8, 16, 2, 1,
+ MDA_BUF_BASE, MDA_BUF_SIZE, MDA_BUF_SIZE, 0, 0 },
+ { M_VGA_C80x30, V_INFO_COLOR, 80, 30, 8, 16, 4, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+ { M_VGA_M80x50, 0, 80, 50, 8, 8, 2, 1,
+ MDA_BUF_BASE, MDA_BUF_SIZE, MDA_BUF_SIZE, 0, 0 },
+ { M_VGA_C80x50, V_INFO_COLOR, 80, 50, 8, 8, 4, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+ { M_VGA_M80x60, 0, 80, 60, 8, 8, 2, 1,
+ MDA_BUF_BASE, MDA_BUF_SIZE, MDA_BUF_SIZE, 0, 0 },
+ { M_VGA_C80x60, V_INFO_COLOR, 80, 60, 8, 8, 4, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+#ifndef VGA_NO_MODE_CHANGE
+ /* CGA */
+ { M_BG320, V_INFO_COLOR | V_INFO_GRAPHICS, 320, 200, 8, 8, 2, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+ { M_CG320, V_INFO_COLOR | V_INFO_GRAPHICS, 320, 200, 8, 8, 2, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+ { M_BG640, V_INFO_COLOR | V_INFO_GRAPHICS, 640, 200, 8, 8, 1, 1,
+ CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE, 0, 0 },
+ /* EGA */
+ { M_CG320_D, V_INFO_COLOR | V_INFO_GRAPHICS, 320, 200, 8, 8, 4, 4,
+ GRAPHICS_BUF_BASE, GRAPHICS_BUF_SIZE, GRAPHICS_BUF_SIZE, 0, 0 },
+ { M_CG640_E, V_INFO_COLOR | V_INFO_GRAPHICS, 640, 200, 8, 8, 4, 4,
+ GRAPHICS_BUF_BASE, GRAPHICS_BUF_SIZE, GRAPHICS_BUF_SIZE, 0, 0 },
+ { M_EGAMONOAPA, V_INFO_GRAPHICS, 640, 350, 8, 14, 4, 4,
+ GRAPHICS_BUF_BASE, GRAPHICS_BUF_SIZE, 64*1024, 0, 0 },
+ { M_ENHMONOAPA2,V_INFO_GRAPHICS, 640, 350, 8, 14, 4, 4,
+ GRAPHICS_BUF_BASE, GRAPHICS_BUF_SIZE, GRAPHICS_BUF_SIZE, 0, 0 },
+ { M_CG640x350, V_INFO_COLOR | V_INFO_GRAPHICS, 640, 350, 8, 14, 2, 2,
+ GRAPHICS_BUF_BASE, GRAPHICS_BUF_SIZE, GRAPHICS_BUF_SIZE, 0, 0 },
+ { M_ENH_CG640, V_INFO_COLOR | V_INFO_GRAPHICS, 640, 350, 8, 14, 4, 4,
+ GRAPHICS_BUF_BASE, GRAPHICS_BUF_SIZE, GRAPHICS_BUF_SIZE, 0, 0 },
+ /* VGA */
+ { M_BG640x480, V_INFO_COLOR | V_INFO_GRAPHICS, 640, 480, 8, 16, 4, 4,
+ GRAPHICS_BUF_BASE, GRAPHICS_BUF_SIZE, GRAPHICS_BUF_SIZE, 0, 0 },
+ { M_CG640x480, V_INFO_COLOR | V_INFO_GRAPHICS, 640, 480, 8, 16, 4, 4,
+ GRAPHICS_BUF_BASE, GRAPHICS_BUF_SIZE, GRAPHICS_BUF_SIZE, 0, 0 },
+ { M_VGA_CG320, V_INFO_COLOR | V_INFO_GRAPHICS, 320, 200, 8, 8, 8, 1,
+ GRAPHICS_BUF_BASE, GRAPHICS_BUF_SIZE, GRAPHICS_BUF_SIZE, 0, 0 },
+ { M_VGA_MODEX, V_INFO_COLOR | V_INFO_GRAPHICS, 320, 240, 8, 8, 8, 1,
+ GRAPHICS_BUF_BASE, GRAPHICS_BUF_SIZE, GRAPHICS_BUF_SIZE, 0, 0 },
+#endif /* VGA_NO_MODE_CHANGE */
+
+ { EOT },
+};
+
+static int init_done = FALSE;
+static u_char *video_mode_ptr = NULL; /* EGA/VGA */
+static u_char *video_mode_ptr2 = NULL; /* CGA/MDA */
+static u_char *mode_map[V_MODE_MAP_SIZE];
+static adp_state_t adpstate;
+static adp_state_t adpstate2;
+static int rows_offset = 1;
+
+/* local macros and functions */
+#define BIOS_SADDRTOLADDR(p) ((((p) & 0xffff0000) >> 12) + ((p) & 0x0000ffff))
+
+#if !defined(VGA_NO_BIOS) && !defined(VGA_NO_MODE_CHANGE)
+static void map_mode_table(u_char *map[], u_char *table, int max);
+#endif
+static void clear_mode_map(video_adapter_t *adp, u_char *map[], int max,
+ int color);
+#if !defined(VGA_NO_BIOS) && !defined(VGA_NO_MODE_CHANGE)
+static int map_mode_num(int mode);
+#endif
+static int map_gen_mode_num(int type, int color, int mode);
+static int map_bios_mode_num(int type, int color, int bios_mode);
+static u_char *get_mode_param(int mode);
+#ifndef VGA_NO_BIOS
+static void fill_adapter_param(int code, video_adapter_t *adp);
+#endif
+static int verify_adapter(video_adapter_t *adp);
+#if !defined(VGA_NO_BIOS) && !defined(VGA_NO_MODE_CHANGE)
+#define COMP_IDENTICAL 0
+#define COMP_SIMILAR 1
+#define COMP_DIFFERENT 2
+static int comp_adpregs(u_char *buf1, u_char *buf2);
+#endif
+static int probe_adapters(void);
+
+#define PARAM_BUFSIZE 6
+static void set_font_mode(video_adapter_t *adp, u_char *buf);
+static void set_normal_mode(video_adapter_t *adp, u_char *buf);
+
+static void dump_buffer(u_char *buf, size_t len);
+
+#define ISMAPPED(pa, width) \
+ (((pa) <= (u_long)0x1000 - (width)) \
+ || ((pa) >= ISA_HOLE_START && (pa) <= 0x100000 - (width)))
+
+#define prologue(adp, flag, err) \
+ if (!init_done || !((adp)->va_flags & (flag))) \
+ return (err)
+
+/* a backdoor for the console driver */
+static int
+vga_configure(int flags)
+{
+ int i;
+
+ probe_adapters();
+ for (i = 0; i < biosadapters; ++i) {
+ if (!probe_done(&biosadapter[i]))
+ continue;
+ biosadapter[i].va_flags |= V_ADP_INITIALIZED;
+ if (!config_done(&biosadapter[i])) {
+ if (vid_register(&biosadapter[i]) < 0)
+ continue;
+ biosadapter[i].va_flags |= V_ADP_REGISTERED;
+ }
+ }
+ if (vga_sub_configure != NULL)
+ (*vga_sub_configure)(flags);
+
+ return biosadapters;
+}
+
+/* local subroutines */
+
+#if !defined(VGA_NO_BIOS) && !defined(VGA_NO_MODE_CHANGE)
+/* construct the mode parameter map */
+static void
+map_mode_table(u_char *map[], u_char *table, int max)
+{
+ int i;
+
+ for(i = 0; i < max; ++i)
+ map[i] = table + i*V_MODE_PARAM_SIZE;
+ for(; i < V_MODE_MAP_SIZE; ++i)
+ map[i] = NULL;
+}
+#endif /* !VGA_NO_BIOS && !VGA_NO_MODE_CHANGE */
+
+static void
+clear_mode_map(video_adapter_t *adp, u_char *map[], int max, int color)
+{
+ video_info_t info;
+ int i;
+
+ /*
+ * NOTE: we don't touch `bios_vmode[]' because it is shared
+ * by all adapters.
+ */
+ for(i = 0; i < max; ++i) {
+ if (vga_get_info(adp, i, &info))
+ continue;
+ if ((info.vi_flags & V_INFO_COLOR) != color)
+ map[i] = NULL;
+ }
+}
+
+#if !defined(VGA_NO_BIOS) && !defined(VGA_NO_MODE_CHANGE)
+/* map the non-standard video mode to a known mode number */
+static int
+map_mode_num(int mode)
+{
+ static struct {
+ int from;
+ int to;
+ } mode_map[] = {
+ { M_ENH_B80x43, M_ENH_B80x25 },
+ { M_ENH_C80x43, M_ENH_C80x25 },
+ { M_VGA_M80x30, M_VGA_M80x25 },
+ { M_VGA_C80x30, M_VGA_C80x25 },
+ { M_VGA_M80x50, M_VGA_M80x25 },
+ { M_VGA_C80x50, M_VGA_C80x25 },
+ { M_VGA_M80x60, M_VGA_M80x25 },
+ { M_VGA_C80x60, M_VGA_C80x25 },
+ { M_VGA_MODEX, M_VGA_CG320 },
+ };
+ int i;
+
+ for (i = 0; i < sizeof(mode_map)/sizeof(mode_map[0]); ++i) {
+ if (mode_map[i].from == mode)
+ return mode_map[i].to;
+ }
+ return mode;
+}
+#endif /* !VGA_NO_BIOS && !VGA_NO_MODE_CHANGE */
+
+/* map a generic video mode to a known mode number */
+static int
+map_gen_mode_num(int type, int color, int mode)
+{
+ static struct {
+ int from;
+ int to_color;
+ int to_mono;
+ } mode_map[] = {
+ { M_TEXT_80x30, M_VGA_C80x30, M_VGA_M80x30, },
+ { M_TEXT_80x43, M_ENH_C80x43, M_ENH_B80x43, },
+ { M_TEXT_80x50, M_VGA_C80x50, M_VGA_M80x50, },
+ { M_TEXT_80x60, M_VGA_C80x60, M_VGA_M80x60, },
+ };
+ int i;
+
+ if (mode == M_TEXT_80x25) {
+ switch (type) {
+
+ case KD_VGA:
+ if (color)
+ return M_VGA_C80x25;
+ else
+ return M_VGA_M80x25;
+ break;
+
+ case KD_EGA:
+ if (color)
+ return M_ENH_C80x25;
+ else
+ return M_EGAMONO80x25;
+ break;
+
+ case KD_CGA:
+ return M_C80x25;
+
+ case KD_MONO:
+ case KD_HERCULES:
+ return M_EGAMONO80x25; /* XXX: this name is confusing */
+
+ default:
+ return -1;
+ }
+ }
+
+ for (i = 0; i < sizeof(mode_map)/sizeof(mode_map[0]); ++i) {
+ if (mode_map[i].from == mode)
+ return ((color) ? mode_map[i].to_color : mode_map[i].to_mono);
+ }
+ return mode;
+}
+
+/* turn the BIOS video number into our video mode number */
+static int
+map_bios_mode_num(int type, int color, int bios_mode)
+{
+ static int cga_modes[7] = {
+ M_B40x25, M_C40x25, /* 0, 1 */
+ M_B80x25, M_C80x25, /* 2, 3 */
+ M_BG320, M_CG320,
+ M_BG640,
+ };
+ static int ega_modes[17] = {
+ M_ENH_B40x25, M_ENH_C40x25, /* 0, 1 */
+ M_ENH_B80x25, M_ENH_C80x25, /* 2, 3 */
+ M_BG320, M_CG320,
+ M_BG640,
+ M_EGAMONO80x25, /* 7 */
+ 8, 9, 10, 11, 12,
+ M_CG320_D,
+ M_CG640_E,
+ M_ENHMONOAPA2, /* XXX: video momery > 64K */
+ M_ENH_CG640, /* XXX: video momery > 64K */
+ };
+ static int vga_modes[20] = {
+ M_VGA_C40x25, M_VGA_C40x25, /* 0, 1 */
+ M_VGA_C80x25, M_VGA_C80x25, /* 2, 3 */
+ M_BG320, M_CG320,
+ M_BG640,
+ M_VGA_M80x25, /* 7 */
+ 8, 9, 10, 11, 12,
+ M_CG320_D,
+ M_CG640_E,
+ M_ENHMONOAPA2,
+ M_ENH_CG640,
+ M_BG640x480, M_CG640x480,
+ M_VGA_CG320,
+ };
+
+ switch (type) {
+
+ case KD_VGA:
+ if (bios_mode < sizeof(vga_modes)/sizeof(vga_modes[0]))
+ return vga_modes[bios_mode];
+ else if (color)
+ return M_VGA_C80x25;
+ else
+ return M_VGA_M80x25;
+ break;
+
+ case KD_EGA:
+ if (bios_mode < sizeof(ega_modes)/sizeof(ega_modes[0]))
+ return ega_modes[bios_mode];
+ else if (color)
+ return M_ENH_C80x25;
+ else
+ return M_EGAMONO80x25;
+ break;
+
+ case KD_CGA:
+ if (bios_mode < sizeof(cga_modes)/sizeof(cga_modes[0]))
+ return cga_modes[bios_mode];
+ else
+ return M_C80x25;
+ break;
+
+ case KD_MONO:
+ case KD_HERCULES:
+ return M_EGAMONO80x25; /* XXX: this name is confusing */
+
+ default:
+ break;
+ }
+ return -1;
+}
+
+/* look up a parameter table entry */
+static u_char
+*get_mode_param(int mode)
+{
+#if !defined(VGA_NO_BIOS) && !defined(VGA_NO_MODE_CHANGE)
+ if (mode >= V_MODE_MAP_SIZE)
+ mode = map_mode_num(mode);
+#endif
+ if ((mode >= 0) && (mode < V_MODE_MAP_SIZE))
+ return mode_map[mode];
+ else
+ return NULL;
+}
+
+#ifndef VGA_NO_BIOS
+static void
+fill_adapter_param(int code, video_adapter_t *adp)
+{
+ static struct {
+ int primary;
+ int secondary;
+ } dcc[] = {
+ { DCC_MONO, DCC_EGA40 /* CGA monitor */ },
+ { DCC_MONO, DCC_EGA80 /* CGA monitor */ },
+ { DCC_MONO, DCC_EGA80 /* CGA emulation */ },
+ { DCC_MONO, DCC_EGA80 },
+ { DCC_CGA40, DCC_EGAMONO },
+ { DCC_CGA80, DCC_EGAMONO },
+ { DCC_EGA40 /* CGA monitor */, DCC_MONO},
+ { DCC_EGA80 /* CGA monitor */, DCC_MONO},
+ { DCC_EGA80 /* CGA emulation */,DCC_MONO },
+ { DCC_EGA80, DCC_MONO },
+ { DCC_EGAMONO, DCC_CGA40 },
+ { DCC_EGAMONO, DCC_CGA40 },
+ };
+
+ if ((code < 0) || (code >= sizeof(dcc)/sizeof(dcc[0]))) {
+ adp[V_ADP_PRIMARY] = adapter_init_value[DCC_MONO];
+ adp[V_ADP_SECONDARY] = adapter_init_value[DCC_CGA80];
+ } else {
+ adp[V_ADP_PRIMARY] = adapter_init_value[dcc[code].primary];
+ adp[V_ADP_SECONDARY] = adapter_init_value[dcc[code].secondary];
+ }
+}
+#endif /* VGA_NO_BIOS */
+
+static int
+verify_adapter(video_adapter_t *adp)
+{
+ vm_offset_t buf;
+ u_int16_t v;
+
+ buf = BIOS_PADDRTOVADDR(adp->va_window);
+ v = readw(buf);
+ writew(buf, 0xA55A);
+ if (readw(buf) != 0xA55A)
+ return 1;
+ writew(buf, v);
+
+ switch (adp->va_type) {
+
+ case KD_EGA:
+ outb(adp->va_crtc_addr, 7);
+ if (inb(adp->va_crtc_addr) == 7) {
+ adp->va_type = KD_VGA;
+ adp->va_name = "vga";
+ adp->va_flags |= V_ADP_STATESAVE | V_ADP_PALETTE;
+ }
+ adp->va_flags |= V_ADP_STATELOAD | V_ADP_BORDER;
+ /* the color adapter may be in the 40x25 mode... XXX */
+
+#if !defined(VGA_NO_BIOS) && !defined(VGA_NO_MODE_CHANGE)
+ /* get the BIOS video mode pointer */
+ p = *(u_int32_t *)BIOS_PADDRTOVADDR(0x4a8);
+ p = BIOS_SADDRTOLADDR(p);
+ if (ISMAPPED(p, sizeof(u_int32_t))) {
+ p = *(u_int32_t *)BIOS_PADDRTOVADDR(p);
+ p = BIOS_SADDRTOLADDR(p);
+ if (ISMAPPED(p, V_MODE_PARAM_SIZE))
+ video_mode_ptr = (u_char *)BIOS_PADDRTOVADDR(p);
+ }
+#endif
+ break;
+
+ case KD_CGA:
+ adp->va_flags |= V_ADP_COLOR | V_ADP_BORDER;
+ /* may be in the 40x25 mode... XXX */
+#if !defined(VGA_NO_BIOS) && !defined(VGA_NO_MODE_CHANGE)
+ /* get the BIOS video mode pointer */
+ p = *(u_int32_t *)BIOS_PADDRTOVADDR(0x1d*4);
+ p = BIOS_SADDRTOLADDR(p);
+ video_mode_ptr2 = (u_char *)BIOS_PADDRTOVADDR(p);
+#endif
+ break;
+
+ case KD_MONO:
+#if !defined(VGA_NO_BIOS) && !defined(VGA_NO_MODE_CHANGE)
+ /* get the BIOS video mode pointer */
+ p = *(u_int32_t *)BIOS_PADDRTOVADDR(0x1d*4);
+ p = BIOS_SADDRTOLADDR(p);
+ video_mode_ptr2 = (u_char *)BIOS_PADDRTOVADDR(p);
+#endif
+ break;
+ }
+
+ return 0;
+}
+
+#if !defined(VGA_NO_BIOS) && !defined(VGA_NO_MODE_CHANGE)
+/* compare two parameter table entries */
+static int
+comp_adpregs(u_char *buf1, u_char *buf2)
+{
+ static struct {
+ u_char mask;
+ } params[V_MODE_PARAM_SIZE] = {
+ 0xff, 0x00, 0xff, /* COLS, ROWS, POINTS */
+ 0x00, 0x00, /* page length */
+ 0xfe, 0xff, 0xff, 0xff, /* sequencer registers */
+ 0xf3, /* misc register */
+ 0xff, 0xff, 0xff, 0x7f, 0xff, /* CRTC */
+ 0xff, 0xff, 0xff, 0x7f, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xff, 0x7f, 0xff, 0xff,
+ 0x7f, 0xff, 0xff, 0xef, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, /* attribute controller registers */
+ 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xf0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, /* GDC register */
+ 0xff, 0xff, 0xff, 0xff,
+ };
+ int identical = TRUE;
+ int i;
+
+ if ((buf1 == NULL) || (buf2 == NULL))
+ return COMP_DIFFERENT;
+
+ for (i = 0; i < sizeof(params)/sizeof(params[0]); ++i) {
+ if (params[i].mask == 0) /* don't care */
+ continue;
+ if ((buf1[i] & params[i].mask) != (buf2[i] & params[i].mask))
+ return COMP_DIFFERENT;
+ if (buf1[i] != buf2[i])
+ identical = FALSE;
+ }
+ return (identical) ? COMP_IDENTICAL : COMP_SIMILAR;
+}
+#endif /* !VGA_NO_BIOS && !VGA_NO_MODE_CHANGE */
+
+/* probe video adapters and return the number of detected adapters */
+static int
+probe_adapters(void)
+{
+ video_adapter_t *adp;
+ video_info_t info;
+ int i;
+
+ /* do this test only once */
+ if (init_done)
+ return biosadapters;
+ init_done = TRUE;
+
+ /*
+ * Locate display adapters.
+ * The AT architecture supports upto two adapters. `syscons' allows
+ * the following combinations of adapters:
+ * 1) MDA + CGA
+ * 2) MDA + EGA/VGA color
+ * 3) CGA + EGA/VGA mono
+ * Note that `syscons' doesn't bother with MCGA as it is only
+ * avaiable for low end PS/2 models which has 80286 or earlier CPUs,
+ * thus, they are not running FreeBSD!
+ * When there are two adapaters in the system, one becomes `primary'
+ * and the other `secondary'. The EGA adapter has a set of DIP
+ * switches on board for this information and the EGA BIOS copies
+ * it in the BIOS data area BIOSDATA_VIDEOSWITCH (40:88).
+ * The VGA BIOS has more sophisticated mechanism and has this
+ * information in BIOSDATA_DCCINDEX (40:8a), but it also maintains
+ * compatibility with the EGA BIOS by updating BIOSDATA_VIDEOSWITCH.
+ */
+
+ /*
+ * Check rtc and BIOS data area.
+ * XXX: we don't use BIOSDATA_EQUIPMENT, since it is not a dead
+ * copy of RTC_EQUIPMENT. Bits 4 and 5 of ETC_EQUIPMENT are
+ * zeros for EGA and VGA. However, the EGA/VGA BIOS sets
+ * these bits in BIOSDATA_EQUIPMENT according to the monitor
+ * type detected.
+ */
+#ifndef VGA_NO_BIOS
+ switch ((rtcin(RTC_EQUIPMENT) >> 4) & 3) { /* bit 4 and 5 */
+ case 0:
+ /* EGA/VGA */
+ fill_adapter_param(readb(BIOS_PADDRTOVADDR(0x488)) & 0x0f,
+ biosadapter);
+ break;
+ case 1:
+ /* CGA 40x25 */
+ /* FIXME: switch to the 80x25 mode? XXX */
+ biosadapter[V_ADP_PRIMARY] = adapter_init_value[DCC_CGA40];
+ biosadapter[V_ADP_SECONDARY] = adapter_init_value[DCC_MONO];
+ break;
+ case 2:
+ /* CGA 80x25 */
+ biosadapter[V_ADP_PRIMARY] = adapter_init_value[DCC_CGA80];
+ biosadapter[V_ADP_SECONDARY] = adapter_init_value[DCC_MONO];
+ break;
+ case 3:
+ /* MDA */
+ biosadapter[V_ADP_PRIMARY] = adapter_init_value[DCC_MONO];
+ biosadapter[V_ADP_SECONDARY] = adapter_init_value[DCC_CGA80];
+ break;
+ }
+#else
+ /* assume EGA/VGA? XXX */
+ biosadapter[V_ADP_PRIMARY] = adapter_init_value[DCC_EGA80];
+ biosadapter[V_ADP_SECONDARY] = adapter_init_value[DCC_MONO];
+#endif /* VGA_NO_BIOS */
+
+ biosadapters = 0;
+ if (verify_adapter(&biosadapter[V_ADP_SECONDARY]) == 0) {
+ ++biosadapters;
+ biosadapter[V_ADP_SECONDARY].va_flags |= V_ADP_PROBED;
+ biosadapter[V_ADP_SECONDARY].va_mode =
+ biosadapter[V_ADP_SECONDARY].va_initial_mode =
+ map_bios_mode_num(biosadapter[V_ADP_SECONDARY].va_type,
+ biosadapter[V_ADP_SECONDARY].va_flags
+ & V_ADP_COLOR,
+ biosadapter[V_ADP_SECONDARY].va_initial_bios_mode);
+ } else {
+ biosadapter[V_ADP_SECONDARY].va_type = -1;
+ }
+ if (verify_adapter(&biosadapter[V_ADP_PRIMARY]) == 0) {
+ ++biosadapters;
+ biosadapter[V_ADP_PRIMARY].va_flags |= V_ADP_PROBED;
+#ifndef VGA_NO_BIOS
+ biosadapter[V_ADP_PRIMARY].va_initial_bios_mode =
+ readb(BIOS_PADDRTOVADDR(0x449));
+#else
+ biosadapter[V_ADP_PRIMARY].va_initial_bios_mode = 3; /* XXX */
+#endif
+ biosadapter[V_ADP_PRIMARY].va_mode =
+ biosadapter[V_ADP_PRIMARY].va_initial_mode =
+ map_bios_mode_num(biosadapter[V_ADP_PRIMARY].va_type,
+ biosadapter[V_ADP_PRIMARY].va_flags & V_ADP_COLOR,
+ biosadapter[V_ADP_PRIMARY].va_initial_bios_mode);
+ } else {
+ biosadapter[V_ADP_PRIMARY] = biosadapter[V_ADP_SECONDARY];
+ biosadapter[V_ADP_SECONDARY].va_type = -1;
+ }
+ if (biosadapters == 0)
+ return biosadapters;
+#if 0
+ biosadapter[V_ADP_PRIMARY].va_index = V_ADP_PRIMARY;
+ biosadapter[V_ADP_SECONDARY].va_index = V_ADP_SECONDARY;
+#endif
+ biosadapter[V_ADP_PRIMARY].va_unit = V_ADP_PRIMARY;
+ biosadapter[V_ADP_SECONDARY].va_unit = V_ADP_SECONDARY;
+
+#if 0 /* we don't need these... */
+ fb_init_struct(&biosadapter[V_ADP_PRIMARY], ...);
+ fb_init_struct(&biosadapter[V_ADP_SECONDARY], ...);
+#endif
+
+#if 0
+ /*
+ * We cannot have two video adapter of the same type; there must be
+ * only one of color or mono adapter, or one each of them.
+ */
+ if (biosadapters > 1) {
+ if (!((biosadapter[0].va_flags ^ biosadapter[1].va_flags)
+ & V_ADP_COLOR))
+ /* we have two mono or color adapters!! */
+ return (biosadapters = 0);
+ }
+#endif
+
+ /*
+ * Ensure a zero start address. This is mainly to recover after
+ * switching from pcvt using userconfig(). The registers are w/o
+ * for old hardware so it's too hard to relocate the active screen
+ * memory.
+ * This must be done before vga_save_state() for VGA.
+ */
+ outb(biosadapter[V_ADP_PRIMARY].va_crtc_addr, 12);
+ outb(biosadapter[V_ADP_PRIMARY].va_crtc_addr + 1, 0);
+ outb(biosadapter[V_ADP_PRIMARY].va_crtc_addr, 13);
+ outb(biosadapter[V_ADP_PRIMARY].va_crtc_addr + 1, 0);
+
+ /* the video mode parameter table in EGA/VGA BIOS */
+ /* NOTE: there can be only one EGA/VGA, wheather color or mono,
+ * recognized by the video BIOS.
+ */
+ if ((biosadapter[V_ADP_PRIMARY].va_type == KD_EGA) ||
+ (biosadapter[V_ADP_PRIMARY].va_type == KD_VGA)) {
+ adp = &biosadapter[V_ADP_PRIMARY];
+ } else if ((biosadapter[V_ADP_SECONDARY].va_type == KD_EGA) ||
+ (biosadapter[V_ADP_SECONDARY].va_type == KD_VGA)) {
+ adp = &biosadapter[V_ADP_SECONDARY];
+ } else {
+ adp = NULL;
+ }
+ bzero(mode_map, sizeof(mode_map));
+ if (adp != NULL) {
+ if (adp->va_type == KD_VGA) {
+ vga_save_state(adp, &adpstate, sizeof(adpstate));
+#if defined(VGA_NO_BIOS) || defined(VGA_NO_MODE_CHANGE)
+ mode_map[adp->va_initial_mode] = adpstate.regs;
+ rows_offset = 1;
+#else /* VGA_NO_BIOS || VGA_NO_MODE_CHANGE */
+ if (video_mode_ptr == NULL) {
+ mode_map[adp->va_initial_mode] = adpstate.regs;
+ rows_offset = 1;
+ } else {
+ /* discard the table if we are not familiar with it... */
+ map_mode_table(mode_map, video_mode_ptr, M_VGA_CG320 + 1);
+ mp = get_mode_param(adp->va_initial_mode);
+ if (mp != NULL)
+ bcopy(mp, adpstate2.regs, sizeof(adpstate2.regs));
+ switch (comp_adpregs(adpstate.regs, mp)) {
+ case COMP_IDENTICAL:
+ /*
+ * OK, this parameter table looks reasonably familiar
+ * to us...
+ */
+ /*
+ * This is a kludge for Toshiba DynaBook SS433
+ * whose BIOS video mode table entry has the actual #
+ * of rows at the offset 1; BIOSes from other
+ * manufacturers store the # of rows - 1 there. XXX
+ */
+ rows_offset = adpstate.regs[1] + 1 - mp[1];
+ break;
+
+ case COMP_SIMILAR:
+ /*
+ * Not exactly the same, but similar enough to be
+ * trusted. However, use the saved register values
+ * for the initial mode and other modes which are
+ * based on the initial mode.
+ */
+ mode_map[adp->va_initial_mode] = adpstate.regs;
+ rows_offset = adpstate.regs[1] + 1 - mp[1];
+ adpstate.regs[1] -= rows_offset - 1;
+ break;
+
+ case COMP_DIFFERENT:
+ default:
+ /*
+ * Don't use the paramter table in BIOS. It doesn't
+ * look familiar to us. Video mode switching is allowed
+ * only if the new mode is the same as or based on
+ * the initial mode.
+ */
+ video_mode_ptr = NULL;
+ bzero(mode_map, sizeof(mode_map));
+ mode_map[adp->va_initial_mode] = adpstate.regs;
+ rows_offset = 1;
+ break;
+ }
+ }
+#endif /* VGA_NO_BIOS || VGA_NO_MODE_CHANGE */
+
+#ifndef VGA_NO_MODE_CHANGE
+ adp->va_flags |= V_ADP_MODECHANGE;
+#endif
+#ifndef VGA_NO_FONT_LOADING
+ adp->va_flags |= V_ADP_FONT;
+#endif
+ } else if (adp->va_type == KD_EGA) {
+#if defined(VGA_NO_BIOS) || defined(VGA_NO_MODE_CHANGE)
+ rows_offset = 1;
+#else /* VGA_NO_BIOS || VGA_NO_MODE_CHANGE */
+ if (video_mode_ptr == NULL) {
+ rows_offset = 1;
+ } else {
+ map_mode_table(mode_map, video_mode_ptr, M_ENH_C80x25 + 1);
+ /* XXX how can one validate the EGA table... */
+ mp = get_mode_param(adp->va_initial_mode);
+ if (mp != NULL) {
+ adp->va_flags |= V_ADP_MODECHANGE;
+#ifndef VGA_NO_FONT_LOADING
+ adp->va_flags |= V_ADP_FONT;
+#endif
+ rows_offset = 1;
+ } else {
+ /*
+ * This is serious. We will not be able to switch video
+ * modes at all...
+ */
+ video_mode_ptr = NULL;
+ bzero(mode_map, sizeof(mode_map));
+ rows_offset = 1;
+ }
+ }
+#endif /* VGA_NO_BIOS || VGA_NO_MODE_CHANGE */
+ }
+ }
+
+ /* remove conflicting modes if we have more than one adapter */
+ if (biosadapters > 1) {
+ for (i = 0; i < biosadapters; ++i) {
+ if (!(biosadapter[i].va_flags & V_ADP_MODECHANGE))
+ continue;
+ clear_mode_map(&biosadapter[i], mode_map, M_VGA_CG320 + 1,
+ (biosadapter[i].va_flags & V_ADP_COLOR) ?
+ V_INFO_COLOR : 0);
+ if ((biosadapter[i].va_type == KD_VGA)
+ || (biosadapter[i].va_type == KD_EGA)) {
+ biosadapter[i].va_io_base =
+ (biosadapter[i].va_flags & V_ADP_COLOR) ?
+ IO_VGA : IO_MDA;
+ biosadapter[i].va_io_size = 32;
+ }
+ }
+ }
+
+ /* buffer address */
+ vga_get_info(&biosadapter[V_ADP_PRIMARY],
+ biosadapter[V_ADP_PRIMARY].va_initial_mode, &info);
+ biosadapter[V_ADP_PRIMARY].va_mode_flags = info.vi_flags;
+ biosadapter[V_ADP_PRIMARY].va_window = BIOS_PADDRTOVADDR(info.vi_window);
+ biosadapter[V_ADP_PRIMARY].va_window_size = info.vi_window_size;
+ biosadapter[V_ADP_PRIMARY].va_window_gran = info.vi_window_gran;
+ if (info.vi_buffer_size == 0) {
+ biosadapter[V_ADP_PRIMARY].va_buffer = 0;
+ biosadapter[V_ADP_PRIMARY].va_buffer_size = 0;
+ } else {
+ biosadapter[V_ADP_PRIMARY].va_buffer
+ = BIOS_PADDRTOVADDR(info.vi_buffer);
+ biosadapter[V_ADP_PRIMARY].va_buffer_size = info.vi_buffer_size;
+ }
+
+ if (biosadapters > 1) {
+ vga_get_info(&biosadapter[V_ADP_SECONDARY],
+ biosadapter[V_ADP_SECONDARY].va_initial_mode, &info);
+ biosadapter[V_ADP_SECONDARY].va_mode_flags = info.vi_flags;
+ biosadapter[V_ADP_SECONDARY].va_window =
+ BIOS_PADDRTOVADDR(info.vi_window);
+ biosadapter[V_ADP_SECONDARY].va_window_size = info.vi_window_size;
+ biosadapter[V_ADP_SECONDARY].va_window_gran = info.vi_window_gran;
+ if (info.vi_buffer_size == 0) {
+ biosadapter[V_ADP_SECONDARY].va_buffer = 0;
+ biosadapter[V_ADP_SECONDARY].va_buffer_size = 0;
+ } else {
+ biosadapter[V_ADP_SECONDARY].va_buffer =
+ BIOS_PADDRTOVADDR(info.vi_buffer);
+ biosadapter[V_ADP_SECONDARY].va_buffer_size = info.vi_buffer_size;
+ }
+ }
+
+ /*
+ * XXX: we should verify the following values for the primary adapter...
+ * crtc I/O port address: *(u_int16_t *)BIOS_PADDRTOVADDR(0x463);
+ * color/mono display: (*(u_int8_t *)BIOS_PADDRTOVADDR(0x487) & 0x02)
+ * ? 0 : V_ADP_COLOR;
+ * columns: *(u_int8_t *)BIOS_PADDRTOVADDR(0x44a);
+ * rows: *(u_int8_t *)BIOS_PADDRTOVADDR(0x484);
+ * font size: *(u_int8_t *)BIOS_PADDRTOVADDR(0x485);
+ * buffer size: *(u_int16_t *)BIOS_PADDRTOVADDR(0x44c);
+ */
+
+ return biosadapters;
+}
+
+/* entry points */
+
+static int
+vga_nop(void)
+{
+ return 0;
+}
+
+static int
+vga_probe(int unit, video_adapter_t **adpp, void *arg, int flags)
+{
+ probe_adapters();
+ if (unit >= biosadapters)
+ return ENXIO;
+
+ *adpp = &biosadapter[unit];
+
+ return 0;
+}
+
+static int
+vga_init(int unit, video_adapter_t *adp, int flags)
+{
+ if ((unit >= biosadapters) || (adp == NULL) || !probe_done(adp))
+ return ENXIO;
+
+ if (!init_done(adp)) {
+ /* nothing to do really... */
+ adp->va_flags |= V_ADP_INITIALIZED;
+ }
+
+ if (!config_done(adp)) {
+ if (vid_register(adp) < 0)
+ return ENXIO;
+ adp->va_flags |= V_ADP_REGISTERED;
+ }
+ if (vga_sub_configure != NULL)
+ (*vga_sub_configure)(0);
+
+ return 0;
+}
+
+/*
+ * get_info():
+ * Return the video_info structure of the requested video mode.
+ *
+ * all adapters
+ */
+static int
+vga_get_info(video_adapter_t *adp, int mode, video_info_t *info)
+{
+ int i;
+
+ if (!init_done)
+ return 1;
+
+ mode = map_gen_mode_num(adp->va_type, adp->va_flags & V_ADP_COLOR, mode);
+#ifndef VGA_NO_MODE_CHANGE
+ if (adp->va_flags & V_ADP_MODECHANGE) {
+ /*
+ * If the parameter table entry for this mode is not found,
+ * the mode is not supported...
+ */
+ if (get_mode_param(mode) == NULL)
+ return 1;
+ } else
+#endif /* VGA_NO_MODE_CHANGE */
+ {
+ /*
+ * Even if we don't support video mode switching on this adapter,
+ * the information on the initial (thus current) video mode
+ * should be made available.
+ */
+ if (mode != adp->va_initial_mode)
+ return 1;
+ }
+
+ for (i = 0; bios_vmode[i].vi_mode != EOT; ++i) {
+ if (bios_vmode[i].vi_mode == NA)
+ continue;
+ if (mode == bios_vmode[i].vi_mode) {
+ *info = bios_vmode[i];
+ return 0;
+ }
+ }
+ return 1;
+}
+
+/*
+ * query_mode():
+ * Find a video mode matching the requested parameters.
+ * Fields filled with 0 are considered "don't care" fields and
+ * match any modes.
+ *
+ * all adapters
+ */
+static int
+vga_query_mode(video_adapter_t *adp, video_info_t *info)
+{
+ video_info_t buf;
+ int i;
+
+ if (!init_done)
+ return -1;
+
+ for (i = 0; bios_vmode[i].vi_mode != EOT; ++i) {
+ if (bios_vmode[i].vi_mode == NA)
+ continue;
+
+ if ((info->vi_width != 0)
+ && (info->vi_width != bios_vmode[i].vi_width))
+ continue;
+ if ((info->vi_height != 0)
+ && (info->vi_height != bios_vmode[i].vi_height))
+ continue;
+ if ((info->vi_cwidth != 0)
+ && (info->vi_cwidth != bios_vmode[i].vi_cwidth))
+ continue;
+ if ((info->vi_cheight != 0)
+ && (info->vi_cheight != bios_vmode[i].vi_cheight))
+ continue;
+ if ((info->vi_depth != 0)
+ && (info->vi_depth != bios_vmode[i].vi_depth))
+ continue;
+ if ((info->vi_planes != 0)
+ && (info->vi_planes != bios_vmode[i].vi_planes))
+ continue;
+ /* XXX: should check pixel format, memory model */
+ if ((info->vi_flags != 0)
+ && (info->vi_flags != bios_vmode[i].vi_flags))
+ continue;
+
+ /* verify if this mode is supported on this adapter */
+ if (vga_get_info(adp, bios_vmode[i].vi_mode, &buf))
+ continue;
+ return bios_vmode[i].vi_mode;
+ }
+ return -1;
+}
+
+/*
+ * set_mode():
+ * Change the video mode.
+ *
+ * EGA/VGA
+ */
+static int
+vga_set_mode(video_adapter_t *adp, int mode)
+{
+#ifndef VGA_NO_MODE_CHANGE
+ video_info_t info;
+ adp_state_t params;
+
+ prologue(adp, V_ADP_MODECHANGE, 1);
+
+ mode = map_gen_mode_num(adp->va_type,
+ adp->va_flags & V_ADP_COLOR, mode);
+ if (vga_get_info(adp, mode, &info))
+ return 1;
+ params.sig = V_STATE_SIG;
+ bcopy(get_mode_param(mode), params.regs, sizeof(params.regs));
+
+ switch (mode) {
+ case M_VGA_C80x60: case M_VGA_M80x60:
+ params.regs[2] = 0x08;
+ params.regs[19] = 0x47;
+ goto special_480l;
+
+ case M_VGA_C80x30: case M_VGA_M80x30:
+ params.regs[19] = 0x4f;
+special_480l:
+ params.regs[9] |= 0xc0;
+ params.regs[16] = 0x08;
+ params.regs[17] = 0x3e;
+ params.regs[26] = 0xea;
+ params.regs[28] = 0xdf;
+ params.regs[31] = 0xe7;
+ params.regs[32] = 0x04;
+ goto setup_mode;
+
+ case M_ENH_C80x43: case M_ENH_B80x43:
+ params.regs[28] = 87;
+ goto special_80x50;
+
+ case M_VGA_C80x50: case M_VGA_M80x50:
+special_80x50:
+ params.regs[2] = 8;
+ params.regs[19] = 7;
+ goto setup_mode;
+
+ case M_VGA_C40x25: case M_VGA_C80x25:
+ case M_VGA_M80x25:
+ case M_B40x25: case M_C40x25:
+ case M_B80x25: case M_C80x25:
+ case M_ENH_B40x25: case M_ENH_C40x25:
+ case M_ENH_B80x25: case M_ENH_C80x25:
+ case M_EGAMONO80x25:
+
+setup_mode:
+ vga_load_state(adp, &params);
+ break;
+
+ case M_VGA_MODEX:
+ /* "unchain" the VGA mode */
+ params.regs[5-1+0x04] &= 0xf7;
+ params.regs[5-1+0x04] |= 0x04;
+ /* turn off doubleword mode */
+ params.regs[10+0x14] &= 0xbf;
+ /* turn off word adressing */
+ params.regs[10+0x17] |= 0x40;
+ /* set logical screen width */
+ params.regs[10+0x13] = 80;
+ /* set 240 lines */
+ params.regs[10+0x11] = 0x2c;
+ params.regs[10+0x06] = 0x0d;
+ params.regs[10+0x07] = 0x3e;
+ params.regs[10+0x10] = 0xea;
+ params.regs[10+0x11] = 0xac;
+ params.regs[10+0x12] = 0xdf;
+ params.regs[10+0x15] = 0xe7;
+ params.regs[10+0x16] = 0x06;
+ /* set vertical sync polarity to reflect aspect ratio */
+ params.regs[9] = 0xe3;
+ goto setup_grmode;
+
+ case M_BG320: case M_CG320: case M_BG640:
+ case M_CG320_D: case M_CG640_E:
+ case M_CG640x350: case M_ENH_CG640:
+ case M_BG640x480: case M_CG640x480: case M_VGA_CG320:
+
+setup_grmode:
+ vga_load_state(adp, &params);
+ break;
+
+ default:
+ return 1;
+ }
+
+ adp->va_mode = mode;
+ adp->va_mode_flags = info.vi_flags;
+ adp->va_flags &= ~V_ADP_COLOR;
+ adp->va_flags |=
+ (info.vi_flags & V_INFO_COLOR) ? V_ADP_COLOR : 0;
+ adp->va_crtc_addr =
+ (adp->va_flags & V_ADP_COLOR) ? COLOR_CRTC : MONO_CRTC;
+ adp->va_window = BIOS_PADDRTOVADDR(info.vi_window);
+ adp->va_window_size = info.vi_window_size;
+ adp->va_window_gran = info.vi_window_gran;
+ if (info.vi_buffer_size == 0) {
+ adp->va_buffer = 0;
+ adp->va_buffer_size = 0;
+ } else {
+ adp->va_buffer = BIOS_PADDRTOVADDR(info.vi_buffer);
+ adp->va_buffer_size = info.vi_buffer_size;
+ }
+
+ /* move hardware cursor out of the way */
+ (*vidsw[adp->va_index]->set_hw_cursor)(adp, -1, -1);
+
+ return 0;
+#else /* VGA_NO_MODE_CHANGE */
+ return 1;
+#endif /* VGA_NO_MODE_CHANGE */
+}
+
+#ifndef VGA_NO_FONT_LOADING
+
+static void
+set_font_mode(video_adapter_t *adp, u_char *buf)
+{
+ u_char *mp;
+ int s;
+
+ s = splhigh();
+
+ /* save register values */
+ if (adp->va_type == KD_VGA) {
+ outb(TSIDX, 0x02); buf[0] = inb(TSREG);
+ outb(TSIDX, 0x04); buf[1] = inb(TSREG);
+ outb(GDCIDX, 0x04); buf[2] = inb(GDCREG);
+ outb(GDCIDX, 0x05); buf[3] = inb(GDCREG);
+ outb(GDCIDX, 0x06); buf[4] = inb(GDCREG);
+ inb(adp->va_crtc_addr + 6);
+ outb(ATC, 0x10); buf[5] = inb(ATC + 1);
+ } else /* if (adp->va_type == KD_EGA) */ {
+ /*
+ * EGA cannot be read; copy parameters from the mode parameter
+ * table.
+ */
+ mp = get_mode_param(adp->va_mode);
+ buf[0] = mp[5 + 0x02 - 1];
+ buf[1] = mp[5 + 0x04 - 1];
+ buf[2] = mp[55 + 0x04];
+ buf[3] = mp[55 + 0x05];
+ buf[4] = mp[55 + 0x06];
+ buf[5] = mp[35 + 0x10];
+ }
+
+ /* setup vga for loading fonts */
+ inb(adp->va_crtc_addr + 6); /* reset flip-flop */
+ outb(ATC, 0x10); outb(ATC, buf[5] & ~0x01);
+ inb(adp->va_crtc_addr + 6); /* reset flip-flop */
+ outb(ATC, 0x20); /* enable palette */
+
+#if VGA_SLOW_IOACCESS
+#ifdef VGA_ALT_SEQACCESS
+ outb(TSIDX, 0x00); outb(TSREG, 0x01);
+#endif
+ outb(TSIDX, 0x02); outb(TSREG, 0x04);
+ outb(TSIDX, 0x04); outb(TSREG, 0x07);
+#ifdef VGA_ALT_SEQACCESS
+ outb(TSIDX, 0x00); outb(TSREG, 0x03);
+#endif
+ outb(GDCIDX, 0x04); outb(GDCREG, 0x02);
+ outb(GDCIDX, 0x05); outb(GDCREG, 0x00);
+ outb(GDCIDX, 0x06); outb(GDCREG, 0x04);
+#else /* VGA_SLOW_IOACCESS */
+#ifdef VGA_ALT_SEQACCESS
+ outw(TSIDX, 0x0100);
+#endif
+ outw(TSIDX, 0x0402);
+ outw(TSIDX, 0x0704);
+#ifdef VGA_ALT_SEQACCESS
+ outw(TSIDX, 0x0300);
+#endif
+ outw(GDCIDX, 0x0204);
+ outw(GDCIDX, 0x0005);
+ outw(GDCIDX, 0x0406); /* addr = a0000, 64kb */
+#endif /* VGA_SLOW_IOACCESS */
+
+ splx(s);
+}
+
+static void
+set_normal_mode(video_adapter_t *adp, u_char *buf)
+{
+ int s;
+
+ s = splhigh();
+
+ /* setup vga for normal operation mode again */
+ inb(adp->va_crtc_addr + 6); /* reset flip-flop */
+ outb(ATC, 0x10); outb(ATC, buf[5]);
+ inb(adp->va_crtc_addr + 6); /* reset flip-flop */
+ outb(ATC, 0x20); /* enable palette */
+
+#if VGA_SLOW_IOACCESS
+#ifdef VGA_ALT_SEQACCESS
+ outb(TSIDX, 0x00); outb(TSREG, 0x01);
+#endif
+ outb(TSIDX, 0x02); outb(TSREG, buf[0]);
+ outb(TSIDX, 0x04); outb(TSREG, buf[1]);
+#ifdef VGA_ALT_SEQACCESS
+ outb(TSIDX, 0x00); outb(TSREG, 0x03);
+#endif
+ outb(GDCIDX, 0x04); outb(GDCREG, buf[2]);
+ outb(GDCIDX, 0x05); outb(GDCREG, buf[3]);
+ if (adp->va_crtc_addr == MONO_CRTC) {
+ outb(GDCIDX, 0x06); outb(GDCREG,(buf[4] & 0x03) | 0x08);
+ } else {
+ outb(GDCIDX, 0x06); outb(GDCREG,(buf[4] & 0x03) | 0x0c);
+ }
+#else /* VGA_SLOW_IOACCESS */
+#ifdef VGA_ALT_SEQACCESS
+ outw(TSIDX, 0x0100);
+#endif
+ outw(TSIDX, 0x0002 | (buf[0] << 8));
+ outw(TSIDX, 0x0004 | (buf[1] << 8));
+#ifdef VGA_ALT_SEQACCESS
+ outw(TSIDX, 0x0300);
+#endif
+ outw(GDCIDX, 0x0004 | (buf[2] << 8));
+ outw(GDCIDX, 0x0005 | (buf[3] << 8));
+ if (adp->va_crtc_addr == MONO_CRTC)
+ outw(GDCIDX, 0x0006 | (((buf[4] & 0x03) | 0x08)<<8));
+ else
+ outw(GDCIDX, 0x0006 | (((buf[4] & 0x03) | 0x0c)<<8));
+#endif /* VGA_SLOW_IOACCESS */
+
+ splx(s);
+}
+
+#endif /* VGA_NO_FONT_LOADING */
+
+/*
+ * save_font():
+ * Read the font data in the requested font page from the video adapter.
+ *
+ * EGA/VGA
+ */
+static int
+vga_save_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
+ int ch, int count)
+{
+#ifndef VGA_NO_FONT_LOADING
+ u_char buf[PARAM_BUFSIZE];
+ u_int32_t segment;
+ int c;
+#ifdef VGA_ALT_SEQACCESS
+ int s;
+ u_char val = 0;
+#endif
+
+ prologue(adp, V_ADP_FONT, 1);
+
+ if (fontsize < 14) {
+ /* FONT_8 */
+ fontsize = 8;
+ } else if (fontsize >= 32) {
+ fontsize = 32;
+ } else if (fontsize >= 16) {
+ /* FONT_16 */
+ fontsize = 16;
+ } else {
+ /* FONT_14 */
+ fontsize = 14;
+ }
+
+ if (page < 0 || page >= 8)
+ return 1;
+ segment = FONT_BUF + 0x4000*page;
+ if (page > 3)
+ segment -= 0xe000;
+
+#ifdef VGA_ALT_SEQACCESS
+ if (adp->va_type == KD_VGA) { /* what about EGA? XXX */
+ s = splhigh();
+ outb(TSIDX, 0x00); outb(TSREG, 0x01);
+ outb(TSIDX, 0x01); val = inb(TSREG); /* disable screen */
+ outb(TSIDX, 0x01); outb(TSREG, val | 0x20);
+ outb(TSIDX, 0x00); outb(TSREG, 0x03);
+ splx(s);
+ }
+#endif
+
+ set_font_mode(adp, buf);
+ if (fontsize == 32) {
+ bcopy_fromio(segment + ch*32, data, fontsize*count);
+ } else {
+ for (c = ch; count > 0; ++c, --count) {
+ bcopy_fromio(segment + c*32, data, fontsize);
+ data += fontsize;
+ }
+ }
+ set_normal_mode(adp, buf);
+
+#ifdef VGA_ALT_SEQACCESS
+ if (adp->va_type == KD_VGA) {
+ s = splhigh();
+ outb(TSIDX, 0x00); outb(TSREG, 0x01);
+ outb(TSIDX, 0x01); outb(TSREG, val & 0xdf); /* enable screen */
+ outb(TSIDX, 0x00); outb(TSREG, 0x03);
+ splx(s);
+ }
+#endif
+
+ return 0;
+#else /* VGA_NO_FONT_LOADING */
+ return 1;
+#endif /* VGA_NO_FONT_LOADING */
+}
+
+/*
+ * load_font():
+ * Set the font data in the requested font page.
+ * NOTE: it appears that some recent video adapters do not support
+ * the font page other than 0... XXX
+ *
+ * EGA/VGA
+ */
+static int
+vga_load_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
+ int ch, int count)
+{
+#ifndef VGA_NO_FONT_LOADING
+ u_char buf[PARAM_BUFSIZE];
+ u_int32_t segment;
+ int c;
+#ifdef VGA_ALT_SEQACCESS
+ int s;
+ u_char val = 0;
+#endif
+
+ prologue(adp, V_ADP_FONT, 1);
+
+ if (fontsize < 14) {
+ /* FONT_8 */
+ fontsize = 8;
+ } else if (fontsize >= 32) {
+ fontsize = 32;
+ } else if (fontsize >= 16) {
+ /* FONT_16 */
+ fontsize = 16;
+ } else {
+ /* FONT_14 */
+ fontsize = 14;
+ }
+
+ if (page < 0 || page >= 8)
+ return 1;
+ segment = FONT_BUF + 0x4000*page;
+ if (page > 3)
+ segment -= 0xe000;
+
+#ifdef VGA_ALT_SEQACCESS
+ if (adp->va_type == KD_VGA) { /* what about EGA? XXX */
+ s = splhigh();
+ outb(TSIDX, 0x00); outb(TSREG, 0x01);
+ outb(TSIDX, 0x01); val = inb(TSREG); /* disable screen */
+ outb(TSIDX, 0x01); outb(TSREG, val | 0x20);
+ outb(TSIDX, 0x00); outb(TSREG, 0x03);
+ splx(s);
+ }
+#endif
+
+ set_font_mode(adp, buf);
+ if (fontsize == 32) {
+ bcopy_toio(data, segment + ch*32, fontsize*count);
+ } else {
+ for (c = ch; count > 0; ++c, --count) {
+ bcopy_toio(data, segment + c*32, fontsize);
+ data += fontsize;
+ }
+ }
+ set_normal_mode(adp, buf);
+
+#ifdef VGA_ALT_SEQACCESS
+ if (adp->va_type == KD_VGA) {
+ s = splhigh();
+ outb(TSIDX, 0x00); outb(TSREG, 0x01);
+ outb(TSIDX, 0x01); outb(TSREG, val & 0xdf); /* enable screen */
+ outb(TSIDX, 0x00); outb(TSREG, 0x03);
+ splx(s);
+ }
+#endif
+
+ return 0;
+#else /* VGA_NO_FONT_LOADING */
+ return 1;
+#endif /* VGA_NO_FONT_LOADING */
+}
+
+/*
+ * show_font():
+ * Activate the requested font page.
+ * NOTE: it appears that some recent video adapters do not support
+ * the font page other than 0... XXX
+ *
+ * EGA/VGA
+ */
+static int
+vga_show_font(video_adapter_t *adp, int page)
+{
+#ifndef VGA_NO_FONT_LOADING
+ static u_char cg[] = { 0x00, 0x05, 0x0a, 0x0f, 0x30, 0x35, 0x3a, 0x3f };
+ int s;
+
+ prologue(adp, V_ADP_FONT, 1);
+ if (page < 0 || page >= 8)
+ return 1;
+
+ s = splhigh();
+ outb(TSIDX, 0x03); outb(TSREG, cg[page]);
+ splx(s);
+
+ return 0;
+#else /* VGA_NO_FONT_LOADING */
+ return 1;
+#endif /* VGA_NO_FONT_LOADING */
+}
+
+/*
+ * save_palette():
+ * Read DAC values. The values have expressed in 8 bits.
+ *
+ * VGA
+ */
+static int
+vga_save_palette(video_adapter_t *adp, u_char *palette)
+{
+ int i;
+
+ prologue(adp, V_ADP_PALETTE, 1);
+
+ /*
+ * We store 8 bit values in the palette buffer, while the standard
+ * VGA has 6 bit DAC .
+ */
+ outb(PALRADR, 0x00);
+ for (i = 0; i < 256*3; ++i)
+ palette[i] = inb(PALDATA) << 2;
+ inb(adp->va_crtc_addr + 6); /* reset flip/flop */
+ return 0;
+}
+
+/*
+ * load_palette():
+ * Set DAC values.
+ *
+ * VGA
+ */
+static int
+vga_load_palette(video_adapter_t *adp, u_char *palette)
+{
+ int i;
+
+ prologue(adp, V_ADP_PALETTE, 1);
+
+ outb(PIXMASK, 0xff); /* no pixelmask */
+ outb(PALWADR, 0x00);
+ for (i = 0; i < 256*3; ++i)
+ outb(PALDATA, palette[i] >> 2);
+ inb(adp->va_crtc_addr + 6); /* reset flip/flop */
+ outb(ATC, 0x20); /* enable palette */
+ return 0;
+}
+
+/*
+ * set_border():
+ * Change the border color.
+ *
+ * CGA/EGA/VGA
+ */
+static int
+vga_set_border(video_adapter_t *adp, int color)
+{
+ prologue(adp, V_ADP_BORDER, 1);
+
+ switch (adp->va_type) {
+ case KD_EGA:
+ case KD_VGA:
+ inb(adp->va_crtc_addr + 6); /* reset flip-flop */
+ outb(ATC, 0x31); outb(ATC, color & 0xff);
+ break;
+ case KD_CGA:
+ outb(adp->va_crtc_addr + 5, color & 0x0f); /* color select register */
+ break;
+ case KD_MONO:
+ case KD_HERCULES:
+ default:
+ break;
+ }
+ return 0;
+}
+
+/*
+ * save_state():
+ * Read video register values.
+ * NOTE: this function only reads the standard EGA/VGA registers.
+ * any extra/extended registers of SVGA adapters are not saved.
+ *
+ * VGA
+ */
+static int
+vga_save_state(video_adapter_t *adp, void *p, size_t size)
+{
+ video_info_t info;
+ u_char *buf;
+ int crtc_addr;
+ int i, j;
+ int s;
+
+ if (size == 0) {
+ /* return the required buffer size */
+ prologue(adp, V_ADP_STATESAVE, 0);
+ return sizeof(adp_state_t);
+ } else {
+ prologue(adp, V_ADP_STATESAVE, 1);
+ if (size < sizeof(adp_state_t))
+ return 1;
+ }
+
+ ((adp_state_t *)p)->sig = V_STATE_SIG;
+ buf = ((adp_state_t *)p)->regs;
+ bzero(buf, V_MODE_PARAM_SIZE);
+ crtc_addr = adp->va_crtc_addr;
+
+ s = splhigh();
+
+ outb(TSIDX, 0x00); outb(TSREG, 0x01); /* stop sequencer */
+ for (i = 0, j = 5; i < 4; i++) {
+ outb(TSIDX, i + 1);
+ buf[j++] = inb(TSREG);
+ }
+ buf[9] = inb(MISC + 10); /* dot-clock */
+ outb(TSIDX, 0x00); outb(TSREG, 0x03); /* start sequencer */
+
+ for (i = 0, j = 10; i < 25; i++) { /* crtc */
+ outb(crtc_addr, i);
+ buf[j++] = inb(crtc_addr + 1);
+ }
+ for (i = 0, j = 35; i < 20; i++) { /* attribute ctrl */
+ inb(crtc_addr + 6); /* reset flip-flop */
+ outb(ATC, i);
+ buf[j++] = inb(ATC + 1);
+ }
+ for (i = 0, j = 55; i < 9; i++) { /* graph data ctrl */
+ outb(GDCIDX, i);
+ buf[j++] = inb(GDCREG);
+ }
+ inb(crtc_addr + 6); /* reset flip-flop */
+ outb(ATC, 0x20); /* enable palette */
+
+ splx(s);
+
+#if 1
+ if (vga_get_info(adp, adp->va_mode, &info) == 0) {
+ if (info.vi_flags & V_INFO_GRAPHICS) {
+ buf[0] = info.vi_width/info.vi_cwidth; /* COLS */
+ buf[1] = info.vi_height/info.vi_cheight - 1; /* ROWS */
+ } else {
+ buf[0] = info.vi_width; /* COLS */
+ buf[1] = info.vi_height - 1; /* ROWS */
+ }
+ buf[2] = info.vi_cheight; /* POINTS */
+ } else {
+ /* XXX: shouldn't be happening... */
+ printf("vga%d: %s: failed to obtain mode info. (vga_save_state())\n",
+ adp->va_unit, adp->va_name);
+ }
+#else
+ buf[0] = readb(BIOS_PADDRTOVADDR(0x44a)); /* COLS */
+ buf[1] = readb(BIOS_PADDRTOVADDR(0x484)); /* ROWS */
+ buf[2] = readb(BIOS_PADDRTOVADDR(0x485)); /* POINTS */
+ buf[3] = readb(BIOS_PADDRTOVADDR(0x44c));
+ buf[4] = readb(BIOS_PADDRTOVADDR(0x44d));
+#endif
+
+ return 0;
+}
+
+/*
+ * load_state():
+ * Set video registers at once.
+ * NOTE: this function only updates the standard EGA/VGA registers.
+ * any extra/extended registers of SVGA adapters are not changed.
+ *
+ * EGA/VGA
+ */
+static int
+vga_load_state(video_adapter_t *adp, void *p)
+{
+ u_char *buf;
+ int crtc_addr;
+ int s;
+ int i;
+
+ prologue(adp, V_ADP_STATELOAD, 1);
+ if (((adp_state_t *)p)->sig != V_STATE_SIG)
+ return 1;
+
+ buf = ((adp_state_t *)p)->regs;
+ crtc_addr = adp->va_crtc_addr;
+
+ s = splhigh();
+
+ outb(TSIDX, 0x00); outb(TSREG, 0x01); /* stop sequencer */
+ for (i = 0; i < 4; ++i) { /* program sequencer */
+ outb(TSIDX, i + 1);
+ outb(TSREG, buf[i + 5]);
+ }
+ outb(MISC, buf[9]); /* set dot-clock */
+ outb(TSIDX, 0x00); outb(TSREG, 0x03); /* start sequencer */
+ outb(crtc_addr, 0x11);
+ outb(crtc_addr + 1, inb(crtc_addr + 1) & 0x7F);
+ for (i = 0; i < 25; ++i) { /* program crtc */
+ outb(crtc_addr, i);
+ outb(crtc_addr + 1, buf[i + 10]);
+ }
+ inb(crtc_addr+6); /* reset flip-flop */
+ for (i = 0; i < 20; ++i) { /* program attribute ctrl */
+ outb(ATC, i);
+ outb(ATC, buf[i + 35]);
+ }
+ for (i = 0; i < 9; ++i) { /* program graph data ctrl */
+ outb(GDCIDX, i);
+ outb(GDCREG, buf[i + 55]);
+ }
+ inb(crtc_addr + 6); /* reset flip-flop */
+ outb(ATC, 0x20); /* enable palette */
+
+#ifndef VGA_NO_BIOS
+ if (adp->va_unit == V_ADP_PRIMARY) {
+ writeb(BIOS_PADDRTOVADDR(0x44a), buf[0]); /* COLS */
+ writeb(BIOS_PADDRTOVADDR(0x484), buf[1] + rows_offset - 1); /* ROWS */
+ writeb(BIOS_PADDRTOVADDR(0x485), buf[2]); /* POINTS */
+#if 0
+ writeb(BIOS_PADDRTOVADDR(0x44c), buf[3]);
+ writeb(BIOS_PADDRTOVADDR(0x44d), buf[4]);
+#endif
+ }
+#endif /* VGA_NO_BIOS */
+
+ splx(s);
+ return 0;
+}
+
+/*
+ * set_origin():
+ * Change the origin (window mapping) of the banked frame buffer.
+ */
+static int
+vga_set_origin(video_adapter_t *adp, off_t offset)
+{
+ /*
+ * The standard video modes do not require window mapping;
+ * always return error.
+ */
+ return 1;
+}
+
+/*
+ * read_hw_cursor():
+ * Read the position of the hardware text cursor.
+ *
+ * all adapters
+ */
+static int
+vga_read_hw_cursor(video_adapter_t *adp, int *col, int *row)
+{
+ video_info_t info;
+ u_int16_t off;
+ int s;
+
+ if (!init_done)
+ return 1;
+
+ (*vidsw[adp->va_index]->get_info)(adp, adp->va_mode, &info);
+ if (info.vi_flags & V_INFO_GRAPHICS)
+ return 1;
+
+ s = spltty();
+ outb(adp->va_crtc_addr, 14);
+ off = inb(adp->va_crtc_addr + 1);
+ outb(adp->va_crtc_addr, 15);
+ off = (off << 8) | inb(adp->va_crtc_addr + 1);
+ splx(s);
+
+ *row = off / info.vi_width;
+ *col = off % info.vi_width;
+
+ return 0;
+}
+
+/*
+ * set_hw_cursor():
+ * Move the hardware text cursor. If col and row are both -1,
+ * the cursor won't be shown.
+ *
+ * all adapters
+ */
+static int
+vga_set_hw_cursor(video_adapter_t *adp, int col, int row)
+{
+ video_info_t info;
+ u_int16_t off;
+ int s;
+
+ if (!init_done)
+ return 1;
+
+ if ((col == -1) && (row == -1)) {
+ off = -1;
+ } else {
+ (*vidsw[adp->va_index]->get_info)(adp, adp->va_mode, &info);
+ if (info.vi_flags & V_INFO_GRAPHICS)
+ return 1;
+ off = row*info.vi_width + col;
+ }
+
+ s = spltty();
+ outb(adp->va_crtc_addr, 14);
+ outb(adp->va_crtc_addr + 1, off >> 8);
+ outb(adp->va_crtc_addr, 15);
+ outb(adp->va_crtc_addr + 1, off & 0x00ff);
+ splx(s);
+
+ return 0;
+}
+
+/*
+ * set_hw_cursor_shape():
+ * Change the shape of the hardware text cursor. If the height is
+ * zero or negative, the cursor won't be shown.
+ *
+ * all adapters
+ */
+static int
+vga_set_hw_cursor_shape(video_adapter_t *adp, int base, int height,
+ int celsize, int blink)
+{
+ int s;
+
+ if (!init_done)
+ return 1;
+
+ s = spltty();
+ switch (adp->va_type) {
+ case KD_VGA:
+ case KD_CGA:
+ case KD_MONO:
+ case KD_HERCULES:
+ default:
+ if (height <= 0) {
+ /* make the cursor invisible */
+ outb(adp->va_crtc_addr, 10);
+ outb(adp->va_crtc_addr + 1, 32);
+ outb(adp->va_crtc_addr, 11);
+ outb(adp->va_crtc_addr + 1, 0);
+ } else {
+ outb(adp->va_crtc_addr, 10);
+ outb(adp->va_crtc_addr + 1, celsize - base - height);
+ outb(adp->va_crtc_addr, 11);
+ outb(adp->va_crtc_addr + 1, celsize - base - 1);
+ }
+ break;
+ case KD_EGA:
+ if (height <= 0) {
+ /* make the cursor invisible */
+ outb(adp->va_crtc_addr, 10);
+ outb(adp->va_crtc_addr + 1, celsize);
+ outb(adp->va_crtc_addr, 11);
+ outb(adp->va_crtc_addr + 1, 0);
+ } else {
+ outb(adp->va_crtc_addr, 10);
+ outb(adp->va_crtc_addr + 1, celsize - base - height);
+ outb(adp->va_crtc_addr, 11);
+ outb(adp->va_crtc_addr + 1, celsize - base);
+ }
+ break;
+ }
+ splx(s);
+
+ return 0;
+}
+
+/*
+ * mmap():
+ * Mmap frame buffer.
+ *
+ * all adapters
+ */
+static int
+vga_mmap(video_adapter_t *adp, vm_offset_t offset)
+{
+ if (offset > 0x20000 - PAGE_SIZE)
+ return -1;
+#ifdef __i386__
+ return i386_btop((VIDEO_BUF_BASE + offset));
+#endif
+#ifdef __alpha__
+ return alpha_btop((VIDEO_BUF_BASE + offset));
+#endif
+}
+
+static void
+dump_buffer(u_char *buf, size_t len)
+{
+ int i;
+
+ for(i = 0; i < len;) {
+ printf("%02x ", buf[i]);
+ if ((++i % 16) == 0)
+ printf("\n");
+ }
+}
+
+/*
+ * diag():
+ * Print some information about the video adapter and video modes,
+ * with requested level of details.
+ *
+ * all adapters
+ */
+static int
+vga_diag(video_adapter_t *adp, int level)
+{
+#if FB_DEBUG > 1
+ video_info_t info;
+#endif
+ u_char *mp;
+
+ if (!init_done)
+ return 1;
+
+#if FB_DEBUG > 1
+#ifndef VGA_NO_BIOS
+ printf("vga: RTC equip. code:0x%02x, DCC code:0x%02x\n",
+ rtcin(RTC_EQUIPMENT), readb(BIOS_PADDRTOVADDR(0x488)));
+ printf("vga: CRTC:0x%x, video option:0x%02x, ",
+ readw(BIOS_PADDRTOVADDR(0x463)),
+ readb(BIOS_PADDRTOVADDR(0x487)));
+ printf("rows:%d, cols:%d, font height:%d\n",
+ readb(BIOS_PADDRTOVADDR(0x44a)),
+ readb(BIOS_PADDRTOVADDR(0x484)) + 1,
+ readb(BIOS_PADDRTOVADDR(0x485)));
+#endif /* VGA_NO_BIOS */
+ printf("vga: param table EGA/VGA:%p", video_mode_ptr);
+ printf(", CGA/MDA:%p\n", video_mode_ptr2);
+ printf("vga: rows_offset:%d\n", rows_offset);
+#endif /* FB_DEBUG > 1 */
+
+ fb_dump_adp_info(DRIVER_NAME, adp, level);
+
+#if FB_DEBUG > 1
+ if (adp->va_flags & V_ADP_MODECHANGE) {
+ for (i = 0; bios_vmode[i].vi_mode != EOT; ++i) {
+ if (bios_vmode[i].vi_mode == NA)
+ continue;
+ if (get_mode_param(bios_vmode[i].vi_mode) == NULL)
+ continue;
+ fb_dump_mode_info(DRIVER_NAME, adp, &bios_vmode[i], level);
+ }
+ } else {
+ vga_get_info(adp, adp->va_initial_mode, &info); /* shouldn't fail */
+ fb_dump_mode_info(DRIVER_NAME, adp, &info, level);
+ }
+#endif /* FB_DEBUG > 1 */
+
+ if ((adp->va_type != KD_EGA) && (adp->va_type != KD_VGA))
+ return 0;
+#if !defined(VGA_NO_BIOS) && !defined(VGA_NO_MODE_CHANGE)
+ if (video_mode_ptr == NULL)
+ printf("vga%d: %s: WARNING: video mode switching is not "
+ "fully supported on this adapter\n",
+ adp->va_unit, adp->va_name);
+#endif
+ if (level <= 0)
+ return 0;
+
+ if (adp->va_type == KD_VGA) {
+ printf("VGA parameters upon power-up\n");
+ dump_buffer(adpstate.regs, sizeof(adpstate.regs));
+ printf("VGA parameters in BIOS for mode %d\n", adp->va_initial_mode);
+ dump_buffer(adpstate2.regs, sizeof(adpstate2.regs));
+ }
+
+ mp = get_mode_param(adp->va_initial_mode);
+ if (mp == NULL) /* this shouldn't be happening */
+ return 0;
+ printf("EGA/VGA parameters to be used for mode %d\n", adp->va_initial_mode);
+ dump_buffer(mp, V_MODE_PARAM_SIZE);
+
+ return 0;
+}
+
+#endif /* NVGA > 0 */
diff --git a/sys/isa/videoio.c b/sys/isa/videoio.c
deleted file mode 100644
index c5b84c6..0000000
--- a/sys/isa/videoio.c
+++ /dev/null
@@ -1,1628 +0,0 @@
-/*-
- * Copyright (c) 1998 Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id$
- * from: i386/isa videoio.c,v 1.1
- */
-
-#include "sc.h"
-#include "opt_syscons.h"
-
-#if NSC > 0
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <machine/clock.h>
-#include <machine/console.h>
-#include <machine/md_var.h>
-#include <machine/pc/bios.h>
-
-#include <isa/isareg.h>
-#include <isa/videoio.h>
-
-/* this should really be in `rtc.h' */
-#define RTC_EQUIPMENT 0x14
-
-/* video adapter state buffer */
-struct adp_state {
- int sig;
-#define V_STATE_SIG 0x736f6962
- u_char regs[V_MODE_PARAM_SIZE];
-};
-typedef struct adp_state adp_state_t;
-
-/* video adapter information */
-#define DCC_MONO 0
-#define DCC_CGA40 1
-#define DCC_CGA80 2
-#define DCC_EGAMONO 3
-#define DCC_EGA40 4
-#define DCC_EGA80 5
-
-/*
- * NOTE: `va_window' should have a virtual address, but is initialized
- * with a physical address in the following table, as verify_adapter()
- * will perform address conversion at run-time.
- */
-static video_adapter_t adapter_init_value[] = {
- { 0, KD_MONO, 0, MONO_BASE, 0xb0000, 32, 32, 0, 0, 0, 7, 0 },
- { 0, KD_CGA, V_ADP_COLOR, COLOR_BASE, 0xb8000, 32, 32, 0, 0, 0, 3, 0 },
- { 0, KD_CGA, V_ADP_COLOR, COLOR_BASE, 0xb8000, 32, 32, 0, 0, 0, 3, 0 },
- { 0, KD_EGA, 0, MONO_BASE, 0xb0000, 32, 32, 0, 0, 0, 7, 0 },
- { 0, KD_EGA, V_ADP_COLOR, COLOR_BASE, 0xb8000, 32, 32, 0, 0, 0, 3, 0 },
- { 0, KD_EGA, V_ADP_COLOR, COLOR_BASE, 0xb8000, 32, 32, 0, 0, 0, 3, 0 },
-};
-
-static video_adapter_t adapter[V_MAX_ADAPTERS];
-static int adapters = 0;
-
-/* VGA function entries */
-static vi_init_t vid_init;
-static vi_adapter_t vid_adapter;
-static vi_get_info_t vid_get_info;
-static vi_query_mode_t vid_query_mode;
-static vi_set_mode_t vid_set_mode;
-static vi_save_font_t vid_save_font;
-static vi_load_font_t vid_load_font;
-static vi_show_font_t vid_show_font;
-static vi_save_palette_t vid_save_palette;
-static vi_load_palette_t vid_load_palette;
-static vi_set_border_t vid_set_border;
-static vi_save_state_t vid_save_state;
-static vi_load_state_t vid_load_state;
-static vi_set_win_org_t vid_set_origin;
-static vi_read_hw_cursor_t vid_read_hw_cursor;
-static vi_set_hw_cursor_t vid_set_hw_cursor;
-static vi_diag_t vid_diag;
-
-struct vidsw biosvidsw = {
- vid_init, vid_adapter, vid_get_info, vid_query_mode,
- vid_set_mode, vid_save_font, vid_load_font, vid_show_font,
- vid_save_palette,vid_load_palette,vid_set_border,vid_save_state,
- vid_load_state, vid_set_origin, vid_read_hw_cursor, vid_set_hw_cursor,
- vid_diag,
-};
-
-/* VGA BIOS standard video modes */
-#define EOT (-1)
-#define NA (-2)
-
-static video_info_t bios_vmode[] = {
- /* CGA */
- { M_B40x25, V_INFO_COLOR, 40, 25, 8, 8, 2, 1, 0xb8000, 32, 32, 0, 32 },
- { M_C40x25, V_INFO_COLOR, 40, 25, 8, 8, 4, 1, 0xb8000, 32, 32, 0, 32 },
- { M_B80x25, V_INFO_COLOR, 80, 25, 8, 8, 2, 1, 0xb8000, 32, 32, 0, 32 },
- { M_C80x25, V_INFO_COLOR, 80, 25, 8, 8, 4, 1, 0xb8000, 32, 32, 0, 32 },
- /* EGA */
- { M_ENH_B40x25, V_INFO_COLOR, 40, 25, 8, 14, 2, 1, 0xb8000, 32, 32, 0, 32 },
- { M_ENH_C40x25, V_INFO_COLOR, 40, 25, 8, 14, 4, 1, 0xb8000, 32, 32, 0, 32 },
- { M_ENH_B80x25, V_INFO_COLOR, 80, 25, 8, 14, 2, 1, 0xb8000, 32, 32, 0, 32 },
- { M_ENH_C80x25, V_INFO_COLOR, 80, 25, 8, 14, 4, 1, 0xb8000, 32, 32, 0, 32 },
- /* VGA */
- { M_VGA_C40x25, V_INFO_COLOR, 40, 25, 8, 16, 4, 1, 0xb8000, 32, 32, 0, 32 },
- { M_VGA_M80x25, 0, 80, 25, 8, 16, 2, 1, 0xb0000, 32, 32, 0, 32 },
- { M_VGA_C80x25, V_INFO_COLOR, 80, 25, 8, 16, 4, 1, 0xb8000, 32, 32, 0, 32 },
- /* MDA */
- { M_EGAMONO80x25, 0, 80, 25, 8, 14, 2, 1, 0xb0000, 32, 32, 0, 32 },
- /* EGA */
- { M_ENH_B80x43, V_INFO_COLOR, 80, 43, 8, 8, 2, 1, 0xb8000, 32, 32, 0, 32 },
- { M_ENH_C80x43, V_INFO_COLOR, 80, 43, 8, 8, 4, 1, 0xb8000, 32, 32, 0, 32 },
- /* VGA */
- { M_VGA_M80x30, 0, 80, 30, 8, 16, 2, 1, 0xb0000, 32, 32, 0, 32 },
- { M_VGA_C80x30, V_INFO_COLOR, 80, 30, 8, 16, 4, 1, 0xb8000, 32, 32, 0, 32 },
- { M_VGA_M80x50, 0, 80, 50, 8, 8, 2, 1, 0xb0000, 32, 32, 0, 32 },
- { M_VGA_C80x50, V_INFO_COLOR, 80, 50, 8, 8, 4, 1, 0xb8000, 32, 32, 0, 32 },
- { M_VGA_M80x60, 0, 80, 60, 8, 8, 2, 1, 0xb0000, 32, 32, 0, 32 },
- { M_VGA_C80x60, V_INFO_COLOR, 80, 60, 8, 8, 4, 1, 0xb8000, 32, 32, 0, 32 },
- /* CGA */
- { M_BG320, V_INFO_COLOR | V_INFO_GRAPHICS,
- 320, 200, 8, 8, 2, 1, 0xb8000, 32, 32, 0, 32 },
- { M_CG320, V_INFO_COLOR | V_INFO_GRAPHICS,
- 320, 200, 8, 8, 2, 1, 0xb8000, 32, 32, 0, 32 },
- { M_BG640, V_INFO_COLOR | V_INFO_GRAPHICS,
- 640, 200, 8, 8, 1, 1, 0xb8000, 32, 32, 0, 32 },
- /* EGA */
- { M_CG320_D, V_INFO_COLOR | V_INFO_GRAPHICS,
- 320, 200, 8, 8, 4, 4, 0xa0000, 64, 64, 0, 64 },
- { M_CG640_E, V_INFO_COLOR | V_INFO_GRAPHICS,
- 640, 200, 8, 8, 4, 4, 0xa0000, 64, 64, 0, 64 },
- { M_EGAMONOAPA, V_INFO_GRAPHICS,
- 640, 350, 8, 14, 4, 4, 0xa0000, 64, 64, 0, 64 },
- { M_ENHMONOAPA2,V_INFO_GRAPHICS,
- 640, 350, 8, 14, 4, 4, 0xa0000, 64, 64, 0, 64 },
- { M_CG640x350, V_INFO_COLOR | V_INFO_GRAPHICS,
- 640, 350, 8, 14, 2, 2, 0xa0000, 64, 64, 0, 64 },
- { M_ENH_CG640, V_INFO_COLOR | V_INFO_GRAPHICS,
- 640, 350, 8, 14, 4, 4, 0xa0000, 64, 64, 0, 64 },
- /* VGA */
- { M_BG640x480, V_INFO_COLOR | V_INFO_GRAPHICS,
- 640, 480, 8, 16, 4, 4, 0xa0000, 64, 64, 0, 64 },
- { M_CG640x480, V_INFO_COLOR | V_INFO_GRAPHICS,
- 640, 480, 8, 16, 4, 4, 0xa0000, 64, 64, 0, 64 },
- { M_VGA_CG320, V_INFO_COLOR | V_INFO_GRAPHICS,
- 320, 200, 8, 8, 8, 1, 0xa0000, 64, 64, 0, 64 },
- { M_VGA_MODEX, V_INFO_COLOR | V_INFO_GRAPHICS,
- 320, 240, 8, 8, 8, 1, 0xa0000, 64, 64, 0, 64 },
-
- { EOT },
-};
-
-static int init_done = FALSE;
-static u_char *video_mode_ptr = NULL; /* EGA/VGA */
-static u_char *video_mode_ptr2 = NULL; /* CGA/MDA */
-static u_char *mode_map[V_MODE_MAP_SIZE];
-static adp_state_t adpstate;
-static adp_state_t adpstate2;
-static int rows_offset = 1;
-
-/* local macros and functions */
-#define BIOS_SADDRTOLADDR(p) ((((p) & 0xffff0000) >> 12) + ((p) & 0x0000ffff))
-
-static void map_mode_table(u_char *map[], u_char *table, int max);
-static void clear_mode_map(int ad, u_char *map[], int max, int color);
-static int map_mode_num(int mode);
-static int map_bios_mode_num(int type, int color, int bios_mode);
-static u_char *get_mode_param(int mode);
-static void fill_adapter_param(int code, video_adapter_t *adp);
-static int verify_adapter(video_adapter_t *adp);
-#define COMP_IDENTICAL 0
-#define COMP_SIMILAR 1
-#define COMP_DIFFERENT 2
-static int comp_adpregs(u_char *buf1, u_char *buf2);
-
-#define PARAM_BUFSIZE 6
-static void set_font_mode(video_adapter_t *adp, u_char *buf);
-static void set_normal_mode(video_adapter_t *adp, u_char *buf);
-
-static char *adapter_name(int type);
-static void dump_adp_info(int ad, video_adapter_t *adp, int level);
-static void dump_mode_info(int ad, video_info_t *info, int level);
-static void dump_buffer(u_char *buf, size_t len);
-
-extern void generic_bcopy(const void *, void *, size_t);
-
-#define ISMAPPED(pa, width) \
- (((pa) <= (u_long)0x1000 - (width)) \
- || ((pa) >= ISA_HOLE_START && (pa) <= 0x100000 - (width)))
-
-#define prologue(ad, flag, err) \
- if (!init_done \
- || ((ad) < 0) || ((ad) >= adapters) \
- || !(adapter[(ad)].va_flags & (flag))) \
- return (err)
-
-/* construct the mode parameter map */
-static void
-map_mode_table(u_char *map[], u_char *table, int max)
-{
- int i;
-
- for(i = 0; i < max; ++i)
- map[i] = table + i*V_MODE_PARAM_SIZE;
- for(; i < V_MODE_MAP_SIZE; ++i)
- map[i] = NULL;
-}
-
-static void
-clear_mode_map(int ad, u_char *map[], int max, int color)
-{
- video_info_t info;
- int i;
-
- /*
- * NOTE: we don't touch `bios_vmode[]' because it is shared
- * by all adapters.
- */
- for(i = 0; i < max; ++i) {
- if (vid_get_info(ad, i, &info))
- continue;
- if ((info.vi_flags & V_INFO_COLOR) != color)
- map[i] = NULL;
- }
-}
-
-/* the non-standard video mode is based on a standard mode... */
-static int
-map_mode_num(int mode)
-{
- static struct {
- int from;
- int to;
- } mode_map[] = {
- { M_ENH_B80x43, M_ENH_B80x25 },
- { M_ENH_C80x43, M_ENH_C80x25 },
- { M_VGA_M80x30, M_VGA_M80x25 },
- { M_VGA_C80x30, M_VGA_C80x25 },
- { M_VGA_M80x50, M_VGA_M80x25 },
- { M_VGA_C80x50, M_VGA_C80x25 },
- { M_VGA_M80x60, M_VGA_M80x25 },
- { M_VGA_C80x60, M_VGA_C80x25 },
- { M_VGA_MODEX, M_VGA_CG320 },
- };
- int i;
-
- for (i = 0; i < sizeof(mode_map)/sizeof(mode_map[0]); ++i) {
- if (mode_map[i].from == mode)
- return mode_map[i].to;
- }
- return mode;
-}
-
-/* turn the BIOS video number into our video mode number */
-static int
-map_bios_mode_num(int type, int color, int bios_mode)
-{
- static int cga_modes[7] = {
- M_B40x25, M_C40x25, /* 0, 1 */
- M_B80x25, M_C80x25, /* 2, 3 */
- M_BG320, M_CG320,
- M_BG640,
- };
- static int ega_modes[17] = {
- M_ENH_B40x25, M_ENH_C40x25, /* 0, 1 */
- M_ENH_B80x25, M_ENH_C80x25, /* 2, 3 */
- M_BG320, M_CG320,
- M_BG640,
- M_EGAMONO80x25, /* 7 */
- 8, 9, 10, 11, 12,
- M_CG320_D,
- M_CG640_E,
- M_ENHMONOAPA2, /* XXX: video momery > 64K */
- M_ENH_CG640, /* XXX: video momery > 64K */
- };
- static int vga_modes[20] = {
- M_VGA_C40x25, M_VGA_C40x25, /* 0, 1 */
- M_VGA_C80x25, M_VGA_C80x25, /* 2, 3 */
- M_BG320, M_CG320,
- M_BG640,
- M_VGA_M80x25, /* 7 */
- 8, 9, 10, 11, 12,
- M_CG320_D,
- M_CG640_E,
- M_ENHMONOAPA2,
- M_ENH_CG640,
- M_BG640x480, M_CG640x480,
- M_VGA_CG320,
- };
-
- switch (type) {
-
- case KD_VGA:
- if (bios_mode < sizeof(vga_modes)/sizeof(vga_modes[0]))
- return vga_modes[bios_mode];
- else if (color)
- return M_VGA_C80x25;
- else
- return M_VGA_M80x25;
- break;
-
- case KD_EGA:
- if (bios_mode < sizeof(ega_modes)/sizeof(ega_modes[0]))
- return ega_modes[bios_mode];
- else if (color)
- return M_ENH_C80x25;
- else
- return M_EGAMONO80x25;
- break;
-
- case KD_CGA:
- if (bios_mode < sizeof(cga_modes)/sizeof(cga_modes[0]))
- return cga_modes[bios_mode];
- else
- return M_C80x25;
- break;
-
- case KD_MONO:
- case KD_HERCULES:
- return M_EGAMONO80x25; /* XXX: this name is confusing */
-
- default:
- break;
- }
- return -1;
-}
-
-/* look up a parameter table entry */
-static u_char
-*get_mode_param(int mode)
-{
- if (mode >= V_MODE_MAP_SIZE)
- mode = map_mode_num(mode);
- if (mode < V_MODE_MAP_SIZE)
- return mode_map[mode];
- else
- return NULL;
-}
-
-static void
-fill_adapter_param(int code, video_adapter_t *adp)
-{
- static struct {
- int primary;
- int secondary;
- } dcc[] = {
- { DCC_MONO, DCC_EGA40 /* CGA monitor */ },
- { DCC_MONO, DCC_EGA80 /* CGA monitor */ },
- { DCC_MONO, DCC_EGA80 /* CGA emulation */ },
- { DCC_MONO, DCC_EGA80 },
- { DCC_CGA40, DCC_EGAMONO },
- { DCC_CGA80, DCC_EGAMONO },
- { DCC_EGA40 /* CGA monitor */, DCC_MONO},
- { DCC_EGA80 /* CGA monitor */, DCC_MONO},
- { DCC_EGA80 /* CGA emulation */,DCC_MONO },
- { DCC_EGA80, DCC_MONO },
- { DCC_EGAMONO, DCC_CGA40 },
- { DCC_EGAMONO, DCC_CGA40 },
- };
-
- if ((code < 0) || (code >= sizeof(dcc)/sizeof(dcc[0]))) {
- adp[V_ADP_PRIMARY] = adapter_init_value[DCC_MONO];
- adp[V_ADP_SECONDARY] = adapter_init_value[DCC_CGA80];
- } else {
- adp[V_ADP_PRIMARY] = adapter_init_value[dcc[code].primary];
- adp[V_ADP_SECONDARY] = adapter_init_value[dcc[code].secondary];
- }
-}
-
-static int
-verify_adapter(video_adapter_t *adp)
-{
- u_int32_t buf;
- u_short v;
- u_int32_t p;
-
- buf = BIOS_PADDRTOVADDR(adp->va_window);
- v = readw(buf);
- writew(buf, 0xA55A);
- if (readw(buf) != 0xA55A)
- return 1;
- writew(buf, v);
-
- switch (adp->va_type) {
-
- case KD_EGA:
- outb(adp->va_crtc_addr, 7);
- if (inb(adp->va_crtc_addr) == 7) {
- adp->va_type = KD_VGA;
- adp->va_flags |= V_ADP_STATESAVE | V_ADP_PALETTE;
- }
- adp->va_flags |= V_ADP_STATELOAD | V_ADP_FONT | V_ADP_BORDER;
- /* the color adapter may be in the 40x25 mode... XXX */
-
-#ifdef __i386__
- /* get the BIOS video mode pointer */
- p = *(u_int32_t *)BIOS_PADDRTOVADDR(0x4a8);
- p = BIOS_SADDRTOLADDR(p);
- if (ISMAPPED(p, sizeof(u_int32_t))) {
- p = *(u_int32_t *)BIOS_PADDRTOVADDR(p);
- p = BIOS_SADDRTOLADDR(p);
- if (ISMAPPED(p, V_MODE_PARAM_SIZE))
- video_mode_ptr = (u_char *)BIOS_PADDRTOVADDR(p);
- }
-#endif
- break;
-
- case KD_CGA:
- adp->va_flags |= V_ADP_COLOR | V_ADP_BORDER;
- /* may be in the 40x25 mode... XXX */
- break;
-
- case KD_MONO:
- break;
- }
-
- return 0;
-}
-
-/* compare two parameter table entries */
-static int
-comp_adpregs(u_char *buf1, u_char *buf2)
-{
- static struct {
- u_char mask;
- } params[V_MODE_PARAM_SIZE] = {
- 0xff, 0x00, 0xff, /* COLS, ROWS, POINTS */
- 0x00, 0x00, /* page length */
- 0xfe, 0xff, 0xff, 0xff, /* sequencer registers */
- 0xf3, /* misc register */
- 0xff, 0xff, 0xff, 0x7f, 0xff, /* CRTC */
- 0xff, 0xff, 0xff, 0x7f, 0xff,
- 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xff, 0x7f, 0xff, 0xff,
- 0x7f, 0xff, 0xff, 0xef, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, /* attribute controller registers */
- 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xf0,
- 0xff, 0xff, 0xff, 0xff, 0xff, /* GDC register */
- 0xff, 0xff, 0xff, 0xff,
- };
- int identical = TRUE;
- int i;
-
- if ((buf1 == NULL) || (buf2 == NULL))
- return COMP_DIFFERENT;
-
- for (i = 0; i < sizeof(params)/sizeof(params[0]); ++i) {
- if (params[i].mask == 0) /* don't care */
- continue;
- if ((buf1[i] & params[i].mask) != (buf2[i] & params[i].mask))
- return COMP_DIFFERENT;
- if (buf1[i] != buf2[i])
- identical = FALSE;
- }
- return (identical) ? COMP_IDENTICAL : COMP_SIMILAR;
-}
-
-/* exported functions */
-
-/* all adapters */
-static int
-vid_init(void)
-{
- video_adapter_t *adp;
- video_info_t info;
- u_char *mp;
- int i;
-
- /* do this test only once */
- if (init_done)
- return adapters;
- init_done = TRUE;
-
- /*
- * Locate display adapters.
- * The AT architecture supports upto two adapters. `syscons' allows
- * the following combinations of adapters:
- * 1) MDA + CGA
- * 2) MDA + EGA/VGA color
- * 3) CGA + EGA/VGA mono
- * Note that `syscons' doesn't bother with MCGA as it is only
- * avaiable for low end PS/2 models which has 80286 or earlier CPUs,
- * thus, they are not running FreeBSD!
- * When there are two adapaters in the system, one becomes `primary'
- * and the other `secondary'. The EGA adapter has a set of DIP
- * switches on board for this information and the EGA BIOS copies
- * it in the BIOS data area BIOSDATA_VIDEOSWITCH (40:88).
- * The VGA BIOS has more sophisticated mechanism and has this
- * information in BIOSDATA_DCCINDEX (40:8a), but it also maintains
- * compatibility with the EGA BIOS by updating BIOSDATA_VIDEOSWITCH.
- */
-
- /* check rtc and BIOS date area */
- /*
- * XXX: don't use BIOSDATA_EQUIPMENT, it is not a dead copy
- * of RTC_EQUIPMENT. The bit 4 and 5 of the ETC_EQUIPMENT are
- * zeros for EGA and VGA. However, the EGA/VGA BIOS will set
- * these bits in BIOSDATA_EQUIPMENT according to the monitor
- * type detected.
- */
-#ifdef __i386__
- switch ((rtcin(RTC_EQUIPMENT) >> 4) & 3) { /* bit 4 and 5 */
- case 0:
- /* EGA/VGA */
- fill_adapter_param(readb(BIOS_PADDRTOVADDR(0x488)) & 0x0f,
- adapter);
- break;
- case 1:
- /* CGA 40x25 */
- /* FIXME: switch to the 80x25 mode? XXX */
- adapter[V_ADP_PRIMARY] = adapter_init_value[DCC_CGA40];
- adapter[V_ADP_SECONDARY] = adapter_init_value[DCC_MONO];
- break;
- case 2:
- /* CGA 80x25 */
- adapter[V_ADP_PRIMARY] = adapter_init_value[DCC_CGA80];
- adapter[V_ADP_SECONDARY] = adapter_init_value[DCC_MONO];
- break;
- case 3:
- /* MDA */
- adapter[V_ADP_PRIMARY] = adapter_init_value[DCC_MONO];
- adapter[V_ADP_SECONDARY] = adapter_init_value[DCC_CGA80];
- break;
- }
-#else
- /* EGA/VGA */
- fill_adapter_param(-1, adapter);
-#endif
-
- adapters = 0;
- if (verify_adapter(&adapter[V_ADP_SECONDARY]) == 0) {
- ++adapters;
- adapter[V_ADP_SECONDARY].va_mode =
- adapter[V_ADP_SECONDARY].va_initial_mode =
- map_bios_mode_num(adapter[V_ADP_SECONDARY].va_type,
- adapter[V_ADP_SECONDARY].va_flags & V_ADP_COLOR,
- adapter[V_ADP_SECONDARY].va_initial_bios_mode);
- } else {
- adapter[V_ADP_SECONDARY].va_type = -1;
- }
- if (verify_adapter(&adapter[V_ADP_PRIMARY]) == 0) {
- ++adapters;
-#ifdef __i386__
- adapter[V_ADP_PRIMARY].va_initial_bios_mode =
- *(u_int8_t *)BIOS_PADDRTOVADDR(0x449);
-#else
- adapter[V_ADP_PRIMARY].va_initial_bios_mode = 3;
-#endif
- adapter[V_ADP_PRIMARY].va_mode =
- adapter[V_ADP_PRIMARY].va_initial_mode =
- map_bios_mode_num(adapter[V_ADP_PRIMARY].va_type,
- adapter[V_ADP_PRIMARY].va_flags & V_ADP_COLOR,
- adapter[V_ADP_PRIMARY].va_initial_bios_mode);
- } else {
- adapter[V_ADP_PRIMARY] = adapter[V_ADP_SECONDARY];
- adapter[V_ADP_SECONDARY].va_type = -1;
- }
- if (adapters == 0)
- return adapters;
- adapter[V_ADP_PRIMARY].va_index = V_ADP_PRIMARY;
- adapter[V_ADP_SECONDARY].va_index = V_ADP_SECONDARY;
-
-#if 0
- /*
- * We cannot have two video adapter of the same type; there must be
- * only one of color or mono adapter, or one each of them.
- */
- if (adapters > 1) {
- if (!((adapter[0].va_flags ^ adapter[1].va_flags) & V_ADP_COLOR))
- /* we have two mono or color adapters!! */
- return (adapters = 0);
- }
-#endif
-
- /*
- * Ensure a zero start address. This is mainly to recover after
- * switching from pcvt using userconfig(). The registers are w/o
- * for old hardware so it's too hard to relocate the active screen
- * memory.
- * This must be done before vid_save_state() for VGA.
- */
- outb(adapter[V_ADP_PRIMARY].va_crtc_addr, 12);
- outb(adapter[V_ADP_PRIMARY].va_crtc_addr + 1, 0);
- outb(adapter[V_ADP_PRIMARY].va_crtc_addr, 13);
- outb(adapter[V_ADP_PRIMARY].va_crtc_addr + 1, 0);
-
- /* the video mode parameter table in EGA/VGA BIOS */
- /* NOTE: there can be only one EGA/VGA, wheather color or mono,
- * recognized by the video BIOS.
- */
- if ((adapter[V_ADP_PRIMARY].va_type == KD_EGA) ||
- (adapter[V_ADP_PRIMARY].va_type == KD_VGA)) {
- adp = &adapter[V_ADP_PRIMARY];
- } else if ((adapter[V_ADP_SECONDARY].va_type == KD_EGA) ||
- (adapter[V_ADP_SECONDARY].va_type == KD_VGA)) {
- adp = &adapter[V_ADP_SECONDARY];
- } else {
- adp = NULL;
- }
- bzero(mode_map, sizeof(mode_map));
- if (adp != NULL) {
- if (adp->va_type == KD_VGA) {
- vid_save_state(adp - adapter, &adpstate, sizeof(adpstate));
- if (video_mode_ptr == NULL) {
- mode_map[map_mode_num(adp->va_initial_mode)] = adpstate.regs;
- rows_offset = 1;
- } else {
- /* discard the table if we are not familiar with it... */
- map_mode_table(mode_map, video_mode_ptr, M_VGA_CG320 + 1);
- mp = get_mode_param(adp->va_initial_mode);
- if (mp != NULL)
- bcopy(mp, adpstate2.regs, sizeof(adpstate2.regs));
- switch (comp_adpregs(adpstate.regs, mp)) {
- case COMP_IDENTICAL:
- /*
- * OK, this parameter table looks reasonably familiar
- * to us...
- */
- /*
- * This is a kludge for Toshiba DynaBook SS433
- * whose BIOS video mode table entry has the actual #
- * of rows at the offset 1; BIOSes from other
- * manufacturers store the # of rows - 1 there. XXX
- */
- rows_offset = adpstate.regs[1] + 1 - mp[1];
- break;
-
- case COMP_SIMILAR:
- /*
- * Not exactly the same, but similar enough to be
- * trusted. However, use the saved register values
- * for the initial mode and other modes which are
- * based on the initial mode.
- */
- mode_map[map_mode_num(adp->va_initial_mode)] =
- adpstate.regs;
- rows_offset = adpstate.regs[1] + 1 - mp[1];
- adpstate.regs[1] -= rows_offset - 1;
- break;
-
- case COMP_DIFFERENT:
- default:
- /*
- * Don't use the paramter table in BIOS. It doesn't
- * look familiar to us. Video mode switching is allowed
- * only if the new mode is the same as or based on
- * the initial mode.
- */
- video_mode_ptr = NULL;
- bzero(mode_map, sizeof(mode_map));
- mode_map[map_mode_num(adp->va_initial_mode)] =
- adpstate.regs;
- rows_offset = 1;
- break;
- }
- }
- adp->va_flags |= V_ADP_MODECHANGE;
- } else if (adp->va_type == KD_EGA) {
- if (video_mode_ptr == NULL) {
- adp->va_flags &= ~V_ADP_FONT;
- rows_offset = 1;
- } else {
- map_mode_table(mode_map, video_mode_ptr, M_ENH_C80x25 + 1);
- /* XXX how can one validate the EGA table... */
- mp = get_mode_param(adp->va_initial_mode);
- if (mp != NULL) {
- adp->va_flags |= V_ADP_MODECHANGE;
- rows_offset = 1;
- } else {
- /*
- * This is serious. We will not be able to switch video
- * modes at all...
- */
- adp->va_flags &= ~V_ADP_FONT;
- video_mode_ptr = NULL;
- bzero(mode_map, sizeof(mode_map));
- rows_offset = 1;
- }
- }
- }
- }
-
- /* remove conflicting modes if we have more than one adapter */
- if (adapters > 1) {
- for (i = 0; i < adapters; ++i) {
- if (!(adapter[i].va_flags & V_ADP_MODECHANGE))
- continue;
- clear_mode_map(i, mode_map, M_VGA_CG320 + 1,
- (adapter[i].va_flags & V_ADP_COLOR) ?
- V_INFO_COLOR : 0);
- }
- }
-
- /* buffer address */
- vid_get_info(V_ADP_PRIMARY,
- adapter[V_ADP_PRIMARY].va_initial_mode, &info);
- adapter[V_ADP_PRIMARY].va_window = BIOS_PADDRTOVADDR(info.vi_window);
- adapter[V_ADP_PRIMARY].va_window_size = info.vi_window_size;
- adapter[V_ADP_PRIMARY].va_window_gran = info.vi_window_gran;
- adapter[V_ADP_PRIMARY].va_buffer = BIOS_PADDRTOVADDR(info.vi_buffer);
- adapter[V_ADP_PRIMARY].va_buffer_size = info.vi_buffer_size;
- if (adapters > 1) {
- vid_get_info(V_ADP_SECONDARY,
- adapter[V_ADP_SECONDARY].va_initial_mode, &info);
- adapter[V_ADP_SECONDARY].va_window = BIOS_PADDRTOVADDR(info.vi_window);
- adapter[V_ADP_SECONDARY].va_window_size = info.vi_window_size;
- adapter[V_ADP_SECONDARY].va_window_gran = info.vi_window_gran;
- adapter[V_ADP_SECONDARY].va_buffer = BIOS_PADDRTOVADDR(info.vi_buffer);
- adapter[V_ADP_SECONDARY].va_buffer_size = info.vi_buffer_size;
- }
-
- /*
- * XXX: we should verify the following values for the primary adapter...
- * crtc I/O port address: *(u_int16_t *)BIOS_PADDRTOVADDR(0x463);
- * color/mono display: (*(u_int8_t *)BIOS_PADDRTOVADDR(0x487) & 0x02)
- * ? 0 : V_ADP_COLOR;
- * columns: *(u_int8_t *)BIOS_PADDRTOVADDR(0x44a);
- * rows: *(u_int8_t *)BIOS_PADDRTOVADDR(0x484);
- * font size: *(u_int8_t *)BIOS_PADDRTOVADDR(0x485);
- * buffer size: *(u_int16_t *)BIOS_PADDRTOVADDR(0x44c);
- */
-
- return adapters;
-}
-
-/* all adapters */
-static video_adapter_t
-*vid_adapter(int ad)
-{
- if (!init_done)
- return NULL;
- if ((ad < 0) || (ad >= adapters))
- return NULL;
- return &adapter[ad];
-}
-
-/* all adapters */
-static int
-vid_get_info(int ad, int mode, video_info_t *info)
-{
- int i;
-
- if (!init_done)
- return 1;
- if ((ad < 0) || (ad >= adapters))
- return 1;
-
- if (adapter[ad].va_flags & V_ADP_MODECHANGE) {
- /*
- * If the parameter table entry for this mode is not found,
- * the mode is not supported...
- */
- if (get_mode_param(mode) == NULL)
- return 1;
- } else {
- /*
- * Even if we don't support video mode switching on this adapter,
- * the information on the initial (thus current) video mode
- * should be made available.
- */
- if (mode != adapter[ad].va_initial_mode)
- return 1;
- }
-
- for (i = 0; bios_vmode[i].vi_mode != EOT; ++i) {
- if (bios_vmode[i].vi_mode == NA)
- continue;
- if (mode == bios_vmode[i].vi_mode) {
- *info = bios_vmode[i];
- return 0;
- }
- }
- return 1;
-}
-
-/* all adapters */
-static int
-vid_query_mode(int ad, video_info_t *info)
-{
- video_info_t buf;
- int i;
-
- if (!init_done)
- return -1;
- if ((ad < 0) || (ad >= adapters))
- return -1;
-
- for (i = 0; bios_vmode[i].vi_mode != EOT; ++i) {
- if (bios_vmode[i].vi_mode == NA)
- continue;
-
- if ((info->vi_width != 0)
- && (info->vi_width != bios_vmode[i].vi_width))
- continue;
- if ((info->vi_height != 0)
- && (info->vi_height != bios_vmode[i].vi_height))
- continue;
- if ((info->vi_cwidth != 0)
- && (info->vi_cwidth != bios_vmode[i].vi_cwidth))
- continue;
- if ((info->vi_cheight != 0)
- && (info->vi_cheight != bios_vmode[i].vi_cheight))
- continue;
- if ((info->vi_depth != 0)
- && (info->vi_depth != bios_vmode[i].vi_depth))
- continue;
- if ((info->vi_planes != 0)
- && (info->vi_planes != bios_vmode[i].vi_planes))
- continue;
- /* XXX: should check pixel format, memory model */
- if ((info->vi_flags != 0)
- && (info->vi_flags != bios_vmode[i].vi_flags))
- continue;
-
- /* verify if this mode is supported on this adapter */
- if (vid_get_info(ad, bios_vmode[i].vi_mode, &buf))
- continue;
- return bios_vmode[i].vi_mode;
- }
- return -1;
-}
-
-/* EGA/VGA */
-static int
-vid_set_mode(int ad, int mode)
-{
- video_info_t info;
- adp_state_t params;
-
- prologue(ad, V_ADP_MODECHANGE, 1);
-
- if (vid_get_info(ad, mode, &info))
- return 1;
- params.sig = V_STATE_SIG;
- bcopy(get_mode_param(mode), params.regs, sizeof(params.regs));
-
- switch (mode) {
- case M_VGA_C80x60: case M_VGA_M80x60:
- params.regs[2] = 0x08;
- params.regs[19] = 0x47;
- goto special_480l;
-
- case M_VGA_C80x30: case M_VGA_M80x30:
- params.regs[19] = 0x4f;
-special_480l:
- params.regs[9] |= 0xc0;
- params.regs[16] = 0x08;
- params.regs[17] = 0x3e;
- params.regs[26] = 0xea;
- params.regs[28] = 0xdf;
- params.regs[31] = 0xe7;
- params.regs[32] = 0x04;
- goto setup_mode;
-
- case M_ENH_C80x43: case M_ENH_B80x43:
- params.regs[28] = 87;
- goto special_80x50;
-
- case M_VGA_C80x50: case M_VGA_M80x50:
-special_80x50:
- params.regs[2] = 8;
- params.regs[19] = 7;
- goto setup_mode;
-
- case M_VGA_C40x25: case M_VGA_C80x25:
- case M_VGA_M80x25:
- case M_B40x25: case M_C40x25:
- case M_B80x25: case M_C80x25:
- case M_ENH_B40x25: case M_ENH_C40x25:
- case M_ENH_B80x25: case M_ENH_C80x25:
- case M_EGAMONO80x25:
-
-setup_mode:
- vid_load_state(ad, &params);
- break;
-
- case M_VGA_MODEX:
- /* "unchain" the VGA mode */
- params.regs[5-1+0x04] &= 0xf7;
- params.regs[5-1+0x04] |= 0x04;
- /* turn off doubleword mode */
- params.regs[10+0x14] &= 0xbf;
- /* turn off word adressing */
- params.regs[10+0x17] |= 0x40;
- /* set logical screen width */
- params.regs[10+0x13] = 80;
- /* set 240 lines */
- params.regs[10+0x11] = 0x2c;
- params.regs[10+0x06] = 0x0d;
- params.regs[10+0x07] = 0x3e;
- params.regs[10+0x10] = 0xea;
- params.regs[10+0x11] = 0xac;
- params.regs[10+0x12] = 0xdf;
- params.regs[10+0x15] = 0xe7;
- params.regs[10+0x16] = 0x06;
- /* set vertical sync polarity to reflect aspect ratio */
- params.regs[9] = 0xe3;
- goto setup_grmode;
-
- case M_BG320: case M_CG320: case M_BG640:
- case M_CG320_D: case M_CG640_E:
- case M_CG640x350: case M_ENH_CG640:
- case M_BG640x480: case M_CG640x480: case M_VGA_CG320:
-
-setup_grmode:
- vid_load_state(ad, &params);
- break;
-
- default:
- return 1;
- }
-
- adapter[ad].va_mode = mode;
- adapter[ad].va_flags &= ~V_ADP_COLOR;
- adapter[ad].va_flags |=
- (info.vi_flags & V_INFO_COLOR) ? V_ADP_COLOR : 0;
- adapter[ad].va_crtc_addr =
- (adapter[ad].va_flags & V_ADP_COLOR) ? COLOR_BASE : MONO_BASE;
- adapter[ad].va_window = BIOS_PADDRTOVADDR(info.vi_window);
- adapter[ad].va_window_size = info.vi_window_size;
- adapter[ad].va_window_gran = info.vi_window_gran;
- if (info.vi_buffer_size == 0) {
- adapter[ad].va_buffer = 0;
- adapter[ad].va_buffer_size = 0;
- } else {
- adapter[ad].va_buffer = BIOS_PADDRTOVADDR(info.vi_buffer);
- adapter[ad].va_buffer_size = info.vi_buffer_size;
- }
-
- return 0;
-}
-
-static void
-set_font_mode(video_adapter_t *adp, u_char *buf)
-{
- u_char *mp;
- int s;
-
- s = splhigh();
-
- /* save register values */
- if (adp->va_type == KD_VGA) {
- outb(TSIDX, 0x02); buf[0] = inb(TSREG);
- outb(TSIDX, 0x04); buf[1] = inb(TSREG);
- outb(GDCIDX, 0x04); buf[2] = inb(GDCREG);
- outb(GDCIDX, 0x05); buf[3] = inb(GDCREG);
- outb(GDCIDX, 0x06); buf[4] = inb(GDCREG);
- inb(adp->va_crtc_addr + 6);
- outb(ATC, 0x10); buf[5] = inb(ATC + 1);
- } else /* if (adp->va_type == KD_EGA) */ {
- /*
- * EGA cannot be read; copy parameters from the mode parameter
- * table.
- */
- mp = get_mode_param(adp->va_mode);
- buf[0] = mp[5 + 0x02 - 1];
- buf[1] = mp[5 + 0x04 - 1];
- buf[2] = mp[55 + 0x04];
- buf[3] = mp[55 + 0x05];
- buf[4] = mp[55 + 0x06];
- buf[5] = mp[35 + 0x10];
- }
-
- /* setup vga for loading fonts */
- inb(adp->va_crtc_addr + 6); /* reset flip-flop */
- outb(ATC, 0x10); outb(ATC, buf[5] & ~0x01);
- inb(adp->va_crtc_addr + 6); /* reset flip-flop */
- outb(ATC, 0x20); /* enable palette */
-
-#if SLOW_VGA
-#ifndef SC_BAD_FLICKER
- outb(TSIDX, 0x00); outb(TSREG, 0x01);
-#endif
- outb(TSIDX, 0x02); outb(TSREG, 0x04);
- outb(TSIDX, 0x04); outb(TSREG, 0x07);
-#ifndef SC_BAD_FLICKER
- outb(TSIDX, 0x00); outb(TSREG, 0x03);
-#endif
- outb(GDCIDX, 0x04); outb(GDCREG, 0x02);
- outb(GDCIDX, 0x05); outb(GDCREG, 0x00);
- outb(GDCIDX, 0x06); outb(GDCREG, 0x04);
-#else
-#ifndef SC_BAD_FLICKER
- outw(TSIDX, 0x0100);
-#endif
- outw(TSIDX, 0x0402);
- outw(TSIDX, 0x0704);
-#ifndef SC_BAD_FLICKER
- outw(TSIDX, 0x0300);
-#endif
- outw(GDCIDX, 0x0204);
- outw(GDCIDX, 0x0005);
- outw(GDCIDX, 0x0406); /* addr = a0000, 64kb */
-#endif
-
- splx(s);
-}
-
-static void
-set_normal_mode(video_adapter_t *adp, u_char *buf)
-{
- int s;
-
- s = splhigh();
-
- /* setup vga for normal operation mode again */
- inb(adp->va_crtc_addr + 6); /* reset flip-flop */
- outb(ATC, 0x10); outb(ATC, buf[5]);
- inb(adp->va_crtc_addr + 6); /* reset flip-flop */
- outb(ATC, 0x20); /* enable palette */
-
-#if SLOW_VGA
-#ifndef SC_BAD_FLICKER
- outb(TSIDX, 0x00); outb(TSREG, 0x01);
-#endif
- outb(TSIDX, 0x02); outb(TSREG, buf[0]);
- outb(TSIDX, 0x04); outb(TSREG, buf[1]);
-#ifndef SC_BAD_FLICKER
- outb(TSIDX, 0x00); outb(TSREG, 0x03);
-#endif
- outb(GDCIDX, 0x04); outb(GDCREG, buf[2]);
- outb(GDCIDX, 0x05); outb(GDCREG, buf[3]);
- if (adp->va_crtc_addr == MONO_BASE) {
- outb(GDCIDX, 0x06); outb(GDCREG,(buf[4] & 0x03) | 0x08);
- } else {
- outb(GDCIDX, 0x06); outb(GDCREG,(buf[4] & 0x03) | 0x0c);
- }
-#else
-#ifndef SC_BAD_FLICKER
- outw(TSIDX, 0x0100);
-#endif
- outw(TSIDX, 0x0002 | (buf[0] << 8));
- outw(TSIDX, 0x0004 | (buf[1] << 8));
-#ifndef SC_BAD_FLICKER
- outw(TSIDX, 0x0300);
-#endif
- outw(GDCIDX, 0x0004 | (buf[2] << 8));
- outw(GDCIDX, 0x0005 | (buf[3] << 8));
- if (adp->va_crtc_addr == MONO_BASE)
- outw(GDCIDX, 0x0006 | (((buf[4] & 0x03) | 0x08)<<8));
- else
- outw(GDCIDX, 0x0006 | (((buf[4] & 0x03) | 0x0c)<<8));
-#endif
-
- splx(s);
-}
-
-/* EGA/VGA */
-static int
-vid_save_font(int ad, int page, int fontsize, u_char *data, int ch, int count)
-{
- u_char buf[PARAM_BUFSIZE];
- u_char val = 0;
- u_int32_t segment;
- int c;
- int s;
-
- prologue(ad, V_ADP_FONT, 1);
-
- if (fontsize < 14) {
- /* FONT_8 */
- fontsize = 8;
- } else if (fontsize >= 32) {
- fontsize = 32;
- } else if (fontsize >= 16) {
- /* FONT_16 */
- fontsize = 16;
- } else {
- /* FONT_14 */
- fontsize = 14;
- }
-
- if (page < 0 || page >= 8)
- return 1;
- segment = VIDEOMEM + 0x4000*page;
- if (page > 3)
- segment -= 0xe000;
-
- if (adapter[ad].va_type == KD_VGA) { /* what about EGA? XXX */
- s = splhigh();
- outb(TSIDX, 0x00); outb(TSREG, 0x01);
- outb(TSIDX, 0x01); val = inb(TSREG); /* disable screen */
- outb(TSIDX, 0x01); outb(TSREG, val | 0x20);
- outb(TSIDX, 0x00); outb(TSREG, 0x03);
- splx(s);
- }
-
- set_font_mode(&adapter[ad], buf);
- if (fontsize == 32) {
- memcpy_fromio(data, BIOS_PADDRTOVADDR(segment + ch*32),
- fontsize*count);
- } else {
- for (c = ch; count > 0; ++c, --count) {
- memcpy_fromio(data, BIOS_PADDRTOVADDR(segment + c*32),
- fontsize);
- data += fontsize;
- }
- }
- set_normal_mode(&adapter[ad], buf);
-
- if (adapter[ad].va_type == KD_VGA) {
- s = splhigh();
- outb(TSIDX, 0x00); outb(TSREG, 0x01);
- outb(TSIDX, 0x01); outb(TSREG, val & 0xdf); /* enable screen */
- outb(TSIDX, 0x00); outb(TSREG, 0x03);
- splx(s);
- }
-
- return 0;
-}
-
-/* EGA/VGA */
-static int
-vid_load_font(int ad, int page, int fontsize, u_char *data, int ch, int count)
-{
- u_char buf[PARAM_BUFSIZE];
- u_char val = 0;
- u_int32_t segment;
- int c;
- int s;
-
- prologue(ad, V_ADP_FONT, 1);
-
- if (fontsize < 14) {
- /* FONT_8 */
- fontsize = 8;
- } else if (fontsize >= 32) {
- fontsize = 32;
- } else if (fontsize >= 16) {
- /* FONT_16 */
- fontsize = 16;
- } else {
- /* FONT_14 */
- fontsize = 14;
- }
-
- if (page < 0 || page >= 8)
- return 1;
- segment = VIDEOMEM + 0x4000*page;
- if (page > 3)
- segment -= 0xe000;
-
- if (adapter[ad].va_type == KD_VGA) { /* what about EGA? XXX */
- s = splhigh();
- outb(TSIDX, 0x00); outb(TSREG, 0x01);
- outb(TSIDX, 0x01); val = inb(TSREG); /* disable screen */
- outb(TSIDX, 0x01); outb(TSREG, val | 0x20);
- outb(TSIDX, 0x00); outb(TSREG, 0x03);
- splx(s);
- }
-
- set_font_mode(&adapter[ad], buf);
- if (fontsize == 32) {
- memcpy_toio(BIOS_PADDRTOVADDR(segment + ch*32), data,
- fontsize*count);
- } else {
- for (c = ch; count > 0; ++c, --count) {
- memcpy_toio(BIOS_PADDRTOVADDR(segment + c*32), data,
- fontsize);
- data += fontsize;
- }
- }
- set_normal_mode(&adapter[ad], buf);
-
- if (adapter[ad].va_type == KD_VGA) {
- s = splhigh();
- outb(TSIDX, 0x00); outb(TSREG, 0x01);
- outb(TSIDX, 0x01); outb(TSREG, val & 0xdf); /* enable screen */
- outb(TSIDX, 0x00); outb(TSREG, 0x03);
- splx(s);
- }
-
- return 0;
-}
-
-/* EGA/VGA */
-static int
-vid_show_font(int ad, int page)
-{
- static u_char cg[] = { 0x00, 0x05, 0x0a, 0x0f, 0x30, 0x35, 0x3a, 0x3f };
- int s;
-
- prologue(ad, V_ADP_FONT, 1);
- if (page < 0 || page >= 8)
- return 1;
-
- s = splhigh();
- outb(TSIDX, 0x03); outb(TSREG, cg[page]);
- splx(s);
-
- return 0;
-}
-
-/* VGA */
-static int
-vid_save_palette(int ad, u_char *palette)
-{
- int i;
-
- prologue(ad, V_ADP_PALETTE, 1);
-
- /*
- * We store 8 bit values in the palette buffer, while the standard
- * VGA has 6 bit DAC .
- */
- outb(PALRADR, 0x00);
- for (i = 0; i < 256*3; ++i)
- palette[i] = inb(PALDATA) << 2;
- inb(adapter[ad].va_crtc_addr + 6); /* reset flip/flop */
- return 0;
-}
-
-/* VGA */
-static int
-vid_load_palette(int ad, u_char *palette)
-{
- int i;
-
- prologue(ad, V_ADP_PALETTE, 1);
-
- outb(PIXMASK, 0xff); /* no pixelmask */
- outb(PALWADR, 0x00);
- for (i = 0; i < 256*3; ++i)
- outb(PALDATA, palette[i] >> 2);
- inb(adapter[ad].va_crtc_addr + 6); /* reset flip/flop */
- outb(ATC, 0x20); /* enable palette */
- return 0;
-}
-
-/* CGA/EGA/VGA */
-static int
-vid_set_border(int ad, int color)
-{
- prologue(ad, V_ADP_BORDER, 1);
-
- switch (adapter[ad].va_type) {
- case KD_EGA:
- case KD_VGA:
- inb(adapter[ad].va_crtc_addr + 6); /* reset flip-flop */
- outb(ATC, 0x31); outb(ATC, color & 0xff);
- break;
- case KD_CGA:
- outb(adapter[ad].va_crtc_addr + 5, color & 0x0f); /* color select register */
- break;
- case KD_MONO:
- case KD_HERCULES:
- default:
- break;
- }
- return 0;
-}
-
-/* VGA */
-static int
-vid_save_state(int ad, void *p, size_t size)
-{
- video_info_t info;
- u_char *buf;
- int crtc_addr;
- int i, j;
- int s;
-
- if (size == 0) {
- /* return the required buffer size */
- prologue(ad, V_ADP_STATESAVE, 0);
- return sizeof(adp_state_t);
- } else {
- prologue(ad, V_ADP_STATESAVE, 1);
- if (size < sizeof(adp_state_t))
- return 1;
- }
-
- ((adp_state_t *)p)->sig = V_STATE_SIG;
- buf = ((adp_state_t *)p)->regs;
- bzero(buf, V_MODE_PARAM_SIZE);
- crtc_addr = adapter[ad].va_crtc_addr;
-
- s = splhigh();
-
- outb(TSIDX, 0x00); outb(TSREG, 0x01); /* stop sequencer */
- for (i = 0, j = 5; i < 4; i++) {
- outb(TSIDX, i + 1);
- buf[j++] = inb(TSREG);
- }
- buf[9] = inb(MISC + 10); /* dot-clock */
- outb(TSIDX, 0x00); outb(TSREG, 0x03); /* start sequencer */
-
- for (i = 0, j = 10; i < 25; i++) { /* crtc */
- outb(crtc_addr, i);
- buf[j++] = inb(crtc_addr + 1);
- }
- for (i = 0, j = 35; i < 20; i++) { /* attribute ctrl */
- inb(crtc_addr + 6); /* reset flip-flop */
- outb(ATC, i);
- buf[j++] = inb(ATC + 1);
- }
- for (i = 0, j = 55; i < 9; i++) { /* graph data ctrl */
- outb(GDCIDX, i);
- buf[j++] = inb(GDCREG);
- }
- inb(crtc_addr + 6); /* reset flip-flop */
- outb(ATC, 0x20); /* enable palette */
-
- splx(s);
-
-#if 1
- if (vid_get_info(ad, adapter[ad].va_mode, &info) == 0) {
- if (info.vi_flags & V_INFO_GRAPHICS) {
- buf[0] = info.vi_width/info.vi_cwidth; /* COLS */
- buf[1] = info.vi_height/info.vi_cheight - 1; /* ROWS */
- } else {
- buf[0] = info.vi_width; /* COLS */
- buf[1] = info.vi_height - 1; /* ROWS */
- }
- buf[2] = info.vi_cheight; /* POINTS */
- } else {
- /* XXX: shouldn't be happening... */
- printf("video#%d: failed to obtain mode info. (vid_save_state())\n",
- ad);
- }
-#else
- buf[0] = *(u_int8_t *)BIOS_PADDRTOVADDR(0x44a); /* COLS */
- buf[1] = *(u_int8_t *)BIOS_PADDRTOVADDR(0x484); /* ROWS */
- buf[2] = *(u_int8_t *)BIOS_PADDRTOVADDR(0x485); /* POINTS */
- buf[3] = *(u_int8_t *)BIOS_PADDRTOVADDR(0x44c);
- buf[4] = *(u_int8_t *)BIOS_PADDRTOVADDR(0x44d);
-#endif
-
- return 0;
-}
-
-/* EGA/VGA */
-static int
-vid_load_state(int ad, void *p)
-{
- u_char *buf;
- int crtc_addr;
- int s;
- int i;
-
- prologue(ad, V_ADP_STATELOAD, 1);
- if (((adp_state_t *)p)->sig != V_STATE_SIG)
- return 1;
-
- buf = ((adp_state_t *)p)->regs;
- crtc_addr = adapter[ad].va_crtc_addr;
-
- s = splhigh();
-
- outb(TSIDX, 0x00); outb(TSREG, 0x01); /* stop sequencer */
- for (i = 0; i < 4; ++i) { /* program sequencer */
- outb(TSIDX, i + 1);
- outb(TSREG, buf[i + 5]);
- }
- outb(MISC, buf[9]); /* set dot-clock */
- outb(TSIDX, 0x00); outb(TSREG, 0x03); /* start sequencer */
- outb(crtc_addr, 0x11);
- outb(crtc_addr + 1, inb(crtc_addr + 1) & 0x7F);
- for (i = 0; i < 25; ++i) { /* program crtc */
- outb(crtc_addr, i);
- outb(crtc_addr + 1, buf[i + 10]);
- }
- inb(crtc_addr+6); /* reset flip-flop */
- for (i = 0; i < 20; ++i) { /* program attribute ctrl */
- outb(ATC, i);
- outb(ATC, buf[i + 35]);
- }
- for (i = 0; i < 9; ++i) { /* program graph data ctrl */
- outb(GDCIDX, i);
- outb(GDCREG, buf[i + 55]);
- }
- inb(crtc_addr + 6); /* reset flip-flop */
- outb(ATC, 0x20); /* enable palette */
-
-#ifdef __i386__
- if (ad == V_ADP_PRIMARY) {
- *(u_int8_t *)BIOS_PADDRTOVADDR(0x44a) = buf[0]; /* COLS */
- *(u_int8_t *)BIOS_PADDRTOVADDR(0x484) = buf[1] + rows_offset - 1; /* ROWS */
- *(u_int8_t *)BIOS_PADDRTOVADDR(0x485) = buf[2]; /* POINTS */
-#if 0
- *(u_int8_t *)BIOS_PADDRTOVADDR(0x44c) = buf[3];
- *(u_int8_t *)BIOS_PADDRTOVADDR(0x44d) = buf[4];
-#endif
- }
-#endif
-
- splx(s);
- return 0;
-}
-
-/* all */
-static int
-vid_set_origin(int ad, off_t offset)
-{
- /*
- * The standard video modes do not require window mapping;
- * always return error.
- */
- return 1;
-}
-
-/* all */
-static int
-vid_read_hw_cursor(int ad, int *col, int *row)
-{
- video_info_t info;
- u_int16_t off;
-
- if (!init_done)
- return 1;
- if ((ad < 0) || (ad >= adapters))
- return 1;
-
- (*biosvidsw.get_info)(ad, adapter[ad].va_mode, &info);
- if (info.vi_flags & V_INFO_GRAPHICS)
- return 1;
-
- outb(adapter[ad].va_crtc_addr, 14);
- off = inb(adapter[ad].va_crtc_addr + 1);
- outb(adapter[ad].va_crtc_addr, 15);
- off = (off << 8) | inb(adapter[ad].va_crtc_addr + 1);
-
- *row = off / info.vi_width;
- *col = off % info.vi_width;
-
- return 0;
-}
-
-/* all */
-static int
-vid_set_hw_cursor(int ad, int col, int row)
-{
- video_info_t info;
- u_int16_t off;
-
- if (!init_done)
- return 1;
- if ((ad < 0) || (ad >= adapters))
- return 1;
-
- (*biosvidsw.get_info)(ad, adapter[ad].va_mode, &info);
- if (info.vi_flags & V_INFO_GRAPHICS)
- return 1;
-
- if ((col == -1) || (row == -1))
- off = 0xffff;
- else
- off = row*info.vi_width + col;
- outb(adapter[ad].va_crtc_addr, 14);
- outb(adapter[ad].va_crtc_addr + 1, off >> 8);
- outb(adapter[ad].va_crtc_addr, 15);
- outb(adapter[ad].va_crtc_addr + 1, off & 0x00ff);
-
- return 0;
-}
-
-static char
-*adapter_name(int type)
-{
- static struct {
- int type;
- char *name;
- } names[] = {
- { KD_MONO, "MDA" },
- { KD_HERCULES, "Hercules" },
- { KD_CGA, "CGA" },
- { KD_EGA, "EGA" },
- { KD_VGA, "VGA" },
- { KD_PC98, "PC-98xx" },
- { -1, "Unknown" },
- };
- int i;
-
- for (i = 0; names[i].type != -1; ++i)
- if (names[i].type == type)
- break;
- return names[i].name;
-}
-
-static void
-dump_adp_info(int ad, video_adapter_t *adp, int level)
-{
- if (level <= 0)
- return;
-
- printf("video#%d: adapter type:%s (%d), flags:0x%x, CRTC:0x%x\n",
- ad, adapter_name(adp->va_type), adp->va_type,
- adp->va_flags, adp->va_crtc_addr);
- printf("video#%d: init mode:%d, bios mode:%d, current mode:%d\n",
- ad, adp->va_initial_mode, adp->va_initial_bios_mode, adp->va_mode);
- printf("video#%d: window:0x%x size:%dk gran:%dk, buf:0x%x size:%dk\n",
- ad,
- adp->va_window, (int)adp->va_window_size, (int)adp->va_window_gran,
- adp->va_buffer, (int)adp->va_buffer_size);
-}
-
-static void
-dump_mode_info(int ad, video_info_t *info, int level)
-{
- if (level <= 0)
- return;
-
- printf("video#%d: mode:%d, flags:0x%x ",
- ad, info->vi_mode, info->vi_flags);
- if (info->vi_flags & V_INFO_GRAPHICS)
- printf("G %dx%dx%d, %d plane(s), font:%dx%d, ",
- info->vi_width, info->vi_height,
- info->vi_depth, info->vi_planes,
- info->vi_cwidth, info->vi_cheight);
- else
- printf("T %dx%d, font:%dx%d, ",
- info->vi_width, info->vi_height,
- info->vi_cwidth, info->vi_cheight);
- printf("win:0x%x\n", info->vi_window);
-}
-
-static void
-dump_buffer(u_char *buf, size_t len)
-{
- int i;
-
- for(i = 0; i < len;) {
- printf("%02x ", buf[i]);
- if ((++i % 16) == 0)
- printf("\n");
- }
-}
-
-static int
-vid_diag(int level)
-{
- video_info_t info;
- u_char *mp;
- int ad;
- int i;
-
- if (!init_done)
- return 1;
-
-#ifdef __i386__
- if (level > 0) {
- printf("video: RTC equip. code:0x%02x, DCC code:0x%02x\n",
- rtcin(RTC_EQUIPMENT), *(u_int8_t *)BIOS_PADDRTOVADDR(0x488));
- printf("video: CRTC:0x%x, video option:0x%02x, ",
- *(u_int16_t *)BIOS_PADDRTOVADDR(0x463),
- *(u_int8_t *)BIOS_PADDRTOVADDR(0x487));
- printf("rows:%d, cols:%d, font height:%d\n",
- *(u_int8_t *)BIOS_PADDRTOVADDR(0x44a),
- *(u_int8_t *)BIOS_PADDRTOVADDR(0x484) + 1,
- *(u_int8_t *)BIOS_PADDRTOVADDR(0x485));
- printf("video: param table EGA/VGA:%p, CGA/MDA:%p\n",
- video_mode_ptr, video_mode_ptr2);
- printf("video: rows_offset:%d\n", rows_offset);
- }
-#endif
-
- for (ad = 0; ad < adapters; ++ad) {
- dump_adp_info(ad, &adapter[ad], level);
-
- if (!(adapter[ad].va_flags & V_ADP_MODECHANGE)) {
- vid_get_info(ad, adapter[ad].va_initial_mode, &info);
- dump_mode_info(ad, &info, level);
- } else {
- for (i = 0; bios_vmode[i].vi_mode != EOT; ++i) {
- if (bios_vmode[i].vi_mode == NA)
- continue;
- if (get_mode_param(bios_vmode[i].vi_mode) == NULL)
- continue;
- dump_mode_info(ad, &bios_vmode[i], level);
- }
- }
- if ((adapter[ad].va_type != KD_EGA) && (adapter[ad].va_type != KD_VGA))
- continue;
-
- if (video_mode_ptr == NULL)
- printf("video#%d: WARNING: video mode switching is not fully supported on this adapter\n", ad);
-
- if (level <= 0)
- continue;
-
- if (adapter[ad].va_type == KD_VGA) {
- printf("VGA parameters upon power-up\n");
- dump_buffer(adpstate.regs, sizeof(adpstate.regs));
- printf("VGA parameters in BIOS for mode %d\n",
- adapter[ad].va_initial_mode);
- dump_buffer(adpstate2.regs, sizeof(adpstate2.regs));
- }
-
- mp = get_mode_param(adapter[ad].va_initial_mode);
- if (mp == NULL) /* this shouldn't be happening */
- continue;
- printf("EGA/VGA parameters to be used for mode %d\n",
- adapter[ad].va_initial_mode);
- dump_buffer(mp, V_MODE_PARAM_SIZE);
- }
-
- return 0;
-}
-
-#endif /* NSC > 0 */
diff --git a/sys/isa/videoio.h b/sys/isa/videoio.h
deleted file mode 100644
index d004478..0000000
--- a/sys/isa/videoio.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*-
- * Copyright (c) 1998 Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id$
- * from: i386/isa/videoio.h,v 1.1
- */
-
-#ifndef _I386_ISA_VIDEOIO_H_
-#define _I386_ISA_VIDEOIO_H_
-
-#ifdef KERNEL
-
-#define V_MAX_ADAPTERS 2
-
-#define V_MODE_MAP_SIZE (M_VGA_CG320 + 1)
-#define V_MODE_PARAM_SIZE 64
-
-/* physical addresses */
-#define MONO_BUF BIOS_PADDRTOVADDR(0xb0000)
-#define CGA_BUF BIOS_PADDRTOVADDR(0xb8000)
-#define GRAPHICS_BUF BIOS_PADDRTOVADDR(0xa0000)
-#define VIDEOMEM 0x000A0000
-
-/* I/O port addresses */
-#define MONO_BASE 0x3B4 /* crt controller base mono */
-#define COLOR_BASE 0x3D4 /* crt controller base color */
-#define MISC 0x3C2 /* misc output register */
-#define ATC IO_VGA+0x00 /* attribute controller */
-#define TSIDX IO_VGA+0x04 /* timing sequencer idx */
-#define TSREG IO_VGA+0x05 /* timing sequencer data */
-#define PIXMASK IO_VGA+0x06 /* pixel write mask */
-#define PALRADR IO_VGA+0x07 /* palette read address */
-#define PALWADR IO_VGA+0x08 /* palette write address */
-#define PALDATA IO_VGA+0x09 /* palette data register */
-#define GDCIDX IO_VGA+0x0E /* graph data controller idx */
-#define GDCREG IO_VGA+0x0F /* graph data controller data */
-
-/* video function table */
-typedef int vi_init_t(void);
-typedef video_adapter_t *vi_adapter_t(int ad);
-typedef int vi_get_info_t(int ad, int mode, video_info_t *info);
-typedef int vi_query_mode_t(int ad, video_info_t *info);
-typedef int vi_set_mode_t(int ad, int mode);
-typedef int vi_save_font_t(int ad, int page, int size, u_char *data,
- int c, int count);
-typedef int vi_load_font_t(int ad, int page, int size, u_char *data,
- int c, int count);
-typedef int vi_show_font_t(int ad, int page);
-typedef int vi_save_palette_t(int ad, u_char *palette);
-typedef int vi_load_palette_t(int ad, u_char *palette);
-typedef int vi_set_border_t(int ad, int border);
-typedef int vi_save_state_t(int ad, void *p, size_t size);
-typedef int vi_load_state_t(int ad, void *p);
-typedef int vi_set_win_org_t(int ad, off_t offset);
-typedef int vi_read_hw_cursor_t(int ad, int *col, int *row);
-typedef int vi_set_hw_cursor_t(int ad, int col, int row);
-typedef int vi_diag_t(int level);
-
-struct vidsw {
- vi_init_t *init; /* all */
- vi_adapter_t *adapter; /* all */
- vi_get_info_t *get_info; /* all */
- vi_query_mode_t *query_mode; /* all */
- vi_set_mode_t *set_mode; /* EGA/VGA */
- vi_save_font_t *save_font; /* EGA/VGA */
- vi_load_font_t *load_font; /* EGA/VGA */
- vi_show_font_t *show_font; /* EGA/VGA */
- vi_save_palette_t *save_palette; /* VGA */
- vi_load_palette_t *load_palette; /* VGA */
- vi_set_border_t *set_border; /* CGA/EGA/VGA */
- vi_save_state_t *save_state; /* VGA */
- vi_load_state_t *load_state; /* EGA/VGA */
- vi_set_win_org_t *set_win_org; /* all */
- vi_read_hw_cursor_t *read_hw_cursor; /* all */
- vi_set_hw_cursor_t *set_hw_cursor; /* all */
- vi_diag_t *diag; /* all */
-};
-
-extern struct vidsw biosvidsw;
-
-#endif /* KERNEL */
-
-#endif /* !_I386_ISA_VIDEOIO_H_ */
OpenPOWER on IntegriCloud