2 * Copyright (C) the Wine project
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef __WNASPI32_H__
20 #define __WNASPI32_H__
22 /* This file should be 100% source compatible according to MS docs and
27 #endif /* #ifdef __cplusplus */
29 /* SCSI Miscellaneous Stuff */
31 #define SRB_DIR_SCSI 0x00
32 #define SRB_POSTING 0x01
33 #define SRB_ENABLE_RESIDUAL_COUNT 0x04
34 #define SRB_DIR_IN 0x08
35 #define SRB_DIR_OUT 0x10
37 /* ASPI Command Definitions */
38 #define SC_HA_INQUIRY 0x00
39 #define SC_GET_DEV_TYPE 0x01
40 #define SC_EXEC_SCSI_CMD 0x02
41 #define SC_ABORT_SRB 0x03
42 #define SC_RESET_DEV 0x04
43 #define SC_SET_HA_PARMS 0x05
44 #define SC_GET_DISK_INFO 0x06
46 /* SRB status codes */
47 #define SS_PENDING 0x00
49 #define SS_ABORTED 0x02
50 #define SS_ABORT_FAIL 0x03
53 #define SS_INVALID_CMD 0x80
54 #define SS_INVALID_HA 0x81
55 #define SS_NO_DEVICE 0x82
57 #define SS_INVALID_SRB 0xE0
58 #define SS_OLD_MANAGER 0xE1
59 #define SS_BUFFER_ALIGN 0xE1 /* Win32 */
60 #define SS_ILLEGAL_MODE 0xE2
61 #define SS_NO_ASPI 0xE3
62 #define SS_FAILED_INIT 0xE4
63 #define SS_ASPI_IS_BUSY 0xE5
64 #define SS_BUFFER_TO_BIG 0xE6
65 #define SS_MISMATCHED_COMPONENTS 0xE7 /* DLLs/EXE version mismatch */
66 #define SS_NO_ADAPTERS 0xE8
67 #define SS_INSUFFICIENT_RESOURCES 0xE9
68 #define SS_ASPI_IS_SHUTDOWN 0xEA
69 #define SS_BAD_INSTALL 0xEB
72 /* Host status codes */
73 #define HASTAT_OK 0x00
74 #define HASTAT_SEL_TO 0x11
75 #define HASTAT_DO_DU 0x12
76 #define HASTAT_BUS_FREE 0x13
77 #define HASTAT_PHASE_ERR 0x14
79 #define HASTAT_TIMEOUT 0x09
80 #define HASTAT_COMMAND_TIMEOUT 0x0B
81 #define HASTAT_MESSAGE_REJECT 0x0D
82 #define HASTAT_BUS_RESET 0x0E
83 #define HASTAT_PARITY_ERROR 0x0F
84 #define HASTAT_REQUEST_SENSE_FAILED 0x10
87 /* Additional definitions */
88 /* SCSI Miscellaneous Stuff */
89 #define SRB_EVENT_NOTIFY 0x40
90 #define RESIDUAL_COUNT_SUPPORTED 0x02
91 #define MAX_SRB_TIMEOUT 1080001u
92 #define DEFAULT_SRB_TIMEOUT 1080001u
94 /* These are defined by MS but not adaptec */
95 #define SRB_DATA_SG_LIST 0x02
96 #define WM_ASPIPOST 0x4D42
99 /* ASPI Command Definitions */
100 #define SC_RESCAN_SCSI_BUS 0x07
101 #define SC_GETSET_TIMEOUTS 0x08
103 /* SRB Status.. MS defined */
104 #define SS_SECURITY_VIOLATION 0xE2 /* Replaces SS_INVALID_MODE */
107 #include <pshpack1.h>
109 /* SRB - HOST ADAPTER INQUIRY - SC_HA_INQUIRY */
110 typedef struct tagSRB32_HaInquiry
{
111 BYTE SRB_Cmd
; /* 00 ASPI command code = SC_HA_INQUIRY */
112 BYTE SRB_Status
; /* 01 ASPI command status byte */
113 BYTE SRB_HaId
; /* 02 ASPI host adapter number */
114 BYTE SRB_Flags
; /* 03 ASPI request flags */
115 DWORD SRB_Hdr_Rsvd
; /* 04 Reserved, MUST = 0 */
116 BYTE HA_Count
; /* 08 Number of host adapters present */
117 BYTE HA_SCSI_ID
; /* 09 SCSI ID of host adapter */
118 BYTE HA_ManagerId
[16]; /* 0A String describing the manager */
119 BYTE HA_Identifier
[16]; /* 1A String describing the host adapter */
120 BYTE HA_Unique
[16]; /* 2A Host Adapter Unique parameters */
122 } SRB_HaInquiry
, *PSRB_HaInquiry
;
124 /* SRB - GET DEVICE TYPE - SC_GET_DEV_TYPE */
125 typedef struct tagSRB32_GDEVBlock
{
126 BYTE SRB_Cmd
; /* 00 ASPI command code = SC_GET_DEV_TYPE */
127 BYTE SRB_Status
; /* 01 ASPI command status byte */
128 BYTE SRB_HaId
; /* 02 ASPI host adapter number */
129 BYTE SRB_Flags
; /* 03 Reserved */
130 DWORD SRB_Hdr_Rsvd
; /* 04 Reserved */
131 BYTE SRB_Target
; /* 08 Target's SCSI ID */
132 BYTE SRB_Lun
; /* 09 Target's LUN number */
133 BYTE SRB_DeviceType
; /* 0A Target's peripheral device type */
135 } SRB_GDEVBlock
, *PSRB_GDEVBlock
;
137 /* SRB - EXECUTE SCSI COMMAND - SC_EXEC_SCSI_CMD */
138 typedef struct tagSRB32_ExecSCSICmd
{
139 BYTE SRB_Cmd
; /* 00 ASPI command code = SC_EXEC_SCSI_CMD */
140 BYTE SRB_Status
; /* 01 ASPI command status byte */
141 BYTE SRB_HaId
; /* 02 ASPI host adapter number */
142 BYTE SRB_Flags
; /* 03 ASPI request flags */
143 DWORD SRB_Hdr_Rsvd
; /* 04 Reserved */
144 BYTE SRB_Target
; /* 08 Target's SCSI ID */
145 BYTE SRB_Lun
; /* 09 Target's LUN number */
146 WORD SRB_Rsvd1
; /* 0A Reserved for Alignment */
147 DWORD SRB_BufLen
; /* 0C Data Allocation Length */
148 BYTE
*SRB_BufPointer
; /* 10 Data Buffer Point */
149 BYTE SRB_SenseLen
; /* 14 Sense Allocation Length */
150 BYTE SRB_CDBLen
; /* 15 CDB Length */
151 BYTE SRB_HaStat
; /* 16 Host Adapter Status */
152 BYTE SRB_TargStat
; /* 17 Target Status */
153 void (*SRB_PostProc
)( struct tagSRB32_ExecSCSICmd
* ); /* 18 Post routine */
154 void *SRB_Rsvd2
; /* 1C Reserved */
155 BYTE SRB_Rsvd3
[16]; /* 20 Reserved for expansion */
156 BYTE CDBByte
[16]; /* 30 SCSI CDB */
157 BYTE SenseArea
[SENSE_LEN
+2]; /* 40 Request sense buffer - var length */
158 } SRB_ExecSCSICmd
, *PSRB_ExecSCSICmd
;
160 /* SRB - ABORT AN ARB - SC_ABORT_SRB */
161 typedef struct tagSRB32_Abort
{
162 BYTE SRB_Cmd
; /* 00 ASPI command code = SC_ABORT_SRB */
163 BYTE SRB_Status
; /* 01 ASPI command status byte */
164 BYTE SRB_HaId
; /* 02 ASPI host adapter number */
165 BYTE SRB_Flags
; /* 03 Reserved */
166 DWORD SRB_Hdr_Rsvd
; /* 04 Reserved, MUST = 0 */
167 VOID
*SRB_ToAbort
; /* 08 Pointer to SRB to abort */
168 } SRB_Abort
, *PSRB_Abort
;
170 /* SRB - BUS DEVICE RESET - SC_RESET_DEV */
171 typedef struct tagSRB32_BusDeviceReset
{
172 BYTE SRB_Cmd
; /* 00 ASPI cmd code = SC_RESET_DEV */
173 BYTE SRB_Status
; /* 01 ASPI command status byte */
174 BYTE SRB_HaId
; /* 02 ASPI host adapter number */
175 BYTE SRB_Flags
; /* 03 Reserved */
176 DWORD SRB_Hdr_Rsvd
; /* 04 Reserved */
177 BYTE SRB_Target
; /* 08 Target's SCSI ID */
178 BYTE SRB_Lun
; /* 09 Target's LUN number */
179 BYTE SRB_Rsvd1
[12]; /* 0A Reserved for Alignment */
180 BYTE SRB_HaStat
; /* 16 Host Adapter Status */
181 BYTE SRB_TargStat
; /* 17 Target Status */
182 void (*SRB_PostProc
)( struct tagSRB32_BusDeviceReset
* ); /* 18 Post routine */
183 void *SRB_Rsvd2
; /* 1c Reserved */
184 BYTE SRB_Rsvd3
[32]; /* 20 Reserved */
185 } SRB_BusDeviceReset
, *PSRB_BusDeviceReset
;
187 /* SRB - GET DISK INFORMATION - SC_GET_DISK_INFO */
188 typedef struct tagSRB32_GetDiskInfo
{
189 BYTE SRB_Cmd
; /* 00 ASPI cmd code = SC_RESET_DEV */
190 BYTE SRB_Status
; /* 01 ASPI command status byte */
191 BYTE SRB_HaId
; /* 02 ASPI host adapter number */
192 BYTE SRB_Flags
; /* 03 Reserved */
193 DWORD SRB_Hdr_Rsvd
; /* 04 Reserved */
194 BYTE SRB_Target
; /* 08 Target's SCSI ID */
195 BYTE SRB_Lun
; /* 09 Target's LUN number */
196 BYTE SRB_DriveFlags
; /* 0A Driver flags */
197 BYTE SRB_Int13HDriveInfo
; /* 0B Host Adapter Status */
198 BYTE SRB_Heads
; /* 0C Preferred number of heads trans */
199 BYTE SRB_Sectors
; /* 0D Preferred number of sectors trans */
200 BYTE SRB_Rsvd1
[10]; /* 0E Reserved */
201 } SRB_GetDiskInfo
, *PSRB_GetDiskInfo
;
203 typedef struct tagSRB32_GetSetTimeouts
{
204 BYTE SRB_Cmd
; /* 00 ASPI cmd code = SC_GETSET_TIMEOUTS */
205 BYTE SRB_Status
; /* 01 ASPI command status byte */
206 BYTE SRB_HaId
; /* 02 ASPI host adapter number */
207 BYTE SRB_Flags
; /* 03 Reserved */
208 DWORD SRB_Hdr_Rsvd
; /* 04 Reserved */
209 BYTE SRB_Target
; /* 08 Target's SCSI ID */
210 BYTE SRB_Lun
; /* 09 Target's LUN number */
211 DWORD SRB_Timeout
; /* 10 Target's Timeout value */
212 } SRB_GetSetTimeouts
, *PSRB_GetSetTimeouts
;
215 typedef struct tagSRB32_Header
{
216 BYTE SRB_Cmd
; /* 00 ASPI cmd code = SC_RESET_DEV */
217 BYTE SRB_Status
; /* 01 ASPI command status byte */
218 BYTE SRB_HaId
; /* 02 ASPI host adapter number */
219 BYTE SRB_Flags
; /* 03 Reserved */
220 DWORD SRB_Hdr_Rsvd
; /* 04 Reserved */
221 } SRB_Header
, *PSRB_Header
;
223 typedef union tagSRB32
{
225 SRB_HaInquiry inquiry
;
228 SRB_BusDeviceReset reset
;
229 SRB_GDEVBlock devtype
;
230 SRB_GetDiskInfo diskinfo
;
231 } SRB
, *PSRB
, *LPSRB
;
233 typedef struct tagASPI32BUFF
{
234 LPBYTE AB_BufPointer
; /* pointer to buffer */
235 DWORD AB_BufLen
; /* length of buffer */
236 DWORD AB_ZeroFill
; /* set to 1 if zeroing */
237 DWORD AB_Reserved
; /* 0 */
238 } ASPI32BUFF
, *PASPI32BUFF
;
243 extern DWORD __cdecl
SendASPI32Command (PSRB
);
244 extern DWORD __cdecl
GetASPI32SupportInfo (void);
245 extern DWORD __cdecl
GetASPI32DLLVersion(void);
246 extern BOOL __cdecl
GetASPI32Buffer(PASPI32BUFF pab
);
250 #endif /* #ifdef __cplusplus */
252 #endif /* __WNASPI32_H__ */