diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2000-11-08 15:42:49 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2000-11-08 15:42:49 +0000 |
commit | 5e5d66af434518337c3737e1d9dd29b5b0c17719 (patch) | |
tree | a2021658f49a1db82c88dbaa19fa79cc14e7878b | |
parent | a4e0c469bb1a4b5e82cf475f675c8b1ed7cbe69d (diff) |
Add comcnattach that does the basic steps needed to attach
a com as a serial console. (idea from NetBSD).
If cn_tab->cn_dev == NODEV, try to find comopen in cdevsw and set cn_dev
to the right device.
-rw-r--r-- | sys/dev/ic/com.c | 44 | ||||
-rw-r--r-- | sys/dev/ic/comvar.h | 4 |
2 files changed, 44 insertions, 4 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index 4a99d20212e..60630c8c7bc 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com.c,v 1.55 2000/01/27 09:05:33 mickey Exp $ */ +/* $OpenBSD: com.c,v 1.56 2000/11/08 15:42:48 art Exp $ */ /* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */ /* @@ -91,6 +91,8 @@ #include <machine/bus.h> #include <machine/intr.h> +#include <dev/cons.h> + #include <dev/ic/comreg.h> #include <dev/ic/comvar.h> #include <dev/ic/ns16550reg.h> @@ -629,8 +631,19 @@ comattach(parent, self, aux) #endif /* XXX maybe move up some? */ - if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) + if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) { + int maj; + + /* locate the major number */ + for (maj = 0; maj < nchrdev; maj++) + if (cdevsw[maj].d_open == comopen) + break; + + if (maj < nchrdev && cn_tab->cn_dev == NODEV) + cn_tab->cn_dev = makedev(maj, sc->sc_dev.dv_unit); + printf("%s: console\n", sc->sc_dev.dv_xname); + } /* * If there are no enable/disable functions, assume the device @@ -1673,7 +1686,6 @@ ohfudge: /* * Following are all routines needed for COM to act as console */ -#include <dev/cons.h> #if defined(arc) || defined(hppa) #undef CONADDR @@ -1762,6 +1774,32 @@ cominit(iot, ioh, rate) } int +comcnattach(iot, iobase, rate, frequency, cflag) + bus_space_tag_t iot; + int iobase; + int rate, frequency; + tcflag_t cflag; +{ + static struct consdev comcons = { + NULL, NULL, comcngetc, comcnputc, comcnpollc, + NODEV, CN_NORMAL + }; + + if (bus_space_map(iot, iobase, COM_NPORTS, 0, &comconsioh)) + return ENOMEM; + + cominit(iot, comconsioh, rate); + + cn_tab = &comcons; + + comconsiot = iot; + comconsaddr = iobase; + comconscflag = cflag; + + return (0); +} + +int comcngetc(dev) dev_t dev; { diff --git a/sys/dev/ic/comvar.h b/sys/dev/ic/comvar.h index c1d4a4c06bc..141b8f9fb9f 100644 --- a/sys/dev/ic/comvar.h +++ b/sys/dev/ic/comvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: comvar.h,v 1.16 2000/02/04 06:11:58 angelos Exp $ */ +/* $OpenBSD: comvar.h,v 1.17 2000/11/08 15:42:48 art Exp $ */ /* $NetBSD: comvar.h,v 1.5 1996/05/05 19:50:47 christos Exp $ */ /* @@ -156,6 +156,8 @@ int comcngetc __P((dev_t)); void comcnputc __P((dev_t, int)); void comcnpollc __P((dev_t, int)); +int comcnattach __P((bus_space_tag_t, int, int, int, tcflag_t)); + extern int comdefaultrate; extern int comconsaddr; extern int comconsinit; |