diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-08-08 01:34:16 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-08-08 01:34:16 +0000 |
commit | 5101cd1517f87a054f3041c0d83c68f26c105c48 (patch) | |
tree | a4f2b616d544d16ee0ead1eefba6cdcd48428b88 /sys/arch/i386 | |
parent | a180199d7f84a71f2401a43aed2c094742e44b36 (diff) |
Detach support for com; NetBSD and me
Diffstat (limited to 'sys/arch/i386')
-rw-r--r-- | sys/arch/i386/isa/pccom.c | 80 | ||||
-rw-r--r-- | sys/arch/i386/isa/pccomvar.h | 9 |
2 files changed, 87 insertions, 2 deletions
diff --git a/sys/arch/i386/isa/pccom.c b/sys/arch/i386/isa/pccom.c index 4d54d805279..03c6645059e 100644 --- a/sys/arch/i386/isa/pccom.c +++ b/sys/arch/i386/isa/pccom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pccom.c,v 1.31 1999/07/26 12:31:44 niklas Exp $ */ +/* $OpenBSD: pccom.c,v 1.32 1999/08/08 01:34:15 niklas Exp $ */ /* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */ /* @@ -86,6 +86,7 @@ #include <sys/syslog.h> #include <sys/types.h> #include <sys/device.h> +#include <sys/vnode.h> #include <machine/bus.h> #include <machine/intr.h> @@ -668,6 +669,83 @@ comattach(parent, self, aux) /* XXX maybe move up some? */ if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) printf("%s: console\n", sc->sc_dev.dv_xname); + + /* + * If there are no enable/disable functions, assume the device + * is always enabled. + */ +#ifdef notyet + if (!sc->enable) +#endif + sc->enabled = 1; +} + +int +com_detach(self, flags) + struct device *self; + int flags; +{ + struct com_softc *sc = (struct com_softc *)self; + int maj, mn; + + /* locate the major number */ + for (maj = 0; maj < nchrdev; maj++) + if (cdevsw[maj].d_open == comopen) + break; + + /* Nuke the vnodes for any open instances. */ + mn = self->dv_unit; + vdevgone(maj, mn, mn, VCHR); + + /* XXX a symbolic constant for the cua bit would be nicer. */ + mn |= 0x80; + vdevgone(maj, mn, mn, VCHR); + + /* Detach and free the tty. */ + if (sc->sc_tty) { + tty_detach(sc->sc_tty); + ttyfree(sc->sc_tty); + } + + untimeout(com_raisedtr, sc); + untimeout(comdiag, sc); + + return (0); +} + +int +com_activate(self, act) + struct device *self; + enum devact act; +{ + struct com_softc *sc = (struct com_softc *)self; + int s, rv = 0; + + /* XXX splserial, when we get that. */ + s = spltty(); + switch (act) { + case DVACT_ACTIVATE: + rv = EOPNOTSUPP; + break; + + case DVACT_DEACTIVATE: +#ifdef notyet + if (sc->sc_hwflags & (COM_HW_CONSOLE|COM_HW_KGDB)) { +#else + if (sc->sc_hwflags & (COM_HW_CONSOLE)) { +#endif + rv = EBUSY; + break; + } + + if (sc->disable != NULL && sc->enabled != 0) { + (*sc->disable)(sc); + sc->enabled = 0; + } + break; + } + splx(s); + return (rv); } int diff --git a/sys/arch/i386/isa/pccomvar.h b/sys/arch/i386/isa/pccomvar.h index 5aa03ef8cb5..d3734c8499e 100644 --- a/sys/arch/i386/isa/pccomvar.h +++ b/sys/arch/i386/isa/pccomvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pccomvar.h,v 1.7 1999/07/26 12:31:44 niklas Exp $ */ +/* $OpenBSD: pccomvar.h,v 1.8 1999/08/08 01:34:15 niklas Exp $ */ /* $NetBSD: comvar.h,v 1.5 1996/05/05 19:50:47 christos Exp $ */ /* @@ -99,11 +99,18 @@ struct com_softc { u_char sc_rxbuf[RBUFSIZE]; u_char *sc_tba; int sc_tbc; + + /* power management hooks */ + int (*enable) __P((struct com_softc *)); + void (*disable) __P((struct com_softc *)); + int enabled; }; int comprobe1 __P((bus_space_tag_t, bus_space_handle_t)); void cominit __P((bus_space_tag_t, bus_space_handle_t, int)); int comintr __P((void *)); +int com_detach __P((struct device *, int)); +int com_activate __P((struct device *, enum devact)); #ifdef COM_HAYESP int comprobeHAYESP __P((bus_space_handle_t hayespioh, struct com_softc *sc)); |