From 754d79402b3097e54339cc9764780246d5e6acb5 Mon Sep 17 00:00:00 2001 From: macallan Date: Thu, 30 Jun 2005 12:07:51 +0000 Subject: [PATCH] Allow sparc64-style attachment of mouse and keyboard via zstty, needed for wscons support. Reviewed by uwe. --- sys/arch/sparc/conf/files.sparc | 11 ++++--- sys/arch/sparc/conf/majors.sparc | 4 +-- sys/arch/sparc/dev/kd.c | 8 ++--- sys/arch/sparc/dev/zs.c | 54 ++++++++++++++++++++++++++++++-- sys/dev/ic/z8530tty.c | 20 ++++++++++-- 5 files changed, 81 insertions(+), 16 deletions(-) diff --git a/sys/arch/sparc/conf/files.sparc b/sys/arch/sparc/conf/files.sparc index a59d50e006ff..c88d216e375d 100644 --- a/sys/arch/sparc/conf/files.sparc +++ b/sys/arch/sparc/conf/files.sparc @@ -1,4 +1,4 @@ -# $NetBSD: files.sparc,v 1.130 2004/09/14 16:51:58 jdolecek Exp $ +# $NetBSD: files.sparc,v 1.131 2005/06/30 12:07:51 macallan Exp $ # @(#)files.sparc 8.1 (Berkeley) 7/19/93 # sparc-specific configuration info @@ -174,8 +174,9 @@ file dev/sun/kbd_zs.c kbd_zs # kbd lower layer # sun keyboard at a tty line discipline # only used by sparc64, but we can test-compile it here -#attach kbd at zstty with kbd_tty -#file dev/sun/sunkbd.c kbd_tty # kbd lower layer +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 @@ -191,8 +192,8 @@ 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 -#attach ms at zstty with ms_tty -#file dev/sun/sunms.c ms_tty # mouse lower layer +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? diff --git a/sys/arch/sparc/conf/majors.sparc b/sys/arch/sparc/conf/majors.sparc index 0ff1ed34f260..f6bca9b13b45 100644 --- a/sys/arch/sparc/conf/majors.sparc +++ b/sys/arch/sparc/conf/majors.sparc @@ -1,4 +1,4 @@ -# $NetBSD: majors.sparc,v 1.21 2005/06/03 13:15:04 blymn Exp $ +# $NetBSD: majors.sparc,v 1.22 2005/06/30 12:07:51 macallan Exp $ # # Device majors for sparc # @@ -16,7 +16,7 @@ device-major swap char 7 block 4 device-major xy char 9 block 3 xy device-major zstty char 12 zstty -device-major ms char 13 ms +device-major ms char 13 ms | sunms device-major log char 16 device-major sd char 17 block 7 sd diff --git a/sys/arch/sparc/dev/kd.c b/sys/arch/sparc/dev/kd.c index f6af94f84bec..6db696b9d102 100644 --- a/sys/arch/sparc/dev/kd.c +++ b/sys/arch/sparc/dev/kd.c @@ -1,4 +1,4 @@ -/* $NetBSD: kd.c,v 1.33 2005/06/03 22:17:18 martin Exp $ */ +/* $NetBSD: kd.c,v 1.34 2005/06/30 12:07:51 macallan Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -46,7 +46,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kd.c,v 1.33 2005/06/03 22:17:18 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kd.c,v 1.34 2005/06/30 12:07:51 macallan Exp $"); #include "opt_kgdb.h" #include "fb.h" @@ -553,7 +553,7 @@ char prom_stdout_args[16]; extern void prom_cnprobe(struct consdev *); static void prom_cninit(struct consdev *); -static int prom_cngetc(dev_t); +int prom_cngetc(dev_t); static void prom_cnputc(dev_t, int); extern void prom_cnpollc(dev_t, int); @@ -609,7 +609,7 @@ prom_cnpollc(dev, on) /* * PROM console input putchar. */ -static int +int prom_cngetc(dev) dev_t dev; { diff --git a/sys/arch/sparc/dev/zs.c b/sys/arch/sparc/dev/zs.c index 5fac572e42bf..1fa85b15afb1 100644 --- a/sys/arch/sparc/dev/zs.c +++ b/sys/arch/sparc/dev/zs.c @@ -1,4 +1,4 @@ -/* $NetBSD: zs.c,v 1.101 2004/04/03 17:43:50 chs Exp $ */ +/* $NetBSD: zs.c,v 1.102 2005/06/30 12:07:51 macallan Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -45,7 +45,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.101 2004/04/03 17:43:50 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.102 2005/06/30 12:07:51 macallan Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -77,6 +77,10 @@ __KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.101 2004/04/03 17:43:50 chs Exp $"); #include #include #include +#include + +#include "kbd.h" +#include "ms.h" /* * Some warts needed by z8530tty.c - @@ -190,6 +194,9 @@ int zs_enable __P((struct zs_chanstate *)); void zs_disable __P((struct zs_chanstate *)); +/* XXX from dev/ic/z8530tty.c */ +extern struct tty *zstty_get_tty_from_dev(struct device *); + /* * Is the zs chip present? */ @@ -434,6 +441,7 @@ zs_attach(zsc, zsd, pri) */ for (channel = 0; channel < 2; channel++) { struct zschan *zc; + struct device *child; zsc_args.channel = channel; cs = &zsc->zsc_cs_store[channel]; @@ -493,7 +501,9 @@ zs_attach(zsc, zsd, pri) * Look for a child driver for this channel. * The child attach will setup the hardware. */ - if (!config_found(&zsc->zsc_dev, (void *)&zsc_args, zs_print)) { + + child = config_found(&zsc->zsc_dev, &zsc_args, zs_print); + if (child == NULL) { /* No sub-driver. Just reset it. */ u_char reset = (channel == 0) ? ZSWR9_A_RESET : ZSWR9_B_RESET; @@ -501,6 +511,37 @@ zs_attach(zsc, zsd, pri) zs_write_reg(cs, 9, reset); splx(s); } +#if (NKBD > 0) || (NMS > 0) + /* + * If this was a zstty it has a keyboard + * property on it we need to attach the + * sunkbd and sunms line disciplines. + */ + if ((child != NULL) + && (strcmp(child->dv_cfdata->cf_name, "zstty") == 0) + && (prom_getproplen(zsc->zsc_node, "keyboard") == 0)) + { + struct kbd_ms_tty_attach_args kma; + struct tty *tp = zstty_get_tty_from_dev(child); + kma.kmta_tp = tp; + kma.kmta_dev = tp->t_dev; + kma.kmta_consdev = zsc_args.consdev; + + /* Attach 'em if we got 'em. */ +#if (NKBD > 0) + if (channel == 0) { + kma.kmta_name = "keyboard"; + config_found(child, &kma, NULL); + } +#endif +#if (NMS > 0) + if (channel == 1) { + kma.kmta_name = "mouse"; + config_found(child, &kma, NULL); + } +#endif + } +#endif } /* @@ -543,6 +584,7 @@ zs_attach(zsc, zsd, pri) (void)splfd(); /* XXX: splzs - 1 */ } #endif + } static int @@ -1033,3 +1075,9 @@ zs_disable(cs) auxiotwoserialendis (ZS_DISABLE); cs->enabled = 0; } + + + + + + diff --git a/sys/dev/ic/z8530tty.c b/sys/dev/ic/z8530tty.c index 3e5135b25ef9..2f50dd11e26e 100644 --- a/sys/dev/ic/z8530tty.c +++ b/sys/dev/ic/z8530tty.c @@ -1,4 +1,4 @@ -/* $NetBSD: z8530tty.c,v 1.98 2005/05/31 00:45:52 christos Exp $ */ +/* $NetBSD: z8530tty.c,v 1.99 2005/06/30 12:07:51 macallan Exp $ */ /*- * Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998, 1999 @@ -137,7 +137,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.98 2005/05/31 00:45:52 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.99 2005/06/30 12:07:51 macallan Exp $"); #include "opt_kgdb.h" #include "opt_ntp.h" @@ -291,6 +291,22 @@ static void zstty_softint(struct zs_chanstate *); #define ZSUNIT(x) (minor(x) & 0x7ffff) #define ZSDIALOUT(x) (minor(x) & 0x80000) +struct tty *zstty_get_tty_from_dev(struct device *); + +/* + * XXX get the (struct tty *) out of a (struct device *) we trust to be a + * (struct zstty_softc *) - needed by sparc/dev/zs.c, sparc64/dev/zs.c, + * sun3/dev/zs.c and sun2/dev/zs.c will probably need it at some point + */ + +struct tty * +zstty_get_tty_from_dev(struct device *dev) +{ + struct zstty_softc *sc = (struct zstty_softc *)dev; + + return sc->zst_tty; +} + /* * zstty_match: how is this zs channel configured? */