1 /*
2  * myaspi32.h - Copyright (C) 1999 Jay A. Key
3  *
4  * API for WNASPI32.DLL
5  *
6  **********************************************************************
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  *
22  **********************************************************************
23  *
24  */
25 
26 /***************************************************************************
27  ** Module Name:    myaspi32.h
28  **
29  ** Description:    Header file replacement for wnaspi32.h
30  **
31  ***************************************************************************/
32 
33 #ifndef __MYASPI32_H_
34 #define __MYASPI32_H_
35 
36 #ifndef __GNUC__
37 #define PACKED
38 #endif
39 
40 /***************************************************************************
41  ** SCSI MISCELLANEOUS EQUATES
42  ***************************************************************************/
43 #define SENSE_LEN                 14     /* Default sense buffer length    */
44 #define SRB_DIR_SCSI              0x00   /* Direction determined by SCSI   */
45 #define SRB_POSTING               0x01   /* Enable ASPI posting            */
46 #define SRB_ENABLE_RESIDUAL_COUNT 0x04   /* Enable residual byte count     */
47                                          /* reporting                      */
48 #define SRB_DIR_IN                0x08   /* Transfer from SCSI target to   */
49                                          /* host                           */
50 #define SRB_DIR_OUT               0x10   /* Transfer from host to SCSI     */
51                                          /* target                         */
52 #define SRB_EVENT_NOTIFY          0x40   /* Enable ASPI event notification */
53 #define RESIDUAL_COUNT_SUPPORTED  0x02   /* Extended buffer flag           */
54 #define MAX_SRB_TIMEOUT       1080001u   /* 30 hour maximum timeout in sec */
55 #define DEFAULT_SRB_TIMEOUT   1080001u   /* use max.timeout by default     */
56 
57 /***************************************************************************
58  ** ASPI command definitions
59  ***************************************************************************/
60 #define SC_HA_INQUIRY             0x00   /* Host adapter inquiry           */
61 #define SC_GET_DEV_TYPE           0x01   /* Get device type                */
62 #define SC_EXEC_SCSI_CMD          0x02   /* Execute SCSI command           */
63 #define SC_ABORT_SRB              0x03   /* Abort an SRB                   */
64 #define SC_RESET_DEV              0x04   /* SCSI bus device reset          */
65 #define SC_SET_HA_PARMS           0x05   /* Set HA parameters              */
66 #define SC_GET_DISK_INFO          0x06   /* Get Disk                       */
67 #define SC_RESCAN_SCSI_BUS        0x07   /* Rebuild SCSI device map        */
68 #define SC_GETSET_TIMEOUTS        0x08   /* Get/Set target timeouts        */
69 
70 
71 /***************************************************************************
72  ** SRB Status
73  ***************************************************************************/
74 #define SS_PENDING                0x00   /* SRB being processed            */
75 #define SS_COMP                   0x01   /* SRB completed without error    */
76 #define SS_ABORTED                0x02   /* SRB aborted                    */
77 #define SS_ABORT_FAIL             0x03   /* Unable to abort SRB            */
78 #define SS_ERR                    0x04   /* SRB completed with error       */
79 #define SS_INVALID_CMD            0x80   /* Invalid ASPI command           */
80 #define SS_INVALID_HA             0x81   /* Invalid host adapter number    */
81 #define SS_NO_DEVICE              0x82   /* SCSI device not installed      */
82 #define SS_INVALID_SRB            0xE0   /* Invalid parameter set in SRB   */
83 #define SS_OLD_MANAGER            0xE1   /* ASPI manager doesn't support   */
84                                          /* windows                        */
85 #define SS_BUFFER_ALIGN           0xE1   /* Buffer not aligned (replaces   */
86                                          /* SS_OLD_MANAGER in Win32)       */
87 #define SS_ILLEGAL_MODE           0xE2   /* Unsupported Windows mode       */
88 #define SS_NO_ASPI                0xE3   /* No ASPI managers               */
89 #define SS_FAILED_INIT            0xE4   /* ASPI for windows failed init   */
90 #define SS_ASPI_IS_BUSY           0xE5   /* No resources available to      */
91                                          /* execute command                */
92 #define SS_BUFFER_TO_BIG          0xE6   /* Buffer size too big to handle  */
93 #define SS_BUFFER_TOO_BIG         0xE6   /* Correct spelling of 'too'      */
94 #define SS_MISMATCHED_COMPONENTS  0xE7   /* The DLLs/EXEs of ASPI don't    */
95                                          /* version check                  */
96 #define SS_NO_ADAPTERS            0xE8   /* No host adapters to manager    */
97 #define SS_INSUFFICIENT_RESOURCES 0xE9   /* Couldn't allocate resources    */
98                                          /* needed to init                 */
99 #define SS_ASPI_IS_SHUTDOWN       0xEA   /* Call came to ASPI after        */
100                                          /* PROCESS_DETACH                 */
101 #define SS_BAD_INSTALL            0xEB   /* The DLL or other components    */
102                                          /* are installed wrong            */
103 
104 /***************************************************************************
105  ** Host Adapter Status
106  ***************************************************************************/
107 #define HASTAT_OK                 0x00   /* No error detected by HA        */
108 #define HASTAT_SEL_TO             0x11   /* Selection Timeout              */
109 #define HASTAT_DO_DU              0x12   /* Data overrun/data underrun     */
110 #define HASTAT_BUS_FREE           0x13   /* Unexpected bus free            */
111 #define HASTAT_PHASE_ERR          0x14   /* Target bus phase sequence      */
112 #define HASTAT_TIMEOUT            0x09   /* Timed out while SRB was        */
113                                          /* waiting to be processed        */
114 #define HASTAT_COMMAND_TIMEOUT    0x0B   /* Adapter timed out while        */
115                                          /* processing SRB                 */
116 #define HASTAT_MESSAGE_REJECT     0x0D   /* While processing the SRB, the  */
117                                          /* adapter received a MESSAGE     */
118 #define HASTAT_BUS_RESET          0x0E   /* A bus reset was detected       */
119 #define HASTAT_PARITY_ERROR       0x0F   /* A parity error was detected    */
120 #define HASTAT_REQUEST_SENSE_FAILED 0x10 /* The adapter failed in issuing  */
121 
122 
123 #ifndef __GNUC__
124 #pragma pack(1)
125 #endif
126 
127 /***************************************************************************
128  ** SRB - HOST ADAPTER INQUIRIY - SC_HA_INQUIRY (0)
129  ***************************************************************************/
130 typedef struct {
131   BYTE     SRB_Cmd;           /* 00/000 ASPI command code == SC_HA_INQUIRY */
132   BYTE     SRB_Status;        /* 01/001 ASPI command status byte           */
133   BYTE     SRB_HaID;          /* 02/002 ASPI host adapter number           */
134   BYTE     SRB_Flags;         /* 03/003 ASPI request flags                 */
135   DWORD    SRB_Hdr_Rsvd;      /* 04/004 Reserved, must = 0                 */
136   BYTE     HA_Count;          /* 08/008 Number of host adapters present    */
137   BYTE     HA_SCSI_ID;        /* 09/009 SCSI ID of host adapter            */
138   BYTE     HA_ManagerId[16];  /* 0a/010 String describing the manager      */
139   BYTE     HA_Identifier[16]; /* 1a/026 String describing the host adapter */
140   BYTE     HA_Unique[16];     /* 2a/042 Host Adapter Unique parameters     */
141   WORD     HA_Rsvd1;          /* 3a/058 Reserved, must = 0                 */
142   BYTE     pad[20];
143 } PACKED SRB_HAInquiry, *PSRB_HAInquiry, FAR *LPSRB_HAInquiry;
144 
145 
146 /***************************************************************************
147  ** SRB - GET DEVICE TYPE - SC_GET_DEV_TYPE (1)
148  ***************************************************************************/
149 typedef struct
150 {
151   BYTE     SRB_Cmd;           /* 00/000 ASPI cmd code == SC_GET_DEV_TYPE   */
152   BYTE     SRB_Status;        /* 01/001 ASPI command status byte           */
153   BYTE     SRB_HaID;          /* 02/002 ASPI host adapter number           */
154   BYTE     SRB_Flags;         /* 03/003 Reserved, must = 0                 */
155   DWORD    SRB_Hdr_Rsvd;      /* 04/004 Reserved, must = 0                 */
156   BYTE     SRB_Target;        /* 08/008 Target's SCSI ID                   */
157   BYTE     SRB_Lun;           /* 09/009 Target's LUN number                */
158   BYTE     SRB_DeviceType;    /* 0a/010 Target's peripheral device type    */
159   BYTE     SRB_Rsvd1;         /* 0b/011 Reserved, must = 0                 */
160   BYTE     pad[68];
161 } PACKED SRB_GDEVBlock, *PSRB_GDEVBlock, FAR *LPSRB_GDEVBlock;
162 
163 
164 /***************************************************************************
165  ** SRB - EXECUTE SCSI COMMAND - SC_EXEC_SCSI_CMD (2)
166  ***************************************************************************/
167 typedef struct
168 {
169   BYTE     SRB_Cmd;           /* 00/000 ASPI cmd code == SC_EXEC_SCSI_CMD  */
170   BYTE     SRB_Status;        /* 01/001 ASPI command status byte           */
171   BYTE     SRB_HaID;          /* 02/002 ASPI host adapter number           */
172   BYTE     SRB_Flags;         /* 03/003 Reserved, must = 0                 */
173   DWORD    SRB_Hdr_Rsvd;      /* 04/004 Reserved, must = 0                 */
174   BYTE     SRB_Target;        /* 08/008 Target's SCSI ID                   */
175   BYTE     SRB_Lun;           /* 09/009 Target's LUN                       */
176   WORD     SRB_Rsvd1;         /* 0a/010 Reserved for alignment             */
177   DWORD    SRB_BufLen;        /* 0c/012 Data Allocation Length             */
178   BYTE FAR *SRB_BufPointer;   /* 10/016 Data Buffer Pointer                */
179   BYTE     SRB_SenseLen;      /* 14/020 Sense Allocation Length            */
180   BYTE     SRB_CDBLen;        /* 15/021 CDB Length                         */
181   BYTE     SRB_HaStat;        /* 16/022 Host Adapter Status                */
182   BYTE     SRB_TargStat;      /* 17/023 Target Status                      */
183   VOID FAR *SRB_PostProc;     /* 18/024 Post routine                       */
184   BYTE     SRB_Rsvd2[20];     /* 1c/028 Reserved, must = 0                 */
185   BYTE     CDBByte[16];       /* 30/048 SCSI CDB                           */
186   BYTE SenseArea[SENSE_LEN+2]; /* 40/064 Request Sense buffer              */
187 } PACKED SRB_ExecSCSICmd, *PSRB_ExecSCSICmd, FAR *LPSRB_ExecSCSICmd;
188 
189 
190 /***************************************************************************
191  ** SRB - BUS DEVICE RESET - SC_RESET_DEV (4)
192  ***************************************************************************/
193 typedef struct
194 {
195   BYTE     SRB_Cmd;           /* 00/000 ASPI cmd code == SC_RESET_DEV      */
196   BYTE     SRB_Status;        /* 01/001 ASPI command status byte           */
197   BYTE     SRB_HaId;          /* 02/002 ASPI host adapter number           */
198   BYTE     SRB_Flags;         /* 03/003 Reserved, must = 0                 */
199   DWORD    SRB_Hdr_Rsvd;      /* 04/004 Reserved                           */
200   BYTE     SRB_Target;        /* 08/008 Target's SCSI ID                   */
201   BYTE     SRB_Lun;           /* 09/009 Target's LUN number                */
202   BYTE     SRB_Rsvd1[12];     /* 0A/010 Reserved for alignment             */
203   BYTE     SRB_HaStat;        /* 16/022 Host Adapter Status                */
204   BYTE     SRB_TargStat;      /* 17/023 Target Status                      */
205   VOID FAR *SRB_PostProc;     /* 18/024 Post routine                       */
206   BYTE     SRB_Rsvd2[36];     /* 1C/028 Reserved, must = 0                 */
207   BYTE     pad[16];
208 } SRB_BusDeviceReset, *PSRB_BusDeviceReset, FAR *LPSRB_BusDeviceReset;
209 
210 
211 
212 typedef struct tag_ASPI32BUFF
213 {
214   PBYTE     AB_BufPointer;
215   DWORD     AB_BufLen;
216   DWORD     AB_ZeroFill;
217   DWORD     AB_Reserved;
218 } PACKED ASPI32BUFF, *PASPI32BUFF, FAR *LPASPI32BUFF;
219 
220 typedef struct
221 {
222   BYTE      SRB_Cmd;
223   BYTE      SRB_Status;
224   BYTE      SRB_HaId;
225   BYTE      SRB_Flags;
226   DWORD     SRB_Hdr_Rsvd;
227 } PACKED SRB, *PSRB, FAR *LPSRB;
228 
229 #ifndef __GNUC__
230 #pragma pack()
231 #endif
232 
233 #endif
234