Subject: Re: New device - Patch review for mouse console support
To: None <tech-kern@netbsd.org>
From: Julio Merino <jmmv@hispabsd.org>
List: tech-kern
Date: 05/01/2002 16:13:21
--uXxzq0nDebZQVNAZ
Content-Type: multipart/mixed; boundary="24zk1gE8NUlDmwG9"
Content-Disposition: inline


--24zk1gE8NUlDmwG9
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Well, continuing with my patch, I've done some changes trying to get a
better structure. I've added a new device, /dev/ttyEctl beeing 47,254 that
is used for new ioctl's. This way we can completly separate them from the
ones already found in /dev/ttyEcfg; as I see it, that is for "configuring"
wscons, not to "control" it. The real reason to separate it is that I may
need to include several more ioctl's, and ttyEcfg would get messed with
lots of features.

And this way we could run wsmoused from a user that is not root, changing
ownership and permissions of ttyEctl...

I don't know if you will like this idea so I keep a backup of the file as
I posted before (all ioctl's inside ttyEcfg).

The patch for wsdisplay.c is included, so you can see it :p

Thank you.

On Wed, May 01, 2002 at 01:32:13PM +0000, Christos Zoulas wrote:
> In article <3CCFC2FC.C3A092E1@augustsson.net>,
> Lennart Augustsson <lennart@augustsson.net> wrote:
> >I've not looked at your patch very carefully, but it looks nice and smal=
l.
> >I think you're on the right track. :-)  Good work!
> >
>=20
> Yup, that looks good.
>=20
> christos

--=20
Of course it runs NetBSD - http://www.netbsd.org
HispaBSD member - http://www.hispabsd.org
Julio Merino <jmmv@hispabsd.org>

--24zk1gE8NUlDmwG9
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="patch.diff"
Content-Transfer-Encoding: quoted-printable

--- wsdisplay.c.orig	Mon Apr 29 18:49:02 2002
+++ wsdisplay.c	Wed May  1 15:15:47 2002
@@ -167,7 +167,8 @@
=20
 #define	WSDISPLAYUNIT(dev)	(minor(dev) >> 8)
 #define	WSDISPLAYSCREEN(dev)	(minor(dev) & 0xff)
-#define ISWSDISPLAYCTL(dev)	(WSDISPLAYSCREEN(dev) =3D=3D 255)
+#define ISWSDISPLAYCTL(dev)	(WSDISPLAYSCREEN(dev) =3D=3D 254)
+#define ISWSDISPLAYCFG(dev)	(WSDISPLAYSCREEN(dev) =3D=3D 255)
 #define WSDISPLAYMINOR(unit, screen)	(((unit) << 8) | (screen))
=20
 #define	WSSCREEN_HAS_EMULATOR(scr)	((scr)->scr_dconf->wsemul !=3D NULL)
@@ -675,7 +676,7 @@
 	if (sc =3D=3D NULL)			/* make sure it was attached */
 		return (ENXIO);
=20
-	if (ISWSDISPLAYCTL(dev))
+	if (ISWSDISPLAYCTL(dev) || ISWSDISPLAYCFG(dev))
 		return (0);
=20
 	if (WSDISPLAYSCREEN(dev) >=3D WSDISPLAY_MAXSCREEN)
@@ -731,7 +732,7 @@
=20
 	sc =3D device_lookup(&wsdisplay_cd, WSDISPLAYUNIT(dev));
=20
-	if (ISWSDISPLAYCTL(dev))
+	if (ISWSDISPLAYCTL(dev) || ISWSDISPLAYCFG(dev))
 		return (0);
=20
 	scr =3D sc->sc_scr[WSDISPLAYSCREEN(dev)];
@@ -785,7 +786,7 @@
=20
 	sc =3D device_lookup(&wsdisplay_cd, WSDISPLAYUNIT(dev));
=20
-	if (ISWSDISPLAYCTL(dev))
+	if (ISWSDISPLAYCTL(dev) || ISWSDISPLAYCFG(dev))
 		return (0);
=20
 	scr =3D sc->sc_scr[WSDISPLAYSCREEN(dev)];
@@ -806,7 +807,7 @@
=20
 	sc =3D device_lookup(&wsdisplay_cd, WSDISPLAYUNIT(dev));
=20
-	if (ISWSDISPLAYCTL(dev))
+	if (ISWSDISPLAYCTL(dev) || ISWSDISPLAYCFG(dev))
 		return (0);
=20
 	scr =3D sc->sc_scr[WSDISPLAYSCREEN(dev)];
@@ -827,7 +828,7 @@
=20
 	sc =3D device_lookup(&wsdisplay_cd, WSDISPLAYUNIT(dev));
=20
-	if (ISWSDISPLAYCTL(dev))
+	if (ISWSDISPLAYCTL(dev) || ISWSDISPLAYCFG(dev))
 		return (0);
=20
 	scr =3D sc->sc_scr[WSDISPLAYSCREEN(dev)];
@@ -847,7 +848,7 @@
=20
 	sc =3D device_lookup(&wsdisplay_cd, WSDISPLAYUNIT(dev));
=20
-	if (ISWSDISPLAYCTL(dev))
+	if (ISWSDISPLAYCTL(dev) || ISWSDISPLAYCFG(dev))
 		panic("wsdisplaytty() on ctl device");
=20
 	scr =3D sc->sc_scr[WSDISPLAYSCREEN(dev)];
@@ -871,7 +872,12 @@
 		return (error);
 #endif
=20
+#ifdef WSDISPLAY_CTLDEV
 	if (ISWSDISPLAYCTL(dev))
+		return (wsdisplay_ctl_ioctl(sc, cmd, data, flag, p));
+#endif /* WSDISPLAY_CTLDEV */
+
+	if (ISWSDISPLAYCFG(dev))
 		return (wsdisplay_cfg_ioctl(sc, cmd, data, flag, p));
=20
 	scr =3D sc->sc_scr[WSDISPLAYSCREEN(dev)];
@@ -1109,6 +1115,33 @@
 	return (EPASSTHROUGH);
 }
