Add new nubus handling that's much more robust.

Update via, if_ae, and grf accordingly.
Revamp grf.
This commit is contained in:
briggs 1995-04-29 20:23:36 +00:00
parent 67c2aabd6c
commit 59b4da2b39
14 changed files with 2208 additions and 1733 deletions

View File

@ -1,8 +1,5 @@
# $NetBSD: files.mac68k,v 1.31 1995/04/27 12:10:51 christos Exp $
# $NetBSD: files.mac68k,v 1.32 1995/04/29 20:23:36 briggs Exp $
# @(#)files.sparc 8.1 (Berkeley) 7/19/93
#
# files.mac68k.newconf
# mac68k-specific configuration info
# maxpartitions must be first item in files.${ARCH}.newconf
@ -31,6 +28,8 @@ file arch/mac68k/mac68k/fpu.c fpu
device grf at nubus
file arch/mac68k/dev/grf.c grf needs-count
file arch/mac68k/dev/grf_mv.c grf
file arch/mac68k/dev/grf_iv.c grf
device ite at mainbus
file arch/mac68k/dev/ite.c ite needs-flag

View File

@ -1,4 +1,4 @@
/* $NetBSD: grf.c,v 1.20 1995/04/21 03:44:13 briggs Exp $ */
/* $NetBSD: grf.c,v 1.21 1995/04/29 20:23:39 briggs Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -79,29 +79,34 @@
#define iteoff(u,f)
#endif
static int matchvideocard __P((/*struct device *parent, struct device *dev,
static int grf_match __P((/*struct device *parent, struct device *dev,
void *aux*/));
static void grf_attach __P((struct device *parent, struct device *dev,
void *aux));
static void fake_internal __P((void));
static int grfprobe __P((struct nubus_hw *nu, int unit));
static int macvideo_init __P((struct grf_softc *gp, struct nubus_hw *nu));
static int macvideo_mode __P((struct grf_softc *gp, int cmd, void *arg));
extern int grfmv_probe __P((struct grf_softc *gp, nubus_slot *nu));
extern int grfmv_init __P((struct grf_softc *gp));
extern int grfmv_mode __P((struct grf_softc *gp, int cmd, void *arg));
extern int grfiv_probe __P((struct grf_softc *gp, nubus_slot *ignore));
extern int grfiv_init __P((struct grf_softc *gp));
extern int grfiv_mode __P((struct grf_softc *gp, int cmd, void *arg));
struct cfdriver grfcd = {
NULL, "grf", matchvideocard, grf_attach, DV_DULL,
NULL, "grf", grf_match, grf_attach, DV_DULL,
sizeof(struct grf_softc)
};
struct grfdev grfdev[] = {
GID_MAC, GRFMAC, macvideo_init, macvideo_mode, "MacVideo",
/* DrSW (*gd_probe)() (*gd_init)() (*gd_mode)() gd_desc */
NUBUS_DRSW_APPLE, grfmv_probe, grfmv_init, grfmv_mode, "QD-compatible",
0xFF, grfiv_probe, grfiv_init, grfiv_mode, "Internal video",
};
static int ngrfdev=(sizeof(grfdev) / sizeof(grfdev[0]));
static int gNumGrfDev=0;
#ifdef DEBUG
static int grfdebug = 0xff;
#define GDB_DEVNO 0x01
@ -110,119 +115,49 @@ static int grfdebug = 0xff;
#define GDB_LOCK 0x08
#endif
/*
* Normal init routine called by configure() code
*/
grfprobe(nu, unit)
struct nubus_hw *nu;
int unit;
{
struct grf_softc *gp;
gp = grfcd.cd_devs[unit];
if ((gp->g_flags & GF_ALIVE) == 0 && !grfinit(nu, unit)) {
printf("\n");
return (0);
}
printf(": %d x %d ",
gp->g_display.gd_dwidth, gp->g_display.gd_dheight);
if (gp->g_display.gd_colors == 2)
printf("monochrome");
else
printf("%d color", gp->g_display.gd_colors);
printf(" %s (%s) display\n",
grfdev[gp->g_type].gd_desc, nu->slot.name);
gp->g_data = (void *) &nu->slot;
return (1);
}
static int
matchvideocard(parent, cf, aux)
struct device *parent;
struct device *cf;
void *aux;
grf_match(parent, match, aux)
struct device *parent;
void *match, *aux;
{
struct nubus_hw *nu = (struct nubus_hw *) aux;
struct grf_softc *sc = match;
nubus_slot *nu = (nubus_slot *) aux;
int i, r;
return (nu->slot.type == NUBUS_VIDEO);
for (i = 0; i < ngrfdev; i++) {
if ((r = (*grfdev[i].gd_probe)(sc, nu)) > 0) {
sc->g_type = i;
bcopy(aux, &sc->sc_slot, sizeof(nubus_slot));
return r;
}
}
return 0;
}
static void
grf_attach(parent, dev, aux)
struct device *parent, *dev;
grf_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct nubus_hw *nu = (struct nubus_hw *) aux;
struct grf_softc *sc;
grfprobe(nu, dev->dv_unit);
}
sc = (struct grf_softc *) self;
int
grfinit(nu, unit)
struct nubus_hw *nu;
int unit;
{
struct grf_softc *gp;
struct grfreg *gr;
register struct grfdev *gd;
gp = grfcd.cd_devs[unit];
for (gd = grfdev; gd < &grfdev[ngrfdev]; gd++)
/* if (gd->gd_hardid == gr->gr_id2) */
break;
if (gd < &grfdev[ngrfdev] && (*gd->gd_init) (gp, nu)) {
gp->g_display.gd_id = gd->gd_softid;
gp->g_type = gd - grfdev;
gp->g_flags = GF_ALIVE;
return (1);
}
return (0);
}
static void
fake_internal()
{
extern unsigned long int_video_start;
struct grf_softc *gp;
struct grfinfo *gi;
struct grfterm *gt;
struct grfmouse *gm;
int i, j;
if (int_video_start == 0) {
if ((*grfdev[sc->g_type].gd_init)(sc) == 0) {
printf("\n");
return;
}
for (i = 0; i < NGRF; i++) {
gp = grfcd.cd_devs[i];
if ((gp->g_flags & GF_ALIVE) == 0) {
break;
}
}
sc->g_flags = GF_ALIVE;
if (i == NGRF) {
printf("grf: not enough grf's to map internal video.\n");
return;
}
gp->g_type = 0;
gp->g_flags = GF_ALIVE;
printf(": %d x %d ", sc->curr_mode.width, sc->curr_mode.height);
gi = &(gp->g_display);
gi->gd_id = GRFMAC;
gi->gd_regsize = 0;
gi->gd_colors = 1;
gi->gd_planes = 1;
gi->gd_dwidth = gi->gd_fbwidth = 640; /* XXX */
gi->gd_dheight = gi->gd_fbheight = 480; /* XXX */
gi->gd_fbsize = gi->gd_dwidth * gi->gd_dheight;
gi->gd_fbrowbytes = 80; /* XXX Hack */
gi->gd_fbaddr = (caddr_t) 0;
gp->g_fbkva = gi->gd_fbaddr;
if (sc->curr_mode.psize == 1)
printf("monochrome");
else
printf("%d color", 1 << sc->curr_mode.psize);
printf(" %s (%s) display\n",
grfdev[sc->g_type].gd_desc, sc->card_name);
}
/*ARGSUSED*/
@ -233,19 +168,14 @@ grfopen(dev, flag, mode, p)
int mode;
struct proc *p;
{
static int faked; /* Whether we've faked internal video yet */
register struct grf_softc *gp;
int unit;
int error;
unit = GRFUNIT(dev);
gp = grfcd.cd_devs[unit];
if (!faked) {
fake_internal();
faked = 1;
}
if (unit >= NGRF || (gp->g_flags & GF_ALIVE) == 0)
if (unit >= grfcd.cd_ndevs || (gp->g_flags & GF_ALIVE) == 0)
return (ENXIO);
if ((gp->g_flags & (GF_OPEN | GF_EXCLUDE)) == (GF_OPEN | GF_EXCLUDE))
@ -275,7 +205,6 @@ grfclose(dev, flag, mode, p)
gp = grfcd.cd_devs[GRFUNIT(dev)];
(void) grfoff(dev);
(void) grfunlock(gp);
gp->g_flags &= GF_ALIVE;
return (0);
@ -291,17 +220,28 @@ grfioctl(dev, cmd, data, flag, p)
{
register struct grf_softc *gp;
int error;
int unit = GRFUNIT(dev);
gp = grfcd.cd_devs[GRFUNIT(dev)];
gp = grfcd.cd_devs[unit];
error = 0;
switch (cmd) {
case OGRFIOCGINFO:
bcopy((caddr_t) & gp->g_display, data, sizeof(struct ogrfinfo));
break;
case GRFIOCGINFO:
bcopy((caddr_t) & gp->g_display, data, sizeof(struct grfinfo));
case GRFIOCGINFO: /* XXX - This should go away as soon as X and */
/* dt are fixed to use GRFIOC*MODE* */
{ struct grfinfo *g;
g = (struct grfinfo *) data;
bzero(data, sizeof(struct grfinfo));
g->gd_id = gp->curr_mode.mode_id;
g->gd_fbaddr = gp->curr_mode.fbbase;
g->gd_fbsize = gp->curr_mode.fbsize;
g->gd_colors = 1 << (u_int32_t) gp->curr_mode.psize;
g->gd_planes = gp->curr_mode.psize;
g->gd_fbwidth = g->gd_dwidth = gp->curr_mode.width;
g->gd_fbheight = g->gd_dheight = gp->curr_mode.height;
g->gd_fbrowbytes = gp->curr_mode.rowbytes;
}
break;
case GRFIOCON:
error = grfon(dev);
break;
@ -314,6 +254,17 @@ grfioctl(dev, cmd, data, flag, p)
case GRFIOCUNMAP:
error = grfunmap(dev, *(caddr_t *) data, p);
break;
case GRFIOCGETMODE:
error = (*grfdev[gp->g_type].gd_mode)(gp, GM_CURRMODE, data);
break;
case GRFIOCSETMODE:
error = (*grfdev[gp->g_type].gd_mode)(gp, GM_NEWMODE, data);
break;
case GRFIOCLISTMODES:
error = (*grfdev[gp->g_type].gd_mode)(gp, GM_LISTMODES, data);
break;
default:
error = EINVAL;
break;
@ -332,59 +283,6 @@ grfselect(dev, rw, p)
return (1);
}
int
grflock(gp, block)
register struct grf_softc *gp;
int block;
{
extern char devioc[];
struct proc *p = curproc; /* XXX */
int error;
#ifdef DEBUG
if (grfdebug & GDB_LOCK)
printf("grflock(%d): dev %x flags %x lockpid %x\n",
p->p_pid, gp->sc_dev.dv_unit, gp->g_flags,
gp->g_lockp ? gp->g_lockp->p_pid : -1);
#endif
if (gp->g_lockp) {
if (gp->g_lockp == p)
return (EBUSY);
if (!block)
return (EAGAIN);
do {
gp->g_flags |= GF_WANTED;
if (error = tsleep((caddr_t) & gp->g_flags,
(PZERO + 1) | PCATCH, devioc, 0))
return (error);
} while (gp->g_lockp);
}
gp->g_lockp = p;
return (0);
}
int
grfunlock(gp)
register struct grf_softc *gp;
{
#ifdef DEBUG
if (grfdebug & GDB_LOCK)
printf("grfunlock(%d): dev %x flags %x lockpid %d\n",
curproc->p_pid, gp->sc_dev.dv_unit, gp->g_flags,
gp->g_lockp ? gp->g_lockp->p_pid : -1);
#endif
if (gp->g_lockp != curproc)
return (EBUSY);
if (gp->g_flags & GF_WANTED) {
wakeup((caddr_t) & gp->g_flags);
gp->g_flags &= ~GF_WANTED;
}
gp->g_lockp = NULL;
return (0);
}
/*ARGSUSED*/
grfmmap(dev, off, prot)
dev_t dev;
@ -402,14 +300,15 @@ grfon(dev)
struct grf_softc *gp;
gp = grfcd.cd_devs[unit];
/*
* 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);
return ((*grfdev[gp->g_type].gd_mode)
(gp, (dev & GRFOVDEV) ? GM_GRFOVON : GM_GRFON));
return (*grfdev[gp->g_type].gd_mode) (gp, GM_GRFON, NULL);
}
int
@ -421,11 +320,14 @@ grfoff(dev)
int error;
gp = grfcd.cd_devs[unit];
(void) grfunmap(dev, (caddr_t) 0, curproc);
error = (*grfdev[gp->g_type].gd_mode)
(gp, (dev & GRFOVDEV) ? GM_GRFOVOFF : GM_GRFOFF);
error = (*grfdev[gp->g_type].gd_mode) (gp, GM_GRFOFF, NULL);
/* XXX: see comment for iteoff above */
iteon(unit, 2);
return (error);
}
@ -434,16 +336,10 @@ grfaddr(gp, off)
struct grf_softc *gp;
register int off;
{
register struct grfinfo *gi = &gp->g_display;
register struct grfmode *gm = &gp->curr_mode;
/* control registers */
if (off >= 0 && off < gi->gd_regsize)
return (((u_int) gi->gd_regaddr + off) >> PGSHIFT);
/* frame buffer */
if (off >= gi->gd_regsize && off < gi->gd_regsize + gi->gd_fbsize) {
off -= gi->gd_regsize;
return (((u_int) gi->gd_fbaddr + off) >> PGSHIFT);
if (off < gm->fbsize) {
return (((u_int) gm->fbbase + off) >> PGSHIFT);
}
/* bogus */
return (-1);
@ -456,17 +352,17 @@ grfmap(dev, addrp, p)
struct proc *p;
{
struct grf_softc *gp;
int len, error;
struct vnode vn;
struct specinfo si;
int flags;
struct vnode vn;
int len, error;
int flags;
gp = grfcd.cd_devs[GRFUNIT(dev)];
#ifdef DEBUG
if (grfdebug & GDB_MMAP)
printf("grfmap(%d): addr %x\n", p->p_pid, *addrp);
#endif
len = gp->g_display.gd_regsize + gp->g_display.gd_fbsize;
len = gp->curr_mode.fbsize;
flags = MAP_SHARED;
if (*addrp)
flags |= MAP_FIXED;
@ -483,7 +379,7 @@ grfmap(dev, addrp, p)
0);
/* Offset into page: */
*addrp += (unsigned long) gp->g_display.gd_fbaddr & 0xfff;
*addrp += (unsigned long) gp->curr_mode.fbbase & 0xfff;
return (error);
}
@ -499,67 +395,18 @@ grfunmap(dev, addr, p)
int rv;
gp = grfcd.cd_devs[GRFUNIT(dev)];
#ifdef DEBUG
if (grfdebug & GDB_MMAP)
printf("grfunmap(%d): dev %x addr %x\n", p->p_pid, dev, addr);
#endif
if (addr == 0)
return (EINVAL);/* XXX: how do we deal with this? */
size = round_page(gp->g_display.gd_regsize + gp->g_display.gd_fbsize);
size = round_page(gp->curr_mode.fbsize);
rv = vm_deallocate(&p->p_vmspace->vm_map, (vm_offset_t) addr, size);
return (rv == KERN_SUCCESS ? 0 : EINVAL);
}
static char zero = 0;
static void
macvideo_intr(unit, slot)
int unit, slot;
{
struct grf_softc *gp;
((char *) (0xf0000000 | ((long) slot << 24)))[0xa0000] = zero;
}
static int
macvideo_init(gp, nu)
struct grf_softc *gp;
struct nubus_hw *nu;
{
struct grfinfo *gi;
struct imagedata *image;
struct imagedata imageSpace;
int i = 0;
/*
* find out which nubus slot this guy is in, then get the video params
*/
image = (struct imagedata *) NUBUS_GetImageData(&(nu->slot), &imageSpace);
gi = &(gp->g_display);
gi->gd_regsize = 0;
gi->gd_colors = 1;
gi->gd_planes = 1;
gi->gd_dwidth = gi->gd_fbwidth = image->right;
gi->gd_dheight = gi->gd_fbheight = image->bottom;
gi->gd_fbsize = image->rowbytes * image->bottom;
gi->gd_fbrowbytes = image->rowbytes;
gi->gd_fbaddr = (caddr_t) ((u_long) image->offset + (u_long) nu->addr);
gp->g_fbkva = gi->gd_fbaddr;
add_nubus_intr((unsigned int) nu->addr & 0xFF000000, macvideo_intr,
(gp->sc_dev.dv_unit));
gNumGrfDev++;
return 1;
}
static int
macvideo_mode(gp, cmd, arg)
struct grf_softc *gp;
int cmd;
void *arg;
{
return 0;
}

View File

@ -0,0 +1,101 @@
/* $NetBSD: grf_iv.c,v 1.1 1995/04/29 20:23:41 briggs Exp $ */
/*
* Copyright (c) 1995 Allen Briggs. All rights reserved.
*
* 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 Allen Briggs.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/*
* Graphics display driver for the Macintosh internal video for machines
* that don't map it into a fake nubus card.
*/
#include <sys/param.h>
#include <sys/device.h>
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/malloc.h>
#include <sys/mman.h>
#include <sys/proc.h>
#include <machine/grfioctl.h>
#include <machine/cpu.h>
#include "nubus.h"
#include "grfvar.h"
extern int grfiv_probe __P((struct grf_softc *sc, nubus_slot *ignore));
extern int grfiv_init __P((struct grf_softc *sc));
extern int grfiv_mode __P((struct grf_softc *sc, int cmd, void *arg));
extern int
grfiv_probe(sc, ignore)
struct grf_softc *sc;
nubus_slot *ignore;
{
extern unsigned long int_video_start;
if (int_video_start == 0) {
return 0;
}
return 1;
}
extern int
grfiv_init(sc)
struct grf_softc *sc;
{
struct grfmode *gm;
int i, j;
sc->card_id = 0;
strcpy(sc->card_name, "Internal video");
gm = &(sc->curr_mode);
gm->mode_id = 0;
gm->psize = 1;
gm->ptype = 0;
gm->width = 640; /* XXX */
gm->height = 480; /* XXX */
gm->rowbytes = 80; /* XXX Hack */
gm->hres = 80; /* XXX Hack */
gm->vres = 80; /* XXX Hack */
gm->fbsize = gm->width * gm->height;
gm->fbbase = (caddr_t) 0;
return 1;
}
extern int
grfiv_mode(sc, cmd, arg)
struct grf_softc *sc;
int cmd;
void *arg;
{
return 0;
}

View File

@ -0,0 +1,213 @@
/* $NetBSD: grf_mv.c,v 1.1 1995/04/29 20:23:42 briggs Exp $ */
/*
* Copyright (c) 1995 Allen Briggs. All rights reserved.
*
* 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 Allen Briggs.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/*
* Device-specific routines for handling Nubus-based video cards.
*/
#include <sys/param.h>
#include <sys/device.h>
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/malloc.h>
#include <sys/mman.h>
#include <sys/proc.h>
#include <machine/grfioctl.h>
#include <machine/cpu.h>
#include "nubus.h"
#include "grfvar.h"
extern int grfmv_probe __P((struct grf_softc *gp, nubus_slot *slot));
extern int grfmv_init __P((struct grf_softc *gp));
extern int grfmv_mode __P((struct grf_softc *gp, int cmd, void *arg));
static char zero = 0;
static void
load_image_data(data, image)
caddr_t data;
struct image_data *image;
{
bcopy(data , &image->size, 4);
bcopy(data + 4, &image->offset, 4);
bcopy(data + 8, &image->rowbytes, 2);
bcopy(data + 10, &image->top, 2);
bcopy(data + 12, &image->left, 2);
bcopy(data + 14, &image->bottom, 2);
bcopy(data + 16, &image->right, 2);
bcopy(data + 18, &image->version, 2);
bcopy(data + 20, &image->packType, 2);
bcopy(data + 22, &image->packSize, 4);
bcopy(data + 26, &image->hRes, 4);
bcopy(data + 30, &image->vRes, 4);
bcopy(data + 34, &image->pixelType, 2);
bcopy(data + 36, &image->pixelSize, 2);
bcopy(data + 38, &image->cmpCount, 2);
bcopy(data + 40, &image->cmpSize, 2);
bcopy(data + 42, &image->planeBytes, 4);
}
static void
grfmv_intr(sc, slot)
struct grf_softc *sc;
int slot;
{
struct grf_softc *gp;
((char *) (((u_long) (0xf0 | slot)) << 24))[0xa0000] = zero;
}
extern int
grfmv_probe(sc, slot)
struct grf_softc *sc;
nubus_slot *slot;
{
nubus_dir dir, *dirp, dir2, *dirp2;
nubus_dirent dirent, *direntp;
nubus_type slottype;
dirp = &dir;
direntp = &dirent;
nubus_get_main_dir(slot, dirp);
/*
* Unfortunately, I think we'll have to load this value from
* the macos. The alternative is putting in enough hooks to
* be able to call the card's PrimaryInit routine which could
* call just about any part of the ROM, I think.
*/
if (nubus_find_rsrc(slot, dirp, 128, direntp) <= 0) {
if (nubus_find_rsrc(slot, dirp, 129, direntp) <= 0) {
return 0;
}
}
dirp2 = (nubus_dir *) &sc->board_dir;
nubus_get_dir_from_rsrc(slot, direntp, dirp2);
if (nubus_find_rsrc(slot, dirp2, NUBUS_RSRC_TYPE, direntp) <= 0)
/* Type is a required entry... This should never happen. */
return 0;
if (nubus_get_ind_data(slot, direntp,
(caddr_t) &slottype, sizeof(nubus_type)) <= 0)
return 0;
if (slottype.category != NUBUS_CATEGORY_DISPLAY)
return 0;
if (slottype.type != NUBUS_TYPE_VIDEO)
return 0;
if (slottype.drsw != NUBUS_DRSW_APPLE)
return 0;
/*
* If we've gotten this far, then we're dealing with a real-live
* Apple QuickDraw-compatible display card resource. Now, how to
* determine that this is an active resource??? Dunno. But we'll
* proceed like it is.
*/
sc->card_id = slottype.drhw;
printf("card id = 0x%x.\n", sc->card_id);
/* Need to load display info (and driver?), etc... */
return 1;
}
extern int
grfmv_init(sc)
struct grf_softc *sc;
{
struct image_data image_store, image;
nubus_dirent dirent;
nubus_dir mode_dir;
int mode;
u_long base;
mode = NUBUS_RSRC_FIRSTMODE;
if (nubus_find_rsrc(&sc->sc_slot, &sc->board_dir, mode, &dirent) <= 0)
return 0;
nubus_get_dir_from_rsrc(&sc->sc_slot, &dirent, &mode_dir);
if (nubus_find_rsrc(&sc->sc_slot, &mode_dir, VID_PARAMS, &dirent) <= 0)
return 0;
if (nubus_get_ind_data(&sc->sc_slot, &dirent, (caddr_t) &image_store,
sizeof(struct image_data)) <= 0)
return 0;
load_image_data((caddr_t) &image_store, &image);
base = NUBUS_SLOT_TO_BASE(sc->sc_slot.slot);
sc->curr_mode.mode_id = mode;
sc->curr_mode.fbbase = (caddr_t) (base + image.offset);
sc->curr_mode.rowbytes = image.rowbytes;
sc->curr_mode.width = image.right - image.left;
sc->curr_mode.height = image.bottom - image.top;
sc->curr_mode.fbsize = sc->curr_mode.height * sc->curr_mode.rowbytes;
sc->curr_mode.hres = image.hRes;
sc->curr_mode.vres = image.vRes;
sc->curr_mode.ptype = image.pixelType;
sc->curr_mode.psize = image.pixelSize;
strncpy(sc->card_name, nubus_get_card_name(&sc->sc_slot),
CARD_NAME_LEN);
sc->card_name[CARD_NAME_LEN-1] = '\0';
add_nubus_intr(sc->sc_slot.slot, grfmv_intr, sc);
return 1;
}
extern int
grfmv_mode(gp, cmd, arg)
struct grf_softc *gp;
int cmd;
void *arg;
{
switch (cmd) {
case GM_CURRMODE:
break;
case GM_NEWMODE:
break;
case GM_LISTMODES:
break;
}
return EINVAL;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: grfvar.h,v 1.6 1995/04/21 03:44:19 briggs Exp $ */
/* $NetBSD: grfvar.h,v 1.7 1995/04/29 20:23:43 briggs Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -42,27 +42,19 @@
* @(#)grfvar.h 7.3 (Berkeley) 5/7/91
*/
/* internal structure of lock page */
#define GRFMAXLCK 256
struct grf_lockpage {
u_char gl_locks[GRFMAXLCK];
};
#define gl_lockslot gl_locks[0]
#define CARD_NAME_LEN 64
/* per display info */
struct grf_softc {
struct device sc_dev;
struct device sc_dev;
nubus_slot sc_slot;
int g_flags; /* software flags */
int g_type; /* type of display */
caddr_t g_regkva; /* KVA of registers */
caddr_t g_fbkva; /* KVA of framebuffer */
struct grfinfo g_display; /* hardware description (for ioctl) */
struct grf_lockpage *g_lock; /* lock page associated with device */
struct proc *g_lockp; /* process holding lock */
short *g_pid; /* array of pids with device open */
int g_lockpslot; /* g_pid entry of g_lockp */
caddr_t g_data; /* device dependent data */
char card_name[CARD_NAME_LEN];
struct grfmode curr_mode; /* hardware desc(for ioctl) */
u_int32_t g_flags; /* software flags */
u_int32_t g_type; /* index into grfdev */
u_int16_t card_id; /* DrHW value for nubus cards */
nubus_dir board_dir; /* Nubus dir for curr board */
caddr_t g_data; /* device dependent data */
};
/* flags */
@ -74,47 +66,53 @@ struct grf_softc {
#define GF_HPUXOPEN 0x20
/* display types - indices into grfdev */
#define GT_MAC 0
#define GT_MACVIDEO 0
#define GT_INTERNALVIDEO 1
struct grfdev {
int gd_hardid; /* secondary id returned by hardware */
int gd_softid; /* id returned by HP-UX */
int gd_softid; /* DrSW */
int (*gd_probe)(); /* probe routine */
int (*gd_init) (); /* boot time initialization */
int (*gd_mode) (); /* misc functions */
int (*gd_mode) (); /* mode-change on/off/mode function */
char *gd_desc; /* text description */
};
/* hardware ids */
#define GID_MAC 1
/* software ids defined in grfioctl.h */
/* requests to mode routine */
#define GM_GRFON 1
#define GM_GRFOFF 2
#define GM_GRFOVON 3
#define GM_GRFOVOFF 4
struct grfreg {
char gr_pad0;
u_char gr_id; /* +0x01 */
char gr_pad1[0x13];
u_char gr_id2; /* +0x15 */
char gr_pad2[0x47];
u_char gr_fbomsb; /* +0x5d */
char gr_pad3;
u_char gr_fbolsb; /* +0x5f */
};
/* bitmapped display hardware id */
#define GRFHWID 0x39
/* internal bitmapped display address */
#define GRFIADDR 0x560000
#define GM_CURRMODE 3
#define GM_LISTMODES 4
#define GM_NEWMODE 5
/* minor device interpretation */
#define GRFOVDEV 0x10 /* overlay planes */
#define GRFIMDEV 0x20 /* images planes */
#define GRFUNIT(d) ((d) & 0x7)
#ifdef _KERNEL
extern struct grf_softc grf_softc[];
#endif /* _KERNEL */
/*
* Nubus image data structure. This is the equivalent of a PixMap in
* MacOS programming parlance. One of these structures exists for each
* video mode that a quickdraw compatible card can fit in.
*/
struct image_data {
u_int32_t size;
u_int32_t offset;
u_int16_t rowbytes;
u_int16_t top;
u_int16_t left;
u_int16_t bottom;
u_int16_t right;
u_int16_t version;
u_int16_t packType;
u_int32_t packSize;
u_int32_t hRes;
u_int32_t vRes;
u_int16_t pixelType;
u_int16_t pixelSize;
u_int16_t cmpCount;
u_int16_t cmpSize;
u_int32_t planeBytes;
};
#define VID_PARAMS 1
#define VID_TABLE_OFFSET 2
#define VID_PAGE_CNT 3
#define VID_DEV_TYPE 4

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ae.c,v 1.27 1995/04/22 12:08:12 briggs Exp $ */
/* $NetBSD: if_ae.c,v 1.28 1995/04/29 20:23:44 briggs Exp $ */
/*
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@ -61,20 +61,22 @@
#include <dev/ic/dp8390.h>
#include "if_aereg.h"
#define INTERFACE_NAME_LEN 32
/*
* ae_softc: per line info and status
*/
struct ae_softc {
struct device sc_dev;
/* struct nubusdev sc_nu;
struct intrhand sc_ih; */
struct device sc_dev;
nubus_slot sc_slot;
/* struct intrhand sc_ih; */
struct arpcom sc_arpcom;/* ethernet common */
char *type_str; /* pointer to type string */
u_char vendor; /* interface vendor */
u_char type; /* interface type code */
u_char regs_rev; /* registers are reversed */
char type_str[INTERFACE_NAME_LEN]; /* type string */
u_short type; /* interface type code */
u_char vendor; /* interface vendor */
u_char regs_rev; /* registers are reversed */
#define REG_MAP(sc, reg) ((sc)->regs_rev ? (0x0f-(reg))<<2 : (reg)<<2)
#define NIC_GET(sc, reg) ((sc)->nic_addr[REG_MAP(sc, reg)])
@ -121,45 +123,19 @@ u_short ae_put __P((struct ae_softc *, struct mbuf *, caddr_t));
void ae_get_packet __P(( /* struct ae_softc *, caddr_t, u_short */ ));
static inline void ae_rint __P((struct ae_softc *));
static inline void ae_xmit __P((struct ae_softc *));
static inline caddr_t ae_ring_copy
__P(( /* struct ae_softc *, caddr_t, caddr_t,
u_short */ ));
static inline caddr_t ae_ring_copy __P((
/* struct ae_softc *, caddr_t, caddr_t, u_short */ ));
struct cfdriver aecd = {
NULL, "ae", aeprobe, aeattach, DV_IFNET, sizeof(struct ae_softc)
};
struct cfdriver aecd = {
NULL, "ae", aeprobe, aeattach, DV_IFNET, sizeof(struct ae_softc)
};
#define ETHER_MIN_LEN 64
#define ETHER_MAX_LEN 1518
#define ETHER_ADDR_LEN 6
char ae_name[] = "8390 Nubus Ethernet card";
static char zero = 0;
static u_char ones = 0xff;
struct vendor_S {
char *manu;
int len;
int vendor;
} vend[] =
{
{
"Apple", 5, AE_VENDOR_APPLE
},
{
"3Com", 4, AE_VENDOR_APPLE
},
{
"Dayna", 5, AE_VENDOR_DAYNA
},
{
"Inter", 5, AE_VENDOR_INTERLAN
},
{
"Asant", 5, AE_VENDOR_ASANTE
},
};
static int numvend = sizeof(vend) / sizeof(vend[0]);
static char zero = 0;
static u_char ones = 0xff;
/*
* XXX These two should be moved to locore, and maybe changed to use shorts
@ -200,25 +176,59 @@ byte_copy(a, b, len)
*b++ = *a++;
}
void
ae_id_card(nu, sc)
struct nubus_hw *nu;
static int
ae_id_card(slot, sc)
nubus_slot *slot;
struct ae_softc *sc;
{
int i;
nubus_dir dir;
nubus_dirent dirent;
nubus_type slottype;
/*
* Try to determine what type of card this is...
*/
sc->vendor = AE_VENDOR_UNKNOWN;
for (i = 0; i < numvend; i++) {
if (!strncmp(nu->slot.manufacturer, vend[i].manu, vend[i].len)) {
sc->vendor = vend[i].vendor;
break;
}
nubus_get_main_dir(slot, &dir);
if (nubus_find_rsrc(slot, &dir, 0x80, &dirent) <= 0)
return 0;
nubus_get_dir_from_rsrc(slot, &dirent, &dir);
if (nubus_find_rsrc(slot, &dir, NUBUS_RSRC_TYPE, &dirent) <= 0)
return 0;
if (nubus_get_ind_data(slot, &dirent,
(caddr_t) &slottype, sizeof(nubus_type)) <= 0)
return 0;
if (slottype.category != NUBUS_CATEGORY_NETWORK)
return 0;
if (slottype.type != NUBUS_TYPE_ETHERNET)
return 0;
switch (slottype.type) {
case NUBUS_DRSW_3COM:
case NUBUS_DRSW_APPLE:
sc->vendor = AE_VENDOR_APPLE;
break;
case NUBUS_DRSW_ASANTE:
sc->vendor = AE_VENDOR_ASANTE;
break;
case NUBUS_DRSW_DAYNA:
sc->vendor = AE_VENDOR_DAYNA;
break;
case NUBUS_DRSW_INTERLAN:
sc->vendor = AE_VENDOR_INTERLAN;
break;
default:
sc->vendor = AE_VENDOR_UNKNOWN;
return 0;
}
sc->type_str = (char *) (nu->slot.manufacturer);
strncpy(sc->type_str, nubus_get_card_name(slot), INTERFACE_NAME_LEN);
sc->type_str[INTERFACE_NAME_LEN-1] = '\0';
return 1;
}
int
@ -266,28 +276,29 @@ aeprobe(parent, match, aux)
void *match, *aux;
{
struct ae_softc *sc = match;
register struct nubus_hw *nu = aux;
nubus_slot *nu = (nubus_slot *) aux;
caddr_t addr;
int i, memsize;
int flags = 0;
if (nu->slot.type != NUBUS_NETWORK)
if (ae_id_card(nu, sc) < 0)
return 0;
ae_id_card(nu, sc);
sc->regs_rev = 0;
sc->mem_wr_short = 0;
addr = (caddr_t) NUBUS_SLOT_TO_BASE(nu->slot);
switch (sc->vendor) {
case AE_VENDOR_INTERLAN:
sc->nic_addr = nu->addr + GC_NIC_OFFSET;
sc->rom_addr = nu->addr + GC_ROM_OFFSET;
sc->mem_start = nu->addr + GC_DATA_OFFSET;
sc->nic_addr = addr + GC_NIC_OFFSET;
sc->rom_addr = addr + GC_ROM_OFFSET;
sc->mem_start = addr + GC_DATA_OFFSET;
if ((memsize = ae_size_card_memory(sc)) == 0)
return 0;
/* reset the NIC chip */
*((caddr_t) nu->addr + GC_RESET_OFFSET) = (char) zero;
*((caddr_t) addr + GC_RESET_OFFSET) = (char) zero;
/* Get station address from on-board ROM */
for (i = 0; i < ETHER_ADDR_LEN; ++i)
@ -301,9 +312,9 @@ aeprobe(parent, match, aux)
case AE_VENDOR_APPLE:
sc->regs_rev = 1;
sc->nic_addr = nu->addr + AE_NIC_OFFSET;
sc->rom_addr = nu->addr + AE_ROM_OFFSET;
sc->mem_start = nu->addr + AE_DATA_OFFSET;
sc->nic_addr = addr + AE_NIC_OFFSET;
sc->rom_addr = addr + AE_ROM_OFFSET;
sc->mem_start = addr + AE_DATA_OFFSET;
if ((memsize = ae_size_card_memory(sc)) == 0)
return (0);
@ -314,9 +325,9 @@ aeprobe(parent, match, aux)
case AE_VENDOR_DAYNA:
printf("We think we are a Dayna card, but ");
sc->nic_addr = nu->addr + DP_NIC_OFFSET;
sc->rom_addr = nu->addr + DP_ROM_OFFSET;
sc->mem_start = nu->addr + DP_DATA_OFFSET;
sc->nic_addr = addr + DP_NIC_OFFSET;
sc->rom_addr = addr + DP_ROM_OFFSET;
sc->mem_start = addr + DP_DATA_OFFSET;
memsize = 8192;
/* Get station address from on-board ROM */
@ -356,6 +367,8 @@ aeprobe(parent, match, aux)
sc->mem_start + i);
return (0);
}
bcopy(nu, &sc->sc_slot, sizeof(nubus_slot));
return (1);
}
/*
@ -390,19 +403,14 @@ aeattach(parent, self, aux)
/* Print additional info when attached. */
printf(": address %s, ", ether_sprintf(sc->sc_arpcom.ac_enaddr));
if (sc->type_str && (*sc->type_str != 0))
printf("type %s", sc->type_str);
else
printf("type unknown (0x%x)", sc->type);
printf(", %dk mem.\n", sc->mem_size / 1024);
printf("type %s, %dk mem.\n", sc->type_str, sc->mem_size / 1024);
#if NBPFILTER > 0
bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
#endif
/* make sure interrupts are vectored to us */
add_nubus_intr((int) sc->rom_addr & 0xFF000000, aeintr, sc);
add_nubus_intr(sc->sc_slot.slot, aeintr, sc);
/*
* XXX -- enable nubus interrupts here. Should be done elsewhere,

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,7 @@
/* $NetBSD: nubus.h,v 1.4 1995/04/21 02:48:01 briggs Exp $ */
/* $NetBSD: nubus.h,v 1.5 1995/04/29 20:23:48 briggs Exp $ */
/*-
* Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
* Michael L. Finch, Bradley A. Grantham, and
* Lawrence A. Kesteloot
* All rights reserved.
/*
* Copyright (c) 1995 Allen Briggs. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -16,80 +13,219 @@
* 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 Alice Group.
* 4. The names of the Alice Group or any of its members may not be used
* to endorse or promote products derived from this software without
* specific prior written permission.
* This product includes software developed by Allen Briggs.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``AS IS'' AND ANY EXPRESS OR
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT,
* IN NO EVENT SHALL THE AUTHOR 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.
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define NUBUS_VIDEO 3
#define NUBUS_NETWORK 4
#define NUBUS_MOTHERBOARD 0x0a
#define NUBUS_MAXSLOTS 16
/*
* Nubus cards in Macintoshes are identified by 4 16-bit numbers:
* Category: What is the main purpose of this card?
* Type: Within this overall category, what kind of card?
* DrSW: What software interface does it use?
* DrHW: What specific hardware is it?
*
* For example, the "Toby Frame Buffer" display card is
* Category 3 (display)
* Type 1 (video)
* DrSW 1 (Apple)
* and DrHW 1 (TFB).
*/
struct imagedata {
long whatTheHellIsThis;
long offset;
short rowbytes;
short top;
short left;
short right;
short bottom;
short version;
short packType;
short packSize;
long hRes;
long vRes;
short pixelType;
short pixelSize;
#define NUBUS_CATEGORY_BOARD 0x0001
#define NUBUS_CATEGORY_DISPLAY 0x0003
#define NUBUS_TYPE_VIDEO 0x0001
#define NUBUS_TYPE_LCD 0x0002
#define NUBUS_DRSW_APPLE 0x0001
#define NUBUS_DRHW_TFB 0x0001
#define NUBUS_DRHW_M2HRVC 0x0013
#define NUBUS_DRHW_MICRON 0x0146
#define NUBUS_CATEGORY_NETWORK 0x0004
#define NUBUS_TYPE_ETHERNET 0x0001
#define NUBUS_DRSW_3COM 0x0000
#define NUBUS_DRSW_ASANTE 0x0104
#define NUBUS_DRSW_DAYNA 0x0105 /* XXX */
#define NUBUS_DRSW_INTERLAN 0x0106 /* XXX */
#define NUBUS_DRHW_SONIC 0x0110
#define NUBUS_CATEGORY_FONT 0x0009 /* KanjiTalk Font Card? */
#define NUBUS_CATEGORY_CPU 0x000A
#define NUBUS_TYPE_68000 0x0002
#define NUBUS_TYPE_68020 0x0003
#define NUBUS_TYPE_68030 0x0004
#define NUBUS_TYPE_68040 0x0005
/*
* This is the same as Apple's Format Block for a card, with the
* addition of a pointer to the base of the NuBUS slot.
*
* This basically describes a nubus card--this structure is held in the last
* N bytes of each valid card's declaration ROM.
*/
typedef struct _nubus_slot {
u_long top;
u_int8_t slot;
u_int8_t bytelanes;
u_int8_t step;
u_int32_t test_pattern;
u_int8_t format;
u_int8_t revision_level;
u_int32_t crc;
u_int32_t length;
u_int32_t directory_offset;
} nubus_slot;
/*
* Just a structure to ease comparison of type for drivers, etc.
*/
typedef struct _nubus_type {
u_int16_t category;
u_int16_t type;
u_int16_t drsw;
u_int16_t drhw;
} nubus_type;
/*
* nubus_dir is a structure that describes a nubus directory.
* The nubus*dir() functions should be used to traverse this.
*/
typedef struct _nubus_dir {
u_int32_t dirbase;
u_int32_t curr_ent;
} nubus_dir;
/*
* This is the equivalent of an Apple sResource directory entry
* with the addition of a pointer to itself (essentially) for easy
* calculation of jump to indirect data.
*/
typedef struct _nubus_dirent {
u_int32_t myloc;
u_int8_t rsrc_id;
u_int32_t offset;
} nubus_dirent;
/*
* This is the equivalent of an Apple sResource with the addition of
* a pointer back to the sResource directory from whence we came.
*
* According to the Apple documentation, each sResource is of one of the
* following forms:
* all: bits 31-24 Identification number
*
* offset: bits 23-0 Offset to long data, cString, sBlock, etc.
* word: bits 23-16 0x00
* bits 15-0 word data
* byte: bits 23-8 0x0000
* bits 7-0 byte data
*
* The last resource has id = 0xff and data = 0x000000.
*/
typedef struct _nubus_rsrc {
u_int32_t myloc;
u_int8_t id;
u_int32_t data;
} nubus_rsrc;
/* Resource IDs for NUBUS_CATEGORY_* (All) */
#define NUBUS_RSRC_TYPE 0x01 /* Type (required) */
#define NUBUS_RSRC_NAME 0x02 /* Name (required) */
#define NUBUS_RSRC_ICON 0x03 /* Icon */
#define NUBUS_RSRC_DRVRDIR 0x04 /* Driver directory */
#define NUBUS_RSRC_LOADREC 0x05 /* Load record for resource */
#define NUBUS_RSRC_BOOTREC 0x06 /* Boot record */
#define NUBUS_RSRC_FLAGS 0x07 /* sResource Flags */
#define NUBUS_RSRC_HWDEVID 0x08 /* Hardware device ID */
#define NUBUS_RSRC_MINOR_BASEOS 0x0A /* Offset to hw in std space */
#define NUBUS_RSRC_MINOR_LENGTH 0x0B /* Length of std space */
#define NUBUS_RSRC_MAJOR_BASEOS 0x0C /* Offset to hw in super space */
#define NUBUS_RSRC_MAJOR_LENGTH 0x0D /* Length of super space */
#define NUBUS_RSRC_CICN 0x0F /* Color icon */
#define NUBUS_RSRC_ICL8 0x10 /* 8-bit icon data */
#define NUBUS_RSRC_ICL4 0x11 /* 4-bit icon data */
/* Resource IDs for NUBUS_CATEGORY_DISPLAY */
#define NUBUS_RSRC_GAMMADIR 0x40 /* ID for gamma directory */
#define NUBUS_RSRC_VIDNAMES 0x41 /* ID for video name directory */
#define NUBUS_RSRC_FIRSTMODE 0x80 /* ID for first mode (1-bit) */
#define NUBUS_RSRC_SECONDMODE 0x81 /* ID for 2nd mode (2-bit) */
#define NUBUS_RSRC_THIRDMODE 0x82 /* ID for 3rd mode (4-bit) */
#define NUBUS_RSRC_FOURTHMODE 0x83 /* ID for 4th mode (8-bit) */
#define NUBUS_RSRC_FIFTHMODE 0x84 /* ID for 5th mode (16-bit) */
#define NUBUS_RSRC_SIXTHMODE 0x85 /* ID for 6th mode (32-bit) */
/* Resource IDs for NUBUS_CATEGORY_BOARD */
#define NUBUS_RSRC_BOARDID 0x20 /* Board ID */
#define NUBUS_RSRC_PRAMINITDATA 0x21 /* Private board data for PRAM */
#define NUBUS_RSRC_PRIMARYINIT 0x22 /* Primary init record */
#define NUBUS_RSRC_TIMEOUTCONST 0x23 /* Timeout constant */
#define NUBUS_RSRC_VENDORINFO 0x24 /* Vendor info list */
#define NUBUS_RSRC_BOARDFLAGS 0x25 /* Board flags */
#define NUBUS_RSRC_SECONDINIT 0x26 /* Secondary init record */
#define NUBUS_RSRC_VEND_ID 0x01 /* Card vendor's design ID */
#define NUBUS_RSRC_VEND_SERIAL 0x02 /* Card's serial number */
#define NUBUS_RSRC_VEND_REV 0x03 /* Card design's revision level */
#define NUBUS_RSRC_VEND_PART 0x04 /* Card part number */
#define NUBUS_RSRC_VEND_DATE 0x05 /* Card revision date */
typedef struct _NUBUS_DRIVER {
u_int8_t drvr_id;
u_int32_t offset;
} NUBUS_DRIVER;
typedef struct _NUBUS_BLOCK {
u_int32_t size; /* Size of block of data */
caddr_t data; /* Pointer to data */
} NUBUS_BLOCK;
typedef struct _NUBUS_EXEC_BLOCK {
u_int32_t size; /* Size of total block - 4 */
u_int8_t revision; /* Always 0x2 */
u_int8_t cpu; /* Which processor? */
u_int32_t code_offset; /* Offset base to start of code */
caddr_t code; /* pointer to base of code. */
} NUBUS_EXEC_BLOCK;
#define NUBUS_EXEC_CPU_68000 1
#define NUBUS_EXEC_CPU_68020 2
#define NUBUS_EXEC_CPU_68030 3
#define NUBUS_EXEC_CPU_68040 4
#define NUBUS_MIN_SLOT 0x9
#define NUBUS_MAX_SLOT 0xE
#define NUBUS_ROM_TEST_PATTERN 0x5A932BC7
#define NUBUS_BASE_TO_SLOT(x) (((x) >> 24) & 0x0F)
#define NUBUS_SLOT_TO_BASE(x) (0xF0000000 | (((x) & 0xF) << 24))
struct nubus_softc {
struct device sc_dev;
};
/* this is the main data structure that points to good stuff */
struct header {
long offset;
long length;
long crc;
char romrev;
char format;
long tst;
char reserved;
char bytelane;
};
void nubus_get_main_dir __P((nubus_slot *slot, nubus_dir *dir_return));
int nubus_find_rsrc __P((nubus_slot *slot, nubus_dir *dir, u_int8_t rsrcid,
nubus_dirent *dirent_return));
void nubus_get_dir_from_rsrc __P((nubus_slot *slot, nubus_dirent *dirent,
nubus_dir *dir_return));
int nubus_get_ind_data __P((nubus_slot *slot, nubus_dirent *dirent,
caddr_t data_return, int nbytes));
int nubus_get_c_string __P((nubus_slot *slot, nubus_dirent *dirent,
caddr_t data_return, int max_bytes));
char *nubus_get_vendor __P((nubus_slot *slot, int rsrc));
char *nubus_get_card_name __P((nubus_slot *slot));
/* this is what the directory entries contain */
struct dir {
unsigned char rsrc;
unsigned long offset;
unsigned long base;
};
/* describe a single slot */
struct slot {
int size;
struct header head;
struct dir mainDir[15];
long type;
char name[40];
char manufacturer[40];
};
struct nubus_hw {
int found; /* If there is a card there */
caddr_t addr; /* Phys addr of start of card */
caddr_t rom; /* Phys addr of start of ROM */
int claimed; /* TRUE if a driver claims this */
struct slot slot; /* MF NUBUS STUFF */
/* any other Nubus stuff we can think of when we get */
/* the NuBus documentation */
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: grfioctl.h,v 1.2 1994/10/26 08:46:32 cgd Exp $ */
/* $NetBSD: grfioctl.h,v 1.3 1995/04/29 20:23:50 briggs Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -42,6 +42,43 @@
* @(#)grfioctl.h 7.2 (Berkeley) 11/4/90
*/
struct grfmode {
u_int8_t mode_id; /* Identifier for mode. */
caddr_t fbbase; /* Base of frame buffer */
u_int32_t fbsize; /* Size of frame buffer */
u_int16_t rowbytes; /* Screen rowbytes */
u_int16_t width; /* Screen width */
u_int16_t height; /* Screen height */
u_int16_t hres; /* Horizontal resolution (dpi) */
u_int16_t vres; /* Vertical resolution (dpi) */
u_int16_t ptype; /* 0 = indexed, 0x10 = direct */
u_int16_t psize; /* Screen depth */
};
struct grfmodes {
int nmodes; /* Number of modes in modelist */
struct grfmode *modelist; /* Pointer to space for modes */
};
/*
* BSD ioctls (first few match HP/UX ioctl()s. In case we want
* compatibility later, start our own at 16).
*/
#define GRFIOCGINFO _IOR('G', 0, struct grfinfo) /* get info on device */
#define GRFIOCON _IO('G', 1) /* turn graphics on */
#define GRFIOCOFF _IO('G', 2) /* turn graphics off */
#define GRFIOCMAP _IOWR('G', 5, int) /* map in regs+framebuffer */
#define GRFIOCUNMAP _IOW('G', 6, int) /* unmap regs+framebuffer */
#define GRFIOCLISTMODES _IOWR('G', 16, struct grfmodes) /* Get list of modes */
#define GRFIOCGETMODE _IOR('G', 17, int) /* Get list of modes */
#define GRFIOCSETMODE _IOW('G', 18, int) /* Set to mode_id mode */
/*
* Obsolete structure.
* Only used to return information to older programs that still
* depend on GRFIOCGINFO.
*/
struct grfinfo {
int gd_id; /* HPUX identifier */
caddr_t gd_regaddr; /* control registers physaddr */
@ -50,7 +87,6 @@ struct grfinfo {
int gd_fbsize; /* frame buffer size */
short gd_colors; /* number of colors */
short gd_planes; /* number of planes */
/* new stuff */
int gd_fbwidth; /* frame buffer width */
int gd_fbheight; /* frame buffer height */
int gd_fbrowbytes; /* frame buffer rowbytes */
@ -59,50 +95,3 @@ struct grfinfo {
int gd_pad[6]; /* for future expansion */
};
/* types */
#define GRFMAC 8
/*
* HPUX ioctls (here for the benefit of the driver)
*/
struct grf_slot {
int slot;
u_char *addr;
};
#ifndef _IOH
#define _IOH(x,y) (IOC_IN|((x)<<8)|y) /* IOC_IN is IOC_VOID */
#define GCID _IOR('G', 0, int)
#define GCON _IOH('G', 1)
#define GCOFF _IOH('G', 2)
#define GCAON _IOH('G', 3)
#define GCAOFF _IOH('G', 4)
#define GCMAP _IOWR('G', 5, int)
#define GCUNMAP _IOWR('G', 6, int)
#define GCLOCK _IOH('G', 7)
#define GCUNLOCK _IOH('G', 8)
#define GCLOCK_MINIMUM _IOH('G', 9)
#define GCUNLOCK_MINIMUM _IOH('G', 10)
#define GCSTATIC_CMAP _IOH('G', 11)
#define GCVARIABLE_CMAP _IOH('G', 12)
#define GCSLOT _IOWR('G', 13, struct grf_slot)
/* XXX: for now */
#define IOMAPID _IOR('M',0,int) /* ??? */
#define IOMAPMAP _IOWR('M',1,int)
#define IOMAPUNMAP _IOWR('M',2,int)
#endif
/*
* BSD ioctls
*/
#define GRFIOCGINFO _IOR('G', 0, struct grfinfo) /* get info on device */
#define GRFIOCON _IO('G', 1) /* turn graphics on */
#define GRFIOCOFF _IO('G', 2) /* turn graphics off */
#define GRFIOCMAP _IOWR('G', 5, int) /* map in regs+framebuffer */
#define GRFIOCUNMAP _IOW('G', 6, int) /* unmap regs+framebuffer */
/* compat - for old grfinfo structure */
struct ogrfinfo { char oinfo[24]; };
#define OGRFIOCGINFO _IOR('G', 0, struct ogrfinfo)

View File

@ -1,4 +1,4 @@
/* $NetBSD: via.c,v 1.19 1995/04/21 04:00:55 briggs Exp $ */
/* $NetBSD: via.c,v 1.20 1995/04/29 20:23:53 briggs Exp $ */
/*-
* Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
@ -140,10 +140,6 @@ void VIA_initialize()
via2itab[1] = via2_nubus_intr;
}else{ /* RBV */
/* I'm sure that I'll find something to put in here
someday. -- BG */
/* enable specific interrupts */
/* via_reg(VIA2, rIER) = RBV_INTS | 0x80; */
real_via2_intr = rbv_intr;
via2itab[1] = rbv_nubus_intr;
}
@ -244,16 +240,14 @@ long via2_noint(int bitnum)
static int nubus_intr_mask = 0;
int
add_nubus_intr(addr, func, client_data)
int addr;
add_nubus_intr(slot, func, client_data)
int slot;
void (*func)();
void *client_data;
{
int s = splhigh();
int slot;
slot = nubus_addr_to_slot(addr);
if (slot < 0) return 0;
if (slot < 9 || slot > 15) return 0;
slotitab[slot-9] = func;
slotptab[slot-9] = client_data;

View File

@ -0,0 +1,213 @@
/* $NetBSD: grf_nubus.c,v 1.1 1995/04/29 20:23:42 briggs Exp $ */
/*
* Copyright (c) 1995 Allen Briggs. All rights reserved.
*
* 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 Allen Briggs.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/*
* Device-specific routines for handling Nubus-based video cards.
*/
#include <sys/param.h>
#include <sys/device.h>
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/malloc.h>
#include <sys/mman.h>
#include <sys/proc.h>
#include <machine/grfioctl.h>
#include <machine/cpu.h>
#include "nubus.h"
#include "grfvar.h"
extern int grfmv_probe __P((struct grf_softc *gp, nubus_slot *slot));
extern int grfmv_init __P((struct grf_softc *gp));
extern int grfmv_mode __P((struct grf_softc *gp, int cmd, void *arg));
static char zero = 0;
static void
load_image_data(data, image)
caddr_t data;
struct image_data *image;
{
bcopy(data , &image->size, 4);
bcopy(data + 4, &image->offset, 4);
bcopy(data + 8, &image->rowbytes, 2);
bcopy(data + 10, &image->top, 2);
bcopy(data + 12, &image->left, 2);
bcopy(data + 14, &image->bottom, 2);
bcopy(data + 16, &image->right, 2);
bcopy(data + 18, &image->version, 2);
bcopy(data + 20, &image->packType, 2);
bcopy(data + 22, &image->packSize, 4);
bcopy(data + 26, &image->hRes, 4);
bcopy(data + 30, &image->vRes, 4);
bcopy(data + 34, &image->pixelType, 2);
bcopy(data + 36, &image->pixelSize, 2);
bcopy(data + 38, &image->cmpCount, 2);
bcopy(data + 40, &image->cmpSize, 2);
bcopy(data + 42, &image->planeBytes, 4);
}
static void
grfmv_intr(sc, slot)
struct grf_softc *sc;
int slot;
{
struct grf_softc *gp;
((char *) (((u_long) (0xf0 | slot)) << 24))[0xa0000] = zero;
}
extern int
grfmv_probe(sc, slot)
struct grf_softc *sc;
nubus_slot *slot;
{
nubus_dir dir, *dirp, dir2, *dirp2;
nubus_dirent dirent, *direntp;
nubus_type slottype;
dirp = &dir;
direntp = &dirent;
nubus_get_main_dir(slot, dirp);
/*
* Unfortunately, I think we'll have to load this value from
* the macos. The alternative is putting in enough hooks to
* be able to call the card's PrimaryInit routine which could
* call just about any part of the ROM, I think.
*/
if (nubus_find_rsrc(slot, dirp, 128, direntp) <= 0) {
if (nubus_find_rsrc(slot, dirp, 129, direntp) <= 0) {
return 0;
}
}
dirp2 = (nubus_dir *) &sc->board_dir;
nubus_get_dir_from_rsrc(slot, direntp, dirp2);
if (nubus_find_rsrc(slot, dirp2, NUBUS_RSRC_TYPE, direntp) <= 0)
/* Type is a required entry... This should never happen. */
return 0;
if (nubus_get_ind_data(slot, direntp,
(caddr_t) &slottype, sizeof(nubus_type)) <= 0)
return 0;
if (slottype.category != NUBUS_CATEGORY_DISPLAY)
return 0;
if (slottype.type != NUBUS_TYPE_VIDEO)
return 0;
if (slottype.drsw != NUBUS_DRSW_APPLE)
return 0;
/*
* If we've gotten this far, then we're dealing with a real-live
* Apple QuickDraw-compatible display card resource. Now, how to
* determine that this is an active resource??? Dunno. But we'll
* proceed like it is.
*/
sc->card_id = slottype.drhw;
printf("card id = 0x%x.\n", sc->card_id);
/* Need to load display info (and driver?), etc... */
return 1;
}
extern int
grfmv_init(sc)
struct grf_softc *sc;
{
struct image_data image_store, image;
nubus_dirent dirent;
nubus_dir mode_dir;
int mode;
u_long base;
mode = NUBUS_RSRC_FIRSTMODE;
if (nubus_find_rsrc(&sc->sc_slot, &sc->board_dir, mode, &dirent) <= 0)
return 0;
nubus_get_dir_from_rsrc(&sc->sc_slot, &dirent, &mode_dir);
if (nubus_find_rsrc(&sc->sc_slot, &mode_dir, VID_PARAMS, &dirent) <= 0)
return 0;
if (nubus_get_ind_data(&sc->sc_slot, &dirent, (caddr_t) &image_store,
sizeof(struct image_data)) <= 0)
return 0;
load_image_data((caddr_t) &image_store, &image);
base = NUBUS_SLOT_TO_BASE(sc->sc_slot.slot);
sc->curr_mode.mode_id = mode;
sc->curr_mode.fbbase = (caddr_t) (base + image.offset);
sc->curr_mode.rowbytes = image.rowbytes;
sc->curr_mode.width = image.right - image.left;
sc->curr_mode.height = image.bottom - image.top;
sc->curr_mode.fbsize = sc->curr_mode.height * sc->curr_mode.rowbytes;
sc->curr_mode.hres = image.hRes;
sc->curr_mode.vres = image.vRes;
sc->curr_mode.ptype = image.pixelType;
sc->curr_mode.psize = image.pixelSize;
strncpy(sc->card_name, nubus_get_card_name(&sc->sc_slot),
CARD_NAME_LEN);
sc->card_name[CARD_NAME_LEN-1] = '\0';
add_nubus_intr(sc->sc_slot.slot, grfmv_intr, sc);
return 1;
}
extern int
grfmv_mode(gp, cmd, arg)
struct grf_softc *gp;
int cmd;
void *arg;
{
switch (cmd) {
case GM_CURRMODE:
break;
case GM_NEWMODE:
break;
case GM_LISTMODES:
break;
}
return EINVAL;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,7 @@
/* $NetBSD: nubus.h,v 1.4 1995/04/21 02:48:01 briggs Exp $ */
/* $NetBSD: nubus.h,v 1.5 1995/04/29 20:23:48 briggs Exp $ */
/*-
* Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
* Michael L. Finch, Bradley A. Grantham, and
* Lawrence A. Kesteloot
* All rights reserved.
/*
* Copyright (c) 1995 Allen Briggs. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -16,80 +13,219 @@
* 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 Alice Group.
* 4. The names of the Alice Group or any of its members may not be used
* to endorse or promote products derived from this software without
* specific prior written permission.
* This product includes software developed by Allen Briggs.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``AS IS'' AND ANY EXPRESS OR
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT,
* IN NO EVENT SHALL THE AUTHOR 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.
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define NUBUS_VIDEO 3
#define NUBUS_NETWORK 4
#define NUBUS_MOTHERBOARD 0x0a
#define NUBUS_MAXSLOTS 16
/*
* Nubus cards in Macintoshes are identified by 4 16-bit numbers:
* Category: What is the main purpose of this card?
* Type: Within this overall category, what kind of card?
* DrSW: What software interface does it use?
* DrHW: What specific hardware is it?
*
* For example, the "Toby Frame Buffer" display card is
* Category 3 (display)
* Type 1 (video)
* DrSW 1 (Apple)
* and DrHW 1 (TFB).
*/
struct imagedata {
long whatTheHellIsThis;
long offset;
short rowbytes;
short top;
short left;
short right;
short bottom;
short version;
short packType;
short packSize;
long hRes;
long vRes;
short pixelType;
short pixelSize;
#define NUBUS_CATEGORY_BOARD 0x0001
#define NUBUS_CATEGORY_DISPLAY 0x0003
#define NUBUS_TYPE_VIDEO 0x0001
#define NUBUS_TYPE_LCD 0x0002
#define NUBUS_DRSW_APPLE 0x0001
#define NUBUS_DRHW_TFB 0x0001
#define NUBUS_DRHW_M2HRVC 0x0013
#define NUBUS_DRHW_MICRON 0x0146
#define NUBUS_CATEGORY_NETWORK 0x0004
#define NUBUS_TYPE_ETHERNET 0x0001
#define NUBUS_DRSW_3COM 0x0000
#define NUBUS_DRSW_ASANTE 0x0104
#define NUBUS_DRSW_DAYNA 0x0105 /* XXX */
#define NUBUS_DRSW_INTERLAN 0x0106 /* XXX */
#define NUBUS_DRHW_SONIC 0x0110
#define NUBUS_CATEGORY_FONT 0x0009 /* KanjiTalk Font Card? */
#define NUBUS_CATEGORY_CPU 0x000A
#define NUBUS_TYPE_68000 0x0002
#define NUBUS_TYPE_68020 0x0003
#define NUBUS_TYPE_68030 0x0004
#define NUBUS_TYPE_68040 0x0005
/*
* This is the same as Apple's Format Block for a card, with the
* addition of a pointer to the base of the NuBUS slot.
*
* This basically describes a nubus card--this structure is held in the last
* N bytes of each valid card's declaration ROM.
*/
typedef struct _nubus_slot {
u_long top;
u_int8_t slot;
u_int8_t bytelanes;
u_int8_t step;
u_int32_t test_pattern;
u_int8_t format;
u_int8_t revision_level;
u_int32_t crc;
u_int32_t length;
u_int32_t directory_offset;
} nubus_slot;
/*
* Just a structure to ease comparison of type for drivers, etc.
*/
typedef struct _nubus_type {
u_int16_t category;
u_int16_t type;
u_int16_t drsw;
u_int16_t drhw;
} nubus_type;
/*
* nubus_dir is a structure that describes a nubus directory.
* The nubus*dir() functions should be used to traverse this.
*/
typedef struct _nubus_dir {
u_int32_t dirbase;
u_int32_t curr_ent;
} nubus_dir;
/*
* This is the equivalent of an Apple sResource directory entry
* with the addition of a pointer to itself (essentially) for easy
* calculation of jump to indirect data.
*/
typedef struct _nubus_dirent {
u_int32_t myloc;
u_int8_t rsrc_id;
u_int32_t offset;
} nubus_dirent;
/*
* This is the equivalent of an Apple sResource with the addition of
* a pointer back to the sResource directory from whence we came.
*
* According to the Apple documentation, each sResource is of one of the
* following forms:
* all: bits 31-24 Identification number
*
* offset: bits 23-0 Offset to long data, cString, sBlock, etc.
* word: bits 23-16 0x00
* bits 15-0 word data
* byte: bits 23-8 0x0000
* bits 7-0 byte data
*
* The last resource has id = 0xff and data = 0x000000.
*/
typedef struct _nubus_rsrc {
u_int32_t myloc;
u_int8_t id;
u_int32_t data;
} nubus_rsrc;
/* Resource IDs for NUBUS_CATEGORY_* (All) */
#define NUBUS_RSRC_TYPE 0x01 /* Type (required) */
#define NUBUS_RSRC_NAME 0x02 /* Name (required) */
#define NUBUS_RSRC_ICON 0x03 /* Icon */
#define NUBUS_RSRC_DRVRDIR 0x04 /* Driver directory */
#define NUBUS_RSRC_LOADREC 0x05 /* Load record for resource */
#define NUBUS_RSRC_BOOTREC 0x06 /* Boot record */
#define NUBUS_RSRC_FLAGS 0x07 /* sResource Flags */
#define NUBUS_RSRC_HWDEVID 0x08 /* Hardware device ID */
#define NUBUS_RSRC_MINOR_BASEOS 0x0A /* Offset to hw in std space */
#define NUBUS_RSRC_MINOR_LENGTH 0x0B /* Length of std space */
#define NUBUS_RSRC_MAJOR_BASEOS 0x0C /* Offset to hw in super space */
#define NUBUS_RSRC_MAJOR_LENGTH 0x0D /* Length of super space */
#define NUBUS_RSRC_CICN 0x0F /* Color icon */
#define NUBUS_RSRC_ICL8 0x10 /* 8-bit icon data */
#define NUBUS_RSRC_ICL4 0x11 /* 4-bit icon data */
/* Resource IDs for NUBUS_CATEGORY_DISPLAY */
#define NUBUS_RSRC_GAMMADIR 0x40 /* ID for gamma directory */
#define NUBUS_RSRC_VIDNAMES 0x41 /* ID for video name directory */
#define NUBUS_RSRC_FIRSTMODE 0x80 /* ID for first mode (1-bit) */
#define NUBUS_RSRC_SECONDMODE 0x81 /* ID for 2nd mode (2-bit) */
#define NUBUS_RSRC_THIRDMODE 0x82 /* ID for 3rd mode (4-bit) */
#define NUBUS_RSRC_FOURTHMODE 0x83 /* ID for 4th mode (8-bit) */
#define NUBUS_RSRC_FIFTHMODE 0x84 /* ID for 5th mode (16-bit) */
#define NUBUS_RSRC_SIXTHMODE 0x85 /* ID for 6th mode (32-bit) */
/* Resource IDs for NUBUS_CATEGORY_BOARD */
#define NUBUS_RSRC_BOARDID 0x20 /* Board ID */
#define NUBUS_RSRC_PRAMINITDATA 0x21 /* Private board data for PRAM */
#define NUBUS_RSRC_PRIMARYINIT 0x22 /* Primary init record */
#define NUBUS_RSRC_TIMEOUTCONST 0x23 /* Timeout constant */
#define NUBUS_RSRC_VENDORINFO 0x24 /* Vendor info list */
#define NUBUS_RSRC_BOARDFLAGS 0x25 /* Board flags */
#define NUBUS_RSRC_SECONDINIT 0x26 /* Secondary init record */
#define NUBUS_RSRC_VEND_ID 0x01 /* Card vendor's design ID */
#define NUBUS_RSRC_VEND_SERIAL 0x02 /* Card's serial number */
#define NUBUS_RSRC_VEND_REV 0x03 /* Card design's revision level */
#define NUBUS_RSRC_VEND_PART 0x04 /* Card part number */
#define NUBUS_RSRC_VEND_DATE 0x05 /* Card revision date */
typedef struct _NUBUS_DRIVER {
u_int8_t drvr_id;
u_int32_t offset;
} NUBUS_DRIVER;
typedef struct _NUBUS_BLOCK {
u_int32_t size; /* Size of block of data */
caddr_t data; /* Pointer to data */
} NUBUS_BLOCK;
typedef struct _NUBUS_EXEC_BLOCK {
u_int32_t size; /* Size of total block - 4 */
u_int8_t revision; /* Always 0x2 */
u_int8_t cpu; /* Which processor? */
u_int32_t code_offset; /* Offset base to start of code */
caddr_t code; /* pointer to base of code. */
} NUBUS_EXEC_BLOCK;
#define NUBUS_EXEC_CPU_68000 1
#define NUBUS_EXEC_CPU_68020 2
#define NUBUS_EXEC_CPU_68030 3
#define NUBUS_EXEC_CPU_68040 4
#define NUBUS_MIN_SLOT 0x9
#define NUBUS_MAX_SLOT 0xE
#define NUBUS_ROM_TEST_PATTERN 0x5A932BC7
#define NUBUS_BASE_TO_SLOT(x) (((x) >> 24) & 0x0F)
#define NUBUS_SLOT_TO_BASE(x) (0xF0000000 | (((x) & 0xF) << 24))
struct nubus_softc {
struct device sc_dev;
};
/* this is the main data structure that points to good stuff */
struct header {
long offset;
long length;
long crc;
char romrev;
char format;
long tst;
char reserved;
char bytelane;
};
void nubus_get_main_dir __P((nubus_slot *slot, nubus_dir *dir_return));
int nubus_find_rsrc __P((nubus_slot *slot, nubus_dir *dir, u_int8_t rsrcid,
nubus_dirent *dirent_return));
void nubus_get_dir_from_rsrc __P((nubus_slot *slot, nubus_dirent *dirent,
nubus_dir *dir_return));
int nubus_get_ind_data __P((nubus_slot *slot, nubus_dirent *dirent,
caddr_t data_return, int nbytes));
int nubus_get_c_string __P((nubus_slot *slot, nubus_dirent *dirent,
caddr_t data_return, int max_bytes));
char *nubus_get_vendor __P((nubus_slot *slot, int rsrc));
char *nubus_get_card_name __P((nubus_slot *slot));
/* this is what the directory entries contain */
struct dir {
unsigned char rsrc;
unsigned long offset;
unsigned long base;
};
/* describe a single slot */
struct slot {
int size;
struct header head;
struct dir mainDir[15];
long type;
char name[40];
char manufacturer[40];
};
struct nubus_hw {
int found; /* If there is a card there */
caddr_t addr; /* Phys addr of start of card */
caddr_t rom; /* Phys addr of start of ROM */
int claimed; /* TRUE if a driver claims this */
struct slot slot; /* MF NUBUS STUFF */
/* any other Nubus stuff we can think of when we get */
/* the NuBus documentation */
};

View File

@ -0,0 +1,101 @@
/* $NetBSD: grf_obio.c,v 1.1 1995/04/29 20:23:41 briggs Exp $ */
/*
* Copyright (c) 1995 Allen Briggs. All rights reserved.
*
* 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 Allen Briggs.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/*
* Graphics display driver for the Macintosh internal video for machines
* that don't map it into a fake nubus card.
*/
#include <sys/param.h>
#include <sys/device.h>
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/malloc.h>
#include <sys/mman.h>
#include <sys/proc.h>
#include <machine/grfioctl.h>
#include <machine/cpu.h>
#include "nubus.h"
#include "grfvar.h"
extern int grfiv_probe __P((struct grf_softc *sc, nubus_slot *ignore));
extern int grfiv_init __P((struct grf_softc *sc));
extern int grfiv_mode __P((struct grf_softc *sc, int cmd, void *arg));
extern int
grfiv_probe(sc, ignore)
struct grf_softc *sc;
nubus_slot *ignore;
{
extern unsigned long int_video_start;
if (int_video_start == 0) {
return 0;
}
return 1;
}
extern int
grfiv_init(sc)
struct grf_softc *sc;
{
struct grfmode *gm;
int i, j;
sc->card_id = 0;
strcpy(sc->card_name, "Internal video");
gm = &(sc->curr_mode);
gm->mode_id = 0;
gm->psize = 1;
gm->ptype = 0;
gm->width = 640; /* XXX */
gm->height = 480; /* XXX */
gm->rowbytes = 80; /* XXX Hack */
gm->hres = 80; /* XXX Hack */
gm->vres = 80; /* XXX Hack */
gm->fbsize = gm->width * gm->height;
gm->fbbase = (caddr_t) 0;
return 1;
}
extern int
grfiv_mode(sc, cmd, arg)
struct grf_softc *sc;
int cmd;
void *arg;
{
return 0;
}