Subject: port-mac68k/3862: patch for Macintosh Display Card
To: None <gnats-bugs@gnats.netbsd.org>
From: None <ivanenko@ctpa03.mit.edu>
List: netbsd-bugs
Date: 07/14/1997 10:14:15
>Number:         3862
>Category:       port-mac68k
>Synopsis:       Fix the console and interrupt support for Macintosh Display Card
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 14 07:20:01 1997
>Last-Modified:
>Originator:     Taras Ivanenko
>Organization:
	Home
>Release:        <NetBSD-current source date> Jul 11 07:31:13 1997
>Environment:
	
System: NetBSD taras.mit.edu 1.2C NetBSD 1.2C (TARAS) #0: Sun Mar 9 01:16:17 EST 1997 ivanenko@taras.mit.edu:/usr/src/sys/arch/mac68k/compile/TARAS mac68k


>Description:
  The code in grf_mv.c states:
 	gm->fbbase = (caddr_t)(sc->sc_handle + image.offset); /* XXX evil! */
  	gm->fboff = image.offset;
  and it is evil indeed. The value fbbase is used consistently in 
  grf.c, ite.c and grf_iv.c as a start of the buffer indexed by fboff.
  So, fboff is added twice, once in attach() routine above and once more
  when it it used in other routines. On my machine, fbbase is 0xF9000000
  and fboff is 0xA00.

  The other change installs the interrupt driver for Macintosh Display Card,
  the code obtained by disassembling the ROM routine.

>How-To-Repeat:
	
   Boot the kernel from July 11 sources, see the lines
Jul 13 20:16:26 taras /netbsd: nubus0 at mainbus0
Jul 13 20:16:26 taras /netbsd: macvid0 at nubus0: Macintosh Display Card
Jul 13 20:16:26 taras /netbsd: macvid0: Unknown video card ID 0x19 -- Not installing interrupt routine.
Jul 13 20:16:26 taras /netbsd: macvid0: 640 x 480, monochrome
Jul 13 20:16:26 taras /netbsd: grf0 at macvid0
Jul 13 20:16:26 taras /netbsd: ite at grf0 not configured
Jul 13 20:16:26 taras /netbsd: fpu0 at mainbus0 (mc68882)

>Fix:
  Apply this patch in /sys/arch/mac68k/dev
*** nubus.h.orig	Sun Jul 13 21:32:06 1997
--- nubus.h	Sun Jul 13 21:32:08 1997
***************
*** 56,61 ****
--- 56,62 ----
  #define    NUBUS_DRHW_SE30	0x0009
  #define    NUBUS_DRHW_M2HRVC	0x0013	/* Apple Mac II High-Res Video Card */
  #define    NUBUS_DRHW_PVC	0x0017	/* Apple Mac II Portrait Video Card */
+ #define    NUBUS_DRHW_MDC       0x0019  /* Macintosh Display Card */
  #define    NUBUS_DRHW_CB264	0x013B	/* RasterOps ColorBoard 264 */
  #define    NUBUS_DRHW_MICRON	0x0146
  #define    NUBUS_DRHW_CB364	0x026F	/* RasterOps ColorBoard 364 */
*** grf_mv.c.orig	Sun Jul 13 21:23:27 1997
--- grf_mv.c	Mon Jul 14 08:59:37 1997
***************
*** 57,62 ****
--- 60,66 ----
  static void	grfmv_intr_cti __P((void *vsc, int slot));
  static void	grfmv_intr_cb264 __P((void *vsc, int slot));
  static void	grfmv_intr_cb364 __P((void *vsc, int slot));
+ static void     grfmv_intr_mdc __P((void *vsc, int slot));
  
  static int	grfmv_mode __P((struct grf_softc *gp, int cmd, void *arg));
  static caddr_t	grfmv_phys __P((struct grf_softc *gp, vm_offset_t addr));
***************
*** 193,199 ****
  
  	gm = &sc->curr_mode;
  	gm->mode_id = mode;
! 	gm->fbbase = (caddr_t)(sc->sc_handle + image.offset); /* XXX evil! */
  	gm->fboff = image.offset;
  	gm->rowbytes = image.rowbytes;
  	gm->width = image.right - image.left;
--- 197,203 ----
  
  	gm = &sc->curr_mode;
  	gm->mode_id = mode;
! 	gm->fbbase = (caddr_t)(sc->sc_handle); /* XXX evil! */
  	gm->fboff = image.offset;
  	gm->rowbytes = image.rowbytes;
  	gm->width = image.right - image.left;
***************
*** 257,262 ****
--- 261,275 ----
  	case NUBUS_DRHW_SE30:
  		/* Do nothing--SE/30 interrupts are disabled */
  		break;
+         case NUBUS_DRHW_MDC:
+ 		/* The interrupts are not generated until
+ 		   bus_space_write_4(sc->sc_tag, sc->sc_handle, 0x20013C, 5);
+ 		   to disable interrupts use
+ 		   bus_space_write_4(sc->sc_tag, sc->sc_handle, 0x20013C, 7);
+ 		   */
+ 		add_nubus_intr(na->slot, grfmv_intr_mdc, sc);
+ 		bus_space_write_4(sc->sc_tag, sc->sc_handle, 0x20013C, 5);
+ 		break;
  	case NUBUS_DRHW_MICRON:
  		/* What do we know about this one? */
  	default:
***************
*** 506,509 ****
--- 519,548 ----
  			movl	#0x1,a0@(0xfe6014)
  		_cb364_intr_quit:
  		" : : "g" (slotbase) : "a0","d0","d1","d2");
+ }
+ 
+ /*
+  * Routine to clear interrupts for the Macintosh Display Card.
+  */
+ /*ARGSUSED*/
+ static void
+ grfmv_intr_mdc(vsc, slot)
+ 	void	*vsc;
+ 	int	slot;
+ {
+         struct grfbus_softc *sc;
+ 
+         sc = (struct grfbus_softc *)vsc;
+ 
+         bus_space_write_4(sc->sc_tag, (u_long)sc->sc_handle, 0x200148, 1);
  }

>Audit-Trail:
>Unformatted: