diff --git a/sys/arch/mac68k/dev/grf.c b/sys/arch/mac68k/dev/grf.c index 211540fe91a8..508935afb199 100644 --- a/sys/arch/mac68k/dev/grf.c +++ b/sys/arch/mac68k/dev/grf.c @@ -1,4 +1,4 @@ -/* $NetBSD: grf.c,v 1.32 1996/05/06 01:08:24 briggs Exp $ */ +/* $NetBSD: grf.c,v 1.33 1996/05/19 22:27:04 scottr Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -81,18 +81,63 @@ #define iteoff(u,f) #endif +int grfmatch __P((struct device *, void *, void *)); +void grfattach __P((struct device *, struct device *, void *)); + struct cfdriver grf_cd = { NULL, "grf", DV_DULL }; +struct cfattach grf_ca = { + sizeof(struct grf_softc), grfmatch, grfattach +}; + #ifdef DEBUG -static int grfdebug = 0xff; #define GDB_DEVNO 0x01 #define GDB_MMAP 0x02 #define GDB_IOMAP 0x04 #define GDB_LOCK 0x08 +static int grfdebug = (GDB_DEVNO|GDB_MMAP|GDB_IOMAP|GDB_LOCK); #endif +int +grfmatch(parent, match, aux) + struct device *parent; + void *match, *aux; +{ + 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; + + printf("\n"); + + /* Load forwarded pointers. */ + sc->sc_grfmode = ga->ga_grfmode; + sc->sc_slot = ga->ga_slot; + sc->sc_mode = ga->ga_mode; + sc->sc_phys = ga->ga_phys; + + sc->sc_flags = GF_ALIVE; /* XXX bogus */ + +#ifdef notyet + /* + * Attach ite semantics to the grf. Change the name, forward + * everything else. + */ + ga->ga_name = "ite"; + (void)config_found(self, ga, grfbusprint); +#endif +} + /*ARGSUSED*/ int grfopen(dev, flag, mode, p) @@ -108,10 +153,10 @@ grfopen(dev, flag, mode, p) unit = GRFUNIT(dev); gp = grf_cd.cd_devs[unit]; - if (unit >= grf_cd.cd_ndevs || (gp->g_flags & GF_ALIVE) == 0) + if (unit >= grf_cd.cd_ndevs || (gp->sc_flags & GF_ALIVE) == 0) return (ENXIO); - if ((gp->g_flags & (GF_OPEN | GF_EXCLUDE)) == (GF_OPEN | GF_EXCLUDE)) + if ((gp->sc_flags & (GF_OPEN | GF_EXCLUDE)) == (GF_OPEN | GF_EXCLUDE)) return (EBUSY); /* @@ -119,8 +164,8 @@ grfopen(dev, flag, mode, p) * XXX: always put in graphics mode. */ error = 0; - if ((gp->g_flags & GF_OPEN) == 0) { - gp->g_flags |= GF_OPEN; + if ((gp->sc_flags & GF_OPEN) == 0) { + gp->sc_flags |= GF_OPEN; error = grfon(dev); } return (error); @@ -139,7 +184,7 @@ grfclose(dev, flag, mode, p) gp = grf_cd.cd_devs[GRFUNIT(dev)]; (void) grfoff(dev); - gp->g_flags &= GF_ALIVE; + gp->sc_flags &= GF_ALIVE; return (0); } @@ -153,11 +198,13 @@ grfioctl(dev, cmd, data, flag, p) int flag; struct proc *p; { - register struct grf_softc *gp; + struct grf_softc *gp; + struct grfmode *gm; int error; int unit = GRFUNIT(dev); gp = grf_cd.cd_devs[unit]; + gm = gp->sc_grfmode; error = 0; switch (cmd) { @@ -166,14 +213,14 @@ grfioctl(dev, cmd, data, flag, p) { 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; + g->gd_id = gm->mode_id; + g->gd_fbaddr = gm->fbbase; + g->gd_fbsize = gm->fbsize; + g->gd_colors = 1 << (u_int32_t) gm->psize; + 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; } break; @@ -191,16 +238,16 @@ grfioctl(dev, cmd, data, flag, p) break; case GRFIOCGMODE: - bcopy(&gp->curr_mode, data, sizeof(struct grfmode)); + bcopy(gm, data, sizeof(struct grfmode)); break; case GRFIOCGETMODE: - error = (*gp->g_mode)(gp, GM_CURRMODE, data); + error = (*gp->sc_mode)(gp, GM_CURRMODE, data); break; case GRFIOCSETMODE: - error = (*gp->g_mode)(gp, GM_NEWMODE, data); + error = (*gp->sc_mode)(gp, GM_NEWMODE, data); break; case GRFIOCLISTMODES: - error = (*gp->g_mode)(gp, GM_LISTMODES, data); + error = (*gp->sc_mode)(gp, GM_LISTMODES, data); break; default: @@ -252,7 +299,7 @@ grfon(dev) */ iteoff(unit, 3); - return (*gp->g_mode) (gp, GM_GRFON, NULL); + return (*gp->sc_mode) (gp, GM_GRFON, NULL); } int @@ -267,7 +314,7 @@ grfoff(dev) (void) grfunmap(dev, (caddr_t) 0, curproc); - error = (*gp->g_mode) (gp, GM_GRFOFF, NULL); + error = (*gp->sc_mode) (gp, GM_GRFOFF, NULL); /* XXX: see comment for iteoff above */ iteon(unit, 2); @@ -280,11 +327,11 @@ grfaddr(gp, off) struct grf_softc *gp; register int off; { - register struct grfmode *gm = &gp->curr_mode; + register struct grfmode *gm = gp->sc_grfmode; u_long addr; - if (off < mac68k_round_page(gm->fbsize + gm->fboff) ) { - addr = (u_long) (*gp->g_phys)(gp, (int) gm->fbbase) + off; + if (off < mac68k_round_page(gm->fbsize + gm->fboff)) { + addr = (u_long)(*gp->sc_phys)(gp, (vm_offset_t)gm->fbbase)+off; return mac68k_btop(addr); } /* bogus */ @@ -306,28 +353,27 @@ grfmap(dev, addrp, p) gp = grf_cd.cd_devs[GRFUNIT(dev)]; #ifdef DEBUG if (grfdebug & GDB_MMAP) - printf("grfmap(%d): addr %x\n", p->p_pid, *addrp); + printf("grfmap(%d): addr %p\n", p->p_pid, *addrp); #endif - len = mac68k_round_page(gp->curr_mode.fbsize + gp->curr_mode.fboff); + len = mac68k_round_page(gp->sc_grfmode->fbsize + gp->sc_grfmode->fboff); flags = MAP_SHARED | MAP_FIXED; *addrp = (caddr_t) mac68k_trunc_page( - NUBUS_SLOT_TO_PADDR(gp->sc_slot.slot)); + NUBUS_SLOT_TO_PADDR(gp->sc_slot->slot)); vn.v_type = VCHR; /* XXX */ vn.v_specinfo = &si; /* XXX */ vn.v_rdev = dev; /* XXX */ 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); + (vm_size_t) len, VM_PROT_ALL, VM_PROT_ALL, flags, (caddr_t) &vn, 0); /* Offset into page: */ - *addrp += (unsigned long) gp->curr_mode.fboff & 0xfff; + *addrp += (unsigned long) gp->sc_grfmode->fboff & 0xfff; #ifdef DEBUG if (grfdebug & GDB_MMAP) - printf("grfmap(%d): returning addr %x\n", p->p_pid, *addrp); + printf("grfmap(%d): returning addr %p\n", p->p_pid, *addrp); #endif return (error); @@ -347,13 +393,13 @@ grfunmap(dev, addr, p) #ifdef DEBUG if (grfdebug & GDB_MMAP) - printf("grfunmap(%d): dev %x addr %x\n", p->p_pid, dev, addr); + printf("grfunmap(%d): dev %x addr %p\n", p->p_pid, dev, addr); #endif if (addr == 0) return (EINVAL);/* XXX: how do we deal with this? */ - size = round_page(gp->curr_mode.fbsize); + size = round_page(gp->sc_grfmode->fbsize); rv = vm_deallocate(&p->p_vmspace->vm_map, (vm_offset_t) addr, size); diff --git a/sys/arch/mac68k/dev/grf_iv.c b/sys/arch/mac68k/dev/grf_iv.c index c721ba229c2b..53a98ce5bb06 100644 --- a/sys/arch/mac68k/dev/grf_iv.c +++ b/sys/arch/mac68k/dev/grf_iv.c @@ -1,4 +1,4 @@ -/* $NetBSD: grf_iv.c,v 1.11 1996/05/05 06:16:32 briggs Exp $ */ +/* $NetBSD: grf_iv.c,v 1.12 1996/05/19 22:27:06 scottr Exp $ */ /* * Copyright (c) 1995 Allen Briggs. All rights reserved. @@ -60,8 +60,12 @@ static caddr_t grfiv_phys __P((struct grf_softc *gp, vm_offset_t addr)); static int grfiv_match __P((struct device *, void *, void *)); static void grfiv_attach __P((struct device *, struct device *, void *)); -struct cfattach grf_iv_ca = { - sizeof(struct grf_softc), grfiv_match, grfiv_attach +struct cfdriver intvid_cd = { + NULL, "intvid", DV_DULL +}; + +struct cfattach intvid_ca = { + sizeof(struct grfbus_softc), grfiv_match, grfiv_attach }; static int @@ -83,16 +87,14 @@ grfiv_attach(parent, self, aux) struct device *parent, *self; void *aux; { - struct grf_softc *sc; + struct grfbus_softc *sc; struct grfmode *gm; - sc = (struct grf_softc *) self; + sc = (struct grfbus_softc *) self; sc->card_id = 0; - strcpy(sc->card_name, "Internal video"); - sc->g_mode = grfiv_mode; - sc->g_phys = grfiv_phys; + printf(": Internal Video\n"); gm = &(sc->curr_mode); gm->mode_id = 0; @@ -107,16 +109,8 @@ grfiv_attach(parent, self, aux) gm->fbbase = (caddr_t) mac68k_vidlog; gm->fboff = 0; - sc->g_flags = GF_ALIVE; - - printf(": %d x %d ", sc->curr_mode.width, sc->curr_mode.height); - - if (sc->curr_mode.psize == 1) - printf("monochrome"); - else - printf("%d color", 1 << sc->curr_mode.psize); - - printf(" %s display\n", sc->card_name); + /* Perform common video attachment. */ + grf_establish(sc, grfiv_mode, grfiv_phys); } static int diff --git a/sys/arch/mac68k/dev/grf_mv.c b/sys/arch/mac68k/dev/grf_mv.c index ab9346138308..a19390bc3c2c 100644 --- a/sys/arch/mac68k/dev/grf_mv.c +++ b/sys/arch/mac68k/dev/grf_mv.c @@ -1,4 +1,4 @@ -/* $NetBSD: grf_mv.c,v 1.10 1996/05/06 03:27:20 briggs Exp $ */ +/* $NetBSD: grf_mv.c,v 1.11 1996/05/19 22:27:07 scottr Exp $ */ /* * Copyright (c) 1995 Allen Briggs. All rights reserved. @@ -60,8 +60,12 @@ static caddr_t grfmv_phys __P((struct grf_softc *gp, vm_offset_t addr)); static int grfmv_match __P((struct device *, void *, void *)); static void grfmv_attach __P((struct device *, struct device *, void *)); -struct cfattach grf_mv_ca = { - sizeof(struct grf_softc), grfmv_match, grfmv_attach +struct cfdriver macvid_cd = { + NULL, "macvid", DV_DULL +}; + +struct cfattach macvid_ca = { + sizeof(struct grfbus_softc), grfmv_match, grfmv_attach }; static void @@ -95,9 +99,9 @@ grfmv_intr(vsc, slot) int slot; { caddr_t slotbase; - struct grf_softc *sc; + struct grfbus_softc *sc; - sc = (struct grf_softc *) vsc; + sc = (struct grfbus_softc *) vsc; slotbase = (caddr_t) sc->sc_slot.virtual_base; slotbase[0xa0000] = zero; } @@ -116,18 +120,18 @@ extern u_short mac68k_vrsrc_vec[]; } static int -grfmv_match(pdp, match, aux) - struct device *pdp; - void *match, *aux; +grfmv_match(parent, self, aux) + struct device *parent; + void *self, *aux; { - struct grf_softc *sc; + struct grfbus_softc *sc; nubus_slot *slot = (nubus_slot *) aux; nubus_dir dir, *dirp, *dirp2; nubus_dirent dirent, *direntp; nubus_type slottype; int vrsrc; - sc = (struct grf_softc *) match; + sc = (struct grfbus_softc *) self; /* XXX: indirect brokenness */ dirp = &dir; direntp = &dirent; nubus_get_main_dir(slot, dirp); @@ -181,21 +185,21 @@ grfmv_attach(parent, self, aux) struct device *parent, *self; void *aux; { - struct grf_softc *sc; + struct grfbus_softc *sc; struct image_data image_store, image; + struct grfmode *gm; + char cardname[CARD_NAME_LEN]; nubus_dirent dirent; nubus_dir mode_dir; int mode; - u_long base; - sc = (struct grf_softc *) self; - - sc->g_mode = grfmv_mode; - sc->g_phys = grfmv_phys; + sc = (struct grfbus_softc *) self; + gm = &sc->curr_mode; mode = NUBUS_RSRC_FIRSTMODE; if (nubus_find_rsrc(&sc->sc_slot, &sc->board_dir, mode, &dirent) <= 0) { - printf("grf probe failed to get board rsrc.\n"); + printf("\n%s: probe failed to get board rsrc.\n", + sc->sc_dev.dv_xname); return; } @@ -203,49 +207,42 @@ grfmv_attach(parent, self, aux) if (nubus_find_rsrc(&sc->sc_slot, &mode_dir, VID_PARAMS, &dirent) <= 0) { - printf("grf probe failed to get mode dir.\n"); + printf("\n%s: probe failed to get mode dir.\n", + sc->sc_dev.dv_xname); return; } if (nubus_get_ind_data(&sc->sc_slot, &dirent, (caddr_t) &image_store, sizeof(struct image_data)) <= 0) { - printf("grf probe failed to get indirect mode data.\n"); + printf("\n%s: probe failed to get indirect mode data.\n", + sc->sc_dev.dv_xname); return; } load_image_data((caddr_t) &image_store, &image); - base = sc->sc_slot.virtual_base; + gm->mode_id = mode; + gm->fbbase = (caddr_t) (sc->sc_slot.virtual_base + image.offset); + gm->fboff = image.offset; + gm->rowbytes = image.rowbytes; + gm->width = image.right - image.left; + gm->height = image.bottom - image.top; + gm->fbsize = sc->curr_mode.height * sc->curr_mode.rowbytes; + gm->hres = image.hRes; + gm->vres = image.vRes; + gm->ptype = image.pixelType; + gm->psize = image.pixelSize; - sc->curr_mode.mode_id = mode; - sc->curr_mode.fbbase = (caddr_t) (base + image.offset); - sc->curr_mode.fboff = 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), + strncpy(cardname, nubus_get_card_name(&sc->sc_slot), CARD_NAME_LEN); + cardname[CARD_NAME_LEN-1] = '\0'; - sc->card_name[CARD_NAME_LEN-1] = '\0'; + printf(": %s\n", cardname); add_nubus_intr(sc->sc_slot.slot, grfmv_intr, sc); - sc->g_flags = GF_ALIVE; - - printf(": %d x %d ", sc->curr_mode.width, sc->curr_mode.height); - - if (sc->curr_mode.psize == 1) - printf("monochrome"); - else - printf("%d color", 1 << sc->curr_mode.psize); - - printf(" %s display\n", sc->card_name); + /* Perform common video attachment. */ + grf_establish(sc, grfmv_mode, grfmv_phys); } static int @@ -273,6 +270,6 @@ grfmv_phys(gp, addr) struct grf_softc *gp; vm_offset_t addr; { - return (caddr_t) (NUBUS_SLOT_TO_PADDR(gp->sc_slot.slot) + - (addr - gp->sc_slot.virtual_base)); + return (caddr_t) (NUBUS_SLOT_TO_PADDR(gp->sc_slot->slot) + + (addr - gp->sc_slot->virtual_base)); } diff --git a/sys/arch/mac68k/dev/grf_subr.c b/sys/arch/mac68k/dev/grf_subr.c new file mode 100644 index 000000000000..0e4bb2eada7a --- /dev/null +++ b/sys/arch/mac68k/dev/grf_subr.c @@ -0,0 +1,84 @@ +/* $NetBSD: grf_subr.c,v 1.1 1996/05/19 22:27:08 scottr Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * 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 NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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. + */ + +#include +#include +#include + +#include + +#include +#include + +void +grf_establish(sc, g_mode, g_phys) + struct grfbus_softc *sc; + int (*g_mode) __P((struct grf_softc *, int, void *)); + caddr_t (*g_phys) __P((struct grf_softc *, vm_offset_t)); +{ + struct grfmode *gm = &sc->curr_mode; + struct grfbus_attach_args ga; + + /* Print hardware characteristics. */ + printf("%s: %d x %d, ", sc->sc_dev.dv_xname, gm->width, gm->height); + if (gm->psize == 1) + printf("monochrome\n"); + else + printf("%d color\n", 1 << gm->psize); + + /* Attach grf semantics to the hardware. */ + ga.ga_name = "grf"; + ga.ga_grfmode = gm; + ga.ga_slot = &sc->sc_slot; /* XXX */ + ga.ga_mode = g_mode; + ga.ga_phys = g_phys; + (void)config_found(&sc->sc_dev, &ga, grfbusprint); +} + +int +grfbusprint(aux, name) + void *aux; + char *name; +{ + struct grfbus_attach_args *ga = aux; + + if (name) + printf("%s at %s", ga->ga_name, name); + + return (UNCONF); +} diff --git a/sys/arch/mac68k/dev/grfvar.h b/sys/arch/mac68k/dev/grfvar.h index b1a45a9cb876..cd60da3c9af0 100644 --- a/sys/arch/mac68k/dev/grfvar.h +++ b/sys/arch/mac68k/dev/grfvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: grfvar.h,v 1.9 1996/05/05 06:16:37 briggs Exp $ */ +/* $NetBSD: grfvar.h,v 1.10 1996/05/19 22:27:10 scottr Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -43,22 +43,43 @@ */ #define CARD_NAME_LEN 64 -/* per display info */ -struct grf_softc { + +/* + * State info, per hardware instance. + */ +struct grfbus_softc { struct device sc_dev; nubus_slot sc_slot; - 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 */ - int (*g_mode) __P((struct grf_softc *, int, void *)); +}; + +/* + * State info, per grf instance. + */ +struct grf_softc { + struct device sc_dev; /* device glue */ + + int sc_flags; /* software flags */ + struct grfmode *sc_grfmode; /* forwarded ... */ + nubus_slot *sc_slot; /* mode-change on/off/mode function */ - caddr_t (*g_phys) __P((struct grf_softc *, vm_offset_t)); + int (*sc_mode) __P((struct grf_softc *, int, void *)); /* map virtual addr to physical addr */ - caddr_t g_data; /* device dependent data */ + caddr_t (*sc_phys) __P((struct grf_softc *, vm_offset_t)); +}; + +/* + * Attach grf and ite semantics to Mac video hardware. + */ +struct grfbus_attach_args { + char *ga_name; /* name of semantics to attach */ + struct grfmode *ga_grfmode; /* forwarded ... */ + nubus_slot *ga_slot; + int (*ga_mode) __P((struct grf_softc *, int, void *)); + caddr_t (*ga_phys) __P((struct grf_softc *, vm_offset_t)); }; typedef caddr_t (*grf_phys_t) __P((struct grf_softc *gp, vm_offset_t addr)); @@ -121,3 +142,8 @@ int grfoff __P((dev_t dev)); int grfaddr __P((struct grf_softc *gp, register int off)); int grfmap __P((dev_t dev, caddr_t *addrp, struct proc *p)); int grfunmap __P((dev_t dev, caddr_t addr, struct proc *p)); + +void grf_establish __P((struct grfbus_softc *, + int (*)(struct grf_softc *, int, void *), + caddr_t (*)(struct grf_softc *, vm_offset_t))); +int grfbusprint __P((void *, char *)); diff --git a/sys/arch/mac68k/nubus/grf_nubus.c b/sys/arch/mac68k/nubus/grf_nubus.c index 21009c031897..e30cab9306d6 100644 --- a/sys/arch/mac68k/nubus/grf_nubus.c +++ b/sys/arch/mac68k/nubus/grf_nubus.c @@ -1,4 +1,4 @@ -/* $NetBSD: grf_nubus.c,v 1.10 1996/05/06 03:27:20 briggs Exp $ */ +/* $NetBSD: grf_nubus.c,v 1.11 1996/05/19 22:27:07 scottr Exp $ */ /* * Copyright (c) 1995 Allen Briggs. All rights reserved. @@ -60,8 +60,12 @@ static caddr_t grfmv_phys __P((struct grf_softc *gp, vm_offset_t addr)); static int grfmv_match __P((struct device *, void *, void *)); static void grfmv_attach __P((struct device *, struct device *, void *)); -struct cfattach grf_mv_ca = { - sizeof(struct grf_softc), grfmv_match, grfmv_attach +struct cfdriver macvid_cd = { + NULL, "macvid", DV_DULL +}; + +struct cfattach macvid_ca = { + sizeof(struct grfbus_softc), grfmv_match, grfmv_attach }; static void @@ -95,9 +99,9 @@ grfmv_intr(vsc, slot) int slot; { caddr_t slotbase; - struct grf_softc *sc; + struct grfbus_softc *sc; - sc = (struct grf_softc *) vsc; + sc = (struct grfbus_softc *) vsc; slotbase = (caddr_t) sc->sc_slot.virtual_base; slotbase[0xa0000] = zero; } @@ -116,18 +120,18 @@ extern u_short mac68k_vrsrc_vec[]; } static int -grfmv_match(pdp, match, aux) - struct device *pdp; - void *match, *aux; +grfmv_match(parent, self, aux) + struct device *parent; + void *self, *aux; { - struct grf_softc *sc; + struct grfbus_softc *sc; nubus_slot *slot = (nubus_slot *) aux; nubus_dir dir, *dirp, *dirp2; nubus_dirent dirent, *direntp; nubus_type slottype; int vrsrc; - sc = (struct grf_softc *) match; + sc = (struct grfbus_softc *) self; /* XXX: indirect brokenness */ dirp = &dir; direntp = &dirent; nubus_get_main_dir(slot, dirp); @@ -181,21 +185,21 @@ grfmv_attach(parent, self, aux) struct device *parent, *self; void *aux; { - struct grf_softc *sc; + struct grfbus_softc *sc; struct image_data image_store, image; + struct grfmode *gm; + char cardname[CARD_NAME_LEN]; nubus_dirent dirent; nubus_dir mode_dir; int mode; - u_long base; - sc = (struct grf_softc *) self; - - sc->g_mode = grfmv_mode; - sc->g_phys = grfmv_phys; + sc = (struct grfbus_softc *) self; + gm = &sc->curr_mode; mode = NUBUS_RSRC_FIRSTMODE; if (nubus_find_rsrc(&sc->sc_slot, &sc->board_dir, mode, &dirent) <= 0) { - printf("grf probe failed to get board rsrc.\n"); + printf("\n%s: probe failed to get board rsrc.\n", + sc->sc_dev.dv_xname); return; } @@ -203,49 +207,42 @@ grfmv_attach(parent, self, aux) if (nubus_find_rsrc(&sc->sc_slot, &mode_dir, VID_PARAMS, &dirent) <= 0) { - printf("grf probe failed to get mode dir.\n"); + printf("\n%s: probe failed to get mode dir.\n", + sc->sc_dev.dv_xname); return; } if (nubus_get_ind_data(&sc->sc_slot, &dirent, (caddr_t) &image_store, sizeof(struct image_data)) <= 0) { - printf("grf probe failed to get indirect mode data.\n"); + printf("\n%s: probe failed to get indirect mode data.\n", + sc->sc_dev.dv_xname); return; } load_image_data((caddr_t) &image_store, &image); - base = sc->sc_slot.virtual_base; + gm->mode_id = mode; + gm->fbbase = (caddr_t) (sc->sc_slot.virtual_base + image.offset); + gm->fboff = image.offset; + gm->rowbytes = image.rowbytes; + gm->width = image.right - image.left; + gm->height = image.bottom - image.top; + gm->fbsize = sc->curr_mode.height * sc->curr_mode.rowbytes; + gm->hres = image.hRes; + gm->vres = image.vRes; + gm->ptype = image.pixelType; + gm->psize = image.pixelSize; - sc->curr_mode.mode_id = mode; - sc->curr_mode.fbbase = (caddr_t) (base + image.offset); - sc->curr_mode.fboff = 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), + strncpy(cardname, nubus_get_card_name(&sc->sc_slot), CARD_NAME_LEN); + cardname[CARD_NAME_LEN-1] = '\0'; - sc->card_name[CARD_NAME_LEN-1] = '\0'; + printf(": %s\n", cardname); add_nubus_intr(sc->sc_slot.slot, grfmv_intr, sc); - sc->g_flags = GF_ALIVE; - - printf(": %d x %d ", sc->curr_mode.width, sc->curr_mode.height); - - if (sc->curr_mode.psize == 1) - printf("monochrome"); - else - printf("%d color", 1 << sc->curr_mode.psize); - - printf(" %s display\n", sc->card_name); + /* Perform common video attachment. */ + grf_establish(sc, grfmv_mode, grfmv_phys); } static int @@ -273,6 +270,6 @@ grfmv_phys(gp, addr) struct grf_softc *gp; vm_offset_t addr; { - return (caddr_t) (NUBUS_SLOT_TO_PADDR(gp->sc_slot.slot) + - (addr - gp->sc_slot.virtual_base)); + return (caddr_t) (NUBUS_SLOT_TO_PADDR(gp->sc_slot->slot) + + (addr - gp->sc_slot->virtual_base)); } diff --git a/sys/arch/mac68k/obio/grf_obio.c b/sys/arch/mac68k/obio/grf_obio.c index 8a8dcb2859d3..a53b98d8db5d 100644 --- a/sys/arch/mac68k/obio/grf_obio.c +++ b/sys/arch/mac68k/obio/grf_obio.c @@ -1,4 +1,4 @@ -/* $NetBSD: grf_obio.c,v 1.11 1996/05/05 06:16:32 briggs Exp $ */ +/* $NetBSD: grf_obio.c,v 1.12 1996/05/19 22:27:06 scottr Exp $ */ /* * Copyright (c) 1995 Allen Briggs. All rights reserved. @@ -60,8 +60,12 @@ static caddr_t grfiv_phys __P((struct grf_softc *gp, vm_offset_t addr)); static int grfiv_match __P((struct device *, void *, void *)); static void grfiv_attach __P((struct device *, struct device *, void *)); -struct cfattach grf_iv_ca = { - sizeof(struct grf_softc), grfiv_match, grfiv_attach +struct cfdriver intvid_cd = { + NULL, "intvid", DV_DULL +}; + +struct cfattach intvid_ca = { + sizeof(struct grfbus_softc), grfiv_match, grfiv_attach }; static int @@ -83,16 +87,14 @@ grfiv_attach(parent, self, aux) struct device *parent, *self; void *aux; { - struct grf_softc *sc; + struct grfbus_softc *sc; struct grfmode *gm; - sc = (struct grf_softc *) self; + sc = (struct grfbus_softc *) self; sc->card_id = 0; - strcpy(sc->card_name, "Internal video"); - sc->g_mode = grfiv_mode; - sc->g_phys = grfiv_phys; + printf(": Internal Video\n"); gm = &(sc->curr_mode); gm->mode_id = 0; @@ -107,16 +109,8 @@ grfiv_attach(parent, self, aux) gm->fbbase = (caddr_t) mac68k_vidlog; gm->fboff = 0; - sc->g_flags = GF_ALIVE; - - printf(": %d x %d ", sc->curr_mode.width, sc->curr_mode.height); - - if (sc->curr_mode.psize == 1) - printf("monochrome"); - else - printf("%d color", 1 << sc->curr_mode.psize); - - printf(" %s display\n", sc->card_name); + /* Perform common video attachment. */ + grf_establish(sc, grfiv_mode, grfiv_phys); } static int