1997-08-12 02:53:26 +04:00
|
|
|
/* $NetBSD: grf.c,v 1.45 1997/08/11 22:53:30 scottr Exp $ */
|
1994-10-26 11:45:48 +03:00
|
|
|
|
1993-09-29 09:08:37 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1988 University of Utah.
|
|
|
|
* Copyright (c) 1990 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* the Systems Programming Group of the University of Utah Computer
|
|
|
|
* Science Department.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* from: Utah $Hdr: grf.c 1.31 91/01/21$
|
|
|
|
*
|
1994-10-26 11:45:48 +03:00
|
|
|
* @(#)grf.c 7.8 (Berkeley) 5/7/91
|
1993-09-29 09:08:37 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
1994-07-31 12:32:47 +04:00
|
|
|
* Graphics display driver for the Macintosh.
|
1993-09-29 09:08:37 +03:00
|
|
|
* This is the hardware-independent portion of the driver.
|
|
|
|
* Hardware access is through the grfdev routines below.
|
|
|
|
*/
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
#include <sys/param.h>
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1994-01-30 04:15:31 +03:00
|
|
|
#include <sys/device.h>
|
1995-04-21 06:47:35 +04:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mman.h>
|
1996-09-14 09:54:53 +04:00
|
|
|
#include <sys/poll.h>
|
1995-04-21 06:47:35 +04:00
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/vnode.h>
|
1996-05-05 10:15:56 +04:00
|
|
|
#include <sys/systm.h>
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1997-02-20 03:23:25 +03:00
|
|
|
#include <machine/bus.h>
|
1994-01-30 04:15:31 +03:00
|
|
|
#include <machine/cpu.h>
|
1997-02-20 03:23:25 +03:00
|
|
|
#include <machine/grfioctl.h>
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
#include <miscfs/specfs/specdev.h>
|
|
|
|
|
1994-01-30 04:15:31 +03:00
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/vm_kern.h>
|
|
|
|
#include <vm/vm_page.h>
|
|
|
|
#include <vm/vm_pager.h>
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1997-08-12 02:53:26 +04:00
|
|
|
#include <mac68k/dev/nubus.h>
|
|
|
|
#include <mac68k/dev/itevar.h>
|
|
|
|
#include <mac68k/dev/grfvar.h>
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
#include "grf.h"
|
1993-09-29 09:08:37 +03:00
|
|
|
#include "ite.h"
|
1995-04-21 06:47:35 +04:00
|
|
|
|
1995-03-26 19:52:21 +04:00
|
|
|
#if NITE == 0
|
1993-09-29 09:08:37 +03:00
|
|
|
#define iteon(u,f)
|
|
|
|
#define iteoff(u,f)
|
1995-03-26 19:52:21 +04:00
|
|
|
#endif
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1996-12-16 19:17:02 +03:00
|
|
|
int grfmatch __P((struct device *, struct cfdata *, void *));
|
1996-05-20 02:27:04 +04:00
|
|
|
void grfattach __P((struct device *, struct device *, void *));
|
|
|
|
|
1996-03-17 04:26:49 +03:00
|
|
|
struct cfdriver grf_cd = {
|
|
|
|
NULL, "grf", DV_DULL
|
1993-09-29 09:08:37 +03:00
|
|
|
};
|
|
|
|
|
1996-05-20 02:27:04 +04:00
|
|
|
struct cfattach grf_ca = {
|
|
|
|
sizeof(struct grf_softc), grfmatch, grfattach
|
|
|
|
};
|
|
|
|
|
1993-09-29 09:08:37 +03:00
|
|
|
#ifdef DEBUG
|
1997-08-03 10:25:56 +04:00
|
|
|
#define GRF_DEBUG
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef GRF_DEBUG
|
1993-09-29 09:08:37 +03:00
|
|
|
#define GDB_DEVNO 0x01
|
|
|
|
#define GDB_MMAP 0x02
|
|
|
|
#define GDB_IOMAP 0x04
|
|
|
|
#define GDB_LOCK 0x08
|
1996-05-20 02:27:04 +04:00
|
|
|
static int grfdebug = (GDB_DEVNO|GDB_MMAP|GDB_IOMAP|GDB_LOCK);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int
|
1996-12-16 19:17:02 +03:00
|
|
|
grfmatch(parent, cf, aux)
|
1996-05-20 02:27:04 +04:00
|
|
|
struct device *parent;
|
1996-12-16 19:17:02 +03:00
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
1996-05-20 02:27:04 +04:00
|
|
|
{
|
|
|
|
struct grfbus_attach_args *ga = aux;
|
|
|
|
|
|
|
|
return (strcmp(ga->ga_name, "grf") == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
grfattach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct grf_softc *sc = (struct grf_softc *)self;
|
|
|
|
struct grfbus_attach_args *ga = aux;
|
|
|
|
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("\n");
|
1996-05-20 02:27:04 +04:00
|
|
|
|
|
|
|
/* Load forwarded pointers. */
|
|
|
|
sc->sc_grfmode = ga->ga_grfmode;
|
|
|
|
sc->sc_slot = ga->ga_slot;
|
1997-05-11 23:11:27 +04:00
|
|
|
sc->sc_tag = ga->ga_tag;
|
|
|
|
sc->sc_handle = ga->ga_handle;
|
1996-05-20 02:27:04 +04:00
|
|
|
sc->sc_mode = ga->ga_mode;
|
|
|
|
sc->sc_phys = ga->ga_phys;
|
|
|
|
|
|
|
|
sc->sc_flags = GF_ALIVE; /* XXX bogus */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attach ite semantics to the grf. Change the name, forward
|
|
|
|
* everything else.
|
|
|
|
*/
|
|
|
|
ga->ga_name = "ite";
|
|
|
|
(void)config_found(self, ga, grfbusprint);
|
|
|
|
}
|
1993-09-29 09:08:37 +03:00
|
|
|
|
|
|
|
/*ARGSUSED*/
|
1995-04-21 06:47:35 +04:00
|
|
|
int
|
|
|
|
grfopen(dev, flag, mode, p)
|
1993-09-29 09:08:37 +03:00
|
|
|
dev_t dev;
|
1995-04-21 06:47:35 +04:00
|
|
|
int flag;
|
|
|
|
int mode;
|
|
|
|
struct proc *p;
|
1993-09-29 09:08:37 +03:00
|
|
|
{
|
1995-04-21 06:47:35 +04:00
|
|
|
register struct grf_softc *gp;
|
|
|
|
int unit;
|
|
|
|
int error;
|
1994-07-31 12:32:47 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
unit = GRFUNIT(dev);
|
1996-03-17 04:26:49 +03:00
|
|
|
gp = grf_cd.cd_devs[unit];
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1996-05-20 02:27:04 +04:00
|
|
|
if (unit >= grf_cd.cd_ndevs || (gp->sc_flags & GF_ALIVE) == 0)
|
1995-04-21 06:47:35 +04:00
|
|
|
return (ENXIO);
|
|
|
|
|
1996-05-20 02:27:04 +04:00
|
|
|
if ((gp->sc_flags & (GF_OPEN | GF_EXCLUDE)) == (GF_OPEN | GF_EXCLUDE))
|
1995-04-21 06:47:35 +04:00
|
|
|
return (EBUSY);
|
|
|
|
|
1993-09-29 09:08:37 +03:00
|
|
|
/*
|
|
|
|
* First open.
|
|
|
|
* XXX: always put in graphics mode.
|
|
|
|
*/
|
|
|
|
error = 0;
|
1996-05-20 02:27:04 +04:00
|
|
|
if ((gp->sc_flags & GF_OPEN) == 0) {
|
|
|
|
gp->sc_flags |= GF_OPEN;
|
1993-09-29 09:08:37 +03:00
|
|
|
error = grfon(dev);
|
|
|
|
}
|
1995-04-21 06:47:35 +04:00
|
|
|
return (error);
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
1996-05-05 10:15:56 +04:00
|
|
|
int
|
1995-04-21 06:47:35 +04:00
|
|
|
grfclose(dev, flag, mode, p)
|
1993-09-29 09:08:37 +03:00
|
|
|
dev_t dev;
|
1995-04-21 06:47:35 +04:00
|
|
|
int flag;
|
|
|
|
int mode;
|
|
|
|
struct proc *p;
|
1993-09-29 09:08:37 +03:00
|
|
|
{
|
1995-04-21 06:47:35 +04:00
|
|
|
register struct grf_softc *gp;
|
|
|
|
|
1996-03-17 04:26:49 +03:00
|
|
|
gp = grf_cd.cd_devs[GRFUNIT(dev)];
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1997-08-03 10:25:56 +04:00
|
|
|
(void)grfoff(dev);
|
1996-05-20 02:27:04 +04:00
|
|
|
gp->sc_flags &= GF_ALIVE;
|
1995-04-21 06:47:35 +04:00
|
|
|
|
|
|
|
return (0);
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
1996-05-05 10:15:56 +04:00
|
|
|
int
|
1993-09-29 09:08:37 +03:00
|
|
|
grfioctl(dev, cmd, data, flag, p)
|
|
|
|
dev_t dev;
|
1995-04-21 06:47:35 +04:00
|
|
|
int cmd;
|
1993-09-29 09:08:37 +03:00
|
|
|
caddr_t data;
|
1995-04-21 06:47:35 +04:00
|
|
|
int flag;
|
1993-09-29 09:08:37 +03:00
|
|
|
struct proc *p;
|
|
|
|
{
|
1996-05-20 02:27:04 +04:00
|
|
|
struct grf_softc *gp;
|
|
|
|
struct grfmode *gm;
|
1995-04-21 06:47:35 +04:00
|
|
|
int error;
|
1995-04-30 00:23:36 +04:00
|
|
|
int unit = GRFUNIT(dev);
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1996-03-17 04:26:49 +03:00
|
|
|
gp = grf_cd.cd_devs[unit];
|
1996-05-20 02:27:04 +04:00
|
|
|
gm = gp->sc_grfmode;
|
1993-09-29 09:08:37 +03:00
|
|
|
error = 0;
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
switch (cmd) {
|
1995-04-30 00:23:36 +04:00
|
|
|
case GRFIOCGINFO: /* XXX - This should go away as soon as X and */
|
|
|
|
/* dt are fixed to use GRFIOC*MODE* */
|
|
|
|
{ struct grfinfo *g;
|
1997-08-03 10:25:56 +04:00
|
|
|
g = (struct grfinfo *)data;
|
1995-04-30 00:23:36 +04:00
|
|
|
bzero(data, sizeof(struct grfinfo));
|
1996-05-20 02:27:04 +04:00
|
|
|
g->gd_id = gm->mode_id;
|
|
|
|
g->gd_fbaddr = gm->fbbase;
|
|
|
|
g->gd_fbsize = gm->fbsize;
|
1997-08-03 10:25:56 +04:00
|
|
|
g->gd_colors = 1 << (u_int32_t)gm->psize;
|
1996-05-20 02:27:04 +04:00
|
|
|
g->gd_planes = gm->psize;
|
|
|
|
g->gd_fbwidth = g->gd_dwidth = gm->width;
|
|
|
|
g->gd_fbheight = g->gd_dheight = gm->height;
|
|
|
|
g->gd_fbrowbytes = gm->rowbytes;
|
1995-04-30 00:23:36 +04:00
|
|
|
}
|
1993-09-29 09:08:37 +03:00
|
|
|
break;
|
1995-04-30 00:23:36 +04:00
|
|
|
|
1993-09-29 09:08:37 +03:00
|
|
|
case GRFIOCON:
|
|
|
|
error = grfon(dev);
|
|
|
|
break;
|
|
|
|
case GRFIOCOFF:
|
|
|
|
error = grfoff(dev);
|
|
|
|
break;
|
|
|
|
case GRFIOCMAP:
|
1997-08-03 10:25:56 +04:00
|
|
|
error = grfmap(dev, (caddr_t *)data, p);
|
1993-09-29 09:08:37 +03:00
|
|
|
break;
|
|
|
|
case GRFIOCUNMAP:
|
1997-08-03 10:25:56 +04:00
|
|
|
error = grfunmap(dev, *(caddr_t *)data, p);
|
1993-09-29 09:08:37 +03:00
|
|
|
break;
|
1995-04-30 00:23:36 +04:00
|
|
|
|
1995-07-02 09:26:27 +04:00
|
|
|
case GRFIOCGMODE:
|
1996-05-20 02:27:04 +04:00
|
|
|
bcopy(gm, data, sizeof(struct grfmode));
|
1995-07-02 09:26:27 +04:00
|
|
|
break;
|
1995-04-30 00:23:36 +04:00
|
|
|
case GRFIOCGETMODE:
|
1996-05-20 02:27:04 +04:00
|
|
|
error = (*gp->sc_mode)(gp, GM_CURRMODE, data);
|
1995-04-30 00:23:36 +04:00
|
|
|
break;
|
|
|
|
case GRFIOCSETMODE:
|
1996-05-20 02:27:04 +04:00
|
|
|
error = (*gp->sc_mode)(gp, GM_NEWMODE, data);
|
1995-04-30 00:23:36 +04:00
|
|
|
break;
|
|
|
|
case GRFIOCLISTMODES:
|
1996-05-20 02:27:04 +04:00
|
|
|
error = (*gp->sc_mode)(gp, GM_LISTMODES, data);
|
1995-04-30 00:23:36 +04:00
|
|
|
break;
|
|
|
|
|
1993-09-29 09:08:37 +03:00
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
1995-04-21 06:47:35 +04:00
|
|
|
return (error);
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
1996-05-05 10:15:56 +04:00
|
|
|
int
|
1996-09-14 09:54:53 +04:00
|
|
|
grfpoll(dev, events, p)
|
1993-09-29 09:08:37 +03:00
|
|
|
dev_t dev;
|
1996-09-14 09:54:53 +04:00
|
|
|
int events;
|
1995-04-21 06:47:35 +04:00
|
|
|
struct proc *p;
|
1993-09-29 09:08:37 +03:00
|
|
|
{
|
1996-09-14 09:54:53 +04:00
|
|
|
return (events & (POLLOUT | POLLWRNORM));
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
1996-05-05 10:15:56 +04:00
|
|
|
int
|
1995-04-10 11:56:46 +04:00
|
|
|
grfmmap(dev, off, prot)
|
1993-09-29 09:08:37 +03:00
|
|
|
dev_t dev;
|
1995-04-21 06:47:35 +04:00
|
|
|
int off;
|
|
|
|
int prot;
|
1993-09-29 09:08:37 +03:00
|
|
|
{
|
1997-08-03 10:25:56 +04:00
|
|
|
struct grf_softc *gp = grf_cd.cd_devs[GRFUNIT(dev)];
|
|
|
|
struct grfmode *gm = gp->sc_grfmode;
|
|
|
|
u_long addr;
|
1995-07-02 03:40:38 +04:00
|
|
|
|
1997-08-03 10:25:56 +04:00
|
|
|
#ifdef GRF_DEBUG
|
|
|
|
if (grfdebug & GDB_MMAP)
|
|
|
|
printf("grfmmap(%x): off %x, prot %x\n", dev, off, prot);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (off < m68k_round_page(gm->fbsize + gm->fboff))
|
|
|
|
addr = m68k_btop((*gp->sc_phys)(gp) + off);
|
|
|
|
else
|
|
|
|
addr = (-1); /* XXX bogus */
|
|
|
|
|
|
|
|
#ifdef GRF_DEBUG
|
|
|
|
if (grfdebug & GDB_MMAP)
|
|
|
|
printf("grfmmap(%x): returning addr 0x%08lx\n", dev, addr);
|
|
|
|
#endif
|
|
|
|
return (int)addr;
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
int
|
1993-09-29 09:08:37 +03:00
|
|
|
grfon(dev)
|
1995-04-21 06:47:35 +04:00
|
|
|
dev_t dev;
|
1993-09-29 09:08:37 +03:00
|
|
|
{
|
1995-04-21 06:47:35 +04:00
|
|
|
int unit = GRFUNIT(dev);
|
1995-04-21 07:44:13 +04:00
|
|
|
struct grf_softc *gp;
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1996-03-17 04:26:49 +03:00
|
|
|
gp = grf_cd.cd_devs[unit];
|
1995-04-30 00:23:36 +04:00
|
|
|
|
1993-09-29 09:08:37 +03:00
|
|
|
/*
|
|
|
|
* XXX: iteoff call relies on devices being in same order
|
|
|
|
* as ITEs and the fact that iteoff only uses the minor part
|
|
|
|
* of the dev arg.
|
|
|
|
*/
|
|
|
|
iteoff(unit, 3);
|
1995-04-30 00:23:36 +04:00
|
|
|
|
1997-08-03 10:25:56 +04:00
|
|
|
return (*gp->sc_mode)(gp, GM_GRFON, NULL);
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
int
|
1993-09-29 09:08:37 +03:00
|
|
|
grfoff(dev)
|
1995-04-21 06:47:35 +04:00
|
|
|
dev_t dev;
|
1993-09-29 09:08:37 +03:00
|
|
|
{
|
1995-04-21 06:47:35 +04:00
|
|
|
int unit = GRFUNIT(dev);
|
1995-04-21 07:44:13 +04:00
|
|
|
struct grf_softc *gp;
|
1995-04-21 06:47:35 +04:00
|
|
|
int error;
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1996-03-17 04:26:49 +03:00
|
|
|
gp = grf_cd.cd_devs[unit];
|
1995-04-30 00:23:36 +04:00
|
|
|
|
1997-08-03 10:25:56 +04:00
|
|
|
(void) grfunmap(dev, (caddr_t)0, curproc);
|
1995-04-30 00:23:36 +04:00
|
|
|
|
1997-08-03 10:25:56 +04:00
|
|
|
error = (*gp->sc_mode)(gp, GM_GRFOFF, NULL);
|
1995-04-30 00:23:36 +04:00
|
|
|
|
1993-09-29 09:08:37 +03:00
|
|
|
/* XXX: see comment for iteoff above */
|
|
|
|
iteon(unit, 2);
|
1995-04-30 00:23:36 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
return (error);
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
int
|
1995-04-10 11:56:46 +04:00
|
|
|
grfmap(dev, addrp, p)
|
1993-09-29 09:08:37 +03:00
|
|
|
dev_t dev;
|
|
|
|
caddr_t *addrp;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1995-04-21 07:44:13 +04:00
|
|
|
struct grf_softc *gp;
|
1997-08-03 10:25:56 +04:00
|
|
|
struct grfmode *gm;
|
1993-09-29 09:08:37 +03:00
|
|
|
struct specinfo si;
|
1995-04-30 00:23:36 +04:00
|
|
|
struct vnode vn;
|
1997-08-03 10:25:56 +04:00
|
|
|
u_long len, ofs;
|
|
|
|
int error, flags;
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1996-03-17 04:26:49 +03:00
|
|
|
gp = grf_cd.cd_devs[GRFUNIT(dev)];
|
1997-08-03 10:25:56 +04:00
|
|
|
gm = gp->sc_grfmode;
|
|
|
|
#ifdef GRF_DEBUG
|
1993-09-29 09:08:37 +03:00
|
|
|
if (grfdebug & GDB_MMAP)
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("grfmap(%d): addr %p\n", p->p_pid, *addrp);
|
1993-09-29 09:08:37 +03:00
|
|
|
#endif
|
1995-07-02 04:49:52 +04:00
|
|
|
|
1997-08-03 10:25:56 +04:00
|
|
|
*addrp = (*gp->sc_phys)(gp);
|
|
|
|
ofs = (u_long)*addrp & PGOFSET;
|
|
|
|
*addrp = (caddr_t)m68k_trunc_page(*addrp);
|
|
|
|
len = m68k_round_page(ofs + gm->fboff + gm->fbsize);
|
|
|
|
flags = MAP_SHARED | MAP_FIXED;
|
1995-07-02 04:49:52 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
vn.v_type = VCHR; /* XXX */
|
|
|
|
vn.v_specinfo = &si; /* XXX */
|
|
|
|
vn.v_rdev = dev; /* XXX */
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1997-08-03 10:25:56 +04:00
|
|
|
error = vm_mmap(&p->p_vmspace->vm_map, (vm_offset_t *)addrp,
|
|
|
|
(vm_size_t)len, VM_PROT_ALL, VM_PROT_ALL, flags, (caddr_t)&vn, 0);
|
1994-07-31 12:32:47 +04:00
|
|
|
|
|
|
|
/* Offset into page: */
|
1997-08-03 10:25:56 +04:00
|
|
|
*addrp += (unsigned long)gm->fboff + ofs;
|
1994-04-05 05:30:28 +04:00
|
|
|
|
1997-08-03 10:25:56 +04:00
|
|
|
#ifdef GRF_DEBUG
|
1995-07-02 04:49:52 +04:00
|
|
|
if (grfdebug & GDB_MMAP)
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("grfmap(%d): returning addr %p\n", p->p_pid, *addrp);
|
1995-07-02 04:49:52 +04:00
|
|
|
#endif
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
return (error);
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
int
|
1995-04-10 11:56:46 +04:00
|
|
|
grfunmap(dev, addr, p)
|
1995-04-21 06:47:35 +04:00
|
|
|
dev_t dev;
|
1993-09-29 09:08:37 +03:00
|
|
|
caddr_t addr;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1995-04-21 07:44:13 +04:00
|
|
|
struct grf_softc *gp;
|
1993-09-29 09:08:37 +03:00
|
|
|
vm_size_t size;
|
1995-04-21 06:47:35 +04:00
|
|
|
int rv;
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1996-03-17 04:26:49 +03:00
|
|
|
gp = grf_cd.cd_devs[GRFUNIT(dev)];
|
1995-04-30 00:23:36 +04:00
|
|
|
|
1997-08-03 10:25:56 +04:00
|
|
|
#ifdef GRF_DEBUG
|
1993-09-29 09:08:37 +03:00
|
|
|
if (grfdebug & GDB_MMAP)
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("grfunmap(%d): dev %x addr %p\n", p->p_pid, dev, addr);
|
1993-09-29 09:08:37 +03:00
|
|
|
#endif
|
1995-04-30 00:23:36 +04:00
|
|
|
|
1993-09-29 09:08:37 +03:00
|
|
|
if (addr == 0)
|
1995-04-21 06:47:35 +04:00
|
|
|
return (EINVAL);/* XXX: how do we deal with this? */
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1996-05-20 02:27:04 +04:00
|
|
|
size = round_page(gp->sc_grfmode->fbsize);
|
1995-03-23 16:45:07 +03:00
|
|
|
|
1997-08-03 10:25:56 +04:00
|
|
|
rv = vm_deallocate(&p->p_vmspace->vm_map, (vm_offset_t)addr, size);
|
1995-03-23 16:45:07 +03:00
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
return (rv == KERN_SUCCESS ? 0 : EINVAL);
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|