diff options
author | Martin Reindl <martin@cvs.openbsd.org> | 2005-08-06 19:51:45 +0000 |
---|---|---|
committer | Martin Reindl <martin@cvs.openbsd.org> | 2005-08-06 19:51:45 +0000 |
commit | 50f81f3d5e5b5b206944aab7cf18d58adb4564ec (patch) | |
tree | f0243447d3cd295e5cb489ad664920b7e4e94953 /sys/arch/mac68k | |
parent | 9f36dcaaddbb3cb52a01409a14c2f52efd1287d8 (diff) |
overhaul the grf driver:
- Simplify grfmv_phys() to work like grfiv_phys(), and eliminate the
second argument to both, as we don't use it anyway.
- Handle fbbase and fboff consistently throughout.
- Eliminate grfaddr() by pulling it into grfmmap(), which is the
only place it was used, previously.
- grfmap() now gets the physical address of the framebuffer from
the appropriate driver, rather than try to compute it by itself.
Be careful with aligning the base to a page address and increase
the length of the mapped region appropriately.
- Store the PA of the framebuffer in the softc. This eliminates the need
for the sc_phys callback; we can just store the PA in the grfbus attach
args, rather than a function pointer, which simplifies the code nicely.
- Disable Valkyrie interrupts on the Quadra 630
- New and improved console framebuffer initialization and autoconfig. This
resolves a great many issues, including Performa 58x interrupt handling
and offset displays on some models.
- Remove unused grf ioctls
- Some KNF and other minor things
help and ok miod@
from NetBSD
Diffstat (limited to 'sys/arch/mac68k')
-rw-r--r-- | sys/arch/mac68k/dev/grf.c | 160 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/grf_iv.c | 236 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/grf_mv.c | 20 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/grf_subr.c | 7 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/grfvar.h | 30 | ||||
-rw-r--r-- | sys/arch/mac68k/include/grfioctl.h | 27 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/machdep.c | 97 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/pmap_bootstrap.c | 5 |
8 files changed, 289 insertions, 293 deletions
diff --git a/sys/arch/mac68k/dev/grf.c b/sys/arch/mac68k/dev/grf.c index 6e84a03efb4..09af2b76281 100644 --- a/sys/arch/mac68k/dev/grf.c +++ b/sys/arch/mac68k/dev/grf.c @@ -1,5 +1,5 @@ -/* $OpenBSD: grf.c,v 1.27 2005/07/23 23:28:58 martin Exp $ */ -/* $NetBSD: grf.c,v 1.41 1997/02/24 06:20:04 scottr Exp $ */ +/* $OpenBSD: grf.c,v 1.28 2005/08/06 19:51:43 martin Exp $ */ +/* $NetBSD: grf.c,v 1.53 1998/06/02 02:14:20 scottr Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -66,9 +66,9 @@ #include <uvm/uvm.h> -#include "nubus.h" -#include "itevar.h" -#include "grfvar.h" +#include <mac68k/dev/nubus.h> +#include <mac68k/dev/itevar.h> +#include <mac68k/dev/grfvar.h> #include "grf.h" #include "ite.h" @@ -90,11 +90,15 @@ struct cfattach grf_ca = { }; #ifdef DEBUG +#define GRF_DEBUG +#endif + +#ifdef GRF_DEBUG #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); +int grfdebug = 0; #endif int @@ -121,6 +125,8 @@ grfattach(parent, self, aux) /* Load forwarded pointers. */ sc->sc_grfmode = ga->ga_grfmode; sc->sc_slot = ga->ga_slot; + sc->sc_tag = ga->ga_tag; + sc->sc_regh = ga->ga_handle; sc->sc_mode = ga->ga_mode; sc->sc_phys = ga->ga_phys; @@ -179,7 +185,7 @@ grfclose(dev, flag, mode, p) gp = grf_cd.cd_devs[GRFUNIT(dev)]; - (void) grfoff(dev); + (void)grfoff(dev); gp->sc_flags &= GF_ALIVE; return (0); @@ -204,34 +210,12 @@ grfioctl(dev, cmd, data, flag, p) error = 0; switch (cmd) { - 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 = 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; - case GRFIOCON: error = grfon(dev); break; case GRFIOCOFF: error = grfoff(dev); break; - case GRFIOCMAP: - error = grfmap(dev, (caddr_t *) data, p); - break; - case GRFIOCUNMAP: - error = grfunmap(dev, *(caddr_t *) data, p); - break; case GRFIOCGMODE: bcopy(gm, data, sizeof(struct grfmode)); @@ -271,11 +255,26 @@ grfmmap(dev, off, prot) off_t off; int prot; { - int unit = GRFUNIT(dev); - struct grf_softc *gp; + struct grf_softc *gp = grf_cd.cd_devs[GRFUNIT(dev)]; + struct grfmode *gm = gp->sc_grfmode; + u_long addr; - gp = grf_cd.cd_devs[unit]; - return (grfaddr(gp, off)); +#ifdef GRF_DEBUG + if (grfdebug & GDB_MMAP) + printf("grfmmap(%x): off %x, prot %x\n", dev, off, prot); +#endif + + if (off < m68k_trunc_page(gm->fboff) || + off >= m68k_round_page(gm->fbsize + gm->fboff)) + addr = (-1); /* XXX bogus */ + else + addr = m68k_btop(gp->sc_phys + off); + +#ifdef GRF_DEBUG + if (grfdebug & GDB_MMAP) + printf("grfmmap(%x): returning addr 0x%08lx\n", dev, addr); +#endif + return (int)addr; } int @@ -294,7 +293,7 @@ grfon(dev) */ iteoff(unit, 3); - return (*gp->sc_mode) (gp, GM_GRFON, NULL); + return (*gp->sc_mode)(gp, GM_GRFON, NULL); } int @@ -307,101 +306,10 @@ grfoff(dev) gp = grf_cd.cd_devs[unit]; - (void) grfunmap(dev, (caddr_t) 0, curproc); - - error = (*gp->sc_mode) (gp, GM_GRFOFF, NULL); + error = (*gp->sc_mode)(gp, GM_GRFOFF, NULL); /* XXX: see comment for iteoff above */ iteon(unit, 2); return (error); } - -int -grfaddr(gp, off) - struct grf_softc *gp; - register int off; -{ - register struct grfmode *gm = gp->sc_grfmode; - u_long addr; - - if (off >= 0 && off < m68k_round_page(gm->fbsize + gm->fboff)) { - addr = (u_long)(*gp->sc_phys)(gp, (vaddr_t)gm->fbbase)+off; - return m68k_btop(addr); - } - /* bogus */ - return (-1); -} - -int -grfmap(dev, addrp, p) - dev_t dev; - caddr_t *addrp; - struct proc *p; -{ - extern u_int32_t mac68k_vidphys; - struct grf_softc *gp; - struct specinfo si; - struct vnode vn; - int len, error; - int flags; - - gp = grf_cd.cd_devs[GRFUNIT(dev)]; -#ifdef DEBUG - if (grfdebug & GDB_MMAP) - printf("grfmap(%d): addr %p\n", p->p_pid, *addrp); -#endif - len = m68k_round_page(gp->sc_grfmode->fbsize + gp->sc_grfmode->fboff); - flags = MAP_SHARED | MAP_FIXED; - - if (gp->sc_slot == NULL) - *addrp = (caddr_t) m68k_trunc_page(mac68k_vidphys); - else - *addrp = (caddr_t) m68k_trunc_page( - NUBUS_SLOT2PA(gp->sc_slot->slot)); - - vn.v_type = VCHR; /* XXX */ - vn.v_specinfo = &si; /* XXX */ - vn.v_rdev = dev; /* XXX */ - - error = uvm_mmap(&p->p_vmspace->vm_map, (vaddr_t *)addrp, - (vm_size_t)len, UVM_PROT_RW, UVM_PROT_RW, flags, (caddr_t)&vn, 0, - p->p_rlimit[RLIMIT_MEMLOCK].rlim_cur, p); - - /* Offset into page: */ - *addrp += (unsigned long) gp->sc_grfmode->fboff & 0xfff; - -#ifdef DEBUG - if (grfdebug & GDB_MMAP) - printf("grfmap(%d): returning addr %p\n", p->p_pid, *addrp); -#endif - - return (error); -} - -int -grfunmap(dev, addr, p) - dev_t dev; - caddr_t addr; - struct proc *p; -{ - struct grf_softc *gp; - vm_size_t size; - - gp = grf_cd.cd_devs[GRFUNIT(dev)]; - -#ifdef DEBUG - if (grfdebug & GDB_MMAP) - 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->sc_grfmode->fbsize); - - uvm_unmap(&p->p_vmspace->vm_map, (vaddr_t)addr, - (vaddr_t)addr + size); - - return (0); -} diff --git a/sys/arch/mac68k/dev/grf_iv.c b/sys/arch/mac68k/dev/grf_iv.c index c4335be40f5..fccc9ec53d7 100644 --- a/sys/arch/mac68k/dev/grf_iv.c +++ b/sys/arch/mac68k/dev/grf_iv.c @@ -1,7 +1,33 @@ -/* $OpenBSD: grf_iv.c,v 1.25 2005/08/01 19:09:19 martin Exp $ */ +/* $OpenBSD: grf_iv.c,v 1.26 2005/08/06 19:51:43 martin Exp $ */ /* $NetBSD: grf_iv.c,v 1.17 1997/02/20 00:23:27 scottr Exp $ */ /* + * Copyright (C) 1998 Scott Reynolds + * 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. 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. + */ +/* * Copyright (c) 1995 Allen Briggs. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,7 +61,6 @@ */ #include <sys/param.h> - #include <sys/device.h> #include <sys/ioctl.h> #include <sys/file.h> @@ -50,18 +75,18 @@ #include <machine/grfioctl.h> #include <machine/viareg.h> -#include "nubus.h" -#include "obiovar.h" -#include "grfvar.h" +#include <mac68k/dev/nubus.h> +#include <mac68k/dev/obiovar.h> +#include <mac68k/dev/grfvar.h> -extern u_int32_t mac68k_vidlog; extern u_int32_t mac68k_vidphys; +extern u_int32_t mac68k_vidlen; +extern long videoaddr; extern long videorowbytes; extern long videobitdepth; -extern unsigned long videosize; +extern u_long videosize; static int grfiv_mode(struct grf_softc *gp, int cmd, void *arg); -static caddr_t grfiv_phys(struct grf_softc *gp, vaddr_t addr); static int grfiv_match(struct device *, void *, void *); static void grfiv_attach(struct device *, struct device *, void *); @@ -73,8 +98,12 @@ struct cfattach intvid_ca = { sizeof(struct grfbus_softc), grfiv_match, grfiv_attach }; -#define QUADRA_DAFB_BASE 0xF9800000 +#define DAFB_BASE 0xf9000000 +#define DAFB_CONTROL_BASE 0xf9800000 +#define CIVIC_BASE 0x50100000 #define CIVIC_CONTROL_BASE 0x50036000 +#define VALKYRIE_BASE 0xf9000000 +#define VALKYRIE_CONTROL_BASE 0x50f2a000 static int grfiv_match(parent, vcf, aux) @@ -82,39 +111,50 @@ grfiv_match(parent, vcf, aux) void *vcf; void *aux; { - struct obio_attach_args *oa = (struct obio_attach_args *) aux; - bus_space_handle_t bsh; - int found, sense; + struct obio_attach_args *oa = (struct obio_attach_args *)aux; + bus_space_handle_t bsh; + int found; + u_int base; found = 1; switch (current_mac_model->class) { - case MACH_CLASSQ: case MACH_CLASSQ2: + if (current_mac_model->machineid != MACH_MACLC575) { + base = VALKYRIE_CONTROL_BASE; + + if (bus_space_map(oa->oa_tag, base, 0x40, 0, &bsh)) + return 0; + /* Disable interrupts */ + bus_space_write_1(oa->oa_tag, bsh, 0x18, 0x1); + break; + } + /* + * Note: the only system in this class that does not have + * the Valkyrie chip -- at least, that we know of -- is + * the Performa/LC 57x series. This system has a version + * of the DAFB controller, instead. + * + * If this assumption proves false, we'll have to be more + * intelligent here. + */ + /*FALLTHROUGH*/ + case MACH_CLASSQ: /* * Assume DAFB for all of these, unless we can't * access the memory. */ + base = DAFB_CONTROL_BASE; - if (bus_space_map(oa->oa_tag, QUADRA_DAFB_BASE, PAGE_SIZE, - 0, &bsh)) { - panic("failed to map space for DAFB regs."); - } + if (bus_space_map(oa->oa_tag, base, 0x1000, 0, &bsh)) + return 0; - if (mac68k_bus_space_probe(oa->oa_tag, bsh, 0x1C, 4) == 0) { + if (mac68k_bus_space_probe(oa->oa_tag, bsh, 0x1c, 4) == 0) { bus_space_unmap(oa->oa_tag, bsh, PAGE_SIZE); - found = 0; - goto nodafb; + return 0; } - sense = (bus_space_read_4(oa->oa_tag, bsh, 0x1C) & 7); - -#if 0 /* when using a non-Apple monitor with an adapter, sense is zero */ - if (sense == 0) - found = 0; -#endif - /* Set "Turbo SCSI" configuration to default */ bus_space_write_4(oa->oa_tag, bsh, 0x24, 0x1d1); /* ch0 */ bus_space_write_4(oa->oa_tag, bsh, 0x28, 0x1d1); /* ch1 */ @@ -128,62 +168,134 @@ grfiv_match(parent, vcf, aux) bus_space_write_4(oa->oa_tag, bsh, 0x114, 0); bus_space_unmap(oa->oa_tag, bsh, PAGE_SIZE); - break; - case MACH_CLASSAV: - if (bus_space_map(oa->oa_tag, CIVIC_CONTROL_BASE, 0x1000, - 0, &bsh)) { - panic("failed to map space for CIVIC control regs.\n"); - } + base = CIVIC_CONTROL_BASE; + + if (bus_space_map(oa->oa_tag, base, 0x1000, 0, &bsh)) + return 0; + /* Disable interrupts */ bus_space_write_1(oa->oa_tag, bsh, 0x120, 0); + bus_space_unmap(oa->oa_tag, bsh, 0x1000); break; - default: -nodafb: - if (mac68k_vidlog == 0) { + if (mac68k_vidlen == 0) found = 0; - } - break; } return found; } -#define R4(sc, o) (bus_space_read_4((sc)->sc_tag, (sc)->sc_regh, o) & 0xfff) - static void grfiv_attach(parent, self, aux) struct device *parent, *self; void *aux; { struct obio_attach_args *oa = (struct obio_attach_args *) aux; - struct grfbus_softc *sc; - struct grfmode *gm; + struct grfbus_softc *sc; + struct grfmode *gm; + u_long base, length; + u_int32_t vbase1, vbase2; - sc = (struct grfbus_softc *) self; + sc = (struct grfbus_softc *)self; sc->card_id = 0; switch (current_mac_model->class) { + case MACH_CLASSQ2: + if (current_mac_model->machineid != MACH_MACLC575) { + sc->sc_basepa = VALKYRIE_BASE; + length = 0x00100000; /* 1MB */ + + if (sc->sc_basepa <= mac68k_vidphys && + mac68k_vidphys < (sc->sc_basepa + length)) + sc->sc_fbofs = mac68k_vidphys - sc->sc_basepa; + else + sc->sc_fbofs = 0; + +#ifdef DEBUG + printf(" @ %lx", sc->sc_basepa + sc->sc_fbofs); +#endif + printf(": Valkyrie\n"); + break; + } + /* See note in grfiv_match() */ + /*FALLTHROUGH*/ case MACH_CLASSQ: - case MACH_CLASSQ2: + base = DAFB_CONTROL_BASE; sc->sc_tag = oa->oa_tag; - if (bus_space_map(sc->sc_tag, QUADRA_DAFB_BASE, 0x20, - 0, &sc->sc_regh)) { - panic("failed to map space for DAFB regs."); + if (bus_space_map(sc->sc_tag, base, 0x1000, 0, &sc->sc_regh)) { + printf(": failed to map DAFB register space\n"); + return; } - printf(": DAFB: Monitor sense %x.\n", R4(sc,0x1C)&7); - bus_space_unmap(sc->sc_tag, sc->sc_regh, 0x20); + + sc->sc_basepa = DAFB_BASE; + length = 0x00100000; /* 1MB */ + + /* Compute the current frame buffer offset */ + vbase1 = bus_space_read_4(sc->sc_tag, sc->sc_regh, 0x0) & 0xfff; + vbase2 = bus_space_read_4(sc->sc_tag, sc->sc_regh, 0x4) & 0xf; + sc->sc_fbofs = (vbase1 << 9) | (vbase2 << 5); +#if 1 + /* + * XXX The following hack exists because the DAFB v7 in these + * systems doesn't compute fbofs correctly. (sar 19980813) + */ + switch (current_mac_model->machineid) { + case MACH_MACLC475: + case MACH_MACLC475_33: + case MACH_MACLC575: + sc->sc_fbofs = 0x1000; + break; + } +#endif + +#ifdef DEBUG + printf(" @ %lx", sc->sc_basepa + sc->sc_fbofs); +#endif + printf(": DAFB: monitor sense %x\n", + (bus_space_read_4(sc->sc_tag, sc->sc_regh, 0x1c) & 0x7)); + + bus_space_unmap(sc->sc_tag, sc->sc_regh, 0x1000); + break; + case MACH_CLASSAV: + sc->sc_basepa = CIVIC_BASE; + length = 0x00200000; /* 2MB */ + + if (sc->sc_basepa <= mac68k_vidphys && + mac68k_vidphys < (sc->sc_basepa + length)) + sc->sc_fbofs = mac68k_vidphys - sc->sc_basepa; + else + sc->sc_fbofs = 0; + +#ifdef DEBUG + printf(" @ %lx", sc->sc_basepa + sc->sc_fbofs); +#endif + printf(": Civic\n"); break; default: - printf(": Internal Video\n"); + sc->sc_basepa = m68k_trunc_page(mac68k_vidphys); + sc->sc_fbofs = mac68k_vidphys & PGOFSET; + length = mac68k_vidlen + sc->sc_fbofs; + + printf(" @ %lx: On-board video\n", + sc->sc_basepa + sc->sc_fbofs); break; } + if (bus_space_map(sc->sc_tag, sc->sc_basepa, length, 0, + &sc->sc_handle)) { + printf("%s: failed to map video RAM\n", sc->sc_dev.dv_xname); + return; + } + + if (sc->sc_basepa <= mac68k_vidphys && + mac68k_vidphys < (sc->sc_basepa + length)) + videoaddr = sc->sc_handle + sc->sc_fbofs; /* XXX big ol' hack */ + gm = &(sc->curr_mode); gm->mode_id = 0; gm->psize = videobitdepth; @@ -191,14 +303,14 @@ grfiv_attach(parent, self, aux) gm->width = videosize & 0xffff; gm->height = (videosize >> 16) & 0xffff; gm->rowbytes = videorowbytes; - gm->hres = 80; /* XXX Hack */ - gm->vres = 80; /* XXX Hack */ - gm->fbsize = gm->rowbytes * gm->height; - gm->fbbase = (caddr_t) m68k_trunc_page(mac68k_vidlog); - gm->fboff = mac68k_vidlog & PGOFSET; + gm->hres = 80; /* XXX Hack */ + gm->vres = 80; /* XXX Hack */ + gm->fbsize = gm->height * gm->rowbytes; + gm->fbbase = (caddr_t)sc->sc_handle; /* XXX yet another hack */ + gm->fboff = sc->sc_fbofs; /* Perform common video attachment. */ - grf_establish(sc, NULL, grfiv_mode, grfiv_phys); + grf_establish(sc, NULL, grfiv_mode); } static int @@ -220,15 +332,3 @@ grfiv_mode(sc, cmd, arg) } return EINVAL; } - -static caddr_t -grfiv_phys(gp, addr) - struct grf_softc *gp; - vaddr_t addr; -{ - /* - * If we're using IIsi or similar, this will be 0. - * If we're using IIvx or similar, this will be correct. - */ - return (caddr_t) mac68k_vidphys; -} diff --git a/sys/arch/mac68k/dev/grf_mv.c b/sys/arch/mac68k/dev/grf_mv.c index fe08c3715e6..ae2deee1206 100644 --- a/sys/arch/mac68k/dev/grf_mv.c +++ b/sys/arch/mac68k/dev/grf_mv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grf_mv.c,v 1.24 2005/07/23 23:28:58 martin Exp $ */ +/* $OpenBSD: grf_mv.c,v 1.25 2005/08/06 19:51:43 martin Exp $ */ /* $NetBSD: grf_nubus.c,v 1.62 2001/01/22 20:27:02 briggs Exp $ */ /* @@ -69,7 +69,6 @@ static int grfmv_intr_radius_gsc(void *vsc); static int grfmv_intr_radius_gx(void *vsc); static int grfmv_mode(struct grf_softc *gp, int cmd, void *arg); -static caddr_t grfmv_phys(struct grf_softc *gp, vaddr_t addr); static int grfmv_match(struct device *, void *, void *); static void grfmv_attach(struct device *, struct device *, void *); @@ -150,9 +149,11 @@ grfmv_attach(parent, self, aux) sc->sc_tag = na->na_tag; sc->card_id = na->drhw; + sc->sc_basepa = (bus_addr_t)NUBUS_SLOT2PA(na->slot); + sc->sc_fbofs = 0; - if (bus_space_map(sc->sc_tag, - NUBUS_SLOT2PA(na->slot), NBMEMSIZE, 0, &sc->sc_regh)) { + if (bus_space_map(sc->sc_tag, sc->sc_basepa, NBMEMSIZE, + 0, &sc->sc_regh)) { printf(": grfmv_attach: failed to map slot %d\n", na->slot); return; } @@ -374,7 +375,7 @@ bad: } /* Perform common video attachment. */ - grf_establish(sc, &sc->sc_slot, grfmv_mode, grfmv_phys); + grf_establish(sc, &sc->sc_slot, grfmv_mode); } static int @@ -397,15 +398,6 @@ grfmv_mode(gp, cmd, arg) return EINVAL; } -static caddr_t -grfmv_phys(gp, addr) - struct grf_softc *gp; - vaddr_t addr; -{ - return (caddr_t)(NUBUS_SLOT2PA(gp->sc_slot->slot) + - (addr - gp->sc_regh)); /* XXX evil hack */ -} - /* Interrupt handlers... */ /* * Generic routine to clear interrupts for cards where it simply takes diff --git a/sys/arch/mac68k/dev/grf_subr.c b/sys/arch/mac68k/dev/grf_subr.c index cb25065a4f8..58c44afef60 100644 --- a/sys/arch/mac68k/dev/grf_subr.c +++ b/sys/arch/mac68k/dev/grf_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grf_subr.c,v 1.6 2005/07/23 23:28:58 martin Exp $ */ +/* $OpenBSD: grf_subr.c,v 1.7 2005/08/06 19:51:43 martin Exp $ */ /* $NetBSD: grf_subr.c,v 1.6 1997/02/20 00:23:28 scottr Exp $ */ /*- @@ -48,11 +48,10 @@ #include <mac68k/dev/grfvar.h> void -grf_establish(sc, sp, g_mode, g_phys) +grf_establish(sc, sp, g_mode) struct grfbus_softc *sc; nubus_slot *sp; int (*g_mode)(struct grf_softc *, int, void *); - caddr_t (*g_phys)(struct grf_softc *, vaddr_t); { struct grfmode *gm = &sc->curr_mode; struct grfbus_attach_args ga; @@ -68,8 +67,8 @@ grf_establish(sc, sp, g_mode, g_phys) ga.ga_name = "grf"; ga.ga_grfmode = gm; ga.ga_slot = sp; + ga.ga_phys = sc->sc_basepa; ga.ga_mode = g_mode; - ga.ga_phys = g_phys; (void)config_found(&sc->sc_dev, &ga, grfbusprint); } diff --git a/sys/arch/mac68k/dev/grfvar.h b/sys/arch/mac68k/dev/grfvar.h index 42b6e382194..4ac5a1ffb60 100644 --- a/sys/arch/mac68k/dev/grfvar.h +++ b/sys/arch/mac68k/dev/grfvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: grfvar.h,v 1.15 2005/07/23 23:28:58 martin Exp $ */ +/* $OpenBSD: grfvar.h,v 1.16 2005/08/06 19:51:43 martin Exp $ */ /* $NetBSD: grfvar.h,v 1.11 1996/08/04 06:03:58 scottr Exp $ */ /* @@ -48,15 +48,18 @@ struct grfbus_softc { struct device sc_dev; nubus_slot sc_slot; + bus_addr_t sc_basepa; /* base of video space */ + bus_addr_t sc_fbofs; /* offset to framebuffer */ + bus_space_tag_t sc_tag; + bus_space_handle_t sc_handle; bus_space_handle_t sc_regh; - bus_space_handle_t sc_fbh; struct grfmode curr_mode; /* hardware desc(for ioctl) */ u_int32_t card_id; /* DrHW value for nubus cards */ - u_int32_t cli_offset; /* Offset of byte to clear intr */ + bus_size_t cli_offset; /* Offset of byte to clear intr */ /* for cards where that's suff. */ - unsigned char cli_value; /* Value to write at cli_offset */ + u_int32_t cli_value; /* Value to write at cli_offset */ nubus_dir board_dir; /* Nubus dir for curr board */ }; @@ -69,24 +72,26 @@ struct grf_softc { bus_space_tag_t sc_tag; bus_space_handle_t sc_regh; - int sc_flags; /* software flags */ + int sc_flags; /* driver flags */ + u_long sc_phys; /* PA of framebuffer */ + struct grfmode *sc_grfmode; /* forwarded ... */ nubus_slot *sc_slot; /* mode-change on/off/mode function */ int (*sc_mode)(struct grf_softc *, int, void *); - /* map virtual addr to physical addr */ - caddr_t (*sc_phys)(struct grf_softc *, vaddr_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 ... */ + char *ga_name; /* name of semantics to attach */ + bus_space_tag_t ga_tag; + bus_space_handle_t ga_handle; + struct grfmode *ga_grfmode; nubus_slot *ga_slot; - int (*ga_mode)(struct grf_softc *, int, void *); - caddr_t (*ga_phys)(struct grf_softc *, vaddr_t); + bus_addr_t ga_phys; + int (*ga_mode)(struct grf_softc *, int, void *); }; typedef caddr_t (*grf_phys_t)(struct grf_softc *gp, vaddr_t addr); @@ -151,6 +156,5 @@ int grfmap(dev_t dev, caddr_t *addrp, struct proc *p); int grfunmap(dev_t dev, caddr_t addr, struct proc *p); void grf_establish(struct grfbus_softc *, nubus_slot *, - int (*)(struct grf_softc *, int, void *), - caddr_t (*)(struct grf_softc *, vaddr_t)); + int (*)(struct grf_softc *, int, void *)); int grfbusprint(void *, const char *); diff --git a/sys/arch/mac68k/include/grfioctl.h b/sys/arch/mac68k/include/grfioctl.h index 95e09392207..bbc3ae5a740 100644 --- a/sys/arch/mac68k/include/grfioctl.h +++ b/sys/arch/mac68k/include/grfioctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: grfioctl.h,v 1.5 2003/06/02 23:27:49 millert Exp $ */ +/* $OpenBSD: grfioctl.h,v 1.6 2005/08/06 19:51:44 martin Exp $ */ /* $NetBSD: grfioctl.h,v 1.5 1995/07/02 05:26:45 briggs Exp $ */ /* @@ -66,36 +66,11 @@ struct grfmodes { * 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 */ #define GRFIOCGMODE _IOR('G', 19, struct grfmode) /* Get list of modes */ -/* - * Obsolete structure. - * Only used to return information to older programs that still - * depend on GRFIOCGINFO. - */ -struct grfinfo { - int gd_id; /* HP-UX identifier */ - caddr_t gd_regaddr; /* control registers physaddr */ - int gd_regsize; /* control registers size */ - caddr_t gd_fbaddr; /* frame buffer physaddr */ - int gd_fbsize; /* frame buffer size */ - short gd_colors; /* number of colors */ - short gd_planes; /* number of planes */ - int gd_fbwidth; /* frame buffer width */ - int gd_fbheight; /* frame buffer height */ - int gd_fbrowbytes; /* frame buffer rowbytes */ - int gd_dwidth; /* displayed part width */ - int gd_dheight; /* displayed part height */ - int gd_pad[6]; /* for future expansion */ -}; - #endif /* _MAC68K_GRFIOCTL_H_ */ diff --git a/sys/arch/mac68k/mac68k/machdep.c b/sys/arch/mac68k/mac68k/machdep.c index 31f5198ab2b..13c50d0c26b 100644 --- a/sys/arch/mac68k/mac68k/machdep.c +++ b/sys/arch/mac68k/mac68k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.117 2005/07/23 23:30:56 martin Exp $ */ +/* $OpenBSD: machdep.c,v 1.118 2005/08/06 19:51:44 martin Exp $ */ /* $NetBSD: machdep.c,v 1.207 1998/07/08 04:39:34 thorpej Exp $ */ /* @@ -2044,7 +2044,7 @@ struct { int machineid; caddr_t fbbase; u_long fblen; -} intvid_info[] = { +} intvid_info[] = { { MACH_MACCLASSICII, (caddr_t)0xfee09a80, 21888 }, { MACH_MACPB140, (caddr_t)0xfee00000, 32 * 1024 }, { MACH_MACPB145, (caddr_t)0xfee00000, 32 * 1024 }, @@ -2053,26 +2053,30 @@ struct { { MACH_MACPB160, (caddr_t)0x60000000, 128 * 1024 }, { MACH_MACPB165, (caddr_t)0x60000000, 128 * 1024 }, { MACH_MACPB180, (caddr_t)0x60000000, 128 * 1024 }, + { MACH_MACIICI, (caddr_t)0x0, 320 * 1024 }, + { MACH_MACIISI, (caddr_t)0x0, 320 * 1024 }, { MACH_MACCCLASSIC, (caddr_t)0x50f40000, 512 * 1024 }, { MACH_MACPB165C, (caddr_t)0xfc040000, 512 * 1024 }, { MACH_MACPB180C, (caddr_t)0xfc040000, 512 * 1024 }, { MACH_MACPB500, (caddr_t)0x60000000, 512 * 1024 }, - { MACH_MACLC520, (caddr_t)0x60000000, 1024 * 1024 }, - { MACH_MACLC475, (caddr_t)0xf9000000, 1024 * 1024 }, - { MACH_MACLC475_33, (caddr_t)0xf9000000, 1024 * 1024 }, - { MACH_MACLC575, (caddr_t)0xf9000000, 1024 * 1024 }, - { MACH_MACC610, (caddr_t)0xf9000000, 1024 * 1024 }, - { MACH_MACC650, (caddr_t)0xf9000000, 1024 * 1024 }, - { MACH_MACP580, (caddr_t)0xf9000000, 1024 * 1024 }, - { MACH_MACQ605, (caddr_t)0xf9000000, 1024 * 1024 }, - { MACH_MACQ605_33, (caddr_t)0xf9000000, 1024 * 1024 }, - { MACH_MACQ610, (caddr_t)0xf9000000, 1024 * 1024 }, - { MACH_MACQ630, (caddr_t)0xf9000000, 1024 * 1024 }, - { MACH_MACQ650, (caddr_t)0xf9000000, 1024 * 1024 }, - { MACH_MACQ700, (caddr_t)0xf9000000, 1024 * 1024 }, - { MACH_MACQ800, (caddr_t)0xf9000000, 1024 * 1024 }, - { MACH_MACQ900, (caddr_t)0xf9000000, 1024 * 1024 }, - { MACH_MACQ950, (caddr_t)0xf9000000, 1024 * 1024 }, + { MACH_MACLC520, (caddr_t)0x60000000, 1 * 1024 * 1024 }, + { MACH_MACLC475, (caddr_t)0xf9000000, 1 * 1024 * 1024 }, + { MACH_MACLC475_33, (caddr_t)0xf9000000, 1 * 1024 * 1024 }, + { MACH_MACLC575, (caddr_t)0xf9000000, 1 * 1024 * 1024 }, + { MACH_MACC610, (caddr_t)0xf9000000, 1 * 1024 * 1024 }, + { MACH_MACC650, (caddr_t)0xf9000000, 1 * 1024 * 1024 }, + { MACH_MACP580, (caddr_t)0xf9000000, 1 * 1024 * 1024 }, + { MACH_MACQ605, (caddr_t)0xf9000000, 1 * 1024 * 1024 }, + { MACH_MACQ605_33, (caddr_t)0xf9000000, 1 * 1024 * 1024 }, + { MACH_MACQ610, (caddr_t)0xf9000000, 1 * 1024 * 1024 }, + { MACH_MACQ630, (caddr_t)0xf9000000, 1 * 1024 * 1024 }, + { MACH_MACQ650, (caddr_t)0xf9000000, 1 * 1024 * 1024 }, + { MACH_MACC660AV, (caddr_t)0x50100000, 1 * 1024 * 1024 }, + { MACH_MACQ700, (caddr_t)0xf9000000, 1 * 1024 * 1024 }, + { MACH_MACQ800, (caddr_t)0xf9000000, 1 * 1024 * 1024 }, + { MACH_MACQ900, (caddr_t)0xf9000000, 1 * 1024 * 1024 }, + { MACH_MACQ950, (caddr_t)0xf9000000, 1 * 1024 * 1024 }, + { MACH_MACQ840AV, (caddr_t)0x50100000, 2 * 1024 * 1024 }, { 0, (caddr_t)0x0, 0 }, }; /* End of intvid_info[] initialization. */ @@ -2277,7 +2281,6 @@ setmachdep() { int setup_mrg_vectors = 0; struct cpu_model_info *cpui; - int i; /* * First, set things that need to be set on the first pass only @@ -2397,19 +2400,6 @@ setmachdep() } /* - * Set `internal' framebuffer location and length, if we know - * what they are. - */ - for (i = 0; intvid_info[i].machineid; i++) { - if (mac68k_machine.machineid == intvid_info[i].machineid) { - mac68k_vidlog = mac68k_vidphys = - (u_int32_t)intvid_info[i].fbbase; - mac68k_vidlen = (u_int32_t)intvid_info[i].fblen; - break; - } - } - - /* * Set up current ROM Glue vectors. Actually now all we do * is save the address of the ROM Glue Vector table. This gets * used later when we re-map the vectors from MacOS Address @@ -2558,10 +2548,10 @@ extern int get_pte(u_int addr, u_long pte[2], u_short * psr); u_long get_physical(u_int addr, u_long * phys) { + extern u_int macos_tc; u_long pte[2], ph, mask; u_short psr; int i, numbits; - extern u_int macos_tc; if (mmutype == MMU_68040) { ph = ptest040((caddr_t)addr, FC_SUPERD); @@ -2688,15 +2678,46 @@ get_mapping(void) } #endif + /* + * Find on-board video, if we have an idea of where to look + * on this system. + */ + for (i = 0; intvid_info[i].machineid; i++) + if (mac68k_machine.machineid == intvid_info[i].machineid) + break; + + if (mac68k_machine.machineid == intvid_info[i].machineid && + get_physical(videoaddr, &phys) && + phys >= (u_long)intvid_info[i].fbbase && + phys < (u_long)(intvid_info[i].fbbase + intvid_info[i].fblen)) { + mac68k_vidphys = phys; + mac68k_vidlen = 32768; + if (mac68k_vidlen > intvid_info[i].fblen) { + mac68k_vidlen = intvid_info[i].fblen; + } else { + addr = videoaddr + 32768; + while (get_physical(addr, &phys)) { + if ((phys - mac68k_vidphys) != mac68k_vidlen) + break; + if (mac68k_vidlen + 32768 > + intvid_info[i].fblen) { + mac68k_vidlen = intvid_info[i].fblen; + break; + } + mac68k_vidlen += 32768; + addr += 32768; + } + } + } + if (mac68k_vidlen > 0) { /* - * We've already figured out where internal video is in - * setmachdep() (by using intvid_info[]). Tell the user - * what we know. + * We've already figured out where internal video is. + * Tell the user what we know. */ #ifdef DIAGNOSTIC - printf("On-board video at addr 0x%x (phys 0x%x), len 0x%x.\n", - mac68k_vidlog, mac68k_vidphys, mac68k_vidlen); + printf("On-board video at addr 0x%lx (phys 0x%x), len 0x%x.\n", + videoaddr, mac68k_vidphys, mac68k_vidlen); #endif } else { /* diff --git a/sys/arch/mac68k/mac68k/pmap_bootstrap.c b/sys/arch/mac68k/mac68k/pmap_bootstrap.c index 9b01d5b12e9..5533ad6a0f9 100644 --- a/sys/arch/mac68k/mac68k/pmap_bootstrap.c +++ b/sys/arch/mac68k/mac68k/pmap_bootstrap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap_bootstrap.c,v 1.30 2005/08/01 12:10:23 miod Exp $ */ +/* $OpenBSD: pmap_bootstrap.c,v 1.31 2005/08/06 19:51:44 martin Exp $ */ /* $NetBSD: pmap_bootstrap.c,v 1.50 1999/04/07 06:14:33 scottr Exp $ */ /* @@ -67,7 +67,6 @@ u_long high[8]; u_long maxaddr; /* PA of the last physical page */ int vidlen; #define VIDMAPSIZE btoc(vidlen) -extern u_int32_t mac68k_vidlog; extern u_int32_t mac68k_vidphys; extern u_int32_t videoaddr; extern u_int32_t videorowbytes; @@ -166,8 +165,6 @@ do { \ if (vidlen != 0) { \ newvideoaddr = iiobase + m68k_ptob(IIOMAPSIZE + ROMMAPSIZE) \ + (mac68k_vidphys & PGOFSET); \ - if (mac68k_vidlog) \ - mac68k_vidlog = newvideoaddr; \ } \ } while (0) |