1996-05-05 23:48:15 +04:00
|
|
|
/* $NetBSD: pccons.c,v 1.98 1996/05/05 19:48:15 christos Exp $ */
|
1994-10-27 07:14:23 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*-
|
1995-04-19 23:10:35 +04:00
|
|
|
* Copyright (c) 1993, 1994, 1995 Charles Hannum. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
* Copyright (c) 1990 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* William Jolitz and Don Ahn.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
1994-10-27 07:14:23 +03:00
|
|
|
* @(#)pccons.c 5.11 (Berkeley) 5/21/91
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1993-04-10 16:04:35 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* code to work keyboard & display for PC-style console
|
|
|
|
*/
|
1994-02-23 02:01:22 +03:00
|
|
|
|
1993-12-20 12:05:17 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/user.h>
|
|
|
|
#include <sys/select.h>
|
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/callout.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/syslog.h>
|
1994-02-23 02:01:22 +03:00
|
|
|
#include <sys/device.h>
|
1993-12-20 12:05:17 +03:00
|
|
|
|
1994-02-01 06:42:08 +03:00
|
|
|
#include <dev/cons.h>
|
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
#include <machine/cpu.h>
|
1993-12-20 12:05:17 +03:00
|
|
|
#include <machine/pio.h>
|
|
|
|
#include <machine/pc/display.h>
|
1994-02-23 02:01:22 +03:00
|
|
|
#include <machine/pccons.h>
|
1996-05-03 23:14:50 +04:00
|
|
|
#include <machine/conf.h>
|
1993-12-20 12:05:17 +03:00
|
|
|
|
1995-04-17 16:06:30 +04:00
|
|
|
#include <dev/isa/isareg.h>
|
|
|
|
#include <dev/isa/isavar.h>
|
|
|
|
#include <i386/isa/isa_machdep.h>
|
1994-02-23 02:01:22 +03:00
|
|
|
#include <i386/isa/kbdreg.h>
|
1993-05-28 13:10:52 +04:00
|
|
|
|
1994-02-25 06:48:51 +03:00
|
|
|
#define XFREE86_BUG_COMPAT
|
|
|
|
|
1993-06-16 06:57:17 +04:00
|
|
|
#ifndef BEEP_FREQ
|
|
|
|
#define BEEP_FREQ 1500
|
|
|
|
#endif
|
|
|
|
#ifndef BEEP_TIME
|
1994-02-23 02:01:22 +03:00
|
|
|
#define BEEP_TIME (hz/5)
|
1993-06-16 06:57:17 +04:00
|
|
|
#endif
|
|
|
|
|
1993-07-11 11:54:47 +04:00
|
|
|
#define PCBURST 128
|
|
|
|
|
1995-04-21 08:51:30 +04:00
|
|
|
static u_short *Crtat; /* pointer to backing store */
|
1994-02-23 02:01:22 +03:00
|
|
|
static u_short *crtat; /* pointer to current char */
|
|
|
|
static volatile u_char ack, nak; /* Don't ask. */
|
|
|
|
static u_char async, kernel, polling; /* Really, you don't want to know. */
|
1994-12-01 14:12:04 +03:00
|
|
|
static u_char lock_state = 0x00, /* all off */
|
1994-02-25 06:48:51 +03:00
|
|
|
old_lock_state = 0xff,
|
|
|
|
typematic_rate = 0xff, /* don't update until set by user */
|
|
|
|
old_typematic_rate = 0xff;
|
1994-12-01 14:12:04 +03:00
|
|
|
static u_short cursor_shape = 0xffff, /* don't update until set by user */
|
1994-02-25 06:48:51 +03:00
|
|
|
old_cursor_shape = 0xffff;
|
1993-09-28 06:25:01 +03:00
|
|
|
int pc_xmode = 0;
|
1993-03-21 21:04:42 +03:00
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
#define PCUNIT(x) (minor(x))
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
static struct video_state {
|
1994-02-23 02:01:22 +03:00
|
|
|
int cx, cy; /* escape parameters */
|
1993-03-21 12:45:37 +03:00
|
|
|
int row, col; /* current cursor position */
|
1994-02-23 02:01:22 +03:00
|
|
|
int nrow, ncol, nchr; /* current screen geometry */
|
|
|
|
u_char state; /* parser state */
|
|
|
|
#define VSS_ESCAPE 1
|
|
|
|
#define VSS_EBRACE 2
|
|
|
|
#define VSS_EPARAM 3
|
|
|
|
char so; /* in standout mode? */
|
|
|
|
char color; /* color or mono display */
|
|
|
|
char at; /* normal attributes */
|
|
|
|
char so_at; /* standout attributes */
|
1993-03-21 12:45:37 +03:00
|
|
|
} vs;
|
|
|
|
|
1995-04-19 22:10:47 +04:00
|
|
|
struct pc_softc {
|
|
|
|
struct device sc_dev;
|
|
|
|
void *sc_ih;
|
|
|
|
struct tty *sc_tty;
|
1995-04-21 23:44:52 +04:00
|
|
|
};
|
1995-04-19 22:10:47 +04:00
|
|
|
|
1994-11-04 04:02:40 +03:00
|
|
|
int pcprobe __P((struct device *, void *, void *));
|
|
|
|
void pcattach __P((struct device *, struct device *, void *));
|
1995-04-17 16:06:30 +04:00
|
|
|
int pcintr __P((void *));
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1996-03-17 04:26:49 +03:00
|
|
|
struct cfattach pc_ca = {
|
|
|
|
sizeof(struct pc_softc), pcprobe, pcattach
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cfdriver pc_cd = {
|
|
|
|
NULL, "pc", DV_TTY
|
1993-03-21 12:45:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#define COL 80
|
|
|
|
#define ROW 25
|
|
|
|
#define CHR 2
|
|
|
|
|
|
|
|
/*
|
1994-02-23 02:01:22 +03:00
|
|
|
* DANGER WIL ROBINSON -- the values of SCROLL, NUM, CAPS, and ALT are
|
|
|
|
* important.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-02-23 02:01:22 +03:00
|
|
|
#define SCROLL 0x0001 /* stop output */
|
|
|
|
#define NUM 0x0002 /* numeric shift cursors vs. numeric */
|
|
|
|
#define CAPS 0x0004 /* caps shift -- swaps case of letter */
|
|
|
|
#define SHIFT 0x0008 /* keyboard shift */
|
|
|
|
#define CTL 0x0010 /* control shift -- allows ctl function */
|
|
|
|
#define ASCII 0x0020 /* ascii code for this key */
|
|
|
|
#define ALT 0x0080 /* alternate shift -- alternate chars */
|
|
|
|
#define FUNC 0x0100 /* function key */
|
|
|
|
#define KP 0x0200 /* Keypad keys */
|
|
|
|
#define NONE 0x0400 /* no function */
|
|
|
|
|
|
|
|
static unsigned int addr_6845 = MONO_BASE;
|
|
|
|
|
|
|
|
char *sget __P((void));
|
|
|
|
void sput __P((u_char *, int));
|
1996-03-30 10:51:51 +03:00
|
|
|
void pc_xmode_on __P((void));
|
|
|
|
void pc_xmode_off __P((void));
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1996-05-03 23:14:50 +04:00
|
|
|
void pcstart __P((struct tty *));
|
|
|
|
int pcparam __P((struct tty *, struct termios *));
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
char partab[];
|
|
|
|
|
1996-05-03 23:14:50 +04:00
|
|
|
int kbd_cmd __P((u_char, u_char));
|
|
|
|
void set_cursor_shape __P((void));
|
|
|
|
void get_cursor_shape __P((void));
|
|
|
|
void do_async_update __P((void *));
|
|
|
|
void async_update __P((void));
|
|
|
|
|
|
|
|
static __inline int kbd_wait_output __P((void));
|
|
|
|
static __inline int kbd_wait_input __P((void));
|
|
|
|
static __inline void kbd_flush_input __P((void));
|
|
|
|
static u_char kbc_get8042cmd __P((void));
|
|
|
|
static int kbc_put8042cmd __P((u_char));
|
|
|
|
|
|
|
|
void pccnprobe __P((struct consdev *));
|
|
|
|
void pccninit __P((struct consdev *));
|
|
|
|
void pccnputc __P((dev_t, char));
|
|
|
|
int pccngetc __P((dev_t));
|
|
|
|
void pccnpollc __P((dev_t, int));
|
1993-09-28 06:25:01 +03:00
|
|
|
|
1994-10-09 12:28:54 +03:00
|
|
|
#define KBD_DELAY \
|
1996-05-03 23:14:50 +04:00
|
|
|
{ u_char x = inb(0x84); (void) x; } \
|
|
|
|
{ u_char x = inb(0x84); (void) x; } \
|
|
|
|
{ u_char x = inb(0x84); (void) x; } \
|
|
|
|
{ u_char x = inb(0x84); (void) x; }
|
1994-10-09 12:28:54 +03:00
|
|
|
|
1996-05-03 23:14:50 +04:00
|
|
|
static __inline int
|
1994-10-16 18:46:13 +03:00
|
|
|
kbd_wait_output()
|
1994-02-23 02:01:22 +03:00
|
|
|
{
|
|
|
|
u_int i;
|
1993-04-23 00:20:56 +04:00
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
for (i = 100000; i; i--)
|
1994-04-24 05:34:05 +04:00
|
|
|
if ((inb(KBSTATP) & KBS_IBF) == 0) {
|
1994-10-09 12:28:54 +03:00
|
|
|
KBD_DELAY;
|
1994-02-23 02:01:22 +03:00
|
|
|
return 1;
|
1994-04-24 05:34:05 +04:00
|
|
|
}
|
1994-02-23 02:01:22 +03:00
|
|
|
return 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1996-05-03 23:14:50 +04:00
|
|
|
static __inline int
|
1994-10-16 18:46:13 +03:00
|
|
|
kbd_wait_input()
|
|
|
|
{
|
|
|
|
u_int i;
|
|
|
|
|
|
|
|
for (i = 100000; i; i--)
|
|
|
|
if ((inb(KBSTATP) & KBS_DIB) != 0) {
|
|
|
|
KBD_DELAY;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-05-03 23:14:50 +04:00
|
|
|
static __inline void
|
1994-10-16 18:46:13 +03:00
|
|
|
kbd_flush_input()
|
|
|
|
{
|
|
|
|
u_int i;
|
|
|
|
|
|
|
|
for (i = 10; i; i--) {
|
|
|
|
if ((inb(KBSTATP) & KBS_DIB) == 0)
|
|
|
|
return;
|
|
|
|
KBD_DELAY;
|
|
|
|
(void) inb(KBDATAP);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-03-03 22:28:04 +03:00
|
|
|
#if 1
|
1993-03-21 21:04:42 +03:00
|
|
|
/*
|
1994-03-02 11:03:02 +03:00
|
|
|
* Get the current command byte.
|
|
|
|
*/
|
|
|
|
static u_char
|
|
|
|
kbc_get8042cmd()
|
|
|
|
{
|
|
|
|
|
1994-10-16 18:46:13 +03:00
|
|
|
if (!kbd_wait_output())
|
1994-03-02 11:03:02 +03:00
|
|
|
return -1;
|
|
|
|
outb(KBCMDP, K_RDCMDBYTE);
|
1994-10-16 18:46:13 +03:00
|
|
|
if (!kbd_wait_input())
|
1994-03-02 11:03:02 +03:00
|
|
|
return -1;
|
|
|
|
return inb(KBDATAP);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pass command byte to keyboard controller (8042).
|
1993-03-21 21:04:42 +03:00
|
|
|
*/
|
1994-02-23 02:01:22 +03:00
|
|
|
static int
|
1994-03-02 11:03:02 +03:00
|
|
|
kbc_put8042cmd(val)
|
1994-02-23 02:01:22 +03:00
|
|
|
u_char val;
|
1993-03-21 21:04:42 +03:00
|
|
|
{
|
|
|
|
|
1994-10-16 18:46:13 +03:00
|
|
|
if (!kbd_wait_output())
|
1994-02-23 02:01:22 +03:00
|
|
|
return 0;
|
|
|
|
outb(KBCMDP, K_LDCMDBYTE);
|
1994-10-16 18:46:13 +03:00
|
|
|
if (!kbd_wait_output())
|
1994-02-23 02:01:22 +03:00
|
|
|
return 0;
|
|
|
|
outb(KBOUTP, val);
|
|
|
|
return 1;
|
1993-03-21 21:04:42 +03:00
|
|
|
}
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Pass command to keyboard itself
|
|
|
|
*/
|
1994-02-23 02:01:22 +03:00
|
|
|
int
|
|
|
|
kbd_cmd(val, polling)
|
|
|
|
u_char val;
|
|
|
|
u_char polling;
|
1993-03-21 21:04:42 +03:00
|
|
|
{
|
1994-02-23 02:01:22 +03:00
|
|
|
u_int retries = 3;
|
|
|
|
register u_int i;
|
1993-03-21 21:04:42 +03:00
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
do {
|
1994-10-16 18:46:13 +03:00
|
|
|
if (!kbd_wait_output())
|
1994-02-23 02:01:22 +03:00
|
|
|
return 0;
|
|
|
|
ack = nak = 0;
|
|
|
|
outb(KBOUTP, val);
|
|
|
|
if (polling)
|
|
|
|
for (i = 100000; i; i--) {
|
|
|
|
if (inb(KBSTATP) & KBS_DIB) {
|
|
|
|
register u_char c;
|
1994-10-09 12:28:54 +03:00
|
|
|
|
|
|
|
KBD_DELAY;
|
1994-02-23 02:01:22 +03:00
|
|
|
c = inb(KBDATAP);
|
|
|
|
if (c == KBR_ACK || c == KBR_ECHO) {
|
|
|
|
ack = 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (c == KBR_RESEND) {
|
|
|
|
nak = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
printf("kbd_cmd: input char %x lost\n", c);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
for (i = 100000; i; i--) {
|
1994-10-16 18:46:13 +03:00
|
|
|
(void) inb(KBSTATP);
|
1994-02-23 02:01:22 +03:00
|
|
|
if (ack)
|
|
|
|
return 1;
|
|
|
|
if (nak)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!nak)
|
|
|
|
return 0;
|
|
|
|
} while (--retries);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1994-02-25 06:48:51 +03:00
|
|
|
void
|
|
|
|
set_cursor_shape()
|
|
|
|
{
|
1994-11-19 01:07:32 +03:00
|
|
|
register int iobase = addr_6845;
|
1994-02-25 06:48:51 +03:00
|
|
|
|
|
|
|
outb(iobase, 10);
|
1994-12-01 14:12:04 +03:00
|
|
|
outb(iobase+1, cursor_shape >> 8);
|
1994-02-25 06:48:51 +03:00
|
|
|
outb(iobase, 11);
|
|
|
|
outb(iobase+1, cursor_shape);
|
|
|
|
old_cursor_shape = cursor_shape;
|
|
|
|
}
|
|
|
|
|
1994-12-01 14:12:04 +03:00
|
|
|
void
|
|
|
|
get_cursor_shape()
|
|
|
|
{
|
|
|
|
register int iobase = addr_6845;
|
|
|
|
|
|
|
|
outb(iobase, 10);
|
|
|
|
cursor_shape = inb(iobase+1) << 8;
|
|
|
|
outb(iobase, 11);
|
|
|
|
cursor_shape |= inb(iobase+1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* real 6845's, as found on, MDA, Hercules or CGA cards, do
|
|
|
|
* not support reading the cursor shape registers. the 6845
|
|
|
|
* tri-states it's data bus. This is _normally_ read by the
|
|
|
|
* cpu as either 0x00 or 0xff.. in which case we just use
|
|
|
|
* a line cursor.
|
|
|
|
*/
|
|
|
|
if (cursor_shape == 0x0000 || cursor_shape == 0xffff)
|
|
|
|
cursor_shape = 0x0b10;
|
|
|
|
else
|
|
|
|
cursor_shape &= 0x1f1f;
|
|
|
|
}
|
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
void
|
1996-05-03 23:14:50 +04:00
|
|
|
do_async_update(v)
|
|
|
|
void *v;
|
1994-02-23 02:01:22 +03:00
|
|
|
{
|
1996-05-03 23:14:50 +04:00
|
|
|
u_char poll = v ? 1 : 0;
|
1994-02-25 08:15:31 +03:00
|
|
|
int pos;
|
1994-02-25 06:48:51 +03:00
|
|
|
static int old_pos = -1;
|
1994-02-23 02:01:22 +03:00
|
|
|
|
|
|
|
async = 0;
|
|
|
|
|
1994-02-25 06:48:51 +03:00
|
|
|
if (lock_state != old_lock_state) {
|
|
|
|
old_lock_state = lock_state;
|
1994-02-23 02:01:22 +03:00
|
|
|
if (!kbd_cmd(KBC_MODEIND, poll) ||
|
|
|
|
!kbd_cmd(lock_state, poll)) {
|
|
|
|
printf("pc: timeout updating leds\n");
|
|
|
|
(void) kbd_cmd(KBC_ENABLE, poll);
|
|
|
|
}
|
|
|
|
}
|
1994-02-25 06:48:51 +03:00
|
|
|
if (typematic_rate != old_typematic_rate) {
|
|
|
|
old_typematic_rate = typematic_rate;
|
1994-02-23 02:01:22 +03:00
|
|
|
if (!kbd_cmd(KBC_TYPEMATIC, poll) ||
|
1994-02-25 06:48:51 +03:00
|
|
|
!kbd_cmd(typematic_rate, poll)) {
|
1994-02-23 02:01:22 +03:00
|
|
|
printf("pc: timeout updating typematic rate\n");
|
|
|
|
(void) kbd_cmd(KBC_ENABLE, poll);
|
|
|
|
}
|
|
|
|
}
|
1994-02-25 08:15:31 +03:00
|
|
|
|
|
|
|
if (pc_xmode > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pos = crtat - Crtat;
|
|
|
|
if (pos != old_pos) {
|
1994-11-19 01:07:32 +03:00
|
|
|
register int iobase = addr_6845;
|
1994-02-25 08:15:31 +03:00
|
|
|
outb(iobase, 14);
|
1994-12-01 14:12:04 +03:00
|
|
|
outb(iobase+1, pos >> 8);
|
1994-02-25 08:15:31 +03:00
|
|
|
outb(iobase, 15);
|
|
|
|
outb(iobase+1, pos);
|
|
|
|
old_pos = pos;
|
|
|
|
}
|
|
|
|
if (cursor_shape != old_cursor_shape)
|
|
|
|
set_cursor_shape();
|
1994-02-23 02:01:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
async_update()
|
|
|
|
{
|
|
|
|
|
|
|
|
if (kernel || polling) {
|
|
|
|
if (async)
|
1994-05-05 12:28:35 +04:00
|
|
|
untimeout(do_async_update, NULL);
|
1996-05-03 23:14:50 +04:00
|
|
|
do_async_update((void *)1);
|
1994-02-23 02:01:22 +03:00
|
|
|
} else {
|
|
|
|
if (async)
|
|
|
|
return;
|
|
|
|
async = 1;
|
1994-05-05 12:28:35 +04:00
|
|
|
timeout(do_async_update, NULL, 1);
|
1994-02-23 02:01:22 +03:00
|
|
|
}
|
1993-03-21 21:04:42 +03:00
|
|
|
}
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* these are both bad jokes
|
|
|
|
*/
|
1994-02-23 23:15:28 +03:00
|
|
|
int
|
1994-11-04 10:30:51 +03:00
|
|
|
pcprobe(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
void *match, *aux;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-03-29 08:35:37 +04:00
|
|
|
struct isa_attach_args *ia = aux;
|
1994-10-16 18:46:13 +03:00
|
|
|
u_int i;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-03-21 21:04:42 +03:00
|
|
|
/* Enable interrupts and keyboard, etc. */
|
1994-03-02 11:03:02 +03:00
|
|
|
if (!kbc_put8042cmd(CMDBYTE)) {
|
1994-02-23 02:01:22 +03:00
|
|
|
printf("pcprobe: command error\n");
|
|
|
|
return 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-03-03 22:28:04 +03:00
|
|
|
#if 1
|
1994-03-03 22:11:59 +03:00
|
|
|
/* Flush any garbage. */
|
1994-10-16 18:46:13 +03:00
|
|
|
kbd_flush_input();
|
1994-02-23 02:01:22 +03:00
|
|
|
/* Reset the keyboard. */
|
1994-02-24 01:20:40 +03:00
|
|
|
if (!kbd_cmd(KBC_RESET, 1)) {
|
1994-03-02 11:03:02 +03:00
|
|
|
printf("pcprobe: reset error %d\n", 1);
|
1994-02-24 01:20:40 +03:00
|
|
|
goto lose;
|
|
|
|
}
|
1994-10-16 18:46:13 +03:00
|
|
|
for (i = 600000; i; i--)
|
|
|
|
if ((inb(KBSTATP) & KBS_DIB) != 0) {
|
|
|
|
KBD_DELAY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i == 0 || inb(KBDATAP) != KBR_RSTDONE) {
|
1994-03-02 11:03:02 +03:00
|
|
|
printf("pcprobe: reset error %d\n", 2);
|
1994-02-24 01:20:40 +03:00
|
|
|
goto lose;
|
|
|
|
}
|
1994-03-03 22:28:04 +03:00
|
|
|
/*
|
|
|
|
* Some keyboards seem to leave a second ack byte after the reset.
|
|
|
|
* This is kind of stupid, but we account for them anyway by just
|
|
|
|
* flushing the buffer.
|
|
|
|
*/
|
1994-10-16 18:46:13 +03:00
|
|
|
kbd_flush_input();
|
1994-03-03 22:28:04 +03:00
|
|
|
/* Just to be sure. */
|
1994-03-02 09:46:11 +03:00
|
|
|
if (!kbd_cmd(KBC_ENABLE, 1)) {
|
1994-03-02 11:03:02 +03:00
|
|
|
printf("pcprobe: reset error %d\n", 3);
|
1994-03-02 03:57:35 +03:00
|
|
|
goto lose;
|
|
|
|
}
|
1994-03-02 11:03:02 +03:00
|
|
|
|
1994-03-03 22:28:04 +03:00
|
|
|
/*
|
|
|
|
* Some keyboard/8042 combinations do not seem to work if the keyboard
|
|
|
|
* is set to table 1; in fact, it would appear that some keyboards just
|
|
|
|
* ignore the command altogether. So by default, we use the AT scan
|
|
|
|
* codes and have the 8042 translate them. Unfortunately, this is
|
|
|
|
* known to not work on some PS/2 machines. We try desparately to deal
|
|
|
|
* with this by checking the (lack of a) translate bit in the 8042 and
|
|
|
|
* attempting to set the keyboard to XT mode. If this all fails, well,
|
|
|
|
* tough luck.
|
|
|
|
*
|
|
|
|
* XXX It would perhaps be a better choice to just use AT scan codes
|
|
|
|
* and not bother with this.
|
|
|
|
*/
|
1994-03-02 11:03:02 +03:00
|
|
|
if (kbc_get8042cmd() & KC8_TRANS) {
|
|
|
|
/* The 8042 is translating for us; use AT codes. */
|
|
|
|
if (!kbd_cmd(KBC_SETTABLE, 1) || !kbd_cmd(2, 1)) {
|
|
|
|
printf("pcprobe: reset error %d\n", 4);
|
|
|
|
goto lose;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Stupid 8042; set keyboard to XT codes. */
|
|
|
|
if (!kbd_cmd(KBC_SETTABLE, 1) || !kbd_cmd(1, 1)) {
|
|
|
|
printf("pcprobe: reset error %d\n", 5);
|
|
|
|
goto lose;
|
|
|
|
}
|
1994-03-02 07:38:26 +03:00
|
|
|
}
|
1994-02-24 01:20:40 +03:00
|
|
|
|
|
|
|
lose:
|
|
|
|
/*
|
|
|
|
* Technically, we should probably fail the probe. But we'll be nice
|
|
|
|
* and allow keyboard-less machines to boot with the console.
|
|
|
|
*/
|
1994-03-02 11:03:02 +03:00
|
|
|
#endif
|
1993-03-21 21:04:42 +03:00
|
|
|
|
1994-03-29 08:35:37 +04:00
|
|
|
ia->ia_iosize = 16;
|
|
|
|
ia->ia_msize = 0;
|
|
|
|
return 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-03-29 08:35:37 +04:00
|
|
|
void
|
|
|
|
pcattach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1995-04-19 22:10:47 +04:00
|
|
|
struct pc_softc *sc = (void *)self;
|
1994-04-07 10:48:19 +04:00
|
|
|
struct isa_attach_args *ia = aux;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-03-29 08:35:37 +04:00
|
|
|
printf(": %s\n", vs.color ? "color" : "mono");
|
1996-05-03 23:14:50 +04:00
|
|
|
do_async_update((void *)1);
|
1994-04-07 10:48:19 +04:00
|
|
|
|
1996-04-12 02:15:08 +04:00
|
|
|
sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
|
|
|
|
IPL_TTY, pcintr, sc);
|
1996-03-16 09:08:46 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for children of the keyboard controller.
|
|
|
|
* XXX Really should decouple keyboard controller
|
|
|
|
* from the console code.
|
|
|
|
*/
|
1996-04-12 02:15:08 +04:00
|
|
|
while (config_found(self, ia->ia_ic, NULL) != NULL) /* XXX */
|
1996-03-16 09:08:46 +03:00
|
|
|
/* will break when no more children */ ;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
int
|
1993-03-21 12:45:37 +03:00
|
|
|
pcopen(dev, flag, mode, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, mode;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1995-04-19 22:10:47 +04:00
|
|
|
struct pc_softc *sc;
|
1994-02-23 02:01:22 +03:00
|
|
|
int unit = PCUNIT(dev);
|
|
|
|
struct tty *tp;
|
|
|
|
|
1996-03-17 04:26:49 +03:00
|
|
|
if (unit >= pc_cd.cd_ndevs)
|
1995-04-19 22:10:47 +04:00
|
|
|
return ENXIO;
|
1996-03-17 04:26:49 +03:00
|
|
|
sc = pc_cd.cd_devs[unit];
|
1995-04-19 22:10:47 +04:00
|
|
|
if (sc == 0)
|
1994-02-23 02:01:22 +03:00
|
|
|
return ENXIO;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1995-04-19 22:10:47 +04:00
|
|
|
if (!sc->sc_tty)
|
|
|
|
tp = sc->sc_tty = ttymalloc();
|
1994-02-23 02:01:22 +03:00
|
|
|
else
|
1995-04-19 22:10:47 +04:00
|
|
|
tp = sc->sc_tty;
|
1994-02-23 02:01:22 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
tp->t_oproc = pcstart;
|
|
|
|
tp->t_param = pcparam;
|
|
|
|
tp->t_dev = dev;
|
|
|
|
if ((tp->t_state & TS_ISOPEN) == 0) {
|
|
|
|
tp->t_state |= TS_WOPEN;
|
|
|
|
ttychars(tp);
|
|
|
|
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;
|
|
|
|
pcparam(tp, &tp->t_termios);
|
|
|
|
ttsetwater(tp);
|
|
|
|
} else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0)
|
1994-02-23 02:01:22 +03:00
|
|
|
return EBUSY;
|
1993-03-21 12:45:37 +03:00
|
|
|
tp->t_state |= TS_CARR_ON;
|
1994-02-23 02:01:22 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
return ((*linesw[tp->t_line].l_open)(dev, tp));
|
|
|
|
}
|
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
int
|
1993-03-21 12:45:37 +03:00
|
|
|
pcclose(dev, flag, mode, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, mode;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1996-03-17 04:26:49 +03:00
|
|
|
struct pc_softc *sc = pc_cd.cd_devs[PCUNIT(dev)];
|
1995-04-20 02:08:08 +04:00
|
|
|
struct tty *tp = sc->sc_tty;
|
1993-07-07 15:00:23 +04:00
|
|
|
|
|
|
|
(*linesw[tp->t_line].l_close)(tp, flag);
|
|
|
|
ttyclose(tp);
|
1994-02-23 02:01:22 +03:00
|
|
|
#ifdef notyet /* XXX */
|
|
|
|
ttyfree(tp);
|
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
1993-09-28 06:25:01 +03:00
|
|
|
int
|
1993-03-21 12:45:37 +03:00
|
|
|
pcread(dev, uio, flag)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
1994-02-23 02:01:22 +03:00
|
|
|
int flag;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1996-03-17 04:26:49 +03:00
|
|
|
struct pc_softc *sc = pc_cd.cd_devs[PCUNIT(dev)];
|
1995-04-20 02:08:08 +04:00
|
|
|
struct tty *tp = sc->sc_tty;
|
1993-07-07 15:00:23 +04:00
|
|
|
|
|
|
|
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1993-09-28 06:25:01 +03:00
|
|
|
int
|
1993-03-21 12:45:37 +03:00
|
|
|
pcwrite(dev, uio, flag)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
1994-02-23 02:01:22 +03:00
|
|
|
int flag;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1996-03-17 04:26:49 +03:00
|
|
|
struct pc_softc *sc = pc_cd.cd_devs[PCUNIT(dev)];
|
1995-04-20 02:08:08 +04:00
|
|
|
struct tty *tp = sc->sc_tty;
|
1993-07-07 15:00:23 +04:00
|
|
|
|
|
|
|
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1995-04-19 22:10:47 +04:00
|
|
|
struct tty *
|
|
|
|
pctty(dev)
|
|
|
|
dev_t dev;
|
|
|
|
{
|
1996-03-17 04:26:49 +03:00
|
|
|
struct pc_softc *sc = pc_cd.cd_devs[PCUNIT(dev)];
|
1995-04-20 02:08:08 +04:00
|
|
|
struct tty *tp = sc->sc_tty;
|
1995-04-19 22:10:47 +04:00
|
|
|
|
1995-04-20 02:08:08 +04:00
|
|
|
return (tp);
|
1995-04-19 22:10:47 +04:00
|
|
|
}
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Got a console receive interrupt -
|
|
|
|
* the console processor wants to give us a character.
|
|
|
|
* Catch the character, and see who it goes to.
|
|
|
|
*/
|
1994-02-23 02:01:22 +03:00
|
|
|
int
|
1995-04-17 16:06:30 +04:00
|
|
|
pcintr(arg)
|
|
|
|
void *arg;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1995-04-19 22:10:47 +04:00
|
|
|
struct pc_softc *sc = arg;
|
|
|
|
register struct tty *tp = sc->sc_tty;
|
1994-02-23 02:01:22 +03:00
|
|
|
u_char *cp;
|
1993-03-21 21:04:42 +03:00
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
if ((inb(KBSTATP) & KBS_DIB) == 0)
|
|
|
|
return 0;
|
|
|
|
if (polling)
|
|
|
|
return 1;
|
1993-09-06 09:52:33 +04:00
|
|
|
do {
|
1994-02-23 02:01:22 +03:00
|
|
|
cp = sget();
|
|
|
|
if (!tp || (tp->t_state & TS_ISOPEN) == 0)
|
|
|
|
return 1;
|
|
|
|
if (cp)
|
|
|
|
do
|
|
|
|
(*linesw[tp->t_line].l_rint)(*cp++, tp);
|
|
|
|
while (*cp);
|
|
|
|
} while (inb(KBSTATP) & KBS_DIB);
|
|
|
|
return 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1993-09-28 06:25:01 +03:00
|
|
|
int
|
1994-02-10 00:06:46 +03:00
|
|
|
pcioctl(dev, cmd, data, flag, p)
|
1993-03-21 12:45:37 +03:00
|
|
|
dev_t dev;
|
1994-10-31 00:43:03 +03:00
|
|
|
u_long cmd;
|
1993-03-21 12:45:37 +03:00
|
|
|
caddr_t data;
|
1994-02-10 00:06:46 +03:00
|
|
|
int flag;
|
|
|
|
struct proc *p;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1996-03-17 04:26:49 +03:00
|
|
|
struct pc_softc *sc = pc_cd.cd_devs[PCUNIT(dev)];
|
1995-04-21 23:44:52 +04:00
|
|
|
struct tty *tp = sc->sc_tty;
|
1994-02-23 02:01:22 +03:00
|
|
|
int error;
|
1993-03-21 21:04:42 +03:00
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
|
|
|
|
if (error >= 0)
|
|
|
|
return error;
|
|
|
|
error = ttioctl(tp, cmd, data, flag, p);
|
|
|
|
if (error >= 0)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case CONSOLE_X_MODE_ON:
|
|
|
|
pc_xmode_on();
|
|
|
|
return 0;
|
|
|
|
case CONSOLE_X_MODE_OFF:
|
|
|
|
pc_xmode_off();
|
|
|
|
return 0;
|
|
|
|
case CONSOLE_X_BELL:
|
|
|
|
/*
|
|
|
|
* If set, data is a pointer to a length 2 array of
|
|
|
|
* integers. data[0] is the pitch in Hz and data[1]
|
|
|
|
* is the duration in msec.
|
|
|
|
*/
|
|
|
|
if (data)
|
1993-06-16 06:57:17 +04:00
|
|
|
sysbeep(((int*)data)[0],
|
1994-02-23 02:01:22 +03:00
|
|
|
(((int*)data)[1] * hz) / 1000);
|
|
|
|
else
|
1993-06-16 06:57:17 +04:00
|
|
|
sysbeep(BEEP_FREQ, BEEP_TIME);
|
1994-02-23 02:01:22 +03:00
|
|
|
return 0;
|
|
|
|
case CONSOLE_SET_TYPEMATIC_RATE: {
|
1993-09-28 06:25:01 +03:00
|
|
|
u_char rate;
|
|
|
|
|
|
|
|
if (!data)
|
1994-02-23 02:01:22 +03:00
|
|
|
return EINVAL;
|
1993-09-28 06:25:01 +03:00
|
|
|
rate = *((u_char *)data);
|
|
|
|
/*
|
1994-02-23 02:01:22 +03:00
|
|
|
* Check that it isn't too big (which would cause it to be
|
|
|
|
* confused with a command).
|
1993-09-28 06:25:01 +03:00
|
|
|
*/
|
1994-02-23 02:01:22 +03:00
|
|
|
if (rate & 0x80)
|
|
|
|
return EINVAL;
|
1994-02-25 06:48:51 +03:00
|
|
|
typematic_rate = rate;
|
1994-02-23 02:01:22 +03:00
|
|
|
async_update();
|
|
|
|
return 0;
|
1993-09-28 06:25:01 +03:00
|
|
|
}
|
1994-02-23 02:01:22 +03:00
|
|
|
default:
|
|
|
|
return ENOTTY;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
panic("pcioctl: impossible");
|
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1993-08-29 17:46:31 +04:00
|
|
|
void
|
1993-03-21 12:45:37 +03:00
|
|
|
pcstart(tp)
|
1994-02-23 02:01:22 +03:00
|
|
|
struct tty *tp;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-02-23 02:01:22 +03:00
|
|
|
struct clist *cl;
|
1996-05-03 23:14:50 +04:00
|
|
|
int s, len;
|
1993-07-12 15:36:53 +04:00
|
|
|
u_char buf[PCBURST];
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
s = spltty();
|
1994-02-23 02:01:22 +03:00
|
|
|
if (tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP))
|
1993-03-21 12:45:37 +03:00
|
|
|
goto out;
|
1993-04-22 11:56:23 +04:00
|
|
|
tp->t_state |= TS_BUSY;
|
|
|
|
splx(s);
|
|
|
|
/*
|
|
|
|
* We need to do this outside spl since it could be fairly
|
|
|
|
* expensive and we don't want our serial ports to overflow.
|
|
|
|
*/
|
1994-02-23 02:01:22 +03:00
|
|
|
cl = &tp->t_outq;
|
|
|
|
len = q_to_b(cl, buf, PCBURST);
|
|
|
|
sput(buf, len);
|
1993-04-22 11:56:23 +04:00
|
|
|
s = spltty();
|
|
|
|
tp->t_state &= ~TS_BUSY;
|
1994-02-23 02:01:22 +03:00
|
|
|
if (cl->c_cc) {
|
1993-07-11 11:54:47 +04:00
|
|
|
tp->t_state |= TS_TIMEOUT;
|
1994-05-05 12:28:35 +04:00
|
|
|
timeout(ttrstrt, tp, 1);
|
1993-07-11 11:54:47 +04:00
|
|
|
}
|
1994-02-23 02:01:22 +03:00
|
|
|
if (cl->c_cc <= tp->t_lowat) {
|
|
|
|
if (tp->t_state & TS_ASLEEP) {
|
1993-03-21 12:45:37 +03:00
|
|
|
tp->t_state &= ~TS_ASLEEP;
|
1994-12-13 16:42:53 +03:00
|
|
|
wakeup(cl);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1993-05-18 22:18:40 +04:00
|
|
|
selwakeup(&tp->t_wsel);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
out:
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
1996-05-03 23:14:50 +04:00
|
|
|
int
|
1994-12-13 16:42:53 +03:00
|
|
|
pcstop(tp, flag)
|
|
|
|
struct tty *tp;
|
|
|
|
int flag;
|
|
|
|
{
|
1996-05-03 23:14:50 +04:00
|
|
|
return 0;
|
1994-12-13 16:42:53 +03:00
|
|
|
}
|
|
|
|
|
1995-04-10 05:01:40 +04:00
|
|
|
void
|
1993-03-21 12:45:37 +03:00
|
|
|
pccnprobe(cp)
|
|
|
|
struct consdev *cp;
|
|
|
|
{
|
|
|
|
int maj;
|
|
|
|
|
|
|
|
/* locate the major number */
|
|
|
|
for (maj = 0; maj < nchrdev; maj++)
|
|
|
|
if (cdevsw[maj].d_open == pcopen)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* initialize required fields */
|
|
|
|
cp->cn_dev = makedev(maj, 0);
|
|
|
|
cp->cn_pri = CN_INTERNAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ARGSUSED */
|
1995-04-10 05:01:40 +04:00
|
|
|
void
|
1993-03-21 12:45:37 +03:00
|
|
|
pccninit(cp)
|
|
|
|
struct consdev *cp;
|
|
|
|
{
|
1994-02-23 02:01:22 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* For now, don't screw with it.
|
|
|
|
*/
|
|
|
|
/* crtat = 0; */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ARGSUSED */
|
1995-04-10 05:01:40 +04:00
|
|
|
void
|
1993-03-21 12:45:37 +03:00
|
|
|
pccnputc(dev, c)
|
|
|
|
dev_t dev;
|
|
|
|
char c;
|
|
|
|
{
|
1994-02-23 02:01:22 +03:00
|
|
|
u_char oldkernel = kernel;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
kernel = 1;
|
|
|
|
if (c == '\n')
|
|
|
|
sput("\r\n", 2);
|
|
|
|
else
|
|
|
|
sput(&c, 1);
|
|
|
|
kernel = oldkernel;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ARGSUSED */
|
1996-03-30 10:51:51 +03:00
|
|
|
int
|
1993-03-21 12:45:37 +03:00
|
|
|
pccngetc(dev)
|
|
|
|
dev_t dev;
|
|
|
|
{
|
|
|
|
register char *cp;
|
|
|
|
|
1993-09-28 06:25:01 +03:00
|
|
|
if (pc_xmode > 0)
|
1994-02-23 02:01:22 +03:00
|
|
|
return 0;
|
1993-03-21 21:04:42 +03:00
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
do {
|
|
|
|
/* wait for byte */
|
|
|
|
while ((inb(KBSTATP) & KBS_DIB) == 0);
|
|
|
|
/* see if it's worthwhile */
|
|
|
|
cp = sget();
|
|
|
|
} while (!cp);
|
|
|
|
if (*cp == '\r')
|
|
|
|
return '\n';
|
|
|
|
return *cp;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-10-26 21:06:30 +03:00
|
|
|
void
|
|
|
|
pccnpollc(dev, on)
|
|
|
|
dev_t dev;
|
|
|
|
int on;
|
|
|
|
{
|
|
|
|
|
|
|
|
polling = on;
|
|
|
|
if (!on) {
|
1995-05-04 00:46:32 +04:00
|
|
|
int unit;
|
|
|
|
struct pc_softc *sc;
|
|
|
|
int s;
|
1994-10-26 21:13:24 +03:00
|
|
|
|
1994-10-26 21:06:30 +03:00
|
|
|
/*
|
1995-05-04 00:46:32 +04:00
|
|
|
* If disabling polling on a device that's been configured,
|
|
|
|
* make sure there are no bytes left in the FIFO, holding up
|
|
|
|
* the interrupt line. Otherwise we won't get any further
|
|
|
|
* interrupts.
|
1994-10-26 21:06:30 +03:00
|
|
|
*/
|
1995-05-04 00:46:32 +04:00
|
|
|
unit = PCUNIT(dev);
|
1996-03-17 04:26:49 +03:00
|
|
|
if (pc_cd.cd_ndevs > unit) {
|
|
|
|
sc = pc_cd.cd_devs[unit];
|
1995-05-04 00:46:32 +04:00
|
|
|
if (sc != 0) {
|
|
|
|
s = spltty();
|
|
|
|
pcintr(sc);
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
}
|
1994-10-26 21:06:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1994-02-23 02:01:22 +03:00
|
|
|
* Set line parameters.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-02-23 02:01:22 +03:00
|
|
|
int
|
1993-03-21 12:45:37 +03:00
|
|
|
pcparam(tp, t)
|
1994-02-23 02:01:22 +03:00
|
|
|
struct tty *tp;
|
|
|
|
struct termios *t;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
tp->t_ispeed = t->c_ispeed;
|
|
|
|
tp->t_ospeed = t->c_ospeed;
|
|
|
|
tp->t_cflag = t->c_cflag;
|
|
|
|
return 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
#define wrtchar(c, at) do {\
|
|
|
|
char *cp = (char *)crtat; *cp++ = (c); *cp = (at); crtat++; vs.col++; \
|
|
|
|
} while (0)
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/* translate ANSI color codes to standard pc ones */
|
1994-02-23 02:01:22 +03:00
|
|
|
static char fgansitopc[] = {
|
|
|
|
FG_BLACK, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE,
|
|
|
|
FG_MAGENTA, FG_CYAN, FG_LIGHTGREY
|
|
|
|
};
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
static char bgansitopc[] = {
|
|
|
|
BG_BLACK, BG_RED, BG_GREEN, BG_BROWN, BG_BLUE,
|
|
|
|
BG_MAGENTA, BG_CYAN, BG_LIGHTGREY
|
|
|
|
};
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/*
|
1994-02-23 02:01:22 +03:00
|
|
|
* `pc3' termcap emulation.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-02-23 02:01:22 +03:00
|
|
|
void
|
|
|
|
sput(cp, n)
|
|
|
|
u_char *cp;
|
|
|
|
int n;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-02-23 02:01:22 +03:00
|
|
|
u_char c, scroll = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-09-28 06:25:01 +03:00
|
|
|
if (pc_xmode > 0)
|
1993-03-21 21:04:42 +03:00
|
|
|
return;
|
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
if (crtat == 0) {
|
1995-04-21 08:51:30 +04:00
|
|
|
u_short volatile *cp;
|
1993-03-21 21:04:42 +03:00
|
|
|
u_short was;
|
1993-03-21 12:45:37 +03:00
|
|
|
unsigned cursorat;
|
|
|
|
|
1995-04-21 08:51:30 +04:00
|
|
|
cp = ISA_HOLE_VADDR(CGA_BUF);
|
1993-03-21 12:45:37 +03:00
|
|
|
was = *cp;
|
|
|
|
*cp = (u_short) 0xA55A;
|
|
|
|
if (*cp != 0xA55A) {
|
1995-04-21 08:51:30 +04:00
|
|
|
cp = ISA_HOLE_VADDR(MONO_BUF);
|
1993-03-21 12:45:37 +03:00
|
|
|
addr_6845 = MONO_BASE;
|
1995-04-21 08:51:30 +04:00
|
|
|
vs.color = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
} else {
|
|
|
|
*cp = was;
|
|
|
|
addr_6845 = CGA_BASE;
|
1995-04-21 08:51:30 +04:00
|
|
|
vs.color = 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1994-02-25 06:48:51 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/* Extract cursor location */
|
1994-02-25 06:48:51 +03:00
|
|
|
outb(addr_6845, 14);
|
|
|
|
cursorat = inb(addr_6845+1) << 8;
|
|
|
|
outb(addr_6845, 15);
|
1993-03-21 12:45:37 +03:00
|
|
|
cursorat |= inb(addr_6845+1);
|
|
|
|
|
1994-02-25 06:48:51 +03:00
|
|
|
#ifdef FAT_CURSOR
|
|
|
|
cursor_shape = 0x0012;
|
|
|
|
#endif
|
|
|
|
|
1995-05-04 23:35:20 +04:00
|
|
|
Crtat = (u_short *)cp;
|
|
|
|
crtat = (u_short *)(cp + cursorat);
|
1995-04-21 08:51:30 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
vs.ncol = COL;
|
|
|
|
vs.nrow = ROW;
|
1994-02-23 02:01:22 +03:00
|
|
|
vs.nchr = COL * ROW;
|
|
|
|
vs.at = FG_LIGHTGREY | BG_BLACK;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
if (vs.color == 0)
|
1993-03-21 12:45:37 +03:00
|
|
|
vs.so_at = FG_BLACK | BG_LIGHTGREY;
|
1994-02-23 02:01:22 +03:00
|
|
|
else
|
1993-03-21 12:45:37 +03:00
|
|
|
vs.so_at = FG_YELLOW | BG_BLACK;
|
|
|
|
|
1996-05-05 23:48:15 +04:00
|
|
|
fillw((vs.at << 8) | ' ', crtat, vs.nchr - cursorat);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
while (n--) {
|
|
|
|
if (!(c = *cp++))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch (c) {
|
|
|
|
case 0x1B:
|
|
|
|
if (vs.state >= VSS_ESCAPE) {
|
|
|
|
wrtchar(c, vs.so_at);
|
|
|
|
vs.state = 0;
|
|
|
|
goto maybe_scroll;
|
|
|
|
} else
|
|
|
|
vs.state = VSS_ESCAPE;
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
case '\t': {
|
|
|
|
int inccol = 8 - (vs.col & 7);
|
|
|
|
crtat += inccol;
|
|
|
|
vs.col += inccol;
|
|
|
|
}
|
|
|
|
maybe_scroll:
|
|
|
|
if (vs.col >= COL) {
|
|
|
|
vs.col -= COL;
|
|
|
|
scroll = 1;
|
|
|
|
}
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
case '\010':
|
|
|
|
if (crtat <= Crtat)
|
|
|
|
break;
|
|
|
|
--crtat;
|
|
|
|
if (--vs.col < 0)
|
|
|
|
vs.col += COL; /* non-destructive backspace */
|
1993-11-11 18:43:52 +03:00
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
case '\r':
|
|
|
|
crtat -= vs.col;
|
|
|
|
vs.col = 0;
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
case '\n':
|
|
|
|
crtat += vs.ncol;
|
|
|
|
scroll = 1;
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
default:
|
|
|
|
switch (vs.state) {
|
|
|
|
case 0:
|
|
|
|
if (c == '\a')
|
|
|
|
sysbeep(BEEP_FREQ, BEEP_TIME);
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* If we're outputting multiple printed
|
|
|
|
* characters, just blast them to the
|
|
|
|
* screen until we reach the end of the
|
|
|
|
* buffer or a control character. This
|
|
|
|
* saves time by short-circuiting the
|
|
|
|
* switch.
|
|
|
|
* If we reach the end of the line, we
|
|
|
|
* break to do a scroll check.
|
|
|
|
*/
|
|
|
|
for (;;) {
|
|
|
|
if (vs.so)
|
|
|
|
wrtchar(c, vs.so_at);
|
|
|
|
else
|
|
|
|
wrtchar(c, vs.at);
|
|
|
|
if (vs.col >= vs.ncol) {
|
|
|
|
vs.col = 0;
|
|
|
|
scroll = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!n || (c = *cp) < ' ')
|
|
|
|
break;
|
|
|
|
n--, cp++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VSS_ESCAPE:
|
|
|
|
if (c == '[') { /* Start ESC [ sequence */
|
|
|
|
vs.cx = vs.cy = 0;
|
|
|
|
vs.state = VSS_EBRACE;
|
|
|
|
} else if (c == 'c') { /* Clear screen & home */
|
1996-05-03 23:14:50 +04:00
|
|
|
fillw((vs.at << 8) | ' ',
|
1996-05-05 23:48:15 +04:00
|
|
|
Crtat, vs.nchr);
|
1994-02-23 02:01:22 +03:00
|
|
|
crtat = Crtat;
|
|
|
|
vs.col = 0;
|
|
|
|
vs.state = 0;
|
|
|
|
} else { /* Invalid, clear state */
|
|
|
|
wrtchar(c, vs.so_at);
|
|
|
|
vs.state = 0;
|
|
|
|
goto maybe_scroll;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: /* VSS_EBRACE or VSS_EPARAM */
|
|
|
|
switch (c) {
|
1993-03-21 12:45:37 +03:00
|
|
|
int pos;
|
|
|
|
case 'm':
|
1994-02-23 02:01:22 +03:00
|
|
|
if (!vs.cx)
|
|
|
|
vs.so = 0;
|
|
|
|
else
|
|
|
|
vs.so = 1;
|
|
|
|
vs.state = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1994-02-23 02:01:22 +03:00
|
|
|
case 'A': { /* back cx rows */
|
|
|
|
int cx = vs.cx;
|
|
|
|
if (cx <= 0)
|
|
|
|
cx = 1;
|
|
|
|
else
|
|
|
|
cx %= vs.nrow;
|
1993-03-21 12:45:37 +03:00
|
|
|
pos = crtat - Crtat;
|
1994-02-23 02:01:22 +03:00
|
|
|
pos -= vs.ncol * cx;
|
1993-03-21 12:45:37 +03:00
|
|
|
if (pos < 0)
|
1994-02-23 02:01:22 +03:00
|
|
|
pos += vs.nchr;
|
1993-03-21 12:45:37 +03:00
|
|
|
crtat = Crtat + pos;
|
1994-02-23 02:01:22 +03:00
|
|
|
vs.state = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1994-02-23 02:01:22 +03:00
|
|
|
}
|
|
|
|
case 'B': { /* down cx rows */
|
|
|
|
int cx = vs.cx;
|
|
|
|
if (cx <= 0)
|
|
|
|
cx = 1;
|
|
|
|
else
|
|
|
|
cx %= vs.nrow;
|
1993-03-21 12:45:37 +03:00
|
|
|
pos = crtat - Crtat;
|
1994-02-23 02:01:22 +03:00
|
|
|
pos += vs.ncol * cx;
|
|
|
|
if (pos >= vs.nchr)
|
|
|
|
pos -= vs.nchr;
|
1993-03-21 12:45:37 +03:00
|
|
|
crtat = Crtat + pos;
|
1994-02-23 02:01:22 +03:00
|
|
|
vs.state = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1994-02-23 02:01:22 +03:00
|
|
|
}
|
|
|
|
case 'C': { /* right cursor */
|
|
|
|
int cx = vs.cx,
|
|
|
|
col = vs.col;
|
|
|
|
if (cx <= 0)
|
|
|
|
cx = 1;
|
|
|
|
else
|
|
|
|
cx %= vs.ncol;
|
1993-03-21 12:45:37 +03:00
|
|
|
pos = crtat - Crtat;
|
1994-02-23 02:01:22 +03:00
|
|
|
pos += cx;
|
|
|
|
col += cx;
|
|
|
|
if (col >= vs.ncol) {
|
|
|
|
pos -= vs.ncol;
|
|
|
|
col -= vs.ncol;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1994-02-23 02:01:22 +03:00
|
|
|
vs.col = col;
|
1993-03-21 12:45:37 +03:00
|
|
|
crtat = Crtat + pos;
|
1994-02-23 02:01:22 +03:00
|
|
|
vs.state = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1994-02-23 02:01:22 +03:00
|
|
|
}
|
|
|
|
case 'D': { /* left cursor */
|
|
|
|
int cx = vs.cx,
|
|
|
|
col = vs.col;
|
|
|
|
if (cx <= 0)
|
|
|
|
cx = 1;
|
|
|
|
else
|
|
|
|
cx %= vs.ncol;
|
1993-03-21 12:45:37 +03:00
|
|
|
pos = crtat - Crtat;
|
1994-02-23 02:01:22 +03:00
|
|
|
pos -= cx;
|
|
|
|
col -= cx;
|
|
|
|
if (col < 0) {
|
|
|
|
pos += vs.ncol;
|
|
|
|
col += vs.ncol;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1994-02-23 02:01:22 +03:00
|
|
|
vs.col = col;
|
1993-03-21 12:45:37 +03:00
|
|
|
crtat = Crtat + pos;
|
1994-02-23 02:01:22 +03:00
|
|
|
vs.state = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1994-02-23 02:01:22 +03:00
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
case 'J': /* Clear ... */
|
1994-02-23 02:01:22 +03:00
|
|
|
switch (vs.cx) {
|
|
|
|
case 0:
|
1993-03-21 12:45:37 +03:00
|
|
|
/* ... to end of display */
|
1996-05-03 23:14:50 +04:00
|
|
|
fillw((vs.at << 8) | ' ',
|
1996-05-05 23:48:15 +04:00
|
|
|
crtat,
|
1994-02-23 02:01:22 +03:00
|
|
|
Crtat + vs.nchr - crtat);
|
|
|
|
break;
|
|
|
|
case 1:
|
1993-03-21 12:45:37 +03:00
|
|
|
/* ... to next location */
|
1996-05-03 23:14:50 +04:00
|
|
|
fillw((vs.at << 8) | ' ',
|
1996-05-05 23:48:15 +04:00
|
|
|
Crtat, crtat - Crtat + 1);
|
1994-02-23 02:01:22 +03:00
|
|
|
break;
|
|
|
|
case 2:
|
1993-03-21 12:45:37 +03:00
|
|
|
/* ... whole display */
|
1996-05-03 23:14:50 +04:00
|
|
|
fillw((vs.at << 8) | ' ',
|
1996-05-05 23:48:15 +04:00
|
|
|
Crtat, vs.nchr);
|
1994-02-23 02:01:22 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
vs.state = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case 'K': /* Clear line ... */
|
1994-02-23 02:01:22 +03:00
|
|
|
switch (vs.cx) {
|
|
|
|
case 0:
|
1993-03-21 12:45:37 +03:00
|
|
|
/* ... current to EOL */
|
1996-05-03 23:14:50 +04:00
|
|
|
fillw((vs.at << 8) | ' ',
|
1996-05-05 23:48:15 +04:00
|
|
|
crtat, vs.ncol - vs.col);
|
1994-02-23 02:01:22 +03:00
|
|
|
break;
|
|
|
|
case 1:
|
1993-03-21 12:45:37 +03:00
|
|
|
/* ... beginning to next */
|
1994-02-23 02:01:22 +03:00
|
|
|
fillw((vs.at << 8) | ' ',
|
1996-05-05 23:48:15 +04:00
|
|
|
crtat - vs.col, vs.col + 1);
|
1994-02-23 02:01:22 +03:00
|
|
|
break;
|
|
|
|
case 2:
|
1993-03-21 12:45:37 +03:00
|
|
|
/* ... entire line */
|
1994-02-23 02:01:22 +03:00
|
|
|
fillw((vs.at << 8) | ' ',
|
1996-05-05 23:48:15 +04:00
|
|
|
crtat - vs.col, vs.ncol);
|
1994-02-23 02:01:22 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
vs.state = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case 'f': /* in system V consoles */
|
1994-02-23 02:01:22 +03:00
|
|
|
case 'H': { /* Cursor move */
|
|
|
|
int cx = vs.cx,
|
|
|
|
cy = vs.cy;
|
|
|
|
if (!cx || !cy) {
|
1993-03-21 12:45:37 +03:00
|
|
|
crtat = Crtat;
|
|
|
|
vs.col = 0;
|
|
|
|
} else {
|
1994-02-23 02:01:22 +03:00
|
|
|
if (cx > vs.nrow)
|
|
|
|
cx = vs.nrow;
|
|
|
|
if (cy > vs.ncol)
|
|
|
|
cy = vs.ncol;
|
|
|
|
crtat = Crtat +
|
|
|
|
(cx - 1) * vs.ncol + cy - 1;
|
|
|
|
vs.col = cy - 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1994-02-23 02:01:22 +03:00
|
|
|
vs.state = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1994-02-23 02:01:22 +03:00
|
|
|
}
|
1994-02-23 21:42:04 +03:00
|
|
|
case 'M': { /* delete cx rows */
|
|
|
|
u_short *crtAt = crtat - vs.col;
|
|
|
|
int cx = vs.cx,
|
|
|
|
row = (crtAt - Crtat) / vs.ncol,
|
|
|
|
nrow = vs.nrow - row;
|
|
|
|
if (cx <= 0)
|
|
|
|
cx = 1;
|
|
|
|
else if (cx > nrow)
|
|
|
|
cx = nrow;
|
|
|
|
if (cx < nrow)
|
|
|
|
bcopy(crtAt + vs.ncol * cx,
|
|
|
|
crtAt, vs.ncol * (nrow -
|
|
|
|
cx) * CHR);
|
|
|
|
fillw((vs.at << 8) | ' ',
|
1996-05-05 23:48:15 +04:00
|
|
|
crtAt + vs.ncol * (nrow - cx),
|
1994-02-23 21:42:04 +03:00
|
|
|
vs.ncol * cx);
|
|
|
|
vs.state = 0;
|
|
|
|
break;
|
|
|
|
}
|
1994-02-23 02:01:22 +03:00
|
|
|
case 'S': { /* scroll up cx lines */
|
|
|
|
int cx = vs.cx;
|
|
|
|
if (cx <= 0)
|
|
|
|
cx = 1;
|
1994-02-23 21:42:04 +03:00
|
|
|
else if (cx > vs.nrow)
|
1994-02-23 02:01:22 +03:00
|
|
|
cx = vs.nrow;
|
|
|
|
if (cx < vs.nrow)
|
|
|
|
bcopy(Crtat + vs.ncol * cx,
|
|
|
|
Crtat, vs.ncol * (vs.nrow -
|
|
|
|
cx) * CHR);
|
|
|
|
fillw((vs.at << 8) | ' ',
|
1996-05-05 23:48:15 +04:00
|
|
|
Crtat + vs.ncol * (vs.nrow - cx),
|
1994-02-23 02:01:22 +03:00
|
|
|
vs.ncol * cx);
|
1996-05-03 23:14:50 +04:00
|
|
|
#if 0
|
|
|
|
crtat -= vs.ncol * cx; /* XXX */
|
|
|
|
#endif
|
1994-02-23 02:01:22 +03:00
|
|
|
vs.state = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1994-02-23 02:01:22 +03:00
|
|
|
}
|
1994-02-23 21:42:04 +03:00
|
|
|
case 'L': { /* insert cx rows */
|
|
|
|
u_short *crtAt = crtat - vs.col;
|
|
|
|
int cx = vs.cx,
|
|
|
|
row = (crtAt - Crtat) / vs.ncol,
|
|
|
|
nrow = vs.nrow - row;
|
|
|
|
if (cx <= 0)
|
|
|
|
cx = 1;
|
|
|
|
else if (cx > nrow)
|
|
|
|
cx = nrow;
|
|
|
|
if (cx < nrow)
|
|
|
|
bcopy(crtAt,
|
|
|
|
crtAt + vs.ncol * cx,
|
|
|
|
vs.ncol * (nrow - cx) *
|
|
|
|
CHR);
|
1996-05-03 23:14:50 +04:00
|
|
|
fillw((vs.at << 8) | ' ',
|
1996-05-05 23:48:15 +04:00
|
|
|
crtAt, vs.ncol * cx);
|
1994-02-23 21:42:04 +03:00
|
|
|
vs.state = 0;
|
|
|
|
break;
|
|
|
|
}
|
1994-02-23 02:01:22 +03:00
|
|
|
case 'T': { /* scroll down cx lines */
|
|
|
|
int cx = vs.cx;
|
|
|
|
if (cx <= 0)
|
|
|
|
cx = 1;
|
1994-02-23 21:42:04 +03:00
|
|
|
else if (cx > vs.nrow)
|
1994-02-23 02:01:22 +03:00
|
|
|
cx = vs.nrow;
|
|
|
|
if (cx < vs.nrow)
|
|
|
|
bcopy(Crtat,
|
|
|
|
Crtat + vs.ncol * cx,
|
|
|
|
vs.ncol * (vs.nrow - cx) *
|
|
|
|
CHR);
|
1996-05-03 23:14:50 +04:00
|
|
|
fillw((vs.at << 8) | ' ',
|
1996-05-05 23:48:15 +04:00
|
|
|
Crtat, vs.ncol * cx);
|
1996-05-03 23:14:50 +04:00
|
|
|
#if 0
|
|
|
|
crtat += vs.ncol * cx; /* XXX */
|
|
|
|
#endif
|
1994-02-23 02:01:22 +03:00
|
|
|
vs.state = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1994-02-23 02:01:22 +03:00
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
case ';': /* Switch params in cursor def */
|
1994-02-23 02:01:22 +03:00
|
|
|
vs.state = VSS_EPARAM;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case 'r':
|
1994-02-23 02:01:22 +03:00
|
|
|
vs.so_at = (vs.cx & FG_MASK) |
|
|
|
|
((vs.cy << 4) & BG_MASK);
|
|
|
|
vs.state = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case 'x': /* set attributes */
|
|
|
|
switch (vs.cx) {
|
|
|
|
case 0:
|
1994-02-23 02:01:22 +03:00
|
|
|
vs.at = FG_LIGHTGREY | BG_BLACK;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
/* ansi background */
|
1994-02-23 02:01:22 +03:00
|
|
|
if (!vs.color)
|
|
|
|
break;
|
|
|
|
vs.at &= FG_MASK;
|
|
|
|
vs.at |= bgansitopc[vs.cy & 7];
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
/* ansi foreground */
|
1994-02-23 02:01:22 +03:00
|
|
|
if (!vs.color)
|
|
|
|
break;
|
|
|
|
vs.at &= BG_MASK;
|
|
|
|
vs.at |= fgansitopc[vs.cy & 7];
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
/* pc text attribute */
|
1994-02-23 02:01:22 +03:00
|
|
|
if (vs.state >= VSS_EPARAM)
|
|
|
|
vs.at = vs.cy;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
}
|
1994-02-23 02:01:22 +03:00
|
|
|
vs.state = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* Only numbers valid here */
|
1994-02-23 02:01:22 +03:00
|
|
|
if ((c >= '0') && (c <= '9')) {
|
|
|
|
if (vs.state >= VSS_EPARAM) {
|
1993-03-21 12:45:37 +03:00
|
|
|
vs.cy *= 10;
|
|
|
|
vs.cy += c - '0';
|
|
|
|
} else {
|
|
|
|
vs.cx *= 10;
|
|
|
|
vs.cx += c - '0';
|
|
|
|
}
|
1994-02-23 02:01:22 +03:00
|
|
|
} else
|
|
|
|
vs.state = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1994-02-23 02:01:22 +03:00
|
|
|
if (scroll) {
|
|
|
|
scroll = 0;
|
|
|
|
/* scroll check */
|
|
|
|
if (crtat >= Crtat + vs.nchr) {
|
|
|
|
if (!kernel) {
|
|
|
|
int s = spltty();
|
|
|
|
if (lock_state & SCROLL)
|
1996-05-05 23:48:15 +04:00
|
|
|
tsleep(&lock_state,
|
1994-02-23 02:01:22 +03:00
|
|
|
PUSER, "pcputc", 0);
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
bcopy(Crtat + vs.ncol, Crtat,
|
|
|
|
(vs.nchr - vs.ncol) * CHR);
|
|
|
|
fillw((vs.at << 8) | ' ',
|
1996-05-05 23:48:15 +04:00
|
|
|
Crtat + vs.nchr - vs.ncol,
|
1996-05-03 23:14:50 +04:00
|
|
|
vs.ncol);
|
1994-02-23 02:01:22 +03:00
|
|
|
crtat -= vs.ncol;
|
|
|
|
}
|
1993-07-08 11:27:29 +04:00
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1994-02-23 02:01:22 +03:00
|
|
|
async_update();
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#define CODE_SIZE 4 /* Use a max of 4 for now... */
|
1994-02-23 02:01:22 +03:00
|
|
|
typedef struct {
|
1993-03-21 12:45:37 +03:00
|
|
|
u_short type;
|
1994-02-23 02:01:22 +03:00
|
|
|
char unshift[CODE_SIZE];
|
|
|
|
char shift[CODE_SIZE];
|
|
|
|
char ctl[CODE_SIZE];
|
1993-03-21 12:45:37 +03:00
|
|
|
} Scan_def;
|
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
static Scan_def scan_codes[] = {
|
1996-05-03 23:14:50 +04:00
|
|
|
{ NONE, "", "", "" }, /* 0 unused */
|
|
|
|
{ ASCII,"\033", "\033", "\033" }, /* 1 ESCape */
|
|
|
|
{ ASCII,"1", "!", "!" }, /* 2 1 */
|
|
|
|
{ ASCII,"2", "@", "\000" }, /* 3 2 */
|
|
|
|
{ ASCII,"3", "#", "#" }, /* 4 3 */
|
|
|
|
{ ASCII,"4", "$", "$" }, /* 5 4 */
|
|
|
|
{ ASCII,"5", "%", "%" }, /* 6 5 */
|
|
|
|
{ ASCII,"6", "^", "\036" }, /* 7 6 */
|
|
|
|
{ ASCII,"7", "&", "&" }, /* 8 7 */
|
|
|
|
{ ASCII,"8", "*", "\010" }, /* 9 8 */
|
|
|
|
{ ASCII,"9", "(", "(" }, /* 10 9 */
|
|
|
|
{ ASCII,"0", ")", ")" }, /* 11 0 */
|
|
|
|
{ ASCII,"-", "_", "\037" }, /* 12 - */
|
|
|
|
{ ASCII,"=", "+", "+" }, /* 13 = */
|
|
|
|
{ ASCII,"\177", "\177", "\010" }, /* 14 backspace */
|
|
|
|
{ ASCII,"\t", "\177\t", "\t" }, /* 15 tab */
|
|
|
|
{ ASCII,"q", "Q", "\021" }, /* 16 q */
|
|
|
|
{ ASCII,"w", "W", "\027" }, /* 17 w */
|
|
|
|
{ ASCII,"e", "E", "\005" }, /* 18 e */
|
|
|
|
{ ASCII,"r", "R", "\022" }, /* 19 r */
|
|
|
|
{ ASCII,"t", "T", "\024" }, /* 20 t */
|
|
|
|
{ ASCII,"y", "Y", "\031" }, /* 21 y */
|
|
|
|
{ ASCII,"u", "U", "\025" }, /* 22 u */
|
|
|
|
{ ASCII,"i", "I", "\011" }, /* 23 i */
|
|
|
|
{ ASCII,"o", "O", "\017" }, /* 24 o */
|
|
|
|
{ ASCII,"p", "P", "\020" }, /* 25 p */
|
|
|
|
{ ASCII,"[", "{", "\033" }, /* 26 [ */
|
|
|
|
{ ASCII,"]", "}", "\035" }, /* 27 ] */
|
|
|
|
{ ASCII,"\r", "\r", "\n" }, /* 28 return */
|
|
|
|
{ CTL, "", "", "" }, /* 29 control */
|
|
|
|
{ ASCII,"a", "A", "\001" }, /* 30 a */
|
|
|
|
{ ASCII,"s", "S", "\023" }, /* 31 s */
|
|
|
|
{ ASCII,"d", "D", "\004" }, /* 32 d */
|
|
|
|
{ ASCII,"f", "F", "\006" }, /* 33 f */
|
|
|
|
{ ASCII,"g", "G", "\007" }, /* 34 g */
|
|
|
|
{ ASCII,"h", "H", "\010" }, /* 35 h */
|
|
|
|
{ ASCII,"j", "J", "\n" }, /* 36 j */
|
|
|
|
{ ASCII,"k", "K", "\013" }, /* 37 k */
|
|
|
|
{ ASCII,"l", "L", "\014" }, /* 38 l */
|
|
|
|
{ ASCII,";", ":", ";" }, /* 39 ; */
|
|
|
|
{ ASCII,"'", "\"", "'" }, /* 40 ' */
|
|
|
|
{ ASCII,"`", "~", "`" }, /* 41 ` */
|
|
|
|
{ SHIFT,"", "", "" }, /* 42 shift */
|
|
|
|
{ ASCII,"\\", "|", "\034" }, /* 43 \ */
|
|
|
|
{ ASCII,"z", "Z", "\032" }, /* 44 z */
|
|
|
|
{ ASCII,"x", "X", "\030" }, /* 45 x */
|
|
|
|
{ ASCII,"c", "C", "\003" }, /* 46 c */
|
|
|
|
{ ASCII,"v", "V", "\026" }, /* 47 v */
|
|
|
|
{ ASCII,"b", "B", "\002" }, /* 48 b */
|
|
|
|
{ ASCII,"n", "N", "\016" }, /* 49 n */
|
|
|
|
{ ASCII,"m", "M", "\r" }, /* 50 m */
|
|
|
|
{ ASCII,",", "<", "<" }, /* 51 , */
|
|
|
|
{ ASCII,".", ">", ">" }, /* 52 . */
|
|
|
|
{ ASCII,"/", "?", "\037" }, /* 53 / */
|
|
|
|
{ SHIFT,"", "", "" }, /* 54 shift */
|
|
|
|
{ KP, "*", "*", "*" }, /* 55 kp * */
|
|
|
|
{ ALT, "", "", "" }, /* 56 alt */
|
|
|
|
{ ASCII," ", " ", "\000" }, /* 57 space */
|
|
|
|
{ CAPS, "", "", "" }, /* 58 caps */
|
|
|
|
{ FUNC, "\033[M", "\033[Y", "\033[k" }, /* 59 f1 */
|
|
|
|
{ FUNC, "\033[N", "\033[Z", "\033[l" }, /* 60 f2 */
|
|
|
|
{ FUNC, "\033[O", "\033[a", "\033[m" }, /* 61 f3 */
|
|
|
|
{ FUNC, "\033[P", "\033[b", "\033[n" }, /* 62 f4 */
|
|
|
|
{ FUNC, "\033[Q", "\033[c", "\033[o" }, /* 63 f5 */
|
|
|
|
{ FUNC, "\033[R", "\033[d", "\033[p" }, /* 64 f6 */
|
|
|
|
{ FUNC, "\033[S", "\033[e", "\033[q" }, /* 65 f7 */
|
|
|
|
{ FUNC, "\033[T", "\033[f", "\033[r" }, /* 66 f8 */
|
|
|
|
{ FUNC, "\033[U", "\033[g", "\033[s" }, /* 67 f9 */
|
|
|
|
{ FUNC, "\033[V", "\033[h", "\033[t" }, /* 68 f10 */
|
|
|
|
{ NUM, "", "", "" }, /* 69 num lock */
|
|
|
|
{ SCROLL,"", "", "" }, /* 70 scroll lock */
|
|
|
|
{ KP, "7", "\033[H", "7" }, /* 71 kp 7 */
|
|
|
|
{ KP, "8", "\033[A", "8" }, /* 72 kp 8 */
|
|
|
|
{ KP, "9", "\033[I", "9" }, /* 73 kp 9 */
|
|
|
|
{ KP, "-", "-", "-" }, /* 74 kp - */
|
|
|
|
{ KP, "4", "\033[D", "4" }, /* 75 kp 4 */
|
|
|
|
{ KP, "5", "\033[E", "5" }, /* 76 kp 5 */
|
|
|
|
{ KP, "6", "\033[C", "6" }, /* 77 kp 6 */
|
|
|
|
{ KP, "+", "+", "+" }, /* 78 kp + */
|
|
|
|
{ KP, "1", "\033[F", "1" }, /* 79 kp 1 */
|
|
|
|
{ KP, "2", "\033[B", "2" }, /* 80 kp 2 */
|
|
|
|
{ KP, "3", "\033[G", "3" }, /* 81 kp 3 */
|
|
|
|
{ KP, "0", "\033[L", "0" }, /* 82 kp 0 */
|
|
|
|
{ KP, ".", "\177", "." }, /* 83 kp . */
|
|
|
|
{ NONE, "", "", "" }, /* 84 0 */
|
|
|
|
{ NONE, "100", "", "" }, /* 85 0 */
|
|
|
|
{ NONE, "101", "", "" }, /* 86 0 */
|
|
|
|
{ FUNC, "\033[W", "\033[i", "\033[u" }, /* 87 f11 */
|
|
|
|
{ FUNC, "\033[X", "\033[j", "\033[v" }, /* 88 f12 */
|
|
|
|
{ NONE, "102", "", "" }, /* 89 0 */
|
|
|
|
{ NONE, "103", "", "" }, /* 90 0 */
|
|
|
|
{ NONE, "", "", "" }, /* 91 0 */
|
|
|
|
{ NONE, "", "", "" }, /* 92 0 */
|
|
|
|
{ NONE, "", "", "" }, /* 93 0 */
|
|
|
|
{ NONE, "", "", "" }, /* 94 0 */
|
|
|
|
{ NONE, "", "", "" }, /* 95 0 */
|
|
|
|
{ NONE, "", "", "" }, /* 96 0 */
|
|
|
|
{ NONE, "", "", "" }, /* 97 0 */
|
|
|
|
{ NONE, "", "", "" }, /* 98 0 */
|
|
|
|
{ NONE, "", "", "" }, /* 99 0 */
|
|
|
|
{ NONE, "", "", "" }, /* 100 */
|
|
|
|
{ NONE, "", "", "" }, /* 101 */
|
|
|
|
{ NONE, "", "", "" }, /* 102 */
|
|
|
|
{ NONE, "", "", "" }, /* 103 */
|
|
|
|
{ NONE, "", "", "" }, /* 104 */
|
|
|
|
{ NONE, "", "", "" }, /* 105 */
|
|
|
|
{ NONE, "", "", "" }, /* 106 */
|
|
|
|
{ NONE, "", "", "" }, /* 107 */
|
|
|
|
{ NONE, "", "", "" }, /* 108 */
|
|
|
|
{ NONE, "", "", "" }, /* 109 */
|
|
|
|
{ NONE, "", "", "" }, /* 110 */
|
|
|
|
{ NONE, "", "", "" }, /* 111 */
|
|
|
|
{ NONE, "", "", "" }, /* 112 */
|
|
|
|
{ NONE, "", "", "" }, /* 113 */
|
|
|
|
{ NONE, "", "", "" }, /* 114 */
|
|
|
|
{ NONE, "", "", "" }, /* 115 */
|
|
|
|
{ NONE, "", "", "" }, /* 116 */
|
|
|
|
{ NONE, "", "", "" }, /* 117 */
|
|
|
|
{ NONE, "", "", "" }, /* 118 */
|
|
|
|
{ NONE, "", "", "" }, /* 119 */
|
|
|
|
{ NONE, "", "", "" }, /* 120 */
|
|
|
|
{ NONE, "", "", "" }, /* 121 */
|
|
|
|
{ NONE, "", "", "" }, /* 122 */
|
|
|
|
{ NONE, "", "", "" }, /* 123 */
|
|
|
|
{ NONE, "", "", "" }, /* 124 */
|
|
|
|
{ NONE, "", "", "" }, /* 125 */
|
|
|
|
{ NONE, "", "", "" }, /* 126 */
|
|
|
|
{ NONE, "", "", "" }, /* 127 */
|
1993-03-21 12:45:37 +03:00
|
|
|
};
|
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
/*
|
|
|
|
* Get characters from the keyboard. If none are present, return NULL.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
sget()
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1994-02-23 02:01:22 +03:00
|
|
|
u_char dt;
|
|
|
|
static u_char extended = 0, shift_state = 0;
|
|
|
|
static u_char capchar[2];
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
top:
|
1994-10-09 12:28:54 +03:00
|
|
|
KBD_DELAY;
|
1994-02-23 02:01:22 +03:00
|
|
|
dt = inb(KBDATAP);
|
1993-09-28 06:25:01 +03:00
|
|
|
|
1994-03-01 21:30:13 +03:00
|
|
|
switch (dt) {
|
|
|
|
case KBR_ACK:
|
|
|
|
ack = 1;
|
|
|
|
goto loop;
|
|
|
|
case KBR_RESEND:
|
|
|
|
nak = 1;
|
|
|
|
goto loop;
|
|
|
|
}
|
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
if (pc_xmode > 0) {
|
1993-09-28 06:25:01 +03:00
|
|
|
#if defined(DDB) && defined(XSERVER_DDB)
|
1994-02-23 02:01:22 +03:00
|
|
|
/* F12 enters the debugger while in X mode */
|
|
|
|
if (dt == 88)
|
|
|
|
Debugger();
|
1993-09-28 06:25:01 +03:00
|
|
|
#endif
|
1994-02-23 02:01:22 +03:00
|
|
|
capchar[0] = dt;
|
|
|
|
capchar[1] = 0;
|
|
|
|
/*
|
|
|
|
* Check for locking keys.
|
1994-02-25 06:48:51 +03:00
|
|
|
*
|
|
|
|
* XXX Setting the LEDs this way is a bit bogus. What if the
|
|
|
|
* keyboard has been remapped in X?
|
1994-02-23 02:01:22 +03:00
|
|
|
*/
|
|
|
|
switch (scan_codes[dt & 0x7f].type) {
|
|
|
|
case NUM:
|
|
|
|
if (dt & 0x80) {
|
|
|
|
shift_state &= ~NUM;
|
|
|
|
break;
|
|
|
|
}
|
1994-02-25 08:36:51 +03:00
|
|
|
if (shift_state & NUM)
|
|
|
|
break;
|
1994-02-23 02:01:22 +03:00
|
|
|
shift_state |= NUM;
|
|
|
|
lock_state ^= NUM;
|
1994-02-25 06:48:51 +03:00
|
|
|
async_update();
|
1994-02-23 02:01:22 +03:00
|
|
|
break;
|
|
|
|
case CAPS:
|
|
|
|
if (dt & 0x80) {
|
|
|
|
shift_state &= ~CAPS;
|
|
|
|
break;
|
|
|
|
}
|
1994-02-25 08:36:51 +03:00
|
|
|
if (shift_state & CAPS)
|
|
|
|
break;
|
1994-02-23 02:01:22 +03:00
|
|
|
shift_state |= CAPS;
|
|
|
|
lock_state ^= CAPS;
|
1994-02-25 06:48:51 +03:00
|
|
|
async_update();
|
1994-02-23 02:01:22 +03:00
|
|
|
break;
|
|
|
|
case SCROLL:
|
|
|
|
if (dt & 0x80) {
|
|
|
|
shift_state &= ~SCROLL;
|
|
|
|
break;
|
1993-03-21 21:04:42 +03:00
|
|
|
}
|
1994-02-25 08:36:51 +03:00
|
|
|
if (shift_state & SCROLL)
|
|
|
|
break;
|
1994-02-23 02:01:22 +03:00
|
|
|
shift_state |= SCROLL;
|
|
|
|
lock_state ^= SCROLL;
|
|
|
|
if ((lock_state & SCROLL) == 0)
|
1996-05-05 23:48:15 +04:00
|
|
|
wakeup(&lock_state);
|
1994-02-25 06:48:51 +03:00
|
|
|
async_update();
|
1994-02-23 02:01:22 +03:00
|
|
|
break;
|
1993-03-21 21:04:42 +03:00
|
|
|
}
|
1994-02-23 02:01:22 +03:00
|
|
|
return capchar;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
switch (dt) {
|
|
|
|
case KBR_EXTENDED:
|
1993-03-21 12:45:37 +03:00
|
|
|
extended = 1;
|
1993-03-21 21:04:42 +03:00
|
|
|
goto loop;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1993-04-10 16:04:35 +04:00
|
|
|
#ifdef DDB
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1994-02-23 02:01:22 +03:00
|
|
|
* Check for cntl-alt-esc.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-02-23 02:01:22 +03:00
|
|
|
if ((dt == 1) && (shift_state & (CTL | ALT)) == (CTL | ALT)) {
|
1993-03-21 12:45:37 +03:00
|
|
|
Debugger();
|
1994-02-23 02:01:22 +03:00
|
|
|
dt |= 0x80; /* discard esc (ddb discarded ctl-alt) */
|
1993-03-21 21:04:42 +03:00
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
1994-02-23 02:01:22 +03:00
|
|
|
* Check for make/break.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-02-23 02:01:22 +03:00
|
|
|
if (dt & 0x80) {
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1994-02-23 02:01:22 +03:00
|
|
|
* break
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-02-23 02:01:22 +03:00
|
|
|
dt &= 0x7f;
|
|
|
|
switch (scan_codes[dt].type) {
|
|
|
|
case NUM:
|
|
|
|
shift_state &= ~NUM;
|
|
|
|
break;
|
|
|
|
case CAPS:
|
|
|
|
shift_state &= ~CAPS;
|
|
|
|
break;
|
|
|
|
case SCROLL:
|
|
|
|
shift_state &= ~SCROLL;
|
|
|
|
break;
|
|
|
|
case SHIFT:
|
|
|
|
shift_state &= ~SHIFT;
|
|
|
|
break;
|
|
|
|
case ALT:
|
|
|
|
shift_state &= ~ALT;
|
|
|
|
break;
|
|
|
|
case CTL:
|
|
|
|
shift_state &= ~CTL;
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1994-02-23 02:01:22 +03:00
|
|
|
} else {
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1994-02-23 02:01:22 +03:00
|
|
|
* make
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-02-23 02:01:22 +03:00
|
|
|
switch (scan_codes[dt].type) {
|
|
|
|
/*
|
|
|
|
* locking keys
|
|
|
|
*/
|
|
|
|
case NUM:
|
|
|
|
if (shift_state & NUM)
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1994-02-23 02:01:22 +03:00
|
|
|
shift_state |= NUM;
|
|
|
|
lock_state ^= NUM;
|
|
|
|
async_update();
|
|
|
|
break;
|
|
|
|
case CAPS:
|
|
|
|
if (shift_state & CAPS)
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1994-02-23 02:01:22 +03:00
|
|
|
shift_state |= CAPS;
|
|
|
|
lock_state ^= CAPS;
|
|
|
|
async_update();
|
|
|
|
break;
|
|
|
|
case SCROLL:
|
|
|
|
if (shift_state & SCROLL)
|
1993-03-21 21:04:42 +03:00
|
|
|
break;
|
1994-02-23 02:01:22 +03:00
|
|
|
shift_state |= SCROLL;
|
|
|
|
lock_state ^= SCROLL;
|
|
|
|
if ((lock_state & SCROLL) == 0)
|
1996-05-05 23:48:15 +04:00
|
|
|
wakeup(&lock_state);
|
1994-02-23 02:01:22 +03:00
|
|
|
async_update();
|
|
|
|
break;
|
|
|
|
/*
|
|
|
|
* non-locking keys
|
|
|
|
*/
|
|
|
|
case SHIFT:
|
|
|
|
shift_state |= SHIFT;
|
|
|
|
break;
|
|
|
|
case ALT:
|
|
|
|
shift_state |= ALT;
|
|
|
|
break;
|
|
|
|
case CTL:
|
|
|
|
shift_state |= CTL;
|
|
|
|
break;
|
|
|
|
case ASCII:
|
|
|
|
/* control has highest priority */
|
|
|
|
if (shift_state & CTL)
|
|
|
|
capchar[0] = scan_codes[dt].ctl[0];
|
|
|
|
else if (shift_state & SHIFT)
|
|
|
|
capchar[0] = scan_codes[dt].shift[0];
|
|
|
|
else
|
|
|
|
capchar[0] = scan_codes[dt].unshift[0];
|
|
|
|
if ((lock_state & CAPS) && capchar[0] >= 'a' &&
|
|
|
|
capchar[0] <= 'z') {
|
|
|
|
capchar[0] -= ('a' - 'A');
|
|
|
|
}
|
|
|
|
capchar[0] |= (shift_state & ALT);
|
|
|
|
extended = 0;
|
|
|
|
return capchar;
|
|
|
|
case NONE:
|
|
|
|
break;
|
|
|
|
case FUNC: {
|
|
|
|
char *more_chars;
|
|
|
|
if (shift_state & SHIFT)
|
|
|
|
more_chars = scan_codes[dt].shift;
|
|
|
|
else if (shift_state & CTL)
|
|
|
|
more_chars = scan_codes[dt].ctl;
|
|
|
|
else
|
|
|
|
more_chars = scan_codes[dt].unshift;
|
|
|
|
extended = 0;
|
|
|
|
return more_chars;
|
|
|
|
}
|
|
|
|
case KP: {
|
|
|
|
char *more_chars;
|
|
|
|
if (shift_state & (SHIFT | CTL) ||
|
|
|
|
(lock_state & NUM) == 0 || extended)
|
|
|
|
more_chars = scan_codes[dt].shift;
|
|
|
|
else
|
|
|
|
more_chars = scan_codes[dt].unshift;
|
|
|
|
extended = 0;
|
|
|
|
return more_chars;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
1994-02-23 02:01:22 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
extended = 0;
|
1994-02-23 02:01:22 +03:00
|
|
|
loop:
|
|
|
|
if ((inb(KBSTATP) & KBS_DIB) == 0)
|
1993-03-21 12:45:37 +03:00
|
|
|
return 0;
|
1994-02-23 02:01:22 +03:00
|
|
|
goto top;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1994-02-23 02:01:22 +03:00
|
|
|
int
|
|
|
|
pcmmap(dev, offset, nprot)
|
|
|
|
dev_t dev;
|
|
|
|
int offset;
|
|
|
|
int nprot;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
if (offset > 0x20000)
|
|
|
|
return -1;
|
1994-02-23 02:01:22 +03:00
|
|
|
return i386_btop(0xa0000 + offset);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1993-03-21 21:04:42 +03:00
|
|
|
|
1996-03-30 10:51:51 +03:00
|
|
|
void
|
1994-02-23 02:01:22 +03:00
|
|
|
pc_xmode_on()
|
1993-03-21 21:04:42 +03:00
|
|
|
{
|
1993-09-16 07:24:13 +04:00
|
|
|
struct trapframe *fp;
|
1993-03-21 21:04:42 +03:00
|
|
|
|
|
|
|
if (pc_xmode)
|
|
|
|
return;
|
|
|
|
pc_xmode = 1;
|
|
|
|
|
1994-12-01 14:12:04 +03:00
|
|
|
#ifdef XFREE86_BUG_COMPAT
|
|
|
|
/* If still unchanged, get current shape. */
|
|
|
|
if (cursor_shape == 0xffff)
|
|
|
|
get_cursor_shape();
|
|
|
|
#endif
|
|
|
|
|
1995-10-11 07:19:29 +03:00
|
|
|
#ifdef COMPAT_10
|
|
|
|
/* This is done by i386_iopl(3) now. */
|
1995-05-01 12:25:30 +04:00
|
|
|
fp = curproc->p_md.md_regs;
|
1993-09-16 07:24:13 +04:00
|
|
|
fp->tf_eflags |= PSL_IOPL;
|
1995-10-11 07:19:29 +03:00
|
|
|
#endif
|
1993-03-21 21:04:42 +03:00
|
|
|
}
|
|
|
|
|
1996-03-30 10:51:51 +03:00
|
|
|
void
|
1994-02-23 02:01:22 +03:00
|
|
|
pc_xmode_off()
|
1993-03-21 21:04:42 +03:00
|
|
|
{
|
1993-09-16 07:24:13 +04:00
|
|
|
struct trapframe *fp;
|
1993-03-21 21:04:42 +03:00
|
|
|
|
|
|
|
if (pc_xmode == 0)
|
|
|
|
return;
|
|
|
|
pc_xmode = 0;
|
|
|
|
|
1994-03-03 23:48:16 +03:00
|
|
|
#ifdef XFREE86_BUG_COMPAT
|
|
|
|
/* XXX It would be hard to justify why the X server doesn't do this. */
|
|
|
|
set_cursor_shape();
|
|
|
|
#endif
|
1994-02-23 02:01:22 +03:00
|
|
|
async_update();
|
1993-03-21 21:04:42 +03:00
|
|
|
|
1995-05-01 12:25:30 +04:00
|
|
|
fp = curproc->p_md.md_regs;
|
1993-09-16 07:24:13 +04:00
|
|
|
fp->tf_eflags &= ~PSL_IOPL;
|
1993-03-21 21:04:42 +03:00
|
|
|
}
|