Subject: Re: Fixing {get,put}wschar functions
To: None <tech-kern@netbsd.org>
From: Julio M. Merino Vidal <jmmv84@gmail.com>
List: tech-kern
Date: 04/12/2006 17:13:54
------=_Part_5378_33089103.1144854834020
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I was improving the changes to make the get/putwschar functions not use
void pointers as suggested by drochner@ when I noticed an ugly issue.

With the previous code, you could only get/put characters from the screen y=
ou
owned.  I.e., if you opened /dev/ttyE0, you could only get/set its characte=
rs,
no matter if it was active or not.

As a result of making these functions driver dependent, their entry point i=
s
vga_ioctl (in one of the possible hardware cases, of course).  As I underst=
and
it, there is no way to know, at that point, which ttyE? device was used to
execute the ioctl.  This is why I passed vc->active as the parameter to the
get/set functions.

And this obviously leds to a problem: no matter what ttyE? device you open
you can read the contents of the active screen.  As ttyE? changes ownership
when you log in, any user can spy the contents of another screen.

One could argue that this is not a big issue because if you can log into a
wscons console, you can switch to all other virtual screens easily.  But wh=
at
if a user "forgot" to close his session in, e.g, ttyE4, and then another us=
er
logs in, say, ttyE0?  The former user could read the latter's screen.

This feels wrong although the problem might not be really serious.  Any ide=
as
on how to fix it?

Assuming that there is no way to know if the opened device corresponds to
the active screen, the only solution I can come up with is to move these
ioctls to another device such as ttyEstat because it does not change owners=
hip.
This'd certainly simplify wsmoused's code.  But the name is not very approp=
riate
and the user loses the ability to call these ioctls on his own screen,
if he wanted
to.

Please comment.

On 4/11/06, Julio M. Merino Vidal <jmmv84@gmail.com> wrote:
> Hi,
>
> uwe@ reported that the {get,put}wschar functions in wscons are incorrectl=
y
> placed as they do not belong to accessops.  They should rather be in the
> drivers implementing them.
>
> I'm attaching a patch that supposedly fixes this.  Could you please tell =
me
> if it is correct?
>
> Also I'm thinking about removing the WSDISPLAY_CHARFUNCS kernel
> build option (which the patch also does).  It was added to reduce "bloat"
> from wsdisplay, but now makes little sense because the functions become
> driver-dependent.  Not to mention that these functions are very small and=
,
> at the moment, some drivers do not honour the option anyway.
>
> Thanks,
>
> --
> Julio M. Merino Vidal <jmmv84@gmail.com>
> The Julipedia - http://julipedia.blogspot.com/
>
>
>


--
Julio M. Merino Vidal <jmmv84@gmail.com>
The Julipedia - http://julipedia.blogspot.com/

------=_Part_5378_33089103.1144854834020
Content-Type: text/x-patch; name=patch.diff; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="patch.diff"

Index: arch/amd64/conf/GENERIC
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/conf/GENERIC,v
retrieving revision 1.91
diff -u -p -r1.91 GENERIC
--- arch/amd64/conf/GENERIC	12 Apr 2006 03:41:51 -0000	1.91
+++ arch/amd64/conf/GENERIC	12 Apr 2006 14:07:32 -0000
@@ -211,10 +211,6 @@ options 	PCDISPLAY_SOFTCURSOR
 #options 	VGA_CONSOLE_SCREENTYPE="\"80x24\""
 # work around a hardware bug that loaded fonts don't work; found on ATI cards
 #options 	VGA_CONSOLE_ATI_BROKEN_FONTSEL
-# the following enables some functions to get mouse console support.
-# if you want a really secure system, it may be better not to enable them,
-# see wsmoused(8), section SECURITY CONSIDERATIONS for more info.
-#options 	WSDISPLAY_CHARFUNCS		# mouse console support
 # console scrolling support.
 options 	WSDISPLAY_SCROLLSUPPORT
 # enable VGA raster mode capable of displaying multilingual text on console
Index: arch/amd64/conf/INSTALL
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/conf/INSTALL,v
retrieving revision 1.50
diff -u -p -r1.50 INSTALL
--- arch/amd64/conf/INSTALL	12 Apr 2006 03:41:51 -0000	1.50
+++ arch/amd64/conf/INSTALL	12 Apr 2006 14:07:32 -0000
@@ -149,10 +149,6 @@ options 	PCDISPLAY_SOFTCURSOR
 #options 	VGA_CONSOLE_SCREENTYPE="\"80x24\""
 # work around a hardware bug that loaded fonts don't work; found on ATI cards
 #options 	VGA_CONSOLE_ATI_BROKEN_FONTSEL
