[comp.sys.amiga.programmer] SCSI Direct

Harvey_Taylor@mindlink.bc.ca (Harvey Taylor) (05/17/91)

    I've been playing with SCSI Direct lately (without documentation)
 & I have some questions. I am trying to talk to a TEAC scsi floppy from
 a Xetec MiniFastCard. These are my results so far.
*
*************************************************************
*       SCSI Commands                   RESULTS
*
*       TEST_UNIT_READY                 $2D BadStatus
*       REQUEST_SENSE                   $2D BadStatus
*       INQUIRY                         $00 TEAC info REV etc
*       READ_CAPACITY                   $2C SelTimeout
*       MODE_SELECT                     $2D BadStatus
*       FORMAT                          $2D BadStatus
*       SEND DIAGNOSTIC  (Self Test)    $2C SelTimeout
*
*       SEND DIAGNOSTIC                 $2C SelTimeout
*       RECEIVE DIAGNOSTIC RESULTS      GURU
*************************************************************
*
    Does anybody happen to know a mapping between the result codes
 & more specific device info? ie. What do all those damn BadStatus results
 mean?

HFERR_SelfUnit          EQU     $00000028
HFERR_DMA               EQU     $00000029
HFERR_Phase             EQU     $0000002A
HFERR_Parity            EQU     $0000002B
HFERR_SelTimeout        EQU     $0000002C
HFERR_BadStatus         EQU     $0000002D
HFERR_NoBoard           EQU     $00000032

    In a .hdr file with the Xetec stuff they show their SCSI_CMD
 structure as having a few more fields than the CBM version.
 Specifically:
*
SCSICmd                 EQU     $00000000
scsi_Data               EQU     $00000000
scsi_Length             EQU     $00000004
scsi_Actual             EQU     $00000008
scsi_Command            EQU     $0000000C
scsi_CmdLength          EQU     $00000010
scsi_CmdActual          EQU     $00000012
scsi_Flags              EQU     $00000014
scsi_Status             EQU     $00000015
*
* Xetec extra below
*
scsi_SenseData          EQU     $00000016
scsi_SenseLength        EQU     $0000001A
scsi_SenseActual        EQU     $0000001C
*
*
    Is anybody else using these? GVP? MicroBotics? Has the CBM spec grown
 or is it just Xetec?
    Finally, in the SCSI_CMD structure, scsi_Flags field what is the
 meaning of (particularly AutoSense):

SCSIF_WRITE             EQU     $00000000
SCSIF_READ              EQU     $00000001
SCSIF_AUTOSENSE         EQU     $00000002

    Any info or thoughts you have would be appreciated.
    -het

   "With the first link, a chain is forged.
    The first speech censured, the first thought forbidden,
    the first freedom denied, chains us all irrevocably." - Satie

        Harvey Taylor      Meta Media Productions
        uunet!van-bc!rsoft!mindlink!Harvey_Taylor
                    a186@mindlink.bc.ca

jesup@cbmvax.commodore.com (Randell Jesup) (05/20/91)

>*************************************************************
>*       SCSI Commands                   RESULTS
>*
>*       TEST_UNIT_READY                 $2D BadStatus
>*       REQUEST_SENSE                   $2D BadStatus
>*       INQUIRY                         $00 TEAC info REV etc
>*       READ_CAPACITY                   $2C SelTimeout
>*       MODE_SELECT                     $2D BadStatus
>*       FORMAT                          $2D BadStatus
>*       SEND DIAGNOSTIC  (Self Test)    $2C SelTimeout
>*
>*       SEND DIAGNOSTIC                 $2C SelTimeout
>*       RECEIVE DIAGNOSTIC RESULTS      GURU
>*************************************************************
>*
>    Does anybody happen to know a mapping between the result codes
> & more specific device info? ie. What do all those damn BadStatus results
> mean?

	Usually that there was some sort of error in the command.  Without
more precise info it's hard to tell.  You need to examine the full scsi
error stuff (and use SCSIF_AUTOSENSE).

>    In a .hdr file with the Xetec stuff they show their SCSI_CMD
> structure as having a few more fields than the CBM version.
> Specifically:
>*
>* Xetec extra below
>*
>scsi_SenseData          EQU     $00000016
>scsi_SenseLength        EQU     $0000001A
>scsi_SenseActual        EQU     $0000001C
>*
>*
>    Is anybody else using these? GVP? MicroBotics? Has the CBM spec grown
> or is it just Xetec?

	It was added to the file when it became a spec a long time ago.
Specify SCSIF_AUTOSENSE to the driver will automatically read the sense
data for you.

>SCSIF_WRITE             EQU     $00000000
>SCSIF_READ              EQU     $00000001

	You must specify one of these to let the driver know which way data
will be transferred.  Some drivers are smart and detect the direction from 
the phase the target goes to, but not all.

-- 
Randell Jesup, Keeper of AmigaDos, Commodore Engineering.
{uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.commodore.com  BIX: rjesup  
Disclaimer: Nothing I say is anything other than my personal opinion.
Thus spake the Master Ninjei: "To program a million-line operating system
is easy, to change a man's temperament is more difficult."
(From "The Zen of Programming")  ;-)

DrBob@cup.portal.com (Robert A Rethemeyer) (05/20/91)

Harvey Taylor writes...

>     I've been playing with SCSI Direct lately (without documentation)
>  & I have some questions. I am trying to talk to a TEAC scsi floppy from
>  a Xetec MiniFastCard. These are my results so far.

