Home | History | Annotate | Line # | Download | only in nubus
grf_nubus.c revision 1.52.8.2
      1 /*	$NetBSD: grf_nubus.c,v 1.52.8.2 2000/12/14 00:19:36 he Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1995 Allen Briggs.  All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  * 3. All advertising materials mentioning features or use of this software
     15  *    must display the following acknowledgement:
     16  *	This product includes software developed by Allen Briggs.
     17  * 4. The name of the author may not be used to endorse or promote products
     18  *    derived from this software without specific prior written permission.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 /*
     32  * Device-specific routines for handling Nubus-based video cards.
     33  */
     34 
     35 #include "opt_grf.h"
     36 
     37 #include <sys/param.h>
     38 
     39 #include <sys/device.h>
     40 #include <sys/ioctl.h>
     41 #include <sys/file.h>
     42 #include <sys/malloc.h>
     43 #include <sys/mman.h>
     44 #include <sys/proc.h>
     45 #include <sys/systm.h>
     46 
     47 #include <machine/bus.h>
     48 #include <machine/cpu.h>
     49 #include <machine/grfioctl.h>
     50 #include <machine/viareg.h>
     51 
     52 #include <mac68k/nubus/nubus.h>
     53 #include <mac68k/dev/grfvar.h>
     54 
     55 static void	load_image_data __P((caddr_t data, struct image_data *image));
     56 
     57 static void	grfmv_intr_generic_write1 __P((void *vsc));
     58 static void	grfmv_intr_generic_write4 __P((void *vsc));
     59 static void	grfmv_intr_generic_or4 __P((void *vsc));
     60 
     61 static void	grfmv_intr_cb264 __P((void *vsc));
     62 static void	grfmv_intr_cb364 __P((void *vsc));
     63 static void	grfmv_intr_cmax __P((void *vsc));
     64 static void	grfmv_intr_cti __P((void *vsc));
     65 static void	grfmv_intr_radius __P((void *vsc));
     66 static void	grfmv_intr_radius24 __P((void *vsc));
     67 static void	grfmv_intr_supermacgfx __P((void *vsc));
     68 static void	grfmv_intr_lapis __P((void *vsc));
     69 static void	grfmv_intr_formac __P((void *vsc));
     70 static void	grfmv_intr_vimage __P((void *vsc));
     71 static void	grfmv_intr_gvimage __P((void *vsc));
     72 
     73 static int	grfmv_mode __P((struct grf_softc *gp, int cmd, void *arg));
     74 static int	grfmv_match __P((struct device *, struct cfdata *, void *));
     75 static void	grfmv_attach __P((struct device *, struct device *, void *));
     76 
     77 struct cfattach macvid_ca = {
     78 	sizeof(struct grfbus_softc), grfmv_match, grfmv_attach
     79 };
     80 
     81 static void
     82 load_image_data(data, image)
     83 	caddr_t	data;
     84 	struct	image_data *image;
     85 {
     86 	bcopy(data     , &image->size,       4);
     87 	bcopy(data +  4, &image->offset,     4);
     88 	bcopy(data +  8, &image->rowbytes,   2);
     89 	bcopy(data + 10, &image->top,        2);
     90 	bcopy(data + 12, &image->left,       2);
     91 	bcopy(data + 14, &image->bottom,     2);
     92 	bcopy(data + 16, &image->right,      2);
     93 	bcopy(data + 18, &image->version,    2);
     94 	bcopy(data + 20, &image->packType,   2);
     95 	bcopy(data + 22, &image->packSize,   4);
     96 	bcopy(data + 26, &image->hRes,       4);
     97 	bcopy(data + 30, &image->vRes,       4);
     98 	bcopy(data + 34, &image->pixelType,  2);
     99 	bcopy(data + 36, &image->pixelSize,  2);
    100 	bcopy(data + 38, &image->cmpCount,   2);
    101 	bcopy(data + 40, &image->cmpSize,    2);
    102 	bcopy(data + 42, &image->planeBytes, 4);
    103 }
    104 
    105 
    106 static int
    107 grfmv_match(parent, cf, aux)
    108 	struct device *parent;
    109 	struct cfdata *cf;
    110 	void *aux;
    111 {
    112 	struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
    113 
    114 	if (na->category != NUBUS_CATEGORY_DISPLAY)
    115 		return 0;
    116 
    117 	if (na->type != NUBUS_TYPE_VIDEO)
    118 		return 0;
    119 
    120 	if (na->drsw != NUBUS_DRSW_APPLE)
    121 		return 0;
    122 
    123 	/*
    124 	 * If we've gotten this far, then we're dealing with a real-live
    125 	 * Apple QuickDraw-compatible display card resource.  Now, how to
    126 	 * determine that this is an active resource???  Dunno.  But we'll
    127 	 * proceed like it is.
    128 	 */
    129 
    130 	return 1;
    131 }
    132 
    133 static void
    134 grfmv_attach(parent, self, aux)
    135 	struct device *parent, *self;
    136 	void *aux;
    137 {
    138 	struct grfbus_softc *sc = (struct grfbus_softc *)self;
    139 	struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
    140 	struct image_data image_store, image;
    141 	struct grfmode *gm;
    142 	char cardname[CARD_NAME_LEN];
    143 	nubus_dirent dirent;
    144 	nubus_dir dir, mode_dir;
    145 	int mode;
    146 
    147 	bcopy(na->fmt, &sc->sc_slot, sizeof(nubus_slot));
    148 
    149 	sc->sc_tag = na->na_tag;
    150 	sc->card_id = na->drhw;
    151 	sc->sc_basepa = (bus_addr_t)NUBUS_SLOT2PA(na->slot);
    152 	sc->sc_fbofs = 0;
    153 
    154 	if (bus_space_map(sc->sc_tag, sc->sc_basepa, NBMEMSIZE,
    155 	    0, &sc->sc_handle)) {
    156 		printf(": grfmv_attach: failed to map slot %d\n", na->slot);
    157 		return;
    158 	}
    159 
    160 	nubus_get_main_dir(&sc->sc_slot, &dir);
    161 
    162 	if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
    163 	    &sc->sc_slot, &dir, na->rsrcid, &dirent) <= 0) {
    164 bad:
    165 		bus_space_unmap(sc->sc_tag, sc->sc_handle, NBMEMSIZE);
    166 		return;
    167 	}
    168 
    169 	nubus_get_dir_from_rsrc(&sc->sc_slot, &dirent, &sc->board_dir);
    170 
    171 	if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
    172 	    &sc->sc_slot, &sc->board_dir, NUBUS_RSRC_TYPE, &dirent) <= 0)
    173 		if ((na->rsrcid != 128) ||
    174 		    (nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
    175 		    &sc->sc_slot, &dir, 129, &dirent) <= 0))
    176 			goto bad;
    177 
    178 	mode = NUBUS_RSRC_FIRSTMODE;
    179 	if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
    180 	    &sc->sc_slot, &sc->board_dir, mode, &dirent) <= 0) {
    181 		printf(": probe failed to get board rsrc.\n");
    182 		goto bad;
    183 	}
    184 
    185 	nubus_get_dir_from_rsrc(&sc->sc_slot, &dirent, &mode_dir);
    186 
    187 	if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
    188 	    &sc->sc_slot, &mode_dir, VID_PARAMS, &dirent) <= 0) {
    189 		printf(": probe failed to get mode dir.\n");
    190 		goto bad;
    191 	}
    192 
    193 	if (nubus_get_ind_data(sc->sc_tag, sc->sc_handle, &sc->sc_slot,
    194 	    &dirent, (caddr_t)&image_store, sizeof(struct image_data)) <= 0) {
    195 		printf(": probe failed to get indirect mode data.\n");
    196 		goto bad;
    197 	}
    198 
    199 	/* Need to load display info (and driver?), etc... (?) */
    200 
    201 	load_image_data((caddr_t)&image_store, &image);
    202 
    203 	gm = &sc->curr_mode;
    204 	gm->mode_id = mode;
    205 	gm->ptype = image.pixelType;
    206 	gm->psize = image.pixelSize;
    207 	gm->width = image.right - image.left;
    208 	gm->height = image.bottom - image.top;
    209 	gm->rowbytes = image.rowbytes;
    210 	gm->hres = image.hRes;
    211 	gm->vres = image.vRes;
    212 	gm->fbsize = gm->height * gm->rowbytes;
    213 	gm->fbbase = (caddr_t)sc->sc_handle;	/* XXX evil hack */
    214 	gm->fboff = image.offset;
    215 
    216 	strncpy(cardname, nubus_get_card_name(sc->sc_tag, sc->sc_handle,
    217 	    &sc->sc_slot), CARD_NAME_LEN);
    218 	cardname[CARD_NAME_LEN-1] = '\0';
    219 	printf(": %s\n", cardname);
    220 
    221 	if (sc->card_id == NUBUS_DRHW_TFB) {
    222 		/*
    223 		 * This is the Toby card, but apparently some manufacturers
    224 		 * (like Cornerstone) didn't bother to get/use their own
    225 		 * value here, even though the cards are different, so we
    226 		 * so we try to differentiate here.
    227 		 */
    228 		if (strncmp(cardname, "Samsung 768", 11) == 0)
    229 			sc->card_id = NUBUS_DRHW_SAM768;
    230 		else if (strncmp(cardname, "Toby frame", 10) != 0)
    231 			printf("%s: This display card pretends to be a TFB!\n",
    232 			    sc->sc_dev.dv_xname);
    233 	}
    234 
    235 	switch (sc->card_id) {
    236 	case NUBUS_DRHW_TFB:
    237 	case NUBUS_DRHW_M2HRVC:
    238 	case NUBUS_DRHW_PVC:
    239 		sc->cli_offset = 0xa0000;
    240 		sc->cli_value = 0;
    241 		add_nubus_intr(na->slot, grfmv_intr_generic_write1, sc);
    242 		break;
    243 	case NUBUS_DRHW_WVC:
    244 		sc->cli_offset = 0xa00000;
    245 		sc->cli_value = 0;
    246 		add_nubus_intr(na->slot, grfmv_intr_generic_write1, sc);
    247 		break;
    248 	case NUBUS_DRHW_COLORMAX:
    249 		add_nubus_intr(na->slot, grfmv_intr_cmax, sc);
    250 		break;
    251 	case NUBUS_DRHW_SE30:
    252 		/* Do nothing--SE/30 interrupts are disabled */
    253 		break;
    254 	case NUBUS_DRHW_MDC:
    255 		sc->cli_offset = 0x200148;
    256 		sc->cli_value = 1;
    257 		add_nubus_intr(na->slot, grfmv_intr_generic_write4, sc);
    258 
    259 		/* Enable interrupts; to disable, write 0x7 to this location */
    260 		bus_space_write_4(sc->sc_tag, sc->sc_handle, 0x20013C, 5);
    261 		break;
    262 	case NUBUS_DRHW_CB264:
    263 		add_nubus_intr(na->slot, grfmv_intr_cb264, sc);
    264 		break;
    265 	case NUBUS_DRHW_CB364:
    266 		add_nubus_intr(na->slot, grfmv_intr_cb364, sc);
    267 		break;
    268 	case NUBUS_DRHW_RPC8:
    269 		sc->cli_offset = 0xfdff8f;
    270 		sc->cli_value = 0xff;
    271 		add_nubus_intr(na->slot, grfmv_intr_generic_write1, sc);
    272 		break;
    273 	case NUBUS_DRHW_RPC8XJ:
    274 		sc->cli_value = 0x66;
    275 		add_nubus_intr(na->slot, grfmv_intr_radius, sc);
    276 		break;
    277 	case NUBUS_DRHW_RPC24X:
    278 	case NUBUS_DRHW_BOOGIE:
    279 		sc->cli_value = 0x64;
    280 		add_nubus_intr(na->slot, grfmv_intr_radius, sc);
    281 		break;
    282 	case NUBUS_DRHW_RPC24XP:
    283 		add_nubus_intr(na->slot, grfmv_intr_radius24, sc);
    284 		break;
    285 	case NUBUS_DRHW_FIILX:
    286 	case NUBUS_DRHW_FIISXDSP:
    287 	case NUBUS_DRHW_FUTURASX:
    288 		sc->cli_offset = 0xf05000;
    289 		sc->cli_value = 0x80;
    290 		add_nubus_intr(na->slot, grfmv_intr_generic_write1, sc);
    291 		break;
    292 	case NUBUS_DRHW_SAM768:
    293 		add_nubus_intr(na->slot, grfmv_intr_cti, sc);
    294 		break;
    295 	case NUBUS_DRHW_SUPRGFX:
    296 		add_nubus_intr(na->slot, grfmv_intr_supermacgfx, sc);
    297 		break;
    298 	case NUBUS_DRHW_SPECTRM8:
    299 		sc->cli_offset = 0x0de178;
    300 		sc->cli_value = 0x80;
    301 		add_nubus_intr(na->slot, grfmv_intr_generic_or4, sc);
    302 		break;
    303 	case NUBUS_DRHW_LAPIS:
    304 		add_nubus_intr(na->slot, grfmv_intr_lapis, sc);
    305 		break;
    306 	case NUBUS_DRHW_FORMAC:
    307 		add_nubus_intr(na->slot, grfmv_intr_formac, sc);
    308 		break;
    309 	case NUBUS_DRHW_ROPS24LXI:
    310 	case NUBUS_DRHW_ROPS24XLTV:
    311 		sc->cli_offset = 0xfb0010;
    312 		sc->cli_value = 0x00;
    313 		add_nubus_intr(na->slot, grfmv_intr_generic_write4, sc);
    314 		break;
    315 	case NUBUS_DRHW_VIMAGE:
    316 		add_nubus_intr(na->slot, grfmv_intr_vimage, sc);
    317 		break;
    318 	case NUBUS_DRHW_GVIMAGE:
    319 		add_nubus_intr(na->slot, grfmv_intr_gvimage, sc);
    320 		break;
    321 	case NUBUS_DRHW_MC2124NB:
    322 		sc->cli_offset = 0xfd1000;
    323 		sc->cli_value = 0x00;
    324 		add_nubus_intr(na->slot, grfmv_intr_generic_write4, sc);
    325 		break;
    326 	case NUBUS_DRHW_MICRON:
    327 		/* What do we know about this one? */
    328 	default:
    329 		printf("%s: Unknown video card ID 0x%x --",
    330 		    sc->sc_dev.dv_xname, sc->card_id);
    331 		printf(" Not installing interrupt routine.\n");
    332 		break;
    333 	}
    334 
    335 	/* Perform common video attachment. */
    336 	grf_establish(sc, &sc->sc_slot, grfmv_mode);
    337 }
    338 
    339 static int
    340 grfmv_mode(gp, cmd, arg)
    341 	struct grf_softc *gp;
    342 	int cmd;
    343 	void *arg;
    344 {
    345 	switch (cmd) {
    346 	case GM_GRFON:
    347 	case GM_GRFOFF:
    348 		return 0;
    349 	case GM_CURRMODE:
    350 		break;
    351 	case GM_NEWMODE:
    352 		break;
    353 	case GM_LISTMODES:
    354 		break;
    355 	}
    356 	return EINVAL;
    357 }
    358 
    359 /* Interrupt handlers... */
    360 /*
    361  * Generic routine to clear interrupts for cards where it simply takes
    362  * a MOV.B to clear the interrupt.  The offset and value of this byte
    363  * varies between cards.
    364  */
    365 /*ARGSUSED*/
    366 static void
    367 grfmv_intr_generic_write1(vsc)
    368 	void	*vsc;
    369 {
    370 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    371 
    372 	bus_space_write_1(sc->sc_tag, sc->sc_handle,
    373 	    sc->cli_offset, (u_int8_t)sc->cli_value);
    374 }
    375 
    376 /*
    377  * Generic routine to clear interrupts for cards where it simply takes
    378  * a MOV.L to clear the interrupt.  The offset and value of this byte
    379  * varies between cards.
    380  */
    381 /*ARGSUSED*/
    382 static void
    383 grfmv_intr_generic_write4(vsc)
    384 	void	*vsc;
    385 {
    386 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    387 
    388 	bus_space_write_4(sc->sc_tag, sc->sc_handle,
    389 	    sc->cli_offset, sc->cli_value);
    390 }
    391 
    392 /*
    393  * Generic routine to clear interrupts for cards where it simply takes
    394  * an OR.L to clear the interrupt.  The offset and value of this byte
    395  * varies between cards.
    396  */
    397 /*ARGSUSED*/
    398 static void
    399 grfmv_intr_generic_or4(vsc)
    400 	void	*vsc;
    401 {
    402 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    403 	unsigned long	scratch;
    404 
    405 	scratch = bus_space_read_4(sc->sc_tag, sc->sc_handle, sc->cli_offset);
    406 	scratch |= 0x80;
    407 	bus_space_write_4(sc->sc_tag, sc->sc_handle, sc->cli_offset, scratch);
    408 }
    409 
    410 /*
    411  * Routine to clear interrupts for the Radius PrecisionColor 8xj card.
    412  */
    413 /*ARGSUSED*/
    414 static void
    415 grfmv_intr_radius(vsc)
    416 	void	*vsc;
    417 {
    418 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    419 	u_int8_t c;
    420 
    421 	c = sc->cli_value;
    422 
    423 	c |= 0x80;
    424 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xd00403, c);
    425 	c &= 0x7f;
    426 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xd00403, c);
    427 }
    428 
    429 /*
    430  * Routine to clear interrupts for the Radius PrecisionColor 24Xp card.
    431  * Is this what the 8xj routine is doing, too?
    432  */
    433 /*ARGSUSED*/
    434 static void
    435 grfmv_intr_radius24(vsc)
    436 	void	*vsc;
    437 {
    438 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    439 	u_int8_t c;
    440 
    441 	c = 0x80 | bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xfffd8);
    442 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xd00403, c);
    443 	c &= 0x7f;
    444 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xd00403, c);
    445 }
    446 
    447 /*
    448  * Routine to clear interrupts on Samsung 768x1006 video controller.
    449  * This controller was manufactured by Cornerstone Technology, Inc.,
    450  * now known as Cornerstone Imaging.
    451  *
    452  * To clear this interrupt, we apparently have to set, then clear,
    453  * bit 2 at byte offset 0x80000 from the card's base.
    454  *	Information for this provided by Brad Salai <bsalai (at) servtech.com>
    455  */
    456 /*ARGSUSED*/
    457 static void
    458 grfmv_intr_cti(vsc)
    459 	void	*vsc;
    460 {
    461 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    462 	u_int8_t c;
    463 
    464 	c = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0x80000);
    465 	c |= 0x02;
    466 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x80000, c);
    467 	c &= 0xfd;
    468 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x80000, c);
    469 }
    470 
    471 /*ARGSUSED*/
    472 static void
    473 grfmv_intr_cb264(vsc)
    474 	void	*vsc;
    475 {
    476 	struct grfbus_softc *sc;
    477 	volatile char *slotbase;
    478 
    479 	sc = (struct grfbus_softc *)vsc;
    480 	slotbase = (volatile char *)sc->sc_handle;	/* XXX evil hack */
    481 	asm volatile("	movl	%0,a0
    482 			movl	a0@(0xff6028),d0
    483 			andl	#0x2,d0
    484 			beq	_mv_intr0
    485 			movql	#0x3,d0
    486 		_mv_intr0:
    487 			movl	a0@(0xff600c),d1
    488 			andl	#0x3,d1
    489 			cmpl	d1,d0
    490 			beq	_mv_intr_fin
    491 			movl	d0,a0@(0xff600c)
    492 			nop
    493 			tstb	d0
    494 			beq	_mv_intr1
    495 			movl	#0x0002,a0@(0xff6040)
    496 			movl	#0x0102,a0@(0xff6044)
    497 			movl	#0x0105,a0@(0xff6048)
    498 			movl	#0x000e,a0@(0xff604c)
    499 			movl	#0x001c,a0@(0xff6050)
    500 			movl	#0x00bc,a0@(0xff6054)
    501 			movl	#0x00c3,a0@(0xff6058)
    502 			movl	#0x0061,a0@(0xff605c)
    503 			movl	#0x0012,a0@(0xff6060)
    504 			bra	_mv_intr_fin
    505 		_mv_intr1:
    506 			movl	#0x0002,a0@(0xff6040)
    507 			movl	#0x0209,a0@(0xff6044)
    508 			movl	#0x020c,a0@(0xff6048)
    509 			movl	#0x000f,a0@(0xff604c)
    510 			movl	#0x0027,a0@(0xff6050)
    511 			movl	#0x00c7,a0@(0xff6054)
    512 			movl	#0x00d7,a0@(0xff6058)
    513 			movl	#0x006b,a0@(0xff605c)
    514 			movl	#0x0029,a0@(0xff6060)
    515 		_mv_intr_fin:
    516 			movl	#0x1,a0@(0xff6014)"
    517 		: : "g" (slotbase) : "a0","d0","d1");
    518 }
    519 
    520 /*
    521  * Support for the Colorboard 364 might be more complex than it needs to
    522  * be.  If we can find more information about this card, this might be
    523  * significantly simplified.  Contributions welcome...  :-)
    524  */
    525 /*ARGSUSED*/
    526 static void
    527 grfmv_intr_cb364(vsc)
    528 	void	*vsc;
    529 {
    530 	struct grfbus_softc *sc;
    531 	volatile char *slotbase;
    532 
    533 	sc = (struct grfbus_softc *)vsc;
    534 	slotbase = (volatile char *)sc->sc_handle;	/* XXX evil hack */
    535 	asm volatile("	movl	%0,a0
    536 			movl	a0@(0xfe6028),d0
    537 			andl	#0x2,d0
    538 			beq	_cb364_intr4
    539 			movql	#0x3,d0
    540 			movl	a0@(0xfe6018),d1
    541 			movl	#0x3,a0@(0xfe6018)
    542 			movw	a0@(0xfe7010),d2
    543 			movl	d1,a0@(0xfe6018)
    544 			movl	a0@(0xfe6020),d1
    545 			btst	#0x06,d2
    546 			beq	_cb364_intr0
    547 			btst	#0x00,d1
    548 			beq	_cb364_intr5
    549 			bsr	_cb364_intr1
    550 			bra	_cb364_intr_out
    551 		_cb364_intr0:
    552 			btst	#0x00,d1
    553 			bne	_cb364_intr5
    554 			bsr	_cb364_intr1
    555 			bra	_cb364_intr_out
    556 		_cb364_intr1:
    557 			movl	d0,a0@(0xfe600c)
    558 			nop
    559 			tstb	d0
    560 			beq	_cb364_intr3
    561 			movl	#0x0002,a0@(0xfe6040)
    562 			movl	#0x0105,a0@(0xfe6048)
    563 			movl	#0x000e,a0@(0xfe604c)
    564 			movl	#0x00c3,a0@(0xfe6058)
    565 			movl	#0x0061,a0@(0xfe605c)
    566 			btst	#0x06,d2
    567 			beq	_cb364_intr2
    568 			movl	#0x001c,a0@(0xfe6050)
    569 			movl	#0x00bc,a0@(0xfe6054)
    570 			movl	#0x0012,a0@(0xfe6060)
    571 			movl	#0x000e,a0@(0xfe6044)
    572 			movl	#0x00c3,a0@(0xfe6064)
    573 			movl	#0x0061,a0@(0xfe6020)
    574 			rts
    575 		_cb364_intr2:
    576 			movl	#0x0016,a0@(0xfe6050)
    577 			movl	#0x00b6,a0@(0xfe6054)
    578 			movl	#0x0011,a0@(0xfe6060)
    579 			movl	#0x0101,a0@(0xfe6044)
    580 			movl	#0x00bf,a0@(0xfe6064)
    581 			movl	#0x0001,a0@(0xfe6020)
    582 			rts
    583 		_cb364_intr3:
    584 			movl	#0x0002,a0@(0xfe6040)
    585 			movl	#0x0209,a0@(0xfe6044)
    586 			movl	#0x020c,a0@(0xfe6048)
    587 			movl	#0x000f,a0@(0xfe604c)
    588 			movl	#0x0027,a0@(0xfe6050)
    589 			movl	#0x00c7,a0@(0xfe6054)
    590 			movl	#0x00d7,a0@(0xfe6058)
    591 			movl	#0x006b,a0@(0xfe605c)
    592 			movl	#0x0029,a0@(0xfe6060)
    593 			oril	#0x0040,a0@(0xfe6064)
    594 			movl	#0x0000,a0@(0xfe6020)
    595 			rts
    596 		_cb364_intr4:
    597 			movq	#0x00,d0
    598 		_cb364_intr5:
    599 			movl	a0@(0xfe600c),d1
    600 			andl	#0x3,d1
    601 			cmpl	d1,d0
    602 			beq	_cb364_intr_out
    603 			bsr	_cb364_intr1
    604 		_cb364_intr_out:
    605 			movl	#0x1,a0@(0xfe6014)
    606 		_cb364_intr_quit:
    607 		" : : "g" (slotbase) : "a0","d0","d1","d2");
    608 }
    609 
    610 /*
    611  * Interrupt clearing routine for SuperMac GFX card.
    612  */
    613 /*ARGSUSED*/
    614 static void
    615 grfmv_intr_supermacgfx(vsc)
    616 	void	*vsc;
    617 {
    618 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    619 	u_int8_t dummy;
    620 
    621 	dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xE70D3);
    622 }
    623 
    624 /*
    625  * Routine to clear interrupts for the Sigma Designs ColorMax card.
    626  */
    627 /*ARGSUSED*/
    628 static void
    629 grfmv_intr_cmax(vsc)
    630 	void	*vsc;
    631 {
    632 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    633 	u_int32_t dummy;
    634 
    635 	dummy = bus_space_read_4(sc->sc_tag, sc->sc_handle, 0xf501c);
    636 	dummy = bus_space_read_4(sc->sc_tag, sc->sc_handle, 0xf5018);
    637 }
    638 
    639 /*
    640  * Routine to clear interrupts for the Lapis ProColorServer 8 PDS card
    641  * (for the SE/30).
    642  */
    643 /*ARGSUSED*/
    644 static void
    645 grfmv_intr_lapis(vsc)
    646 	void	*vsc;
    647 {
    648 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    649 
    650 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xff7000, 0x08);
    651 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xff7000, 0x0C);
    652 }
    653 
    654 /*
    655  * Routine to clear interrupts for the Formac Color Card II
    656  */
    657 /*ARGSUSED*/
    658 static void
    659 grfmv_intr_formac(vsc)
    660 	void	*vsc;
    661 {
    662 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    663 	u_int8_t dummy;
    664 
    665 	dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xde80db);
    666 	dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xde80d3);
    667 }
    668 
    669 /*
    670  * Routine to clear interrupts for the Vimage by Interware Co., Ltd.
    671  */
    672 /*ARGSUSED*/
    673 static void
    674 grfmv_intr_vimage(vsc)
    675 	void	*vsc;
    676 {
    677 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    678 
    679 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x800000, 0x67);
    680 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x800000, 0xE7);
    681 }
    682 
    683 /*
    684  * Routine to clear interrupts for the Grand Vimage by Interware Co., Ltd.
    685  */
    686 /*ARGSUSED*/
    687 static void
    688 grfmv_intr_gvimage(vsc)
    689 	void	*vsc;
    690 {
    691 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    692 	u_int8_t dummy;
    693 
    694 	dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xf00000);
    695 }
    696