1
0

Winaspi.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. //**********************************************************************
  2. //
  3. // Name: WINASPI.H
  4. //
  5. // Description: ASPI for Windows definitions ('C' Language)
  6. //
  7. //**********************************************************************
  8. #ifndef _WINASPI_H
  9. #define _WINASPI_H
  10. typedef BYTE *LPSRB;
  11. #define SENSE_LEN 14 // Default sense buffer length
  12. #define SRB_DIR_SCSI 0x00 // Direction determined by SCSI command
  13. #define SRB_DIR_IN 0x08 // Transfer from SCSI target to host
  14. #define SRB_DIR_OUT 0x10 // Transfer from host to SCSI targetw
  15. #define SRB_POSTING 0x01 // Enable ASPI posting
  16. #define SRB_EVENT_NOTIFY 0x40 // Enable ASPI command notification
  17. #define SRB_ENABLE_RESIDUAL_COUNT 0x04 //Enable reporting of residual byte count
  18. #define WM_ASPIPOST 0x4D42 // ASPI Post message
  19. #define TIMEOUT 30000 // Wait 30 seconds
  20. //**********************************************************************
  21. // %%% ASPI Command Definitions %%%
  22. //**********************************************************************
  23. #define SC_HA_INQUIRY 0x00 // Host adapter inquiry
  24. #define SC_GET_DEV_TYPE 0x01 // Get device type
  25. #define SC_EXEC_SCSI_CMD 0x02 // Execute SCSI command
  26. #define SC_ABORT_SRB 0x03 // Abort an SRB
  27. #define SC_RESET_DEV 0x04 // SCSI bus device reset
  28. //**********************************************************************
  29. // %%% SRB Status %%%
  30. //**********************************************************************
  31. #define SS_PENDING 0x00 // SRB being processed
  32. #define SS_COMP 0x01 // SRB completed without error
  33. #define SS_ABORTED 0x02 // SRB aborted
  34. #define SS_ABORT_FAIL 0x03 // Unable to abort SRB
  35. #define SS_ERR 0x04 // SRB completed with error
  36. #define SS_INVALID_CMD 0x80 // Invalid ASPI command
  37. #define SS_INVALID_HA 0x81 // Invalid host adapter number
  38. #define SS_NO_DEVICE 0x82 // SCSI device not installed
  39. #define SS_INVALID_SRB 0xE0 // Invalid parameter set in SRB
  40. #define SS_OLD_MANAGER 0xE1 // ASPI manager doesn't support Window
  41. #define SS_ILLEGAL_MODE 0xE2 // Unsupported Windows mode
  42. #define SS_NO_ASPI 0xE3 // No ASPI managers resident
  43. #define SS_FAILED_INIT 0xE4 // ASPI for windows failed init
  44. #define SS_ASPI_IS_BUSY 0xE5 // No resources available to execute cmd
  45. #define SS_BUFFER_TO_BIG 0xE6 // Buffer size to big to handle!
  46. //**********************************************************************
  47. // %%% Host Adapter Status %%%
  48. //**********************************************************************
  49. #define HASTAT_OK 0x00 // Host adapter did not detect an error
  50. #define HASTAT_SEL_TO 0x11 // Selection Timeout
  51. #define HASTAT_DO_DU 0x12 // Data overrun data underrun
  52. #define HASTAT_BUS_FREE 0x13 // Unexpected bus free
  53. #define HASTAT_PHASE_ERR 0x14 // Target bus phase sequence failure
  54. //**********************************************************************
  55. // %%% SRB - HOST ADAPTER INQUIRY - SC_HA_INQUIRY %%%
  56. //**********************************************************************
  57. #pragma pack(push,ASPI_Structures,1)
  58. typedef BYTE TDriveMode[64];
  59. struct THAUnique
  60. {
  61. WORD BufferAlignmentMask;
  62. BYTE AdapterUniqueFlags;
  63. BYTE MaximumSCSITargets;
  64. DWORD MaximumTransferLen;
  65. BYTE Reserved[8];
  66. };
  67. typedef struct
  68. {
  69. BYTE SRB_Cmd; // ASPI command code = SC_HA_INQUIRY
  70. BYTE SRB_Status; // ASPI command status byte
  71. BYTE SRB_HaId; // ASPI host adapter number
  72. BYTE SRB_Flags; // ASPI request flags
  73. DWORD SRB_Hdr_Rsvd; // Reserved, MUST = 0
  74. BYTE HA_Count; // Number of host adapters present
  75. BYTE HA_SCSI_ID; // SCSI ID of host adapter
  76. BYTE HA_ManagerId[16]; // String describing the manager
  77. BYTE HA_Identifier[16]; // String describing the host adapter
  78. THAUnique HA_Unique; // Host Adapter Unique parameters
  79. WORD HA_Rsvd1;
  80. } SRB_HAInquiry, *PSRB_HAInquiry;
  81. //**********************************************************************
  82. // %%% SRB - GET DEVICE TYPE - SC_GET_DEV_TYPE %%%
  83. //**********************************************************************
  84. typedef struct
  85. {
  86. BYTE SRB_Cmd; // ASPI command code = SC_GET_DEV_TYPE
  87. BYTE SRB_Status; // ASPI command status byte
  88. BYTE SRB_HaId; // ASPI host adapter number
  89. BYTE SRB_Flags; // Reserved
  90. DWORD SRB_Hdr_Rsvd; // Reserved
  91. BYTE SRB_Target; // Target's SCSI ID
  92. BYTE SRB_Lun; // Target's LUN number
  93. BYTE SRB_DeviceType; // Target's peripheral device type
  94. BYTE SRB_Rsvd1; // Reserved for alignment
  95. } SRB_GDEVBlock, *PSRB_GDEVBlock;
  96. //**********************************************************************
  97. // %%% SRB - EXECUTE SCSI COMMAND - SC_EXEC_SCSI_CMD %%%
  98. //**********************************************************************
  99. typedef struct
  100. {
  101. BYTE SRB_Cmd; // ASPI command code = SC_EXEC_SCSI_CMD
  102. BYTE SRB_Status; // ASPI command status byte
  103. BYTE SRB_HaId; // ASPI host adapter number
  104. BYTE SRB_Flags; // ASPI request flags
  105. DWORD SRB_Hdr_Rsvd; // Reserved
  106. BYTE SRB_Target; // Target's SCSI ID
  107. BYTE SRB_Lun; // Target's LUN number
  108. WORD SRB_Rsvd1; // Reserved for Alignment
  109. DWORD SRB_BufLen; // Data Allocation Length
  110. BYTE *SRB_BufPointer; // Data Buffer Point
  111. BYTE SRB_SenseLen; // Sense Allocation Length
  112. BYTE SRB_CDBLen; // CDB Length
  113. BYTE SRB_HaStat; // Host Adapter Status
  114. BYTE SRB_TargStat; // Target Status
  115. void (*SRB_PostProc)(); // Post routine
  116. void *SRB_Rsvd2; // Reserved
  117. BYTE SRB_Rsvd3[16]; // Reserved for expansion
  118. BYTE CDBByte[16]; // SCSI CDB
  119. BYTE SenseArea[SENSE_LEN+2]; // Request Sense buffer
  120. } SRB_ExecSCSICmd, *PSRB_ExecSCSICmd;
  121. //**********************************************************************
  122. // %%% SRB - ABORT AN SRB - SC_ABORT_SRB %%%
  123. //**********************************************************************
  124. typedef struct
  125. {
  126. BYTE SRB_Cmd; // ASPI command code = SC_ABORT_SRB
  127. BYTE SRB_Status; // ASPI command status byte
  128. BYTE SRB_HaId; // ASPI host adapter number
  129. BYTE SRB_Flags; // ASPI request flags
  130. DWORD SRB_Hdr_Rsvd; // Reserved, MUST = 0
  131. LPSRB SRB_ToAbort; // Pointer to SRB to abort
  132. } SRB_Abort;
  133. //**********************************************************************
  134. // %%% SRB - BUS DEVICE RESET - SC_RESET_DEV %%%
  135. //**********************************************************************
  136. typedef struct
  137. {
  138. BYTE SRB_Cmd; // ASPI command code = SC_RESET_DEV
  139. BYTE SRB_Status; // ASPI command status byte
  140. BYTE SRB_HaId; // ASPI host adapter number
  141. BYTE SRB_Flags; // Reserved
  142. DWORD SRB_Hdr_Rsvd; // Reserved
  143. BYTE SRB_Target; // Target's SCSI ID
  144. BYTE SRB_Lun; // Target's LUN number
  145. BYTE SRB_Rsvd1[12]; // Reserved for Alignment
  146. BYTE SRB_HaStat; // Host Adapter Status
  147. BYTE SRB_TargStat; // Target Status
  148. void *SRB_PostProc; // Post routine
  149. void *SRB_Rsvd2; // Reserved
  150. BYTE SRB_Rsvd3[32]; // Reserved
  151. } SRB_BusDeviceReset, *PSRB_BusDeviceReset;
  152. //**********************************************************************
  153. // %%% Header for TOC Reading %%%
  154. //**********************************************************************
  155. struct TTrackInfo
  156. {
  157. BYTE Reserved1;
  158. BYTE AdrCtrl;
  159. BYTE TrackNummer;
  160. BYTE Reserved2;
  161. DWORD AbsCDAdress;
  162. };
  163. struct TTOCHeader
  164. {
  165. WORD TOCDataLength;
  166. BYTE FirstTrack;
  167. BYTE LastTrack;
  168. TTrackInfo Info[100];
  169. };
  170. //**********************************************************************
  171. // %%% Structure for Read Sub-Channel %%%
  172. //**********************************************************************
  173. struct TQChannelInfo
  174. {
  175. BYTE Reserved1;
  176. BYTE AudioStatus;
  177. WORD DataLen;
  178. BYTE FormatCode;
  179. BYTE ADRCtrl;
  180. BYTE TrackNumber;
  181. BYTE IndexNumber;
  182. long AbsCDAdress;
  183. long RelTrackAdress;
  184. };
  185. //**********************************************************************
  186. // %%% Request Sense Data Format %%%
  187. //**********************************************************************
  188. typedef struct {
  189. BYTE ErrorCode; // Error Code (70H or 71H)
  190. BYTE SegmentNum; // Number of current segment descriptor
  191. BYTE SenseKey; // Sense Key(See bit definitions too)
  192. BYTE InfoByte0; // Information MSB
  193. BYTE InfoByte1; // Information MID
  194. BYTE InfoByte2; // Information MID
  195. BYTE InfoByte3; // Information LSB
  196. BYTE AddSenLen; // Additional Sense Length
  197. BYTE ComSpecInf0; // Command Specific Information MSB
  198. BYTE ComSpecInf1; // Command Specific Information MID
  199. BYTE ComSpecInf2; // Command Specific Information MID
  200. BYTE ComSpecInf3; // Command Specific Information LSB
  201. BYTE AddSenseCode; // Additional Sense Code
  202. BYTE AddSenQual; // Additional Sense Code Qualifier
  203. BYTE FieldRepUCode; // Field Replaceable Unit Code
  204. BYTE SenKeySpec15; // Sense Key Specific 15th byte
  205. BYTE SenKeySpec16; // Sense Key Specific 16th byte
  206. BYTE SenKeySpec17; // Sense Key Specific 17th byte
  207. BYTE AddSenseBytes; // Additional Sense Bytes
  208. } TSenseInfo;
  209. #pragma pack(pop,ASPI_Structures)
  210. #endif //_WINASPI_H