Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/wscons Eliminate the need for needs-count for wsmux....
details: https://anonhg.NetBSD.org/src/rev/30af3e344f2d
branches: trunk
changeset: 475068:30af3e344f2d
user: augustss <augustss%NetBSD.org@localhost>
date: Fri Jul 30 20:52:27 1999 +0000
description:
Eliminate the need for needs-count for wsmux. This should make
wsdisplays work properly again.
diffstat:
sys/dev/wscons/files.wscons | 7 +-
sys/dev/wscons/wskbd.c | 8 +-
sys/dev/wscons/wsmux.c | 483 ++++++++++++++++++++++---------------------
3 files changed, 258 insertions(+), 240 deletions(-)
diffs (truncated from 641 to 300 lines):
diff -r 1da77a8240ac -r 30af3e344f2d sys/dev/wscons/files.wscons
--- a/sys/dev/wscons/files.wscons Fri Jul 30 20:46:10 1999 +0000
+++ b/sys/dev/wscons/files.wscons Fri Jul 30 20:52:27 1999 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.wscons,v 1.17 1999/07/30 20:42:16 thorpej Exp $
+# $NetBSD: files.wscons,v 1.18 1999/07/30 20:52:27 augustss Exp $
#
# "Workstation Console" glue; attaches frame buffer to emulator & keyboard,
@@ -53,8 +53,5 @@
file dev/wscons/wscons_rinit.c wsrasteremulops
file dev/wscons/wscons_rops.c wsrasteremulops
-# XXX XXX XXX COMPLETELY, UTTERLY BROKEN!!! XXX XXX XXX
-# XXX XXX XXX wsdisplay needs wsmux to work but there is Lossage
-# XXX XXX XXX if you use "wsmux | wsdisplay" below.
defpseudo wsmux
-file dev/wscons/wsmux.c wsmux needs-count
+file dev/wscons/wsmux.c wsmux | wsdisplay needs-flag
diff -r 1da77a8240ac -r 30af3e344f2d sys/dev/wscons/wskbd.c
--- a/sys/dev/wscons/wskbd.c Fri Jul 30 20:46:10 1999 +0000
+++ b/sys/dev/wscons/wskbd.c Fri Jul 30 20:52:27 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wskbd.c,v 1.27 1999/07/29 18:20:03 augustss Exp $ */
+/* $NetBSD: wskbd.c,v 1.28 1999/07/30 20:52:28 augustss Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@@ -36,7 +36,7 @@
static const char _copyright[] __attribute__ ((unused)) =
"Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.";
static const char _rcsid[] __attribute__ ((unused)) =
- "$NetBSD: wskbd.c,v 1.27 1999/07/29 18:20:03 augustss Exp $";
+ "$NetBSD: wskbd.c,v 1.28 1999/07/30 20:52:28 augustss Exp $";
/*
* Copyright (c) 1992, 1993
@@ -391,7 +391,7 @@
}
printf("\n");
-#if NWSMUX > 0 || NWSDISPLAY > 0
+#if NWSMUX > 0
if (mux != WSKBDDEVCF_MUX_DEFAULT)
wsmux_attach(mux, WSMUX_KBD, &sc->sc_dv, &sc->sc_events,
&sc->sc_mux, &wskbd_muxops);
@@ -470,7 +470,7 @@
struct wseventvar *evar;
int maj, mn;
int s;
-#if NWSMUX > 0 || NWSDISPLAY > 0
+#if NWSMUX > 0
int mux;
mux = sc->sc_dv.dv_cfdata->wskbddevcf_mux;
diff -r 1da77a8240ac -r 30af3e344f2d sys/dev/wscons/wsmux.c
--- a/sys/dev/wscons/wsmux.c Fri Jul 30 20:46:10 1999 +0000
+++ b/sys/dev/wscons/wsmux.c Fri Jul 30 20:52:27 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsmux.c,v 1.1 1999/07/29 18:20:03 augustss Exp $ */
+/* $NetBSD: wsmux.c,v 1.2 1999/07/30 20:52:28 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -88,13 +88,11 @@
struct wsmuxops *sc_ops;
};
-cdev_decl(wsmux);
-
int wsmuxdoclose __P((struct device *, int, int, struct proc *));
int wsmux_set_display __P((struct device *, struct wsmux_softc *));
-int nwsmux = NWSMUX;
-struct wsmux_softc *wsmuxdevs[NWSMUX];
+#if NWSMUX > 0
+cdev_decl(wsmux);
void wsmuxattach __P((int));
@@ -103,6 +101,34 @@
wsmux_set_display
};
+void wsmux_setmax __P((int n));
+
+int nwsmux = 0;
+struct wsmux_softc **wsmuxdevs;
+
+void
+wsmux_setmax(n)
+ int n;
+{
+ int i;
+
+ if (n >= nwsmux) {
+ i = nwsmux;
+ nwsmux = n + 1;
+ if (nwsmux != 0)
+ wsmuxdevs = realloc(wsmuxdevs,
+ nwsmux * sizeof (*wsmuxdevs),
+ M_DEVBUF, M_NOWAIT);
+ else
+ wsmuxdevs = malloc(nwsmux * sizeof (*wsmuxdevs),
+ M_DEVBUF, M_NOWAIT);
+ if (wsmuxdevs == 0)
+ panic("wsmux_setmax: no memory\n");
+ for (; i < nwsmux; i++)
+ wsmuxdevs[i] = 0;
+ }
+}
+
/* From upper level */
void
wsmuxattach(n)
@@ -110,14 +136,7 @@
{
int i;
-#if 0
-/* Called too late. We use static allocation instead. */
- nwsmux = n;
- wsmuxdevs = malloc(n * sizeof (struct wsmux_softc *),
- M_DEVBUF, M_NOWAIT);
- if (wsmuxdevs == 0)
- panic("wsmuxattach: out of memory\n");
-#endif
+ wsmux_setmax(n); /* Make sure we have room for all muxes. */
/* Make sure all muxes are there. */
for (i = 0; i < nwsmux; i++)
@@ -125,25 +144,6 @@
wsmuxdevs[i] = wsmux_create("wsmux", i);
}
-struct wsmux_softc *
-wsmux_create(name, unit)
- const char *name;
- int unit;
-{
- struct wsmux_softc *sc;
-
- DPRINTF(("wsmux_create: allocating\n"));
- sc = malloc(sizeof *sc, M_DEVBUF, M_NOWAIT);
- if (!sc)
- return (0);
- memset(sc, 0, sizeof *sc);
- LIST_INIT(&sc->sc_reals);
- snprintf(sc->sc_dv.dv_xname, sizeof sc->sc_dv.dv_xname,
- "%s%d", name, unit);
- sc->sc_dv.dv_unit = unit;
- return (sc);
-}
-
/* From mouse or keyboard. */
void
wsmux_attach(n, type, dsc, ev, psp, ops)
@@ -157,12 +157,8 @@
struct wsmux_softc *sc;
int error;
- DPRINTF(("wsmux_attach\n"));
- if (n >= nwsmux || n < 0) {
- printf("wsmux: attach device %d is out of range (%d..%d)\n",
- n, 0, nwsmux-1);
- return;
- }
+ DPRINTF(("wsmux_attach: n=%d\n", n));
+ wsmux_setmax(n);
sc = wsmuxdevs[n];
if (sc == 0) {
sc = wsmux_create("wsmux", n);
@@ -177,73 +173,6 @@
printf("wsmux_attach: error=%d\n", error);
}
-int
-wsmux_attach_sc(sc, type, dsc, ev, psp, ops)
- struct wsmux_softc *sc;
- int type;
- struct device *dsc;
- struct wseventvar *ev;
- struct wsmux_softc **psp;
- struct wsmuxops *ops;
-{
- struct wsplink *m;
- int error;
-
- DPRINTF(("wsmux_attach_sc: %s: type=%d dsc=%p, *psp=%p\n",
- sc->sc_dv.dv_xname, type, dsc, *psp));
- m = malloc(sizeof *m, M_DEVBUF, M_NOWAIT);
- if (m == 0)
- return (ENOMEM);
- m->type = type;
- m->mux = sc;
- m->sc = dsc;
- m->sc_mevents = ev;
- m->sc_muxp = psp;
- m->sc_ops = ops;
- LIST_INSERT_HEAD(&sc->sc_reals, m, next);
-
- if (sc->sc_displaydv) {
- /* This is a display mux, so attach the new device to it. */
- DPRINTF(("wsmux_attach_sc: %s: set display %p\n",
- sc->sc_dv.dv_xname, sc->sc_displaydv));
- error = 0;
- if (m->sc_ops->dsetdisplay) {
- error = m->sc_ops->dsetdisplay(m->sc, sc);
- /* Ignore that the console already has a display. */
- if (error == EBUSY)
- error = 0;
- if (!error) {
- *m->sc_muxp = sc;
-#ifdef WSDISPLAY_COMPAT_RAWKBD
- DPRINTF(("wsmux_attach_sc: on %s set rawkbd=%d\n",
- m->sc->dv_xname, sc->sc_rawkbd));
- (void)m->sc_ops->dioctl(m->sc,
- WSKBDIO_SETMODE,
- (caddr_t)&sc->sc_rawkbd,
- 0, 0);
-#endif
- }
- }
- } else if (sc->sc_events.io) {
- /* Mux is open, so open the new subdevice */
- DPRINTF(("wsmux_attach_sc: %s: calling open of %s\n",
- sc->sc_dv.dv_xname, m->sc->dv_xname));
- /* mux already open, join in */
- error = m->sc_ops->dopen(makedev(0, m->sc->dv_unit),
- sc->sc_flags, sc->sc_mode, sc->sc_p);
- if (!error)
- *m->sc_muxp = sc;
- } else {
- DPRINTF(("wsmux_attach_sc: %s not open\n",
- sc->sc_dv.dv_xname));
- error = 0;
- }
- DPRINTF(("wsmux_attach_sc: done sc=%p psp=%p *psp=%p\n",
- sc, psp, *psp));
-
- return (error);
-}
-
/* From mouse or keyboard. */
void
wsmux_detach(n, dsc)
@@ -265,52 +194,6 @@
}
int
-wsmux_detach_sc(sc, dsc)
- struct wsmux_softc *sc;
- struct device *dsc;
-{
- struct wsplink *m;
- int error;
-
- DPRINTF(("wsmux_detach_sc: %s: dsc=%p\n", sc->sc_dv.dv_xname, dsc));
-#ifdef DIAGNOSTIC
- if (sc == 0) {
- printf("wsmux_detach_sc: not allocated\n");
- return (ENXIO);
- }
-#endif
-
- for (m = LIST_FIRST(&sc->sc_reals); m; m = LIST_NEXT(m, next)) {
- if (m->sc == dsc)
- break;
- }
-#ifdef DIAGNOSTIC
- if (!m) {
- printf("wsmux_detach_sc: not found\n");
- return (ENXIO);
- }
-#endif
- if (sc->sc_displaydv) {
- if (m->sc_ops->dsetdisplay)
- error = m->sc_ops->dsetdisplay(m->sc, 0);
- if (error)
- return (error);
- *m->sc_muxp = 0;
- } else if (*m->sc_muxp) {
- DPRINTF(("wsmux_detach_sc: close\n"));
- /* mux device is open, so close multiplexee */
- m->sc_ops->dclose(m->sc, FREAD, 0, 0);
- *m->sc_muxp = 0;
- }
-
- LIST_REMOVE(m, next);
-
- free(m, M_DEVBUF);
- DPRINTF(("wsmux_detach_sc: done sc=%p\n", sc));
- return (0);
-}
-
-int
wsmuxopen(dev, flags, mode, p)
dev_t dev;
int flags, mode;
@@ -378,6 +261,220 @@
Home |
Main Index |
Thread Index |
Old Index