| 1 |  | 
|---|
| 2 | #if !defined(WNASPI32_H) | 
|---|
| 3 | #define WNASPI32_H | 
|---|
| 4 |  | 
|---|
| 5 | /* SCSI Miscellaneous Stuff */ | 
|---|
| 6 | #define SENSE_LEN                               14 | 
|---|
| 7 | #define SRB_DIR_SCSI                        0x00 | 
|---|
| 8 | #define SRB_POSTING                             0x01 | 
|---|
| 9 | #define SRB_ENABLE_RESIDUAL_COUNT       0x04 | 
|---|
| 10 | #define SRB_DIR_IN                              0x08 | 
|---|
| 11 | #define SRB_DIR_OUT                             0x10 | 
|---|
| 12 |  | 
|---|
| 13 | /* ASPI Command Definitions */ | 
|---|
| 14 | #define SC_HA_INQUIRY                   0x00 | 
|---|
| 15 | #define SC_GET_DEV_TYPE                 0x01 | 
|---|
| 16 | #define SC_EXEC_SCSI_CMD                0x02 | 
|---|
| 17 | #define SC_ABORT_SRB                    0x03 | 
|---|
| 18 | #define SC_RESET_DEV                    0x04 | 
|---|
| 19 | #define SC_SET_HA_PARMS                 0x05 | 
|---|
| 20 | #define SC_GET_DISK_INFO                0x06 | 
|---|
| 21 |  | 
|---|
| 22 | /* SRB status codes */ | 
|---|
| 23 | #define SS_PENDING                      0x00 | 
|---|
| 24 | #define SS_COMP                         0x01 | 
|---|
| 25 | #define SS_ABORTED                      0x02 | 
|---|
| 26 | #define SS_ABORT_FAIL                   0x03 | 
|---|
| 27 | #define SS_ERR                          0x04 | 
|---|
| 28 |  | 
|---|
| 29 | #define SS_INVALID_CMD                  0x80 | 
|---|
| 30 | #define SS_INVALID_HA                   0x81 | 
|---|
| 31 | #define SS_NO_DEVICE                    0x82 | 
|---|
| 32 |  | 
|---|
| 33 | #define SS_INVALID_SRB                  0xE0 | 
|---|
| 34 | #define SS_OLD_MANAGER                  0xE1 | 
|---|
| 35 | #define SS_BUFFER_ALIGN                 0xE1 // Win32 | 
|---|
| 36 | #define SS_ILLEGAL_MODE                 0xE2 | 
|---|
| 37 | #define SS_NO_ASPI                      0xE3 | 
|---|
| 38 | #define SS_FAILED_INIT                  0xE4 | 
|---|
| 39 | #define SS_ASPI_IS_BUSY                 0xE5 | 
|---|
| 40 | #define SS_BUFFER_TO_BIG                0xE6 | 
|---|
| 41 | #define SS_MISMATCHED_COMPONENTS        0xE7 // DLLs/EXE version mismatch | 
|---|
| 42 | #define SS_NO_ADAPTERS                  0xE8 | 
|---|
| 43 | #define SS_INSUFFICIENT_RESOURCES       0xE9 | 
|---|
| 44 | #define SS_ASPI_IS_SHUTDOWN             0xEA | 
|---|
| 45 | #define SS_BAD_INSTALL                  0xEB | 
|---|
| 46 |  | 
|---|
| 47 |  | 
|---|
| 48 | /* Host status codes */ | 
|---|
| 49 | #define HASTAT_OK                       0x00 | 
|---|
| 50 | #define HASTAT_SEL_TO                   0x11 | 
|---|
| 51 | #define HASTAT_DO_DU                    0x12 | 
|---|
| 52 | #define HASTAT_BUS_FREE                 0x13 | 
|---|
| 53 | #define HASTAT_PHASE_ERR                0x14 | 
|---|
| 54 |  | 
|---|
| 55 | #define HASTAT_TIMEOUT                  0x09 | 
|---|
| 56 | #define HASTAT_COMMAND_TIMEOUT          0x0B | 
|---|
| 57 | #define HASTAT_MESSAGE_REJECT           0x0D | 
|---|
| 58 | #define HASTAT_BUS_RESET                0x0E | 
|---|
| 59 | #define HASTAT_PARITY_ERROR             0x0F | 
|---|
| 60 | #define HASTAT_REQUEST_SENSE_FAILED     0x10 | 
|---|
| 61 |  | 
|---|
| 62 |  | 
|---|
| 63 | /* Additional definitions */ | 
|---|
| 64 | /* SCSI Miscellaneous Stuff */ | 
|---|
| 65 | #define SRB_EVENT_NOTIFY                0x40 | 
|---|
| 66 | #define RESIDUAL_COUNT_SUPPORTED        0x02 | 
|---|
| 67 | #define MAX_SRB_TIMEOUT                 1080001u | 
|---|
| 68 | #define DEFAULT_SRB_TIMEOUT             1080001u | 
|---|
| 69 |  | 
|---|
| 70 | /* These are defined by MS but not adaptec */ | 
|---|
| 71 | #define SRB_DATA_SG_LIST                0x02 | 
|---|
| 72 | #define WM_ASPIPOST                     0x4D42 | 
|---|
| 73 |  | 
|---|
| 74 |  | 
|---|
| 75 | /* ASPI Command Definitions */ | 
|---|
| 76 | #define SC_RESCAN_SCSI_BUS              0x07 | 
|---|
| 77 | #define SC_GETSET_TIMEOUTS              0x08 | 
|---|
| 78 |  | 
|---|
| 79 | /* SRB Status.. MS defined */ | 
|---|
| 80 | #define SS_SECURITY_VIOLATION           0xE2 // Replaces SS_INVALID_MODE | 
|---|
| 81 |  | 
|---|
| 82 |  | 
|---|
| 83 |  | 
|---|
| 84 | //     0:      'Direct-access device (e.g., magnetic disk)'; | 
|---|
| 85 | //     1:      'Sequential-access device (e.g., magnetic tape)'; | 
|---|
| 86 | //     2:      'Printer device'; | 
|---|
| 87 | //     3:      'Processor device'; | 
|---|
| 88 | //     4:      'Write-once device (e.g., some optical disks)'; | 
|---|
| 89 | //     5:      'CD-ROM device'; | 
|---|
| 90 | //     6:      'Scanner device'; | 
|---|
| 91 | //     7:      'Optical memory device (e.g., some optical disks)'; | 
|---|
| 92 | //     8:      'Medium Changer device (e.g., jukeboxes)'; | 
|---|
| 93 | //     9:      'Communications device'; | 
|---|
| 94 | //     10..11: 'Defined by ASC IT8 (Graphic Arts Pre-Press Devices)'; | 
|---|
| 95 | //     12..30: 'Reserved'; | 
|---|
| 96 | //     31:     'Unknown or no device type'; | 
|---|
| 97 | #define SS_DEVTYPE_DIRECTACCESS         0 | 
|---|
| 98 | #define SS_DEVTYPE_SEQUENTIAL           1 | 
|---|
| 99 | #define SS_DEVTYPE_PRINTER              2 | 
|---|
| 100 | #define SS_DEVTYPE_PROCESSOR            3 | 
|---|
| 101 | #define SS_DEVTYPE_WRITEONCE            4 | 
|---|
| 102 | #define SS_DEVTYPE_CDROM                5 | 
|---|
| 103 | #define SS_DEVTYPE_SCANNER              6 | 
|---|
| 104 | #define SS_DEVTYPE_OPTICALMEMORY        7 | 
|---|
| 105 | #define SS_DEVTYPE_MEDIUMCHANGER        8 | 
|---|
| 106 | #define SS_DEVTYPE_COMMUNICATION        9 | 
|---|
| 107 |  | 
|---|
| 108 | /*** END DEFS */ | 
|---|
| 109 |  | 
|---|
| 110 | #include "pshpack1.h" | 
|---|
| 111 |  | 
|---|
| 112 | /* SRB - HOST ADAPTER INQUIRY - SC_HA_INQUIRY */ | 
|---|
| 113 | typedef struct tagSRB32_HaInquiry { | 
|---|
| 114 | BYTE  SRB_Cmd;                 /* 00 ASPI command code = SC_HA_INQUIRY */ | 
|---|
| 115 | BYTE  SRB_Status;              /* 01 ASPI command status byte */ | 
|---|
| 116 | BYTE  SRB_HaId;                /* 02 ASPI host adapter number */ | 
|---|
| 117 | BYTE  SRB_Flags;               /* 03 ASPI request flags */ | 
|---|
| 118 | DWORD  SRB_Hdr_Rsvd;           /* 04 Reserved, MUST = 0 */ | 
|---|
| 119 | BYTE  HA_Count;                /* 08 Number of host adapters present */ | 
|---|
| 120 | BYTE  HA_SCSI_ID;              /* 09 SCSI ID of host adapter */ | 
|---|
| 121 | BYTE  HA_ManagerId[16];        /* 0A String describing the manager */ | 
|---|
| 122 | BYTE  HA_Identifier[16];       /* 1A String describing the host adapter */ | 
|---|
| 123 | BYTE  HA_Unique[16];           /* 2A Host Adapter Unique parameters */ | 
|---|
| 124 | WORD  HA_Rsvd1; | 
|---|
| 125 | } SRB_HaInquiry, *PSRB_HaInquiry; | 
|---|
| 126 |  | 
|---|
| 127 | /* SRB - GET DEVICE TYPE - SC_GET_DEV_TYPE */ | 
|---|
| 128 | typedef struct tagSRB32_GDEVBlock { | 
|---|
| 129 | BYTE  SRB_Cmd;                 /* 00 ASPI command code = SC_GET_DEV_TYPE */ | 
|---|
| 130 | BYTE  SRB_Status;              /* 01 ASPI command status byte */ | 
|---|
| 131 | BYTE  SRB_HaId;                /* 02 ASPI host adapter number */ | 
|---|
| 132 | BYTE  SRB_Flags;               /* 03 Reserved */ | 
|---|
| 133 | DWORD  SRB_Hdr_Rsvd;           /* 04 Reserved */ | 
|---|
| 134 | BYTE  SRB_Target;              /* 08 Target's SCSI ID */ | 
|---|
| 135 | BYTE  SRB_Lun;                 /* 09 Target's LUN number */ | 
|---|
| 136 | BYTE  SRB_DeviceType;          /* 0A Target's peripheral device type */ | 
|---|
| 137 | BYTE  SRB_Rsvd1; | 
|---|
| 138 | } SRB_GDEVBlock, *PSRB_GDEVBlock; | 
|---|
| 139 |  | 
|---|
| 140 | /* SRB - EXECUTE SCSI COMMAND - SC_EXEC_SCSI_CMD */ | 
|---|
| 141 | typedef struct tagSRB32_ExecSCSICmd { | 
|---|
| 142 | BYTE        SRB_Cmd;            /* 00 ASPI command code = SC_EXEC_SCSI_CMD */ | 
|---|
| 143 | BYTE        SRB_Status;         /* 01 ASPI command status byte */ | 
|---|
| 144 | BYTE        SRB_HaId;           /* 02 ASPI host adapter number */ | 
|---|
| 145 | BYTE        SRB_Flags;          /* 03 ASPI request flags */ | 
|---|
| 146 | DWORD       SRB_Hdr_Rsvd;       /* 04 Reserved */ | 
|---|
| 147 | BYTE        SRB_Target;         /* 08 Target's SCSI ID */ | 
|---|
| 148 | BYTE        SRB_Lun;            /* 09 Target's LUN number */ | 
|---|
| 149 | WORD        SRB_Rsvd1;          /* 0A Reserved for Alignment */ | 
|---|
| 150 | DWORD       SRB_BufLen;         /* 0C Data Allocation Length */ | 
|---|
| 151 | BYTE        *SRB_BufPointer;    /* 10 Data Buffer Point */ | 
|---|
| 152 | BYTE        SRB_SenseLen;       /* 14 Sense Allocation Length */ | 
|---|
| 153 | BYTE        SRB_CDBLen;         /* 15 CDB Length */ | 
|---|
| 154 | BYTE        SRB_HaStat;         /* 16 Host Adapter Status */ | 
|---|
| 155 | BYTE        SRB_TargStat;       /* 17 Target Status */ | 
|---|
| 156 | void        (*SRB_PostProc)();  /* 18 Post routine */ | 
|---|
| 157 | void        *SRB_Rsvd2;         /* 1C Reserved */ | 
|---|
| 158 | BYTE        SRB_Rsvd3[16];      /* 20 Reserved for expansion */ | 
|---|
| 159 | BYTE        CDBByte[16];        /* 30 SCSI CDB */ | 
|---|
| 160 | BYTE        SenseArea[SENSE_LEN+2];  /* 40 Request sense buffer - var length */ | 
|---|
| 161 | } SRB_ExecSCSICmd, *PSRB_ExecSCSICmd; | 
|---|
| 162 |  | 
|---|
| 163 | /* SRB - ABORT AN ARB - SC_ABORT_SRB */ | 
|---|
| 164 | typedef struct tagSRB32_Abort { | 
|---|
| 165 | BYTE        SRB_Cmd;            /* 00 ASPI command code = SC_ABORT_SRB */ | 
|---|
| 166 | BYTE        SRB_Status;         /* 01 ASPI command status byte */ | 
|---|
| 167 | BYTE        SRB_HaId;           /* 02 ASPI host adapter number */ | 
|---|
| 168 | BYTE        SRB_Flags;          /* 03 Reserved */ | 
|---|
| 169 | DWORD       SRB_Hdr_Rsvd;       /* 04 Reserved, MUST = 0 */ | 
|---|
| 170 | VOID       *SRB_ToAbort;        /* 08 Pointer to SRB to abort */ | 
|---|
| 171 | } SRB_Abort, *PSRB_Abort; | 
|---|
| 172 |  | 
|---|
| 173 | /* SRB - BUS DEVICE RESET - SC_RESET_DEV */ | 
|---|
| 174 | typedef struct tagSRB32_BusDeviceReset { | 
|---|
| 175 | BYTE         SRB_Cmd;                  /* 00 ASPI cmd code = SC_RESET_DEV */ | 
|---|
| 176 | BYTE         SRB_Status;               /* 01 ASPI command status byte */ | 
|---|
| 177 | BYTE         SRB_HaId;                 /* 02 ASPI host adapter number */ | 
|---|
| 178 | BYTE         SRB_Flags;                /* 03 Reserved */ | 
|---|
| 179 | DWORD        SRB_Hdr_Rsvd;             /* 04 Reserved */ | 
|---|
| 180 | BYTE         SRB_Target;               /* 08 Target's SCSI ID */ | 
|---|
| 181 | BYTE         SRB_Lun;                  /* 09 Target's LUN number */ | 
|---|
| 182 | BYTE         SRB_Rsvd1[12];            /* 0A Reserved for Alignment */ | 
|---|
| 183 | BYTE         SRB_HaStat;               /* 16 Host Adapter Status */ | 
|---|
| 184 | BYTE         SRB_TargStat;             /* 17 Target Status */ | 
|---|
| 185 | void         (*SRB_PostProc)();        /* 18 Post routine */ | 
|---|
| 186 | void         *SRB_Rsvd2;               /* 1c Reserved */ | 
|---|
| 187 | BYTE         SRB_Rsvd3[32];            /* 20 Reserved */ | 
|---|
| 188 | } SRB_BusDeviceReset, *PSRB_BusDeviceReset; | 
|---|
| 189 |  | 
|---|
| 190 | /* SRB - GET DISK INFORMATION - SC_GET_DISK_INFO */ | 
|---|
| 191 | typedef struct tagSRB32_GetDiskInfo { | 
|---|
| 192 | BYTE         SRB_Cmd;                  /* 00 ASPI cmd code = SC_RESET_DEV */ | 
|---|
| 193 | BYTE         SRB_Status;               /* 01 ASPI command status byte */ | 
|---|
| 194 | BYTE         SRB_HaId;                 /* 02 ASPI host adapter number */ | 
|---|
| 195 | BYTE         SRB_Flags;                /* 03 Reserved */ | 
|---|
| 196 | DWORD        SRB_Hdr_Rsvd;             /* 04 Reserved */ | 
|---|
| 197 | BYTE         SRB_Target;               /* 08 Target's SCSI ID */ | 
|---|
| 198 | BYTE         SRB_Lun;                  /* 09 Target's LUN number */ | 
|---|
| 199 | BYTE         SRB_DriveFlags;           /* 0A Driver flags */ | 
|---|
| 200 | BYTE         SRB_Int13HDriveInfo;      /* 0B Host Adapter Status */ | 
|---|
| 201 | BYTE         SRB_Heads;                /* 0C Preferred number of heads trans */ | 
|---|
| 202 | BYTE         SRB_Sectors;              /* 0D Preferred number of sectors trans */ | 
|---|
| 203 | BYTE         SRB_Rsvd1[10];            /* 0E Reserved */ | 
|---|
| 204 | } SRB_GetDiskInfo, *PSRB_GetDiskInfo; | 
|---|
| 205 |  | 
|---|
| 206 | /* SRB header */ | 
|---|
| 207 | typedef struct tagSRB32_Header { | 
|---|
| 208 | BYTE         SRB_Cmd;                  /* 00 ASPI cmd code = SC_RESET_DEV */ | 
|---|
| 209 | BYTE         SRB_Status;               /* 01 ASPI command status byte */ | 
|---|
| 210 | BYTE         SRB_HaId;                 /* 02 ASPI host adapter number */ | 
|---|
| 211 | BYTE         SRB_Flags;                /* 03 Reserved */ | 
|---|
| 212 | DWORD        SRB_Hdr_Rsvd;             /* 04 Reserved */ | 
|---|
| 213 | } SRB_Header, *PSRB_Header; | 
|---|
| 214 |  | 
|---|
| 215 | typedef union tagSRB32 { | 
|---|
| 216 | SRB_Header          common; | 
|---|
| 217 | SRB_HaInquiry       inquiry; | 
|---|
| 218 | SRB_ExecSCSICmd     cmd; | 
|---|
| 219 | SRB_Abort           abort; | 
|---|
| 220 | SRB_BusDeviceReset  reset; | 
|---|
| 221 | SRB_GDEVBlock       devtype; | 
|---|
| 222 | SRB_GetDiskInfo     diskinfo; | 
|---|
| 223 | } SRB, *PSRB, *LPSRB; | 
|---|
| 224 |  | 
|---|
| 225 | typedef struct tagASPI32BUFF { | 
|---|
| 226 | LPBYTE AB_BufPointer;       /* pointer to buffer */ | 
|---|
| 227 | DWORD AB_BufLen;            /* length of buffer */ | 
|---|
| 228 | DWORD AB_ZeroFill;          /* set to 1 if zeroing */ | 
|---|
| 229 | DWORD AB_Reserved;          /* 0 */ | 
|---|
| 230 | } ASPI32BUFF, *PASPI32BUFF; | 
|---|
| 231 |  | 
|---|
| 232 | #include "poppack.h" | 
|---|
| 233 |  | 
|---|
| 234 | /* Prototypes */ | 
|---|
| 235 | extern DWORD __cdecl SendASPI32Command (PSRB); | 
|---|
| 236 | extern DWORD __cdecl GetASPI32SupportInfo (void); | 
|---|
| 237 | extern DWORD __cdecl GetASPI32DLLVersion(void); | 
|---|
| 238 | extern BOOL  __cdecl GetASPI32Buffer(PASPI32BUFF pab); | 
|---|
| 239 |  | 
|---|
| 240 | #endif | 
|---|