Index: src/sys/arch/mac68k/conf/files.mac68k =================================================================== --- src.orig/sys/arch/mac68k/conf/files.mac68k 2007-09-03 22:34:24.000000000 +0200 +++ src/sys/arch/mac68k/conf/files.mac68k 2007-09-03 22:34:50.000000000 +0200 @@ -50,22 +50,7 @@ attach nubus at mainbus file arch/mac68k/nubus/nubus.c nubus -define grfbus { } -file arch/mac68k/dev/grf_subr.c grfbus - -device intvid: grfbus -attach intvid at obio -file arch/mac68k/obio/grf_obio.c intvid - -device macvid: grfbus -attach macvid at nubus -file arch/mac68k/nubus/grf_nubus.c macvid - -device macfb: wsemuldisplaydev, wsrasteremulops -attach macfb at grfbus -file arch/mac68k/dev/macfb.c macfb needs-flag - -file arch/mac68k/dev/maccons.c akbd & ( genfb | macfb ) +file arch/mac68k/dev/maccons.c akbd & genfb include "dev/rasops/files.rasops" include "dev/wsfb/files.wsfb" Index: src/sys/arch/mac68k/dev/macfb.c =================================================================== --- src.orig/sys/arch/mac68k/dev/macfb.c 2007-09-03 22:34:24.000000000 +0200 +++ /dev/null 1970-01-01 00:00:00.000000000 +0000 @@ -1,395 +0,0 @@ -/* $NetBSD: macfb.c,v 1.18 2007/08/29 16:09:32 jmmv Exp $ */ -/* - * Copyright (c) 1998 Matt DeBergalis - * 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 Matt DeBergalis - * 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. - */ - -#include -__KERNEL_RCSID(0, "$NetBSD: macfb.c,v 1.18 2007/08/29 16:09:32 jmmv Exp $"); - -#include "opt_wsdisplay_compat.h" -#include "grf.h" - -#include /* RCS ID & Copyright macro defns */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -int macfb_match(struct device *, struct cfdata *, void *); -void macfb_attach(struct device *, struct device *, void *); - -CFATTACH_DECL(macfb, sizeof(struct macfb_softc), - macfb_match, macfb_attach, NULL, NULL); - -const struct wsdisplay_emulops macfb_emulops = { - rcons_cursor, - rcons_mapchar, - rcons_putchar, - rcons_copycols, - rcons_erasecols, - rcons_copyrows, - rcons_eraserows, - rcons_allocattr -}; - -struct wsscreen_descr macfb_stdscreen = { - "std", - 0, 0, /* will be filled in -- XXX shouldn't, it's global */ - &macfb_emulops, - 0, 0, - WSSCREEN_REVERSE -}; - -const struct wsscreen_descr *_macfb_scrlist[] = { - &macfb_stdscreen, -}; - -const struct wsscreen_list macfb_screenlist = { - sizeof(_macfb_scrlist) / sizeof(struct wsscreen_descr *), - _macfb_scrlist -}; - -static int macfb_ioctl(void *, void *, u_long, void *, int, struct lwp *); -static paddr_t macfb_mmap(void *, void *, off_t, int); -static int macfb_alloc_screen(void *, const struct wsscreen_descr *, - void **, int *, int *, long *); -static void macfb_free_screen(void *, void *); -static int macfb_show_screen(void *, void *, int, - void (*)(void *, int, int), void *); - -const struct wsdisplay_accessops macfb_accessops = { - macfb_ioctl, - macfb_mmap, - macfb_alloc_screen, - macfb_free_screen, - macfb_show_screen, - 0 /* load_font */ -}; - -void macfb_init(struct macfb_devconfig *); - -paddr_t macfb_consaddr; -static int macfb_is_console(paddr_t); -#ifdef WSDISPLAY_COMPAT_ITEFONT -static void init_itefont(void); -#endif /* WSDISPLAY_COMPAT_ITEFONT */ - -static struct macfb_devconfig macfb_console_dc; - -static int -macfb_is_console(paddr_t addr) -{ - if (addr != macfb_consaddr && - (addr >= 0xf9000000 && addr <= 0xfeffffff)) { - /* - * This is in the NuBus standard slot space range, so we - * may well have to look at 0xFssxxxxx, too. Mask off the - * slot number and duplicate it in bits 20-23, per IM:V - * pp 459, 463, and IM:VI ch 30 p 17. - * Note: this is an ugly hack and I wish I knew what - * to do about it. -- sr - */ - addr = (paddr_t)(((u_long)addr & 0xff0fffff) | - (((u_long)addr & 0x0f000000) >> 4)); - } - return ((mac68k_machine.serial_console & 0x03) == 0 - && (addr == macfb_consaddr)); -} - -void -macfb_clear(struct macfb_devconfig *dc) -{ - int i, rows; - - /* clear the display */ - rows = dc->dc_ht; - for (i = 0; rows-- > 0; i += dc->dc_rowbytes) - memset((u_char *)dc->dc_vaddr + dc->dc_offset + i, - 0, dc->dc_rowbytes); -} - -void -macfb_init(struct macfb_devconfig *dc) -{ - struct raster *rap; - struct rcons *rcp; - - macfb_clear(dc); - -#ifdef WSDISPLAY_COMPAT_ITEFONT - init_itefont(); -#endif /* WSDISPLAY_COMPAT_ITEFONT */ - - rap = &dc->dc_raster; - rap->width = dc->dc_wid; - rap->height = dc->dc_ht; - rap->depth = dc->dc_depth; - rap->linelongs = dc->dc_rowbytes / sizeof(u_int32_t); - rap->pixels = (u_int32_t *)(dc->dc_vaddr + dc->dc_offset); - - /* initialize the raster console blitter */ - rcp = &dc->dc_rcons; - rcp->rc_sp = rap; - rcp->rc_crow = rcp->rc_ccol = -1; - rcp->rc_crowp = &rcp->rc_crow; - rcp->rc_ccolp = &rcp->rc_ccol; - rcons_init(rcp, 128, 192); - - macfb_stdscreen.nrows = dc->dc_rcons.rc_maxrow; - macfb_stdscreen.ncols = dc->dc_rcons.rc_maxcol; -} - -int -macfb_match(struct device *parent, struct cfdata *match, void *aux) -{ - return (1); -} - -void -macfb_attach(struct device *parent, struct device *self, void *aux) -{ - struct grfbus_attach_args *ga = aux; - struct grfmode *gm = ga->ga_grfmode; - struct macfb_softc *sc; - struct wsemuldisplaydev_attach_args waa; - int isconsole; - - sc = (struct macfb_softc *)self; - - printf("\n"); - - isconsole = macfb_is_console(ga->ga_phys + ga->ga_grfmode->fboff); - - if (isconsole) { - sc->sc_dc = &macfb_console_dc; - sc->nscreens = 1; - } else { - sc->sc_dc = malloc(sizeof(struct macfb_devconfig), M_DEVBUF, M_WAITOK); - sc->sc_dc->dc_vaddr = (vaddr_t)gm->fbbase; - sc->sc_dc->dc_paddr = ga->ga_phys; - sc->sc_dc->dc_size = gm->fbsize; - - sc->sc_dc->dc_wid = gm->width; - sc->sc_dc->dc_ht = gm->height; - sc->sc_dc->dc_depth = gm->psize; - sc->sc_dc->dc_rowbytes = gm->rowbytes; - - sc->sc_dc->dc_offset = gm->fboff; - - macfb_clear(sc->sc_dc); - - sc->nscreens = 1; - } - - /* initialize the raster */ - waa.console = isconsole; - waa.scrdata = &macfb_screenlist; - waa.accessops = &macfb_accessops; - waa.accesscookie = sc; - - config_found(self, &waa, wsemuldisplaydevprint); - -#if NGRF > 0 - grf_attach(sc, device_unit(self)); -#endif -} - - -int -macfb_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, - struct lwp *l) -{ - struct macfb_softc *sc = v; - struct macfb_devconfig *dc = sc->sc_dc; - struct wsdisplay_fbinfo *wdf; - - switch (cmd) { - case WSDISPLAYIO_GTYPE: - *(int *)data = dc->dc_type; - return 0; - - case WSDISPLAYIO_GINFO: - wdf = (struct wsdisplay_fbinfo *)data; - wdf->height = dc->dc_raster.height; - wdf->width = dc->dc_raster.width; - wdf->depth = dc->dc_raster.depth; - wdf->cmsize = 256; - return 0; - - case WSDISPLAYIO_GCURMAX: - case WSDISPLAYIO_GCURPOS: - case WSDISPLAYIO_GCURSOR: - case WSDISPLAYIO_GETCMAP: - case WSDISPLAYIO_GVIDEO: - case WSDISPLAYIO_PUTCMAP: - case WSDISPLAYIO_SCURPOS: - case WSDISPLAYIO_SCURSOR: - case WSDISPLAYIO_SVIDEO: - /* NONE of these operations are supported. */ - return EPASSTHROUGH; - } - - return EPASSTHROUGH; -} - -static paddr_t -macfb_mmap(void *v, void *vs, off_t offset, int prot) -{ - struct macfb_softc *sc = v; - struct macfb_devconfig *dc = sc->sc_dc; - paddr_t addr; - - if (offset >= 0 && - offset < m68k_round_page(dc->dc_rowbytes * dc->dc_ht)) - addr = m68k_btop(dc->dc_paddr + dc->dc_offset + offset); - else - addr = (-1); /* XXX bogus */ - - return addr; -} - -int -macfb_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep, - int *curxp, int *curyp, long *defattrp) -{ - struct macfb_softc *sc = v; - long defattr; - - if (sc->nscreens > 0) - return (ENOMEM); - - *cookiep = &sc->sc_dc->dc_rcons; /* one and only for now */ - *curxp = 0; - *curyp = 0; - rcons_allocattr(&sc->sc_dc->dc_rcons, 0, 0, 0, &defattr); - *defattrp = defattr; - sc->nscreens++; - return (0); -} - -void -macfb_free_screen(void *v, void *cookie) -{ - struct macfb_softc *sc = v; - - if (sc->sc_dc == &macfb_console_dc) - panic("cfb_free_screen: console"); - - sc->nscreens--; -} - -int -macfb_show_screen(void *v, void *cookie, int waitok, - void (*cb)(void *, int, int), void *cbarg) -{ - return 0; -} - -int -macfb_cnattach(paddr_t addr) -{ - struct macfb_devconfig *dc = &macfb_console_dc; - long defattr; - - dc->dc_vaddr = m68k_trunc_page(mac68k_video.mv_kvaddr); - dc->dc_paddr = m68k_trunc_page(mac68k_video.mv_phys); - - dc->dc_wid = mac68k_video.mv_width; - dc->dc_ht = mac68k_video.mv_height; - dc->dc_depth = mac68k_video.mv_depth; - dc->dc_rowbytes = mac68k_video.mv_stride; - - dc->dc_size = (mac68k_video.mv_len > 0) ? - mac68k_video.mv_len : dc->dc_ht * dc->dc_rowbytes; - dc->dc_offset = m68k_page_offset(mac68k_video.mv_phys); - - /* set up the display */ - macfb_init(&macfb_console_dc); - - rcons_allocattr(&dc->dc_rcons, 0, 0, 0, &defattr); - - wsdisplay_cnattach(&macfb_stdscreen, &dc->dc_rcons, - 0, 0, defattr); - - macfb_consaddr = addr; - dc->isconsole = 1; - return (0); -} - -#ifdef WSDISPLAY_COMPAT_ITEFONT -#include - -void -init_itefont(void) -{ - static int itefont_initted; - int i, j; - - extern struct raster_font gallant19; /* XXX */ - - if (itefont_initted) - return; - itefont_initted = 1; - - /* XXX but we cannot use malloc here... */ - gallant19.width = 6; - gallant19.height = 10; - gallant19.ascent = 0; - - for (i = 32; i < 128; i++) { - u_int *p; - - if (gallant19.chars[i].r == NULL) - continue; - - gallant19.chars[i].r->width = 6; - gallant19.chars[i].r->height = 10; - p = gallant19.chars[i].r->pixels; - - for (j = 0; j < 10; j++) - *p++ = Font6x10[i * 10 + j] << 26; - } -} -#endif /* WSDISPLAY_COMPAT_ITEFONT */ Index: src/sys/arch/mac68k/dev/macfbvar.h =================================================================== --- src.orig/sys/arch/mac68k/dev/macfbvar.h 2007-09-03 22:34:24.000000000 +0200 +++ /dev/null 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -/* $NetBSD: macfbvar.h,v 1.4 2005/12/11 12:18:02 christos Exp $ */ -/* - * Copyright (c) 1998 Matt DeBergalis - * 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 Matt DeBergalis - * 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. - */ - -#include -#include - -#include - -struct macfb_devconfig; -struct fbcmap; -struct fbcursor; -struct fbcurpos; - -struct macfb_devconfig { - int dc_type; /* WSCONS display type */ - - vaddr_t dc_vaddr; /* memory space virtual base address */ - paddr_t dc_paddr; /* memory space physical base address */ - psize_t dc_size; /* size of slot memory */ - - int dc_offset; /* offset from dc_vaddr to base of flat fb */ - - int dc_wid; /* width of frame buffer */ - int dc_ht; /* height of frame buffer */ - int dc_depth; /* depth of frame buffer */ - int dc_rowbytes; /* bytes in fb scan line */ - - struct raster dc_raster; /* raster description */ - struct rcons dc_rcons; /* raster blitter control info */ - - int isconsole; /* console device */ -}; - -struct macfb_softc { - struct device sc_dev; - - int nscreens; - struct macfb_devconfig *sc_dc; -}; - -int macfb_cnattach(paddr_t); -void macfb_clear(struct macfb_devconfig *); Index: src/sys/arch/mac68k/nubus/grf_nubus.c =================================================================== --- src.orig/sys/arch/mac68k/nubus/grf_nubus.c 2007-09-03 22:34:24.000000000 +0200 +++ /dev/null 1970-01-01 00:00:00.000000000 +0000 @@ -1,772 +0,0 @@ -/* $NetBSD: grf_nubus.c,v 1.74 2007/08/30 11:37:53 jmmv 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. 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 -__KERNEL_RCSID(0, "$NetBSD: grf_nubus.c,v 1.74 2007/08/30 11:37:53 jmmv Exp $"); - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -static void load_image_data(void *, struct image_data *); - -static void grfmv_intr_generic_write1(void *); -static void grfmv_intr_generic_write4(void *); -static void grfmv_intr_generic_or4(void *); - -static void grfmv_intr_cb264(void *); -static void grfmv_intr_cb364(void *); -static void grfmv_intr_cmax(void *); -static void grfmv_intr_cti(void *); -static void grfmv_intr_radius(void *); -static void grfmv_intr_radius24(void *); -static void grfmv_intr_supermacgfx(void *); -static void grfmv_intr_lapis(void *); -static void grfmv_intr_formac(void *); -static void grfmv_intr_vimage(void *); -static void grfmv_intr_gvimage(void *); -static void grfmv_intr_radius_gsc(void *); -static void grfmv_intr_radius_gx(void *); -static void grfmv_intr_relax_200(void *); -static void grfmv_intr_mvc(void *); -static void grfmv_intr_viltro_340(void *); - -static int grfmv_mode(struct grf_softc *, int, void *); -static int grfmv_match(struct device *, struct cfdata *, void *); -static void grfmv_attach(struct device *, struct device *, void *); - -CFATTACH_DECL(macvid, sizeof(struct grfbus_softc), - grfmv_match, grfmv_attach, NULL, NULL); - -static void -load_image_data(void * data, struct image_data *image) -{ - char *d = (char*)data; - - memcpy(&image->size, d , 4); - memcpy(&image->offset, d + 4, 4); - memcpy(&image->rowbytes, d + 8, 2); - memcpy(&image->top, d + 10, 2); - memcpy(&image->left, d + 12, 2); - memcpy(&image->bottom, d + 14, 2); - memcpy(&image->right, d + 16, 2); - memcpy(&image->version, d + 18, 2); - memcpy(&image->packType, d + 20, 2); - memcpy(&image->packSize, d + 22, 4); - memcpy(&image->hRes, d + 26, 4); - memcpy(&image->vRes, d + 30, 4); - memcpy(&image->pixelType, d + 34, 2); - memcpy(&image->pixelSize, d + 36, 2); - memcpy(&image->cmpCount, d + 38, 2); - memcpy(&image->cmpSize, d + 40, 2); - memcpy(&image->planeBytes, d + 42, 4); -} - - -static int -grfmv_match(struct device *parent, struct cfdata *cf, void *aux) -{ - struct nubus_attach_args *na = (struct nubus_attach_args *)aux; - - if (na->category != NUBUS_CATEGORY_DISPLAY) - return 0; - - if (na->type != NUBUS_TYPE_VIDEO) - return 0; - - if (na->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. - */ - - return 1; -} - -static void -grfmv_attach(struct device *parent, struct device *self, void *aux) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)self; - struct nubus_attach_args *na = (struct nubus_attach_args *)aux; - struct image_data image_store, image; - struct grfmode *gm; - char cardname[CARD_NAME_LEN]; - nubus_dirent dirent; - nubus_dir dir, mode_dir; - int mode; - - memcpy(&sc->sc_slot, na->fmt, sizeof(nubus_slot)); - - 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, sc->sc_basepa, NBMEMSIZE, - 0, &sc->sc_handle)) { - printf(": grfmv_attach: failed to map slot %d\n", na->slot); - return; - } - - nubus_get_main_dir(&sc->sc_slot, &dir); - - if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle, - &sc->sc_slot, &dir, na->rsrcid, &dirent) <= 0) { -bad: - bus_space_unmap(sc->sc_tag, sc->sc_handle, NBMEMSIZE); - return; - } - - nubus_get_dir_from_rsrc(&sc->sc_slot, &dirent, &sc->board_dir); - - if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle, - &sc->sc_slot, &sc->board_dir, NUBUS_RSRC_TYPE, &dirent) <= 0) - if ((na->rsrcid != 128) || - (nubus_find_rsrc(sc->sc_tag, sc->sc_handle, - &sc->sc_slot, &dir, 129, &dirent) <= 0)) - goto bad; - - mode = NUBUS_RSRC_FIRSTMODE; - if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle, - &sc->sc_slot, &sc->board_dir, mode, &dirent) <= 0) { - printf(": probe failed to get board rsrc.\n"); - goto bad; - } - - nubus_get_dir_from_rsrc(&sc->sc_slot, &dirent, &mode_dir); - - if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle, - &sc->sc_slot, &mode_dir, VID_PARAMS, &dirent) <= 0) { - printf(": probe failed to get mode dir.\n"); - goto bad; - } - - if (nubus_get_ind_data(sc->sc_tag, sc->sc_handle, &sc->sc_slot, - &dirent, (void *)&image_store, sizeof(struct image_data)) <= 0) { - printf(": probe failed to get indirect mode data.\n"); - goto bad; - } - - /* Need to load display info (and driver?), etc... (?) */ - - load_image_data((void *)&image_store, &image); - - gm = &sc->curr_mode; - gm->mode_id = mode; - gm->ptype = image.pixelType; - gm->psize = image.pixelSize; - gm->width = image.right - image.left; - gm->height = image.bottom - image.top; - gm->rowbytes = image.rowbytes; - gm->hres = image.hRes; - gm->vres = image.vRes; - gm->fbsize = gm->height * gm->rowbytes; - gm->fbbase = (void *)(sc->sc_handle.base); /* XXX evil hack */ - gm->fboff = image.offset; - - strncpy(cardname, nubus_get_card_name(sc->sc_tag, sc->sc_handle, - &sc->sc_slot), CARD_NAME_LEN); - cardname[CARD_NAME_LEN-1] = '\0'; - printf(": %s\n", cardname); - - if (sc->card_id == NUBUS_DRHW_TFB) { - /* - * This is the Toby card, but apparently some manufacturers - * (like Cornerstone) didn't bother to get/use their own - * value here, even though the cards are different, so we - * try to differentiate here. - */ - if (strncmp(cardname, "Samsung 768", 11) == 0) - sc->card_id = NUBUS_DRHW_SAM768; - else if (strncmp(cardname, "Toby frame", 10) != 0) - printf("%s: This display card pretends to be a TFB!\n", - sc->sc_dev.dv_xname); - } - - switch (sc->card_id) { - case NUBUS_DRHW_TFB: - case NUBUS_DRHW_M2HRVC: - case NUBUS_DRHW_PVC: - sc->cli_offset = 0xa0000; - sc->cli_value = 0; - add_nubus_intr(na->slot, grfmv_intr_generic_write1, sc); - break; - case NUBUS_DRHW_WVC: - sc->cli_offset = 0xa00000; - sc->cli_value = 0; - add_nubus_intr(na->slot, grfmv_intr_generic_write1, sc); - break; - case NUBUS_DRHW_COLORMAX: - add_nubus_intr(na->slot, grfmv_intr_cmax, sc); - break; - case NUBUS_DRHW_SE30: - /* Do nothing--SE/30 interrupts are disabled */ - break; - case NUBUS_DRHW_MDC: - sc->cli_offset = 0x200148; - sc->cli_value = 1; - add_nubus_intr(na->slot, grfmv_intr_generic_write4, sc); - - /* Enable interrupts; to disable, write 0x7 to this location */ - bus_space_write_4(sc->sc_tag, sc->sc_handle, 0x20013C, 5); - break; - case NUBUS_DRHW_CB264: - add_nubus_intr(na->slot, grfmv_intr_cb264, sc); - break; - case NUBUS_DRHW_CB364: - add_nubus_intr(na->slot, grfmv_intr_cb364, sc); - break; - case NUBUS_DRHW_RPC8: - sc->cli_offset = 0xfdff8f; - sc->cli_value = 0xff; - add_nubus_intr(na->slot, grfmv_intr_generic_write1, sc); - break; - case NUBUS_DRHW_RPC8XJ: - sc->cli_value = 0x66; - add_nubus_intr(na->slot, grfmv_intr_radius, sc); - break; - case NUBUS_DRHW_RPC24X: - case NUBUS_DRHW_BOOGIE: - sc->cli_value = 0x64; - add_nubus_intr(na->slot, grfmv_intr_radius, sc); - break; - case NUBUS_DRHW_RPC24XP: - add_nubus_intr(na->slot, grfmv_intr_radius24, sc); - break; - case NUBUS_DRHW_RADGSC: - add_nubus_intr(na->slot, grfmv_intr_radius_gsc, sc); - break; - case NUBUS_DRHW_RDCGX: - add_nubus_intr(na->slot, grfmv_intr_radius_gx, sc); - break; - case NUBUS_DRHW_FIILX: - case NUBUS_DRHW_FIISXDSP: - case NUBUS_DRHW_FUTURASX: - sc->cli_offset = 0xf05000; - sc->cli_value = 0x80; - add_nubus_intr(na->slot, grfmv_intr_generic_write1, sc); - break; - case NUBUS_DRHW_SAM768: - add_nubus_intr(na->slot, grfmv_intr_cti, sc); - break; - case NUBUS_DRHW_SUPRGFX: - add_nubus_intr(na->slot, grfmv_intr_supermacgfx, sc); - break; - case NUBUS_DRHW_SPECTRM8: - sc->cli_offset = 0x0de178; - sc->cli_value = 0x80; - add_nubus_intr(na->slot, grfmv_intr_generic_or4, sc); - break; - case NUBUS_DRHW_LAPIS: - add_nubus_intr(na->slot, grfmv_intr_lapis, sc); - break; - case NUBUS_DRHW_RELAX200: - add_nubus_intr(na->slot, grfmv_intr_relax_200, sc); - break; - case NUBUS_DRHW_BAER: - case NUBUS_DRHW_FORMAC: - add_nubus_intr(na->slot, grfmv_intr_formac, sc); - break; - case NUBUS_DRHW_ROPS24LXI: - case NUBUS_DRHW_ROPS24XLTV: - case NUBUS_DRHW_ROPS24MXTV: - sc->cli_offset = 0xfb0010; - sc->cli_value = 0x00; - add_nubus_intr(na->slot, grfmv_intr_generic_write4, sc); - break; - case NUBUS_DRHW_ROPSPPGT: - sc->cli_offset = 0xf50010; - sc->cli_value = 0x02; - add_nubus_intr(na->slot, grfmv_intr_generic_write4, sc); - break; - case NUBUS_DRHW_VIMAGE: - add_nubus_intr(na->slot, grfmv_intr_vimage, sc); - break; - case NUBUS_DRHW_GVIMAGE: - add_nubus_intr(na->slot, grfmv_intr_gvimage, sc); - break; - case NUBUS_DRHW_MC2124NB: - sc->cli_offset = 0xfd1000; - sc->cli_value = 0x00; - add_nubus_intr(na->slot, grfmv_intr_generic_write4, sc); - break; - case NUBUS_DRHW_MICRON: - sc->cli_offset = 0xa00014; - sc->cli_value = 0; - add_nubus_intr(na->slot, grfmv_intr_generic_write4, sc); - break; - case NUBUS_DRHW_MVC: - add_nubus_intr(na->slot, grfmv_intr_mvc, sc); - break; - case NUBUS_DRHW_VILTRO340: - add_nubus_intr(na->slot, grfmv_intr_viltro_340, sc); - break; - default: - printf("%s: Unknown video card ID 0x%x --", - sc->sc_dev.dv_xname, sc->card_id); - printf(" Not installing interrupt routine.\n"); - break; - } - - /* Perform common video attachment. */ - grf_establish(sc, &sc->sc_slot, grfmv_mode); -} - -static int -grfmv_mode(struct grf_softc *gp, int cmd, void *arg) -{ - switch (cmd) { - case GM_GRFON: - case GM_GRFOFF: - return 0; - case GM_CURRMODE: - break; - case GM_NEWMODE: - break; - case GM_LISTMODES: - break; - } - return EINVAL; -} - -/* Interrupt handlers... */ -/* - * Generic routine to clear interrupts for cards where it simply takes - * a MOV.B to clear the interrupt. The offset and value of this byte - * varies between cards. - */ -/*ARGSUSED*/ -static void -grfmv_intr_generic_write1(void *vsc) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)vsc; - - bus_space_write_1(sc->sc_tag, sc->sc_handle, - sc->cli_offset, (u_int8_t)sc->cli_value); -} - -/* - * Generic routine to clear interrupts for cards where it simply takes - * a MOV.L to clear the interrupt. The offset and value of this byte - * varies between cards. - */ -/*ARGSUSED*/ -static void -grfmv_intr_generic_write4(void *vsc) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)vsc; - - bus_space_write_4(sc->sc_tag, sc->sc_handle, - sc->cli_offset, sc->cli_value); -} - -/* - * Generic routine to clear interrupts for cards where it simply takes - * an OR.L to clear the interrupt. The offset and value of this byte - * varies between cards. - */ -/*ARGSUSED*/ -static void -grfmv_intr_generic_or4(void *vsc) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)vsc; - unsigned long scratch; - - scratch = bus_space_read_4(sc->sc_tag, sc->sc_handle, sc->cli_offset); - scratch |= 0x80; - bus_space_write_4(sc->sc_tag, sc->sc_handle, sc->cli_offset, scratch); -} - -/* - * Routine to clear interrupts for the Radius PrecisionColor 8xj card. - */ -/*ARGSUSED*/ -static void -grfmv_intr_radius(void *vsc) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)vsc; - u_int8_t c; - - c = sc->cli_value; - - c |= 0x80; - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xd00403, c); - c &= 0x7f; - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xd00403, c); -} - -/* - * Routine to clear interrupts for the Radius PrecisionColor 24Xp card. - * Is this what the 8xj routine is doing, too? - */ -/*ARGSUSED*/ -static void -grfmv_intr_radius24(void *vsc) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)vsc; - u_int8_t c; - - c = 0x80 | bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xfffd8); - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xd00403, c); - c &= 0x7f; - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xd00403, c); -} - -/* - * Routine to clear interrupts on Samsung 768x1006 video controller. - * This controller was manufactured by Cornerstone Technology, Inc., - * now known as Cornerstone Imaging. - * - * To clear this interrupt, we apparently have to set, then clear, - * bit 2 at byte offset 0x80000 from the card's base. - * Information for this provided by Brad Salai - */ -/*ARGSUSED*/ -static void -grfmv_intr_cti(void *vsc) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)vsc; - u_int8_t c; - - c = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0x80000); - c |= 0x02; - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x80000, c); - c &= 0xfd; - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x80000, c); -} - -/*ARGSUSED*/ -static void -grfmv_intr_cb264(void *vsc) -{ - struct grfbus_softc *sc; - volatile char *slotbase; - - sc = (struct grfbus_softc *)vsc; - slotbase = (volatile char *)(sc->sc_handle.base); /* XXX evil hack */ - __asm volatile( - " movl %0,%%a0 \n" - " movl %%a0@(0xff6028),%%d0 \n" - " andl #0x2,%%d0 \n" - " beq _mv_intr0 \n" - " movql #0x3,%%d0 \n" - "_mv_intr0: \n" - " movl %%a0@(0xff600c),%%d1 \n" - " andl #0x3,%%d1 \n" - " cmpl %%d1,%%d0 \n" - " beq _mv_intr_fin \n" - " movl %%d0,%%a0@(0xff600c) \n" - " nop \n" - " tstb %%d0 \n" - " beq _mv_intr1 \n" - " movl #0x0002,%%a0@(0xff6040) \n" - " movl #0x0102,%%a0@(0xff6044) \n" - " movl #0x0105,%%a0@(0xff6048) \n" - " movl #0x000e,%%a0@(0xff604c) \n" - " movl #0x001c,%%a0@(0xff6050) \n" - " movl #0x00bc,%%a0@(0xff6054) \n" - " movl #0x00c3,%%a0@(0xff6058) \n" - " movl #0x0061,%%a0@(0xff605c) \n" - " movl #0x0012,%%a0@(0xff6060) \n" - " bra _mv_intr_fin \n" - "_mv_intr1: \n" - " movl #0x0002,%%a0@(0xff6040) \n" - " movl #0x0209,%%a0@(0xff6044) \n" - " movl #0x020c,%%a0@(0xff6048) \n" - " movl #0x000f,%%a0@(0xff604c) \n" - " movl #0x0027,%%a0@(0xff6050) \n" - " movl #0x00c7,%%a0@(0xff6054) \n" - " movl #0x00d7,%%a0@(0xff6058) \n" - " movl #0x006b,%%a0@(0xff605c) \n" - " movl #0x0029,%%a0@(0xff6060) \n" - "_mv_intr_fin: \n" - " movl #0x1,%%a0@(0xff6014)" - : : "g" (slotbase) : "a0","d0","d1"); -} - -/* - * Support for the Colorboard 364 might be more complex than it needs to - * be. If we can find more information about this card, this might be - * significantly simplified. Contributions welcome... :-) - */ -/*ARGSUSED*/ -static void -grfmv_intr_cb364(void *vsc) -{ - struct grfbus_softc *sc; - volatile char *slotbase; - - sc = (struct grfbus_softc *)vsc; - slotbase = (volatile char *)(sc->sc_handle.base); /* XXX evil hack */ - __asm volatile( - " movl %0,%%a0 \n" - " movl %%a0@(0xfe6028),%%d0 \n" - " andl #0x2,%%d0 \n" - " beq _cb364_intr4 \n" - " movql #0x3,%%d0 \n" - " movl %%a0@(0xfe6018),%%d1 \n" - " movl #0x3,%%a0@(0xfe6018) \n" - " movw %%a0@(0xfe7010),%%d2 \n" - " movl %%d1,%%a0@(0xfe6018) \n" - " movl %%a0@(0xfe6020),%%d1 \n" - " btst #0x06,%%d2 \n" - " beq _cb364_intr0 \n" - " btst #0x00,%%d1 \n" - " beq _cb364_intr5 \n" - " bsr _cb364_intr1 \n" - " bra _cb364_intr_out \n" - "_cb364_intr0: \n" - " btst #0x00,%%d1 \n" - " bne _cb364_intr5 \n" - " bsr _cb364_intr1 \n" - " bra _cb364_intr_out \n" - "_cb364_intr1: \n" - " movl %%d0,%%a0@(0xfe600c) \n" - " nop \n" - " tstb %%d0 \n" - " beq _cb364_intr3 \n" - " movl #0x0002,%%a0@(0xfe6040) \n" - " movl #0x0105,%%a0@(0xfe6048) \n" - " movl #0x000e,%%a0@(0xfe604c) \n" - " movl #0x00c3,%%a0@(0xfe6058) \n" - " movl #0x0061,%%a0@(0xfe605c) \n" - " btst #0x06,%%d2 \n" - " beq _cb364_intr2 \n" - " movl #0x001c,%%a0@(0xfe6050) \n" - " movl #0x00bc,%%a0@(0xfe6054) \n" - " movl #0x0012,%%a0@(0xfe6060) \n" - " movl #0x000e,%%a0@(0xfe6044) \n" - " movl #0x00c3,%%a0@(0xfe6064) \n" - " movl #0x0061,%%a0@(0xfe6020) \n" - " rts \n" - "_cb364_intr2: \n" - " movl #0x0016,%%a0@(0xfe6050) \n" - " movl #0x00b6,%%a0@(0xfe6054) \n" - " movl #0x0011,%%a0@(0xfe6060) \n" - " movl #0x0101,%%a0@(0xfe6044) \n" - " movl #0x00bf,%%a0@(0xfe6064) \n" - " movl #0x0001,%%a0@(0xfe6020) \n" - " rts \n" - "_cb364_intr3: \n" - " movl #0x0002,%%a0@(0xfe6040) \n" - " movl #0x0209,%%a0@(0xfe6044) \n" - " movl #0x020c,%%a0@(0xfe6048) \n" - " movl #0x000f,%%a0@(0xfe604c) \n" - " movl #0x0027,%%a0@(0xfe6050) \n" - " movl #0x00c7,%%a0@(0xfe6054) \n" - " movl #0x00d7,%%a0@(0xfe6058) \n" - " movl #0x006b,%%a0@(0xfe605c) \n" - " movl #0x0029,%%a0@(0xfe6060) \n" - " oril #0x0040,%%a0@(0xfe6064) \n" - " movl #0x0000,%%a0@(0xfe6020) \n" - " rts \n" - "_cb364_intr4: \n" - " movq #0x00,%%d0 \n" - "_cb364_intr5: \n" - " movl %%a0@(0xfe600c),%%d1 \n" - " andl #0x3,%%d1 \n" - " cmpl %%d1,%%d0 \n" - " beq _cb364_intr_out \n" - " bsr _cb364_intr1 \n" - "_cb364_intr_out: \n" - " movl #0x1,%%a0@(0xfe6014) \n" - "_cb364_intr_quit:" - : : "g" (slotbase) : "a0","d0","d1","d2"); -} - -/* - * Interrupt clearing routine for SuperMac GFX card. - */ -/*ARGSUSED*/ -static void -grfmv_intr_supermacgfx(void *vsc) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)vsc; - u_int8_t dummy; - - dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xE70D3); -} - -/* - * Routine to clear interrupts for the Sigma Designs ColorMax card. - */ -/*ARGSUSED*/ -static void -grfmv_intr_cmax(void *vsc) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)vsc; - u_int32_t dummy; - - dummy = bus_space_read_4(sc->sc_tag, sc->sc_handle, 0xf501c); - dummy = bus_space_read_4(sc->sc_tag, sc->sc_handle, 0xf5018); -} - -/* - * Routine to clear interrupts for the Lapis ProColorServer 8 PDS card - * (for the SE/30). - */ -/*ARGSUSED*/ -static void -grfmv_intr_lapis(void *vsc) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)vsc; - - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xff7000, 0x08); - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xff7000, 0x0C); -} - -/* - * Routine to clear interrupts for the Formac ProNitron 80.IVb - * and Color Card II - */ -/*ARGSUSED*/ -static void -grfmv_intr_formac(void *vsc) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)vsc; - u_int8_t dummy; - - dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xde80db); - dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xde80d3); -} - -/* - * Routine to clear interrupts for the Vimage by Interware Co., Ltd. - */ -/*ARGSUSED*/ -static void -grfmv_intr_vimage(void *vsc) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)vsc; - - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x800000, 0x67); - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x800000, 0xE7); -} - -/* - * Routine to clear interrupts for the Grand Vimage by Interware Co., Ltd. - */ -/*ARGSUSED*/ -static void -grfmv_intr_gvimage(void *vsc) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)vsc; - u_int8_t dummy; - - dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xf00000); -} - -/* - * Routine to clear interrupts for the Radius GS/C - */ -/*ARGSUSED*/ -static void -grfmv_intr_radius_gsc(void *vsc) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)vsc; - u_int8_t dummy; - - dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xfb802); - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xfb802, 0xff); -} - -/* - * Routine to clear interrupts for the Radius GS/C - */ -/*ARGSUSED*/ -static void -grfmv_intr_radius_gx(void *vsc) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)vsc; - - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x600000, 0x00); - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x600000, 0x20); -} - -/* - * Routine to clear interrupts for the Relax 19" model 200. - */ -/*ARGSUSED*/ -static void -grfmv_intr_relax_200(void *vsc) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)vsc; - unsigned long scratch; - - /* The board ROM driver code has a tst.l here. */ - scratch = bus_space_read_4(sc->sc_tag, sc->sc_handle, 0x000D0040); -} - -/* - * Routine to clear interrupts for the Apple Mac II Monochrome Video Card. - */ -/*ARGSUSED*/ -static void -grfmv_intr_mvc(void *vsc) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)vsc; - - bus_space_write_4(sc->sc_tag, sc->sc_handle, 0x00040000, 0); - bus_space_write_4(sc->sc_tag, sc->sc_handle, 0x00020000, 0); -} - -/* - * Routine to clear interrupts for the VillageTronic Mac Picasso 340. - */ -/*ARGSUSED*/ -static void -grfmv_intr_viltro_340(void *vsc) -{ - struct grfbus_softc *sc = (struct grfbus_softc *)vsc; - u_int8_t scratch; - - /* Yes, two read accesses to the same spot. */ - scratch = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0x0500); - scratch = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0x0500); -} Index: src/sys/arch/mac68k/obio/grf_obio.c =================================================================== --- src.orig/sys/arch/mac68k/obio/grf_obio.c 2007-09-03 22:34:24.000000000 +0200 +++ /dev/null 1970-01-01 00:00:00.000000000 +0000 @@ -1,369 +0,0 @@ -/* $NetBSD: grf_obio.c,v 1.56 2007/08/29 16:09:32 jmmv 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 - * 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 -__KERNEL_RCSID(0, "$NetBSD: grf_obio.c,v 1.56 2007/08/29 16:09:32 jmmv Exp $"); - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -static int grfiv_mode(struct grf_softc *, int, void *); -static int grfiv_match(struct device *, struct cfdata *, void *); -static void grfiv_attach(struct device *, struct device *, void *); - -CFATTACH_DECL(intvid, sizeof(struct grfbus_softc), - grfiv_match, grfiv_attach, NULL, NULL); - -#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(struct device *parent, struct cfdata *cf, void *aux) -{ - 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_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); - - bus_space_unmap(oa->oa_tag, bsh, 0x40); - 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, base, 0x20, 0, &bsh)) - return 0; - - if (mac68k_bus_space_probe(oa->oa_tag, bsh, 0x1c, 4) == 0) { - bus_space_unmap(oa->oa_tag, bsh, 0x20); - return 0; - } - - bus_space_unmap(oa->oa_tag, bsh, 0x20); - - if (bus_space_map(oa->oa_tag, base + 0x100, 0x20, 0, &bsh)) - return 0; - - if (mac68k_bus_space_probe(oa->oa_tag, bsh, 0x04, 4) == 0) { - bus_space_unmap(oa->oa_tag, bsh, 0x20); - return 0; - } - - /* Disable interrupts */ - bus_space_write_4(oa->oa_tag, bsh, 0x04, 0); - - /* Clear any interrupts */ - bus_space_write_4(oa->oa_tag, bsh, 0x0C, 0); - bus_space_write_4(oa->oa_tag, bsh, 0x10, 0); - bus_space_write_4(oa->oa_tag, bsh, 0x14, 0); - - bus_space_unmap(oa->oa_tag, bsh, 0x20); - break; - case MACH_CLASSAV: - 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; - case MACH_CLASSIIci: - case MACH_CLASSIIsi: - if (mac68k_video.mv_len == 0 || - (via2_reg(rMonitor) & RBVMonitorMask) == RBVMonIDNone) - found = 0; - break; - default: - if (mac68k_video.mv_len == 0) - found = 0; - break; - } - - return found; -} - -static void -grfiv_attach(struct device *parent, struct device *self, void *aux) -{ - struct obio_attach_args *oa = (struct obio_attach_args *)aux; - struct grfbus_softc *sc; - struct grfmode *gm; - u_long base, length; - u_int32_t vbase1, vbase2; - - 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_video.mv_phys && - mac68k_video.mv_phys < (sc->sc_basepa + length)) { - sc->sc_fbofs = - mac68k_video.mv_phys - sc->sc_basepa; - } else { - sc->sc_basepa = - m68k_trunc_page(mac68k_video.mv_phys); - sc->sc_fbofs = - m68k_page_offset(mac68k_video.mv_phys); - length = mac68k_video.mv_len + sc->sc_fbofs; - } - - printf(" @ %lx: Valkyrie video subsystem\n", - sc->sc_basepa + sc->sc_fbofs); - break; - } - /* See note in grfiv_match() */ - /*FALLTHROUGH*/ - case MACH_CLASSQ: - base = DAFB_CONTROL_BASE; - sc->sc_tag = oa->oa_tag; - if (bus_space_map(sc->sc_tag, base, 0x20, 0, &sc->sc_regh)) { - printf(": failed to map DAFB register space\n"); - return; - } - - 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; -#if 1 - /* - * XXX The following exists because the DAFB v7 in these - * systems doesn't return reasonable values to use for fbofs. - * Ken'ichi Ishizaka gets credit for this hack. (sar 19990426) - * (Does this get us the correct result for _all_ DAFB- - * equipped systems and monitor combinations? It seems - * possible, if not likely...) - */ - switch (current_mac_model->machineid) { - case MACH_MACLC475: - case MACH_MACLC475_33: - case MACH_MACLC575: - case MACH_MACQ605: - case MACH_MACQ605_33: - vbase1 &= 0x3f; - break; - } -#endif - vbase2 = bus_space_read_4(sc->sc_tag, sc->sc_regh, 0x4) & 0xf; - sc->sc_fbofs = (vbase1 << 9) | (vbase2 << 5); - - printf(" @ %lx: DAFB video subsystem, monitor sense %x\n", - sc->sc_basepa + sc->sc_fbofs, - (bus_space_read_4(sc->sc_tag, sc->sc_regh, 0x1c) & 0x7)); - - bus_space_unmap(sc->sc_tag, sc->sc_regh, 0x20); - break; - case MACH_CLASSAV: - sc->sc_basepa = CIVIC_BASE; - length = 0x00200000; /* 2MB */ - if (mac68k_video.mv_phys >= sc->sc_basepa && - mac68k_video.mv_phys < (sc->sc_basepa + length)) { - sc->sc_fbofs = mac68k_video.mv_phys - sc->sc_basepa; - } else { - sc->sc_basepa = m68k_trunc_page(mac68k_video.mv_phys); - sc->sc_fbofs = m68k_page_offset(mac68k_video.mv_phys); - length = mac68k_video.mv_len + sc->sc_fbofs; - } - - printf(" @ %lx: CIVIC video subsystem\n", - sc->sc_basepa + sc->sc_fbofs); - break; - case MACH_CLASSIIci: - case MACH_CLASSIIsi: - sc->sc_basepa = m68k_trunc_page(mac68k_video.mv_phys); - sc->sc_fbofs = m68k_page_offset(mac68k_video.mv_phys); - length = mac68k_video.mv_len + sc->sc_fbofs; - - printf(" @ %lx: RBV video subsystem, ", - sc->sc_basepa + sc->sc_fbofs); - switch (via2_reg(rMonitor) & RBVMonitorMask) { - case RBVMonIDBWP: - printf("15\" monochrome portrait"); - break; - case RBVMonIDRGB12: - printf("12\" color"); - break; - case RBVMonIDRGB15: - printf("15\" color"); - break; - case RBVMonIDStd: - printf("Macintosh II"); - break; - default: - printf("unrecognized"); - break; - } - printf(" display\n"); - - break; - default: - sc->sc_basepa = m68k_trunc_page(mac68k_video.mv_phys); - sc->sc_fbofs = m68k_page_offset(mac68k_video.mv_phys); - length = mac68k_video.mv_len + 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_video.mv_phys && - mac68k_video.mv_phys < (sc->sc_basepa + length)) { - /* XXX Hack */ - mac68k_video.mv_kvaddr = sc->sc_handle.base + sc->sc_fbofs; - } - - gm = &(sc->curr_mode); - gm->mode_id = 0; - gm->psize = mac68k_video.mv_depth; - gm->ptype = 0; - gm->width = mac68k_video.mv_width; - gm->height = mac68k_video.mv_height; - gm->rowbytes = mac68k_video.mv_stride; - gm->hres = 80; /* XXX hack */ - gm->vres = 80; /* XXX hack */ - gm->fbsize = gm->height * gm->rowbytes; - gm->fbbase = (void *)sc->sc_handle.base; /* XXX yet another hack */ - gm->fboff = sc->sc_fbofs; - - /* Perform common video attachment. */ - grf_establish(sc, NULL, grfiv_mode); -} - -static int -grfiv_mode(struct grf_softc *sc, int cmd, void *arg) -{ - switch (cmd) { - case GM_GRFON: - case GM_GRFOFF: - return 0; - case GM_CURRMODE: - break; - case GM_NEWMODE: - break; - case GM_LISTMODES: - break; - } - return EINVAL; -} Index: src/sys/arch/mac68k/dev/maccons.c =================================================================== --- src.orig/sys/arch/mac68k/dev/maccons.c 2007-09-03 22:34:24.000000000 +0200 +++ src/sys/arch/mac68k/dev/maccons.c 2007-09-03 22:34:50.000000000 +0200 @@ -44,7 +44,6 @@ #include #include #include -#include #include void maccnprobe(struct consdev *); @@ -83,15 +82,8 @@ * XXX evil hack; see consinit() for an explanation. * note: maccons_initted is initialized to (-1). */ - if (++maccons_initted > 0) { -#if NMACFB > 0 - /* XXX This is insufficient if any of the *fb drivers are - * present. But as macfb is supposed to die soon, don't - * bother to do this correctly. */ - macfb_cnattach(mac68k_video.mv_phys); -#endif + if (++maccons_initted > 0) akbd_cnattach(); - } } int Index: src/sys/arch/mac68k/mac68k/machdep.c =================================================================== --- src.orig/sys/arch/mac68k/mac68k/machdep.c 2007-09-03 22:34:24.000000000 +0200 +++ src/sys/arch/mac68k/mac68k/machdep.c 2007-09-03 22:34:50.000000000 +0200 @@ -115,7 +115,6 @@ #include "opt_kgdb.h" #include "opt_compat_netbsd.h" #include "akbd.h" -#include "macfb.h" #include "wsdisplay.h" #include "zsc.h" @@ -177,9 +176,6 @@ #if NAKBD > 0 #include #endif -#if NMACFB > 0 -#include -#endif #include #include "ksyms.h" Index: src/sys/arch/mac68k/mac68k/conf.c =================================================================== --- src.orig/sys/arch/mac68k/mac68k/conf.c 2007-09-03 22:34:24.000000000 +0200 +++ src/sys/arch/mac68k/mac68k/conf.c 2007-09-03 22:34:50.000000000 +0200 @@ -42,7 +42,6 @@ #include "zstty.h" #include "akbd.h" -#include "macfb.h" #include "wsdisplay.h" #define maccnpollc nullcnpollc cons_decl(mac); Index: src/sys/arch/mac68k/dev/grf_subr.c =================================================================== --- src.orig/sys/arch/mac68k/dev/grf_subr.c 2007-09-03 22:34:24.000000000 +0200 +++ /dev/null 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -/* $NetBSD: grf_subr.c,v 1.19 2005/12/11 12:18:02 christos 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 FOUNDATION 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 -__KERNEL_RCSID(0, "$NetBSD: grf_subr.c,v 1.19 2005/12/11 12:18:02 christos Exp $"); - -#include -#include -#include - -#include -#include - -#include -#include - -void -grf_establish(struct grfbus_softc *sc, nubus_slot *sp, - int (*g_mode)(struct grf_softc *, int, void *)) -{ - 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 = sp; - ga.ga_tag = sc->sc_tag; - ga.ga_handle = sc->sc_handle; - ga.ga_phys = sc->sc_basepa; - ga.ga_mode = g_mode; - (void)config_found(&sc->sc_dev, &ga, grfbusprint); -} - -int -grfbusprint(void *aux, const char *name) -{ - struct grfbus_attach_args *ga = aux; - - if (name) - aprint_normal("%s at %s", ga->ga_name, name); - - return (UNCONF); -} Index: src/sys/arch/mac68k/obio/genfb_obio.c =================================================================== --- src.orig/sys/arch/mac68k/obio/genfb_obio.c 2007-09-03 22:34:24.000000000 +0200 +++ src/sys/arch/mac68k/obio/genfb_obio.c 2007-09-03 22:34:50.000000000 +0200 @@ -118,7 +118,6 @@ #include #include -#include /* XXX Remove with intvid/macvid. */ #include #include @@ -250,11 +249,16 @@ static void obio_genfb_attach(struct device *parent, struct device *self, void *aux) { + char pad[10000]; struct obio_attach_args *oa = (struct obio_attach_args *)aux; struct obio_genfb_softc *sc = (struct obio_genfb_softc *)self; struct colormap_softc *cmap = &sc->sc_cmap; struct genfb_ops ops; size_t length; + char pad2[10000]; + + memset(pad, 0, sizeof(pad)); + memset(pad2, 0, sizeof(pad2)); cmap->sc_cb.gcc_cookie = NULL; cmap->sc_cb.gcc_set_mapreg = NULL; Index: src/sys/arch/mac68k/dev/grfvar.h =================================================================== --- src.orig/sys/arch/mac68k/dev/grfvar.h 2007-09-03 22:34:48.000000000 +0200 +++ src/sys/arch/mac68k/dev/grfvar.h 2007-09-03 22:34:50.000000000 +0200 @@ -169,7 +169,3 @@ #define VID_DEV_TYPE 4 void grf_attach(struct genfb_softc *, int); - -void grf_establish(struct grfbus_softc *, nubus_slot *, - int (*)(struct grf_softc *, int, void *)); -int grfbusprint(void *, const char *);