Subject: Re: Color video LKM and -current system
To: None <PREGMAN1@wit.edu>
From: Colin Wood <cwood@ichips.intel.com>
List: port-mac68k
Date: 09/22/1997 14:37:54
PREGMAN1@wit.edu wrote:
> 
> I have recently upgraded to -current (the September 13 tarballs, to be
> exact) and would like to continue using the X colorkit which I made use
> of under 1.2.  I've followed the instructions for installing the LKM,
> however it refuses to actually load, citing undefined symbols of
> `_nubus_video_resource'.  I've tried running ld on it, but I really have
> no clue what I'm doing with ld, so needless to say it hasn't helped.  I
> did notice a caveat on the FAQ page which basically states that the LKM
> *may* not work with -current setups, and *definitely* will not compile
> under them (I can personally attest to both).  My question, basically,
> is this:  what are my options here (and no, "don't run X in color" is
> not acceptable :>), and what can I do about it?  I'm sure at *least*
> one other person has run into this dilemma, given the popularity of
> both the colorkit and of -current.  Thanks.

Yeah, the symbol that causes the problem is now a static variable so it
doesn't show up in the symbol table anymore :-(  And due to extensive
changes in the nubus code, the colorkit LKM doesn't recompile under
-current sources.  However, I've managed to hack together a patch to get
around this problem.  Please try the patches at the end of this message
and let me know how it goes.

I hope this helps.

Later.

-- 
Colin Wood                                 cwood@ichips.intel.com
Component Design Engineer - MD6                 Intel Corporation
-----------------------------------------------------------------
I speak only on my own behalf, not for my employer.

*** video_lkm.c	Sat Feb 15 17:47:37 1997
--- ../video_lkm.new/video_lkm.c	Mon Feb 24 12:15:37 1997
***************
*** 19,24 ****
--- 19,25 ----
  #include <vm/vm_pager.h>
  
  #include <mac68k/mac68k/macrom.h>
+ #include <mac68k/include/bus.h>
  #include <mac68k/include/cpu.h>
  #include <mac68k/include/pmap.h>
  #include <mac68k/include/grfioctl.h>
*** video_lkm.h	Sat Feb 15 10:31:13 1997
--- ../video_lkm.new/video_lkm.h	Sat Aug  2 01:07:16 1997
***************
*** 107,113 ****
  
  void nubus_install_SM_fmtblock __P((nubus_slot *slot));
  void nubus_uninstall_SM_fmtblock __P((int slot));
! int     nubus_slot_manager(short selector, SpBlock * param);
  
  void mrg_jIODone __P((void));
  
--- 107,114 ----
  
  void nubus_install_SM_fmtblock __P((nubus_slot *slot));
  void nubus_uninstall_SM_fmtblock __P((int slot));
! int     nubus_slot_manager(bus_space_tag_t, bus_space_handle_t,
! 			   short selector, SpBlock * param);
  
  void mrg_jIODone __P((void));
  
*** video_lkm_misc.c	Sat Feb 15 09:33:09 1997
--- ../video_lkm.new/video_lkm_misc.c	Sat Aug  2 20:07:04 1997
***************
*** 18,23 ****
--- 18,24 ----
  #include <vm/vm_page.h>
  #include <vm/vm_pager.h>
  
+ #include <mac68k/include/bus.h>
  #include <mac68k/dev/nubus.h>
  #include <mac68k/include/grfioctl.h>
  #include <mac68k/dev/grfvar.h>
***************
*** 93,131 ****
    nubus_slot_enabled_resources[slot-NUBUS_MIN_SLOT] = NULL;
  }
  
  int 
  mrg_SlotManager()
  {
  	u_short selector;
  	SpBlock *spb;
  
  	asm("	movl a0, %0
  		movw d0, %1" : "=g" (spb), "=g" (selector) :: "a0", "d0");
! 	return nubus_slot_manager(selector, spb);
  }
  
! static int	nubus_sm_SetSRsrcState __P((SpBlock * param));
! static int	nubus_sm_GetNextTypeSRsrc __P((SpBlock * param));
! static int	nubus_sm_SFindStruct __P((SpBlock * param));
! static int	nubus_sm_SGetBlock __P((SpBlock * param));
! static int	nubus_sm_SRsrcInfo __P((SpBlock * param));
  
  int
! nubus_slot_manager(selector, param)
  	short selector;
  	SpBlock *param;
  {
  	switch (selector) {
! 		case 0x9:	/* SetSRsrcState */
! 		return nubus_sm_SetSRsrcState(param);
  	case 0x15:		/* GetNextTypeSRsrc */
! 		return nubus_sm_GetNextTypeSRsrc(param);
  	case 0x06:		/* SFindStruct */
! 		return nubus_sm_SFindStruct(param);
  	case 0x05:		/* SGetBlock */
! 		return nubus_sm_SGetBlock(param);
  	case 0x16:		/* SRsrcInfo */
! 		return nubus_sm_SRsrcInfo(param);
  	default:
  #ifdef DEBUG 
  		printf("SM:Unknown Slot Manager routine 0x%x\n", selector);
--- 94,149 ----
    nubus_slot_enabled_resources[slot-NUBUS_MIN_SLOT] = NULL;
  }
  
+ /* XXX Gross hack!!!!! XXX */
+ extern bus_space_tag_t global_bst;
+ extern bus_space_handle_t global_bsh;
+ 
  int 
  mrg_SlotManager()
  {
+ 	bus_space_tag_t bst;
+ 	bus_space_handle_t bsh;
  	u_short selector;
  	SpBlock *spb;
  
  	asm("	movl a0, %0
  		movw d0, %1" : "=g" (spb), "=g" (selector) :: "a0", "d0");
! 
! #ifdef DEBUG
! 	printf("mrg_SlotManager called...oops!\n");
! #endif
! 	return nubus_slot_manager(global_bst, global_bsh, selector, spb);
  }
  
! static int nubus_sm_SetSRsrcState __P((bus_space_tag_t,
! 				       bus_space_handle_t,SpBlock * param));
! static int nubus_sm_GetNextTypeSRsrc __P((bus_space_tag_t,
! 					  bus_space_handle_t,SpBlock * param));
! static int nubus_sm_SFindStruct __P((bus_space_tag_t, bus_space_handle_t,
! 				     SpBlock * param));
! static int nubus_sm_SGetBlock __P((bus_space_tag_t, bus_space_handle_t,
! 				   SpBlock * param));
! static int nubus_sm_SRsrcInfo __P((bus_space_tag_t, bus_space_handle_t,
! 				   SpBlock * param));
  
  int
! nubus_slot_manager(bst, bsh, selector, param)
! 	bus_space_tag_t bst;
! 	bus_space_handle_t bsh;
  	short selector;
  	SpBlock *param;
  {
  	switch (selector) {
! 	case 0x9:		/* SetSRsrcState */
! 		return nubus_sm_SetSRsrcState(bst, bsh, param);
  	case 0x15:		/* GetNextTypeSRsrc */
! 		return nubus_sm_GetNextTypeSRsrc(bst, bsh, param);
  	case 0x06:		/* SFindStruct */
! 		return nubus_sm_SFindStruct(bst, bsh, param);
  	case 0x05:		/* SGetBlock */
! 		return nubus_sm_SGetBlock(bst, bsh, param);
  	case 0x16:		/* SRsrcInfo */
! 		return nubus_sm_SRsrcInfo(bst, bsh, param);
  	default:
  #ifdef DEBUG 
  		printf("SM:Unknown Slot Manager routine 0x%x\n", selector);
***************
*** 135,141 ****
  }
  
  static int
! nubus_sm_SetSRsrcState(param)
  	SpBlock *param;
  {
  	nubus_slot *slot;
--- 153,161 ----
  }
  
  static int
! nubus_sm_SetSRsrcState(bst, bsh, param)
! 	bus_space_tag_t bst;
! 	bus_space_handle_t bsh;
  	SpBlock *param;
  {
  	nubus_slot *slot;
***************
*** 151,157 ****
  
  	nubus_get_main_dir(slot, &dir);
  
! 	if (nubus_find_rsrc(slot, &dir, id, &dirent) <= 0)
  		return -344;
  
   	nubus_slot_enabled_resources[param->spSlot - NUBUS_MIN_SLOT][id] =
--- 171,177 ----
  
  	nubus_get_main_dir(slot, &dir);
  
! 	if (nubus_find_rsrc(bst, bsh, slot, &dir, id, &dirent) <= 0)
  		return -344;
  
   	nubus_slot_enabled_resources[param->spSlot - NUBUS_MIN_SLOT][id] =
***************
*** 161,167 ****
  }
  
  static int
! nubus_sm_SRsrcInfo(param)
  	SpBlock *param;
  {
  	nubus_slot *slot;
--- 181,189 ----
  }
  
  static int
! nubus_sm_SRsrcInfo(bst, bsh, param)
! 	bus_space_tag_t bst;
! 	bus_space_handle_t bsh;
  	SpBlock *param;
  {
  	nubus_slot *slot;
***************
*** 178,193 ****
  
  	nubus_get_main_dir(slot, &dir);
  
! 	if (nubus_find_rsrc(slot, &dir, id, &dirent) <= 0)
  		return -344;
  
  	nubus_get_dir_from_rsrc(slot, &dirent, &dir2);
  
! 	if (nubus_find_rsrc(slot, &dir2, NUBUS_RSRC_TYPE, &dirent2) <= 0)
  		return -344;
  
! 	if (nubus_get_ind_data(slot, &dirent,
! 		(caddr_t) & slottype, sizeof(nubus_type)) <= 0)
  		return -344;
  
  
--- 200,216 ----
  
  	nubus_get_main_dir(slot, &dir);
  
! 	if (nubus_find_rsrc(bst, bsh, slot, &dir, id, &dirent) <= 0)
  		return -344;
  
  	nubus_get_dir_from_rsrc(slot, &dirent, &dir2);
  
! 	if (nubus_find_rsrc(bst, bsh, slot, &dir2,
! 	    NUBUS_RSRC_TYPE, &dirent2) <= 0)
  		return -344;
  
! 	if (nubus_get_ind_data(bst, bsh, slot, &dirent,
! 			       (caddr_t) & slottype, sizeof(nubus_type)) <= 0)
  		return -344;
  
  
***************
*** 218,224 ****
   */
  
  static int
! nubus_sm_GetNextTypeSRsrc(param)
  	SpBlock *param;
  {
  	nubus_slot *slot;
--- 241,249 ----
   */
  
  static int
! nubus_sm_GetNextTypeSRsrc(bst, bsh, param)
! 	bus_space_tag_t bst;
! 	bus_space_handle_t bsh;
  	SpBlock *param;
  {
  	nubus_slot *slot;
***************
*** 241,255 ****
  	  for (rsrc = (u_int) (param->spID & 0xFF); rsrc < 255; rsrc++) {
  	    if (nubus_slot_enabled_resources[i-NUBUS_MIN_SLOT][rsrc] == 0)
  	      continue;
! 	    if (nubus_find_rsrc(slot, &dir, rsrc, &dirent) <= 0)
  	      continue;
  	    
  	    nubus_get_dir_from_rsrc(slot, &dirent, &dir2);
  	    
! 	    if (nubus_find_rsrc(slot, &dir2, NUBUS_RSRC_TYPE, &dirent) <= 0)
  	      continue;
  
! 	    if (nubus_get_ind_data(slot, &dirent,
  				   (caddr_t) & slottype, sizeof(nubus_type)) <= 0)
  	      continue;
  	    
--- 266,281 ----
  	  for (rsrc = (u_int) (param->spID & 0xFF); rsrc < 255; rsrc++) {
  	    if (nubus_slot_enabled_resources[i-NUBUS_MIN_SLOT][rsrc] == 0)
  	      continue;
! 	    if (nubus_find_rsrc(bst, bsh, slot, &dir, rsrc, &dirent) <= 0)
  	      continue;
  	    
  	    nubus_get_dir_from_rsrc(slot, &dirent, &dir2);
  	    
! 	    if (nubus_find_rsrc(bst, bsh, slot, &dir2,
! 		NUBUS_RSRC_TYPE, &dirent) <= 0)
  	      continue;
  
! 	    if (nubus_get_ind_data(bst, bsh, slot, &dirent,
  				   (caddr_t) & slottype, sizeof(nubus_type)) <= 0)
  	      continue;
  	    
***************
*** 290,296 ****
  }
  
  static int 
! nubus_sm_SFindStruct(param)
  	SpBlock *param;
  {
  	nubus_slot *slot;
--- 316,324 ----
  }
  
  static int 
! nubus_sm_SFindStruct(bst, bsh, param)
! 	bus_space_tag_t bst;
! 	bus_space_handle_t bsh;
  	SpBlock *param;
  {
  	nubus_slot *slot;
***************
*** 306,312 ****
  
  	dir.dirbase = dir.curr_ent = (u_int32_t) param->spsPointer;
  
! 	if (nubus_find_rsrc(slot, &dir, id, &dirent) <= 0) {
  #ifdef DEBUG
  		printf("SM:Do not find rsrc 0x%x in SFindStruct\n", (u_int) param->spID);
  #endif
--- 334,340 ----
  
  	dir.dirbase = dir.curr_ent = (u_int32_t) param->spsPointer;
  
! 	if (nubus_find_rsrc(bst, bsh, slot, &dir, id, &dirent) <= 0) {
  #ifdef DEBUG
  		printf("SM:Do not find rsrc 0x%x in SFindStruct\n", (u_int) param->spID);
  #endif
***************
*** 323,329 ****
  }
  
  static int
! nubus_sm_SGetBlock(param)
  	SpBlock *param;
  {
  	nubus_slot *slot;
--- 351,359 ----
  }
  
  static int
! nubus_sm_SGetBlock(bst, bsh, param)
! 	bus_space_tag_t bst;
! 	bus_space_handle_t bsh;
  	SpBlock *param;
  {
  	nubus_slot *slot;
***************
*** 340,346 ****
  
  	dir.dirbase = dir.curr_ent = (u_int32_t) param->spsPointer;
  
! 	if (nubus_find_rsrc(slot, &dir, id, &dirent) <= 0) {
  #ifdef DEBUG
  		printf("SM:Did not find Rsrc 0x%x in SGetBlock\n", (u_int) param->spID);
  #endif
--- 370,376 ----
  
  	dir.dirbase = dir.curr_ent = (u_int32_t) param->spsPointer;
  
! 	if (nubus_find_rsrc(bst, bsh, slot, &dir, id, &dirent) <= 0) {
  #ifdef DEBUG
  		printf("SM:Did not find Rsrc 0x%x in SGetBlock\n", (u_int) param->spID);
  #endif
***************
*** 351,357 ****
  	printf("SM:Fount Rsrc 0x%x in SGetBlock\n", (u_int) param->spID);
  #endif
  
! 	if (nubus_get_ind_data(slot, &dirent, (caddr_t) &len, sizeof(len)) <= 0) {
  #ifdef DEBUG
  		printf("SM:Can not get data size in SGetBlock\n");
  #endif
--- 381,388 ----
  	printf("SM:Fount Rsrc 0x%x in SGetBlock\n", (u_int) param->spID);
  #endif
  
! 	if (nubus_get_ind_data(bst, bsh, slot, &dirent,
! 			       (caddr_t) &len, sizeof(len)) <= 0) {
  #ifdef DEBUG
  		printf("SM:Can not get data size in SGetBlock\n");
  #endif
***************
*** 368,374 ****
  	if (param->spResult == NULL)
  		return -108;
  
! 	if (nubus_get_ind_data(slot, &dirent, (caddr_t) param->spResult, len) <= 0) {
  #ifdef DEBUG
  		printf("SM:SGetBlock: Can not get data\n");
  #endif
--- 399,406 ----
  	if (param->spResult == NULL)
  		return -108;
  
! 	if (nubus_get_ind_data(bst, bsh, slot, &dirent,
! 	         	       (caddr_t) param->spResult, len) <= 0) {
  #ifdef DEBUG
  		printf("SM:SGetBlock: Can not get data\n");
  #endif
*** video_lkm_module.c	Sat Feb 15 10:38:31 1997
--- ../video_lkm.new/video_lkm_module.c	Sat Aug  2 19:53:56 1997
***************
*** 21,26 ****
--- 21,27 ----
  #include <vm/vm_pager.h>
  
  #include <mac68k/mac68k/macrom.h>
+ #include <mac68k/include/bus.h>
  #include <mac68k/include/cpu.h>
  #include <mac68k/include/pmap.h>
  #include <mac68k/include/grfioctl.h>
***************
*** 38,44 ****
  static void     reset_console   __P((struct grf_softc *gp));
  static int      load_current_mode __P((struct grf_softc *gp));
  static int      set_default_mode __P((struct grf_softc *gp));
! 
  
  extern struct cfdriver grf_cd;
  /* From Booter via locore */
--- 39,45 ----
  static void     reset_console   __P((struct grf_softc *gp));
  static int      load_current_mode __P((struct grf_softc *gp));
  static int      set_default_mode __P((struct grf_softc *gp));
! static int	nubus_video_resource __P((int));
  
  extern struct cfdriver grf_cd;
  /* From Booter via locore */
***************
*** 47,62 ****
  extern long		videobitdepth;
  extern unsigned long	videosize;
  
  caddr_t video_mv_phys(gp,addr)
       struct grf_softc *gp;
       vm_offset_t addr;
  {
!   if(addr < NUBUS_SLOT_TO_PADDR(NUBUS_MIN_SLOT)) {
!     return (caddr_t) (NUBUS_SLOT_TO_PADDR(gp->sc_slot->slot) +
! 		      (addr - gp->sc_slot->virtual_base));
    } else {
      return (caddr_t)addr;
    }
  }
  
  int
--- 48,89 ----
  extern long		videobitdepth;
  extern unsigned long	videosize;
  
+ /*
+  * XXX Gross hack to get around bus_space difficulties in MRG
+  * XXX interface routines
+  */
+ bus_space_tag_t global_bst;
+ bus_space_handle_t global_bsh;
+ 
+ /* XXX Another hack to avoid changing kernel source code */
+ static int
+ nubus_video_resource(slot)
+ 	int slot;
+ {
+ 	extern u_int16_t mac68k_vrsrc_vec[];
+ 	int i;
+ 
+ 	for (i = 0 ; i < 6 ; i++)
+ 		if ((mac68k_vrsrc_vec[i] & 0xff) == slot)
+ 			return ((mac68k_vrsrc_vec[i] >> 8) & 0xff);
+ 	return (-1);
+ }
+ 
+ 
  caddr_t video_mv_phys(gp,addr)
       struct grf_softc *gp;
       vm_offset_t addr;
  {
! #ifdef 0
!   if(addr < NUBUS_SLOT2PA(NUBUS_MIN_SLOT)) {
! 	return (caddr_t)(NUBUS_SLOT2PA(gp->sc_slot->slot) +
! 		(addr - gp->sc_handle));    /* XXX evil hack */
! 
    } else {
      return (caddr_t)addr;
    }
+ #endif
+   return (caddr_t)NUBUS_SLOT2PA(gp->sc_slot->slot);
  }
  
  int
***************
*** 211,216 ****
--- 238,252 ----
    struct image_data image;
    struct grfmode *gm;
  
+ #ifdef DEBUG
+   printf("Installing video driver.\n");
+   printf("\tCurrent value of sc_handle: 0x%x\n", sc->sc_handle);
+   if (!sc->sc_handle) return 1;
+ #endif
+ 
+   global_bst = sc->sc_tag;
+   global_bsh = sc->sc_handle;
+   
    /* correct the video params */
    switch(videobitdepth) {
    default:
***************
*** 231,237 ****
    find_video_params(sc, mode, &image);
    gm = sc->sc_grfmode;
    gm->mode_id = mode;
!   gm->fbbase = (caddr_t) (sc->sc_slot->virtual_base + image.offset);
    gm->fboff = image.offset;
    gm->rowbytes = image.rowbytes;
    gm->width = image.right - image.left;
--- 267,273 ----
    find_video_params(sc, mode, &image);
    gm = sc->sc_grfmode;
    gm->mode_id = mode;
!   gm->fbbase = (caddr_t) (sc->sc_handle);
    gm->fboff = image.offset;
    gm->rowbytes = image.rowbytes;
    gm->width = image.right - image.left;
***************
*** 295,300 ****
--- 331,340 ----
    IOParam vid_io_param;
    u_int video_rsrc = (unsigned int)nubus_video_resource(sc->sc_slot->slot);
  
+ #ifdef DEBUG
+   printf ("Opening video driver.\n");
+ #endif
+ 
    if(video_rsrc == -1) video_rsrc = 0x80;
  
    {
***************
*** 305,314 ****
      spb.spSlot = sc->sc_slot->slot;
      spb.spID = 1;
      spb.spParamData = 0;
!     nubus_slot_manager(0x9, &spb);
  
      spb.spID = video_rsrc;
!     nubus_slot_manager(0x9, &spb);
  
  #ifdef DEBUG
      printf("Enabling Resource 0x%02x\n", (unsigned int)spb.spID&0xFF);
--- 345,354 ----
      spb.spSlot = sc->sc_slot->slot;
      spb.spID = 1;
      spb.spParamData = 0;
!     nubus_slot_manager(sc->sc_tag, sc->sc_handle, 0x9, &spb);
  
      spb.spID = video_rsrc;
!     nubus_slot_manager(sc->sc_tag, sc->sc_handle, 0x9, &spb);
  
  #ifdef DEBUG
      printf("Enabling Resource 0x%02x\n", (unsigned int)spb.spID&0xFF);
***************
*** 324,334 ****
      spb.spDrvrHW = 0; /* ignored */
      spb.spHwDev = 0;
  
!     if(!nubus_slot_manager(0x15, &spb)) {
        spb.spID = 0x40;
!       if(!nubus_slot_manager(0x6, &spb)) {
  	spb.spID = 0x80;
! 	if(!nubus_slot_manager(0x5, &spb)) {
  	  printf("%s\n", (char *)(spb.spResult+2));
  
  	  /* 
--- 364,374 ----
      spb.spDrvrHW = 0; /* ignored */
      spb.spHwDev = 0;
  
!     if(!nubus_slot_manager(sc->sc_tag, sc->sc_handle, 0x15, &spb)) {
        spb.spID = 0x40;
!       if(!nubus_slot_manager(sc->sc_tag, sc->sc_handle, 0x6, &spb)) {
  	spb.spID = 0x80;
! 	if(!nubus_slot_manager(sc->sc_tag, sc->sc_handle, 0x5, &spb)) {
  	  printf("%s\n", (char *)(spb.spResult+2));
  
  	  /* 
***************
*** 347,358 ****
      u_int mode;
  
      nubus_get_main_dir(sc->sc_slot, &dir);
!     if(nubus_find_rsrc(sc->sc_slot, &dir, video_rsrc, &dirent) <= 0) return 1;
      nubus_get_dir_from_rsrc(sc->sc_slot, &dirent, &dir);
  
      printf("Possible modes: ");
      for(mode=NUBUS_RSRC_FIRSTMODE;mode<NUBUS_RSRC_SIXTHMODE;mode++) {
!       if(nubus_find_rsrc(sc->sc_slot, &dir, mode, &dirent) <= 0) continue;
        printf(" 0x%02x", mode);
      }
      printf("\n");
--- 387,402 ----
      u_int mode;
  
      nubus_get_main_dir(sc->sc_slot, &dir);
!     if(nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
! 			sc->sc_slot, &dir, video_rsrc, &dirent) <= 0)
! 	 return 1;
      nubus_get_dir_from_rsrc(sc->sc_slot, &dirent, &dir);
  
      printf("Possible modes: ");
      for(mode=NUBUS_RSRC_FIRSTMODE;mode<NUBUS_RSRC_SIXTHMODE;mode++) {
!       if(nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
! 			 sc->sc_slot, &dir, mode, &dirent) <= 0)
! 	 continue;
        printf(" 0x%02x", mode);
      }
      printf("\n");
***************
*** 369,374 ****
--- 413,420 ----
    mrg_drvr_open(&vid_io_param, dce);
    
  #ifdef DEBUG
+   printf("mrg_drvr_open completed\n");
+ 
    if(vid_io_param.ioResult != 0) {
      printf("Can not open the driver(%d)\n", vid_io_param.ioResult);
    } else {
***************
*** 396,421 ****
    int len;
    u_long base, sz;
  
    rsrc = nubus_video_resource(sc->sc_slot->slot);
  
    nubus_get_main_dir(sc->sc_slot, &dir);
  
!   if (nubus_find_rsrc(sc->sc_slot, &dir, rsrc, &dirent) <= 0)
      return 1;
  
    nubus_get_dir_from_rsrc(sc->sc_slot, &dirent, &board_dir);
  
    mode = NUBUS_RSRC_DRVRDIR;
!   if (nubus_find_rsrc(sc->sc_slot, &board_dir, 
! 		      mode, &dirent) <= 0) return 1;
        
    nubus_get_dir_from_rsrc(sc->sc_slot, &dirent, &mode_dir);
  
!   if (nubus_find_rsrc(sc->sc_slot,&mode_dir,
! 		      NUBUS_EXEC_CPU_68020, &dirent) <= 0) return 1;
        
!   if (nubus_get_ind_data(sc->sc_slot, &dirent, 
! 			 (caddr_t) &len, sizeof(len)) <= 0) return 1;
  
    driver = malloc(len, M_DEVBUF, M_NOWAIT);
  
--- 442,479 ----
    int len;
    u_long base, sz;
  
+ #ifdef DEBUG
+   printf("Loading video driver.\n");
+ #endif
+ 
    rsrc = nubus_video_resource(sc->sc_slot->slot);
  
    nubus_get_main_dir(sc->sc_slot, &dir);
  
!   if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle,
! 			sc->sc_slot, &dir, rsrc, &dirent) <= 0) {
      return 1;
+   }
  
    nubus_get_dir_from_rsrc(sc->sc_slot, &dirent, &board_dir);
  
    mode = NUBUS_RSRC_DRVRDIR;
!   if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle, sc->sc_slot, &board_dir, 
! 		      mode, &dirent) <= 0) {
!     return 1;
!   }
        
    nubus_get_dir_from_rsrc(sc->sc_slot, &dirent, &mode_dir);
  
!   if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle, sc->sc_slot,&mode_dir,
! 		      NUBUS_EXEC_CPU_68020, &dirent) <= 0) {
!     return 1;
!   }
        
!   if (nubus_get_ind_data(sc->sc_tag, sc->sc_handle, sc->sc_slot, &dirent, 
! 			 (caddr_t) &len, sizeof(len)) <= 0) {
!     return 1;
!   }
  
    driver = malloc(len, M_DEVBUF, M_NOWAIT);
  
***************
*** 425,431 ****
    printf("Driver at 0x%x\n", (u_int)(driver));
  #endif
      
!   if(nubus_get_ind_data(sc->sc_slot, &dirent, 
  			(caddr_t) driver, len) <= 0) {
      free(driver, M_DEVBUF);
      return 1;
--- 483,489 ----
    printf("Driver at 0x%x\n", (u_int)(driver));
  #endif
      
!   if(nubus_get_ind_data(sc->sc_tag, sc->sc_handle, sc->sc_slot, &dirent, 
  			(caddr_t) driver, len) <= 0) {
      free(driver, M_DEVBUF);
      return 1;
***************
*** 455,476 ****
    dce->dCtlSlotID = nubus_video_resource(sc->sc_slot->slot);
    if(dce->dCtlSlotID==0xFF) dce->dCtlSlotID=0x80;
  
!   dce->dCtlDevBase = base = NUBUS_SLOT_TO_PADDR(sc->sc_slot->slot);
  
  #ifdef DEBUG
    printf("base = 0x%x\n", dce->dCtlDevBase);
  #endif
  
    /* Map NuBus space exactly where it belongs */
! 
!   base = NUBUS_SLOT_TO_PADDR(sc->sc_slot->slot);
    sz = NBMEMSIZE;
    do {
      pmap_enter(pmap_kernel(), base, base, VM_PROT_ALL, FALSE);
      base += NBPG;
      sz -= NBPG;
    } while(sz > 0);
- 
    return 0;
  }
  
--- 513,532 ----
    dce->dCtlSlotID = nubus_video_resource(sc->sc_slot->slot);
    if(dce->dCtlSlotID==0xFF) dce->dCtlSlotID=0x80;
  
!   dce->dCtlDevBase = base = NUBUS_SLOT2PA(sc->sc_slot->slot);
  
  #ifdef DEBUG
    printf("base = 0x%x\n", dce->dCtlDevBase);
  #endif
  
    /* Map NuBus space exactly where it belongs */
!   base = NUBUS_SLOT2PA(sc->sc_slot->slot);
    sz = NBMEMSIZE;
    do {
      pmap_enter(pmap_kernel(), base, base, VM_PROT_ALL, FALSE);
      base += NBPG;
      sz -= NBPG;
    } while(sz > 0);
    return 0;
  }
  
***************
*** 484,509 ****
    nubus_dir mode_dir;
    int rsrc;
  
    nubus_get_main_dir(sc->sc_slot, &mode_dir);
    rsrc = nubus_video_resource(sc->sc_slot->slot);
    if(rsrc == -1) rsrc = 0x80;
  
!   if (nubus_find_rsrc(sc->sc_slot, &mode_dir, rsrc, &dirent) <= 0)
      return 1;
  
    nubus_get_dir_from_rsrc(sc->sc_slot, &dirent, &mode_dir);
  
!   if (nubus_find_rsrc(sc->sc_slot, &mode_dir, mode, &dirent) <= 0)
      return 1;
  
    nubus_get_dir_from_rsrc(sc->sc_slot, &dirent, &mode_dir);
  
!   if (nubus_find_rsrc(sc->sc_slot, &mode_dir, VID_PARAMS, &dirent) <= 0)
      return 1;
    
!   if (nubus_get_ind_data(sc->sc_slot, &dirent, (caddr_t) image,
! 			 sizeof(struct image_data)) <= 0)
      return 1;
    
    return 0;
  }
--- 540,577 ----
    nubus_dir mode_dir;
    int rsrc;
  
+ #ifdef DEBUG
+   printf("Finding video parameters\n");
+ #endif
+ 
    nubus_get_main_dir(sc->sc_slot, &mode_dir);
    rsrc = nubus_video_resource(sc->sc_slot->slot);
    if(rsrc == -1) rsrc = 0x80;
  
!   if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle, sc->sc_slot,
! 			 &mode_dir, rsrc, &dirent) <= 0) {
      return 1;
+   }
  
    nubus_get_dir_from_rsrc(sc->sc_slot, &dirent, &mode_dir);
  
!   if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle, sc->sc_slot,
! 			&mode_dir, mode, &dirent) <= 0) {
      return 1;
+   }
  
    nubus_get_dir_from_rsrc(sc->sc_slot, &dirent, &mode_dir);
  
!   if (nubus_find_rsrc(sc->sc_tag, sc->sc_handle, sc->sc_slot,
! 			&mode_dir, VID_PARAMS, &dirent) <= 0) {
      return 1;
+   }
    
!   if (nubus_get_ind_data(sc->sc_tag, sc->sc_handle, sc->sc_slot,
! 			 &dirent, (caddr_t) image,
! 			 sizeof(struct image_data)) <= 0) {
      return 1;
+   }
    
    return 0;
  }
***************
*** 513,519 ****
       struct grf_softc *gp;
  {
    if(video_console && minor(gp->sc_dev.dv_unit) == minor(video_console->cn_dev)) {
!     videoaddr = NUBUS_SLOT_TO_PADDR(gp->sc_slot->slot) + gp->sc_grfmode->fboff;
      videorowbytes = gp->sc_grfmode->rowbytes;
      videobitdepth = gp->sc_grfmode->psize;
      videosize = ((unsigned long)gp->sc_grfmode->width) |
--- 581,587 ----
       struct grf_softc *gp;
  {
    if(video_console && minor(gp->sc_dev.dv_unit) == minor(video_console->cn_dev)) {
!     videoaddr = NUBUS_SLOT2PA(gp->sc_slot->slot) + gp->sc_grfmode->fboff;
      videorowbytes = gp->sc_grfmode->rowbytes;
      videobitdepth = gp->sc_grfmode->psize;
      videosize = ((unsigned long)gp->sc_grfmode->width) |
***************
*** 604,610 ****
    printf("    planeBytes=%d\n", image.planeBytes);	  
  #endif
  	
!   base = NUBUS_SLOT_TO_PADDR(gp->sc_slot->slot); 
  
    gp->sc_grfmode->mode_id = vdpg.csMode;
    gp->sc_grfmode->fbbase = (caddr_t) (base + image.offset);
--- 672,678 ----
    printf("    planeBytes=%d\n", image.planeBytes);	  
  #endif
  	
!   base = NUBUS_SLOT2PA(gp->sc_slot->slot); 
  
    gp->sc_grfmode->mode_id = vdpg.csMode;
    gp->sc_grfmode->fbbase = (caddr_t) (base + image.offset);
***************
*** 742,748 ****
  	if(!find_video_params(gp, modes_out + NUBUS_RSRC_FIRSTMODE, 
  			      &image)) break;
  	
! 	base = NUBUS_SLOT_TO_PADDR(gp->sc_slot->slot);
    
  	modelist[modes_out].mode_id = modes_out + NUBUS_RSRC_FIRSTMODE;
  	modelist[modes_out].fbbase = (caddr_t) (base + image.offset);
--- 810,816 ----
  	if(!find_video_params(gp, modes_out + NUBUS_RSRC_FIRSTMODE, 
  			      &image)) break;
  	
! 	base = NUBUS_SLOT2PA(gp->sc_slot->slot);
    
  	modelist[modes_out].mode_id = modes_out + NUBUS_RSRC_FIRSTMODE;
  	modelist[modes_out].fbbase = (caddr_t) (base + image.offset);