power sequencing patch for ST-01 BETA

Derek E. Terveer det at hawkmoon.MN.ORG
Tue Jan 15 20:44:14 AEST 1991


Here is the power sequencing patch for the recently posted st-01 beta driver
(posted by mike at cimcor.mn.org)  This power sequencing code works for me on my
esix 5.3.2-d system running a wren iv.  Your milage may vary.  If anyone can
tell me why i can't get the power down code at shutdown time to work, please
let me know!  (i'm no scsi expert, you see)


*** scsi.c.old	Sun Jan 13 20:53:57 1991
--- scsi.c	Tue Jan 15 02:28:03 1991
***************
*** 25,34 ****
  #include <sys/proc.h>
  #include <sys/strlog.h>
  #include <sys/vtoc.h>
  #include "st01.h"
  #include "scommands.h"
! #define COPYRIGHT "scsi disk driver V2.0"
  
  #define ASM   /* use certain routines coded in assembly */
  
  #define TICKSPERSECOND HZ /* system timer ticks per second */
--- 25,42 ----
  #include <sys/proc.h>
  #include <sys/strlog.h>
  #include <sys/vtoc.h>
+ #include <sys/scsi.h>
  #include "st01.h"
  #include "scommands.h"
! #define	then
! #define FALSE 0
! #define FAIL 0
! #define TRUE 1
! #define SUCCESS 1
! char *pid="st01: ";             /* this program's identification */
  
+ #define COPYRIGHT "scsi disk driver V2.1"
+ 
  #define ASM   /* use certain routines coded in assembly */
  
  #define TICKSPERSECOND HZ /* system timer ticks per second */
***************
*** 1183,1188 ****
--- 1191,1265 ----
    return 1;
  }
  
+ /*******************************************************************************
+  *									       *
+  *				start_unit()				       *
+  *									       *
+  ******************************************************************************/
+ 
+ 
+ /* This starts/stops the motor on a drive.
+  */
+ 
+ static int
+ start_unit(unit,start)
+ 
+ 	int			unit;
+ 	int			start;		/* true if start, else stop */
+ 
+ {
+  	int			cc;
+ 	char			cmd[6];
+ 
+ #if defined(DEBUG)
+   printf("start_unit(%d,st%s)\n",unit,start?"art":"op");
+ #endif
+ 
+   cmd[0]=SS_ST_SP;
+   cmd[1]=unit<<5 + start?0:1;	/* return status immediately if stop */
+   cmd[2]=0;
+   cmd[3]=0;
+   cmd[4]=start?1:0;		/* turn motor on or off */
+   cmd[5]=0;
+ 
+   cc=doscsicmd(unit,cmd,NULL,0,start?250:10,2,0,0,0,NULL);
+   if (cc!=COK && cc!=CDISCONNECT) {
+ 	printf("%scouldn't st%s unit %d! (%d)\n",pid,start?"art":"op",unit,cc);
+ 	return(FAIL);
+   }
+   return(SUCCESS);
+ }  /* start_unit */
+ 
+ /*******************************************************************************
+  *									       *
+  *				scsihalt()				       *
+  *									       *
+  * This routine is *not* called during reboot operations, i.e., init 5 or init *
+  * 6.  Only when init 0 is invoked.					       *
+  *									       *
+  ******************************************************************************/
+ 
+ 
+ extern
+ scsihalt()
+ 
+ {	long			l;
+ 	int			unit;
+ 
+  /* stop all drives
+   */
+ 
+ #if defined(DEBUG)
+  printf("scsihalt()\n");
+ #endif
+ 
+  for (unit=0; unit<SCSIMAXDRIVES; ++unit) 
+   {if (d[unit].blocksize) start_unit(unit,FALSE);	/* spin drive down */
+   }  /* each drive */
+  return(SUCCESS);
+ }  /* scsihalt */
+ 
+ 
  /* This is used to initialize the drive at system startup time */
  
  static initdrive(unit)
***************
*** 1199,1204 ****
--- 1276,1309 ----
    d[unit].nparts=0;
    d[unit].nomsgs=0;
  