-# the following enables some functions to get mouse console support.
-# if you want a really secure system, it may be better not to enable them,
-# see wsmoused(8), section SECURITY CONSIDERATIONS for more info.
-#options 	WSDISPLAY_CHARFUNCS		# mouse console support
 # enable VGA raster mode capable of displaying multilingual text on console
 #options 	VGA_RASTERCONSOLE
 
Index: arch/cats/conf/GENERIC
===================================================================
RCS file: /cvsroot/src/sys/arch/cats/conf/GENERIC,v
retrieving revision 1.103
diff -u -p -r1.103 GENERIC
--- arch/cats/conf/GENERIC	28 Mar 2006 20:58:39 -0000	1.103
+++ arch/cats/conf/GENERIC	12 Apr 2006 14:07:33 -0000
@@ -188,10 +188,6 @@ options 	WSDISPLAY_COMPAT_USL		# VT hand
 options 	WSDISPLAY_COMPAT_RAWKBD		# can get raw scancodes
 # see dev/wscons/wskbdmap_mfii.h for implemented layouts
 #options 	PCKBD_LAYOUT="(KB_DE | KB_NODEAD)"
-# the following enables some functions to get mouse console support.
-# if you want a really secure system, it may be better not to enable them,
-# see wsmoused(8), section SECURITY CONSIDERATIONS for more info.
-#options 	WSDISPLAY_CHARFUNCS		# mouse console support
 
 # Development and Debugging options
 
Index: arch/evbarm/conf/ARMADILLO9
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/conf/ARMADILLO9,v
retrieving revision 1.10
diff -u -p -r1.10 ARMADILLO9
--- arch/evbarm/conf/ARMADILLO9	13 Feb 2006 12:24:22 -0000	1.10
+++ arch/evbarm/conf/ARMADILLO9	12 Apr 2006 14:07:34 -0000
@@ -342,10 +342,6 @@ options 	WSEMUL_VT100		# VT100 / VT220 e
 #options 	VGA_CONSOLE_SCREENTYPE="\"80x24\""
 # work around a hardware bug that loaded fonts don't work; found on ATI cards
 #options 	VGA_CONSOLE_ATI_BROKEN_FONTSEL
-# the following enables some functions to get mouse console support.
-# if you want a really secure system, it may be better not to enable them,
-# see wsmoused(8), section SECURITY CONSIDERATIONS for more info.
-#options 	WSDISPLAY_CHARFUNCS		# mouse console support
 # console scrolling support.
 #options 	WSDISPLAY_SCROLLSUPPORT
 # enable VGA raster mode capable of displaying multilingual text on console
Index: arch/evbarm/conf/TS7200
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/conf/TS7200,v
retrieving revision 1.25
diff -u -p -r1.25 TS7200
--- arch/evbarm/conf/TS7200	5 Feb 2006 05:01:49 -0000	1.25
+++ arch/evbarm/conf/TS7200	12 Apr 2006 14:07:34 -0000
@@ -479,10 +479,6 @@ options 	WSEMUL_VT100		# VT100 / VT220 e
 #options 	VGA_CONSOLE_SCREENTYPE="\"80x24\""
 # work around a hardware bug that loaded fonts don't work; found on ATI cards
 #options 	VGA_CONSOLE_ATI_BROKEN_FONTSEL
-# the following enables some functions to get mouse console support.
-# if you want a really secure system, it may be better not to enable them,
-# see wsmoused(8), section SECURITY CONSIDERATIONS for more info.
-#options 	WSDISPLAY_CHARFUNCS		# mouse console support
 # console scrolling support.
 #options 	WSDISPLAY_SCROLLSUPPORT
 # enable VGA raster mode capable of displaying multilingual text on console
Index: arch/hp700/conf/GENERIC
===================================================================
RCS file: /cvsroot/src/sys/arch/hp700/conf/GENERIC,v
retrieving revision 1.64
diff -u -p -r1.64 GENERIC
--- arch/hp700/conf/GENERIC	28 Mar 2006 20:58:40 -0000	1.64
+++ arch/hp700/conf/GENERIC	12 Apr 2006 14:07:34 -0000
@@ -205,10 +205,6 @@ options 	PCDISPLAY_SOFTCURSOR
 #options 	VGA_CONSOLE_SCREENTYPE="\"80x24\""
 # work around a hardware bug that loaded fonts don't work; found on ATI cards
 #options 	VGA_CONSOLE_ATI_BROKEN_FONTSEL
