Subject: More than 4 MSCP+TMSCP controllers fails (#402)
Index:	pdp/tmscp.h,machdep2.c 2.11BSD

Description:
	The kernel is hardcoded to only support 2 MSCP and 2 TMSCP controllers.

Repeat-By:
	Have 3 TMSCP and 2 MSCP controllers in the system.  The 3rd TMSCP
	controller will fail to 'attach' at autoconfigure/probe time because
	the memory arena used to map the MSCP packet region is exhausted.

	An Emulex UC08 contains two controllers as does the CMD440.  If you also
	have a TQK50 present in the system the kernel will refuse to configure
	the 3rd controller.

Fix:
	pdp/machdep2.c had to include 'tms.h' and 'ra.h' to know if [T]MSCP
	controllers were present in the kernel.  The symbols 'NRAC' and
	'NTMSCP' contain the number of MSCP and TMSCP controllers.  Rather
	than using a hardcoded '2' the names 'NRAC' and 'NTMSCP' are used.

	To apply this small change cut where indicated and save to a file
	(/tmp/402).  Then:

		patch -p0 < /tmp/402

	If you have 2 or fewer [T]MSCP controllers there is no need to
	recompile the kernel at this time.   However nothing will break if you
	feel the urge to remake the kernel.

	As always this and previous updates to 2.11BSD are available via
	anonymous FTP to either FTP.IIPO.GTEGSC.COM or MOE.2BSD.COM in the
	directory /pub/2.11BSD.

==============================cut here========================
*** /usr/src/sys/pdp/tmscp.h.old	Mon Mar  2 21:30:13 1998
--- /usr/src/sys/pdp/tmscp.h	Mon Feb 23 20:37:39 1998
***************
*** 1,10 ****
! /*	@(#)tmscp.h	1.1 (2.11BSD) 1995/12/12 */
  
- /*
-  *	@(#)tmscp.h	1.3	10/21/85
-  * Definitions for the Tape Mass Storage Control Protocol
-  */
- 
  /****************************************************************
   *                                                              *
   *        Licensed from Digital Equipment Corporation           *
--- 1,5 ----
! /*	@(#)tmscp.h	1.2 (2.11BSD) 1998/2/23 */
  
  /****************************************************************
   *                                                              *
   *        Licensed from Digital Equipment Corporation           *
***************
*** 29,36 ****
   *								*
   ****************************************************************
   *
!  * Modification history: /sys/pdp/tmscp.h
   *
   * 12-Dec-95 - sms
   *	Begin process of moving definitions common to MSCP and TMSCP into
   *	a different include file.  Define additional flags for the (heavily)
--- 24,42 ----
   *								*
   ****************************************************************
   *
!  * Modification history:
   *
+  * 23-Feb-98 - sms
+  *	The version number and revision history were accidentally omitted
+  *	when update #401 was prepared (29-Jan-98).
+  *
+  *	Rearrange and clarify tmscp packet structure.  It was apparently
+  *	possible for the 'mscp_dscptr' field to be overwritten with status
+  *	information by the controller.  The 'm_filler' field was not used,
+  *	no longer needed and in fact was just wasting 6 bytes of space.  It
+  *	was removed.  The per controller structure is now 1864 bytes instead
+  *	of 1896.
+  *
   * 12-Dec-95 - sms
   *	Begin process of moving definitions common to MSCP and TMSCP into
   *	a different include file.  Define additional flags for the (heavily)
***************
*** 48,54 ****
  #include <machine/mscp_common.h>
  
  /*
!  * An MSCP packet
   */
   
  struct mscp {
--- 54,63 ----
  #include <machine/mscp_common.h>
  
  /*
!  * A TMSCP packet. 
!  *
!  * WARNING!  If this structure grows be sure to change the '1864' in the
!  * file pdp/machdep2.c!!!
   */
   
  struct mscp {
***************
*** 228,234 ****
  	struct tmscpca	tmscp_ca;         /* communications area */
  	struct mscp	tmscp_rsp[NRSP];  /* response packets */
  	struct mscp	tmscp_cmd[NCMD];  /* command packets */
! };					  /* 1896 bytes per controller! */
  
  /*
   * Per drive information structure.
--- 237,243 ----
  	struct tmscpca	tmscp_ca;         /* communications area */
  	struct mscp	tmscp_rsp[NRSP];  /* response packets */
  	struct mscp	tmscp_cmd[NCMD];  /* command packets */
! };					  /* 1864 bytes per controller! */
  
  /*
   * Per drive information structure.
*** /usr/src/sys/pdp/machdep2.c.old	Mon Mar  2 21:30:09 1998
--- /usr/src/sys/pdp/machdep2.c	Mon Mar  2 21:33:46 1998
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)machdep2.c	2.7 (2.11BSD GTE) 1996/9/14
   */
  
  #include "param.h"
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)machdep2.c	2.8 (2.11BSD) 1998/3/2
   */
  
  #include "param.h"
***************
*** 45,51 ****
  #if	NRAC > 0 || NTMSCP > 0
  memaddr	_iostart, _iobase;
  ubadr_t	_ioumr;
! u_short	_iosize = 2 * (1928 + 1096 + 128);  /* enough for 2 TMSCP and 2 MSCP */
  #endif
  
  #ifdef	SOFUB_MAP
--- 45,51 ----
  #if	NRAC > 0 || NTMSCP > 0
  memaddr	_iostart, _iobase;
  ubadr_t	_ioumr;
! u_short	_iosize = ((NTMSCP * (ctob(btoc(1864)))) + (NRAC * (ctob(btoc(1096)))));
  #endif
  
  #ifdef	SOFUB_MAP
***************
*** 214,220 ****
  #if	NRAC > 0 || NTMSCP > 0
  	if ((_iobase = malloc(coremap, btoc(_iosize))) == 0)
  		panic("_iobase");
! #endif	NRAC
  
  #define B	(size_t)(((long)nbuf * (MAXBSIZE)) / ctob(1))
  	if ((bpaddr = malloc(coremap, B)) == 0)
--- 214,220 ----
  #if	NRAC > 0 || NTMSCP > 0
  	if ((_iobase = malloc(coremap, btoc(_iosize))) == 0)
  		panic("_iobase");
! #endif
  
  #define B	(size_t)(((long)nbuf * (MAXBSIZE)) / ctob(1))
  	if ((bpaddr = malloc(coremap, B)) == 0)
***************
*** 372,378 ****
  		ubp++;
  		paddr += (ubadr_t)UBPAGE;
  	}
! #endif	NRAC
  }
  
  int waittime = -1;
--- 372,378 ----
  		ubp++;
  		paddr += (ubadr_t)UBPAGE;
  	}
! #endif
  }
  
  int waittime = -1;
***************
*** 492,498 ****
  	{
  	return(((ubadr_t)(addr - _iostart) << 6) + _ioumr);
  	}
! #endif NRAC
  
  #define	NLABELS	6
  
--- 492,498 ----
  	{
  	return(((ubadr_t)(addr - _iostart) << 6) + _ioumr);
  	}
! #endif
  
  #define	NLABELS	6
  
*** /VERSION.old	Fri Jan 30 22:45:45 1998
--- /VERSION	Mon Mar  2 21:33:59 1998
***************
*** 1,5 ****
! Current Patch Level: 401
! Date: January 30, 1998
  
  2.11 BSD
  ============
--- 1,5 ----
! Current Patch Level: 402
! Date: March 2, 1998
  
  2.11 BSD
  ============
