home *** CD-ROM | disk | FTP | other *** search
/ Media Share 13 / mediashare_13.zip / mediashare_13 / ZIPPED / PROGRAM / DDJ9403A.ZIP / ASPI.ZIP / ASPI.H < prev    next >
C/C++ Source or Header  |  1993-11-10  |  8KB  |  222 lines

  1. // ----------------------------------------------------------------------
  2. // Module ASPI.H
  3. // Declarations for ASPI constants and structures.
  4. //
  5. // Copyright (C) 1993, Brian Sawert.
  6. // All rights reserved.
  7. //
  8. // ----------------------------------------------------------------------
  9.  
  10.  
  11. #ifndef    _ASPI_H                            // check for multiple inclusion
  12. #define _ASPI_H
  13.  
  14.  
  15. // -------------------- constant definitions --------------------
  16.  
  17. #define MAX_CDB            10                // maximum CDB size
  18. #define MAX_SENSE        32                // maximum sense data size
  19. #define MAX_IDSTR        16                // maximum ID string size
  20.  
  21.  
  22. // -------------------- type definitions --------------------
  23.  
  24. #if !defined(__WINDOWS_H)
  25. typedef unsigned char    BYTE;            // variable type definitions
  26. typedef unsigned int    WORD;
  27. typedef unsigned long    DWORD;
  28. #endif
  29.  
  30. // -------------------- ASPI command codes --------------------
  31.  
  32. #define HOST_INQ        0                // host adapter inquiry
  33. #define GET_DEV            1                // get device type
  34. #define SCSI_IO            2                // execute SCSI I/O command
  35. #define ABORT_IO        3                // abort SCSI I/O command
  36. #define SCSI_RESET        4                // reset SCSI device
  37. #define HOST_SET        5                // set host adapter parameters
  38. #define DISK_INFO        6                // get disk drive information
  39.  
  40.  
  41. // -------------------- ASPI status codes --------------------
  42.  
  43. #define REQ_INPROG        0x0                // SCSI request in progress
  44. #define REQ_NOERR        0x1                // SCSI request completed without error
  45. #define REQ_ABORT        0x2                // SCSI request aborted by host
  46. #define REQ_ERR            0x4                // SCSI request completed with error
  47. #define BAD_REQ            0x80            // invalid SCSI request
  48. #define BAD_HOST        0x81            // invalid host adapter number
  49. #define BAD_DEV            0x82            // SCSI device not installed
  50.  
  51.  
  52. // -------------------- SCSI request flag description --------------------
  53.  
  54. #define RF_POST            0x1                // posting enabled (bit 0)
  55. #define RF_LINK            0x2                // linking enabled (bit 1)
  56. #define RF_DCMD            0x0                // direction set by SCSI command
  57. #define RF_DREAD        0x8                // transfer from SCSI target to host
  58. #define RF_DWRITE        0x10            // transfer from host to SCSI target
  59. #define RF_DNONE        0x18            // no transfer
  60.  
  61.  
  62. // -------------------- host adapter status codes --------------------
  63.  
  64. #define H_OKAY            0x0                // host adapter did not detect error
  65. #define H_TIMEOUT        0x11            // selection timeout
  66. #define H_OVERRUN        0x12            // data overrun or underrun
  67. #define H_BUSFREE        0x13            // unexpected bus free
  68. #define H_SEQFAIL        0x14            // target bus phase sequence failure
  69.  
  70.  
  71. // -------------------- target status codes --------------------
  72.  
  73. #define T_NOSTAT        0x0                // no target status
  74. #define T_CHKSTAT        0x2                // check status (sense data available)
  75. #define T_BUSY            0x8                // specified target/LUN is busy
  76. #define T_CONF            0x18            // reservation conflict
  77.  
  78.  
  79. // -------------------- disk drive flags --------------------
  80.  
  81. #define DF_NOINT13        0x0                // no INT 13 access
  82. #define DF_INT13DOS        0x1                // INT 13 with access
  83. #define DF_INT13NODOS    0x2                // INT 13 without DOS access
  84. #define DF_INVALID        0x3                // invalid flags
  85.  
  86.  
  87. // -------------------- SCSI Request Block (SRB) definitions --------------------
  88.  
  89. typedef struct srb_0
  90.     {                                    // function 0:  Host adapter inquiry
  91.     BYTE numadapt;                        // number of host adapters (R)
  92.     BYTE targid;                        // target ID of host adapter (R)
  93.     char manageid[MAX_IDSTR];            // SCSI manager ID string (R)
  94.     char hostid[MAX_IDSTR];                // host adapter ID string (R)
  95.     BYTE hostparams[MAX_IDSTR];            // host adapter unique parameters (R)
  96.     } srb_0_t;
  97.  
  98. typedef struct srb_1
  99.     {                                    // function 1:  Get device type
  100.     BYTE targid;                        // device target ID (W)
  101.     BYTE lun;                            // logical unit number (W)
  102.     BYTE devtype;                        // peripheral device type (R)
  103.     } srb_1_t;
  104.  
  105. typedef struct srb_2
  106.     {                                    // function 2:  Execute SCSI I/O
  107.     BYTE targid;                        // device target ID (W)
  108.     BYTE lun;                            // logical unit number (W)
  109.     DWORD datalength;                    // data allocation length (W)
  110.     BYTE senselength;                    // sense allocation length (N) (W)
  111.     BYTE far *databufptr;                // data buffer pointer (W)
  112.     void far *srblinkptr;                // SRB link pointer (W)
  113.     BYTE cdblength;                        // SCSI CDB length (M) (W)
  114.     BYTE hoststat;                        // host adapter status (R)
  115.     BYTE targstat;                        // target status (R)
  116.     void far *postptr;                    // POST routine address (R)
  117.     BYTE workspace[34];                    // reserved ASPI workspace
  118. // -------------------- see notes below --------------------
  119.     BYTE scsicdb[MAX_CDB];                // SCSI command descriptor block
  120.     BYTE sensealloc[MAX_SENSE];            // sense data allocation area
  121.  
  122. // -------------------- notes on variable length data --------------------
  123. //    scsicdb - SCSI command descriptor block (CDB) - M bytes.
  124. //    Note:  Length will vary with CDB type (6 byte or 10 byte).
  125. //    sensealloc - sense allocation area - N bytes.
  126. //    Note:  Position and length will vary with CDB type.
  127. // ----------------------------------------------------------------------
  128.  
  129.     } srb_2_t;
  130.  
  131. typedef struct srb_3
  132.     {                                    // function 3:  Abort SCSI I/O command
  133.     BYTE far *srbptr;                    // address of SRB to abort (W)
  134.     } srb_3_t;
  135.  
  136. typedef struct srb_4
  137.     {                                    // function 4:  Reset SCSI device
  138.     BYTE targid;                        // device target ID (W)
  139.     BYTE lun;                            // logical unit number (W)
  140.     BYTE reserved[14];                    // reserved bytes
  141.     BYTE hoststat;                        // host adapter status (R)
  142.     BYTE targstat;                        // target status (R)
  143.     void far *postptr;                    // POST routine address (R)
  144.     BYTE workspace[34];                    // reserved ASPI workspace
  145.     } srb_4_t;
  146.  
  147. typedef struct srb_5
  148.     {                                    // function 5:  Set host parameters
  149.     BYTE hostparams[MAX_IDSTR];            // host adapter unique parameters (R)
  150.     } srb_5_t;
  151.  
  152. typedef struct srb_6
  153.     {                                    // function 6: Get disk information
  154.     BYTE targid;                        // device target ID (W)
  155.     BYTE lun;                            // logical unit number (W)
  156.     BYTE driveflags;                    // flags for drive parameters
  157.     BYTE drivenum;                        // INT 13 drive number
  158.     BYTE headtrans;                        // preferred head number translation
  159.     BYTE secttrans;                        // preferred sector size translation
  160.     BYTE reserved[10];                    // reserved bytes
  161.     } srb_6_t;
  162.  
  163. typedef struct aspi_req
  164.     {                                    // combined SRB structure
  165.     BYTE command;                        // command code (W)
  166.     BYTE status;                        // return status (R)
  167.     BYTE hostnum;                        // host adapter number (W)
  168.     BYTE reqflags;                        // SCSI request flags (W)
  169.     BYTE expand[4];                        // reserved for expansion
  170.     union srb_union
  171.         {                                // individual SRB's
  172.         srb_0_t s0;                        // function 0 SRB
  173.         srb_1_t s1;                        // function 1 SRB
  174.         srb_2_t s2;                        // function 2 SRB
  175.         srb_3_t s3;                        // function 3 SRB
  176.         srb_4_t s4;                        // function 4 SRB
  177.         srb_5_t s5;                        // function 5 SRB
  178.         srb_6_t s6;                        // function 6 SRB
  179.         } su;
  180.     } aspi_req_t;
  181.  
  182. typedef struct abort_req
  183.     {                                    // ASPI abort request
  184.     BYTE command;                        // command code (W)
  185.     BYTE status;                        // return status (R)
  186.     BYTE hostnum;                        // host adapter number (W)
  187.     BYTE reqflags;                        // SCSI request flags (W)
  188.     BYTE expand[4];                        // reserved for expansion
  189.     srb_3_t s3;                            // function 3 SRB
  190.     } abort_req_t;
  191.  
  192.  
  193. // -------------------- ASPI function declarations --------------------
  194.  
  195. #if defined(__WINDOWS_H)                // declare DLL functions
  196. #define FUNC    FAR PASCAL _export
  197. #ifndef _FAR
  198. #define _FAR    far
  199. #endif
  200. #else                                    // non-Windows definitions
  201. #define FUNC
  202. #ifndef _FAR
  203. #define _FAR
  204. #endif
  205. #endif
  206.  
  207. int FUNC aspi_open(void);                // initialize ASPI manager
  208. void FUNC aspi_close(void);                // close ASPI manager
  209. int FUNC aspi_host_inq(char _FAR *idstr, BYTE _FAR *hprm);
  210.                                         // get host adapter info
  211. int FUNC aspi_devtype(BYTE id);            // get SCSI device type
  212. int FUNC aspi_io(BYTE _FAR *cdb, BYTE far *dbuff, WORD dbytes,
  213.     BYTE flags, BYTE id, WORD _FAR *stat);    // perform SCSI I/O
  214. int FUNC aspi_abort_io(void);            // abort SCSI request
  215. int FUNC aspi_reset_dev(BYTE id);        // reset device
  216. int FUNC aspi_set_hostprm(BYTE _FAR *hprm, int hbytes);    // set host parameters
  217. int FUNC aspi_get_driveprm(BYTE id, BYTE _FAR *flags, BYTE _FAR *drvnum,
  218.     int _FAR *heads, int _FAR *sectsize);    // get SCSI disk drive parameters
  219. int FUNC aspi_sense(BYTE _FAR *sb, int sbytes);    // return SCSI sense info
  220.  
  221. #endif
  222.