-# the following enables some functions to get mouse console support.
-# if you want a really secure system, it may be better not to enable them,
-# see wsmoused(8), section SECURITY CONSIDERATIONS for more info.
-#options 	WSDISPLAY_CHARFUNCS		# mouse console support
 # console scrolling support.
 #options 	WSDISPLAY_SCROLLSUPPORT
 # enable VGA raster mode capable of displaying multilingual text on console
Index: arch/i386/conf/GENERIC
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/conf/GENERIC,v
retrieving revision 1.741
diff -u -p -r1.741 GENERIC
--- arch/i386/conf/GENERIC	12 Apr 2006 03:41:51 -0000	1.741
+++ arch/i386/conf/GENERIC	12 Apr 2006 14:07:35 -0000
@@ -276,10 +276,6 @@ options 	PCDISPLAY_SOFTCURSOR
 #options 	VGA_CONSOLE_SCREENTYPE="\"80x24\""
 # work around a hardware bug that loaded fonts don't work; found on ATI cards
 #options 	VGA_CONSOLE_ATI_BROKEN_FONTSEL
-# the following enables some functions to get mouse console support.
-# if you want a really secure system, it may be better not to enable them,
-# see wsmoused(8), section SECURITY CONSIDERATIONS for more info.
-#options 	WSDISPLAY_CHARFUNCS		# mouse console support
 # console scrolling support.
 options 	WSDISPLAY_SCROLLSUPPORT
 # enable VGA raster mode capable of displaying multilingual text on console
Index: arch/i386/conf/LAMB
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/conf/LAMB,v
retrieving revision 1.62
diff -u -p -r1.62 LAMB
--- arch/i386/conf/LAMB	28 Mar 2006 20:58:40 -0000	1.62
+++ arch/i386/conf/LAMB	12 Apr 2006 14:07:35 -0000
@@ -200,10 +200,6 @@ options 	PCDISPLAY_SOFTCURSOR
 #options 	VGA_CONSOLE_SCREENTYPE="\"80x24\""
 # work around a hardware bug that loaded fonts don't work; found on ATI cards
 #options 	VGA_CONSOLE_ATI_BROKEN_FONTSEL
-# the following enables some functions to get mouse console support.
-# if you want a really secure system, it may be better not to enable them,
-# see wsmoused(8), section SECURITY CONSIDERATIONS for more info.
-#options 	WSDISPLAY_CHARFUNCS		# mouse console support
 
 # Kernel root file system and dump configuration.
 config		netbsd	root on ? type ?
Index: arch/i386/conf/VIRTUALPC
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/conf/VIRTUALPC,v
retrieving revision 1.39
diff -u -p -r1.39 VIRTUALPC
--- arch/i386/conf/VIRTUALPC	28 Mar 2006 20:58:40 -0000	1.39
+++ arch/i386/conf/VIRTUALPC	12 Apr 2006 14:07:35 -0000
@@ -234,10 +234,6 @@ options 	PCDISPLAY_SOFTCURSOR
 #options 	VGA_CONSOLE_SCREENTYPE="\"80x24\""
 # work around a hardware bug that loaded fonts don't work; found on ATI cards
 #options 	VGA_CONSOLE_ATI_BROKEN_FONTSEL
-# the following enables some functions to get mouse console support.
-# if you want a really secure system, it may be better not to enable them,
-# see wsmoused(8), section SECURITY CONSIDERATIONS for more info.
-#options 	WSDISPLAY_CHARFUNCS		# mouse console support
 # enable VGA raster mode capable of displaying multilingual text on console
 #options 	VGA_RASTERCONSOLE
 
