summaryrefslogtreecommitdiff
path: root/sys/dev/ic/com.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2007-05-08 21:28:12 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2007-05-08 21:28:12 +0000
commit2a77ff7190f2244ef1d5fc8c75e7e4e06f6e3549 (patch)
tree37e2681ed0701a018aa4dabda242b64e5575b74d /sys/dev/ic/com.c
parentb185e4c3aeffbd65680913ce39c5c3f16e1a717f (diff)
backout while the amd64 puc situation is rethought
Diffstat (limited to 'sys/dev/ic/com.c')
-rw-r--r--sys/dev/ic/com.c74
1 files changed, 73 insertions, 1 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c
index b38725ba57e..5ab1dc80afb 100644
--- a/sys/dev/ic/com.c
+++ b/sys/dev/ic/com.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: com.c,v 1.114 2007/05/08 21:18:18 deraadt Exp $ */
+/* $OpenBSD: com.c,v 1.115 2007/05/08 21:28:11 deraadt Exp $ */
/* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */
/*
@@ -200,6 +200,78 @@ comprobe1(iot, ioh)
#endif
int
+com_detach(self, flags)
+ struct device *self;
+ int flags;
+{
+ struct com_softc *sc = (struct com_softc *)self;
+ int maj, mn;
+
+ sc->sc_swflags |= COM_SW_DEAD;
+
+ /* 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) {
+ ttyfree(sc->sc_tty);
+ }
+
+ timeout_del(&sc->sc_dtr_tmo);
+ timeout_del(&sc->sc_diag_tmo);
+#ifdef __HAVE_GENERIC_SOFT_INTERRUPTS
+ softintr_disestablish(sc->sc_si);
+#else
+ timeout_del(&sc->sc_comsoft_tmo);
+#endif
+
+ 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;
+
+ s = spltty();
+ switch (act) {
+ case DVACT_ACTIVATE:
+ break;
+
+ case DVACT_DEACTIVATE:
+#ifdef KGDB
+ if (sc->sc_hwflags & (COM_HW_CONSOLE|COM_HW_KGDB)) {
+#else
+ if (sc->sc_hwflags & COM_HW_CONSOLE) {
+#endif /* KGDB */
+ rv = EBUSY;
+ break;
+ }
+
+ if (sc->disable != NULL && sc->enabled != 0) {
+ (*sc->disable)(sc);
+ sc->enabled = 0;
+ }
+ break;
+ }
+ splx(s);
+ return (rv);
+}
+
+int
comopen(dev, flag, mode, p)
dev_t dev;
int flag, mode;