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