Index: arch/sgimips/conf/GENERIC32_IP2x
===================================================================
RCS file: /cvsroot/src/sys/arch/sgimips/conf/GENERIC32_IP2x,v
retrieving revision 1.47
diff -u -p -r1.47 GENERIC32_IP2x
--- arch/sgimips/conf/GENERIC32_IP2x	28 Mar 2006 20:58:41 -0000	1.47
+++ arch/sgimips/conf/GENERIC32_IP2x	12 Apr 2006 14:07:37 -0000
@@ -192,10 +192,6 @@ options 	WS_KERNEL_FG=WSCOL_GREEN
 options 	WSDISPLAY_COMPAT_RAWKBD		# can get raw scancodes
 # see dev/pckbc/wskbdmap_mfii.c for implemented layouts
 #options 	PCKBD_LAYOUT="(KB_DE | KB_NODEAD)"
-# the following enables some functions to get mouse console support.
-# if you want a really secure system, it may be better not to enable them,
-# see wsmoused(8), section SECURITY CONSIDERATIONS for more info.
-#options 	WSDISPLAY_CHARFUNCS		# mouse console support
 
 
 # Kernel root file system and dump configuration.
Index: arch/shark/conf/GENERIC
===================================================================
RCS file: /cvsroot/src/sys/arch/shark/conf/GENERIC,v
retrieving revision 1.60
diff -u -p -r1.60 GENERIC
--- arch/shark/conf/GENERIC	28 Mar 2006 20:58:41 -0000	1.60
+++ arch/shark/conf/GENERIC	12 Apr 2006 14:07:37 -0000
@@ -207,10 +207,6 @@ options 	WSDISPLAY_COMPAT_RAWKBD		# can 
 #options 	PCDISPLAY_SOFTCURSOR
 # modify the screen type of the console; defaults to "80x25"
 #options 	VGA_CONSOLE_SCREENTYPE="\"80x24\""
-# the following enables some functions to get mouse console support.
-# if you want a really secure system, it may be better not to enable them,
-# see wsmoused(8), section SECURITY CONSIDERATIONS for more info.
-#options 	WSDISPLAY_CHARFUNCS		# mouse console support
 # console scrolling support.
 #options 	WSDISPLAY_SCROLLSUPPORT
 # enable VGA raster mode capable of displaying multilingual text on console
Index: dev/ic/pcdisplay_subr.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/pcdisplay_subr.c,v
retrieving revision 1.29
diff -u -p -r1.29 pcdisplay_subr.c
--- dev/ic/pcdisplay_subr.c	11 Dec 2005 12:21:28 -0000	1.29
+++ dev/ic/pcdisplay_subr.c	12 Apr 2006 14:07:38 -0000
@@ -30,7 +30,6 @@
 #include <sys/cdefs.h>
 __KERNEL_RCSID(0, "$NetBSD: pcdisplay_subr.c,v 1.29 2005/12/11 12:21:28 christos Exp $");
 
-#include "opt_wsdisplay_compat.h" /* for WSDISPLAY_CHARFUNCS */
 #include "opt_wsmsgattrs.h" /* for WSDISPLAY_CUSTOM_OUTPUT */
 
 #include <sys/param.h>
@@ -313,13 +312,9 @@ pcdisplay_replaceattr(id, oldattr, newat
 }
 #endif /* WSDISPLAY_CUSTOM_OUTPUT */
 
-#ifdef WSDISPLAY_CHARFUNCS
 int
-pcdisplay_getwschar(id, wschar)
-	void *id;
-	struct wsdisplay_char *wschar;
+pcdisplay_getwschar(struct pcdisplayscreen *scr, struct wsdisplay_char *wschar)
 {
-	struct pcdisplayscreen *scr = id;
 	bus_space_tag_t memt = scr->hdl->ph_memt;
 	bus_space_handle_t memh = scr->hdl->ph_memh;
 	int off;
@@ -348,11 +343,8 @@ pcdisplay_getwschar(id, wschar)
 }
 
 int
-pcdisplay_putwschar(id, wschar)
-	void *id;
-	struct wsdisplay_char *wschar;
+pcdisplay_putwschar(struct pcdisplayscreen *scr, struct wsdisplay_char *wschar)
 {
-	struct pcdisplayscreen *scr = id;
 	bus_space_tag_t memt = scr->hdl->ph_memt;
 	bus_space_handle_t memh = scr->hdl->ph_memh;
 	int off;
@@ -378,4 +370,3 @@ pcdisplay_putwschar(id, wschar)
 
 	return 0;
 }
