Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 1 | /* |
| 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 Ernst | 360a3f9 | 2006-05-18 14:49:52 +0200 | [diff] [blame] | 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 17 | */ |
| 18 | |
David Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 19 | #ifndef __WNASPI32_H__ |
| 20 | #define __WNASPI32_H__ |
Patrik Stridvall | 857eb39 | 1999-06-12 18:36:54 +0000 | [diff] [blame] | 21 | |
David Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 22 | /* This file should be 100% source compatible according to MSes docs and |
| 23 | * Adaptecs docs */ |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 24 | |
David Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 25 | #ifdef __cplusplus |
| 26 | extern "C" { |
| 27 | #endif /* #ifdef __cplusplus */ |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 28 | |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 29 | /* 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 Mattinson | 88773cd | 2002-06-28 17:37:34 +0000 | [diff] [blame] | 59 | #define SS_BUFFER_ALIGN 0xE1 /* Win32 */ |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 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 |
Gregg Mattinson | 88773cd | 2002-06-28 17:37:34 +0000 | [diff] [blame] | 65 | #define SS_MISMATCHED_COMPONENTS 0xE7 /* DLLs/EXE version mismatch */ |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 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 |
| 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 Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 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 |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 93 | |
David Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 94 | /* These are defined by MS but not adaptec */ |
| 95 | #define SRB_DATA_SG_LIST 0x02 |
| 96 | #define WM_ASPIPOST 0x4D42 |
Uwe Bonnes | 72dd525 | 1999-06-06 14:34:32 +0000 | [diff] [blame] | 97 | |
David Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 98 | |
| 99 | /* ASPI Command Definitions */ |
| 100 | #define SC_RESCAN_SCSI_BUS 0x07 |
| 101 | #define SC_GETSET_TIMEOUTS 0x08 |
| 102 | |
| 103 | /* SRB Status.. MS defined */ |
Gregg Mattinson | 88773cd | 2002-06-28 17:37:34 +0000 | [diff] [blame] | 104 | #define SS_SECURITY_VIOLATION 0xE2 /* Replaces SS_INVALID_MODE */ |
David Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 105 | /*** END DEFS */ |
| 106 | |
Dimitrie O. Paun | 53f9c21 | 2003-08-28 21:43:34 +0000 | [diff] [blame] | 107 | #include <pshpack1.h> |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 108 | |
David Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 109 | /* SRB - HOST ADAPTER INQUIRY - SC_HA_INQUIRY */ |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 110 | typedef struct tagSRB32_HaInquiry { |
Andreas Mohr | 1af53cb | 2000-12-09 03:15:32 +0000 | [diff] [blame] | 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 */ |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 121 | WORD HA_Rsvd1; |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 122 | } SRB_HaInquiry, *PSRB_HaInquiry; |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 123 | |
David Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 124 | /* SRB - GET DEVICE TYPE - SC_GET_DEV_TYPE */ |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 125 | typedef struct tagSRB32_GDEVBlock { |
Andreas Mohr | 1af53cb | 2000-12-09 03:15:32 +0000 | [diff] [blame] | 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 */ |
David Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 134 | BYTE SRB_Rsvd1; |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 135 | } SRB_GDEVBlock, *PSRB_GDEVBlock; |
David Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 136 | |
| 137 | /* SRB - EXECUTE SCSI COMMAND - SC_EXEC_SCSI_CMD */ |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 138 | typedef struct tagSRB32_ExecSCSICmd { |
Andreas Mohr | 1af53cb | 2000-12-09 03:15:32 +0000 | [diff] [blame] | 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)(); /* 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 Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 158 | } SRB_ExecSCSICmd, *PSRB_ExecSCSICmd; |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 159 | |
David Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 160 | /* SRB - ABORT AN ARB - SC_ABORT_SRB */ |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 161 | typedef struct tagSRB32_Abort { |
Andreas Mohr | 1af53cb | 2000-12-09 03:15:32 +0000 | [diff] [blame] | 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 */ |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 168 | } SRB_Abort, *PSRB_Abort; |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 169 | |
David Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 170 | /* SRB - BUS DEVICE RESET - SC_RESET_DEV */ |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 171 | typedef struct tagSRB32_BusDeviceReset { |
Andreas Mohr | 1af53cb | 2000-12-09 03:15:32 +0000 | [diff] [blame] | 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)(); /* 18 Post routine */ |
| 183 | void *SRB_Rsvd2; /* 1c Reserved */ |
| 184 | BYTE SRB_Rsvd3[32]; /* 20 Reserved */ |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 185 | } SRB_BusDeviceReset, *PSRB_BusDeviceReset; |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 186 | |
David Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 187 | /* SRB - GET DISK INFORMATION - SC_GET_DISK_INFO */ |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 188 | typedef struct tagSRB32_GetDiskInfo { |
Andreas Mohr | 1af53cb | 2000-12-09 03:15:32 +0000 | [diff] [blame] | 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 */ |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 201 | } SRB_GetDiskInfo, *PSRB_GetDiskInfo; |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 202 | |
David Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 203 | /* SRB header */ |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 204 | typedef struct tagSRB32_Header { |
Andreas Mohr | 1af53cb | 2000-12-09 03:15:32 +0000 | [diff] [blame] | 205 | 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 Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 210 | } SRB_Header, *PSRB_Header; |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 211 | |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 212 | typedef 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 Meissner | 485c3ef | 2001-06-06 20:19:07 +0000 | [diff] [blame] | 219 | SRB_GetDiskInfo diskinfo; |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 220 | } SRB, *PSRB, *LPSRB; |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 221 | |
Vincent BĂ©ron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 222 | typedef struct tagASPI32BUFF { |
Marcus Meissner | 485c3ef | 2001-06-06 20:19:07 +0000 | [diff] [blame] | 223 | 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. Paun | 53f9c21 | 2003-08-28 21:43:34 +0000 | [diff] [blame] | 229 | #include <poppack.h> |
David Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 230 | |
| 231 | /* Prototypes */ |
Patrik Stridvall | bf8943c | 2000-10-02 03:39:34 +0000 | [diff] [blame] | 232 | extern DWORD __cdecl SendASPI32Command (PSRB); |
| 233 | extern DWORD __cdecl GetASPI32SupportInfo (void); |
| 234 | extern DWORD __cdecl GetASPI32DLLVersion(void); |
Marcus Meissner | 485c3ef | 2001-06-06 20:19:07 +0000 | [diff] [blame] | 235 | extern BOOL __cdecl GetASPI32Buffer(PASPI32BUFF pab); |
David Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 236 | |
| 237 | #ifdef __cplusplus |
| 238 | } |
| 239 | #endif /* #ifdef __cplusplus */ |
Joerg Mayer | 8de3ba8 | 1999-04-03 16:26:36 +0000 | [diff] [blame] | 240 | |
David Elliott | c3bcd6c | 2000-03-08 19:41:49 +0000 | [diff] [blame] | 241 | #endif /* __WNASPI32_H__ */ |