+ #if !defined(OLD_START)
+   {int newline=FALSE;
+    a=!COK;
+    for (bs=2; bs && a!=COK; --bs)
+     {a=testready(unit);
+      if (a == COK)
+        then break;
+        else
+ 	{if (a!=CERROR && a!=CBUSY) return FAIL; /* no point in waiting */
+ 	 start_unit(unit,TRUE);
+ 	 if (testready(unit)!=COK) {
+ 	     printf("\tWaiting for unit %d powerup",unit);
+ 	     newline=TRUE;
+ 	     for (l=0;l<10000000l;l++)
+ 	       if (l % 100000l == 0) {
+ 		   printf(".");
+ 		   a=testready(unit);
+ 		   if (a == COK) break;
+ 	       }  /* test again, every so often */
+ 	     if (a != COK) printf("\n%sPowerup timeout on drive %d",pid,unit);
+ 	 }  /* not ready after start */
+        }  /* not ready */
+     }  /* try twice */
+    if (newline) printf("\n");
+   }  /* scope of newline */
+   if (a!=COK) return FAIL;
+ 
+ #else
    a=testready(unit);
    if (a != COK)
      {
***************
*** 1218,1223 ****
--- 1323,1330 ----
            return 0;
          }
      }
+ #endif
+ 
    a=requestsense(unit,buf,sizeof(buf),1);
    if (a == CNOCONNECT || a == CBUSBUSY)
      return 0;
***************
*** 1355,1361 ****
  scsiclose()
  {
  #ifdef DEBUG0
!   strlog(0, unit, 0, SL_ERROR, "scsiclose called\n");
  #endif
    /* do nothing */
  }
--- 1462,1468 ----
  scsiclose()
  {
  #ifdef DEBUG0
!   strlog(0, 0, 0, SL_ERROR, "scsiclose called\n");
  #endif
    /* do nothing */
  }
***************
*** 1364,1370 ****
  scsiprint()
  {
  #ifdef DEBUG
!   strlog(0, unit, 0, SL_ERROR, "scsiprint called\n");
  #endif
    /* do nothing */
  }
--- 1471,1477 ----
  scsiprint()
  {
  #ifdef DEBUG
!   strlog(0, 0, 0, SL_ERROR, "scsiprint called\n");
  #endif
    /* do nothing */
  }
*** README1.old	Mon Jan 14 03:36:21 1991
--- README1	Tue Jan 15 03:35:17 1991
***************
*** 42,44 ****
--- 42,65 ----
  Many of the hd(7) ioctls are now supported including support
  for the ESIX/BSD fast file system.
  
+ ** Motor start option added by det at hawkmoon.mn.org **
+ This patched version of the heavily modified st-01 driver (mike at cimcor.mn.org)
+ will attempt to start the drives' motors if initial access attempts fail at boot
+ time.  If the drive is already started you will see no difference in the
+ driver's operation.  Obviously, this attempt will only work for drives that
+ have a motor start option (like most (all?) Wren SCSI drives have).  This code
+ has only been tested on a Wren IV.  If the drive does not have a motor start
+ option and the drive is not on, the code will eventually time out on the
+ attempt to access the drive, just like the original code -- so no hard should
+ come from having this code in the driver.  If however, you don't wish to
+ incorporate the motor start option code, simply add the "-DOLD_START" flag to
+ CFLAGS in the Makefile.
+ 
+ What is the advantage in this?  This provides power sequencing of the drives at
+ boot time.  Instead of having all of your drives starting at the same time and
+ drawing a large amount of current, each drive is started and initialized before
+ the next drive.  The code is also supposed to power down the drives when a
+ system shut down is performed, i.e., "init 0", not just a reboot (e.g., init 5).
+ However, it doesn't appear to be shutting down the drives... sigh.  (:-(
+ To enable the (attempted) drive power-down at shut down time, add the "h" to
+ the second column in the /etc/conf/cf.d/mdevice for the "scsi" driver.
*** Makefile.old	Mon Jan 14 03:37:13 1991
--- Makefile	Mon Jan 14 04:31:00 1991
***************
*** 6,12 ****
  #
  #
  
! CFLAGS = -O #-DDEBUG # -DDEBUG0
  
  all: scsi.o scsiasm.o scsipart verify
  	ld -r -o Driver.o scsi.o scsiasm.o
--- 6,13 ----
  #
  #
  
! CFLAGS = -O #-DDEBUG #-DDEBUG0  # -DOLD_START
! CC=/bin/cc
  
  all: scsi.o scsiasm.o scsipart verify
  	ld -r -o Driver.o scsi.o scsiasm.o
*** Master.old	Mon Jan 14 03:36:40 1991
--- Master	Sun Jan 13 21:51:01 1991
***************
*** 1 ****
! scsi	Iiocrw	ibHc		scsi	0	0	1	15	-1
--- 1 ----
! scsi	Iiocrwh	ibHc		scsi	0	0	1	15	-1
-- 
Derek "Tigger" Terveer	det at hawkmoon.MN.ORG - MNFHA, NCS - UMN Women's Lax, MWD
I am the way and the truth and the light, I know all the answers; don't need
your advice.  -- "I am the way and the truth and the light" -- The Legendary Pink Dots



More information about the Comp.unix.sysv386 mailing list