home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / Includes_and_Autodocs_3.5 / include / devices / scsidisk.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-20  |  5.1 KB  |  140 lines

  1. #ifndef    DEVICES_SCSIDISK_H
  2. #define    DEVICES_SCSIDISK_H
  3. /*
  4. **    $VER: scsidisk.h 44.1 (17.04.1999)
  5. **    Includes Release 44.1
  6. **
  7. **    SCSI exec-level device command
  8. **
  9. **    (C) Copyright 1988-1999 Amiga, Inc.
  10. **        All Rights Reserved
  11. **
  12. **    (C) Copyright 1999 by Joanne Dow, Wizardess Designs, licensed to
  13. **        Amiga Inc.
  14. **        All Rights Reserved
  15. */
  16.  
  17. /*
  18. **    Changes:
  19. **        Added new numbering scheme for handling WIDE SCSI devices.
  20. **        Note that at this time only support for up to 16 IDs is
  21. **        contemplated in most designs although this numbering system
  22. **        can consider far far more.
  23. */
  24.  
  25. #ifndef EXEC_TYPES_H
  26. #include <exec/types.h>
  27. #endif /* EXEC_TYPES_H */
  28.  
  29. /*--------------------------------------------------------------------
  30.  *
  31.  *   SCSI Command
  32.  *    Several Amiga SCSI controller manufacturers are converging on
  33.  *    standard ways to talk to their controllers.  This include
  34.  *    file describes an exec-device command (e.g. for hddisk.device)
  35.  *    that can be used to issue SCSI commands
  36.  *
  37.  *   UNIT NUMBERS
  38.  *    Unit numbers to the OpenDevice call have encoded in them which
  39.  *    SCSI device is being referred to.  The three decimal digits of
  40.  *    the unit number refer to the SCSI Target ID (bus address) in
  41.  *    the 1's digit, the SCSI logical unit (LUN) in the 10's digit,
  42.  *    and the controller board in the 100's digit.
  43.  *
  44.  *    Examples:
  45.  *          0    drive at address 0
  46.  *         12    LUN 1 on multiple drive controller at address 2
  47.  *        104    second controller board, address 4
  48.  *         88    not valid: both logical units and addresses
  49.  *            range from 0..7.
  50.  *
  51.  *   CAVEATS
  52.  *    Original 2090 code did not support this command.
  53.  *
  54.  *    Commodore 2090/2090A unit numbers are different.  The SCSI
  55.  *    logical unit is the 100's digit, and the SCSI Target ID
  56.  *    is a permuted 1's digit: Target ID 0..6 maps to unit 3..9
  57.  *    (7 is reserved for the controller).
  58.  *
  59.  *        Examples:
  60.  *          3    drive at address 0
  61.  *        109    drive at address 6, logical unit 1
  62.  *          1    not valid: this is not a SCSI unit.  Perhaps
  63.  *            it's an ST506 unit.
  64.  *
  65.  *    Some controller boards generate a unique name (e.g. 2090A's
  66.  *    iddisk.device) for the second controller board, instead of
  67.  *    implementing the 100's digit.
  68.  *
  69.  *    With the advent of wide SCSI the scheme above fails miserably.
  70.  *    A new scheme was adopted by Phase V, who appear to be the only
  71.  *    source of wide SCSI for the Amiga at this time. Thus their
  72.  *    numbering system kludge is adopted here. When the ID or LUN is
  73.  *    above 7 the new numbering scheme is used.
  74.  *
  75.  *    Unit =
  76.  *        Board * 10 * 1000 * 1000 +
  77.  *        LUN      * 10 * 1000         +
  78.  *        ID      * 10                 +
  79.  *        HD_WIDESCSI;
  80.  *
  81.  *    There are optional restrictions on the alignment, bus
  82.  *    accessability, and size of the data for the data phase.
  83.  *    Be conservative to work with all manufacturer's controllers.
  84.  *
  85.  *------------------------------------------------------------------*/
  86.  
  87. #define HD_WIDESCSI    8    /* Wide SCSI detection bit. */
  88. #define    HD_SCSICMD    28    /* issue a SCSI command to the unit */
  89.                 /* io_Data points to a SCSICmd */
  90.                 /* io_Length is sizeof(struct SCSICmd) */
  91.                 /* io_Actual and io_Offset are not used */
  92.  
  93. struct SCSICmd {
  94.     UWORD  *scsi_Data;        /* word aligned data for SCSI Data Phase */
  95.                 /* (optional) data need not be byte aligned */
  96.                 /* (optional) data need not be bus accessable */
  97.     ULONG   scsi_Length;    /* even length of Data area */
  98.                 /* (optional) data can have odd length */
  99.                 /* (optional) data length can be > 2**24 */
  100.     ULONG   scsi_Actual;    /* actual Data used */
  101.     UBYTE  *scsi_Command;    /* SCSI Command (same options as scsi_Data) */
  102.     UWORD   scsi_CmdLength;    /* length of Command */
  103.     UWORD   scsi_CmdActual;    /* actual Command used */
  104.     UBYTE   scsi_Flags;        /* includes intended data direction */
  105.     UBYTE   scsi_Status;    /* SCSI status of command */
  106.     UBYTE  *scsi_SenseData;    /* sense data: filled if SCSIF_[OLD]AUTOSENSE */
  107.                 /* is set and scsi_Status has CHECK CONDITION */
  108.                 /* (bit 1) set */
  109.     UWORD   scsi_SenseLength;    /* size of scsi_SenseData, also bytes to */
  110.                 /* request w/ SCSIF_AUTOSENSE, must be 4..255 */
  111.     UWORD   scsi_SenseActual;    /* amount actually fetched (0 means no sense) */
  112. };
  113.  
  114.  
  115. /*----- scsi_Flags -----*/
  116. #define    SCSIF_WRITE        0    /* intended data direction is out */
  117. #define    SCSIF_READ        1    /* intended data direction is in */
  118. #define    SCSIB_READ_WRITE    0    /* (the bit to test) */
  119.  
  120. #define    SCSIF_NOSENSE        0    /* no automatic request sense */
  121. #define    SCSIF_AUTOSENSE        2    /* do standard extended request sense */
  122.                     /* on check condition */
  123. #define    SCSIF_OLDAUTOSENSE    6    /* do 4 byte non-extended request */
  124.                     /* sense on check condition */
  125. #define    SCSIB_AUTOSENSE        1    /* (the bit to test) */
  126. #define    SCSIB_OLDAUTOSENSE    2    /* (the bit to test) */
  127.  
  128. /*----- SCSI io_Error values -----*/
  129. #define    HFERR_SelfUnit        40    /* cannot issue SCSI command to self */
  130. #define    HFERR_DMA        41    /* DMA error */
  131. #define    HFERR_Phase        42    /* illegal or unexpected SCSI phase */
  132. #define    HFERR_Parity        43    /* SCSI parity error */
  133. #define    HFERR_SelTimeout    44    /* Select timed out */
  134. #define    HFERR_BadStatus        45    /* status and/or sense error */
  135.  
  136. /*----- OpenDevice io_Error values -----*/
  137. #define    HFERR_NoBoard        50    /* Open failed for non-existant board */
  138.  
  139. #endif    /* DEVICES_SCSIDISK_H */
  140.