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