1997-02-11 02:26:21 +03:00
|
|
|
/* $NetBSD: kd.c,v 1.25 1997/02/10 23:26:21 gwr Exp $ */
|
1994-10-26 12:07:55 +03:00
|
|
|
|
1996-11-20 21:56:49 +03:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1996 The NetBSD Foundation, Inc.
|
1994-05-04 09:27:50 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
1996-11-20 21:56:49 +03:00
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Gordon W. Ross.
|
|
|
|
*
|
1994-05-04 09:27:50 +04:00
|
|
|
* 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.
|
1996-11-20 21:56:49 +03:00
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
1995-03-28 20:09:41 +04:00
|
|
|
* must display the following acknowledgement:
|
1996-11-20 21:56:49 +03:00
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
1994-05-04 09:27:50 +04:00
|
|
|
*
|
1996-11-20 21:56:49 +03:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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
|
1997-01-27 22:40:46 +03:00
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
1996-11-20 21:56:49 +03:00
|
|
|
* 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-05-04 09:27:50 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Keyboard/Display device.
|
|
|
|
*
|
|
|
|
* This driver exists simply to provide a tty device that
|
|
|
|
* the indirect console driver can point to.
|
|
|
|
* The kbd driver sends its input here.
|
1996-10-13 07:47:25 +04:00
|
|
|
* Output goes to the screen via PROM printf.
|
1994-05-04 09:27:50 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
|
|
|
#include <machine/autoconf.h>
|
|
|
|
#include <machine/mon.h>
|
1995-03-28 20:09:41 +04:00
|
|
|
#include <machine/psl.h>
|
1994-05-04 09:27:50 +04:00
|
|
|
|
|
|
|
#include <dev/cons.h>
|
1996-01-25 01:39:48 +03:00
|
|
|
#include <dev/sun/kbd_xlate.h>
|
1996-12-18 00:10:35 +03:00
|
|
|
#include <sun3/dev/zs_cons.h>
|
|
|
|
|
|
|
|
extern void fb_unblank __P((void)); /* XXX */
|
1994-05-04 09:27:50 +04:00
|
|
|
|
1996-01-25 01:39:48 +03:00
|
|
|
#define KDMAJOR 1
|
|
|
|
#define PUT_WSIZE 64
|
|
|
|
|
|
|
|
cdev_decl(kd); /* open, close, read, write, ioctl, stop, ... */
|
|
|
|
|
|
|
|
struct kd_softc {
|
|
|
|
struct device kd_dev; /* required first: base device */
|
|
|
|
struct tty *kd_tty;
|
|
|
|
};
|
1994-05-04 09:27:50 +04:00
|
|
|
|
1995-04-27 03:20:15 +04:00
|
|
|
/*
|
|
|
|
* There is no point in pretending there might be
|
|
|
|
* more than one keyboard/display device.
|
|
|
|
*/
|
1997-02-11 02:26:21 +03:00
|
|
|
static struct kd_softc kd_softc;
|
|
|
|
static int kd_is_console;
|
1994-05-04 09:27:50 +04:00
|
|
|
|
|
|
|
static int kdparam(struct tty *, struct termios *);
|
|
|
|
static void kdstart(struct tty *);
|
|
|
|
|
1995-03-24 22:48:41 +03:00
|
|
|
|
1996-01-25 01:39:48 +03:00
|
|
|
/*
|
|
|
|
* This is called by kbd_attach()
|
|
|
|
* XXX - Make this a proper child of kbd?
|
|
|
|
*/
|
1994-12-12 21:58:45 +03:00
|
|
|
void
|
1996-01-25 01:39:48 +03:00
|
|
|
kd_init(unit)
|
|
|
|
int unit;
|
1994-05-04 09:27:50 +04:00
|
|
|
{
|
1996-01-25 01:39:48 +03:00
|
|
|
struct kd_softc *kd;
|
|
|
|
struct tty *tp;
|
|
|
|
|
|
|
|
if (unit != 0)
|
|
|
|
return;
|
|
|
|
kd = &kd_softc; /* XXX */
|
1994-05-04 09:27:50 +04:00
|
|
|
|
1996-06-15 18:58:02 +04:00
|
|
|
tp = ttymalloc();
|
1996-01-25 01:39:48 +03:00
|
|
|
tp->t_oproc = kdstart;
|
|
|
|
tp->t_param = kdparam;
|
|
|
|
tp->t_dev = makedev(KDMAJOR, unit);
|
1996-06-15 18:58:02 +04:00
|
|
|
tty_attach(tp);
|
|
|
|
|
|
|
|
kd->kd_tty = tp;
|
1996-01-25 01:39:48 +03:00
|
|
|
|
|
|
|
return;
|
1994-05-04 09:27:50 +04:00
|
|
|
}
|
|
|
|
|
1995-04-27 03:20:15 +04:00
|
|
|
struct tty *
|
|
|
|
kdtty(dev)
|
|
|
|
dev_t dev;
|
|
|
|
{
|
1996-01-25 01:39:48 +03:00
|
|
|
struct kd_softc *kd;
|
|
|
|
|
|
|
|
kd = &kd_softc; /* XXX */
|
|
|
|
return (kd->kd_tty);
|
1995-04-27 03:20:15 +04:00
|
|
|
}
|
|
|
|
|
1994-05-04 09:27:50 +04:00
|
|
|
int
|
|
|
|
kdopen(dev, flag, mode, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, mode;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1996-01-25 01:39:48 +03:00
|
|
|
struct kd_softc *kd;
|
|
|
|
int error, s, unit;
|
1994-05-04 09:27:50 +04:00
|
|
|
struct tty *tp;
|
|
|
|
|
|
|
|
unit = minor(dev);
|
1996-01-25 01:39:48 +03:00
|
|
|
if (unit != 0)
|
1994-05-04 09:27:50 +04:00
|
|
|
return ENXIO;
|
1996-01-25 01:39:48 +03:00
|
|
|
kd = &kd_softc; /* XXX */
|
|
|
|
tp = kd->kd_tty;
|
1994-05-04 09:27:50 +04:00
|
|
|
|
1996-01-25 01:39:48 +03:00
|
|
|
if ((error = kbd_iopen(unit)) != 0) {
|
1994-12-17 23:14:22 +03:00
|
|
|
#ifdef DIAGNOSTIC
|
1996-10-13 07:47:25 +04:00
|
|
|
printf("kd: kbd_iopen, error=%d\n", error);
|
1994-12-17 23:14:22 +03:00
|
|
|
#endif
|
1994-06-03 06:05:18 +04:00
|
|
|
return (error);
|
1994-12-17 23:14:22 +03:00
|
|
|
}
|
1994-06-03 06:05:18 +04:00
|
|
|
|
1996-01-25 01:39:48 +03:00
|
|
|
/* It's simpler to do this up here. */
|
|
|
|
if (((tp->t_state & (TS_ISOPEN | TS_XCLUDE))
|
|
|
|
== (TS_ISOPEN | TS_XCLUDE))
|
|
|
|
&& (p->p_ucred->cr_uid != 0) )
|
|
|
|
{
|
|
|
|
return (EBUSY);
|
|
|
|
}
|
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
|
1994-05-04 09:27:50 +04:00
|
|
|
if ((tp->t_state & TS_ISOPEN) == 0) {
|
1996-01-25 01:39:48 +03:00
|
|
|
/* First open. */
|
1994-05-04 09:27:50 +04:00
|
|
|
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;
|
1996-01-25 01:39:48 +03:00
|
|
|
(void) kdparam(tp, &tp->t_termios);
|
1994-05-04 09:27:50 +04:00
|
|
|
ttsetwater(tp);
|
1996-01-25 01:39:48 +03:00
|
|
|
/* Flush pending input? Clear translator? */
|
|
|
|
/* This (pseudo)device always has SOFTCAR */
|
|
|
|
tp->t_state |= TS_CARR_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
splx(s);
|
1994-05-04 09:27:50 +04:00
|
|
|
|
|
|
|
return ((*linesw[tp->t_line].l_open)(dev, tp));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
kdclose(dev, flag, mode, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, mode;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1996-01-25 01:39:48 +03:00
|
|
|
struct kd_softc *kd;
|
|
|
|
struct tty *tp;
|
|
|
|
|
|
|
|
kd = &kd_softc; /* XXX */
|
|
|
|
tp = kd->kd_tty;
|
|
|
|
|
|
|
|
/* XXX This is for cons.c. */
|
|
|
|
if ((tp->t_state & TS_ISOPEN) == 0)
|
|
|
|
return 0;
|
1994-05-04 09:27:50 +04:00
|
|
|
|
|
|
|
(*linesw[tp->t_line].l_close)(tp, flag);
|
|
|
|
ttyclose(tp);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
kdread(dev, uio, flag)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
|
|
|
int flag;
|
|
|
|
{
|
1996-01-25 01:39:48 +03:00
|
|
|
struct kd_softc *kd;
|
|
|
|
struct tty *tp;
|
|
|
|
|
|
|
|
kd = &kd_softc; /* XXX */
|
|
|
|
tp = kd->kd_tty;
|
1994-05-04 09:27:50 +04:00
|
|
|
|
|
|
|
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
kdwrite(dev, uio, flag)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
|
|
|
int flag;
|
|
|
|
{
|
1996-01-25 01:39:48 +03:00
|
|
|
struct kd_softc *kd;
|
1995-04-10 11:33:53 +04:00
|
|
|
struct tty *tp;
|
|
|
|
|
1996-01-25 01:39:48 +03:00
|
|
|
kd = &kd_softc; /* XXX */
|
|
|
|
tp = kd->kd_tty;
|
|
|
|
|
|
|
|
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
|
1995-04-10 11:33:53 +04:00
|
|
|
}
|
|
|
|
|
1994-05-04 09:27:50 +04:00
|
|
|
int
|
|
|
|
kdioctl(dev, cmd, data, flag, p)
|
|
|
|
dev_t dev;
|
1996-01-25 01:39:48 +03:00
|
|
|
u_long cmd;
|
1994-05-04 09:27:50 +04:00
|
|
|
caddr_t data;
|
|
|
|
int flag;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1996-01-25 01:39:48 +03:00
|
|
|
struct kd_softc *kd;
|
|
|
|
struct tty *tp;
|
1994-05-04 09:27:50 +04:00
|
|
|
int error;
|
1996-01-25 01:39:48 +03:00
|
|
|
|
|
|
|
kd = &kd_softc; /* XXX */
|
|
|
|
tp = kd->kd_tty;
|
1994-05-04 09:27:50 +04: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;
|
|
|
|
|
|
|
|
/* Handle any ioctl commands specific to kbd/display. */
|
|
|
|
/* XXX - Send KB* ioctls to kbd module? */
|
|
|
|
/* XXX - Send FB* ioctls to fb module? */
|
|
|
|
|
|
|
|
return ENOTTY;
|
|
|
|
}
|
|
|
|
|
1997-02-11 02:26:21 +03:00
|
|
|
void
|
|
|
|
kdstop(tp, flag)
|
|
|
|
struct tty *tp;
|
|
|
|
int flag;
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1996-01-25 01:39:48 +03:00
|
|
|
|
|
|
|
static int
|
|
|
|
kdparam(tp, t)
|
|
|
|
struct tty *tp;
|
|
|
|
struct termios *t;
|
|
|
|
{
|
|
|
|
/* XXX - These are ignored... */
|
|
|
|
tp->t_ispeed = t->c_ispeed;
|
|
|
|
tp->t_ospeed = t->c_ospeed;
|
|
|
|
tp->t_cflag = t->c_cflag;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-03-28 20:09:41 +04:00
|
|
|
static void kd_later(void*);
|
|
|
|
static void kd_putfb(struct tty *);
|
|
|
|
|
1997-02-11 02:26:21 +03:00
|
|
|
static void
|
1994-05-04 09:27:50 +04:00
|
|
|
kdstart(tp)
|
|
|
|
struct tty *tp;
|
|
|
|
{
|
|
|
|
struct clist *cl;
|
1995-03-28 20:09:41 +04:00
|
|
|
register int s;
|
1994-05-04 09:27:50 +04:00
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
if (tp->t_state & (TS_BUSY|TS_TTSTOP|TS_TIMEOUT))
|
|
|
|
goto out;
|
|
|
|
|
1995-03-28 20:09:41 +04:00
|
|
|
cl = &tp->t_outq;
|
|
|
|
if (cl->c_cc) {
|
1995-03-24 22:48:41 +03:00
|
|
|
if (kd_is_console) {
|
1995-03-28 20:09:41 +04:00
|
|
|
tp->t_state |= TS_BUSY;
|
|
|
|
if ((s & PSL_IPL) == 0) {
|
|
|
|
/* called at level zero - update screen now. */
|
|
|
|
(void) splsoftclock();
|
|
|
|
kd_putfb(tp);
|
|
|
|
(void) spltty();
|
|
|
|
tp->t_state &= ~TS_BUSY;
|
|
|
|
} else {
|
|
|
|
/* called at interrupt level - do it later */
|
|
|
|
timeout(kd_later, (void*)tp, 0);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* This driver uses the PROM for writing the screen,
|
|
|
|
* and that only works if this is the console device.
|
|
|
|
* If this is not the console, just flush the output.
|
|
|
|
* Sorry. (In that case, use xdm instead of getty.)
|
|
|
|
*/
|
|
|
|
ndflush(cl, cl->c_cc);
|
1995-03-24 22:48:41 +03:00
|
|
|
}
|
1994-05-04 09:27:50 +04:00
|
|
|
}
|
1995-03-28 20:09:41 +04:00
|
|
|
if (cl->c_cc <= tp->t_lowat) {
|
|
|
|
if (tp->t_state & TS_ASLEEP) {
|
|
|
|
tp->t_state &= ~TS_ASLEEP;
|
|
|
|
wakeup((caddr_t)cl);
|
|
|
|
}
|
|
|
|
selwakeup(&tp->t_wsel);
|
1994-05-04 09:27:50 +04:00
|
|
|
}
|
|
|
|
out:
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
1995-03-28 20:09:41 +04:00
|
|
|
/*
|
|
|
|
* Timeout function to do delayed writes to the screen.
|
|
|
|
* Called at splsoftclock when requested by kdstart.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
kd_later(tpaddr)
|
|
|
|
void *tpaddr;
|
|
|
|
{
|
|
|
|
struct tty *tp = tpaddr;
|
|
|
|
register int s;
|
|
|
|
|
|
|
|
kd_putfb(tp);
|
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
tp->t_state &= ~TS_BUSY;
|
1996-04-26 22:36:54 +04:00
|
|
|
(*linesw[tp->t_line].l_start)(tp);
|
1995-03-28 20:09:41 +04:00
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Put text on the screen using the PROM monitor.
|
|
|
|
* This can take a while, so to avoid missing
|
|
|
|
* interrupts, this is called at splsoftclock.
|
|
|
|
*/
|
1997-02-11 02:26:21 +03:00
|
|
|
static void
|
|
|
|
kd_putfb(tp)
|
1995-03-28 20:09:41 +04:00
|
|
|
struct tty *tp;
|
|
|
|
{
|
1996-01-25 01:39:48 +03:00
|
|
|
char buf[PUT_WSIZE];
|
1995-03-28 20:09:41 +04:00
|
|
|
struct clist *cl = &tp->t_outq;
|
|
|
|
char *p, *end;
|
|
|
|
int len;
|
|
|
|
|
1996-01-25 01:39:48 +03:00
|
|
|
while ((len = q_to_b(cl, buf, PUT_WSIZE-1)) > 0) {
|
1995-03-28 20:09:41 +04:00
|
|
|
/* PROM will barf if high bits are set. */
|
|
|
|
p = buf;
|
|
|
|
end = buf + len;
|
|
|
|
while (p < end)
|
|
|
|
*p++ &= 0x7f;
|
|
|
|
(romVectorPtr->fbWriteStr)(buf, len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-01-25 01:39:48 +03:00
|
|
|
/*
|
1996-04-07 09:47:26 +04:00
|
|
|
* Our "interrupt" routine for input. This is called by
|
|
|
|
* the keyboard driver (dev/sun/kbd.c) at spltty.
|
1996-01-25 01:39:48 +03:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
kd_input(c)
|
|
|
|
int c;
|
1994-05-04 09:27:50 +04:00
|
|
|
{
|
1996-01-25 01:39:48 +03:00
|
|
|
struct kd_softc *kd = &kd_softc;
|
|
|
|
struct tty *tp;
|
1994-05-04 09:27:50 +04:00
|
|
|
|
1996-01-25 01:39:48 +03:00
|
|
|
/* XXX: Make sure the device is open. */
|
|
|
|
tp = kd->kd_tty;
|
|
|
|
if (tp == NULL)
|
|
|
|
return;
|
1997-02-11 02:26:21 +03:00
|
|
|
if ((tp->t_state & TS_ISOPEN) == 0)
|
1996-01-25 01:39:48 +03:00
|
|
|
return;
|
1994-05-04 09:27:50 +04:00
|
|
|
|
1996-04-26 22:36:54 +04:00
|
|
|
(*linesw[tp->t_line].l_rint)(c, tp);
|
1996-01-25 01:39:48 +03:00
|
|
|
}
|
1994-05-04 09:27:50 +04:00
|
|
|
|
|
|
|
|
1996-01-25 01:39:48 +03:00
|
|
|
/****************************************************************
|
|
|
|
* kd console support
|
|
|
|
****************************************************************/
|
1994-05-04 09:27:50 +04:00
|
|
|
|
1996-01-25 01:39:48 +03:00
|
|
|
/* The debugger gets its own key translation state. */
|
|
|
|
static struct kbd_state kdcn_state;
|
1994-05-04 09:27:50 +04:00
|
|
|
|
1997-02-11 02:26:21 +03:00
|
|
|
static void kdcnprobe __P((struct consdev *));
|
|
|
|
static void kdcninit __P((struct consdev *));
|
|
|
|
static int kdcngetc __P((dev_t));
|
|
|
|
static void kdcnputc __P((dev_t, int));
|
|
|
|
static void kdcnpollc __P((dev_t, int));
|
|
|
|
|
|
|
|
struct consdev consdev_kd = {
|
|
|
|
kdcnprobe,
|
|
|
|
kdcninit,
|
|
|
|
kdcngetc,
|
|
|
|
kdcnputc,
|
|
|
|
kdcnpollc,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* We never call this. */
|
|
|
|
static void
|
|
|
|
kdcnprobe(cn)
|
|
|
|
struct consdev *cn;
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1996-01-25 01:39:48 +03:00
|
|
|
kdcninit(cn)
|
|
|
|
struct consdev *cn;
|
1994-05-04 09:27:50 +04:00
|
|
|
{
|
1996-01-25 01:39:48 +03:00
|
|
|
struct kbd_state *ks = &kdcn_state;
|
1994-12-17 23:14:22 +03:00
|
|
|
|
1997-02-10 22:11:12 +03:00
|
|
|
cn->cn_dev = makedev(KDMAJOR, 0);
|
|
|
|
cn->cn_pri = CN_INTERNAL;
|
1994-12-17 23:14:22 +03:00
|
|
|
|
|
|
|
/* This prepares kbd_translate() */
|
1996-01-25 01:39:48 +03:00
|
|
|
ks->kbd_id = KBD_MIN_TYPE;
|
|
|
|
kbd_xlate_init(ks);
|
1994-12-17 23:14:22 +03:00
|
|
|
|
1995-03-24 22:48:41 +03:00
|
|
|
/* Indicate that it is OK to use the PROM fbwrite */
|
|
|
|
kd_is_console = 1;
|
1994-05-04 09:27:50 +04:00
|
|
|
}
|
|
|
|
|
1997-02-11 02:26:21 +03:00
|
|
|
static int
|
1994-05-04 09:27:50 +04:00
|
|
|
kdcngetc(dev)
|
|
|
|
dev_t dev;
|
|
|
|
{
|
1996-01-25 01:39:48 +03:00
|
|
|
struct kbd_state *ks = &kdcn_state;
|
|
|
|
int code, class, data, keysym;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
code = zs_getc(zs_conschan);
|
|
|
|
keysym = kbd_code_to_keysym(ks, code);
|
|
|
|
class = KEYSYM_CLASS(keysym);
|
|
|
|
|
|
|
|
switch (class) {
|
|
|
|
case KEYSYM_ASCII:
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
case KEYSYM_CLRMOD:
|
|
|
|
case KEYSYM_SETMOD:
|
|
|
|
data = (keysym & 0x1F);
|
|
|
|
/* Only allow ctrl or shift. */
|
|
|
|
if (data > KBMOD_SHIFT_R)
|
|
|
|
break;
|
|
|
|
data = 1 << data;
|
|
|
|
if (class == KEYSYM_SETMOD)
|
|
|
|
ks->kbd_modbits |= data;
|
|
|
|
else
|
|
|
|
ks->kbd_modbits &= ~data;
|
|
|
|
break;
|
1994-05-04 09:27:50 +04:00
|
|
|
|
1996-01-25 01:39:48 +03:00
|
|
|
case KEYSYM_ALL_UP:
|
|
|
|
/* No toggle keys here. */
|
|
|
|
ks->kbd_modbits = 0;
|
|
|
|
break;
|
1994-05-04 09:27:50 +04:00
|
|
|
|
1996-01-25 01:39:48 +03:00
|
|
|
default: /* ignore all other keysyms */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
return (keysym);
|
1994-05-04 09:27:50 +04:00
|
|
|
}
|
|
|
|
|
1997-02-11 02:26:21 +03:00
|
|
|
static void
|
1994-05-04 09:27:50 +04:00
|
|
|
kdcnputc(dev, c)
|
|
|
|
dev_t dev;
|
|
|
|
int c;
|
|
|
|
{
|
1995-03-28 20:09:41 +04:00
|
|
|
(romVectorPtr->fbWriteChar)(c & 0x7f);
|
1994-05-04 09:27:50 +04:00
|
|
|
}
|
1995-03-10 05:09:35 +03:00
|
|
|
|
1997-02-11 02:26:21 +03:00
|
|
|
static void
|
|
|
|
kdcnpollc(dev, on)
|
1995-03-10 05:09:35 +03:00
|
|
|
dev_t dev;
|
|
|
|
int on;
|
|
|
|
{
|
1996-01-25 01:39:48 +03:00
|
|
|
struct kbd_state *ks = &kdcn_state;
|
|
|
|
|
|
|
|
if (on) {
|
|
|
|
/* Entering debugger. */
|
1995-03-10 05:09:35 +03:00
|
|
|
fb_unblank();
|
1996-01-25 01:39:48 +03:00
|
|
|
/* Clear shift keys too. */
|
|
|
|
ks->kbd_modbits = 0;
|
|
|
|
} else {
|
|
|
|
/* Resuming kernel. */
|
|
|
|
}
|
1995-03-10 05:09:35 +03:00
|
|
|
}
|
1996-01-25 01:39:48 +03:00
|
|
|
|