Home | History | Annotate | Line # | Download | only in nubus
grf_nubus.c revision 1.31
      1  1.31  scottr /*	$NetBSD: grf_nubus.c,v 1.31 1997/08/11 22:53:31 scottr Exp $	*/
      2   1.1  briggs 
      3   1.1  briggs /*
      4   1.1  briggs  * Copyright (c) 1995 Allen Briggs.  All rights reserved.
      5   1.1  briggs  *
      6   1.1  briggs  * Redistribution and use in source and binary forms, with or without
      7   1.1  briggs  * modification, are permitted provided that the following conditions
      8   1.1  briggs  * are met:
      9   1.1  briggs  * 1. Redistributions of source code must retain the above copyright
     10   1.1  briggs  *    notice, this list of conditions and the following disclaimer.
     11   1.1  briggs  * 2. Redistributions in binary form must reproduce the above copyright
     12   1.1  briggs  *    notice, this list of conditions and the following disclaimer in the
     13   1.1  briggs  *    documentation and/or other materials provided with the distribution.
     14   1.1  briggs  * 3. All advertising materials mentioning features or use of this software
     15   1.1  briggs  *    must display the following acknowledgement:
     16   1.1  briggs  *	This product includes software developed by Allen Briggs.
     17   1.1  briggs  * 4. The name of the author may not be used to endorse or promote products
     18   1.1  briggs  *    derived from this software without specific prior written permission.
     19   1.1  briggs  *
     20   1.1  briggs  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21   1.1  briggs  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22   1.1  briggs  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23   1.1  briggs  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24   1.1  briggs  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25   1.1  briggs  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26   1.1  briggs  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27   1.1  briggs  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28   1.1  briggs  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29   1.1  briggs  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30   1.1  briggs  */
     31   1.1  briggs /*
     32   1.1  briggs  * Device-specific routines for handling Nubus-based video cards.
     33   1.1  briggs  */
     34   1.1  briggs 
     35   1.1  briggs #include <sys/param.h>
     36   1.1  briggs 
     37   1.1  briggs #include <sys/device.h>
     38   1.1  briggs #include <sys/ioctl.h>
     39   1.1  briggs #include <sys/file.h>
     40   1.1  briggs #include <sys/malloc.h>
     41   1.1  briggs #include <sys/mman.h>
     42   1.1  briggs #include <sys/proc.h>
     43   1.8  briggs #include <sys/systm.h>
     44   1.1  briggs 
     45  1.16  scottr #include <machine/bus.h>
     46   1.8  briggs #include <machine/cpu.h>
     47   1.1  briggs #include <machine/grfioctl.h>
     48   1.8  briggs #include <machine/viareg.h>
     49   1.1  briggs 
     50  1.31  scottr #include <mac68k/dev/nubus.h>
     51  1.31  scottr #include <mac68k/dev/grfvar.h>
     52   1.1  briggs 
     53   1.8  briggs static void	load_image_data __P((caddr_t data, struct image_data *image));
     54   1.1  briggs 
     55  1.28  scottr static void	grfmv_intr_generic_1 __P((void *vsc, int slot));
     56  1.28  scottr static void	grfmv_intr_generic_4 __P((void *vsc, int slot));
     57  1.23  briggs static void	grfmv_intr_radius __P((void *vsc, int slot));
     58  1.18  briggs static void	grfmv_intr_cti __P((void *vsc, int slot));
     59  1.18  briggs static void	grfmv_intr_cb264 __P((void *vsc, int slot));
     60  1.24  briggs static void	grfmv_intr_cb364 __P((void *vsc, int slot));
     61   1.1  briggs 
     62   1.8  briggs static int	grfmv_mode __P((struct grf_softc *gp, int cmd, void *arg));
     63  1.30  scottr static caddr_t	grfmv_phys __P((struct grf_softc *gp));
     64  1.15  scottr static int	grfmv_match __P((struct device *, struct cfdata *, void *));
     65   1.8  briggs static void	grfmv_attach __P((struct device *, struct device *, void *));
     66   1.8  briggs 
     67  1.11  scottr struct cfdriver macvid_cd = {
     68  1.11  scottr 	NULL, "macvid", DV_DULL
     69  1.11  scottr };
     70  1.11  scottr 
     71  1.11  scottr struct cfattach macvid_ca = {
     72  1.11  scottr 	sizeof(struct grfbus_softc), grfmv_match, grfmv_attach
     73   1.8  briggs };
     74   1.8  briggs 
     75   1.1  briggs static void
     76   1.1  briggs load_image_data(data, image)
     77   1.1  briggs 	caddr_t	data;
     78   1.1  briggs 	struct	image_data *image;
     79   1.1  briggs {
     80   1.1  briggs 	bcopy(data     , &image->size,       4);
     81   1.1  briggs 	bcopy(data +  4, &image->offset,     4);
     82   1.1  briggs 	bcopy(data +  8, &image->rowbytes,   2);
     83   1.1  briggs 	bcopy(data + 10, &image->top,        2);
     84   1.1  briggs 	bcopy(data + 12, &image->left,       2);
     85   1.1  briggs 	bcopy(data + 14, &image->bottom,     2);
     86   1.1  briggs 	bcopy(data + 16, &image->right,      2);
     87   1.1  briggs 	bcopy(data + 18, &image->version,    2);
     88   1.1  briggs 	bcopy(data + 20, &image->packType,   2);
     89   1.1  briggs 	bcopy(data + 22, &image->packSize,   4);
     90   1.1  briggs 	bcopy(data + 26, &image->hRes,       4);
     91   1.1  briggs 	bcopy(data + 30, &image->vRes,       4);
     92   1.1  briggs 	bcopy(data + 34, &image->pixelType,  2);
     93   1.1  briggs 	bcopy(data + 36, &image->pixelSize,  2);
     94   1.1  briggs 	bcopy(data + 38, &image->cmpCount,   2);
     95   1.1  briggs 	bcopy(data + 40, &image->cmpSize,    2);
     96   1.1  briggs 	bcopy(data + 42, &image->planeBytes, 4);
     97   1.1  briggs }
     98   1.1  briggs 
     99   1.1  briggs 
    100   1.7  briggs static int
    101  1.15  scottr grfmv_match(parent, cf, aux)
    102  1.11  scottr 	struct device *parent;
    103  1.15  scottr 	struct cfdata *cf;
    104  1.15  scottr 	void *aux;
    105   1.1  briggs {
    106  1.21  scottr 	struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
    107   1.1  briggs 
    108  1.15  scottr 	if (na->category != NUBUS_CATEGORY_DISPLAY)
    109   1.1  briggs 		return 0;
    110   1.1  briggs 
    111  1.15  scottr 	if (na->type != NUBUS_TYPE_VIDEO)
    112   1.1  briggs 		return 0;
    113   1.1  briggs 
    114  1.15  scottr 	if (na->drsw != NUBUS_DRSW_APPLE)
    115   1.1  briggs 		return 0;
    116   1.1  briggs 
    117   1.1  briggs 	/*
    118   1.1  briggs 	 * If we've gotten this far, then we're dealing with a real-live
    119   1.1  briggs 	 * Apple QuickDraw-compatible display card resource.  Now, how to
    120   1.1  briggs 	 * determine that this is an active resource???  Dunno.  But we'll
    121   1.1  briggs 	 * proceed like it is.
    122   1.1  briggs 	 */
    123   1.1  briggs 
    124   1.1  briggs 	return 1;
    125   1.1  briggs }
    126   1.1  briggs 
    127   1.8  briggs static void
    128   1.8  briggs grfmv_attach(parent, self, aux)
    129   1.8  briggs 	struct device *parent, *self;
    130   1.8  briggs 	void *aux;
    131   1.1  briggs {
    132  1.21  scottr 	struct grfbus_softc *sc = (struct grfbus_softc *)self;
    133  1.21  scottr 	struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
    134   1.1  briggs 	struct image_data image_store, image;
    135  1.15  scottr 	struct grfmode *gm;
    136  1.15  scottr 	char cardname[CARD_NAME_LEN];
    137  1.15  scottr 	nubus_dirent dirent;
    138  1.15  scottr 	nubus_dir dir, mode_dir;
    139  1.15  scottr 	int mode;
    140  1.15  scottr 
    141  1.25  scottr 	sc->sc_tag = na->na_tag;
    142  1.15  scottr 	sc->card_id = na->drhw;
    143  1.15  scottr 
    144  1.15  scottr 	bcopy(na->fmt, &sc->sc_slot, sizeof(nubus_slot));
    145  1.15  scottr 
    146  1.25  scottr 	if (bus_space_map(sc->sc_tag,
    147  1.25  scottr 	    NUBUS_SLOT2PA(na->slot), NBMEMSIZE, 0, &sc->sc_handle)) {
    148  1.25  scottr 		printf(": grfmv_attach: failed to map slot %d\n", na->slot);
    149  1.25  scottr 		return;
    150  1.25  scottr 	}
    151  1.25  scottr 
    152  1.15  scottr 	nubus_get_main_dir(&sc->sc_slot, &dir);
    153   1.1  briggs 
    154  1.25  scottr 	if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
    155  1.25  scottr 	    &sc->sc_slot, &dir, na->rsrcid, &dirent) <= 0) {
    156  1.25  scottr bad:
    157  1.25  scottr 		bus_space_unmap(sc->sc_tag, sc->sc_handle, NBMEMSIZE);
    158  1.15  scottr 		return;
    159  1.25  scottr 	}
    160  1.15  scottr 
    161  1.15  scottr 	nubus_get_dir_from_rsrc(&sc->sc_slot, &dirent, &sc->board_dir);
    162  1.15  scottr 
    163  1.25  scottr 	if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
    164  1.25  scottr 	    &sc->sc_slot, &sc->board_dir, NUBUS_RSRC_TYPE, &dirent) <= 0)
    165  1.15  scottr 		if ((na->rsrcid != 128) ||
    166  1.25  scottr 		    (nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
    167  1.25  scottr 		    &sc->sc_slot, &dir, 129, &dirent) <= 0))
    168  1.25  scottr 			goto bad;
    169   1.8  briggs 
    170   1.1  briggs 	mode = NUBUS_RSRC_FIRSTMODE;
    171  1.25  scottr 	if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
    172  1.25  scottr 	    &sc->sc_slot, &sc->board_dir, mode, &dirent) <= 0) {
    173  1.25  scottr 		printf(": probe failed to get board rsrc.\n");
    174  1.25  scottr 		goto bad;
    175   1.8  briggs 	}
    176   1.1  briggs 
    177   1.1  briggs 	nubus_get_dir_from_rsrc(&sc->sc_slot, &dirent, &mode_dir);
    178   1.1  briggs 
    179  1.25  scottr 	if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
    180  1.25  scottr 	    &sc->sc_slot, &mode_dir, VID_PARAMS, &dirent) <= 0) {
    181  1.25  scottr 		printf(": probe failed to get mode dir.\n");
    182  1.25  scottr 		goto bad;
    183   1.8  briggs 	}
    184   1.1  briggs 
    185  1.25  scottr 	if (nubus_get_ind_data(sc->sc_tag, sc->sc_handle, &sc->sc_slot,
    186  1.25  scottr 	    &dirent, (caddr_t)&image_store, sizeof(struct image_data)) <= 0) {
    187  1.25  scottr 		printf(": probe failed to get indirect mode data.\n");
    188  1.25  scottr 		goto bad;
    189   1.8  briggs 	}
    190   1.1  briggs 
    191  1.15  scottr 	/* Need to load display info (and driver?), etc... (?) */
    192  1.15  scottr 
    193  1.21  scottr 	load_image_data((caddr_t)&image_store, &image);
    194   1.1  briggs 
    195  1.15  scottr 	gm = &sc->curr_mode;
    196  1.11  scottr 	gm->mode_id = mode;
    197  1.29  scottr 	gm->fbbase = (caddr_t)sc->sc_handle; /* XXX evil! */
    198  1.11  scottr 	gm->fboff = image.offset;
    199  1.11  scottr 	gm->rowbytes = image.rowbytes;
    200  1.11  scottr 	gm->width = image.right - image.left;
    201  1.11  scottr 	gm->height = image.bottom - image.top;
    202  1.28  scottr 	gm->fbsize = gm->height * gm->rowbytes;
    203  1.11  scottr 	gm->hres = image.hRes;
    204  1.11  scottr 	gm->vres = image.vRes;
    205  1.11  scottr 	gm->ptype = image.pixelType;
    206  1.11  scottr 	gm->psize = image.pixelSize;
    207   1.1  briggs 
    208  1.25  scottr 	strncpy(cardname, nubus_get_card_name(sc->sc_tag, sc->sc_handle,
    209  1.25  scottr 	    &sc->sc_slot), CARD_NAME_LEN);
    210  1.11  scottr 	cardname[CARD_NAME_LEN-1] = '\0';
    211  1.21  scottr 	printf(": %s\n", cardname);
    212   1.1  briggs 
    213  1.18  briggs 	if (sc->card_id == NUBUS_DRHW_TFB) {
    214  1.18  briggs 		/*
    215  1.18  briggs 		 * This is the Toby card, but apparently some manufacturers
    216  1.18  briggs 		 * (like Cornerstone) didn't bother to get/use their own
    217  1.18  briggs 		 * value here, even though the cards are different, so we
    218  1.18  briggs 		 * so we try to differentiate here.
    219  1.18  briggs 		 */
    220  1.21  scottr 		if (strncmp(cardname, "Samsung 768", 11) == 0)
    221  1.18  briggs 			sc->card_id = NUBUS_DRHW_SAM768;
    222  1.21  scottr 		else if (strncmp(cardname, "Toby frame", 10) != 0)
    223  1.25  scottr 			printf("%s: This display card pretends to be a TFB!\n",
    224  1.21  scottr 			    sc->sc_dev.dv_xname);
    225  1.18  briggs 	}
    226  1.18  briggs 
    227  1.18  briggs 	switch (sc->card_id) {
    228  1.28  scottr 	case NUBUS_DRHW_TFB:
    229  1.18  briggs 	case NUBUS_DRHW_M2HRVC:
    230  1.27  scottr 	case NUBUS_DRHW_PVC:
    231  1.18  briggs 		sc->cli_offset = 0xa0000;
    232  1.22  briggs 		sc->cli_value = 0;
    233  1.28  scottr 		add_nubus_intr(na->slot, grfmv_intr_generic_1, sc);
    234  1.18  briggs 		break;
    235  1.18  briggs 	case NUBUS_DRHW_WVC:
    236  1.18  briggs 		sc->cli_offset = 0xa00000;
    237  1.22  briggs 		sc->cli_value = 0;
    238  1.28  scottr 		add_nubus_intr(na->slot, grfmv_intr_generic_1, sc);
    239  1.28  scottr 		break;
    240  1.28  scottr 	case NUBUS_DRHW_SE30:
    241  1.28  scottr 		/* Do nothing--SE/30 interrupts are disabled */
    242  1.28  scottr 		break;
    243  1.28  scottr 	case NUBUS_DRHW_MDC:
    244  1.28  scottr 		sc->cli_offset = 0x200148;
    245  1.28  scottr 		sc->cli_value = 1;
    246  1.28  scottr 		add_nubus_intr(na->slot, grfmv_intr_generic_4, sc);
    247  1.28  scottr 
    248  1.28  scottr 		/* Enable interrupts; to disable, write 0x7 to this location */
    249  1.28  scottr 		bus_space_write_4(sc->sc_tag, sc->sc_handle, 0x20013C, 5);
    250  1.28  scottr 		break;
    251  1.28  scottr 	case NUBUS_DRHW_CB264:
    252  1.28  scottr 		add_nubus_intr(na->slot, grfmv_intr_cb264, sc);
    253  1.28  scottr 		break;
    254  1.28  scottr 	case NUBUS_DRHW_CB364:
    255  1.28  scottr 		add_nubus_intr(na->slot, grfmv_intr_cb364, sc);
    256  1.22  briggs 		break;
    257  1.23  briggs 	case NUBUS_DRHW_RPC8XJ:
    258  1.25  scottr 		add_nubus_intr(na->slot, grfmv_intr_radius, sc);
    259  1.23  briggs 		break;
    260  1.22  briggs 	case NUBUS_DRHW_FIILX:
    261  1.22  briggs 	case NUBUS_DRHW_FIISXDSP:
    262  1.26  scottr 		sc->cli_offset = 0xf05000;
    263  1.22  briggs 		sc->cli_value = 0x80;
    264  1.28  scottr 		add_nubus_intr(na->slot, grfmv_intr_generic_1, sc);
    265  1.18  briggs 		break;
    266  1.18  briggs 	case NUBUS_DRHW_SAM768:
    267  1.25  scottr 		add_nubus_intr(na->slot, grfmv_intr_cti, sc);
    268  1.19  briggs 		break;
    269  1.18  briggs 	case NUBUS_DRHW_MICRON:
    270  1.18  briggs 		/* What do we know about this one? */
    271  1.18  briggs 	default:
    272  1.21  scottr 		printf("%s: Unknown video card ID 0x%x --",
    273  1.21  scottr 		    sc->sc_dev.dv_xname, sc->card_id);
    274  1.21  scottr 		printf(" Not installing interrupt routine.\n");
    275  1.18  briggs 		break;
    276  1.18  briggs 	}
    277   1.1  briggs 
    278  1.11  scottr 	/* Perform common video attachment. */
    279  1.12  scottr 	grf_establish(sc, &sc->sc_slot, grfmv_mode, grfmv_phys);
    280   1.1  briggs }
    281   1.1  briggs 
    282   1.8  briggs static int
    283   1.1  briggs grfmv_mode(gp, cmd, arg)
    284   1.1  briggs 	struct grf_softc *gp;
    285   1.1  briggs 	int cmd;
    286   1.1  briggs 	void *arg;
    287   1.1  briggs {
    288   1.1  briggs 	switch (cmd) {
    289   1.4  briggs 	case GM_GRFON:
    290   1.4  briggs 	case GM_GRFOFF:
    291   1.4  briggs 		return 0;
    292   1.1  briggs 	case GM_CURRMODE:
    293   1.1  briggs 		break;
    294   1.1  briggs 	case GM_NEWMODE:
    295   1.1  briggs 		break;
    296   1.1  briggs 	case GM_LISTMODES:
    297   1.1  briggs 		break;
    298   1.1  briggs 	}
    299   1.1  briggs 	return EINVAL;
    300   1.6  briggs }
    301   1.6  briggs 
    302   1.8  briggs static caddr_t
    303  1.29  scottr grfmv_phys(gp)
    304   1.6  briggs 	struct grf_softc *gp;
    305   1.6  briggs {
    306  1.29  scottr 	return (caddr_t)NUBUS_SLOT2PA(gp->sc_slot->slot);
    307  1.18  briggs }
    308  1.18  briggs 
    309  1.18  briggs /* Interrupt handlers... */
    310  1.18  briggs /*
    311  1.18  briggs  * Generic routine to clear interrupts for cards where it simply takes
    312  1.28  scottr  * a MOV.B to clear the interrupt.  The offset and value of this byte
    313  1.28  scottr  * varies between cards.
    314  1.18  briggs  */
    315  1.18  briggs /*ARGSUSED*/
    316  1.18  briggs static void
    317  1.28  scottr grfmv_intr_generic_1(vsc, slot)
    318  1.18  briggs 	void	*vsc;
    319  1.18  briggs 	int	slot;
    320  1.18  briggs {
    321  1.26  scottr 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    322  1.26  scottr 
    323  1.26  scottr 	bus_space_write_1(sc->sc_tag, sc->sc_handle,
    324  1.28  scottr 	    sc->cli_offset, (u_int8_t)sc->cli_value);
    325  1.28  scottr }
    326  1.28  scottr 
    327  1.28  scottr /*
    328  1.28  scottr  * Generic routine to clear interrupts for cards where it simply takes
    329  1.28  scottr  * a MOV.L to clear the interrupt.  The offset and value of this byte
    330  1.28  scottr  * varies between cards.
    331  1.28  scottr  */
    332  1.28  scottr /*ARGSUSED*/
    333  1.28  scottr static void
    334  1.28  scottr grfmv_intr_generic_4(vsc, slot)
    335  1.28  scottr 	void	*vsc;
    336  1.28  scottr 	int	slot;
    337  1.28  scottr {
    338  1.28  scottr 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    339  1.28  scottr 
    340  1.28  scottr 	bus_space_write_4(sc->sc_tag, sc->sc_handle,
    341  1.26  scottr 	    sc->cli_offset, sc->cli_value);
    342  1.23  briggs }
    343  1.23  briggs 
    344  1.23  briggs /*
    345  1.26  scottr  * Routine to clear interrupts for the Radius PrecisionColor 8xj card.
    346  1.23  briggs  */
    347  1.23  briggs /*ARGSUSED*/
    348  1.23  briggs static void
    349  1.23  briggs grfmv_intr_radius(vsc, slot)
    350  1.23  briggs 	void	*vsc;
    351  1.23  briggs 	int	slot;
    352  1.23  briggs {
    353  1.26  scottr 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    354  1.26  scottr 	u_int8_t c;
    355  1.23  briggs 
    356  1.23  briggs 	/*
    357  1.23  briggs 	 * The value 0x66 was the observed value on one	card.  It is read
    358  1.23  briggs 	 * from the driver's information block, so this may not be sufficient.
    359  1.23  briggs 	 * Then again, we're not setting up any other interrupts...
    360  1.23  briggs 	 */
    361  1.23  briggs 	c = 0x66;
    362  1.23  briggs 
    363  1.23  briggs 	c |= 0x80;
    364  1.26  scottr 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xd00403, c);
    365  1.26  scottr 	c &= 0x7f;
    366  1.26  scottr 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xd00403, c);
    367  1.18  briggs }
    368  1.18  briggs 
    369  1.18  briggs /*
    370  1.18  briggs  * Routine to clear interrupts on Samsung 768x1006 video controller.
    371  1.18  briggs  * This controller was manufactured by Cornerstone Technology, Inc.,
    372  1.18  briggs  * now known as Cornerstone Imaging.
    373  1.18  briggs  *
    374  1.18  briggs  * To clear this interrupt, we apparently have to set, then clear,
    375  1.18  briggs  * bit 2 at byte offset 0x80000 from the card's base.
    376  1.18  briggs  *	Information for this provided by Brad Salai <bsalai (at) servtech.com>
    377  1.18  briggs  */
    378  1.18  briggs /*ARGSUSED*/
    379  1.18  briggs static void
    380  1.18  briggs grfmv_intr_cti(vsc, slot)
    381  1.18  briggs 	void	*vsc;
    382  1.18  briggs 	int	slot;
    383  1.18  briggs {
    384  1.26  scottr 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    385  1.26  scottr 	u_int8_t c;
    386  1.18  briggs 
    387  1.26  scottr 	c = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0x80000);
    388  1.26  scottr 	c |= 0x02;
    389  1.26  scottr 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x80000, c);
    390  1.26  scottr 	c &= 0xfd;
    391  1.26  scottr 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x80000, c);
    392  1.18  briggs }
    393  1.18  briggs 
    394  1.18  briggs /*ARGSUSED*/
    395  1.18  briggs static void
    396  1.18  briggs grfmv_intr_cb264(vsc, slot)
    397  1.18  briggs 	void	*vsc;
    398  1.18  briggs 	int	slot;
    399  1.18  briggs {
    400  1.18  briggs 	struct grfbus_softc *sc;
    401  1.21  scottr 	volatile char *slotbase;
    402  1.18  briggs 
    403  1.21  scottr 	sc = (struct grfbus_softc *)vsc;
    404  1.25  scottr 	slotbase = (volatile char *)sc->sc_handle;	/* XXX evil hack */
    405  1.18  briggs 	asm volatile("	movl	%0,a0
    406  1.18  briggs 			movl	a0@(0xff6028),d0
    407  1.18  briggs 			andl	#0x2,d0
    408  1.18  briggs 			beq	_mv_intr0
    409  1.18  briggs 			movql	#0x3,d0
    410  1.18  briggs 		_mv_intr0:
    411  1.18  briggs 			movl	a0@(0xff600c),d1
    412  1.18  briggs 			andl	#0x3,d1
    413  1.18  briggs 			cmpl	d1,d0
    414  1.18  briggs 			beq	_mv_intr_fin
    415  1.18  briggs 			movl	d0,a0@(0xff600c)
    416  1.18  briggs 			nop
    417  1.18  briggs 			tstb	d0
    418  1.18  briggs 			beq	_mv_intr1
    419  1.18  briggs 			movl	#0x0002,a0@(0xff6040)
    420  1.18  briggs 			movl	#0x0102,a0@(0xff6044)
    421  1.18  briggs 			movl	#0x0105,a0@(0xff6048)
    422  1.18  briggs 			movl	#0x000e,a0@(0xff604c)
    423  1.18  briggs 			movl	#0x001c,a0@(0xff6050)
    424  1.18  briggs 			movl	#0x00bc,a0@(0xff6054)
    425  1.18  briggs 			movl	#0x00c3,a0@(0xff6058)
    426  1.18  briggs 			movl	#0x0061,a0@(0xff605c)
    427  1.18  briggs 			movl	#0x0012,a0@(0xff6060)
    428  1.18  briggs 			bra	_mv_intr_fin
    429  1.18  briggs 		_mv_intr1:
    430  1.18  briggs 			movl	#0x0002,a0@(0xff6040)
    431  1.18  briggs 			movl	#0x0209,a0@(0xff6044)
    432  1.18  briggs 			movl	#0x020c,a0@(0xff6048)
    433  1.18  briggs 			movl	#0x000f,a0@(0xff604c)
    434  1.18  briggs 			movl	#0x0027,a0@(0xff6050)
    435  1.18  briggs 			movl	#0x00c7,a0@(0xff6054)
    436  1.18  briggs 			movl	#0x00d7,a0@(0xff6058)
    437  1.18  briggs 			movl	#0x006b,a0@(0xff605c)
    438  1.18  briggs 			movl	#0x0029,a0@(0xff6060)
    439  1.18  briggs 		_mv_intr_fin:
    440  1.18  briggs 			movl	#0x1,a0@(0xff6014)"
    441  1.18  briggs 		: : "g" (slotbase) : "a0","d0","d1");
    442  1.24  briggs }
    443  1.24  briggs 
    444  1.24  briggs /*
    445  1.24  briggs  * Support for the Colorboard 364 might be more complex than it needs to
    446  1.24  briggs  * be.  If we can find more information about this card, this might be
    447  1.24  briggs  * significantly simplified.  Contributions welcome...  :-)
    448  1.24  briggs  */
    449  1.24  briggs /*ARGSUSED*/
    450  1.24  briggs static void
    451  1.24  briggs grfmv_intr_cb364(vsc, slot)
    452  1.24  briggs 	void	*vsc;
    453  1.24  briggs 	int	slot;
    454  1.24  briggs {
    455  1.24  briggs 	struct grfbus_softc *sc;
    456  1.24  briggs 	volatile char *slotbase;
    457  1.24  briggs 
    458  1.24  briggs 	sc = (struct grfbus_softc *)vsc;
    459  1.25  scottr 	slotbase = (volatile char *)sc->sc_handle;	/* XXX evil hack */
    460  1.24  briggs 	asm volatile("	movl	%0,a0
    461  1.24  briggs 			movl	a0@(0xfe6028),d0
    462  1.24  briggs 			andl	#0x2,d0
    463  1.24  briggs 			beq	_cb364_intr4
    464  1.24  briggs 			movql	#0x3,d0
    465  1.24  briggs 			movl	a0@(0xfe6018),d1
    466  1.24  briggs 			movl	#0x3,a0@(0xfe6018)
    467  1.24  briggs 			movw	a0@(0xfe7010),d2
    468  1.24  briggs 			movl	d1,a0@(0xfe6018)
    469  1.24  briggs 			movl	a0@(0xfe6020),d1
    470  1.24  briggs 			btst	#0x06,d2
    471  1.24  briggs 			beq	_cb364_intr0
    472  1.24  briggs 			btst	#0x00,d1
    473  1.24  briggs 			beq	_cb364_intr5
    474  1.24  briggs 			bsr	_cb364_intr1
    475  1.24  briggs 			bra	_cb364_intr_out
    476  1.24  briggs 		_cb364_intr0:
    477  1.24  briggs 			btst	#0x00,d1
    478  1.24  briggs 			bne	_cb364_intr5
    479  1.24  briggs 			bsr	_cb364_intr1
    480  1.24  briggs 			bra	_cb364_intr_out
    481  1.24  briggs 		_cb364_intr1:
    482  1.24  briggs 			movl	d0,a0@(0xfe600c)
    483  1.24  briggs 			nop
    484  1.24  briggs 			tstb	d0
    485  1.24  briggs 			beq	_cb364_intr3
    486  1.24  briggs 			movl	#0x0002,a0@(0xfe6040)
    487  1.24  briggs 			movl	#0x0105,a0@(0xfe6048)
    488  1.24  briggs 			movl	#0x000e,a0@(0xfe604c)
    489  1.24  briggs 			movl	#0x00c3,a0@(0xfe6058)
    490  1.24  briggs 			movl	#0x0061,a0@(0xfe605c)
    491  1.24  briggs 			btst	#0x06,d2
    492  1.24  briggs 			beq	_cb364_intr2
    493  1.24  briggs 			movl	#0x001c,a0@(0xfe6050)
    494  1.24  briggs 			movl	#0x00bc,a0@(0xfe6054)
    495  1.24  briggs 			movl	#0x0012,a0@(0xfe6060)
    496  1.24  briggs 			movl	#0x000e,a0@(0xfe6044)
    497  1.24  briggs 			movl	#0x00c3,a0@(0xfe6064)
    498  1.24  briggs 			movl	#0x0061,a0@(0xfe6020)
    499  1.24  briggs 			rts
    500  1.24  briggs 		_cb364_intr2:
    501  1.24  briggs 			movl	#0x0016,a0@(0xfe6050)
    502  1.24  briggs 			movl	#0x00b6,a0@(0xfe6054)
    503  1.24  briggs 			movl	#0x0011,a0@(0xfe6060)
    504  1.24  briggs 			movl	#0x0101,a0@(0xfe6044)
    505  1.24  briggs 			movl	#0x00bf,a0@(0xfe6064)
    506  1.24  briggs 			movl	#0x0001,a0@(0xfe6020)
    507  1.24  briggs 			rts
    508  1.24  briggs 		_cb364_intr3:
    509  1.24  briggs 			movl	#0x0002,a0@(0xfe6040)
    510  1.24  briggs 			movl	#0x0209,a0@(0xfe6044)
    511  1.24  briggs 			movl	#0x020c,a0@(0xfe6048)
    512  1.24  briggs 			movl	#0x000f,a0@(0xfe604c)
    513  1.24  briggs 			movl	#0x0027,a0@(0xfe6050)
    514  1.24  briggs 			movl	#0x00c7,a0@(0xfe6054)
    515  1.24  briggs 			movl	#0x00d7,a0@(0xfe6058)
    516  1.24  briggs 			movl	#0x006b,a0@(0xfe605c)
    517  1.24  briggs 			movl	#0x0029,a0@(0xfe6060)
    518  1.24  briggs 			oril	#0x0040,a0@(0xfe6064)
    519  1.24  briggs 			movl	#0x0000,a0@(0xfe6020)
    520  1.24  briggs 			rts
    521  1.24  briggs 		_cb364_intr4:
    522  1.24  briggs 			movq	#0x00,d0
    523  1.24  briggs 		_cb364_intr5:
    524  1.24  briggs 			movl	a0@(0xfe600c),d1
    525  1.24  briggs 			andl	#0x3,d1
    526  1.24  briggs 			cmpl	d1,d0
    527  1.24  briggs 			beq	_cb364_intr_out
    528  1.24  briggs 			bsr	_cb364_intr1
    529  1.24  briggs 		_cb364_intr_out:
    530  1.24  briggs 			movl	#0x1,a0@(0xfe6014)
    531  1.24  briggs 		_cb364_intr_quit:
    532  1.24  briggs 		" : : "g" (slotbase) : "a0","d0","d1","d2");
    533   1.1  briggs }
    534