Autoconfig

Chris Torek chris at mimsy.UUCP
Fri Jul 1 07:13:12 AEST 1988


In article <5699 at csl.CSL.SRI.COM> aida at porthos.csl.sri.com (Hitoshi Aida)
writes:
>The problem [that causes finding a controller twice] is "the standard
>addresses" embedded in the driver. ...
>I think the best solution is to never use standard addresses.

This works, but is not the best solution (else why have standard
addresses at all?).  Instead, fix the bug in autoconf.c.  Here is
one with just that fix, created only moments ago.  This is untested,
but it did come from a version that is tested.  All of these changes
(and many more) appear in the 4.3-tahoe vax/autoconf.c.

*** autoconf.c.old	Thu Jun 30 16:57:09 1988
--- autoconf.c	Thu Jun 30 17:09:06 1988
***************
*** 4,8 ****
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)autoconf.c	7.1 (Berkeley) 6/6/86
   */
  
--- 4,8 ----
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)autoconf.c	7.1+ (Berkeley) 6/6/86
   */
  
***************
*** 687,701 ****
  		}
  		printf("vec %o, ipl %x\n", cvec, br);
  		um->um_alive = 1;
  		um->um_ubanum = numuba;
! 		um->um_hd = &uba_hd[numuba];
  		um->um_addr = (caddr_t)reg;
  		udp->ud_minfo[um->um_ctlr] = um;
! 		for (ivec = um->um_intr; *ivec; ivec++) {
! 			um->um_hd->uh_vec[cvec/4] =
! 			    scbentry(*ivec, SCB_ISTACK);
! 			cvec += 4;
! 		}
  		for (ui = ubdinit; ui->ui_driver; ui++) {
  			if (ui->ui_driver != udp || ui->ui_alive ||
  			    ui->ui_ctlr != um->um_ctlr && ui->ui_ctlr != '?' ||
--- 687,701 ----
  		}
  		printf("vec %o, ipl %x\n", cvec, br);
+ 		csralloc(ualloc, addr, i);
  		um->um_alive = 1;
  		um->um_ubanum = numuba;
! 		um->um_hd = uhp;
  		um->um_addr = (caddr_t)reg;
  		udp->ud_minfo[um->um_ctlr] = um;
! 		for (cvec /= 4, ivec = um->um_intr; *ivec; cvec++, ivec++)
! 			uhp->uh_vec[cvec] = scbentry(*ivec, SCB_ISTACK);
  		for (ui = ubdinit; ui->ui_driver; ui++) {
+ 			int t;
+ 
  			if (ui->ui_driver != udp || ui->ui_alive ||
  			    ui->ui_ctlr != um->um_ctlr && ui->ui_ctlr != '?' ||
***************
*** 702,710 ****
  			    ui->ui_ubanum != numuba && ui->ui_ubanum != '?')
  				continue;
! 			if ((*udp->ud_slave)(ui, reg)) {
  				ui->ui_alive = 1;
- 				ui->ui_ctlr = um->um_ctlr;
  				ui->ui_ubanum = numuba;
! 				ui->ui_hd = &uba_hd[numuba];
  				ui->ui_addr = (caddr_t)reg;
  				ui->ui_physaddr = pumem + ubdevreg(addr);
--- 702,713 ----
  			    ui->ui_ubanum != numuba && ui->ui_ubanum != '?')
  				continue;
! 			t = ui->ui_ctlr;
! 			ui->ui_ctlr = um->um_ctlr;
! 			if ((*udp->ud_slave)(ui, reg) == 0)
! 				ui->ui_ctlr = t;
! 			else {
  				ui->ui_alive = 1;
  				ui->ui_ubanum = numuba;
! 				ui->ui_hd = uhp;
  				ui->ui_addr = (caddr_t)reg;
  				ui->ui_physaddr = pumem + ubdevreg(addr);
***************
*** 716,723 ****
  				/* ui_type comes from driver */
  				udp->ud_dinfo[ui->ui_unit] = ui;
! 				printf("%s%d at %s%d slave %d\n",
  				    udp->ud_dname, ui->ui_unit,
  				    udp->ud_mname, um->um_ctlr, ui->ui_slave);
  				(*udp->ud_attach)(ui);
  			}
  		}
--- 719,727 ----
  				/* ui_type comes from driver */
  				udp->ud_dinfo[ui->ui_unit] = ui;
! 				printf("%s%d at %s%d slave %d",
  				    udp->ud_dname, ui->ui_unit,
  				    udp->ud_mname, um->um_ctlr, ui->ui_slave);
  				(*udp->ud_attach)(ui);
+ 				printf("\n");
  			}
  		}
***************
*** 768,779 ****
  		}
  		printf("vec %o, ipl %x\n", cvec, br);
! 		while (--i >= 0)
! 			ualloc[ubaoff(addr+i)] = 1;
! 		ui->ui_hd = &uba_hd[numuba];
! 		for (ivec = ui->ui_intr; *ivec; ivec++) {
! 			ui->ui_hd->uh_vec[cvec/4] =
! 			    scbentry(*ivec, SCB_ISTACK);
! 			cvec += 4;
! 		}
  		ui->ui_alive = 1;
  		ui->ui_ubanum = numuba;
--- 772,779 ----
  		}
  		printf("vec %o, ipl %x\n", cvec, br);
! 		csralloc(ualloc, addr, i);
! 		ui->ui_hd = uhp;
! 		for (cvec /= 4, ivec = ui->ui_intr; *ivec; cvec++, ivec++)
! 			uhp->uh_vec[cvec] = scbentry(*ivec, SCB_ISTACK);
  		ui->ui_alive = 1;
  		ui->ui_ubanum = numuba;
***************
*** 815,818 ****
--- 815,843 ----
  
  	wmemfree(ualloc, 8*1024);
+ }
+ 
+ /*
+  * Mark addresses starting at "addr" and continuing
+  * "size" bytes as allocated in the map "ualloc".
+  * Warn if the new allocation overlaps a previous allocation.
+  */
+ static
+ csralloc(ualloc, addr, size)
+ 	caddr_t ualloc;
+ 	u_short addr;
+ 	register int size;
+ {
+ 	register caddr_t p;
+ 	int warned = 0;
+ 
+ 	p = &ualloc[ubaoff(addr+size)];
+ 	while (--size >= 0) {
+ 		if (*--p && !warned) {
+ 			printf(
+ 	"WARNING: device registers overlap those for a previous device!\n");
+ 			warned = 1;
+ 		}
+ 		*p = 1;
+ 	}
  }
  
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.wizards mailing list