First suggestion... get some documentation!  :-)  I recommend going directly
to the source, the ANSI SCSI-1 document X3.131.1986.  Computer book stores
or suppliers should have it.  You won't believe how much it will
clear things up.  You'll kick yourself for not getting it sooner.

>   Does anybody happen to know a mapping between the result codes
> & more specific device info? ie. What do all those damn BadStatus results
> mean?

> HFERR_SelfUnit          EQU     $00000028
You tried to send a scsi command to yourself (usually ID=7)
> HFERR_DMA               EQU     $00000029
Error transferring to memory
> HFERR_Phase             EQU     $0000002A
> HFERR_Parity            EQU     $0000002B
> HFERR_SelTimeout        EQU     $0000002C
All are SCSI bus protocol errors
> HFERR_BadStatus         EQU     $0000002D
Drive is unhappy
> HFERR_NoBoard           EQU     $00000032
Nobody home at the adapter

All the codes except BadStatus are problems detected by the scsi direct
device driver in the Amiga.  BadStatus indicates that the drive returned
"Check Condition" (0x02) in scsi_Status.  This is the drive's way of telling
the programmer that it is unhappy about something.  This includes
errors in the drive hardware, the media, or the scsi command itself.
Probably most of the BadStatus indications you are getting are due
to unsupported commands or illegal bit combinations in the scsi command.

To find out exactly what the drive is unhappy about, you MUST do a
Sense command.  In fact, the drive will usually reject all other
commands until you do the Sense.  Sense will return a 4-bit "sense key" that
generally describes the error.  The keys defined in the SCSI document are:
   0 = No Sense
   1 = Recovered error
   2 = Not ready
   3 = Medium error
   4 = Hardware Error
   5 = Illegal request - includes unknown command, illegal bits, etc.
   6 = Unit Attention
   7 = Data (write) protect
   8 = Blank check (unformatted medium)
   .... other rare keys omitted
A better breakdown of the error reason is also contained in other parts of
the sense data, but it is vendor specific- refer to your drive programming
documentation.

Note- some of the commands you listed are 10-byte commands, not the usual
6 bytes.  If you get this wrong in scsi_CmdLength, that might cause some
of the scsi bus errors you are getting (depends on the adapter and drive).

>    In a .hdr file with the Xetec stuff they show their SCSI_CMD
> structure as having a few more fields than the CBM version.
>    Is anybody else using these? GVP? MicroBotics? Has the CBM spec grown
> or is it just Xetec?

The extentions were defined by CBM, and they allegedly came out with 1.3,
but didn't make it into the includes distributed with the compilers.
They made it into the 2.0 includes.

>    Finally, in the SCSI_CMD structure, scsi_Flags field what is the
> meaning of (particularly AutoSense):

The write/read bit defines the direction of data transfer for commands
that have a data phase.  Read means the data is coming into the Amiga, write
means it is going to the drive. The autosense bit, when one, will cause the
scsi direct driver to automatically issue a Sense when it gets BadStatus/
Check Condition.  scsi_SenseData is a pointer to the buffer to place the
sense data, for up to scsi_SenseLength bytes, and the actual number of sense
bytes is placed in scsi_SenseActual.  Since you always need to do a
Sense after getting BadStatus, this is a nice feature.
Note, you ADD the autosense bit to the read/write bit.

>       Harvey Taylor      Meta Media Productions

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  Bob Rethemeyer                     // "My Sneaker-Phone keeps kicking my
    DrBob@cup.portal.com   -or-     //   Football-Phone off the hook."
..!sun!portal!cup.portal.com!DrBob //                      - Jay Leno

Harvey_Taylor@mindlink.bc.ca (Harvey Taylor) (06/02/91)

    Thankyou to the several folks who answered my earlier questions
 re SCSI Direct. It turns out I was confusing the LUN & the SCSI ID
 & mucking up the CDB. Once I figured out what Inquiry was telling
 me, it was apparent.
    Meanwhile I am still having troubles with MODE_SELECT, SEND_DIAGNOSTIC
 - RECEIVE_DIAGNOSTIC_RESULTS pair & FORMAT. Usually I get ILLEGAL REQUEST
 (or HARDWARE ERROR if I diddle with the Amiga structs).
    Before I get too far into this; I am using an A2000, Xetec FastTrak
 (version 1.48) & a TEAC FD-235JS Scsi floppy. The documentation which I
 don't have, BTW, is for the TEAC controller.

    I am trying to puzzle out the possible failure modes.
    -There may be a problem with the Xetec driver.
    -There may be a problem with the drive hardware. (But it passes
 SEND_DIAGNOSTIC with the Self Test bit set.)
    -There may be some problem with the CDBs I am sending to the
 FC-1. (More likely.)
    -There may be some problem with the sequence of CDBs I send.
    -Maybe I am mucking up the SCSI_CMD & IoRequestBlock.
    -Other failure modes?

    Does anybody know if the Xetec FastTrak SCSI Direct works properly?
 I haven't noticed any effect of setting SCSIF_AUTOSENSE ie. nothing in the
 SenseData buffer.
    To send MODE_SELECT, I have been writing my parameter list to a buffer
 putting the address in scsi_Data, setting the scsi_Flags to SCSIF_WRITE.
 Sound right?
    I suspect I will have to wait for the TEAC docs I ordered to arrive...
 <sigh>
    -het

  "Abstract words are ancient coins whose concrete images in the
    give and take of talk have worn away." -Julian Jaynes

 Harvey Taylor      Meta Media Productions
 uunet!van-bc!rsoft!mindlink!Harvey_Taylor
            a186@mindlink.bc.ca