blob: 09ada9c81736f68e39c5132a6288f3243b615dd8 [file] [log] [blame]
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00001/*
2 * Copyright (C) the Wine project
3 *
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.
8 *
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.
13 *
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
Jonathan Ernst360a3f92006-05-18 14:49:52 +020016 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000017 */
18
David Elliottc3bcd6c2000-03-08 19:41:49 +000019#ifndef __WNASPI32_H__
20#define __WNASPI32_H__
Patrik Stridvall857eb391999-06-12 18:36:54 +000021
David Elliottc3bcd6c2000-03-08 19:41:49 +000022/* This file should be 100% source compatible according to MSes docs and
23 * Adaptecs docs */
Alexandre Julliardd30dfd21998-09-27 18:28:36 +000024
David Elliottc3bcd6c2000-03-08 19:41:49 +000025#ifdef __cplusplus
26extern "C" {
27#endif /* #ifdef __cplusplus */
Alexandre Julliardd30dfd21998-09-27 18:28:36 +000028
Alexandre Julliard83f52d12000-09-26 22:20:14 +000029/* SCSI Miscellaneous Stuff */
30#define SENSE_LEN 14
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
36
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
45
46/* SRB status codes */
47#define SS_PENDING 0x00
48#define SS_COMP 0x01
49#define SS_ABORTED 0x02
50#define SS_ABORT_FAIL 0x03
51#define SS_ERR 0x04
52
53#define SS_INVALID_CMD 0x80
54#define SS_INVALID_HA 0x81
55#define SS_NO_DEVICE 0x82
56
57#define SS_INVALID_SRB 0xE0
58#define SS_OLD_MANAGER 0xE1
Gregg Mattinson88773cd2002-06-28 17:37:34 +000059#define SS_BUFFER_ALIGN 0xE1 /* Win32 */
Alexandre Julliard83f52d12000-09-26 22:20:14 +000060#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
Gregg Mattinson88773cd2002-06-28 17:37:34 +000065#define SS_MISMATCHED_COMPONENTS 0xE7 /* DLLs/EXE version mismatch */
Alexandre Julliard83f52d12000-09-26 22:20:14 +000066#define SS_NO_ADAPTERS 0xE8
67#define SS_INSUFFICIENT_RESOURCES 0xE9
68#define SS_ASPI_IS_SHUTDOWN 0xEA
69#define SS_BAD_INSTALL 0xEB
70
71
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
78
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
85
86
David Elliottc3bcd6c2000-03-08 19:41:49 +000087/* 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
Alexandre Julliardd30dfd21998-09-27 18:28:36 +000093
David Elliottc3bcd6c2000-03-08 19:41:49 +000094/* These are defined by MS but not adaptec */
95#define SRB_DATA_SG_LIST 0x02
96#define WM_ASPIPOST 0x4D42
Uwe Bonnes72dd5251999-06-06 14:34:32 +000097
David Elliottc3bcd6c2000-03-08 19:41:49 +000098
99/* ASPI Command Definitions */
100#define SC_RESCAN_SCSI_BUS 0x07
101#define SC_GETSET_TIMEOUTS 0x08
102
103/* SRB Status.. MS defined */
Gregg Mattinson88773cd2002-06-28 17:37:34 +0000104#define SS_SECURITY_VIOLATION 0xE2 /* Replaces SS_INVALID_MODE */
David Elliottc3bcd6c2000-03-08 19:41:49 +0000105/*** END DEFS */
106
Dimitrie O. Paun53f9c212003-08-28 21:43:34 +0000107#include <pshpack1.h>
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000108
David Elliottc3bcd6c2000-03-08 19:41:49 +0000109/* SRB - HOST ADAPTER INQUIRY - SC_HA_INQUIRY */
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000110typedef struct tagSRB32_HaInquiry {
Andreas Mohr1af53cb2000-12-09 03:15:32 +0000111 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 */
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000121 WORD HA_Rsvd1;
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000122} SRB_HaInquiry, *PSRB_HaInquiry;
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000123
David Elliottc3bcd6c2000-03-08 19:41:49 +0000124/* SRB - GET DEVICE TYPE - SC_GET_DEV_TYPE */
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000125typedef struct tagSRB32_GDEVBlock {
Andreas Mohr1af53cb2000-12-09 03:15:32 +0000126 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 */
David Elliottc3bcd6c2000-03-08 19:41:49 +0000134 BYTE SRB_Rsvd1;
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000135} SRB_GDEVBlock, *PSRB_GDEVBlock;
David Elliottc3bcd6c2000-03-08 19:41:49 +0000136
137/* SRB - EXECUTE SCSI COMMAND - SC_EXEC_SCSI_CMD */
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000138typedef struct tagSRB32_ExecSCSICmd {
Andreas Mohr1af53cb2000-12-09 03:15:32 +0000139 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)(); /* 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 */
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000158} SRB_ExecSCSICmd, *PSRB_ExecSCSICmd;
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000159
David Elliottc3bcd6c2000-03-08 19:41:49 +0000160/* SRB - ABORT AN ARB - SC_ABORT_SRB */
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000161typedef struct tagSRB32_Abort {
Andreas Mohr1af53cb2000-12-09 03:15:32 +0000162 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 */
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000168} SRB_Abort, *PSRB_Abort;
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000169
David Elliottc3bcd6c2000-03-08 19:41:49 +0000170/* SRB - BUS DEVICE RESET - SC_RESET_DEV */
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000171typedef struct tagSRB32_BusDeviceReset {
Andreas Mohr1af53cb2000-12-09 03:15:32 +0000172 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)(); /* 18 Post routine */
183 void *SRB_Rsvd2; /* 1c Reserved */
184 BYTE SRB_Rsvd3[32]; /* 20 Reserved */
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000185} SRB_BusDeviceReset, *PSRB_BusDeviceReset;
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000186
David Elliottc3bcd6c2000-03-08 19:41:49 +0000187/* SRB - GET DISK INFORMATION - SC_GET_DISK_INFO */
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000188typedef struct tagSRB32_GetDiskInfo {
Andreas Mohr1af53cb2000-12-09 03:15:32 +0000189 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 */
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000201} SRB_GetDiskInfo, *PSRB_GetDiskInfo;
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000202
David Elliottc3bcd6c2000-03-08 19:41:49 +0000203/* SRB header */
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000204typedef struct tagSRB32_Header {
Andreas Mohr1af53cb2000-12-09 03:15:32 +0000205 BYTE SRB_Cmd; /* 00 ASPI cmd code = SC_RESET_DEV */
206 BYTE SRB_Status; /* 01 ASPI command status byte */
207 BYTE SRB_HaId; /* 02 ASPI host adapter number */
208 BYTE SRB_Flags; /* 03 Reserved */
209 DWORD SRB_Hdr_Rsvd; /* 04 Reserved */
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000210} SRB_Header, *PSRB_Header;
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000211
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000212typedef union tagSRB32 {
213 SRB_Header common;
214 SRB_HaInquiry inquiry;
215 SRB_ExecSCSICmd cmd;
216 SRB_Abort abort;
217 SRB_BusDeviceReset reset;
218 SRB_GDEVBlock devtype;
Marcus Meissner485c3ef2001-06-06 20:19:07 +0000219 SRB_GetDiskInfo diskinfo;
Alexandre Julliard83f52d12000-09-26 22:20:14 +0000220} SRB, *PSRB, *LPSRB;
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000221
Vincent BĂ©ron9a624912002-05-31 23:06:46 +0000222typedef struct tagASPI32BUFF {
Marcus Meissner485c3ef2001-06-06 20:19:07 +0000223 LPBYTE AB_BufPointer; /* pointer to buffer */
224 DWORD AB_BufLen; /* length of buffer */
225 DWORD AB_ZeroFill; /* set to 1 if zeroing */
226 DWORD AB_Reserved; /* 0 */
227} ASPI32BUFF, *PASPI32BUFF;
228
Dimitrie O. Paun53f9c212003-08-28 21:43:34 +0000229#include <poppack.h>
David Elliottc3bcd6c2000-03-08 19:41:49 +0000230
231/* Prototypes */
Patrik Stridvallbf8943c2000-10-02 03:39:34 +0000232extern DWORD __cdecl SendASPI32Command (PSRB);
233extern DWORD __cdecl GetASPI32SupportInfo (void);
234extern DWORD __cdecl GetASPI32DLLVersion(void);
Marcus Meissner485c3ef2001-06-06 20:19:07 +0000235extern BOOL __cdecl GetASPI32Buffer(PASPI32BUFF pab);
David Elliottc3bcd6c2000-03-08 19:41:49 +0000236
237#ifdef __cplusplus
238}
239#endif /* #ifdef __cplusplus */
Joerg Mayer8de3ba81999-04-03 16:26:36 +0000240
David Elliottc3bcd6c2000-03-08 19:41:49 +0000241#endif /* __WNASPI32_H__ */