-#endif /* WSDISPLAY_CHARFUNCS */
Index: dev/ic/pcdisplayvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/pcdisplayvar.h,v
retrieving revision 1.16
diff -u -p -r1.16 pcdisplayvar.h
--- dev/ic/pcdisplayvar.h	16 Feb 2006 20:17:16 -0000	1.16
+++ dev/ic/pcdisplayvar.h	12 Apr 2006 14:07:38 -0000
@@ -90,5 +90,5 @@ void	pcdisplay_copyrows(void *, int, int
 void	pcdisplay_eraserows(void *, int, int, long);
 void	pcdisplay_replaceattr(void *, long, long);
 struct wsdisplay_char;
-int	pcdisplay_getwschar(void *, struct wsdisplay_char *);
-int	pcdisplay_putwschar(void *, struct wsdisplay_char *);
+int	pcdisplay_getwschar(struct pcdisplayscreen *, struct wsdisplay_char *);
+int	pcdisplay_putwschar(struct pcdisplayscreen *, struct wsdisplay_char *);
Index: dev/ic/vga.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/vga.c,v
retrieving revision 1.85
diff -u -p -r1.85 vga.c
--- dev/ic/vga.c	5 Apr 2006 15:19:54 -0000	1.85
+++ dev/ic/vga.c	12 Apr 2006 14:07:39 -0000
@@ -27,7 +27,7 @@
  * rights to redistribute these changes.
  */
 
-/* for WSCONS_SUPPORT_PCVTFONTS and WSDISPLAY_CHARFUNCS */
+/* for WSCONS_SUPPORT_PCVTFONTS */
 #include "opt_wsdisplay_compat.h"
 /* for WSDISPLAY_CUSTOM_BORDER */
 #include "opt_wsdisplay_border.h"
@@ -274,10 +274,6 @@ static void	vga_free_screen(void *, void
 static int	vga_show_screen(void *, void *, int,
 				void (*)(void *, int, int), void *);
 static int	vga_load_font(void *, void *, struct wsdisplay_font *);
-#ifdef WSDISPLAY_CHARFUNCS
-static int	vga_getwschar(void *, struct wsdisplay_char *);
-static int	vga_putwschar(void *, struct wsdisplay_char *);
-#endif /* WSDISPLAY_CHARFUNCS */
 #ifdef WSDISPLAY_CUSTOM_BORDER
 static int	vga_getborder(struct vga_config *, u_int *);
 static int	vga_setborder(struct vga_config *, u_int);
@@ -293,13 +289,6 @@ const struct wsdisplay_accessops vga_acc
 	vga_show_screen,
 	vga_load_font,
 	NULL,
-#ifdef WSDISPLAY_CHARFUNCS
-	vga_getwschar,
-	vga_putwschar,
-#else /* WSDISPLAY_CHARFUNCS */
-	NULL,
-	NULL,
-#endif /* WSDISPLAY_CHARFUNCS */
 #ifdef WSDISPLAY_SCROLLSUPPORT
 	vga_scroll,
 #else
@@ -791,6 +780,14 @@ vga_ioctl(void *v, u_long cmd, caddr_t d
 		vga_set_video(vc, *(int *)data == WSDISPLAYIO_VIDEO_ON);
 		return 0;
 
+	case WSDISPLAYIO_GETWSCHAR:
+		return pcdisplay_getwschar((struct pcdisplayscreen *)vc->active,
+		    (struct wsdisplay_char *)data);
+
+	case WSDISPLAYIO_PUTWSCHAR:
+		return pcdisplay_putwschar((struct pcdisplayscreen *)vc->active,
+		    (struct wsdisplay_char *)data);
+
 #ifdef WSDISPLAY_CUSTOM_BORDER
 	case WSDISPLAYIO_GBORDER:
 		return (vga_getborder(vc, (u_int *)data));
@@ -1417,27 +1414,6 @@ vga_putchar(void *c, int row, int col, u
 	pcdisplay_putchar(c, row, col, uc, attr);
 }
 
-
-#ifdef WSDISPLAY_CHARFUNCS
-int
-vga_getwschar(void *cookie, struct wsdisplay_char *wschar)
-{
-	struct vgascreen *scr = cookie;
-
-	if (scr == NULL) return 0;
-	return (pcdisplay_getwschar(&scr->pcs, wschar));
-}
-
-int
-vga_putwschar(void *cookie, struct wsdisplay_char *wschar)
-{
-	struct vgascreen *scr = cookie;
-
-	if (scr == NULL) return 0;
-	return (pcdisplay_putwschar(&scr->pcs, wschar));
-}
-#endif /* WSDISPLAY_CHARFUNCS */
-
 #ifdef WSDISPLAY_CUSTOM_BORDER
 static int
 vga_getborder(struct vga_config *vc, u_int *valuep)
Index: dev/pci/machfb.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/machfb.c,v
retrieving revision 1.39
diff -u -p -r1.39 machfb.c
--- dev/pci/machfb.c	5 Apr 2006 15:23:06 -0000	1.39
+++ dev/pci/machfb.c	12 Apr 2006 14:07:39 -0000
@@ -290,8 +290,10 @@ static void	mach64_feed_bytes(struct mac
 #if 0
 static void	mach64_showpal(struct mach64_softc *);
 #endif
-static int	mach64_getwschar(void *, struct wsdisplay_char *);
-static int	mach64_putwschar(void *, struct wsdisplay_char *);
+static int	mach64_getwschar(struct mach64_softc *,
+		                 struct wsdisplay_char *);
+static int	mach64_putwschar(struct mach64_softc *,
+		                 struct wsdisplay_char *);
 
 static void	set_address(struct rasops_info *, bus_addr_t);
 static void	machfb_blank(struct mach64_softc *, int);
@@ -402,8 +404,6 @@ static struct wsdisplay_accessops mach64
 	mach64_show_screen,
 	NULL,			/* load_font */
 	NULL,			/* polls */
-	mach64_getwschar,	/* getwschar */
-	mach64_putwschar,	/* putwschar */
 	NULL,			/* scroll */
 };
 
@@ -1912,9 +1912,8 @@ set_address(struct rasops_info *ri, bus_
 }
 
 static int
-mach64_getwschar(void *cookie, struct wsdisplay_char *wsc)
+mach64_getwschar(struct mach64_softc *sc, struct wsdisplay_char *wsc)
 {
-	struct mach64_softc *sc = cookie;
 	struct mach64screen *scr = sc->active;
 	int fg, bg, fl;
 
@@ -1935,9 +1934,8 @@ mach64_getwschar(void *cookie, struct ws
 }
 
 static int
-mach64_putwschar(void *cookie, struct wsdisplay_char *wsc)
+mach64_putwschar(struct mach64_softc *sc, struct wsdisplay_char *wsc)
 {
-	struct mach64_softc *sc=cookie;
 	struct mach64screen *scr=sc->active;
 	long attr;
 	
Index: dev/pci/voodoofb.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/voodoofb.c,v
retrieving revision 1.1
diff -u -p -r1.1 voodoofb.c
--- dev/pci/voodoofb.c	11 Apr 2006 16:11:07 -0000	1.1
+++ dev/pci/voodoofb.c	12 Apr 2006 14:07:40 -0000
@@ -199,8 +199,6 @@ struct wsdisplay_accessops voodoofb_acce
 	voodoofb_mmap,
 	NULL,	/* load_font */
 	NULL,	/* polls */
-	NULL,	/* getwschar */
-	NULL,	/* putwschar */
 	NULL,	/* scroll */
 };
 
Index: dev/sbus/p9100.c
===================================================================
RCS file: /cvsroot/src/sys/dev/sbus/p9100.c,v
retrieving revision 1.30
diff -u -p -r1.30 p9100.c
--- dev/sbus/p9100.c	6 Apr 2006 12:22:05 -0000	1.30
+++ dev/sbus/p9100.c	12 Apr 2006 14:07:40 -0000
@@ -250,8 +250,6 @@ struct wsdisplay_accessops p9100_accesso
 	NULL,	/* vcons_show_screen */
 	NULL,	/* load_font */
 	NULL,	/* polls */
-	NULL,	/* getwschar */
-	NULL,	/* putwschar */
 	NULL,	/* scroll */
 };
 #endif
Index: dev/sun/cgsix.c
===================================================================
RCS file: /cvsroot/src/sys/dev/sun/cgsix.c,v
retrieving revision 1.29
diff -u -p -r1.29 cgsix.c
--- dev/sun/cgsix.c	12 Dec 2005 02:44:09 -0000	1.29
+++ dev/sun/cgsix.c	12 Apr 2006 14:07:41 -0000
@@ -192,8 +192,6 @@ struct wsdisplay_accessops cgsix_accesso
 	cgsix_show_screen,
 	NULL, 	/* load_font */
 	NULL,	/* pollc */
-	NULL,	/* getwschar */
-	NULL,	/* putwschar */
 	NULL	/* scroll */
 };
 
Index: dev/wscons/files.wscons
===================================================================
RCS file: /cvsroot/src/sys/dev/wscons/files.wscons,v
retrieving revision 1.37
diff -u -p -r1.37 files.wscons
--- dev/wscons/files.wscons	23 Feb 2006 08:01:59 -0000	1.37
+++ dev/wscons/files.wscons	12 Apr 2006 14:07:41 -0000
@@ -27,7 +27,6 @@ defparam opt_wsemul.h		WSEMUL_VT100_HILI
 defflag	opt_wsdisplay_compat.h	WSDISPLAY_COMPAT_USL
 				WSDISPLAY_COMPAT_RAWKBD
 				WSDISPLAY_COMPAT_PCVT WSDISPLAY_COMPAT_SYSCONS
-				WSDISPLAY_CHARFUNCS
 				WSCONS_SUPPORT_PCVTFONTS
 				WSCONS_SUPPORT_ISO7FONTS
 				WSDISPLAY_SCROLLSUPPORT
Index: dev/wscons/wsdisplay.c
===================================================================
RCS file: /cvsroot/src/sys/dev/wscons/wsdisplay.c,v
retrieving revision 1.93
diff -u -p -r1.93 wsdisplay.c
--- dev/wscons/wsdisplay.c	5 Apr 2006 15:18:25 -0000	1.93
+++ dev/wscons/wsdisplay.c	12 Apr 2006 14:07:41 -0000
@@ -1133,28 +1133,6 @@ wsdisplay_internal_ioctl(struct wsdispla
 		return (error);
 #undef d
 
-#if defined(WSDISPLAY_CHARFUNCS)
-	case WSDISPLAYIO_GETWSCHAR:
-#define d ((struct wsdisplay_char *)data)
-		if (!sc->sc_accessops->getwschar)
-			return (EINVAL);
-		return ((*sc->sc_accessops->getwschar)
-			(scr->scr_dconf->emulcookie, d));
-#undef d
-
-	case WSDISPLAYIO_PUTWSCHAR:
-#define d ((struct wsdisplay_char *)data)
-		if (!sc->sc_accessops->putwschar)
-			return (EINVAL);
-		return ((*sc->sc_accessops->putwschar)
-			(scr->scr_dconf->emulcookie, d));
-#undef d
-#else
-	case WSDISPLAYIO_PUTWSCHAR:
-	case WSDISPLAYIO_GETWSCHAR:
-		return ENODEV;
-#endif /* WSDISPLAY_CHARFUNCS */
-
 #ifdef WSDISPLAY_CUSTOM_OUTPUT
 	case WSDISPLAYIO_GMSGATTRS:
 #define d ((struct wsdisplay_msgattrs *)data)
Index: dev/wscons/wsdisplay_vcons.c
===================================================================
RCS file: /cvsroot/src/sys/dev/wscons/wsdisplay_vcons.c,v
retrieving revision 1.5
diff -u -p -r1.5 wsdisplay_vcons.c
--- dev/wscons/wsdisplay_vcons.c	19 Feb 2006 03:51:03 -0000	1.5
+++ dev/wscons/wsdisplay_vcons.c	12 Apr 2006 14:07:41 -0000
@@ -60,6 +60,7 @@ __KERNEL_RCSID(0, "$NetBSD: wsdisplay_vc
 static void vcons_dummy_init_screen(void *, struct vcons_screen *, int, 
 	    long *);
 
+static int  vcons_ioctl(void *, u_long, caddr_t, int, struct lwp *);
 static int  vcons_alloc_screen(void *, const struct wsscreen_descr *, void **, 
 	    int *, int *, long *);
 static void vcons_free_screen(void *, void *);
@@ -87,8 +88,8 @@ static void vcons_putchar(void *, int, i
 static void vcons_cursor(void *, int, int, int);
 
 /* support for readin/writing text buffers. For wsmoused */
-static int  vcons_putwschar(void *, struct wsdisplay_char *);
-static int  vcons_getwschar(void *, struct wsdisplay_char *);
+static int  vcons_putwschar(struct rasops_info *, struct wsdisplay_char *);
+static int  vcons_getwschar(struct rasops_info *, struct wsdisplay_char *);
 
 static void vcons_lock(struct vcons_screen *);
 static void vcons_unlock(struct vcons_screen *);
@@ -107,11 +108,15 @@ vcons_init(struct vcons_data *vd, void *
 	vd->init_screen = vcons_dummy_init_screen;
 	vd->show_screen_cb = NULL;
 
+	/* keep a copy of the accessops that we replace below with our
+	 * own wrappers */
+	vd->ioctl = ao->ioctl;
+
+	/* configure the accessops */
+	ao->ioctl = vcons_ioctl;
 	ao->alloc_screen = vcons_alloc_screen;
 	ao->free_screen = vcons_free_screen;
 	ao->show_screen = vcons_show_screen;
-	ao->getwschar = vcons_getwschar;
-	ao->putwschar = vcons_putwschar;
 
 	LIST_INIT(&vd->screens);
 	vd->active = NULL;
@@ -361,6 +366,33 @@ vcons_redraw_screen(struct vcons_screen 
 }
 
 static int
+vcons_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct lwp *l)
+{
+	struct vcons_data *vd = v;
+	int error;
+
+	switch (cmd) {
+	case WSDISPLAYIO_GETWSCHAR:
+		error = vcons_getwschar(vd->cookie,
+			(struct wsdisplay_char *)data);
+		break;
+
+	case WSDISPLAYIO_PUTWSCHAR:
+		error = vcons_putwschar(vd->cookie,
+			(struct wsdisplay_char *)data);
+		break;
+
+	default:
+		if (vd->ioctl != NULL)
+			error = (*vd->ioctl)(v, cmd, data, flag, l);
+		else
+			error = EINVAL;
+	}
+
+	return error;
+}
+
+static int
 vcons_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
     int *curxp, int *curyp, long *defattrp)
 {
@@ -622,9 +654,8 @@ vcons_cursor(void *cookie, int on, int r
 /* methods to read/write characters via ioctl() */
 
 static int
-vcons_putwschar(void *cookie, struct wsdisplay_char *wsc)
+vcons_putwschar(struct rasops_info *ri, struct wsdisplay_char *wsc)
 {
-	struct rasops_info *ri = cookie;
 	long attr;
 	
 	ri->ri_ops.allocattr(ri, wsc->foreground, wsc->background,
@@ -634,9 +665,8 @@ vcons_putwschar(void *cookie, struct wsd
 }
 
 static int
-vcons_getwschar(void *cookie, struct wsdisplay_char *wsc)
+vcons_getwschar(struct rasops_info *ri, struct wsdisplay_char *wsc)
 {
-	struct rasops_info *ri = cookie;
 	struct vcons_screen *scr = ri->ri_hw;
 	long attr;
 	int offset = ri->ri_cols * wsc->row + wsc->col;
Index: dev/wscons/wsdisplay_vconsvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/wscons/wsdisplay_vconsvar.h,v
retrieving revision 1.3
diff -u -p -r1.3 wsdisplay_vconsvar.h
--- dev/wscons/wsdisplay_vconsvar.h	19 Feb 2006 03:51:03 -0000	1.3
+++ dev/wscons/wsdisplay_vconsvar.h	12 Apr 2006 14:07:41 -0000
@@ -85,6 +85,9 @@ struct vcons_data {
 	void (*init_screen)(void *, struct vcons_screen *, int, 
 	    long *);
 
+	/* accessops */
+	int (*ioctl)(void *, u_long, caddr_t, int, struct lwp *);
+
 	/* rasops */
 	void (*copycols)(void *, int, int, int, int);
 	void (*erasecols)(void *, int, int, int, long);
Index: dev/wscons/wsdisplayvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/wscons/wsdisplayvar.h,v
retrieving revision 1.37
diff -u -p -r1.37 wsdisplayvar.h
--- dev/wscons/wsdisplayvar.h	7 Apr 2006 14:30:20 -0000	1.37
+++ dev/wscons/wsdisplayvar.h	12 Apr 2006 14:07:41 -0000
@@ -121,8 +121,6 @@ struct wsdisplay_accessops {
 				    void (*) (void *, int, int), void *);
 	int	(*load_font)(void *, void *, struct wsdisplay_font *);
 	void	(*pollc)(void *, int);
-	int	(*getwschar)(void *, struct wsdisplay_char *);
-	int	(*putwschar)(void *, struct wsdisplay_char *);
 	void	(*scroll)(void *, void *, int);
 };
 























------=_Part_5378_33089103.1144854834020--