Subject: Re: Fixing {get,put}wschar functions
To: Michael Lorenz <macallan@netbsd.org>
From: Julio M. Merino Vidal <jmmv84@gmail.com>
List: tech-kern
Date: 04/12/2006 23:43:06
------=_Part_13416_13364097.1144878186807
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

On 4/12/06, Michael Lorenz <macallan@netbsd.org> wrote:
> Hello,
>
> > 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 you owned.  I.e., if you opened /dev/ttyE0, you could only
> > get/set its characters, no matter if it was active or not.
>
> The ioctl() and mmap() methods should really, really know which device
> node they're being called from. Stuff like colour maps, read/write
> characters and so on should work on individual screens, not the whole
> thing.

OK.  Doing this makes it work as appropriate; see attached patch.

However, there is still an issue: note how the calls to the ioctl pass the
emulcookie to point to the affected screen.  This drives me back to the
beginning because all these changes were supposed to fix the usage
of emulcookie when calling the get/wschar functions, isn't it?

The thing is that, after inspecting the code, emulcookie seems to always
carry a poiner to the device's screen structure, so it is what we want to
use.  However, the name is misleading.  Do we want to add another
cookie to wsscreen_internal that (generally) holds the same value but
which can be used in these cases without relating them to terminal
emulation?  Something like screencookie?

Thanks,

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

------=_Part_13416_13364097.1144878186807
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 21:37:02 -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 21:37:02 -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 21:37:04 -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 21:37:05 -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 21:37:05 -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 21:37:07 -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 21:37:09 -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 21:37:09 -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 21:37:09 -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 21:37:13 -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 21:37:13 -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.31
diff -u -p -r1.31 pcdisplay_subr.c
--- dev/ic/pcdisplay_subr.c	12 Apr 2006 20:08:20 -0000	1.31
+++ dev/ic/pcdisplay_subr.c	12 Apr 2006 21:37:17 -0000
@@ -30,7 +30,6 @@
 #include <sys/cdefs.h>
 __KERNEL_RCSID(0, "$NetBSD: pcdisplay_subr.c,v 1.31 2006/04/12 20:08:20 jmmv Exp $");
 
-#include "opt_wsdisplay_compat.h" /* for WSDISPLAY_CHARFUNCS */
 #include "opt_wsmsgattrs.h" /* for WSDISPLAY_CUSTOM_OUTPUT */
 
 #include <sys/param.h>
@@ -291,15 +290,15 @@ pcdisplay_replaceattr(void *id, long old
 }
 #endif /* WSDISPLAY_CUSTOM_OUTPUT */
 
-#ifdef WSDISPLAY_CHARFUNCS
 int
