Hi All,
	Well, it's Friday November 3, and this is last set of 'scu' changes
youall will be seeing for awhile.  With any luck, the "powers to be" will
allow all this stuff into Platinum (Dave Gagne is working these issues).
If not, you know where to find it:

	wasted:~rmiller/nscu.d/{scu,scu.hlp,scu.ksh,mbad.dat,scu.tar.Z}

	I would like to encourage everyone to grab this latest version, and
play with it within the next week.  Submission of this code may go into ptos
BL9 if everything is approved.  It has had limited testing (just me so far).

	Everything originally planned, except user defined SCSI CDB's, has
been implemented (this latter capability may get added later if I'm ambitious
and have some spair time).

	Attached below is a description & examples of the latest changes...

Enjoy,
Robin
================================================================================

	What's New as of November 3, 1995
	---------------------------------
    o	Fixed direct-access error handling for read/write/erase/verify,
	when a media error was reported (also made this common code).
	[ i.e, read of block w/media error, would attempt data compare. ]

    o	Mounted file system check is now done on "eject" command.

    o	When "set timing" is enabled, and multiple commands are executed,
	the command line is displayed prior to each commands' times.

    o	"set nexus" command now accepts target id between (0 - 15).

    o	Added "onerror { continue | stop } command-action" functionality.
	This gives the user control of actions to take when errors occur.

    o	Added sanity check to ensure devget device name matchs the inquiry
	product name.  If the names differ, a warning message is displayed
	and inquiry name used (no more "RZxx", "TZxx", or "RZ28" when the
	device is really an "RZ28D", etc).

    o	Added "show diagnostic pages" cmd to display supported diagnostics.

    o	Fixed bug with overriding user selected page control field (pcf).

    o	Added "set width value" command to set the default display width.
	[ Why? cause when using pipe mode, the screen width isn't known. ]

    o	Added "show audio status/volume" commands to replace RRD42 (Sony)
	specific commands to provide backward compatibility.

    o	Added 'rz_mbad" capability via "mbad lba xxx [ soft | hard ]" cmd.
	[ Supports read/write long sector size and bits to toggle options. ]

    o	Added "dump media" command to display hex byte dump of data read.

    o	Added variables to save CAM and SCSI status codes in and emit these
	with prompt string for shells to interpret when using pipe mode.
	[ 'scu.ksh' Korn shell script now parses these into variables. ]

    o	Added "set compliance {on|off} to control non-compliant error msg.
	By default, this flag is off, and a warning message gets displayed.
	[ BTW:  This command is not documented in the 'scu' help file. ]
	[ NOTE: Fred Knight & I agreed we didn't want to report non-compliant
	  error messages by default, or else customers might enter SPR/CLD's
	  wanting these fixed. (Sorry Roger, you'll have to turn this on)]

    o	Added functions to calculate and report performance statistics.
	[ This reporting is controlled via "set statistics { on | off }" ]
	[ The "show statistics" command can be used after tests complete. ]

    o	A problem with test commands not always exiting with failure status
	after reporting an error has been corrected.  Previously, a failure
	was only reported when the error limit (10) was exceeded, unless the
	last request was in error (which sometimes was not the case, ouch!)

    o	Watch progress mode flag is now disabled by default in interactive
	mode, and changed error limit from 10 to 1 (this was a nuisance).

    o	Added read/write lbdata option (similar to "write same" option).
	[ This option writes the logical block number in the first 4 bytes
          of each disk block on random access devices (long overdue). ]

    o	The bus number is automaticlly setup from the selected device so a
	"set nexus ..." cmd isn't necessary for "xza" commands (for Fred).

    o	Lookup CAM_DEVICE envar to override default /dev/cam device name.
	Added "-c device_entry" option to also override CAM device name.

    o	Added "spid n", "stid n", "slun n" shorthand set nexus commands.
	[ NOTE: The lun field now defaults to 0, since 99% of the time,
	  this is what's desired, so "set nexus pid n tid n" possible. ]

    o	Added sanity check to ensure error recovery page per bit is on,
	otherwise recoverable errors are *not* reported after 'mbad'.
	[ NOTE: Only the active error control page is updated.  You must
	  use "set page error per on" to set and *save* the parameters. ]

    o	Modified "scan edt" so if nexus information is omitted, all SCSI
	buses (0 - 63) are scanned (this was really missing functionality).

	Platinum Changes:
	-----------------
    o	Merged in Carolyn_Briglia's changes for SCAN BUS/LUN CCB's.

    o	Added attempting DEVGETINFO ioctl() before using DEVIOVGET.
	[ BTW: Jim, I stole the code you had added to the 'file' utility. ]

    o	Enhanced "show path" to display supported HBA targets & luns.

    o	Made runtime changes, based on operating system version string,
	to ensure Platinum 'scu' runs successfully on all O/S versions.
	[ Please let me know if you find any problem here folks. ]

	'scu' Size Increase?
	--------------------
	Considering the amount of new functionality, not too shabby if you
ask me (thank-you... as he pats himself on the back).  These sizes are from
using 'acc', and may be less with DECC (supposed to be better optimization).

	metabol% size scu
	text    data    bss     dec     hex
	548864  212992  86576   848432  cf230
	metabol% size /sbin/scu-V3.2                                                    
	text    data    bss     dec     hex
	540672  196608  91696   828976  ca630
	metabol% scu eval 848432-828976
	Expression Values:

	          Decimal: 19456
	      Hexadecimal: 0x4c00
	  512 byte Blocks: 38.000000
	        Kilobytes: 19.000000
	        Megabytes: 0.018555
	        Gigabytes: 0.000018
	metabol% 
	metabol% strip scu
	metabol% ls -ls scu                                                             
	752 -rwxr-xr-x   1 rmiller  system    761856 Nov  3 12:09 scu*
	metabol% ls -ls /sbin/scu-V3.2                                                  
	728 -rwxr-xr-x   1 bin      bin       737280 Feb  3  1995 /sbin/scu-V3.2*
	metabol% 

	Hey, I'm impressed by DECC's optimization (-O2 used here):

	% strip scu
	% size scu
	text    data    bss     dec     hex
	532480  204800  79264   816544  c75a0
	% scu eval 828976-816544
	Expression Values:

	            Decimal: 12432
	        Hexadecimal: 0x3090
	    512 byte Blocks: 24.281250
	          Kilobytes: 12.140625
	          Megabytes: 0.011856
	          Gigabytes: 0.000012
	% ls -ls scu
	728 -rwxr-xr-x   1 rmiller  users     737280 Nov  3 16:43 scu*
	% 

	The Platinum size is actually smaller than the V3.2 sizes!!!

================================================================================

imfaster% scu -f /dev/rrz10c
Warning: Inquiry (RZ28D) and system (RZ28) device names are different.
scu> show nexus
Device: RZ28D, Bus: 1, Target: 2, Lun: 0, Type: Direct Access
scu>

--------------------------------------------------------------------------------

scu> show nexus
Device: RZ28, Bus: 0, Target: 0, Lun: 0, Type: Direct Access
scu> ! disklabel rz0
Invalid disk label (label is corrupted, or disk is unlabeled)
scu> show capacity

Disk Capacity Information:

                  Maximum Capacity: 4110480 (2007.070 megabytes)
                      Block Length: 512

scu> write media starting 4110000 popts lbdata
Writing 480 blocks (4110000 - 4110479) on /dev/rrz0c (RZ28) with pattern 0x39c39c39...
scu> dump media lba 4110000
Reading 1 block (4110000 - 4110000) on /dev/rrz0c (RZ28)...

Record Number 1 (Starting Block 4110000)

00000000  00 3e b6 b0 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000028  39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000056  39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000084  39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000112  39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000140  39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000168  39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000196  39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000224  39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000252  39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000280  39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000308  39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000336  39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000364  39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000392  39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000420  39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000448  39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000476  39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 39 9c c3 39 
00000504  39 9c c3 39 39 9c c3 39 
scu> eval 0x003eb6b0
Expression Values:

            Decimal: 4110000
        Hexadecimal: 0x3eb6b0
    512 byte Blocks: 8027.343750
          Kilobytes: 4013.671875
          Megabytes: 3.919601
          Gigabytes: 0.003828
scu> read media starting 4110000 popts lbdata
Reading 480 blocks (4110000 - 4110479) on /dev/rrz0c (RZ28) using pattern 0x39c39c39...
scu> 
scu> set timing on
scu> stop ; start ; tur
< stop >
Elapsed time: 00m05.96s, System time: 00m00.00s, User time: 00m00.00s
< start >
Elapsed time: 00m09.61s, System time: 00m00.00s, User time: 00m00.01s
< tur >
Elapsed time: 00m00.00s, System time: 00m00.00s, User time: 00m00.00s
scu> 
scu> set timing off
scu> show diagnostic pages

Diagnostic Pages Supported by Device /dev/rrz0c (RZ28):

             Supported Diagnostics Page (Code = 0x00)
                 Translate Address Page (Code = 0x40)

scu> mbad lba 4110400
Making SOFT Error @ Logical Block 4110400 on device /dev/rrz0c (RZ28)...
scu> mbad lba 4110400 hard
Making HARD Error @ Logical Block 4110400 on device /dev/rrz0c (RZ28)...
Warning: Reading lba 4110400 did NOT report the expected HARD Error!
scu> write media lba 4110400
Writing 1 block (4110400 - 4110400) on /dev/rrz0c (RZ28) with pattern 0x39c39c39...
scu> mbad lba 4110400 hard
Making HARD Error @ Logical Block 4110400 on device /dev/rrz0c (RZ28)...
scu> read media lba 4110400 compare off
Reading 1 block (4110400 - 4110400) on /dev/rrz0c (RZ28)...
scu: Read error at logical block number 4110400 (0x3eb840).
scu: Sense Key = 0x3 = MEDIUM ERROR - Nonrecoverable medium error,
     Sense Code/Qualifier = (0x11, 0) = Unrecovered read error
scu: Error number 1 occurred on Fri Nov  3 14:04:00 1995
scu> 
scu> read media bs 1m limit 10m compare off
Reading 20480 blocks (0 - 20479) on /dev/rrz0c (RZ28)...
scu> show stats

Total Statistics:

            Device Name/Type: RZ28 (Direct Access)
           Nexus Information: Bus 0, Target 0, Lun 0
     Total Records Processed: 10 @ 1048576 bytes/record, 1 partial
     Total Bytes Transferred: 10485760 (10240.000 Kbytes, 10.000 Mbytes)
      Average Transfer Rates: 4695116 bytes/sec, 4585.075 Kbytes/sec
      Total Passes Completed: 1/1
       Total Errors Detected: 0/1
          Total Elapsed Time: 00m02.23s
           Total System Time: 00m00.05s
             Total User Time: 00m00.13s
               Starting time: Fri Nov  3 14:04:58 1995
                 Ending time: Fri Nov  3 14:05:00 1995

scu> set stats on
scu> read media bs 1m limit 100m compare off
Reading 204800 blocks (0 - 204799) on /dev/rrz0c (RZ28)...

Total Statistics:

            Device Name/Type: RZ28 (Direct Access)
           Nexus Information: Bus 0, Target 0, Lun 0
     Total Records Processed: 100 @ 1048576 bytes/record, 1 partial
     Total Bytes Transferred: 104857600 (102400.000 Kbytes, 100.000 Mbytes)
      Average Transfer Rates: 4777112 bytes/sec, 4665.148 Kbytes/sec
      Total Passes Completed: 1/1
       Total Errors Detected: 0/1
          Total Elapsed Time: 00m21.95s
           Total System Time: 00m00.60s
             Total User Time: 00m01.36s
               Starting time: Fri Nov  3 14:06:17 1995
                 Ending time: Fri Nov  3 14:06:39 1995

scu> stid 4
Device: RRD43, Bus: 0, Target: 4, Lun: 0, Type: Read-Only Direct Access
scu> quit
% 

--------------------------------------------------------------------------------

metabol% scu -f /dev/rrz4c
scu> show inquiry pages supported
Warning: The Vital Product Page option is NOT supported by device 'RRD42'.
scu> set compliance on
scu> show inquiry pages supported
scu: ERROR: The Vital Product Page data on device 'RRD42' is NOT SCSI compliant!
scu> 

--------------------------------------------------------------------------------

scu> set watch off
scu> read media bs 64k limit 11m errors 1
Reading 22528 blocks (0 - 22527) on /dev/rrz0c (RZ28) using pattern 0x39c39c39...
scu: Error number 1 occurred on Fri Oct 27 16:37:16 1995
scu: Data compare error at byte 0 in record number 161
scu: Logical block number where error occured is 20480
scu: Data expected = 0x39, data found = 0xdd, byte count = 65536
scu: The incorrect data starts at address 0x140064000 (marked by asterisk '*')
scu: Dumping Data Buffer (base = 0x140064000, offset = 0, limit = 512 bytes):

0x140064000 *dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x140064018  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x140064030  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x140064048  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x140064060  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x140064078  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x140064090  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x1400640a8  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x1400640c0  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x1400640d8  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x1400640f0  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x140064108  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x140064120  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x140064138  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x140064150  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x140064168  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x140064180  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x140064198  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x1400641b0  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x1400641c8  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x1400641e0  dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa dd cc bb aa
0x1400641f8  dd cc bb aa dd cc bb aa

scu> 

--------------------------------------------------------------------------------

% scu show path

Path Inquiry Information:

    Version Number For The SIM/HBA: 4.12
       SCSI HBA Capabilities Flags: 0x12
                                    0x10 = Supports SDTR message.
                                    0x2 = Supports tag queue message.
         Target Mode Support Flags: 0
   Miscellaneous HBA Feature Flags: 0
              The HBA Engine Count: 0
          Targets Supported by HBA: 8
             LUNs Supported by HBA: 8
        Vendor Unique Capabilities: 0 0 0 0 0 0 0 0 0 0 0 0
     Size of SIM Private Data Area: 56
       Async Callback Capabilities: 0xf3 Reasons for generating async event:
                                    0x80 = New devices found during rescan.
                                    0x40 = SIM module de-registered.
                                    0x20 = SIM module registered.
                                    0x10 = Sent bus device reset to target.
                                    0x2 = Unsolicited reselection.
                                    0x1 = Unsolicited SCSI bus reset.
      Highest HBA Path ID Assigned: 0
       SCSI Device ID of Initiator: 6
          The Vendor ID of the SIM: DEC OSG BSD/V1
          The Vendor ID of the HBA: DEC WSE BSD/V1
             The OSD Usage Pointer: 0

% 

--------------------------------------------------------------------------------

% ksh
$ . scu.ksh
[1]	6406
$ scu sw /dev/rrz0c
Switching to device entry /dev/rrz0c (RZ28)...
$ scu stop immed
$ scu tur
scu: 'test unit ready' failed, EIO (5) - I/O error
scu: Sense Key = 0x2 = NOT READY - Logical unit is NOT ready,
     Sense Code/Qualifier = (0x4, 0x2) = Logical unit not ready, initializing command required
$ echo $?
5
$ print $CamStatus
4
$ print $ScsiStatus
2
$ print $SenseCode
112
$ printf "%#x\n" $SenseCode
0x70
$ print $SenseKey
2
$ print $SenseAscq
1026
$ printf "Sense Code = %#x, Additional Sense Code/Qualifier = %#x\n" $SenseCode $SenseAscq
Sense Code = 0x70, Additional Sense Code/Qualifier = 0x402
$ scu start immed
$ scu tur
scu: 'test unit ready' failed, EIO (5) - I/O error
scu: Sense Key = 0x2 = NOT READY - Logical unit is NOT ready,
     Sense Code/Qualifier = (0x4, 0x1) = Logical unit is in process of becoming ready
$ print $SenseAscq
1025
$ printf "%#x\n" $SenseAscq
0x401
$ fgrep 0x0401 io/cam/scsi_all.h
#define	ASCQ_LUN_NRDY_INPROG	 0x0401 
$ scu tur
$ scu exit
[1] +  Done                    . scu.ksh
$ exit
% 
