Subject: kern/29167: WSDISPLAY_CHARFUNCS non-functional with VGA_RASTERCONSOLE
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <feyrer@rfhinf045.fh-regensburg.de>
List: netbsd-bugs
Date: 01/31/2005 02:27:00
>Number:         29167
>Category:       kern
>Synopsis:       WSDISPLAY_CHARFUNCS non-functional with VGA_RASTERCONSOLE
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 31 02:27:00 +0000 2005
>Originator:     hubert@feyrer.de
>Release:        NetBSD 2.0
>Organization:
Hubert Feyrer <hubertf@channel.regensburg.org>
>Environment:
	
	
System: NetBSD vulab.fh-regensburg.de 2.0 NetBSD 2.0 (GENERIC) #10: Sun Oct 3 01:59:02 CEST 2004 feyrer@vulab.fh-regensburg.de:/disk4/cvs/src-2.0/sys/arch/i386/compile/obj.i386/GENERIC i386
Architecture: i386
Machine: i386
>Description:
	I enabled WSDISPLAY_CHARFUNCS and WSDISPLAY_SCROLLSUPPORT
	options in my kernel, and always wondered why they didn't work.
	After some debugging today, and with a hint from Klaus Klein,
	I found the problem is that I also have VGA_RASTERCONSOLE
	enabled.

	Looking into this wsmoused failure:
	wsmoused: ioctl(WSDISPLAYIO_GETWSCHAR) failed: Invalid argument

	This error comes up if the 'accessops' structure for a 
	driver doesn't set the 'getwschar' value properly. 
	The vga_accessops (in sys/dev/ic/vga.c) is initialized
	properly:

		const struct wsdisplay_accessops vga_accessops = {
			vga_ioctl,
			vga_mmap,
			vga_alloc_screen,
			vga_free_screen,
			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
			NULL,
		#endif
		};      


	vga_raster_accessops struct in sys/dev/ic/vga_raster.c
	doesn't even initialize the struct completely:

		const struct wsdisplay_accessops vga_raster_accessops = {
			vga_raster_ioctl,
			vga_raster_mmap,
			vga_raster_alloc_screen, 
			vga_raster_free_screen,
			vga_raster_show_screen,
			vga_raster_load_font,
		}; 

	It would be best to fix vga_raster.c to properly implement
	the missing functions (possibly using the ones from vga.c?),
	or if that's not possible bring _some_ warning/error if
	VGA_RASTERCONSOLE is used in conjunction with either
	WSDISPLAY_CHARFUNCS and/or WSDISPLAY_SCROLLSUPPORT.

	I guess the "console scrolling doesn't work" problems I
	have originate from this too (untested).


>How-To-Repeat:
	Have a kernel with VGA_RASTERCONSOLE and WSDISPLAY_CHARFUNCS
	Start wsmoused
	See it fail:
		wsmoused: ioctl(WSDISPLAYIO_GETWSCHAR) failed: Invalid argument

	Inspect code, see that it fails in wsdisplay.c, line 1127+:

			if (!sc->sc_accessops->getwschar)
				return (EINVAL);

	Continue debugging, and find that your sc_accessops
		doesn't have 'getwschar' etc. set.

	Next, find that 'getwschar' is set for vga.c, but not for
		vga_raster.c. Curse.

>Fix:
	It would be best to fix vga_raster.c to properly implement
	the missing functions (possibly using the ones from vga.c?),
	or if that's not possible bring _some_ warning/error if
	VGA_RASTERCONSOLE is used in conjunction with either
	WSDISPLAY_CHARFUNCS and/or WSDISPLAY_SCROLLSUPPORT, see above.

>Unformatted: