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