-pcdisplay_getwschar(void *id, struct wsdisplay_char *wschar)
+pcdisplay_getwschar(struct pcdisplayscreen *scr, struct wsdisplay_char *wschar)
 {
-	struct pcdisplayscreen *scr = id;
 	int off;
 	uint16_t chardata;
 	uint8_t attrbyte;
 
+	KASSERT(scr != NULL && wschar != NULL);
+
 	off = wschar->row * scr->type->ncols + wschar->col;
 	if (off >= scr->type->ncols * scr->type->nrows)
 		return -1;
@@ -322,13 +321,14 @@ pcdisplay_getwschar(void *id, struct wsd
 }
 
 int
-pcdisplay_putwschar(void *id, struct wsdisplay_char *wschar)
+pcdisplay_putwschar(struct pcdisplayscreen *scr, struct wsdisplay_char *wschar)
 {
-	struct pcdisplayscreen *scr = id;
 	int off;
 	uint16_t chardata;
 	uint8_t attrbyte;
 
+	KASSERT(scr != NULL && wschar != NULL);
+
 	off = wschar->row * scr->type->ncols + wschar->col;
 	if (off >= (scr->type->ncols * scr->type->nrows))
 		return -1;
@@ -348,4 +348,3 @@ pcdisplay_putwschar(void *id, struct wsd
 
 	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 21:37:17 -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.86
diff -u -p -r1.86 vga.c
--- dev/ic/vga.c	12 Apr 2006 19:38:23 -0000	1.86
+++ dev/ic/vga.c	12 Apr 2006 21:37:18 -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
@@ -771,6 +760,7 @@ int
 vga_ioctl(void *v, void *vs, u_long cmd, caddr_t data, int flag, struct lwp *l)
 {
 	struct vga_config *vc = v;
+	struct vgascreen *scr = vs;
 	const struct vga_funcs *vf = vc->vc_funcs;
 
 	switch (cmd) {
@@ -791,6 +781,14 @@ vga_ioctl(void *v, void *vs, u_long cmd,
 		vga_set_video(vc, *(int *)data == WSDISPLAYIO_VIDEO_ON);
 		return 0;
 
+	case WSDISPLAYIO_GETWSCHAR:
+		return pcdisplay_getwschar((struct pcdisplayscreen *)scr,
+		    (struct wsdisplay_char *)data);
+
+	case WSDISPLAYIO_PUTWSCHAR:
+		return pcdisplay_putwschar((struct pcdisplayscreen *)scr,
+		    (struct wsdisplay_char *)data);
+
 #ifdef WSDISPLAY_CUSTOM_BORDER
 	case WSDISPLAYIO_GBORDER:
 		return (vga_getborder(vc, (u_int *)data));
@@ -1417,27 +1415,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.40
diff -u -p -r1.40 machfb.c
--- dev/pci/machfb.c	12 Apr 2006 19:38:23 -0000	1.40
+++ dev/pci/machfb.c	12 Apr 2006 21:37:19 -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);
@@ -403,8 +405,6 @@ static struct wsdisplay_accessops mach64
 	mach64_show_screen,
 	NULL,			/* load_font */
 	NULL,			/* polls */
-	mach64_getwschar,	/* getwschar */
-	mach64_putwschar,	/* putwschar */
 	NULL,			/* scroll */
 };
 
@@ -1914,9 +1914,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;
 
@@ -1937,9 +1936,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.2
diff -u -p -r1.2 voodoofb.c
--- dev/pci/voodoofb.c	12 Apr 2006 19:38:24 -0000	1.2
+++ dev/pci/voodoofb.c	12 Apr 2006 21:37:20 -0000
@@ -200,8 +200,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.31
diff -u -p -r1.31 p9100.c
--- dev/sbus/p9100.c	12 Apr 2006 19:38:24 -0000	1.31
+++ dev/sbus/p9100.c	12 Apr 2006 21:37:22 -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.30
diff -u -p -r1.30 cgsix.c
--- dev/sun/cgsix.c	12 Apr 2006 19:38:24 -0000	1.30
+++ dev/sun/cgsix.c	12 Apr 2006 21:37:23 -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 21:37:23 -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.94
diff -u -p -r1.94 wsdisplay.c
--- dev/wscons/wsdisplay.c	12 Apr 2006 19:38:24 -0000	1.94
+++ dev/wscons/wsdisplay.c	12 Apr 2006 21:37:25 -0000
@@ -1013,8 +1013,8 @@ int
 wsdisplay_param(struct device *dev, u_long cmd, struct wsdisplay_param *dp)
 {
 	struct wsdisplay_softc *sc = (struct wsdisplay_softc *)dev;
-	return ((*sc->sc_accessops->ioctl)(sc->sc_accesscookie, sc->sc_focus,
-					   cmd, (caddr_t)dp, 0, NULL));
+	return ((*sc->sc_accessops->ioctl)(sc->sc_accesscookie,
+	    sc->sc_focus->scr_dconf->emulcookie, cmd, (caddr_t)dp, 0, NULL));
 }
 
 int
@@ -1077,8 +1077,8 @@ wsdisplay_internal_ioctl(struct wsdispla
 	    } else if (d == WSDISPLAYIO_MODE_EMUL)
 		    return (EINVAL);
 
-	    (void)(*sc->sc_accessops->ioctl)(sc->sc_accesscookie, scr, cmd,
-	        data, flag, l);
+	    (void)(*sc->sc_accessops->ioctl)(sc->sc_accesscookie,
+	        scr->scr_dconf->emulcookie, cmd, data, flag, l);
 
 	    return (0);
 #undef d
@@ -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)
@@ -1183,8 +1161,8 @@ wsdisplay_internal_ioctl(struct wsdispla
 	}
 
 	/* check ioctls for display */
-	return ((*sc->sc_accessops->ioctl)(sc->sc_accesscookie, scr, cmd, data,
-	    flag, l));
+	return ((*sc->sc_accessops->ioctl)(sc->sc_accesscookie,
+	    scr->scr_dconf->emulcookie, cmd, data, flag, l));
 }
 
 int
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 21:37:25 -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 21:37:25 -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.38
diff -u -p -r1.38 wsdisplayvar.h
--- dev/wscons/wsdisplayvar.h	12 Apr 2006 19:38:24 -0000	1.38
+++ dev/wscons/wsdisplayvar.h	12 Apr 2006 21:37:25 -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_13416_13364097.1144878186807--