Home | History | Annotate | Line # | Download | only in dev
grf_compat.c revision 1.7.8.2
      1  1.7.8.2  nathanw /*	$NetBSD: grf_compat.c,v 1.7.8.2 2002/09/17 21:15:24 nathanw Exp $	*/
      2  1.7.8.2  nathanw 
      3  1.7.8.2  nathanw /*
      4  1.7.8.2  nathanw  * Copyright (C) 1999 Scott Reynolds
      5  1.7.8.2  nathanw  * All rights reserved.
      6  1.7.8.2  nathanw  *
      7  1.7.8.2  nathanw  * Redistribution and use in source and binary forms, with or without
      8  1.7.8.2  nathanw  * modification, are permitted provided that the following conditions
      9  1.7.8.2  nathanw  * are met:
     10  1.7.8.2  nathanw  * 1. Redistributions of source code must retain the above copyright
     11  1.7.8.2  nathanw  *    notice, this list of conditions and the following disclaimer.
     12  1.7.8.2  nathanw  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.7.8.2  nathanw  *    notice, this list of conditions and the following disclaimer in the
     14  1.7.8.2  nathanw  *    documentation and/or other materials provided with the distribution.
     15  1.7.8.2  nathanw  * 3. The name of the author may not be used to endorse or promote products
     16  1.7.8.2  nathanw  *    derived from this software without specific prior written permission.
     17  1.7.8.2  nathanw  *
     18  1.7.8.2  nathanw  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19  1.7.8.2  nathanw  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20  1.7.8.2  nathanw  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21  1.7.8.2  nathanw  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22  1.7.8.2  nathanw  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23  1.7.8.2  nathanw  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24  1.7.8.2  nathanw  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25  1.7.8.2  nathanw  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26  1.7.8.2  nathanw  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27  1.7.8.2  nathanw  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28  1.7.8.2  nathanw  */
     29  1.7.8.2  nathanw 
     30  1.7.8.2  nathanw /*
     31  1.7.8.2  nathanw  * macfb compatibility with legacy grf devices
     32  1.7.8.2  nathanw  */
     33  1.7.8.2  nathanw 
     34  1.7.8.2  nathanw #include <sys/param.h>
     35  1.7.8.2  nathanw #include <sys/systm.h>
     36  1.7.8.2  nathanw #include <sys/cdefs.h>
     37  1.7.8.2  nathanw #include <sys/conf.h>
     38  1.7.8.2  nathanw #include <sys/device.h>
     39  1.7.8.2  nathanw #include <sys/errno.h>
     40  1.7.8.2  nathanw #include <sys/ioctl.h>
     41  1.7.8.2  nathanw #include <sys/malloc.h>
     42  1.7.8.2  nathanw #include <sys/mman.h>
     43  1.7.8.2  nathanw #include <sys/proc.h>
     44  1.7.8.2  nathanw #include <sys/resourcevar.h>
     45  1.7.8.2  nathanw #include <sys/vnode.h>
     46  1.7.8.2  nathanw 
     47  1.7.8.2  nathanw #include <machine/autoconf.h>
     48  1.7.8.2  nathanw #include <machine/bus.h>
     49  1.7.8.2  nathanw #include <machine/grfioctl.h>
     50  1.7.8.2  nathanw 
     51  1.7.8.2  nathanw #include <mac68k/nubus/nubus.h>
     52  1.7.8.2  nathanw #include <mac68k/dev/grfvar.h>
     53  1.7.8.2  nathanw #include <mac68k/dev/macfbvar.h>
     54  1.7.8.2  nathanw 
     55  1.7.8.2  nathanw #include <miscfs/specfs/specdev.h>
     56  1.7.8.2  nathanw 
     57  1.7.8.2  nathanw #include <uvm/uvm_extern.h>
     58  1.7.8.2  nathanw #include <uvm/uvm_map.h>
     59  1.7.8.2  nathanw 
     60  1.7.8.2  nathanw dev_type_open(grfopen);
     61  1.7.8.2  nathanw dev_type_close(grfclose);
     62  1.7.8.2  nathanw dev_type_ioctl(grfioctl);
     63  1.7.8.2  nathanw dev_type_poll(grfpoll);
     64  1.7.8.2  nathanw dev_type_mmap(grfmmap);
     65  1.7.8.2  nathanw 
     66  1.7.8.2  nathanw const struct cdevsw grf_cdevsw = {
     67  1.7.8.2  nathanw 	grfopen, grfclose, noread, nowrite, grfioctl,
     68  1.7.8.2  nathanw 	nostop, notty, grfpoll, grfmmap,
     69  1.7.8.2  nathanw };
     70  1.7.8.2  nathanw 
     71  1.7.8.2  nathanw void	grf_scinit __P((struct grf_softc *, const char *, int));
     72  1.7.8.2  nathanw void	grf_init __P((int));
     73  1.7.8.2  nathanw void	grfattach __P((int));
     74  1.7.8.2  nathanw int	grfmap __P((dev_t, struct macfb_softc *, caddr_t *, struct proc *));
     75  1.7.8.2  nathanw int	grfunmap __P((dev_t, struct macfb_softc *, caddr_t, struct proc *));
     76  1.7.8.2  nathanw 
     77  1.7.8.2  nathanw /* Non-private for the benefit of libkvm. */
     78  1.7.8.2  nathanw struct	grf_softc *grf_softc;
     79  1.7.8.2  nathanw int	numgrf = 0;
     80  1.7.8.2  nathanw 
     81  1.7.8.2  nathanw /*
     82  1.7.8.2  nathanw  * Initialize a softc to sane defaults.
     83  1.7.8.2  nathanw  */
     84  1.7.8.2  nathanw void
     85  1.7.8.2  nathanw grf_scinit(sc, name, unit)
     86  1.7.8.2  nathanw 	struct grf_softc *sc;
     87  1.7.8.2  nathanw 	const char *name;
     88  1.7.8.2  nathanw 	int unit;
     89  1.7.8.2  nathanw {
     90  1.7.8.2  nathanw 	memset(sc, 0, sizeof(struct grf_softc));
     91  1.7.8.2  nathanw 	snprintf(sc->sc_xname, sizeof(sc->sc_xname), "%s%d", name, unit);
     92  1.7.8.2  nathanw 	sc->mfb_sc = NULL;
     93  1.7.8.2  nathanw }
     94  1.7.8.2  nathanw 
     95  1.7.8.2  nathanw /*
     96  1.7.8.2  nathanw  * (Re-)initialize the grf_softc block so that at least the requested
     97  1.7.8.2  nathanw  * number of elements has been allocated.  If this results in more
     98  1.7.8.2  nathanw  * elements than we had prior to getting here, we initialize each of
     99  1.7.8.2  nathanw  * them to avoid problems down the road.
    100  1.7.8.2  nathanw  */
    101  1.7.8.2  nathanw void
    102  1.7.8.2  nathanw grf_init(n)
    103  1.7.8.2  nathanw 	int n;
    104  1.7.8.2  nathanw {
    105  1.7.8.2  nathanw 	struct grf_softc *sc;
    106  1.7.8.2  nathanw 	int i;
    107  1.7.8.2  nathanw 
    108  1.7.8.2  nathanw 	if (n >= numgrf) {
    109  1.7.8.2  nathanw 		i = numgrf;
    110  1.7.8.2  nathanw 		numgrf = n + 1;
    111  1.7.8.2  nathanw 
    112  1.7.8.2  nathanw 		if (grf_softc == NULL)
    113  1.7.8.2  nathanw 			sc = (struct grf_softc *)
    114  1.7.8.2  nathanw 			    malloc(numgrf * sizeof(*sc),
    115  1.7.8.2  nathanw 			    M_DEVBUF, M_NOWAIT);
    116  1.7.8.2  nathanw 		else
    117  1.7.8.2  nathanw 			sc = (struct grf_softc *)
    118  1.7.8.2  nathanw 			    realloc(grf_softc, numgrf * sizeof(*sc),
    119  1.7.8.2  nathanw 			    M_DEVBUF, M_NOWAIT);
    120  1.7.8.2  nathanw 		if (sc == NULL) {
    121  1.7.8.2  nathanw 			printf("WARNING: no memory for grf emulation\n");
    122  1.7.8.2  nathanw 			if (grf_softc != NULL)
    123  1.7.8.2  nathanw 				free(grf_softc, M_DEVBUF);
    124  1.7.8.2  nathanw 			return;
    125  1.7.8.2  nathanw 		}
    126  1.7.8.2  nathanw 		grf_softc = sc;
    127  1.7.8.2  nathanw 
    128  1.7.8.2  nathanw 		/* Initialize per-softc structures. */
    129  1.7.8.2  nathanw 		while (i < numgrf) {
    130  1.7.8.2  nathanw 			grf_scinit(&grf_softc[i], "grf", i);
    131  1.7.8.2  nathanw 			i++;
    132  1.7.8.2  nathanw 		}
    133  1.7.8.2  nathanw 	}
    134  1.7.8.2  nathanw }
    135  1.7.8.2  nathanw 
    136  1.7.8.2  nathanw /*
    137  1.7.8.2  nathanw  * Called by main() during pseudo-device attachment.  If we had a
    138  1.7.8.2  nathanw  * way to configure additional grf devices later, this would actually
    139  1.7.8.2  nathanw  * allocate enough space for them.  As it stands, it's nonsensical,
    140  1.7.8.2  nathanw  * so other than a basic sanity check we do nothing.
    141  1.7.8.2  nathanw  */
    142  1.7.8.2  nathanw void
    143  1.7.8.2  nathanw grfattach(n)
    144  1.7.8.2  nathanw 	int n;
    145  1.7.8.2  nathanw {
    146  1.7.8.2  nathanw 	if (n <= 0) {
    147  1.7.8.2  nathanw #ifdef DIAGNOSTIC
    148  1.7.8.2  nathanw 		panic("grfattach: count <= 0");
    149  1.7.8.2  nathanw #endif
    150  1.7.8.2  nathanw 		return;
    151  1.7.8.2  nathanw 	}
    152  1.7.8.2  nathanw 
    153  1.7.8.2  nathanw #if 0 /* XXX someday, if we implement a way to attach after autoconfig */
    154  1.7.8.2  nathanw 	grf_init(n);
    155  1.7.8.2  nathanw #endif
    156  1.7.8.2  nathanw }
    157  1.7.8.2  nathanw 
    158  1.7.8.2  nathanw /*
    159  1.7.8.2  nathanw  * Called from macfb_attach() after setting up the frame buffer.  Since
    160  1.7.8.2  nathanw  * there is a 1:1 correspondence between the macfb device and the grf
    161  1.7.8.2  nathanw  * device, the only bit of information we really need is the macfb_softc.
    162  1.7.8.2  nathanw  */
    163  1.7.8.2  nathanw void
    164  1.7.8.2  nathanw grf_attach(sc, unit)
    165  1.7.8.2  nathanw 	struct macfb_softc *sc;
    166  1.7.8.2  nathanw 	int unit;
    167  1.7.8.2  nathanw {
    168  1.7.8.2  nathanw 	grf_init(unit);
    169  1.7.8.2  nathanw 
    170  1.7.8.2  nathanw 	if (unit < numgrf)
    171  1.7.8.2  nathanw 		grf_softc[unit].mfb_sc = sc;
    172  1.7.8.2  nathanw }
    173  1.7.8.2  nathanw 
    174  1.7.8.2  nathanw /*
    175  1.7.8.2  nathanw  * Standard device ops
    176  1.7.8.2  nathanw  */
    177  1.7.8.2  nathanw int
    178  1.7.8.2  nathanw grfopen(dev, flag, mode, p)
    179  1.7.8.2  nathanw 	dev_t dev;
    180  1.7.8.2  nathanw 	int flag;
    181  1.7.8.2  nathanw 	int mode;
    182  1.7.8.2  nathanw 	struct proc *p;
    183  1.7.8.2  nathanw {
    184  1.7.8.2  nathanw 	struct grf_softc *sc;
    185  1.7.8.2  nathanw 	int unit = GRFUNIT(dev);
    186  1.7.8.2  nathanw 	int rv = 0;
    187  1.7.8.2  nathanw 
    188  1.7.8.2  nathanw 	if (grf_softc == NULL || unit >= numgrf)
    189  1.7.8.2  nathanw 		return ENXIO;
    190  1.7.8.2  nathanw 
    191  1.7.8.2  nathanw 	sc = &grf_softc[unit];
    192  1.7.8.2  nathanw 	if (sc->mfb_sc == NULL)
    193  1.7.8.2  nathanw 		rv = ENXIO;
    194  1.7.8.2  nathanw 
    195  1.7.8.2  nathanw 	return rv;
    196  1.7.8.2  nathanw }
    197  1.7.8.2  nathanw 
    198  1.7.8.2  nathanw int
    199  1.7.8.2  nathanw grfclose(dev, flag, mode, p)
    200  1.7.8.2  nathanw 	dev_t dev;
    201  1.7.8.2  nathanw 	int flag;
    202  1.7.8.2  nathanw 	int mode;
    203  1.7.8.2  nathanw 	struct proc *p;
    204  1.7.8.2  nathanw {
    205  1.7.8.2  nathanw 	struct grf_softc *sc;
    206  1.7.8.2  nathanw 	int unit = GRFUNIT(dev);
    207  1.7.8.2  nathanw 	int rv = 0;
    208  1.7.8.2  nathanw 
    209  1.7.8.2  nathanw 	if (grf_softc == NULL || unit >= numgrf)
    210  1.7.8.2  nathanw 		return ENXIO;
    211  1.7.8.2  nathanw 
    212  1.7.8.2  nathanw 	sc = &grf_softc[unit];
    213  1.7.8.2  nathanw 	if (sc->mfb_sc != NULL)
    214  1.7.8.2  nathanw 		macfb_clear(sc->mfb_sc->sc_dc);	/* clear the display */
    215  1.7.8.2  nathanw 	else
    216  1.7.8.2  nathanw 		rv = ENXIO;
    217  1.7.8.2  nathanw 
    218  1.7.8.2  nathanw 	return rv;
    219  1.7.8.2  nathanw }
    220  1.7.8.2  nathanw 
    221  1.7.8.2  nathanw int
    222  1.7.8.2  nathanw grfioctl(dev, cmd, data, flag, p)
    223  1.7.8.2  nathanw 	dev_t dev;
    224  1.7.8.2  nathanw 	u_long cmd;
    225  1.7.8.2  nathanw 	caddr_t data;
    226  1.7.8.2  nathanw 	int flag;
    227  1.7.8.2  nathanw 	struct proc *p;
    228  1.7.8.2  nathanw {
    229  1.7.8.2  nathanw 	struct grf_softc *sc;
    230  1.7.8.2  nathanw 	struct macfb_devconfig *dc;
    231  1.7.8.2  nathanw #if defined(GRF_COMPAT) || (NGRF > 0)
    232  1.7.8.2  nathanw 	struct grfinfo *gd;
    233  1.7.8.2  nathanw #endif /* GRF_COMPAT || (NGRF > 0) */
    234  1.7.8.2  nathanw 	struct grfmode *gm;
    235  1.7.8.2  nathanw 	int unit = GRFUNIT(dev);
    236  1.7.8.2  nathanw 	int rv;
    237  1.7.8.2  nathanw 
    238  1.7.8.2  nathanw 	if (grf_softc == NULL || unit >= numgrf)
    239  1.7.8.2  nathanw 		return ENXIO;
    240  1.7.8.2  nathanw 
    241  1.7.8.2  nathanw 	sc = &grf_softc[unit];
    242  1.7.8.2  nathanw 	if (sc->mfb_sc == NULL)
    243  1.7.8.2  nathanw 		return ENXIO;
    244  1.7.8.2  nathanw 
    245  1.7.8.2  nathanw 	dc = sc->mfb_sc->sc_dc;
    246  1.7.8.2  nathanw 
    247  1.7.8.2  nathanw 	switch (cmd) {
    248  1.7.8.2  nathanw #if defined(GRF_COMPAT) || (NGRF > 0)
    249  1.7.8.2  nathanw 	case GRFIOCGINFO:
    250  1.7.8.2  nathanw 		gd = (struct grfinfo *)data;
    251  1.7.8.2  nathanw 		memset(gd, 0, sizeof(struct grfinfo));
    252  1.7.8.2  nathanw 		gd->gd_fbaddr     = (caddr_t)dc->dc_paddr;
    253  1.7.8.2  nathanw 		gd->gd_fbsize     = dc->dc_size;
    254  1.7.8.2  nathanw 		gd->gd_colors     = (short)(1 << dc->dc_depth);
    255  1.7.8.2  nathanw 		gd->gd_planes     = (short)dc->dc_depth;
    256  1.7.8.2  nathanw 		gd->gd_fbwidth    = dc->dc_wid;
    257  1.7.8.2  nathanw 		gd->gd_fbheight   = dc->dc_ht;
    258  1.7.8.2  nathanw 		gd->gd_fbrowbytes = dc->dc_rowbytes;
    259  1.7.8.2  nathanw 		gd->gd_dwidth     = dc->dc_raster.width;
    260  1.7.8.2  nathanw 		gd->gd_dheight    = dc->dc_raster.height;
    261  1.7.8.2  nathanw 		rv = 0;
    262  1.7.8.2  nathanw 		break;
    263  1.7.8.2  nathanw #endif /* GRF_COMPAT || (NGRF > 0) */
    264  1.7.8.2  nathanw 
    265  1.7.8.2  nathanw 	case GRFIOCON:
    266  1.7.8.2  nathanw 	case GRFIOCOFF:
    267  1.7.8.2  nathanw 		/* Nothing to do */
    268  1.7.8.2  nathanw 		rv = 0;
    269  1.7.8.2  nathanw 		break;
    270  1.7.8.2  nathanw 
    271  1.7.8.2  nathanw #if defined(GRF_COMPAT) || (NGRF > 0)
    272  1.7.8.2  nathanw 	case GRFIOCMAP:
    273  1.7.8.2  nathanw 		rv = grfmap(dev, sc->mfb_sc, (caddr_t *)data, p);
    274  1.7.8.2  nathanw 		break;
    275  1.7.8.2  nathanw 
    276  1.7.8.2  nathanw 	case GRFIOCUNMAP:
    277  1.7.8.2  nathanw 		rv = grfunmap(dev, sc->mfb_sc, *(caddr_t *)data, p);
    278  1.7.8.2  nathanw 		break;
    279  1.7.8.2  nathanw #endif /* GRF_COMPAT || (NGRF > 0) */
    280  1.7.8.2  nathanw 
    281  1.7.8.2  nathanw 	case GRFIOCGMODE:
    282  1.7.8.2  nathanw 		gm = (struct grfmode *)data;
    283  1.7.8.2  nathanw 		memset(gm, 0, sizeof(struct grfmode));
    284  1.7.8.2  nathanw 		gm->fbbase   = (char *)dc->dc_vaddr;
    285  1.7.8.2  nathanw 		gm->fbsize   = dc->dc_size;
    286  1.7.8.2  nathanw 		gm->fboff    = dc->dc_offset;
    287  1.7.8.2  nathanw 		gm->rowbytes = dc->dc_rowbytes;
    288  1.7.8.2  nathanw 		gm->width    = dc->dc_wid;
    289  1.7.8.2  nathanw 		gm->height   = dc->dc_ht;
    290  1.7.8.2  nathanw 		gm->psize    = dc->dc_depth;
    291  1.7.8.2  nathanw 		rv = 0;
    292  1.7.8.2  nathanw 		break;
    293  1.7.8.2  nathanw 
    294  1.7.8.2  nathanw 	case GRFIOCLISTMODES:
    295  1.7.8.2  nathanw 	case GRFIOCGETMODE:
    296  1.7.8.2  nathanw 	case GRFIOCSETMODE:
    297  1.7.8.2  nathanw 		/* NONE of these operations are (officially) supported. */
    298  1.7.8.2  nathanw 	default:
    299  1.7.8.2  nathanw 		rv = EINVAL;
    300  1.7.8.2  nathanw 		break;
    301  1.7.8.2  nathanw 	}
    302  1.7.8.2  nathanw 	return rv;
    303  1.7.8.2  nathanw }
    304  1.7.8.2  nathanw 
    305  1.7.8.2  nathanw int
    306  1.7.8.2  nathanw grfpoll(dev, events, p)
    307  1.7.8.2  nathanw 	dev_t dev;
    308  1.7.8.2  nathanw 	int events;
    309  1.7.8.2  nathanw 	struct proc *p;
    310  1.7.8.2  nathanw {
    311  1.7.8.2  nathanw 	return EINVAL;
    312  1.7.8.2  nathanw }
    313  1.7.8.2  nathanw 
    314  1.7.8.2  nathanw paddr_t
    315  1.7.8.2  nathanw grfmmap(dev, off, prot)
    316  1.7.8.2  nathanw 	dev_t dev;
    317  1.7.8.2  nathanw 	off_t off;
    318  1.7.8.2  nathanw 	int prot;
    319  1.7.8.2  nathanw {
    320  1.7.8.2  nathanw 	struct grf_softc *sc;
    321  1.7.8.2  nathanw 	struct macfb_devconfig *dc;
    322  1.7.8.2  nathanw 	paddr_t addr;
    323  1.7.8.2  nathanw 	int unit = GRFUNIT(dev);
    324  1.7.8.2  nathanw 
    325  1.7.8.2  nathanw 	if (grf_softc == NULL || unit >= numgrf)
    326  1.7.8.2  nathanw 		return ENXIO;
    327  1.7.8.2  nathanw 
    328  1.7.8.2  nathanw 	sc = &grf_softc[unit];
    329  1.7.8.2  nathanw 	if (sc->mfb_sc == NULL)
    330  1.7.8.2  nathanw 		return ENXIO;
    331  1.7.8.2  nathanw 
    332  1.7.8.2  nathanw 	dc = sc->mfb_sc->sc_dc;
    333  1.7.8.2  nathanw 
    334  1.7.8.2  nathanw 	if (off >= 0 &&
    335  1.7.8.2  nathanw 	    off < m68k_round_page(dc->dc_offset + dc->dc_size))
    336  1.7.8.2  nathanw 		addr = m68k_btop(dc->dc_paddr + off);
    337  1.7.8.2  nathanw 	else
    338  1.7.8.2  nathanw 		addr = (-1);	/* XXX bogus */
    339  1.7.8.2  nathanw 
    340  1.7.8.2  nathanw 	return addr;
    341  1.7.8.2  nathanw }
    342  1.7.8.2  nathanw 
    343  1.7.8.2  nathanw int
    344  1.7.8.2  nathanw grfmap(dev, sc, addrp, p)
    345  1.7.8.2  nathanw 	dev_t dev;
    346  1.7.8.2  nathanw 	struct macfb_softc *sc;
    347  1.7.8.2  nathanw 	caddr_t *addrp;
    348  1.7.8.2  nathanw 	struct proc *p;
    349  1.7.8.2  nathanw {
    350  1.7.8.2  nathanw 	struct specinfo si;
    351  1.7.8.2  nathanw 	struct vnode vn;
    352  1.7.8.2  nathanw 	u_long len;
    353  1.7.8.2  nathanw 	int error, flags;
    354  1.7.8.2  nathanw 
    355  1.7.8.2  nathanw 	*addrp = (caddr_t)sc->sc_dc->dc_paddr;
    356  1.7.8.2  nathanw 	len = m68k_round_page(sc->sc_dc->dc_offset + sc->sc_dc->dc_size);
    357  1.7.8.2  nathanw 	flags = MAP_SHARED | MAP_FIXED;
    358  1.7.8.2  nathanw 
    359  1.7.8.2  nathanw 	vn.v_type = VCHR;		/* XXX */
    360  1.7.8.2  nathanw 	vn.v_specinfo = &si;		/* XXX */
    361  1.7.8.2  nathanw 	vn.v_rdev = dev;		/* XXX */
    362  1.7.8.2  nathanw 
    363  1.7.8.2  nathanw 	error = uvm_mmap(&p->p_vmspace->vm_map, (vaddr_t *)addrp,
    364  1.7.8.2  nathanw 	    (vsize_t)len, VM_PROT_ALL, VM_PROT_ALL,
    365  1.7.8.2  nathanw 	    flags, (caddr_t)&vn, 0, p->p_rlimit[RLIMIT_MEMLOCK].rlim_cur);
    366  1.7.8.2  nathanw 
    367  1.7.8.2  nathanw 	/* Offset into page: */
    368  1.7.8.2  nathanw 	*addrp += sc->sc_dc->dc_offset;
    369  1.7.8.2  nathanw 
    370  1.7.8.2  nathanw 	return (error);
    371  1.7.8.2  nathanw }
    372  1.7.8.2  nathanw 
    373  1.7.8.2  nathanw int
    374  1.7.8.2  nathanw grfunmap(dev, sc, addr, p)
    375  1.7.8.2  nathanw 	dev_t dev;
    376  1.7.8.2  nathanw 	struct macfb_softc *sc;
    377  1.7.8.2  nathanw 	caddr_t addr;
    378  1.7.8.2  nathanw 	struct proc *p;
    379  1.7.8.2  nathanw {
    380  1.7.8.2  nathanw 	vm_size_t size;
    381  1.7.8.2  nathanw 
    382  1.7.8.2  nathanw 	addr -= sc->sc_dc->dc_offset;
    383  1.7.8.2  nathanw 
    384  1.7.8.2  nathanw 	if (addr <= 0)
    385  1.7.8.2  nathanw 		return (-1);
    386  1.7.8.2  nathanw 
    387  1.7.8.2  nathanw 	size = m68k_round_page(sc->sc_dc->dc_offset + sc->sc_dc->dc_size);
    388  1.7.8.2  nathanw 	uvm_unmap(&p->p_vmspace->vm_map, (vaddr_t)addr, (vaddr_t)addr + size);
    389  1.7.8.2  nathanw 	return 0;
    390  1.7.8.2  nathanw }
    391