=20
+#ifdef WSDISPLAY_CTLDEV
+int
+wsdisplay_ctl_ioctl(struct wsdisplay_softc *sc, u_long cmd, caddr_t data,
+		    int flag, struct proc *p)
+{
+	switch (cmd) {
+	case WSDISPLAYIO_GETWSCHAR:
+		if (!sc->sc_accessops->getwschar)
+			return (EINVAL);
+		return ((*sc->sc_accessops->getwschar)
+			(sc->sc_accesscookie, (struct wsdisplay_char *) data));
+
+	case WSDISPLAYIO_PUTWSCHAR:
+		if (!sc->sc_accessops->putwschar)
+			return (EINVAL);
+		return ((*sc->sc_accessops->putwschar)
+			(sc->sc_accesscookie, (struct wsdisplay_char *) data));
+
+	case WSDISPLAYIO_STIOF:
+		if (WSSCREEN_HAS_TTY(sc->sc_focus))
+			ttioctl(sc->sc_focus->scr_tty, TIOCSTI, data, flag, p);
+		return 1;
+	}
+	return (EINVAL);
+}
+#endif /* WSDISPLAY_CTLDEV */
+
 paddr_t
 wsdisplaymmap(dev_t dev, off_t offset, int prot)
 {
@@ -1116,7 +1149,7 @@
 	    device_lookup(&wsdisplay_cd, WSDISPLAYUNIT(dev));
 	struct wsscreen *scr;
=20
-	if (ISWSDISPLAYCTL(dev))
+	if (ISWSDISPLAYCTL(dev) || ISWSDISPLAYCFG(dev))
 		return (-1);
=20
 	scr =3D sc->sc_scr[WSDISPLAYSCREEN(dev)];

--24zk1gE8NUlDmwG9--

--uXxzq0nDebZQVNAZ
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (NetBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE8z/gBzz00ZOPKycwRAhDXAJ9GEA2I7OWQqFn8UrBWkVQZSGRRhwCdFMhS
7ModZ3/ei5khwzmNZ4G/uaI=
=iRly
-----END PGP SIGNATURE-----

--uXxzq0nDebZQVNAZ--