Home | History | Annotate | Line # | Download | only in sun
bwtwo.c revision 1.21
      1  1.20       jdc /*	$NetBSD: bwtwo.c,v 1.21 2009/01/01 13:53:07 jdc Exp $ */
      2   1.1        pk 
      3   1.1        pk /*-
      4   1.1        pk  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
      5   1.1        pk  * All rights reserved.
      6   1.1        pk  *
      7   1.1        pk  * This code is derived from software contributed to The NetBSD Foundation
      8   1.1        pk  * by Jason R. Thorpe.
      9   1.1        pk  *
     10   1.1        pk  * Redistribution and use in source and binary forms, with or without
     11   1.1        pk  * modification, are permitted provided that the following conditions
     12   1.1        pk  * are met:
     13   1.1        pk  * 1. Redistributions of source code must retain the above copyright
     14   1.1        pk  *    notice, this list of conditions and the following disclaimer.
     15   1.1        pk  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1        pk  *    notice, this list of conditions and the following disclaimer in the
     17   1.1        pk  *    documentation and/or other materials provided with the distribution.
     18   1.1        pk  *
     19   1.1        pk  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20   1.1        pk  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21   1.1        pk  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22   1.1        pk  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23   1.1        pk  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24   1.1        pk  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25   1.1        pk  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26   1.1        pk  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27   1.1        pk  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28   1.1        pk  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29   1.1        pk  * POSSIBILITY OF SUCH DAMAGE.
     30   1.1        pk  */
     31   1.1        pk 
     32   1.1        pk /*
     33   1.1        pk  * Copyright (c) 1992, 1993
     34   1.1        pk  *	The Regents of the University of California.  All rights reserved.
     35   1.1        pk  *
     36   1.1        pk  * This software was developed by the Computer Systems Engineering group
     37   1.1        pk  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
     38   1.1        pk  * contributed to Berkeley.
     39   1.1        pk  *
     40   1.1        pk  * All advertising materials mentioning features or use of this software
     41   1.1        pk  * must display the following acknowledgement:
     42   1.1        pk  *	This product includes software developed by the University of
     43   1.1        pk  *	California, Lawrence Berkeley Laboratory.
     44   1.1        pk  *
     45   1.1        pk  * Redistribution and use in source and binary forms, with or without
     46   1.1        pk  * modification, are permitted provided that the following conditions
     47   1.1        pk  * are met:
     48   1.1        pk  * 1. Redistributions of source code must retain the above copyright
     49   1.1        pk  *    notice, this list of conditions and the following disclaimer.
     50   1.1        pk  * 2. Redistributions in binary form must reproduce the above copyright
     51   1.1        pk  *    notice, this list of conditions and the following disclaimer in the
     52   1.1        pk  *    documentation and/or other materials provided with the distribution.
     53   1.9       agc  * 3. Neither the name of the University nor the names of its contributors
     54   1.1        pk  *    may be used to endorse or promote products derived from this software
     55   1.1        pk  *    without specific prior written permission.
     56   1.1        pk  *
     57   1.1        pk  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     58   1.1        pk  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     59   1.1        pk  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     60   1.1        pk  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     61   1.1        pk  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     62   1.1        pk  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     63   1.1        pk  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     64   1.1        pk  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     65   1.1        pk  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     66   1.1        pk  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     67   1.1        pk  * SUCH DAMAGE.
     68   1.1        pk  *
     69   1.1        pk  *	@(#)bwtwo.c	8.1 (Berkeley) 6/11/93
     70   1.1        pk  */
     71   1.1        pk 
     72   1.1        pk /*
     73   1.1        pk  * black & white display (bwtwo) driver.
     74   1.1        pk  *
     75   1.1        pk  * Does not handle interrupts, even though they can occur.
     76   1.1        pk  *
     77  1.12    keihan  * P4 and overlay plane support by Jason R. Thorpe <thorpej (at) NetBSD.org>.
     78   1.1        pk  * Overlay plane handling hints and ideas provided by Brad Spencer.
     79   1.1        pk  */
     80   1.4     lukem 
     81   1.4     lukem #include <sys/cdefs.h>
     82  1.20       jdc __KERNEL_RCSID(0, "$NetBSD: bwtwo.c,v 1.21 2009/01/01 13:53:07 jdc Exp $");
     83   1.1        pk 
     84   1.1        pk #include <sys/param.h>
     85   1.1        pk #include <sys/systm.h>
     86   1.1        pk #include <sys/device.h>
     87   1.1        pk #include <sys/ioctl.h>
     88   1.1        pk #include <sys/malloc.h>
     89   1.1        pk #include <sys/mman.h>
     90   1.1        pk #include <sys/tty.h>
     91   1.1        pk #include <sys/conf.h>
     92   1.1        pk 
     93   1.1        pk #include <machine/autoconf.h>
     94   1.1        pk #include <machine/eeprom.h>
     95   1.1        pk 
     96   1.2        pk #include <dev/sun/fbio.h>
     97   1.2        pk #include <dev/sun/fbvar.h>
     98  1.19       jdc 
     99  1.19       jdc #include "wsdisplay.h"
    100  1.19       jdc #if NWSDISPLAY > 0
    101  1.19       jdc #include <dev/wscons/wsconsio.h>
    102  1.19       jdc #include <dev/wsfont/wsfont.h>
    103  1.19       jdc #include <dev/rasops/rasops.h>
    104  1.19       jdc #include <dev/wscons/wsdisplay_vconsvar.h>
    105  1.19       jdc 
    106  1.19       jdc #include "opt_wsemul.h"
    107  1.19       jdc #endif
    108  1.19       jdc 
    109   1.1        pk #include <dev/sun/btreg.h>
    110   1.1        pk #include <dev/sun/bwtworeg.h>
    111   1.1        pk #include <dev/sun/bwtwovar.h>
    112   1.1        pk #include <dev/sun/pfourreg.h>
    113   1.1        pk 
    114   1.5   gehenna extern struct cfdriver bwtwo_cd;
    115   1.1        pk 
    116   1.5   gehenna dev_type_open(bwtwoopen);
    117   1.5   gehenna dev_type_ioctl(bwtwoioctl);
    118   1.5   gehenna dev_type_mmap(bwtwommap);
    119   1.5   gehenna 
    120   1.5   gehenna const struct cdevsw bwtwo_cdevsw = {
    121   1.5   gehenna 	bwtwoopen, nullclose, noread, nowrite, bwtwoioctl,
    122   1.6  jdolecek 	nostop, notty, nopoll, bwtwommap, nokqfilter,
    123   1.5   gehenna };
    124   1.1        pk 
    125   1.1        pk /* XXX we do not handle frame buffer interrupts (do not know how) */
    126   1.1        pk static void	bwtwounblank(struct device *);
    127   1.1        pk 
    128   1.1        pk /* frame buffer generic driver */
    129   1.1        pk static struct fbdriver bwtwofbdriver = {
    130   1.6  jdolecek 	bwtwounblank, bwtwoopen, nullclose, bwtwoioctl, nopoll, bwtwommap,
    131   1.6  jdolecek 	nokqfilter
    132   1.1        pk };
    133   1.1        pk 
    134  1.19       jdc #if NWSDISPLAY > 0
    135  1.19       jdc #ifdef RASTERCONSOLE
    136  1.19       jdc #error RASTERCONSOLE and wsdisplay are mutually exclusive
    137  1.19       jdc #endif
    138  1.19       jdc 
    139  1.19       jdc struct wsscreen_descr bwtwo_defaultscreen = {
    140  1.19       jdc 	"std",
    141  1.19       jdc 	0, 0,	/* will be filled in -- XXX shouldn't, it's global */
    142  1.19       jdc 	NULL,		/* textops */
    143  1.19       jdc 	8, 16,	/* font width/height */
    144  1.19       jdc 	0,	/* capabilities */
    145  1.19       jdc 	NULL	/* modecookie */
    146  1.19       jdc };
    147  1.19       jdc 
    148  1.19       jdc static int 	bwtwo_ioctl(void *, void *, u_long, void *, int, struct lwp *);
    149  1.19       jdc static paddr_t	bwtwo_mmap(void *, void *, off_t, int);
    150  1.19       jdc static void	bwtwo_init_screen(void *, struct vcons_screen *, int, long *);
    151  1.19       jdc 
    152  1.19       jdc struct wsdisplay_accessops bwtwo_accessops = {
    153  1.19       jdc 	bwtwo_ioctl,
    154  1.19       jdc 	bwtwo_mmap,
    155  1.19       jdc 	NULL,	/* alloc_screen */
    156  1.19       jdc 	NULL,	/* free_screen */
    157  1.19       jdc 	NULL,	/* show_screen */
    158  1.19       jdc 	NULL, 	/* load_font */
    159  1.19       jdc 	NULL,	/* pollc */
    160  1.19       jdc 	NULL	/* scroll */
    161  1.19       jdc };
    162  1.19       jdc 
    163  1.19       jdc const struct wsscreen_descr *_bwtwo_scrlist[] = {
    164  1.19       jdc 	&bwtwo_defaultscreen
    165  1.19       jdc };
    166  1.19       jdc 
    167  1.19       jdc struct wsscreen_list bwtwo_screenlist = {
    168  1.19       jdc 	sizeof(_bwtwo_scrlist) / sizeof(struct wsscreen_descr *),
    169  1.19       jdc 	_bwtwo_scrlist
    170  1.19       jdc };
    171  1.19       jdc 
    172  1.19       jdc 
    173  1.19       jdc static struct vcons_screen bw2_console_screen;
    174  1.19       jdc #endif /* NWSDISPLAY > 0 */
    175  1.19       jdc 
    176   1.1        pk int
    177   1.1        pk bwtwo_pfour_probe(vaddr, arg)
    178   1.1        pk 	void *vaddr;
    179   1.1        pk 	void *arg;
    180   1.1        pk {
    181   1.1        pk 	struct cfdata *cf = arg;
    182   1.1        pk 
    183   1.1        pk 	switch (fb_pfour_id(vaddr)) {
    184   1.1        pk 	case PFOUR_ID_BW:
    185   1.1        pk 	case PFOUR_ID_COLOR8P1:		/* bwtwo in ... */
    186   1.1        pk 	case PFOUR_ID_COLOR24:		/* ...overlay plane */
    187   1.1        pk 		/* This is wrong; should be done in bwtwo_attach() */
    188   1.1        pk 		cf->cf_flags |= FB_PFOUR;
    189   1.1        pk 		/* FALLTHROUGH */
    190   1.1        pk 	case PFOUR_NOTPFOUR:
    191   1.1        pk 		return (1);
    192   1.1        pk 	}
    193   1.1        pk 	return (0);
    194   1.1        pk }
    195   1.1        pk 
    196   1.1        pk void
    197   1.1        pk bwtwoattach(sc, name, isconsole)
    198   1.1        pk 	struct	bwtwo_softc *sc;
    199  1.13   tsutsui 	const char *name;
    200   1.1        pk 	int	isconsole;
    201   1.1        pk {
    202   1.1        pk 	struct fbdevice *fb = &sc->sc_fb;
    203  1.19       jdc 	int isoverlay;
    204  1.19       jdc #if NWSDISPLAY > 0
    205  1.19       jdc 	struct wsemuldisplaydev_attach_args aa;
    206  1.19       jdc 	struct rasops_info *ri = &bw2_console_screen.scr_ri;
    207  1.19       jdc 	unsigned long defattr;
    208  1.19       jdc #endif
    209   1.1        pk 
    210   1.1        pk 	/* Fill in the remaining fbdevice values */
    211   1.1        pk 	fb->fb_driver = &bwtwofbdriver;
    212   1.1        pk 	fb->fb_device = &sc->sc_dev;
    213   1.1        pk 	fb->fb_type.fb_type = FBTYPE_SUN2BW;
    214   1.1        pk 	fb->fb_type.fb_cmsize = 0;
    215   1.1        pk 	fb->fb_type.fb_size = fb->fb_type.fb_height * fb->fb_linebytes;
    216   1.1        pk 	printf(": %s, %d x %d", name,
    217   1.1        pk 	       fb->fb_type.fb_width, fb->fb_type.fb_height);
    218   1.1        pk 
    219  1.19       jdc 	/* Are we an overlay bw2? */
    220  1.19       jdc 	if ((fb->fb_flags & FB_PFOUR) == 0 || (sc->sc_ovtype == BWO_NONE))
    221  1.19       jdc 		isoverlay = 0;
    222  1.19       jdc 	else
    223  1.19       jdc 		isoverlay = 1;
    224  1.19       jdc 
    225   1.1        pk 	/* Insure video is enabled */
    226   1.1        pk 	sc->sc_set_video(sc, 1);
    227   1.1        pk 
    228   1.1        pk 	if (isconsole) {
    229   1.1        pk 		printf(" (console)\n");
    230   1.1        pk #ifdef RASTERCONSOLE
    231   1.1        pk 		/*
    232   1.1        pk 		 * XXX rcons doesn't seem to work properly on the overlay
    233   1.1        pk 		 * XXX plane.  This is a temporary kludge until someone
    234   1.1        pk 		 * XXX fixes it.
    235   1.1        pk 		 */
    236  1.19       jdc 		if (!isoverlay)
    237   1.1        pk 			fbrcons_init(fb);
    238   1.1        pk #endif
    239   1.1        pk 	} else
    240   1.1        pk 		printf("\n");
    241   1.1        pk 
    242  1.19       jdc 	if (isoverlay) {
    243  1.13   tsutsui 		const char *ovnam;
    244   1.1        pk 
    245   1.1        pk 		switch (sc->sc_ovtype) {
    246   1.1        pk 		case BWO_CGFOUR:
    247   1.1        pk 			ovnam = "cgfour";
    248   1.1        pk 			break;
    249   1.1        pk 
    250   1.1        pk 		case BWO_CGEIGHT:
    251   1.1        pk 			ovnam = "cgeight";
    252   1.1        pk 			break;
    253   1.1        pk 
    254   1.1        pk 		default:
    255   1.1        pk 			ovnam = "unknown";
    256   1.1        pk 			break;
    257   1.1        pk 		}
    258  1.16    cegger 		printf("%s: %s overlay plane\n", device_xname(&sc->sc_dev), ovnam);
    259   1.1        pk 	}
    260   1.1        pk 
    261   1.1        pk 	/*
    262   1.1        pk 	 * If we're on an overlay plane of a color framebuffer,
    263   1.1        pk 	 * then we don't force the issue in fb_attach() because
    264   1.1        pk 	 * we'd like the color framebuffer to actually be the
    265   1.1        pk 	 * "console framebuffer".  We're only around to speed
    266   1.1        pk 	 * up rconsole.
    267   1.1        pk 	 */
    268  1.19       jdc 	if (isoverlay)
    269   1.1        pk 		fb_attach(fb, 0);
    270   1.1        pk 	else
    271   1.1        pk 		fb_attach(fb, isconsole);
    272  1.19       jdc 
    273  1.19       jdc #if NWSDISPLAY > 0
    274  1.19       jdc 	sc->sc_width = fb->fb_type.fb_width;
    275  1.19       jdc 	sc->sc_stride = fb->fb_type.fb_width/8;
    276  1.19       jdc 	sc->sc_height = fb->fb_type.fb_height;
    277  1.19       jdc 
    278  1.19       jdc 	/* setup rasops and so on for wsdisplay */
    279  1.19       jdc 	sc->sc_mode = WSDISPLAYIO_MODE_EMUL;
    280  1.19       jdc 
    281  1.19       jdc 	vcons_init(&sc->vd, sc, &bwtwo_defaultscreen, &bwtwo_accessops);
    282  1.19       jdc 	sc->vd.init_screen = bwtwo_init_screen;
    283  1.19       jdc 
    284  1.19       jdc 	if(isconsole && !isoverlay) {
    285  1.19       jdc 		/* we mess with bw2_console_screen only once */
    286  1.19       jdc 		vcons_init_screen(&sc->vd, &bw2_console_screen, 1,
    287  1.19       jdc 		    &defattr);
    288  1.19       jdc 		bw2_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
    289  1.21       jdc 
    290  1.19       jdc 		bwtwo_defaultscreen.textops = &ri->ri_ops;
    291  1.19       jdc 		bwtwo_defaultscreen.capabilities = ri->ri_caps;
    292  1.19       jdc 		bwtwo_defaultscreen.nrows = ri->ri_rows;
    293  1.19       jdc 		bwtwo_defaultscreen.ncols = ri->ri_cols;
    294  1.19       jdc 		sc->vd.active = &bw2_console_screen;
    295  1.21       jdc 		wsdisplay_cnattach(&bwtwo_defaultscreen, ri, 0, 0, defattr);
    296  1.19       jdc 	} else {
    297  1.19       jdc 		/*
    298  1.19       jdc 		 * we're not the console so we just clear the screen and don't
    299  1.19       jdc 		 * set up any sort of text display
    300  1.19       jdc 		 */
    301  1.19       jdc 		if (bwtwo_defaultscreen.textops == NULL) {
    302  1.19       jdc 			/*
    303  1.19       jdc 			 * ugly, but...
    304  1.19       jdc 			 * we want the console settings to win, so we only
    305  1.19       jdc 			 * touch anything when we find an untouched screen
    306  1.19       jdc 			 * definition. In this case we fill it from fb to
    307  1.19       jdc 			 * avoid problems in case no bwtwo is the console
    308  1.19       jdc 			 */
    309  1.19       jdc 			ri = &sc->sc_fb.fb_rinfo;
    310  1.19       jdc 			bwtwo_defaultscreen.textops = &ri->ri_ops;
    311  1.19       jdc 			bwtwo_defaultscreen.capabilities = ri->ri_caps;
    312  1.19       jdc 			bwtwo_defaultscreen.nrows = ri->ri_rows;
    313  1.19       jdc 			bwtwo_defaultscreen.ncols = ri->ri_cols;
    314  1.19       jdc 		}
    315  1.19       jdc 	}
    316  1.19       jdc 
    317  1.19       jdc 	aa.scrdata = &bwtwo_screenlist;
    318  1.19       jdc 	if (isoverlay)
    319  1.19       jdc 		aa.console = 0;
    320  1.19       jdc 	else
    321  1.19       jdc 		aa.console = isconsole;
    322  1.19       jdc 	aa.accessops = &bwtwo_accessops;
    323  1.19       jdc 	aa.accesscookie = &sc->vd;
    324  1.19       jdc 	config_found(&sc->sc_dev, &aa, wsemuldisplaydevprint);
    325  1.19       jdc #endif
    326  1.19       jdc 
    327   1.1        pk }
    328   1.1        pk 
    329   1.1        pk int
    330  1.14  christos bwtwoopen(dev, flags, mode, l)
    331   1.1        pk 	dev_t dev;
    332   1.1        pk 	int flags, mode;
    333  1.14  christos 	struct lwp *l;
    334   1.1        pk {
    335   1.1        pk 	int unit = minor(dev);
    336   1.1        pk 
    337  1.18  drochner 	if (device_lookup(&bwtwo_cd, unit) == NULL)
    338   1.1        pk 		return (ENXIO);
    339   1.1        pk 
    340   1.1        pk 	return (0);
    341   1.1        pk }
    342   1.1        pk 
    343   1.1        pk int
    344  1.14  christos bwtwoioctl(dev, cmd, data, flags, l)
    345   1.1        pk 	dev_t dev;
    346   1.1        pk 	u_long cmd;
    347  1.15  christos 	void *data;
    348   1.1        pk 	int flags;
    349  1.14  christos 	struct lwp *l;
    350   1.1        pk {
    351  1.18  drochner 	struct bwtwo_softc *sc = device_lookup_private(&bwtwo_cd, minor(dev));
    352   1.1        pk 
    353   1.1        pk 	switch (cmd) {
    354   1.1        pk 
    355   1.1        pk 	case FBIOGTYPE:
    356   1.1        pk 		*(struct fbtype *)data = sc->sc_fb.fb_type;
    357   1.1        pk 		break;
    358   1.1        pk 
    359   1.1        pk 	case FBIOGVIDEO:
    360   1.1        pk 		*(int *)data = sc->sc_get_video(sc);
    361   1.1        pk 		break;
    362   1.1        pk 
    363   1.1        pk 	case FBIOSVIDEO:
    364   1.1        pk 		sc->sc_set_video(sc, (*(int *)data));
    365   1.1        pk 		break;
    366   1.1        pk 
    367   1.1        pk 	default:
    368   1.1        pk 		return (ENOTTY);
    369   1.1        pk 	}
    370   1.1        pk 	return (0);
    371   1.1        pk }
    372   1.1        pk 
    373   1.1        pk static void
    374   1.1        pk bwtwounblank(dev)
    375   1.1        pk 	struct device *dev;
    376   1.1        pk {
    377  1.18  drochner 	struct bwtwo_softc *sc = device_private(dev);
    378   1.1        pk 
    379   1.1        pk 	sc->sc_set_video(sc, 1);
    380   1.1        pk }
    381   1.1        pk 
    382   1.1        pk /*
    383   1.1        pk  * Return the address that would map the given device at the given
    384   1.1        pk  * offset, allowing for the given protection, or return -1 for error.
    385   1.1        pk  */
    386   1.1        pk paddr_t
    387   1.1        pk bwtwommap(dev, off, prot)
    388   1.1        pk 	dev_t dev;
    389   1.1        pk 	off_t off;
    390   1.1        pk 	int prot;
    391   1.1        pk {
    392  1.18  drochner 	struct bwtwo_softc *sc = device_lookup_private(&bwtwo_cd, minor(dev));
    393   1.1        pk 
    394   1.1        pk 	if (off & PGOFSET)
    395   1.1        pk 		panic("bwtwommap");
    396   1.1        pk 
    397   1.1        pk 	if (off >= sc->sc_fb.fb_type.fb_size)
    398   1.1        pk 		return (-1);
    399   1.1        pk 
    400   1.3       eeh 	return (bus_space_mmap(sc->sc_bustag,
    401   1.3       eeh 		sc->sc_paddr, sc->sc_pixeloffset + off,
    402   1.3       eeh 		prot, BUS_SPACE_MAP_LINEAR));
    403   1.1        pk }
    404  1.19       jdc 
    405  1.19       jdc #if NWSDISPLAY > 0
    406  1.19       jdc 
    407  1.19       jdc int
    408  1.19       jdc bwtwo_ioctl(void *v, void *vs, u_long cmd, void *data, int flag,
    409  1.19       jdc 	struct lwp *l)
    410  1.19       jdc {
    411  1.19       jdc 	/* we'll probably need to add more stuff here */
    412  1.19       jdc 	struct vcons_data *vd = v;
    413  1.19       jdc 	struct bwtwo_softc *sc = vd->cookie;
    414  1.19       jdc 	struct wsdisplay_fbinfo *wdf;
    415  1.19       jdc 	struct rasops_info *ri = &sc->sc_fb.fb_rinfo;
    416  1.19       jdc 	struct vcons_screen *ms = sc->vd.active;
    417  1.19       jdc 	switch (cmd) {
    418  1.19       jdc 		case WSDISPLAYIO_GTYPE:
    419  1.19       jdc 			*(u_int *)data = WSDISPLAY_TYPE_GENFB;
    420  1.19       jdc 			return 0;
    421  1.19       jdc 		case WSDISPLAYIO_GINFO:
    422  1.19       jdc 			wdf = (void *)data;
    423  1.19       jdc 			wdf->height = ri->ri_height;
    424  1.19       jdc 			wdf->width = ri->ri_width;
    425  1.19       jdc 			wdf->depth = ri->ri_depth;
    426  1.19       jdc 			wdf->cmsize = 0;
    427  1.19       jdc 			return 0;
    428  1.19       jdc 
    429  1.19       jdc 		case WSDISPLAYIO_GETCMAP:
    430  1.19       jdc 			return EINVAL;
    431  1.19       jdc 		case WSDISPLAYIO_PUTCMAP:
    432  1.19       jdc 			return EINVAL;
    433  1.19       jdc 
    434  1.19       jdc 		case WSDISPLAYIO_SMODE:
    435  1.19       jdc 			{
    436  1.19       jdc 				int new_mode = *(int*)data;
    437  1.19       jdc 				if (new_mode != sc->sc_mode)
    438  1.19       jdc 				{
    439  1.19       jdc 					sc->sc_mode = new_mode;
    440  1.19       jdc 					if(new_mode == WSDISPLAYIO_MODE_EMUL)
    441  1.19       jdc 					{
    442  1.19       jdc 						vcons_redraw_screen(ms);
    443  1.19       jdc 					}
    444  1.19       jdc 				}
    445  1.19       jdc 			}
    446  1.19       jdc 	}
    447  1.19       jdc 	return EPASSTHROUGH;
    448  1.19       jdc }
    449  1.19       jdc 
    450  1.19       jdc paddr_t
    451  1.19       jdc bwtwo_mmap(void *v, void *vs, off_t offset, int prot)
    452  1.19       jdc {
    453  1.19       jdc 	/* I'm not at all sure this is the right thing to do */
    454  1.19       jdc 	return bwtwommap(0, offset, prot); /* assume minor dev 0 for now */
    455  1.19       jdc }
    456  1.19       jdc 
    457  1.19       jdc void
    458  1.19       jdc bwtwo_init_screen(void *cookie, struct vcons_screen *scr,
    459  1.19       jdc     int existing, long *defattr)
    460  1.19       jdc {
    461  1.19       jdc 	struct bwtwo_softc *sc = cookie;
    462  1.19       jdc 	struct rasops_info *ri = &scr->scr_ri;
    463  1.19       jdc 
    464  1.19       jdc 	ri->ri_depth = 1;
    465  1.19       jdc 	ri->ri_width = sc->sc_width;
    466  1.19       jdc 	ri->ri_height = sc->sc_height;
    467  1.19       jdc 	ri->ri_stride = sc->sc_stride;
    468  1.21       jdc 	ri->ri_flg = RI_CENTER;
    469  1.19       jdc 
    470  1.19       jdc 	ri->ri_bits = sc->sc_fb.fb_pixels;
    471  1.21       jdc 
    472  1.21       jdc 	memset(sc->sc_fb.fb_pixels, (*defattr >> 16) & 0xff,
    473  1.21       jdc 	    sc->sc_stride * sc->sc_height);
    474  1.19       jdc 	rasops_init(ri, sc->sc_height/8, sc->sc_width/8);
    475  1.19       jdc 	ri->ri_caps = 0;
    476  1.19       jdc 	rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight,
    477  1.19       jdc 		    sc->sc_width / ri->ri_font->fontwidth);
    478  1.19       jdc 
    479  1.19       jdc 	ri->ri_hw = scr;
    480  1.19       jdc }
    481  1.19       jdc 
    482  1.19       jdc #endif /* NWSDISPLAY > 0 */
    483