Home | History | Annotate | Line # | Download | only in isa
pcdisplay.c revision 1.33.20.1
      1  1.33.20.1    bouyer /* $NetBSD: pcdisplay.c,v 1.33.20.1 2007/10/25 22:38:23 bouyer Exp $ */
      2        1.1  drochner 
      3        1.1  drochner /*
      4        1.1  drochner  * Copyright (c) 1998
      5        1.1  drochner  *	Matthias Drochner.  All rights reserved.
      6        1.1  drochner  *
      7        1.1  drochner  * Redistribution and use in source and binary forms, with or without
      8        1.1  drochner  * modification, are permitted provided that the following conditions
      9        1.1  drochner  * are met:
     10        1.1  drochner  * 1. Redistributions of source code must retain the above copyright
     11        1.1  drochner  *    notice, this list of conditions and the following disclaimer.
     12        1.1  drochner  * 2. Redistributions in binary form must reproduce the above copyright
     13        1.1  drochner  *    notice, this list of conditions and the following disclaimer in the
     14        1.1  drochner  *    documentation and/or other materials provided with the distribution.
     15        1.1  drochner  *
     16        1.1  drochner  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17        1.1  drochner  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18        1.1  drochner  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19        1.1  drochner  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20        1.1  drochner  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     21        1.1  drochner  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22        1.1  drochner  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23        1.1  drochner  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24        1.1  drochner  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     25        1.1  drochner  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26        1.1  drochner  *
     27        1.1  drochner  */
     28       1.12     lukem 
     29       1.12     lukem #include <sys/cdefs.h>
     30  1.33.20.1    bouyer __KERNEL_RCSID(0, "$NetBSD: pcdisplay.c,v 1.33.20.1 2007/10/25 22:38:23 bouyer Exp $");
     31        1.1  drochner 
     32        1.1  drochner #include <sys/param.h>
     33        1.1  drochner #include <sys/systm.h>
     34        1.1  drochner #include <sys/kernel.h>
     35        1.1  drochner #include <sys/device.h>
     36        1.1  drochner #include <sys/malloc.h>
     37  1.33.20.1    bouyer #include <sys/bus.h>
     38        1.1  drochner 
     39        1.1  drochner #include <dev/isa/isavar.h>
     40        1.1  drochner 
     41        1.1  drochner #include <dev/ic/mc6845reg.h>
     42        1.1  drochner #include <dev/ic/pcdisplayvar.h>
     43        1.1  drochner #include <dev/isa/pcdisplayvar.h>
     44        1.1  drochner 
     45        1.1  drochner #include <dev/ic/pcdisplay.h>
     46        1.1  drochner 
     47        1.1  drochner #include <dev/wscons/wsconsio.h>
     48        1.1  drochner #include <dev/wscons/wsdisplayvar.h>
     49        1.1  drochner 
     50       1.11   thorpej #include "pcweasel.h"
     51       1.11   thorpej #if NPCWEASEL > 0
     52       1.11   thorpej #include <dev/isa/weaselreg.h>
     53       1.11   thorpej #include <dev/isa/weaselvar.h>
     54       1.11   thorpej #endif
     55       1.11   thorpej 
     56        1.1  drochner struct pcdisplay_config {
     57        1.1  drochner 	struct pcdisplayscreen pcs;
     58        1.1  drochner 	struct pcdisplay_handle dc_ph;
     59        1.1  drochner 	int mono;
     60        1.1  drochner };
     61        1.1  drochner 
     62        1.1  drochner struct pcdisplay_softc {
     63        1.1  drochner 	struct device sc_dev;
     64        1.1  drochner 	struct pcdisplay_config *sc_dc;
     65        1.1  drochner 	int nscreens;
     66       1.11   thorpej #if NPCWEASEL > 0
     67       1.11   thorpej 	struct weasel_handle sc_weasel;
     68       1.11   thorpej #endif
     69        1.1  drochner };
     70        1.1  drochner 
     71        1.1  drochner static int pcdisplayconsole, pcdisplay_console_attached;
     72        1.1  drochner static struct pcdisplay_config pcdisplay_console_dc;
     73        1.1  drochner 
     74       1.27     perry int	pcdisplay_match(struct device *, struct cfdata *, void *);
     75       1.27     perry void	pcdisplay_attach(struct device *, struct device *, void *);
     76        1.1  drochner 
     77       1.27     perry static int pcdisplay_is_console(bus_space_tag_t);
     78       1.27     perry static int pcdisplay_probe_col(bus_space_tag_t, bus_space_tag_t);
     79       1.27     perry static int pcdisplay_probe_mono(bus_space_tag_t, bus_space_tag_t);
     80       1.27     perry static void pcdisplay_init(struct pcdisplay_config *,
     81        1.1  drochner 			     bus_space_tag_t, bus_space_tag_t,
     82       1.27     perry 			     int);
     83       1.27     perry static int pcdisplay_allocattr(void *, int, int, int, long *);
     84        1.1  drochner 
     85       1.21   thorpej CFATTACH_DECL(pcdisplay, sizeof(struct pcdisplay_softc),
     86       1.22   thorpej     pcdisplay_match, pcdisplay_attach, NULL, NULL);
     87        1.1  drochner 
     88        1.1  drochner const struct wsdisplay_emulops pcdisplay_emulops = {
     89        1.1  drochner 	pcdisplay_cursor,
     90        1.3  drochner 	pcdisplay_mapchar,
     91        1.2  drochner 	pcdisplay_putchar,
     92        1.1  drochner 	pcdisplay_copycols,
     93        1.1  drochner 	pcdisplay_erasecols,
     94        1.1  drochner 	pcdisplay_copyrows,
     95        1.1  drochner 	pcdisplay_eraserows,
     96       1.30  christos 	pcdisplay_allocattr,
     97       1.30  christos 	NULL,	/* replaceattr */
     98        1.1  drochner };
     99        1.1  drochner 
    100        1.1  drochner const struct wsscreen_descr pcdisplay_scr = {
    101        1.1  drochner 	"80x25", 80, 25,
    102        1.1  drochner 	&pcdisplay_emulops,
    103        1.1  drochner 	0, 0, /* no font support */
    104       1.30  christos 	WSSCREEN_REVERSE, /* that's minimal... */
    105       1.30  christos 	NULL, /* modecookie */
    106        1.1  drochner };
    107        1.1  drochner 
    108        1.1  drochner const struct wsscreen_descr *_pcdisplay_scrlist[] = {
    109        1.1  drochner 	&pcdisplay_scr,
    110        1.1  drochner };
    111        1.1  drochner 
    112        1.1  drochner const struct wsscreen_list pcdisplay_screenlist = {
    113        1.1  drochner 	sizeof(_pcdisplay_scrlist) / sizeof(struct wsscreen_descr *),
    114        1.1  drochner 	_pcdisplay_scrlist
    115        1.1  drochner };
    116        1.1  drochner 
    117       1.33  christos static int pcdisplay_ioctl(void *, void *, u_long, void *, int, struct lwp *);
    118       1.29      jmmv static paddr_t pcdisplay_mmap(void *, void *, off_t, int);
    119       1.27     perry static int pcdisplay_alloc_screen(void *, const struct wsscreen_descr *,
    120       1.27     perry 				       void **, int *, int *, long *);
    121       1.27     perry static void pcdisplay_free_screen(void *, void *);
    122       1.27     perry static int pcdisplay_show_screen(void *, void *, int,
    123       1.27     perry 				      void (*) (void *, int, int), void *);
    124        1.1  drochner 
    125        1.1  drochner const struct wsdisplay_accessops pcdisplay_accessops = {
    126        1.1  drochner 	pcdisplay_ioctl,
    127        1.1  drochner 	pcdisplay_mmap,
    128        1.1  drochner 	pcdisplay_alloc_screen,
    129        1.1  drochner 	pcdisplay_free_screen,
    130        1.1  drochner 	pcdisplay_show_screen,
    131       1.30  christos 	NULL, /* load_font */
    132       1.30  christos 	NULL, /* pollc */
    133       1.30  christos 	NULL, /* scroll */
    134        1.1  drochner };
    135        1.1  drochner 
    136        1.1  drochner static int
    137        1.1  drochner pcdisplay_probe_col(iot, memt)
    138        1.1  drochner 	bus_space_tag_t iot, memt;
    139        1.1  drochner {
    140        1.1  drochner 	bus_space_handle_t memh, ioh_6845;
    141        1.1  drochner 	u_int16_t oldval, val;
    142        1.1  drochner 
    143        1.1  drochner 	if (bus_space_map(memt, 0xb8000, 0x8000, 0, &memh))
    144        1.1  drochner 		return (0);
    145        1.1  drochner 	oldval = bus_space_read_2(memt, memh, 0);
    146        1.1  drochner 	bus_space_write_2(memt, memh, 0, 0xa55a);
    147        1.1  drochner 	val = bus_space_read_2(memt, memh, 0);
    148        1.1  drochner 	bus_space_write_2(memt, memh, 0, oldval);
    149        1.1  drochner 	bus_space_unmap(memt, memh, 0x8000);
    150        1.1  drochner 	if (val != 0xa55a)
    151        1.1  drochner 		return (0);
    152        1.1  drochner 
    153        1.1  drochner 	if (bus_space_map(iot, 0x3d0, 0x10, 0, &ioh_6845))
    154        1.1  drochner 		return (0);
    155        1.1  drochner 	bus_space_unmap(iot, ioh_6845, 0x10);
    156        1.1  drochner 
    157        1.1  drochner 	return (1);
    158        1.1  drochner }
    159        1.1  drochner 
    160        1.1  drochner static int
    161        1.1  drochner pcdisplay_probe_mono(iot, memt)
    162        1.1  drochner 	bus_space_tag_t iot, memt;
    163        1.1  drochner {
    164        1.1  drochner 	bus_space_handle_t memh, ioh_6845;
    165        1.1  drochner 	u_int16_t oldval, val;
    166        1.1  drochner 
    167        1.1  drochner 	if (bus_space_map(memt, 0xb0000, 0x8000, 0, &memh))
    168        1.1  drochner 		return (0);
    169        1.1  drochner 	oldval = bus_space_read_2(memt, memh, 0);
    170        1.1  drochner 	bus_space_write_2(memt, memh, 0, 0xa55a);
    171        1.1  drochner 	val = bus_space_read_2(memt, memh, 0);
    172        1.1  drochner 	bus_space_write_2(memt, memh, 0, oldval);
    173        1.1  drochner 	bus_space_unmap(memt, memh, 0x8000);
    174        1.1  drochner 	if (val != 0xa55a)
    175        1.1  drochner 		return (0);
    176        1.1  drochner 
    177        1.1  drochner 	if (bus_space_map(iot, 0x3b0, 0x10, 0, &ioh_6845))
    178        1.1  drochner 		return (0);
    179        1.1  drochner 	bus_space_unmap(iot, ioh_6845, 0x10);
    180        1.1  drochner 
    181        1.1  drochner 	return (1);
    182        1.1  drochner }
    183        1.1  drochner 
    184        1.1  drochner static void
    185        1.1  drochner pcdisplay_init(dc, iot, memt, mono)
    186        1.1  drochner 	struct pcdisplay_config *dc;
    187        1.1  drochner 	bus_space_tag_t iot, memt;
    188        1.1  drochner 	int mono;
    189        1.1  drochner {
    190        1.1  drochner 	struct pcdisplay_handle *ph = &dc->dc_ph;
    191        1.1  drochner 	int cpos;
    192        1.1  drochner 
    193        1.1  drochner         ph->ph_iot = iot;
    194        1.1  drochner         ph->ph_memt = memt;
    195        1.1  drochner 	dc->mono = mono;
    196        1.1  drochner 
    197        1.1  drochner 	if (bus_space_map(memt, mono ? 0xb0000 : 0xb8000, 0x8000,
    198        1.1  drochner 			  0, &ph->ph_memh))
    199        1.1  drochner 		panic("pcdisplay_init: cannot map memory");
    200        1.1  drochner 	if (bus_space_map(iot, mono ? 0x3b0 : 0x3d0, 0x10,
    201        1.1  drochner 			  0, &ph->ph_ioh_6845))
    202        1.1  drochner 		panic("pcdisplay_init: cannot map io");
    203        1.1  drochner 
    204        1.1  drochner 	/*
    205        1.1  drochner 	 * initialize the only screen
    206        1.1  drochner 	 */
    207        1.1  drochner 	dc->pcs.hdl = ph;
    208        1.1  drochner 	dc->pcs.type = &pcdisplay_scr;
    209        1.1  drochner 	dc->pcs.active = 1;
    210        1.1  drochner 	dc->pcs.mem = NULL;
    211        1.1  drochner 
    212        1.1  drochner 	cpos = pcdisplay_6845_read(ph, cursorh) << 8;
    213        1.1  drochner 	cpos |= pcdisplay_6845_read(ph, cursorl);
    214        1.1  drochner 
    215        1.1  drochner 	/* make sure we have a valid cursor position */
    216        1.1  drochner 	if (cpos < 0 || cpos >= pcdisplay_scr.nrows * pcdisplay_scr.ncols)
    217        1.1  drochner 		cpos = 0;
    218        1.4  drochner 
    219        1.4  drochner 	dc->pcs.dispoffset = 0;
    220        1.1  drochner 
    221       1.19  junyoung 	dc->pcs.cursorrow = cpos / pcdisplay_scr.ncols;
    222       1.19  junyoung 	dc->pcs.cursorcol = cpos % pcdisplay_scr.ncols;
    223        1.9        ad 	pcdisplay_cursor_init(&dc->pcs, 1);
    224        1.1  drochner }
    225        1.1  drochner 
    226        1.1  drochner int
    227       1.32  christos pcdisplay_match(struct device *parent, struct cfdata *match,
    228       1.31  christos     void *aux)
    229        1.1  drochner {
    230        1.1  drochner 	struct isa_attach_args *ia = aux;
    231        1.1  drochner 	int mono;
    232        1.1  drochner 
    233       1.16   thorpej 	if (ISA_DIRECT_CONFIG(ia))
    234       1.16   thorpej 		return (0);
    235       1.16   thorpej 
    236        1.1  drochner 	/* If values are hardwired to something that they can't be, punt. */
    237       1.16   thorpej 	if (ia->ia_nio < 1 ||
    238       1.26  drochner 	    (ia->ia_io[0].ir_addr != ISA_UNKNOWN_PORT &&
    239       1.16   thorpej 	     ia->ia_io[0].ir_addr != 0x3d0 &&
    240       1.16   thorpej 	     ia->ia_io[0].ir_addr != 0x3b0))
    241       1.16   thorpej 		return (0);
    242       1.16   thorpej 
    243       1.16   thorpej 	if (ia->ia_niomem < 1 ||
    244       1.26  drochner 	    (ia->ia_iomem[0].ir_addr != ISA_UNKNOWN_IOMEM &&
    245       1.16   thorpej 	     ia->ia_iomem[0].ir_addr != 0xb8000 &&
    246       1.16   thorpej 	     ia->ia_iomem[0].ir_addr != 0xb0000))
    247       1.16   thorpej 		return (0);
    248       1.16   thorpej 	if (ia->ia_iomem[0].ir_size != 0 &&
    249       1.16   thorpej 	    ia->ia_iomem[0].ir_size != 0x8000)
    250       1.16   thorpej 		return (0);
    251       1.16   thorpej 
    252       1.16   thorpej 	if (ia->ia_nirq > 0 &&
    253       1.26  drochner 	    ia->ia_irq[0].ir_irq != ISA_UNKNOWN_IRQ)
    254       1.16   thorpej 		return (0);
    255       1.16   thorpej 
    256       1.16   thorpej 	if (ia->ia_ndrq > 0 &&
    257       1.26  drochner 	    ia->ia_drq[0].ir_drq != ISA_UNKNOWN_DRQ)
    258        1.1  drochner 		return (0);
    259        1.1  drochner 
    260        1.1  drochner 	if (pcdisplay_is_console(ia->ia_iot))
    261        1.1  drochner 		mono = pcdisplay_console_dc.mono;
    262       1.16   thorpej 	else if (ia->ia_io[0].ir_addr != 0x3b0 &&
    263       1.16   thorpej 		 ia->ia_iomem[0].ir_addr != 0xb0000 &&
    264        1.1  drochner 		 pcdisplay_probe_col(ia->ia_iot, ia->ia_memt))
    265        1.1  drochner 		mono = 0;
    266       1.16   thorpej 	else if (ia->ia_io[0].ir_addr != 0x3d0 &&
    267       1.16   thorpej 		 ia->ia_iomem[0].ir_addr != 0xb8000 &&
    268        1.1  drochner 		 pcdisplay_probe_mono(ia->ia_iot, ia->ia_memt))
    269        1.1  drochner 		mono = 1;
    270        1.1  drochner 	else
    271        1.1  drochner 		return (0);
    272        1.1  drochner 
    273       1.16   thorpej 	ia->ia_nio = 1;
    274       1.16   thorpej 	ia->ia_io[0].ir_addr = mono ? 0x3b0 : 0x3d0;
    275       1.16   thorpej 	ia->ia_io[0].ir_size = 0x10;
    276       1.16   thorpej 
    277       1.16   thorpej 	ia->ia_niomem = 1;
    278       1.16   thorpej 	ia->ia_iomem[0].ir_size = mono ? 0xb0000 : 0xb8000;
    279       1.16   thorpej 	ia->ia_iomem[0].ir_size = 0x8000;
    280       1.16   thorpej 
    281       1.16   thorpej 	ia->ia_nirq = 0;
    282       1.16   thorpej 	ia->ia_ndrq = 0;
    283       1.16   thorpej 
    284        1.1  drochner 	return (1);
    285        1.1  drochner }
    286        1.1  drochner 
    287        1.1  drochner void
    288       1.32  christos pcdisplay_attach(struct device *parent, struct device *self, void *aux)
    289        1.1  drochner {
    290        1.1  drochner 	struct isa_attach_args *ia = aux;
    291        1.1  drochner 	struct pcdisplay_softc *sc = (struct pcdisplay_softc *)self;
    292        1.1  drochner 	int console;
    293        1.1  drochner 	struct pcdisplay_config *dc;
    294        1.1  drochner 	struct wsemuldisplaydev_attach_args aa;
    295        1.1  drochner 
    296        1.1  drochner 	printf("\n");
    297        1.1  drochner 
    298        1.1  drochner 	console = pcdisplay_is_console(ia->ia_iot);
    299        1.1  drochner 
    300        1.1  drochner 	if (console) {
    301        1.1  drochner 		dc = &pcdisplay_console_dc;
    302        1.1  drochner 		sc->nscreens = 1;
    303        1.1  drochner 		pcdisplay_console_attached = 1;
    304        1.1  drochner 	} else {
    305        1.1  drochner 		dc = malloc(sizeof(struct pcdisplay_config),
    306        1.1  drochner 			    M_DEVBUF, M_WAITOK);
    307       1.16   thorpej 		if (ia->ia_io[0].ir_addr != 0x3b0 &&
    308       1.16   thorpej 		    ia->ia_iomem[0].ir_addr != 0xb0000 &&
    309        1.1  drochner 		    pcdisplay_probe_col(ia->ia_iot, ia->ia_memt))
    310        1.1  drochner 			pcdisplay_init(dc, ia->ia_iot, ia->ia_memt, 0);
    311       1.16   thorpej 		else if (ia->ia_io[0].ir_addr != 0x3d0 &&
    312       1.16   thorpej 			 ia->ia_iomem[0].ir_addr != 0xb8000 &&
    313        1.1  drochner 			 pcdisplay_probe_mono(ia->ia_iot, ia->ia_memt))
    314        1.1  drochner 			pcdisplay_init(dc, ia->ia_iot, ia->ia_memt, 1);
    315        1.1  drochner 		else
    316        1.1  drochner 			panic("pcdisplay_attach: display disappeared");
    317        1.1  drochner 	}
    318        1.1  drochner 	sc->sc_dc = dc;
    319       1.11   thorpej 
    320       1.11   thorpej #if NPCWEASEL > 0
    321       1.11   thorpej 	/*
    322       1.11   thorpej 	 * If the display is monochrome, check to see if we have
    323       1.11   thorpej 	 * a PC-Weasel, and initialize its special features.
    324       1.11   thorpej 	 */
    325       1.11   thorpej 	if (dc->mono) {
    326       1.11   thorpej 		sc->sc_weasel.wh_st = dc->dc_ph.ph_memt;
    327       1.11   thorpej 		sc->sc_weasel.wh_sh = dc->dc_ph.ph_memh;
    328       1.11   thorpej 		sc->sc_weasel.wh_parent = &sc->sc_dev;
    329       1.15   thorpej 		weasel_isa_init(&sc->sc_weasel);
    330       1.11   thorpej 	}
    331       1.11   thorpej #endif /* NPCWEASEL > 0 */
    332        1.1  drochner 
    333        1.1  drochner 	aa.console = console;
    334        1.1  drochner 	aa.scrdata = &pcdisplay_screenlist;
    335        1.1  drochner 	aa.accessops = &pcdisplay_accessops;
    336        1.1  drochner 	aa.accesscookie = sc;
    337        1.1  drochner 
    338        1.1  drochner         config_found(self, &aa, wsemuldisplaydevprint);
    339        1.1  drochner }
    340        1.1  drochner 
    341        1.1  drochner 
    342        1.1  drochner int
    343        1.1  drochner pcdisplay_cnattach(iot, memt)
    344        1.1  drochner 	bus_space_tag_t iot, memt;
    345        1.1  drochner {
    346        1.1  drochner 	int mono;
    347        1.1  drochner 
    348        1.1  drochner 	if (pcdisplay_probe_col(iot, memt))
    349        1.1  drochner 		mono = 0;
    350        1.1  drochner 	else if (pcdisplay_probe_mono(iot, memt))
    351        1.1  drochner 		mono = 1;
    352        1.1  drochner 	else
    353        1.1  drochner 		return (ENXIO);
    354        1.1  drochner 
    355        1.1  drochner 	pcdisplay_init(&pcdisplay_console_dc, iot, memt, mono);
    356        1.1  drochner 
    357        1.1  drochner 	wsdisplay_cnattach(&pcdisplay_scr, &pcdisplay_console_dc,
    358       1.19  junyoung 			   pcdisplay_console_dc.pcs.cursorcol,
    359       1.19  junyoung 			   pcdisplay_console_dc.pcs.cursorrow,
    360        1.1  drochner 			   FG_LIGHTGREY | BG_BLACK);
    361        1.1  drochner 
    362        1.1  drochner 	pcdisplayconsole = 1;
    363        1.1  drochner 	return (0);
    364        1.1  drochner }
    365        1.1  drochner 
    366        1.1  drochner static int
    367        1.1  drochner pcdisplay_is_console(iot)
    368        1.1  drochner 	bus_space_tag_t iot;
    369        1.1  drochner {
    370        1.1  drochner 	if (pcdisplayconsole &&
    371        1.1  drochner 	    !pcdisplay_console_attached &&
    372        1.1  drochner 	    iot == pcdisplay_console_dc.dc_ph.ph_iot)
    373        1.1  drochner 		return (1);
    374        1.1  drochner 	return (0);
    375        1.1  drochner }
    376        1.1  drochner 
    377        1.1  drochner static int
    378       1.32  christos pcdisplay_ioctl(void *v, void *vs, u_long cmd,
    379       1.33  christos     void *data, int flag, struct lwp *l)
    380        1.1  drochner {
    381        1.1  drochner 	/*
    382        1.1  drochner 	 * XXX "do something!"
    383        1.1  drochner 	 */
    384       1.17    atatat 	return (EPASSTHROUGH);
    385        1.1  drochner }
    386        1.1  drochner 
    387       1.10    simonb static paddr_t
    388       1.32  christos pcdisplay_mmap(void *v, void *vs, off_t offset,
    389       1.32  christos     int prot)
    390        1.1  drochner {
    391        1.1  drochner 	return (-1);
    392        1.1  drochner }
    393        1.1  drochner 
    394        1.1  drochner static int
    395       1.32  christos pcdisplay_alloc_screen(void *v, const struct wsscreen_descr *type,
    396       1.31  christos     void **cookiep, int *curxp, int *curyp, long *defattrp)
    397        1.1  drochner {
    398        1.1  drochner 	struct pcdisplay_softc *sc = v;
    399        1.1  drochner 
    400        1.1  drochner 	if (sc->nscreens > 0)
    401        1.1  drochner 		return (ENOMEM);
    402        1.1  drochner 
    403        1.1  drochner 	*cookiep = sc->sc_dc;
    404        1.1  drochner 	*curxp = 0;
    405        1.1  drochner 	*curyp = 0;
    406        1.1  drochner 	*defattrp = FG_LIGHTGREY | BG_BLACK;
    407        1.1  drochner 	sc->nscreens++;
    408        1.1  drochner 	return (0);
    409        1.1  drochner }
    410        1.1  drochner 
    411        1.1  drochner static void
    412       1.32  christos pcdisplay_free_screen(void *v, void *cookie)
    413        1.1  drochner {
    414        1.1  drochner 	struct pcdisplay_softc *sc = v;
    415        1.1  drochner 
    416        1.1  drochner 	if (sc->sc_dc == &pcdisplay_console_dc)
    417        1.1  drochner 		panic("pcdisplay_free_screen: console");
    418        1.1  drochner 
    419        1.1  drochner 	sc->nscreens--;
    420        1.1  drochner }
    421        1.1  drochner 
    422        1.7  drochner static int
    423       1.32  christos pcdisplay_show_screen(void *v, void *cookie,
    424       1.32  christos     int waitok, void (*cb)(void *, int, int),
    425       1.32  christos     void *cbarg)
    426        1.1  drochner {
    427        1.1  drochner #ifdef DIAGNOSTIC
    428        1.1  drochner 	struct pcdisplay_softc *sc = v;
    429        1.1  drochner 
    430        1.1  drochner 	if (cookie != sc->sc_dc)
    431        1.1  drochner 		panic("pcdisplay_show_screen: bad screen");
    432        1.1  drochner #endif
    433        1.7  drochner 	return (0);
    434        1.1  drochner }
    435        1.1  drochner 
    436        1.1  drochner static int
    437       1.32  christos pcdisplay_allocattr(void *id, int fg, int bg,
    438       1.31  christos     int flags, long *attrp)
    439        1.1  drochner {
    440        1.1  drochner 	if (flags & WSATTR_REVERSE)
    441        1.1  drochner 		*attrp = FG_BLACK | BG_LIGHTGREY;
    442        1.1  drochner 	else
    443        1.1  drochner 		*attrp = FG_LIGHTGREY | BG_BLACK;
    444        1.1  drochner 	return (0);
    445        1.1  drochner }
    446