Home | History | Annotate | Line # | Download | only in nubus
grf_nubus.c revision 1.52.6.2
      1 /*	$NetBSD: grf_nubus.c,v 1.52.6.2 1999/06/15 04:32:13 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 static void	grfmv_intr_gvimage __P((void *vsc));
     70 static void	grfmv_intr_radius_gsc __P((void *vsc));
     71 
     72 static int	grfmv_mode __P((struct grf_softc *gp, int cmd, void *arg));
     73 static int	grfmv_match __P((struct device *, struct cfdata *, void *));
     74 static void	grfmv_attach __P((struct device *, struct device *, void *));
     75 
     76 struct cfattach macvid_ca = {
     77 	sizeof(struct grfbus_softc), grfmv_match, grfmv_attach
     78 };
     79 
     80 static void
     81 load_image_data(data, image)
     82 	caddr_t	data;
     83 	struct	image_data *image;
     84 {
     85 	bcopy(data     , &image->size,       4);
     86 	bcopy(data +  4, &image->offset,     4);
     87 	bcopy(data +  8, &image->rowbytes,   2);
     88 	bcopy(data + 10, &image->top,        2);
     89 	bcopy(data + 12, &image->left,       2);
     90 	bcopy(data + 14, &image->bottom,     2);
     91 	bcopy(data + 16, &image->right,      2);
     92 	bcopy(data + 18, &image->version,    2);
     93 	bcopy(data + 20, &image->packType,   2);
     94 	bcopy(data + 22, &image->packSize,   4);
     95 	bcopy(data + 26, &image->hRes,       4);
     96 	bcopy(data + 30, &image->vRes,       4);
     97 	bcopy(data + 34, &image->pixelType,  2);
     98 	bcopy(data + 36, &image->pixelSize,  2);
     99 	bcopy(data + 38, &image->cmpCount,   2);
    100 	bcopy(data + 40, &image->cmpSize,    2);
    101 	bcopy(data + 42, &image->planeBytes, 4);
    102 }
    103 
    104 
    105 static int
    106 grfmv_match(parent, cf, aux)
    107 	struct device *parent;
    108 	struct cfdata *cf;
    109 	void *aux;
    110 {
    111 	struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
    112 
    113 	if (na->category != NUBUS_CATEGORY_DISPLAY)
    114 		return 0;
    115 
    116 	if (na->type != NUBUS_TYPE_VIDEO)
    117 		return 0;
    118 
    119 	if (na->drsw != NUBUS_DRSW_APPLE)
    120 		return 0;
    121 
    122 	/*
    123 	 * If we've gotten this far, then we're dealing with a real-live
    124 	 * Apple QuickDraw-compatible display card resource.  Now, how to
    125 	 * determine that this is an active resource???  Dunno.  But we'll
    126 	 * proceed like it is.
    127 	 */
    128 
    129 	return 1;
    130 }
    131 
    132 static void
    133 grfmv_attach(parent, self, aux)
    134 	struct device *parent, *self;
    135 	void *aux;
    136 {
    137 	struct grfbus_softc *sc = (struct grfbus_softc *)self;
    138 	struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
    139 	struct image_data image_store, image;
    140 	struct grfmode *gm;
    141 	char cardname[CARD_NAME_LEN];
    142 	nubus_dirent dirent;
    143 	nubus_dir dir, mode_dir;
    144 	int mode;
    145 
    146 	bcopy(na->fmt, &sc->sc_slot, sizeof(nubus_slot));
    147 
    148 	sc->sc_tag = na->na_tag;
    149 	sc->card_id = na->drhw;
    150 	sc->sc_basepa = (bus_addr_t)NUBUS_SLOT2PA(na->slot);
    151 	sc->sc_fbofs = 0;
    152 
    153 	if (bus_space_map(sc->sc_tag, sc->sc_basepa, 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->ptype = image.pixelType;
    205 	gm->psize = image.pixelSize;
    206 	gm->width = image.right - image.left;
    207 	gm->height = image.bottom - image.top;
    208 	gm->rowbytes = image.rowbytes;
    209 	gm->hres = image.hRes;
    210 	gm->vres = image.vRes;
    211 	gm->fbsize = gm->height * gm->rowbytes;
    212 	gm->fbbase = (caddr_t)sc->sc_handle;	/* XXX evil hack */
    213 	gm->fboff = image.offset;
    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_RADGSC:
    284 		add_nubus_intr(na->slot, grfmv_intr_radius_gsc, sc);
    285 		break;
    286 	case NUBUS_DRHW_FIILX:
    287 	case NUBUS_DRHW_FIISXDSP:
    288 	case NUBUS_DRHW_FUTURASX:
    289 		sc->cli_offset = 0xf05000;
    290 		sc->cli_value = 0x80;
    291 		add_nubus_intr(na->slot, grfmv_intr_generic_write1, sc);
    292 		break;
    293 	case NUBUS_DRHW_SAM768:
    294 		add_nubus_intr(na->slot, grfmv_intr_cti, sc);
    295 		break;
    296 	case NUBUS_DRHW_SUPRGFX:
    297 		add_nubus_intr(na->slot, grfmv_intr_supermacgfx, sc);
    298 		break;
    299 	case NUBUS_DRHW_SPECTRM8:
    300 		sc->cli_offset = 0x0de178;
    301 		sc->cli_value = 0x80;
    302 		add_nubus_intr(na->slot, grfmv_intr_generic_or4, sc);
    303 		break;
    304 	case NUBUS_DRHW_LAPIS:
    305 		add_nubus_intr(na->slot, grfmv_intr_lapis, sc);
    306 		break;
    307 	case NUBUS_DRHW_FORMAC:
    308 		add_nubus_intr(na->slot, grfmv_intr_formac, sc);
    309 		break;
    310 	case NUBUS_DRHW_ROPS24LXI:
    311 	case NUBUS_DRHW_ROPS24XLTV:
    312 		sc->cli_offset = 0xfb0010;
    313 		sc->cli_value = 0x00;
    314 		add_nubus_intr(na->slot, grfmv_intr_generic_write4, sc);
    315 		break;
    316 	case NUBUS_DRHW_VIMAGE:
    317 		add_nubus_intr(na->slot, grfmv_intr_vimage, sc);
    318 		break;
    319 	case NUBUS_DRHW_GVIMAGE:
    320 		add_nubus_intr(na->slot, grfmv_intr_gvimage, sc);
    321 		break;
    322 	case NUBUS_DRHW_MC2124NB:
    323 		sc->cli_offset = 0xfd1000;
    324 		sc->cli_value = 0x00;
    325 		add_nubus_intr(na->slot, grfmv_intr_generic_write4, sc);
    326 		break;
    327 	case NUBUS_DRHW_MICRON:
    328 		sc->cli_offset = 0xa00014;
    329 		sc->cli_value = 0;
    330 		add_nubus_intr(na->slot, grfmv_intr_generic_write4, sc);
    331 		break;
    332 	default:
    333 		printf("%s: Unknown video card ID 0x%x --",
    334 		    sc->sc_dev.dv_xname, sc->card_id);
    335 		printf(" Not installing interrupt routine.\n");
    336 		break;
    337 	}
    338 
    339 	/* Perform common video attachment. */
    340 	grf_establish(sc, &sc->sc_slot, grfmv_mode);
    341 }
    342 
    343 static int
    344 grfmv_mode(gp, cmd, arg)
    345 	struct grf_softc *gp;
    346 	int cmd;
    347 	void *arg;
    348 {
    349 	switch (cmd) {
    350 	case GM_GRFON:
    351 	case GM_GRFOFF:
    352 		return 0;
    353 	case GM_CURRMODE:
    354 		break;
    355 	case GM_NEWMODE:
    356 		break;
    357 	case GM_LISTMODES:
    358 		break;
    359 	}
    360 	return EINVAL;
    361 }
    362 
    363 /* Interrupt handlers... */
    364 /*
    365  * Generic routine to clear interrupts for cards where it simply takes
    366  * a MOV.B to clear the interrupt.  The offset and value of this byte
    367  * varies between cards.
    368  */
    369 /*ARGSUSED*/
    370 static void
    371 grfmv_intr_generic_write1(vsc)
    372 	void	*vsc;
    373 {
    374 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    375 
    376 	bus_space_write_1(sc->sc_tag, sc->sc_handle,
    377 	    sc->cli_offset, (u_int8_t)sc->cli_value);
    378 }
    379 
    380 /*
    381  * Generic routine to clear interrupts for cards where it simply takes
    382  * a MOV.L to clear the interrupt.  The offset and value of this byte
    383  * varies between cards.
    384  */
    385 /*ARGSUSED*/
    386 static void
    387 grfmv_intr_generic_write4(vsc)
    388 	void	*vsc;
    389 {
    390 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    391 
    392 	bus_space_write_4(sc->sc_tag, sc->sc_handle,
    393 	    sc->cli_offset, sc->cli_value);
    394 }
    395 
    396 /*
    397  * Generic routine to clear interrupts for cards where it simply takes
    398  * an OR.L to clear the interrupt.  The offset and value of this byte
    399  * varies between cards.
    400  */
    401 /*ARGSUSED*/
    402 static void
    403 grfmv_intr_generic_or4(vsc)
    404 	void	*vsc;
    405 {
    406 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    407 	unsigned long	scratch;
    408 
    409 	scratch = bus_space_read_4(sc->sc_tag, sc->sc_handle, sc->cli_offset);
    410 	scratch |= 0x80;
    411 	bus_space_write_4(sc->sc_tag, sc->sc_handle, sc->cli_offset, scratch);
    412 }
    413 
    414 /*
    415  * Routine to clear interrupts for the Radius PrecisionColor 8xj card.
    416  */
    417 /*ARGSUSED*/
    418 static void
    419 grfmv_intr_radius(vsc)
    420 	void	*vsc;
    421 {
    422 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    423 	u_int8_t c;
    424 
    425 	c = sc->cli_value;
    426 
    427 	c |= 0x80;
    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 for the Radius PrecisionColor 24Xp card.
    435  * Is this what the 8xj routine is doing, too?
    436  */
    437 /*ARGSUSED*/
    438 static void
    439 grfmv_intr_radius24(vsc)
    440 	void	*vsc;
    441 {
    442 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    443 	u_int8_t c;
    444 
    445 	c = 0x80 | bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xfffd8);
    446 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xd00403, c);
    447 	c &= 0x7f;
    448 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xd00403, c);
    449 }
    450 
    451 /*
    452  * Routine to clear interrupts on Samsung 768x1006 video controller.
    453  * This controller was manufactured by Cornerstone Technology, Inc.,
    454  * now known as Cornerstone Imaging.
    455  *
    456  * To clear this interrupt, we apparently have to set, then clear,
    457  * bit 2 at byte offset 0x80000 from the card's base.
    458  *	Information for this provided by Brad Salai <bsalai (at) servtech.com>
    459  */
    460 /*ARGSUSED*/
    461 static void
    462 grfmv_intr_cti(vsc)
    463 	void	*vsc;
    464 {
    465 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    466 	u_int8_t c;
    467 
    468 	c = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0x80000);
    469 	c |= 0x02;
    470 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x80000, c);
    471 	c &= 0xfd;
    472 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x80000, c);
    473 }
    474 
    475 /*ARGSUSED*/
    476 static void
    477 grfmv_intr_cb264(vsc)
    478 	void	*vsc;
    479 {
    480 	struct grfbus_softc *sc;
    481 	volatile char *slotbase;
    482 
    483 	sc = (struct grfbus_softc *)vsc;
    484 	slotbase = (volatile char *)sc->sc_handle;	/* XXX evil hack */
    485 	asm volatile("	movl	%0,a0
    486 			movl	a0@(0xff6028),d0
    487 			andl	#0x2,d0
    488 			beq	_mv_intr0
    489 			movql	#0x3,d0
    490 		_mv_intr0:
    491 			movl	a0@(0xff600c),d1
    492 			andl	#0x3,d1
    493 			cmpl	d1,d0
    494 			beq	_mv_intr_fin
    495 			movl	d0,a0@(0xff600c)
    496 			nop
    497 			tstb	d0
    498 			beq	_mv_intr1
    499 			movl	#0x0002,a0@(0xff6040)
    500 			movl	#0x0102,a0@(0xff6044)
    501 			movl	#0x0105,a0@(0xff6048)
    502 			movl	#0x000e,a0@(0xff604c)
    503 			movl	#0x001c,a0@(0xff6050)
    504 			movl	#0x00bc,a0@(0xff6054)
    505 			movl	#0x00c3,a0@(0xff6058)
    506 			movl	#0x0061,a0@(0xff605c)
    507 			movl	#0x0012,a0@(0xff6060)
    508 			bra	_mv_intr_fin
    509 		_mv_intr1:
    510 			movl	#0x0002,a0@(0xff6040)
    511 			movl	#0x0209,a0@(0xff6044)
    512 			movl	#0x020c,a0@(0xff6048)
    513 			movl	#0x000f,a0@(0xff604c)
    514 			movl	#0x0027,a0@(0xff6050)
    515 			movl	#0x00c7,a0@(0xff6054)
    516 			movl	#0x00d7,a0@(0xff6058)
    517 			movl	#0x006b,a0@(0xff605c)
    518 			movl	#0x0029,a0@(0xff6060)
    519 		_mv_intr_fin:
    520 			movl	#0x1,a0@(0xff6014)"
    521 		: : "g" (slotbase) : "a0","d0","d1");
    522 }
    523 
    524 /*
    525  * Support for the Colorboard 364 might be more complex than it needs to
    526  * be.  If we can find more information about this card, this might be
    527  * significantly simplified.  Contributions welcome...  :-)
    528  */
    529 /*ARGSUSED*/
    530 static void
    531 grfmv_intr_cb364(vsc)
    532 	void	*vsc;
    533 {
    534 	struct grfbus_softc *sc;
    535 	volatile char *slotbase;
    536 
    537 	sc = (struct grfbus_softc *)vsc;
    538 	slotbase = (volatile char *)sc->sc_handle;	/* XXX evil hack */
    539 	asm volatile("	movl	%0,a0
    540 			movl	a0@(0xfe6028),d0
    541 			andl	#0x2,d0
    542 			beq	_cb364_intr4
    543 			movql	#0x3,d0
    544 			movl	a0@(0xfe6018),d1
    545 			movl	#0x3,a0@(0xfe6018)
    546 			movw	a0@(0xfe7010),d2
    547 			movl	d1,a0@(0xfe6018)
    548 			movl	a0@(0xfe6020),d1
    549 			btst	#0x06,d2
    550 			beq	_cb364_intr0
    551 			btst	#0x00,d1
    552 			beq	_cb364_intr5
    553 			bsr	_cb364_intr1
    554 			bra	_cb364_intr_out
    555 		_cb364_intr0:
    556 			btst	#0x00,d1
    557 			bne	_cb364_intr5
    558 			bsr	_cb364_intr1
    559 			bra	_cb364_intr_out
    560 		_cb364_intr1:
    561 			movl	d0,a0@(0xfe600c)
    562 			nop
    563 			tstb	d0
    564 			beq	_cb364_intr3
    565 			movl	#0x0002,a0@(0xfe6040)
    566 			movl	#0x0105,a0@(0xfe6048)
    567 			movl	#0x000e,a0@(0xfe604c)
    568 			movl	#0x00c3,a0@(0xfe6058)
    569 			movl	#0x0061,a0@(0xfe605c)
    570 			btst	#0x06,d2
    571 			beq	_cb364_intr2
    572 			movl	#0x001c,a0@(0xfe6050)
    573 			movl	#0x00bc,a0@(0xfe6054)
    574 			movl	#0x0012,a0@(0xfe6060)
    575 			movl	#0x000e,a0@(0xfe6044)
    576 			movl	#0x00c3,a0@(0xfe6064)
    577 			movl	#0x0061,a0@(0xfe6020)
    578 			rts
    579 		_cb364_intr2:
    580 			movl	#0x0016,a0@(0xfe6050)
    581 			movl	#0x00b6,a0@(0xfe6054)
    582 			movl	#0x0011,a0@(0xfe6060)
    583 			movl	#0x0101,a0@(0xfe6044)
    584 			movl	#0x00bf,a0@(0xfe6064)
    585 			movl	#0x0001,a0@(0xfe6020)
    586 			rts
    587 		_cb364_intr3:
    588 			movl	#0x0002,a0@(0xfe6040)
    589 			movl	#0x0209,a0@(0xfe6044)
    590 			movl	#0x020c,a0@(0xfe6048)
    591 			movl	#0x000f,a0@(0xfe604c)
    592 			movl	#0x0027,a0@(0xfe6050)
    593 			movl	#0x00c7,a0@(0xfe6054)
    594 			movl	#0x00d7,a0@(0xfe6058)
    595 			movl	#0x006b,a0@(0xfe605c)
    596 			movl	#0x0029,a0@(0xfe6060)
    597 			oril	#0x0040,a0@(0xfe6064)
    598 			movl	#0x0000,a0@(0xfe6020)
    599 			rts
    600 		_cb364_intr4:
    601 			movq	#0x00,d0
    602 		_cb364_intr5:
    603 			movl	a0@(0xfe600c),d1
    604 			andl	#0x3,d1
    605 			cmpl	d1,d0
    606 			beq	_cb364_intr_out
    607 			bsr	_cb364_intr1
    608 		_cb364_intr_out:
    609 			movl	#0x1,a0@(0xfe6014)
    610 		_cb364_intr_quit:
    611 		" : : "g" (slotbase) : "a0","d0","d1","d2");
    612 }
    613 
    614 /*
    615  * Interrupt clearing routine for SuperMac GFX card.
    616  */
    617 /*ARGSUSED*/
    618 static void
    619 grfmv_intr_supermacgfx(vsc)
    620 	void	*vsc;
    621 {
    622 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    623 	u_int8_t dummy;
    624 
    625 	dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xE70D3);
    626 }
    627 
    628 /*
    629  * Routine to clear interrupts for the Sigma Designs ColorMax card.
    630  */
    631 /*ARGSUSED*/
    632 static void
    633 grfmv_intr_cmax(vsc)
    634 	void	*vsc;
    635 {
    636 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    637 	u_int32_t dummy;
    638 
    639 	dummy = bus_space_read_4(sc->sc_tag, sc->sc_handle, 0xf501c);
    640 	dummy = bus_space_read_4(sc->sc_tag, sc->sc_handle, 0xf5018);
    641 }
    642 
    643 /*
    644  * Routine to clear interrupts for the Lapis ProColorServer 8 PDS card
    645  * (for the SE/30).
    646  */
    647 /*ARGSUSED*/
    648 static void
    649 grfmv_intr_lapis(vsc)
    650 	void	*vsc;
    651 {
    652 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    653 
    654 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xff7000, 0x08);
    655 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xff7000, 0x0C);
    656 }
    657 
    658 /*
    659  * Routine to clear interrupts for the Formac Color Card II
    660  */
    661 /*ARGSUSED*/
    662 static void
    663 grfmv_intr_formac(vsc)
    664 	void	*vsc;
    665 {
    666 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    667 	u_int8_t dummy;
    668 
    669 	dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xde80db);
    670 	dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xde80d3);
    671 }
    672 
    673 /*
    674  * Routine to clear interrupts for the Vimage by Interware Co., Ltd.
    675  */
    676 /*ARGSUSED*/
    677 static void
    678 grfmv_intr_vimage(vsc)
    679 	void	*vsc;
    680 {
    681 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    682 
    683 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x800000, 0x67);
    684 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x800000, 0xE7);
    685 }
    686 
    687 /*
    688  * Routine to clear interrupts for the Grand Vimage by Interware Co., Ltd.
    689  */
    690 /*ARGSUSED*/
    691 static void
    692 grfmv_intr_gvimage(vsc)
    693 	void	*vsc;
    694 {
    695 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    696 	u_int8_t dummy;
    697 
    698 	dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xf00000);
    699 }
    700 
    701 /*
    702  * Routine to clear interrupts for the Radius GS/C
    703  */
    704 /*ARGSUSED*/
    705 static void
    706 grfmv_intr_radius_gsc(vsc)
    707 	void	*vsc;
    708 {
    709 	struct grfbus_softc *sc = (struct grfbus_softc *)vsc;
    710 	u_int8_t dummy;
    711 
    712 	dummy = bus_space_read_1(sc->sc_tag, sc->sc_handle, 0xfb802);
    713 	bus_space_write_1(sc->sc_tag, sc->sc_handle, 0xfb802, 0xff);
    714 }
    715 
    716