Refactor kbd and mouse drivers so that they can use different middle
layers. Common middle layer shared by kbd_zs and sunkbd is moved into the new file. Move shared config directives to files.sun and adjust ports' files.* accordingly. Need this to support console/Xsun on Mr.Coffee JavaStation. Tested on sparc, sparc64 (by martin) and sun3 (by jdc).
This commit is contained in:
parent
4eb09bb2aa
commit
191626f788
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.sparc,v 1.117 2002/09/06 13:18:43 gehenna Exp $
|
||||
# $NetBSD: files.sparc,v 1.118 2002/10/03 16:13:24 uwe Exp $
|
||||
|
||||
# @(#)files.sparc 8.1 (Berkeley) 7/19/93
|
||||
# sparc-specific configuration info
|
||||
@ -127,6 +127,12 @@ attach zs at bootbus with zs_bootbus
|
||||
file arch/sparc/dev/zs.c zs needs-count
|
||||
file dev/ic/z8530sc.c zs
|
||||
|
||||
define zstty {}
|
||||
device zstty: tty
|
||||
attach zstty at zs
|
||||
file dev/ic/z8530tty.c zstty needs-flag
|
||||
file arch/sparc/dev/zs_kgdb.c kgdb
|
||||
|
||||
device fdc {}
|
||||
attach fdc at mainbus with fdc_mainbus
|
||||
attach fdc at obio with fdc_obio
|
||||
@ -151,31 +157,51 @@ file arch/sparc/dev/ts102.c tpcic
|
||||
include "dev/pcmcia/files.pcmcia"
|
||||
include "dev/ata/files.ata"
|
||||
|
||||
|
||||
#
|
||||
# Console (zs) related stuff
|
||||
# Console related stuff
|
||||
#
|
||||
|
||||
device zstty: tty
|
||||
attach zstty at zs
|
||||
file dev/ic/z8530tty.c zstty needs-flag
|
||||
file arch/sparc/dev/zs_kgdb.c kgdb
|
||||
file arch/sparc/dev/kd.c # console
|
||||
|
||||
define zsevent
|
||||
#file dev/sun/event.c zsevent
|
||||
attach pckbc at obio with pckbc_obio
|
||||
attach pckbc at ebus with pckbc_ebus
|
||||
file arch/sparc/dev/pckbc_js.c pckbc_obio | pckbc_ebus
|
||||
|
||||
device kbd: zsevent
|
||||
|
||||
# sun keyboard at a serial port
|
||||
attach kbd at zs with kbd_zs
|
||||
file dev/sun/kbd_zs.c kbd_zs
|
||||
file dev/sun/kbd.c kbd needs-flag
|
||||
file dev/sun/kbd_tables.c kbd
|
||||
file dev/sun/sunkbd.c kbd
|
||||
file arch/sparc/dev/kd.c
|
||||
file dev/sun/kbd_zs.c kbd_zs # kbd lower layer
|
||||
|
||||
device ms: zsevent
|
||||
# sun keyboard at a tty line discipline
|
||||
# only used by sparc64, but we can test-compile it here (pretend kbd_zs)
|
||||
attach kbd at zstty with kbd_tty
|
||||
file dev/sun/sunkbd.c kbd_tty # kbd lower layer
|
||||
|
||||
# shared middle layer for serial keyboard
|
||||
file dev/sun/kbdsun.c kbd_zs | kbd_tty # kbd middle layer
|
||||
|
||||
# PC/AT keyboard at 8042 (pckbc) for Mr.Coffee
|
||||
attach kbd at pckbc with kbd_pckbc
|
||||
file arch/sparc/dev/kbd_pckbc.c kbd_pckbc # kbd mid/lower layers
|
||||
|
||||
|
||||
# sun (mouse systems) mouse at a serial port
|
||||
attach ms at zs with ms_zs
|
||||
file dev/sun/ms_zs.c ms_zs
|
||||
file dev/sun/ms.c ms needs-flag
|
||||
file dev/sun/sunms.c ms
|
||||
file dev/sun/ms_zs.c ms_zs # mouse lower layer
|
||||
|
||||
# sun (mouse systems) mouse at a tty line discipline
|
||||
# only used by sparc64, but we can test-compile it here (pretend ms_zs)
|
||||
attach ms at zstty with ms_tty
|
||||
file dev/sun/sunms.c ms_tty # mouse lower layer
|
||||
|
||||
# XXX: middle layer for sun (mouse systems) serial mice consists of
|
||||
# just one function in dev/sun/ms.c (upper layer). Split it out?
|
||||
|
||||
# PS/2 mouse at 8042 (pckbc) for Mr.Coffee
|
||||
attach ms at pckbc with ms_pckbc
|
||||
file arch/sparc/dev/ms_pckbc.c ms_pckbc # lower/middle layers
|
||||
|
||||
|
||||
#
|
||||
# Machine-independent SCSI drivers
|
||||
@ -282,11 +308,15 @@ file arch/sparc/sparc/db_interface.c ddb | kgdb
|
||||
file arch/sparc/sparc/db_trace.c ddb
|
||||
file arch/sparc/sparc/db_disasm.c ddb
|
||||
|
||||
|
||||
#
|
||||
# Raster Console
|
||||
# Raster Console / WS Console
|
||||
#
|
||||
include "dev/rcons/files.rcons"
|
||||
include "dev/wsfont/files.wsfont"
|
||||
include "dev/wscons/files.wscons" # includes rcons as well
|
||||
include "dev/wsfont/files.wsfont" # both rcons and wscons need it
|
||||
|
||||
include "dev/pckbc/files.pckbc"
|
||||
|
||||
|
||||
#
|
||||
# Compatibility modules
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.sparc64,v 1.67 2002/09/29 04:12:02 chs Exp $
|
||||
# $NetBSD: files.sparc64,v 1.68 2002/10/03 16:13:24 uwe Exp $
|
||||
|
||||
# @(#)files.sparc64 8.1 (Berkeley) 7/19/93
|
||||
# sparc64-specific configuration info
|
||||
@ -137,21 +137,18 @@ device sabtty: tty
|
||||
attach sabtty at sab
|
||||
# file arch/sparc64/dev/sabtty.c sabtty needs-flag
|
||||
|
||||
device kbd
|
||||
attach kbd at zs with kbd_zs
|
||||
attach kbd at zstty, com
|
||||
file dev/sun/kbd_zs.c kbd_zs
|
||||
file dev/sun/kbd.c kbd needs-flag
|
||||
file dev/sun/kbd_tables.c kbd
|
||||
file arch/sparc64/dev/kd.c kbd
|
||||
file dev/sun/sunkbd.c kbd needs-flag
|
||||
|
||||
device ms
|
||||
attach kbd at zs with kbd_zs
|
||||
attach kbd at zstty, com with kbd_tty
|
||||
file dev/sun/kbd_zs.c kbd_zs
|
||||
file dev/sun/sunkbd.c kbd_tty
|
||||
file dev/sun/kbdsun.c kbd_zs | kbd_tty
|
||||
|
||||
attach ms at zs with ms_zs
|
||||
attach ms at zstty, com
|
||||
attach ms at zstty, com with ms_tty
|
||||
file dev/sun/ms_zs.c ms_zs
|
||||
file dev/sun/ms.c ms needs-flag
|
||||
file dev/sun/sunms.c ms needs-flag
|
||||
file dev/sun/sunms.c ms_tty
|
||||
|
||||
#
|
||||
# Machine-independent SCSI drivers
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.sun2,v 1.8 2002/09/06 13:18:43 gehenna Exp $
|
||||
# $NetBSD: files.sun2,v 1.9 2002/10/03 16:13:25 uwe Exp $
|
||||
|
||||
#
|
||||
# sun2-specific configuration info
|
||||
@ -142,17 +142,14 @@ device pcons
|
||||
attach pcons at mainbus
|
||||
file arch/sun2/dev/pcons.c pcons needs-flag
|
||||
|
||||
device kbd
|
||||
attach kbd at zstty
|
||||
file dev/sun/kbd.c kbd needs-flag
|
||||
file dev/sun/kbd_tables.c kbd
|
||||
file arch/sun2/dev/kd.c kbd
|
||||
file dev/sun/sunkbd.c kbd needs-flag
|
||||
|
||||
device ms
|
||||
attach ms at zstty
|
||||
file dev/sun/ms.c ms needs-flag
|
||||
file dev/sun/sunms.c ms needs-flag
|
||||
attach kbd at zstty with kbd_tty
|
||||
file dev/sun/kbdsun.c kbd_tty
|
||||
file dev/sun/sunkbd.c kbd_tty
|
||||
|
||||
attach ms at zstty with ms_tty
|
||||
file dev/sun/sunms.c ms_tty
|
||||
|
||||
# Memory Disk for boot tape
|
||||
file dev/md_root.c memory_disk_hooks
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.sun3,v 1.63 2002/09/06 13:18:43 gehenna Exp $
|
||||
# $NetBSD: files.sun3,v 1.64 2002/10/03 16:13:25 uwe Exp $
|
||||
|
||||
#
|
||||
# sun3-specific configuration info
|
||||
@ -240,6 +240,7 @@ file dev/sun/event.c zsevent
|
||||
device kbd: zsevent
|
||||
attach kbd at zsc with kbd_zs
|
||||
file dev/sun/kbd_zs.c kbd_zs
|
||||
file dev/sun/kbdsun.c kbd_zs
|
||||
file dev/sun/kbd.c kbd needs-flag
|
||||
file dev/sun/kbd_tables.c kbd
|
||||
file arch/sun3/dev/kd.c kbd
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fb.c,v 1.8 2002/09/06 13:18:43 gehenna Exp $ */
|
||||
/* $NetBSD: fb.c,v 1.9 2002/10/03 16:13:25 uwe Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -50,7 +50,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: fb.c,v 1.8 2002/09/06 13:18:43 gehenna Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: fb.c,v 1.9 2002/10/03 16:13:25 uwe Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -363,7 +363,7 @@ fb_bell(on)
|
||||
int on;
|
||||
{
|
||||
#if NKBD > 0
|
||||
(void)kbd_docmd(on?KBD_CMD_BELL:KBD_CMD_NOBELL, 0);
|
||||
kbd_bell(on);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,53 @@
|
||||
# $NetBSD: files.sun,v 1.4 2000/09/21 23:40:47 eeh Exp $
|
||||
# $NetBSD: files.sun,v 1.5 2002/10/03 16:13:25 uwe Exp $
|
||||
#
|
||||
# Configuration file for devices found on Sun machines.
|
||||
#
|
||||
|
||||
file dev/sun/event.c
|
||||
|
||||
#
|
||||
# Sun keyboard and mouse drivers
|
||||
#
|
||||
|
||||
define firm_events
|
||||
file dev/sun/event.c firm_events
|
||||
|
||||
|
||||
# upper layer of sun kbd driver
|
||||
# examples for lower and middle layers follows. cannot move them here
|
||||
# because zs/zstty attachments are slightly different on each sun port.
|
||||
device kbd: firm_events
|
||||
file dev/sun/kbd.c kbd needs-flag
|
||||
file dev/sun/kbd_tables.c kbd
|
||||
|
||||
# e.g. - lower layer: sun keyboard at zs
|
||||
#attach kbd at zs with kbd_zs
|
||||
#file dev/sun/kbd_zs.c kbd_zs
|
||||
|
||||
# e.g. - lower layer: sun keyboard at a line discipline
|
||||
#attach kbd at zstty, com with kbd_tty
|
||||
#file dev/sun/sunkbd.c kbd_tty
|
||||
|
||||
# e.g. - middle layer: serial attachment of sun keyboard
|
||||
#file dev/sun/kbdsun.c kbd_zs | kbd_tty
|
||||
|
||||
|
||||
# upper layer of sun ms driver
|
||||
# XXX: middle layer for sun serial mice (split out?)
|
||||
device ms: firm_events
|
||||
file dev/sun/ms.c ms needs-flag
|
||||
|
||||
# e.g. - lower layer: sun (mouse systems) mouse at zs
|
||||
#attach ms at zs with ms_zs
|
||||
#file dev/sun/ms_zs.c ms_zs
|
||||
|
||||
# e.g. - lower layer: sun (mouse systems) mouse at a line discipline
|
||||
#attach ms at zstty, com with ms_tty
|
||||
#file dev/sun/sunms.c ms_tty
|
||||
|
||||
# XXX: middle layer for sun (mouse systems) serial mice consists of
|
||||
# just one function in dev/sun/ms.c. It probably should be split out
|
||||
# for consistency into a separate middle-layer file.
|
||||
|
||||
|
||||
|
||||
#
|
||||
@ -29,15 +73,7 @@ device bwtwo: fb, rasops1, pfour
|
||||
file dev/sun/bwtwo.c bwtwo needs-flag
|
||||
|
||||
device cgthree: bt_dac, fb, rasops8
|
||||
file dev/sun/cgthree.c cgthree needs-flag
|
||||
file dev/sun/cgthree.c cgthree needs-flag
|
||||
|
||||
device cgsix: bt_dac, fb, rasops8, pfour
|
||||
file dev/sun/cgsix.c cgsix needs-flag
|
||||
|
||||
#device sunkbd
|
||||
#file dev/sun/sunkbd.c sunkbd needs-flag
|
||||
#file dev/sun/kbd.c sunkbd
|
||||
|
||||
#device sunms
|
||||
#file dev/sun/sunms.c sunms needs-flag
|
||||
#file dev/sun/ms.c sunms
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kbd_reg.h,v 1.1 2002/03/22 00:11:55 fredette Exp $ */
|
||||
/* $NetBSD: kbd_reg.h,v 1.2 2002/10/03 16:13:25 uwe Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -92,5 +92,6 @@
|
||||
#define LED_CAPS_LOCK 0x8
|
||||
|
||||
#ifdef _KERNEL
|
||||
int kbd_docmd __P((int, int));
|
||||
/* XXX: backdoor for /dev/fb driver */
|
||||
extern void kbd_bell(int);
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kbd_xlate.h,v 1.3 2000/03/19 12:50:43 pk Exp $ */
|
||||
/* $NetBSD: kbd_xlate.h,v 1.4 2002/10/03 16:13:26 uwe Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -66,10 +66,7 @@
|
||||
*/
|
||||
struct kbd_state {
|
||||
struct keyboard kbd_k; /* table pointers */
|
||||
int kbd_modbits; /* modifier keys */
|
||||
int kbd_expect; /* expect ID or layout byte */
|
||||
#define KBD_EXPECT_IDCODE 1
|
||||
#define KBD_EXPECT_LAYOUT 2
|
||||
int kbd_modbits; /* modifier keys */
|
||||
|
||||
u_char kbd_id; /* a place to store the ID */
|
||||
u_char kbd_layout; /* which keyboard layout */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kbd_zs.c,v 1.13 2002/10/02 16:52:58 thorpej Exp $ */
|
||||
/* $NetBSD: kbd_zs.c,v 1.14 2002/10/03 16:13:26 uwe Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -45,9 +45,8 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Keyboard driver (/dev/kbd -- note that we do not have minor numbers
|
||||
* [yet?]). Translates incoming bytes to ASCII or to `firm_events' and
|
||||
* passes them up to the appropriate reader.
|
||||
* /dev/kbd lower layer for sun keyboard off a zs channel.
|
||||
* This driver uses kbdsun middle layer to hook up to /dev/kbd.
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -58,7 +57,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kbd_zs.c,v 1.13 2002/10/02 16:52:58 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kbd_zs.c,v 1.14 2002/10/03 16:13:26 uwe Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -80,6 +79,7 @@ __KERNEL_RCSID(0, "$NetBSD: kbd_zs.c,v 1.13 2002/10/02 16:52:58 thorpej Exp $");
|
||||
#include <dev/sun/event_var.h>
|
||||
#include <dev/sun/kbd_xlate.h>
|
||||
#include <dev/sun/kbdvar.h>
|
||||
#include <dev/sun/kbdsunvar.h>
|
||||
|
||||
/****************************************************************
|
||||
* Interface to the lower layer (zscc)
|
||||
@ -99,9 +99,9 @@ struct zsops zsops_kbd = {
|
||||
|
||||
static int kbd_zs_match(struct device *, struct cfdata *, void *);
|
||||
static void kbd_zs_attach(struct device *, struct device *, void *);
|
||||
static void kbd_zs_write_data __P((struct kbd_softc *, int));
|
||||
static void kbd_zs_write_data __P((struct kbd_sun_softc *, int));
|
||||
|
||||
CFATTACH_DECL(kbd_zs, sizeof(struct kbd_softc),
|
||||
CFATTACH_DECL(kbd_zs, sizeof(struct kbd_sun_softc),
|
||||
kbd_zs_match, kbd_zs_attach, NULL, NULL);
|
||||
|
||||
/* Fall-back baud rate */
|
||||
@ -132,22 +132,24 @@ kbd_zs_attach(parent, self, aux)
|
||||
|
||||
{
|
||||
struct zsc_softc *zsc = (void *) parent;
|
||||
struct kbd_softc *k = (void *) self;
|
||||
struct kbd_sun_softc *k = (void *) self;
|
||||
struct zsc_attach_args *args = aux;
|
||||
struct zs_chanstate *cs;
|
||||
struct cfdata *cf;
|
||||
int channel, kbd_unit;
|
||||
int channel;
|
||||
int reset, s;
|
||||
int bps;
|
||||
|
||||
cf = k->k_dev.dv_cfdata;
|
||||
kbd_unit = k->k_dev.dv_unit;
|
||||
/* provide upper layer with a link to the middle layer */
|
||||
k->k_kbd.k_ops = &kbd_ops_sun;
|
||||
|
||||
/* provide middle layer with a link to the lower layer (i.e. us) */
|
||||
channel = args->channel;
|
||||
cs = zsc->zsc_cs[channel];
|
||||
cs->cs_private = k;
|
||||
cs->cs_ops = &zsops_kbd;
|
||||
k->k_cs = cs;
|
||||
k->k_write_data = kbd_zs_write_data;
|
||||
|
||||
if ((bps = cs->cs_defspeed) == 0)
|
||||
bps = kbd_zs_bps;
|
||||
|
||||
@ -167,8 +169,8 @@ kbd_zs_attach(parent, self, aux)
|
||||
cc->cc_iclose = kbd_cc_close;
|
||||
cc->cc_upstream = NULL;
|
||||
cons_attach_input(cc, args->consdev);
|
||||
k->k_cc = cc;
|
||||
k->k_isconsole = 1;
|
||||
k->k_kbd.k_cc = cc;
|
||||
k->k_kbd.k_isconsole = 1;
|
||||
printf(" (console input)");
|
||||
}
|
||||
printf("\n");
|
||||
@ -177,7 +179,7 @@ kbd_zs_attach(parent, self, aux)
|
||||
|
||||
/* Initialize the speed, etc. */
|
||||
s = splzs();
|
||||
if (k->k_isconsole == 0) {
|
||||
if (k->k_kbd.k_isconsole == 0) {
|
||||
/* Not the console; may need reset. */
|
||||
reset = (channel == 0) ?
|
||||
ZSWR9_A_RESET : ZSWR9_B_RESET;
|
||||
@ -191,7 +193,7 @@ kbd_zs_attach(parent, self, aux)
|
||||
splx(s);
|
||||
|
||||
/* Do this before any calls to kbd_rint(). */
|
||||
kbd_xlate_init(&k->k_state);
|
||||
kbd_xlate_init(&k->k_kbd.k_state);
|
||||
|
||||
/* XXX - Do this in open? */
|
||||
k->k_repeat_start = hz/2;
|
||||
@ -203,11 +205,11 @@ kbd_zs_attach(parent, self, aux)
|
||||
}
|
||||
|
||||
/*
|
||||
* used by kbd_start_tx();
|
||||
* used by kbd_sun_start_tx();
|
||||
*/
|
||||
void
|
||||
kbd_zs_write_data(k, c)
|
||||
struct kbd_softc *k;
|
||||
struct kbd_sun_softc *k;
|
||||
int c;
|
||||
{
|
||||
int s;
|
||||
@ -222,7 +224,7 @@ static void
|
||||
kbd_zs_rxint(cs)
|
||||
struct zs_chanstate *cs;
|
||||
{
|
||||
struct kbd_softc *k;
|
||||
struct kbd_sun_softc *k;
|
||||
int put, put_next;
|
||||
u_char c, rr1;
|
||||
|
||||
@ -250,7 +252,7 @@ kbd_zs_rxint(cs)
|
||||
k->k_magic1_down = 0;
|
||||
if (c == k->k_magic2) {
|
||||
/* Magic "L1-A" sequence; enter debugger. */
|
||||
if (k->k_isconsole) {
|
||||
if (k->k_kbd.k_isconsole) {
|
||||
zs_abort(cs);
|
||||
/* Debugger done. Fake L1-up to finish it. */
|
||||
c = k->k_magic1 | KBD_UP;
|
||||
@ -286,7 +288,7 @@ static void
|
||||
kbd_zs_txint(cs)
|
||||
struct zs_chanstate *cs;
|
||||
{
|
||||
struct kbd_softc *k;
|
||||
struct kbd_sun_softc *k;
|
||||
|
||||
k = cs->cs_private;
|
||||
zs_write_csr(cs, ZSWR0_RESET_TXINT);
|
||||
@ -301,7 +303,7 @@ kbd_zs_stint(cs, force)
|
||||
struct zs_chanstate *cs;
|
||||
int force;
|
||||
{
|
||||
struct kbd_softc *k;
|
||||
struct kbd_sun_softc *k;
|
||||
int rr0;
|
||||
|
||||
k = cs->cs_private;
|
||||
@ -340,7 +342,7 @@ static void
|
||||
kbd_zs_softint(cs)
|
||||
struct zs_chanstate *cs;
|
||||
{
|
||||
struct kbd_softc *k;
|
||||
struct kbd_sun_softc *k;
|
||||
int get, c, s;
|
||||
int intr_flags;
|
||||
u_short ring_data;
|
||||
@ -374,21 +376,21 @@ kbd_zs_softint(cs)
|
||||
* send a reset to resync key translation.
|
||||
*/
|
||||
log(LOG_ERR, "%s: input error (0x%x)\n",
|
||||
k->k_dev.dv_xname, ring_data);
|
||||
k->k_kbd.k_dev.dv_xname, ring_data);
|
||||
get = k->k_rbput; /* flush */
|
||||
goto send_reset;
|
||||
}
|
||||
|
||||
/* Pass this up to the "middle" layer. */
|
||||
kbd_input_raw(k, c);
|
||||
kbd_sun_input(k, c);
|
||||
}
|
||||
if (intr_flags & INTR_RX_OVERRUN) {
|
||||
log(LOG_ERR, "%s: input overrun\n",
|
||||
k->k_dev.dv_xname);
|
||||
k->k_kbd.k_dev.dv_xname);
|
||||
send_reset:
|
||||
/* Send a reset to resync translation. */
|
||||
kbd_output(k, KBD_CMD_RESET);
|
||||
kbd_start_tx(k);
|
||||
kbd_sun_output(k, KBD_CMD_RESET);
|
||||
kbd_sun_start_tx(k);
|
||||
}
|
||||
k->k_rbget = get;
|
||||
|
||||
@ -398,7 +400,7 @@ kbd_zs_softint(cs)
|
||||
* clear busy and wakeup drain waiters.
|
||||
*/
|
||||
k->k_txflags &= ~K_TXBUSY;
|
||||
kbd_start_tx(k);
|
||||
kbd_sun_start_tx(k);
|
||||
}
|
||||
|
||||
if (intr_flags & INTR_ST_CHECK) {
|
||||
@ -406,7 +408,7 @@ kbd_zs_softint(cs)
|
||||
* Status line change. (Not expected.)
|
||||
*/
|
||||
log(LOG_ERR, "%s: status interrupt?\n",
|
||||
k->k_dev.dv_xname);
|
||||
k->k_kbd.k_dev.dv_xname);
|
||||
cs->cs_rr0_delta = 0;
|
||||
}
|
||||
|
||||
|
595
sys/dev/sun/kbdsun.c
Normal file
595
sys/dev/sun/kbdsun.c
Normal file
@ -0,0 +1,595 @@
|
||||
/* $NetBSD: kbdsun.c,v 1.1 2002/10/03 16:13:26 uwe Exp $ */
|
||||
/* NetBSD: kbd.c,v 1.29 2001/11/13 06:54:32 lukem Exp */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* 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, Lawrence Berkeley Laboratory.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)kbd.c 8.2 (Berkeley) 10/30/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* /dev/kbd middle layer for sun keyboard off a serial line
|
||||
* This code is used by kbd_zs and sunkbd drivers (lower layer).
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kbdsun.c,v 1.1 2002/10/03 16:13:26 uwe Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/signalvar.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/poll.h>
|
||||
#include <sys/file.h>
|
||||
|
||||
#include <machine/vuid_event.h>
|
||||
#include <machine/kbd.h>
|
||||
#include <machine/kbio.h>
|
||||
#include <dev/sun/event_var.h>
|
||||
#include <dev/sun/kbd_xlate.h>
|
||||
|
||||
#include <dev/sun/kbdvar.h>
|
||||
#include <dev/sun/kbdsunvar.h>
|
||||
|
||||
|
||||
/* callbacks for the upper /dev/kbd layer */
|
||||
static int kbd_sun_open(struct kbd_softc *);
|
||||
static int kbd_sun_close(struct kbd_softc *);
|
||||
static int kbd_sun_do_cmd(struct kbd_softc *, int, int);
|
||||
static int kbd_sun_set_leds(struct kbd_softc *, int, int);
|
||||
|
||||
static void kbd_sun_set_leds1(struct kbd_softc *, int); /* aux */
|
||||
|
||||
struct kbd_ops kbd_ops_sun = {
|
||||
kbd_sun_open,
|
||||
kbd_sun_close,
|
||||
kbd_sun_do_cmd,
|
||||
kbd_sun_set_leds
|
||||
};
|
||||
|
||||
/* in user context, wait for keyboard output to finish */
|
||||
static int kbd_sun_drain_tx(struct kbd_sun_softc *);
|
||||
|
||||
/* helper functions for kbd_sun_input */
|
||||
static void kbd_sun_was_reset(struct kbd_sun_softc *);
|
||||
static void kbd_sun_new_layout(struct kbd_sun_softc *);
|
||||
static void kbd_sun_repeat(void *);
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Callbacks for upper layer.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Initialization to be done at first open.
|
||||
* This is called from kbdopen() or kd_cc_open()
|
||||
* Called with user context.
|
||||
*/
|
||||
static int
|
||||
kbd_sun_open(kbd)
|
||||
struct kbd_softc *kbd;
|
||||
{
|
||||
struct kbd_sun_softc *k = (struct kbd_sun_softc *)kbd;
|
||||
struct kbd_state *ks;
|
||||
int error, s;
|
||||
|
||||
if (kbd == NULL)
|
||||
return (ENXIO);
|
||||
|
||||
ks = &kbd->k_state;
|
||||
|
||||
/* tolerate extra calls. */
|
||||
if (k->k_isopen)
|
||||
return (0);
|
||||
|
||||
/* stop pending autorepeat */
|
||||
if (k->k_repeating) {
|
||||
k->k_repeating = 0;
|
||||
callout_stop(&k->k_repeat_ch);
|
||||
}
|
||||
|
||||
/* open internal device */
|
||||
if (k->k_deviopen)
|
||||
(*k->k_deviopen)((struct device *)k, FREAD|FWRITE);
|
||||
|
||||
s = spltty();
|
||||
|
||||
/* reset the keyboard and find out its type */
|
||||
kbd_sun_output(k, KBD_CMD_RESET);
|
||||
kbd_sun_start_tx(k);
|
||||
kbd_sun_drain_tx(k);
|
||||
|
||||
/* the wakeup for this is in kbd_was_reset(). */
|
||||
error = tsleep((caddr_t)&ks->kbd_id, PZERO | PCATCH, devopn, hz);
|
||||
if (error == EWOULDBLOCK) { /* no response */
|
||||
log(LOG_ERR, "%s: reset failed\n", kbd->k_dev.dv_xname);
|
||||
|
||||
/*
|
||||
* Allow the open anyway (to keep getty happy)
|
||||
* but assume the "least common denominator".
|
||||
*/
|
||||
error = 0;
|
||||
ks->kbd_id = KB_SUN2;
|
||||
}
|
||||
|
||||
/* initialize the table pointers for this type */
|
||||
kbd_xlate_init(ks);
|
||||
|
||||
/* earlier than type 4 does not know "layout" */
|
||||
if (ks->kbd_id < KB_SUN4)
|
||||
goto done;
|
||||
|
||||
/* ask for the layout */
|
||||
kbd_sun_output(k, KBD_CMD_GETLAYOUT);
|
||||
kbd_sun_start_tx(k);
|
||||
kbd_sun_drain_tx(k);
|
||||
|
||||
/* the wakeup for this is in kbd_new_layout() */
|
||||
error = tsleep((caddr_t)&ks->kbd_layout, PZERO | PCATCH, devopn, hz);
|
||||
if (error == EWOULDBLOCK) { /* no response */
|
||||
log(LOG_ERR, "%s: no response to get_layout\n",
|
||||
kbd->k_dev.dv_xname);
|
||||
error = 0;
|
||||
ks->kbd_layout = 0; /* US layout */
|
||||
}
|
||||
done:
|
||||
splx(s);
|
||||
|
||||
if (error == 0)
|
||||
k->k_isopen = 1;
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
kbd_sun_close(kbd)
|
||||
struct kbd_softc *kbd;
|
||||
{
|
||||
|
||||
return (0); /* nothing to do so far */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* keyboard command ioctl
|
||||
* ``unimplemented commands are ignored'' (blech)
|
||||
* XXX: This is also exported to the fb driver (for bell).
|
||||
*/
|
||||
static int
|
||||
kbd_sun_do_cmd(kbd, cmd, isioctl)
|
||||
struct kbd_softc *kbd;
|
||||
int cmd;
|
||||
int isioctl;
|
||||
{
|
||||
struct kbd_sun_softc *k = (struct kbd_sun_softc *)kbd;
|
||||
struct kbd_state *ks;
|
||||
int error, s;
|
||||
|
||||
error = 0;
|
||||
ks = &kbd->k_state;
|
||||
|
||||
switch (cmd) {
|
||||
|
||||
case KBD_CMD_BELL:
|
||||
case KBD_CMD_NOBELL:
|
||||
/* Supported by type 2, 3, and 4 keyboards */
|
||||
break;
|
||||
|
||||
case KBD_CMD_CLICK:
|
||||
case KBD_CMD_NOCLICK:
|
||||
/* Unsupported by type 2 keyboards */
|
||||
if (ks->kbd_id <= KB_SUN2)
|
||||
return (0);
|
||||
ks->kbd_click = (cmd == KBD_CMD_CLICK);
|
||||
break;
|
||||
|
||||
default:
|
||||
return (0);
|
||||
}
|
||||
|
||||
s = spltty();
|
||||
|
||||
if (isioctl)
|
||||
error = kbd_sun_drain_tx(k);
|
||||
|
||||
if (error == 0) {
|
||||
kbd_sun_output(k, cmd);
|
||||
kbd_sun_start_tx(k);
|
||||
}
|
||||
|
||||
splx(s);
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* KIOCSLED. Has user context.
|
||||
* Take care about spl and call kbd_sun_set_leds.
|
||||
*/
|
||||
static int
|
||||
kbd_sun_set_leds(kbd, leds, isioctl)
|
||||
struct kbd_softc *kbd;
|
||||
int leds;
|
||||
int isioctl;
|
||||
{
|
||||
struct kbd_sun_softc *k = (struct kbd_sun_softc *)kbd;
|
||||
|
||||
if (isioctl) {
|
||||
int error, s;
|
||||
s = spltty();
|
||||
error = kbd_sun_drain_tx(k);
|
||||
if (error == 0) {
|
||||
kbd_sun_set_leds1(kbd, leds);
|
||||
}
|
||||
splx(s);
|
||||
return (error);
|
||||
}
|
||||
else {
|
||||
kbd_sun_set_leds1(kbd, leds);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Safe to call from intterupt handler. Called at spltty()
|
||||
* by kbd_sun_iocsled and kbd_sun_input (via kbd_update_leds).
|
||||
*/
|
||||
static void
|
||||
kbd_sun_set_leds1(kbd, new_leds)
|
||||
struct kbd_softc *kbd;
|
||||
int new_leds;
|
||||
{
|
||||
struct kbd_sun_softc *k = (struct kbd_sun_softc *)kbd;
|
||||
struct kbd_state *ks = &kbd->k_state;
|
||||
|
||||
/* Don't send unless state changes. */
|
||||
if (ks->kbd_leds == new_leds)
|
||||
return;
|
||||
|
||||
ks->kbd_leds = new_leds;
|
||||
|
||||
/* Only type 4 and later has LEDs anyway. */
|
||||
if (ks->kbd_id < KB_SUN4)
|
||||
return;
|
||||
|
||||
kbd_sun_output(k, KBD_CMD_SETLED);
|
||||
kbd_sun_output(k, new_leds);
|
||||
kbd_sun_start_tx(k);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Methods for lower layer to call and related functions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Enqueue some output for the keyboard
|
||||
* Called at spltty().
|
||||
*/
|
||||
void
|
||||
kbd_sun_output(k, c)
|
||||
struct kbd_sun_softc *k;
|
||||
int c; /* the data */
|
||||
{
|
||||
int put;
|
||||
|
||||
put = k->k_tbput;
|
||||
k->k_tbuf[put] = (u_char)c;
|
||||
put = (put + 1) & KBD_TX_RING_MASK;
|
||||
|
||||
/* Would overrun if increment makes (put == get) */
|
||||
if (put == k->k_tbget) {
|
||||
log(LOG_WARNING, "%s: output overrun\n",
|
||||
k->k_kbd.k_dev.dv_xname);
|
||||
} else {
|
||||
/* OK, really increment. */
|
||||
k->k_tbput = put;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* In user context. Called at spltty().
|
||||
* Wait for output to keyboard to finish.
|
||||
*/
|
||||
static int
|
||||
kbd_sun_drain_tx(k)
|
||||
struct kbd_sun_softc *k;
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
while (k->k_txflags & K_TXBUSY && !error) {
|
||||
k->k_txflags |= K_TXWANT;
|
||||
error = tsleep((caddr_t)&k->k_txflags,
|
||||
PZERO | PCATCH, "kbdout", 0);
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Start the sending data from the output queue
|
||||
* Called at spltty().
|
||||
*/
|
||||
void
|
||||
kbd_sun_start_tx(k)
|
||||
struct kbd_sun_softc *k;
|
||||
{
|
||||
int get;
|
||||
u_char c;
|
||||
|
||||
if (k->k_txflags & K_TXBUSY)
|
||||
return;
|
||||
|
||||
/* Is there anything to send? */
|
||||
get = k->k_tbget;
|
||||
if (get == k->k_tbput) {
|
||||
/* Nothing to send. Wake drain waiters. */
|
||||
if (k->k_txflags & K_TXWANT) {
|
||||
k->k_txflags &= ~K_TXWANT;
|
||||
wakeup((caddr_t)&k->k_txflags);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Have something to send. */
|
||||
c = k->k_tbuf[get];
|
||||
get = (get + 1) & KBD_TX_RING_MASK;
|
||||
k->k_tbget = get;
|
||||
k->k_txflags |= K_TXBUSY;
|
||||
|
||||
/* Pass data down to the underlying device. */
|
||||
(*k->k_write_data)(k, c);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called by underlying driver's softint() routine on input,
|
||||
* which passes us the raw hardware scan codes.
|
||||
* Called at spltty()
|
||||
*/
|
||||
void
|
||||
kbd_sun_input(k, c)
|
||||
struct kbd_sun_softc *k;
|
||||
int c;
|
||||
{
|
||||
struct kbd_softc *kbd = (struct kbd_softc *)k;
|
||||
struct kbd_state *ks = &kbd->k_state;
|
||||
int keysym;
|
||||
|
||||
/* XXX - Input errors already handled. */
|
||||
|
||||
/* Are we expecting special input? */
|
||||
if (k->k_expect) {
|
||||
if (k->k_expect & KBD_EXPECT_IDCODE) {
|
||||
/* We read a KBD_RESET last time. */
|
||||
ks->kbd_id = c;
|
||||
kbd_sun_was_reset(k);
|
||||
}
|
||||
if (k->k_expect & KBD_EXPECT_LAYOUT) {
|
||||
/* We read a KBD_LAYOUT last time. */
|
||||
ks->kbd_layout = c;
|
||||
kbd_sun_new_layout(k);
|
||||
}
|
||||
k->k_expect = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Is this one of the "special" input codes? */
|
||||
if (KBD_SPECIAL(c)) {
|
||||
switch (c) {
|
||||
case KBD_RESET:
|
||||
k->k_expect |= KBD_EXPECT_IDCODE;
|
||||
/* Fake an "all-up" to resync. translation. */
|
||||
c = KBD_IDLE;
|
||||
break;
|
||||
|
||||
case KBD_LAYOUT:
|
||||
k->k_expect |= KBD_EXPECT_LAYOUT;
|
||||
return;
|
||||
|
||||
case KBD_ERROR:
|
||||
log(LOG_WARNING, "%s: received error indicator\n",
|
||||
kbd->k_dev.dv_xname);
|
||||
return;
|
||||
|
||||
case KBD_IDLE:
|
||||
/* Let this go to the translator. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If /dev/kbd is not connected in event mode,
|
||||
* translate and send upstream (to console).
|
||||
*/
|
||||
if (!kbd->k_evmode) {
|
||||
|
||||
/* Any input stops auto-repeat (i.e. key release). */
|
||||
if (k->k_repeating) {
|
||||
k->k_repeating = 0;
|
||||
callout_stop(&k->k_repeat_ch);
|
||||
}
|
||||
|
||||
/* Translate this code to a keysym */
|
||||
keysym = kbd_code_to_keysym(ks, c);
|
||||
|
||||
/* Pass up to the next layer. */
|
||||
if (kbd_input_keysym(kbd, keysym)) {
|
||||
log(LOG_WARNING, "%s: code=0x%x with mod=0x%x"
|
||||
" produced unexpected keysym 0x%x\n",
|
||||
kbd->k_dev.dv_xname,
|
||||
c, ks->kbd_modbits, keysym);
|
||||
/* No point in auto-repeat here. */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Does this symbol get auto-repeat? */
|
||||
if (KEYSYM_NOREPEAT(keysym))
|
||||
return;
|
||||
|
||||
/* Setup for auto-repeat after initial delay. */
|
||||
k->k_repeating = 1;
|
||||
k->k_repeatsym = keysym;
|
||||
callout_reset(&k->k_repeat_ch, k->k_repeat_start,
|
||||
kbd_sun_repeat, k);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* IDLEs confuse the MIT X11R4 server badly, so we must drop them.
|
||||
* This is bad as it means the server will not automatically resync
|
||||
* on all-up IDLEs, but I did not drop them before, and the server
|
||||
* goes crazy when it comes time to blank the screen....
|
||||
*/
|
||||
if (c == KBD_IDLE)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Keyboard is generating events. Turn this keystroke into an
|
||||
* event and put it in the queue.
|
||||
*/
|
||||
kbd_input_event(kbd, c);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called by kbd_sun_input to handle keyboard's response to reset.
|
||||
* Called at spltty().
|
||||
*/
|
||||
static void
|
||||
kbd_sun_was_reset(k)
|
||||
struct kbd_sun_softc *k;
|
||||
{
|
||||
struct kbd_state *ks = &k->k_kbd.k_state;
|
||||
|
||||
/*
|
||||
* On first identification, wake up anyone waiting for type
|
||||
* and set up the table pointers.
|
||||
*/
|
||||
wakeup((caddr_t)&ks->kbd_id);
|
||||
|
||||
/* Restore keyclick, if necessary */
|
||||
switch (ks->kbd_id) {
|
||||
|
||||
case KB_SUN2:
|
||||
/* Type 2 keyboards don't support keyclick */
|
||||
break;
|
||||
|
||||
case KB_SUN3:
|
||||
/* Type 3 keyboards come up with keyclick on */
|
||||
if (!ks->kbd_click) {
|
||||
/* turn off the click */
|
||||
kbd_sun_output(k, KBD_CMD_NOCLICK);
|
||||
kbd_sun_start_tx(k);
|
||||
}
|
||||
break;
|
||||
|
||||
case KB_SUN4:
|
||||
/* Type 4 keyboards come up with keyclick off */
|
||||
if (ks->kbd_click) {
|
||||
/* turn on the click */
|
||||
kbd_sun_output(k, KBD_CMD_CLICK);
|
||||
kbd_sun_start_tx(k);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* LEDs are off after reset. */
|
||||
ks->kbd_leds = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called by kbd_sun_input to handle response to layout request.
|
||||
* Called at spltty().
|
||||
*/
|
||||
static void
|
||||
kbd_sun_new_layout(k)
|
||||
struct kbd_sun_softc *k;
|
||||
{
|
||||
struct kbd_state *ks = &k->k_kbd.k_state;
|
||||
|
||||
/*
|
||||
* On first identification, wake up anyone waiting for type
|
||||
* and set up the table pointers.
|
||||
*/
|
||||
wakeup((caddr_t)&ks->kbd_layout);
|
||||
|
||||
/* XXX: switch decoding tables? */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This is the autorepeat callout function.
|
||||
* Autorepeat is scheduled by kbd_sun_input.
|
||||
* Called at splsoftclock().
|
||||
*/
|
||||
static void
|
||||
kbd_sun_repeat(arg)
|
||||
void *arg;
|
||||
{
|
||||
struct kbd_sun_softc *k = (struct kbd_sun_softc *)arg;
|
||||
int s;
|
||||
|
||||
s = spltty();
|
||||
if (k->k_repeating && k->k_repeatsym >= 0) {
|
||||
|
||||
/* feed typematic keysym to the upper layer */
|
||||
(void)kbd_input_keysym(&k->k_kbd, k->k_repeatsym);
|
||||
|
||||
/* reschedule next repeat */
|
||||
callout_reset(&k->k_repeat_ch, k->k_repeat_step,
|
||||
kbd_sun_repeat, k);
|
||||
}
|
||||
splx(s);
|
||||
}
|
106
sys/dev/sun/kbdsunvar.h
Normal file
106
sys/dev/sun/kbdsunvar.h
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Keyboard driver - middle layer for sun keyboard off a serial line.
|
||||
* This code is used by kbd_zs and sunkbd drivers.
|
||||
*/
|
||||
|
||||
/*
|
||||
* How many input characters we can buffer.
|
||||
* The port-specific var.h may override this.
|
||||
* Note: must be a power of two!
|
||||
*/
|
||||
#define KBD_RX_RING_SIZE 256
|
||||
#define KBD_RX_RING_MASK (KBD_RX_RING_SIZE - 1)
|
||||
|
||||
/*
|
||||
* Output buffer. Only need a few chars.
|
||||
*/
|
||||
#define KBD_TX_RING_SIZE 16
|
||||
#define KBD_TX_RING_MASK (KBD_TX_RING_SIZE - 1)
|
||||
/*
|
||||
* Keyboard serial line speed defaults to 1200 bps.
|
||||
*/
|
||||
#define KBD_DEFAULT_BPS 1200
|
||||
#define KBD_RESET_TIMO 1000 /* mS. */
|
||||
|
||||
|
||||
struct kbd_sun_softc {
|
||||
/* upper layer (also inherits struct device) */
|
||||
struct kbd_softc k_kbd;
|
||||
|
||||
union {
|
||||
void *ku_priv;
|
||||
struct zs_chanstate *ku_cs;
|
||||
} k_u;
|
||||
#define k_priv k_u.ku_priv
|
||||
#define k_cs k_u.ku_cs
|
||||
|
||||
/*
|
||||
* The deviopen and deviclose routines are provided by the
|
||||
* underlying lower level driver and used as a back door when
|
||||
* opening and closing the internal device.
|
||||
*/
|
||||
int (*k_deviopen)(struct device *, int);
|
||||
int (*k_deviclose)(struct device *, int);
|
||||
|
||||
/*
|
||||
* Callback provided by the lower layer (actual device driver).
|
||||
* Middle layer uses it to send commands to sun keyboard.
|
||||
*/
|
||||
void (*k_write_data)(struct kbd_sun_softc *, int);
|
||||
|
||||
/* Was initialized once. */
|
||||
int k_isopen;
|
||||
|
||||
/*
|
||||
* Magic sequence stuff (Stop-A, aka L1-A).
|
||||
* XXX: convert to cnmagic(9).
|
||||
*/
|
||||
char k_magic1_down;
|
||||
u_char k_magic1; /* L1 */
|
||||
u_char k_magic2; /* A */
|
||||
|
||||
/* Autorepeat for sun keyboards is handled in software */
|
||||
int k_repeat_start; /* initial delay */
|
||||
int k_repeat_step; /* inter-char delay */
|
||||
int k_repeatsym; /* repeating symbol */
|
||||
int k_repeating; /* callout is active (use callout_active?) */
|
||||
struct callout k_repeat_ch;
|
||||
|
||||
/* Expecting ID or layout byte from keyboard */
|
||||
int k_expect;
|
||||
#define KBD_EXPECT_IDCODE 1
|
||||
#define KBD_EXPECT_LAYOUT 2
|
||||
|
||||
/* Flags to communicate with kbd_softint() */
|
||||
volatile int k_intr_flags;
|
||||
#define INTR_RX_OVERRUN 1
|
||||
#define INTR_TX_EMPTY 2
|
||||
#define INTR_ST_CHECK 4
|
||||
|
||||
/* Transmit state */
|
||||
volatile int k_txflags;
|
||||
#define K_TXBUSY 1
|
||||
#define K_TXWANT 2
|
||||
|
||||
/*
|
||||
* The transmit ring buffer.
|
||||
*/
|
||||
volatile u_int k_tbget; /* transmit buffer `get' index */
|
||||
volatile u_int k_tbput; /* transmit buffer `put' index */
|
||||
u_char k_tbuf[KBD_TX_RING_SIZE]; /* data */
|
||||
|
||||
/*
|
||||
* The receive ring buffer.
|
||||
*/
|
||||
u_int k_rbget; /* ring buffer `get' index */
|
||||
volatile u_int k_rbput; /* ring buffer `put' index */
|
||||
u_short k_rbuf[KBD_RX_RING_SIZE]; /* rr1, data pairs */
|
||||
};
|
||||
|
||||
/* Middle layer methods exported to the upper layer. */
|
||||
extern struct kbd_ops kbd_ops_sun;
|
||||
|
||||
/* Methods for lower layer to call. */
|
||||
extern void kbd_sun_input(struct kbd_sun_softc *k, int);
|
||||
extern void kbd_sun_output(struct kbd_sun_softc *k, int c);
|
||||
extern void kbd_sun_start_tx(struct kbd_sun_softc *k);
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kbdvar.h,v 1.8 2001/12/09 12:03:32 pk Exp $ */
|
||||
/* $NetBSD: kbdvar.h,v 1.9 2002/10/03 16:13:26 uwe Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -44,141 +44,69 @@
|
||||
* @(#)kbd.c 8.2 (Berkeley) 10/30/93
|
||||
*/
|
||||
|
||||
#include <sys/callout.h>
|
||||
|
||||
/*
|
||||
* How many input characters we can buffer.
|
||||
* The port-specific var.h may override this.
|
||||
* Note: must be a power of two!
|
||||
*/
|
||||
#define KBD_RX_RING_SIZE 256
|
||||
#define KBD_RX_RING_MASK (KBD_RX_RING_SIZE-1)
|
||||
/*
|
||||
* Output buffer. Only need a few chars.
|
||||
*/
|
||||
#define KBD_TX_RING_SIZE 16
|
||||
#define KBD_TX_RING_MASK (KBD_TX_RING_SIZE-1)
|
||||
/*
|
||||
* Keyboard serial line speed defaults to 1200 bps.
|
||||
*/
|
||||
#define KBD_DEFAULT_BPS 1200
|
||||
#define KBD_RESET_TIMO 1000 /* mS. */
|
||||
|
||||
/*
|
||||
* XXX - Historical comment - no longer quite right...
|
||||
* Keyboard driver state. The ascii and kbd links go up and down and
|
||||
* we just sit in the middle doing translation. Note that it is possible
|
||||
* to get just one of the two links, in which case /dev/kbd is unavailable.
|
||||
* The downlink supplies us with `internal' open and close routines which
|
||||
* will enable dataflow across the downlink. We promise to call open when
|
||||
* we are willing to take keystrokes, and to call close when we are not.
|
||||
* If /dev/kbd is not the console tty input source, we do this whenever
|
||||
* /dev/kbd is in use; otherwise we just leave it open forever.
|
||||
*/
|
||||
struct zs_chanstate;
|
||||
struct ucom_softc;
|
||||
|
||||
struct kbd_softc {
|
||||
struct device k_dev; /* required first: base device */
|
||||
struct device k_dev; /* required first: base device */
|
||||
|
||||
/* Stuff our parent setup */
|
||||
union {
|
||||
struct zs_chanstate *ku_cs;
|
||||
struct ucom_softc *ku_usc;
|
||||
void *ku_priv;
|
||||
} k_u;
|
||||
#define k_cs k_u.ku_cs
|
||||
#define k_usc k_u.ku_usc
|
||||
#define k_priv k_u.ku_priv
|
||||
/* middle layer methods */
|
||||
struct kbd_ops *k_ops;
|
||||
|
||||
/*
|
||||
* The deviopen and deviclose routines are provided
|
||||
* by the lower level driver and used as a back door
|
||||
* when opening and closing the internal device.
|
||||
*/
|
||||
int (*k_deviopen) __P((struct device *, int));
|
||||
int (*k_deviclose) __P((struct device *, int));
|
||||
void (*k_write_data) __P((struct kbd_softc *, int));
|
||||
/* state of the upper layer */
|
||||
int k_evmode; /* set if we should produce events */
|
||||
struct evvar k_events; /* event queue state */
|
||||
|
||||
/* Flags to communicate with kbd_softint() */
|
||||
volatile int k_intr_flags;
|
||||
#define INTR_RX_OVERRUN 1
|
||||
#define INTR_TX_EMPTY 2
|
||||
#define INTR_ST_CHECK 4
|
||||
|
||||
/* Transmit state */
|
||||
volatile int k_txflags;
|
||||
#define K_TXBUSY 1
|
||||
#define K_TXWANT 2
|
||||
|
||||
/*
|
||||
* State of upper interface.
|
||||
*/
|
||||
int k_isopen; /* set if open has been done */
|
||||
int k_evmode; /* set if we should produce events */
|
||||
struct evvar k_events; /* event queue state */
|
||||
|
||||
/*
|
||||
* ACSI translation state
|
||||
*/
|
||||
int k_repeat_start; /* initial delay */
|
||||
int k_repeat_step; /* inter-char delay */
|
||||
int k_repeatsym; /* repeating symbol */
|
||||
int k_repeating; /* we've called timeout() */
|
||||
struct kbd_state k_state; /* ASCII translation state */
|
||||
|
||||
struct callout k_repeat_ch;
|
||||
/* ACSII translation state */
|
||||
struct kbd_state k_state;
|
||||
|
||||
/* Console hooks */
|
||||
char k_isconsole;
|
||||
int k_isconsole;
|
||||
struct cons_channel *k_cc;
|
||||
|
||||
/*
|
||||
* Magic sequence stuff (L1-A)
|
||||
*/
|
||||
char k_magic1_down;
|
||||
u_char k_magic1; /* L1 */
|
||||
u_char k_magic2; /* A */
|
||||
|
||||
/*
|
||||
* The transmit ring buffer.
|
||||
*/
|
||||
volatile u_int k_tbget; /* transmit buffer `get' index */
|
||||
volatile u_int k_tbput; /* transmit buffer `put' index */
|
||||
u_char k_tbuf[KBD_TX_RING_SIZE]; /* data */
|
||||
|
||||
/*
|
||||
* The receive ring buffer.
|
||||
*/
|
||||
u_int k_rbget; /* ring buffer `get' index */
|
||||
volatile u_int k_rbput; /* ring buffer `put' index */
|
||||
u_short k_rbuf[KBD_RX_RING_SIZE]; /* rr1, data pairs */
|
||||
|
||||
};
|
||||
|
||||
/* functions used between backend/frontend keyboard drivers */
|
||||
void kbd_input_raw __P((struct kbd_softc *k, int));
|
||||
void kbd_output(struct kbd_softc *k, int c);
|
||||
void kbd_start_tx(struct kbd_softc *k);
|
||||
int kbd_cc_open __P((struct cons_channel *));
|
||||
int kbd_cc_close __P((struct cons_channel *));
|
||||
/*
|
||||
* Downcalls to the middle layer.
|
||||
* NB: iocsled has user context to care about,
|
||||
* setleds can be called from interrupt handler.
|
||||
*/
|
||||
struct kbd_ops {
|
||||
int (*open)(struct kbd_softc *);
|
||||
int (*close)(struct kbd_softc *);
|
||||
int (*docmd)(struct kbd_softc *, int, int); /* KIOCCMD */
|
||||
int (*setleds)(struct kbd_softc *, int, int); /* KIOCSLED */
|
||||
};
|
||||
|
||||
|
||||
/* Callbacks for middle layer to feed us keyboard input */
|
||||
extern int kbd_input_keysym(struct kbd_softc *, int); /* console */
|
||||
extern void kbd_input_event(struct kbd_softc *, int); /* events */
|
||||
|
||||
|
||||
/*
|
||||
* kbd console input channel interface.
|
||||
* XXX - does not belong in this header; but for now, kbd is the only user..
|
||||
*/
|
||||
struct cons_channel {
|
||||
/* Provided by lower driver */
|
||||
void *cc_dev; /* Lower device private data */
|
||||
struct callout cc_callout;
|
||||
int (*cc_iopen) /* Open lower device */
|
||||
__P((struct cons_channel *));
|
||||
int (*cc_iclose) /* Close lower device */
|
||||
__P((struct cons_channel *));
|
||||
/* XXX: only used by PROM console, probably belongs to kd.c */
|
||||
struct callout cc_callout;
|
||||
|
||||
/* Provided by upper driver */
|
||||
void (*cc_upstream)__P((int)); /* Send a character upstream */
|
||||
/*
|
||||
* Callbacks provided by underlying device (e.g. keyboard driver).
|
||||
* Console driver will call these before console is opened/closed.
|
||||
*/
|
||||
void *cc_dev; /* underlying device private data */
|
||||
int (*cc_iopen)(struct cons_channel *); /* open underlying device */
|
||||
int (*cc_iclose)(struct cons_channel *); /* close underlying device */
|
||||
|
||||
/*
|
||||
* Callback provided by the console driver. Underlying driver
|
||||
* calls it to pass input character up as console input.
|
||||
*/
|
||||
void (*cc_upstream)(int);
|
||||
};
|
||||
|
||||
/* upper layer callbacks that lower layer passes to console driver */
|
||||
extern int kbd_cc_open(struct cons_channel *);
|
||||
extern int kbd_cc_close(struct cons_channel *);
|
||||
|
||||
/* Special hook to attach the keyboard driver to the console */
|
||||
void cons_attach_input __P((struct cons_channel *, struct consdev *));
|
||||
struct consdev;
|
||||
extern void cons_attach_input(struct cons_channel *, struct consdev *);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sunkbd.c,v 1.12 2002/10/02 16:52:59 thorpej Exp $ */
|
||||
/* $NetBSD: sunkbd.c,v 1.13 2002/10/03 16:13:26 uwe Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -45,9 +45,8 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Keyboard driver (/dev/kbd -- note that we do not have minor numbers
|
||||
* [yet?]). Translates incoming bytes to ASCII or to `firm_events' and
|
||||
* passes them up to the appropriate reader.
|
||||
* /dev/kbd lower layer for sun keyboard off a tty (line discipline).
|
||||
* This driver uses kbdsun middle layer to hook up to /dev/kbd.
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -56,7 +55,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sunkbd.c,v 1.12 2002/10/02 16:52:59 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sunkbd.c,v 1.13 2002/10/03 16:13:26 uwe Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -79,6 +78,7 @@ __KERNEL_RCSID(0, "$NetBSD: sunkbd.c,v 1.12 2002/10/02 16:52:59 thorpej Exp $");
|
||||
#include <dev/sun/event_var.h>
|
||||
#include <dev/sun/kbd_xlate.h>
|
||||
#include <dev/sun/kbdvar.h>
|
||||
#include <dev/sun/kbdsunvar.h>
|
||||
#include <dev/sun/kbd_ms_ttyvar.h>
|
||||
|
||||
#include "kbd.h"
|
||||
@ -90,7 +90,7 @@ __KERNEL_RCSID(0, "$NetBSD: sunkbd.c,v 1.12 2002/10/02 16:52:59 thorpej Exp $");
|
||||
|
||||
static int sunkbd_match(struct device *, struct cfdata *, void *);
|
||||
static void sunkbd_attach(struct device *, struct device *, void *);
|
||||
static void sunkbd_write_data(struct kbd_softc *, int);
|
||||
static void sunkbd_write_data(struct kbd_sun_softc *, int);
|
||||
static int sunkbdiopen(struct device *, int mode);
|
||||
|
||||
int sunkbdinput(int, struct tty *);
|
||||
@ -99,7 +99,7 @@ int sunkbdstart(struct tty *);
|
||||
/* Default keyboard baud rate */
|
||||
int sunkbd_bps = KBD_DEFAULT_BPS;
|
||||
|
||||
CFATTACH_DECL(kbd, sizeof(struct kbd_softc),
|
||||
CFATTACH_DECL(kbd_tty, sizeof(struct kbd_sun_softc),
|
||||
sunkbd_match, sunkbd_attach, NULL, NULL);
|
||||
|
||||
struct linesw sunkbd_disc =
|
||||
@ -127,14 +127,11 @@ void
|
||||
sunkbd_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
|
||||
{
|
||||
struct kbd_softc *k = (void *) self;
|
||||
struct kbd_sun_softc *k = (void *) self;
|
||||
struct kbd_ms_tty_attach_args *args = aux;
|
||||
struct cfdata *cf;
|
||||
struct tty *tp = args->kmta_tp;
|
||||
struct cons_channel *cc;
|
||||
int kbd_unit;
|
||||
|
||||
/* Set up the proper line discipline. */
|
||||
ttyldisc_init();
|
||||
@ -148,9 +145,10 @@ sunkbd_attach(parent, self, aux)
|
||||
k->k_priv = tp;
|
||||
tp->t_sc = (void *)k;
|
||||
|
||||
cf = k->k_dev.dv_cfdata;
|
||||
kbd_unit = k->k_dev.dv_unit;
|
||||
/* provide upper layer with a link to the middle layer */
|
||||
k->k_kbd.k_ops = &kbd_ops_sun;
|
||||
|
||||
/* provide middle layer with a link to the lower layer (i.e. us) */
|
||||
k->k_deviopen = sunkbdiopen;
|
||||
k->k_deviclose = NULL;
|
||||
k->k_write_data = sunkbd_write_data;
|
||||
@ -174,7 +172,7 @@ sunkbd_attach(parent, self, aux)
|
||||
|
||||
/* Tell our parent what the console should be. */
|
||||
args->kmta_consdev = cn_tab;
|
||||
k->k_isconsole = 1;
|
||||
k->k_kbd.k_isconsole = 1;
|
||||
printf(" (console input)");
|
||||
|
||||
/* Set magic to "L1-A" */
|
||||
@ -187,14 +185,14 @@ sunkbd_attach(parent, self, aux)
|
||||
|
||||
kd_attach_input(cc);
|
||||
}
|
||||
k->k_cc = cc;
|
||||
k->k_kbd.k_cc = cc;
|
||||
|
||||
printf("\n");
|
||||
|
||||
callout_init(&k->k_repeat_ch);
|
||||
|
||||
/* Do this before any calls to kbd_rint(). */
|
||||
kbd_xlate_init(&k->k_state);
|
||||
kbd_xlate_init(&k->k_kbd.k_state);
|
||||
|
||||
/* XXX - Do this in open? */
|
||||
k->k_repeat_start = hz/2;
|
||||
@ -215,7 +213,7 @@ sunkbdiopen(dev, flags)
|
||||
struct device *dev;
|
||||
int flags;
|
||||
{
|
||||
struct kbd_softc *k = (void *) dev;
|
||||
struct kbd_sun_softc *k = (void *) dev;
|
||||
struct tty *tp = (struct tty *)k->k_priv;
|
||||
struct proc *p = curproc;
|
||||
struct termios t;
|
||||
@ -252,7 +250,7 @@ sunkbdinput(c, tp)
|
||||
int c;
|
||||
struct tty *tp;
|
||||
{
|
||||
struct kbd_softc *k = (void *) tp->t_sc;
|
||||
struct kbd_sun_softc *k = (void *) tp->t_sc;
|
||||
u_char *cc;
|
||||
int error;
|
||||
|
||||
@ -268,7 +266,7 @@ sunkbdinput(c, tp)
|
||||
* send a reset to resync key translation.
|
||||
*/
|
||||
log(LOG_ERR, "%s: input error (0x%x)\n",
|
||||
k->k_dev.dv_xname, c);
|
||||
k->k_kbd.k_dev.dv_xname, c);
|
||||
c &= TTY_CHARMASK;
|
||||
if (!k->k_txflags & K_TXBUSY) {
|
||||
ttyflush(tp, FREAD | FWRITE);
|
||||
@ -281,17 +279,17 @@ sunkbdinput(c, tp)
|
||||
*/
|
||||
if (tp->t_rawq.c_cc + tp->t_canq.c_cc >= TTYHOG) {
|
||||
log(LOG_ERR, "%s: input overrun\n",
|
||||
k->k_dev.dv_xname);
|
||||
k->k_kbd.k_dev.dv_xname);
|
||||
goto send_reset;
|
||||
}
|
||||
|
||||
/* Pass this up to the "middle" layer. */
|
||||
kbd_input_raw(k, c);
|
||||
kbd_sun_input(k, c);
|
||||
return (-1);
|
||||
|
||||
send_reset:
|
||||
/* Send a reset to resync translation. */
|
||||
kbd_output(k, KBD_CMD_RESET);
|
||||
kbd_sun_output(k, KBD_CMD_RESET);
|
||||
return (ttstart(tp));
|
||||
|
||||
}
|
||||
@ -300,23 +298,23 @@ int
|
||||
sunkbdstart(tp)
|
||||
struct tty *tp;
|
||||
{
|
||||
struct kbd_softc *k = (void *) tp->t_sc;
|
||||
struct kbd_sun_softc *k = (void *) tp->t_sc;
|
||||
|
||||
/*
|
||||
* Transmit done. Try to send more, or
|
||||
* clear busy and wakeup drain waiters.
|
||||
*/
|
||||
k->k_txflags &= ~K_TXBUSY;
|
||||
kbd_start_tx(k);
|
||||
kbd_sun_start_tx(k);
|
||||
ttstart(tp);
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* used by kbd_start_tx();
|
||||
* used by kbd_sun_start_tx();
|
||||
*/
|
||||
void
|
||||
sunkbd_write_data(k, c)
|
||||
struct kbd_softc *k;
|
||||
struct kbd_sun_softc *k;
|
||||
int c;
|
||||
{
|
||||
struct tty *tp = (struct tty *)k->k_priv;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sunms.c,v 1.11 2002/10/02 16:53:00 thorpej Exp $ */
|
||||
/* $NetBSD: sunms.c,v 1.12 2002/10/03 16:13:26 uwe Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -56,7 +56,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sunms.c,v 1.11 2002/10/02 16:53:00 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sunms.c,v 1.12 2002/10/03 16:13:26 uwe Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -94,7 +94,7 @@ static void sunms_attach(struct device *, struct device *, void *);
|
||||
static int sunmsiopen(struct device *, int mode);
|
||||
int sunmsinput(int, struct tty *);
|
||||
|
||||
CFATTACH_DECL(ms, sizeof(struct ms_softc),
|
||||
CFATTACH_DECL(ms_tty, sizeof(struct ms_softc),
|
||||
sunms_match, sunms_attach, NULL, NULL);
|
||||
|
||||
struct linesw sunms_disc =
|
||||
|
Loading…
Reference in New Issue
Block a user