1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
|
unit WnASPI32;
{-----------------------------------------------------------------------------------------------------------------
WnASPI32
Module : Definitions WnASPI32.dll
==================
Sources :
- Adaptec ASPI SDK
- http://msdn.microsoft.com/library/default.asp?url=/library/en-us/w98ddk/hh/w98ddk/storage_5nzr.asp
==================
Auteur : Bertrand Danos (Millenod)
Date de mise à jour : 2004-04-20
------------------------------------------------------------------------------------------------------------------}
interface
Uses
Windows,
SysUtils;
const
// SENSE_LEN = 32; // Default sense buffer length
SENSE_LEN = 14; // Default sense buffer length
SRB_DIR_SCSI = $00; // Direction determined by SCSI
SRB_POSTING = $01; // Enable ASPI posting
SRB_DATA_SG_LIST = $02; // Data buffer points to scatter-gather list
SRB_ENABLE_RESIDUAL_COUNT = $04; // Enable residual byte count reporting
SRB_DIR_IN = $08; // Transfer from SCSI target to host
SRB_DIR_OUT = $10; // Transfer from host to SCSI target
SRB_EVENT_NOTIFY = $40; // Enable ASPI event notification
{===============================================================================
ASPI Command Definitions (SendASPI32Command)
================================================================================}
const
SC_HA_INQUIRY = $00; // Host adapter inquiry
SC_GET_DEV_TYPE = $01; // Get device type
SC_EXEC_SCSI_CMD = $02; // Execute SCSI command
SC_ABORT_SRB = $03; // Abort an SCSI Request Block (SRB)
SC_RESET_DEV = $04; // SCSI bus device reset
SC_SET_HA_PARMS = $05; // Set HA parameters
SC_GET_DISK_INFO = $06; // Get Disk information
SC_RESCAN_SCSI_BUS = $07; // ReBuild SCSI device map
SC_GETSET_TIMEOUTS = $08; // Get/Set target timeouts
{===============================================================================
SCSI Request Block (SRB) Status
================================================================================}
const
SS_PENDING = $00; // SRB being processed
SS_COMP = $01; // SRB completed without error
SS_ABORTED = $02; // SRB aborted
SS_ABORT_FAIL = $03; // Unable to abort SRB
SS_ERR = $04; // SRB completed with error
SS_INVALID_CMD = $80; // Invalid ASPI command
SS_INVALID_HA = $81; // Invalid host adapter number
SS_NO_DEVICE = $82; // SCSI device not installed
SS_INVALID_SRB = $E0; // Invalid parameter set in SRB
SS_BUFFER_ALIGN = $E1; // Buffer not aligned (replaces OLD_MANAGER in Win32)
SS_ILLEGAL_MODE = $E2; // Unsupported Windows mode
SS_NO_ASPI = $E3; // No ASPI managers resident
SS_FAILED_INIT = $E4; // ASPI for windows failed init
SS_ASPI_IS_BUSY = $E5; // No resources available to execute cmd
SS_BUFFER_TO_BIG = $E6; // Buffer size to big to handle!
SS_MISMATCHED_COMPONENTS = $E7; // The DLLs/EXEs of ASPI don't version check
SS_NO_ADAPTERS = $E8; // No host adapters to manage
SS_INSUFFICIENT_RESOURCES = $E9; // Couldn't allocate resources needed to init
SS_ASPI_IS_SHUTDOWN = $EA; // Call came to ASPI after PROCESS_DETACH
SS_BAD_INSTALL = $EB; // The DLL or other components are installed wrong
{===============================================================================
Host Adapter Status
================================================================================}
const
HASTAT_OK = $00; // Host adapter did not detect an error
HASTAT_SEL_TO = $11; // Selection Timeout
HASTAT_DO_DU = $12; // Data overrun data underrun
HASTAT_BUS_FREE = $13; // Unexpected bus free
HASTAT_PHASE_ERR = $14; // Target bus phase sequence failure
HASTAT_TIMEOUT = $09; // Timed out while SRB was waiting to beprocessed
HASTAT_COMMAND_TIMEOUT = $0B; // Adapter timed out processing SRB
HASTAT_MESSAGE_REJECT = $0D; // While processing SRB, the adapter received a MESSAGE
HASTAT_BUS_RESET = $0E; // A bus reset was detected
HASTAT_PARITY_ERROR = $0F; // A parity error was detected
HASTAT_REQUEST_SENSE_FAILED = $10; // The adapter failed in issuing
{===============================================================================
SCSI devices type
================================================================================}
const
DTYPE_DASD = $00; // Direct Access Device (e.g. magnetic disk)
DTYPE_SEQD = $01; // Sequential Access Device (e.g. magnetic tape)
DTYPE_PRNT = $02; // Printer Device
DTYPE_PROC = $03; // Processor Device
DTYPE_WORM = $04; // Write Once Device (e.g. some optical disks)
DTYPE_CDROM = $05; // CD-Rom Device
DTYPE_SCAN = $06; // Scanner Device
DTYPE_OPTI = $07; // Optical Memory Device (e.g. some optical disks)
DTYPE_JUKE = $08; // Medium Changer Device (e.g. some jukebox)
DTYPE_COMM = $09; // Communication Device
DTYPE_UNKNOWN = $1F; // Unknown or no device type
{===============================================================================
SCSI devices Names
================================================================================}
const
DeviceName : array [0..$1F] of String =
( '00 - Hard disk', // Direct Access Device (e.g. magnetic disk)
'01 - Tape drive', // Sequential Access Device (e.g. magnetic tape)
'02 - Printer', // Printer Device
'03 - Processor', // Processor Device
'04 - WORM unit', // Write Once Device (e.g. some optical disks)
'05 - CD-ROM drive', // CD-Rom Device
'06 - Scanner', // Scanner Device
'07 - RAM disk', // Optical Memory Device (e.g. some optical disks)
'08 - Media changer', // Medium Changer Device (e.g. some jukebox)
'09 - Comm device', // Communication Device
'0A - ASC IT8', // Defined by ASC IT8 (Graphic Arts pre press devices)
'0B - ASC IT8', // Defined by ASC IT8 (Graphic Arts pre press devices)
'0C - N/A',
'0D - N/A',
'0E - N/A',
'0F - N/A',
'10 - N/A',
'11 - N/A',
'12 - N/A',
'13 - N/A',
'14 - N/A',
'15 - N/A',
'16 - N/A',
'17 - N/A',
'18 - N/A',
'19 - N/A',
'1A - N/A',
'1B - N/A',
'1C - N/A',
'1D - N/A',
'1E - N/A',
'1F - UNKNOWN unit' // Unknown or no device type
);
{===============================================================================
Commands for all Device Types
================================================================================}
const
SCSI_CHANGE_DEF = $40; // Change Definition (Optional)
SCSI_COMPARE = $39; // Compare (O)
SCSI_COPY = $18; // Copy (O)
SCSI_COP_VERIFY = $3A; // Copy and Verify (O)
SCSI_INQUIRY = $12; // Inquiry (MANDATORY)
SCSI_LOG_SELECT = $4C; // Log Select (O)
SCSI_LOG_SENSE = $4D; // Log Sense (O)
SCSI_MODE_SEL6 = $15; // Mode Select 6-byte (Device Specific)
SCSI_MODE_SEL10 = $55; // Mode Select 10-byte (Device Specific)
SCSI_MODE_SEN6 = $1A; // Mode Sense 6-byte (Device Specific)
SCSI_MODE_SEN10 = $5A; // Mode Sense 10-byte (Device Specific)
SCSI_READ_BUFF = $3C; // Read Buffer (O)
SCSI_REQ_SENSE = $03; // Request Sense (MANDATORY)
SCSI_SEND_DIAG = $1D; // Send Diagnostic (O)
SCSI_TST_U_RDY = $00; // Test Unit Ready (MANDATORY)
SCSI_WRITE_BUFF = $3B; // Write Buffer (O)
{--------------------------------------------------------------------------------------------------------------------
Structures
---------------------------------------------------------------------------------------------------------------------}
Type
LPSRB = Pointer;
TSRB = packed record
SRB_Cmd : BYTE; // 00/000 ASPI command code = SC_HA_INQUIRY
SRB_Status : BYTE; // 01/001 ASPI command status byte
SRB_HaId : BYTE; // 02/002 ASPI host adapter number
SRB_Flags : BYTE; // 03/003 ASPI request flags
SRB_Hdr_Rsvd : DWORD; // 04/004 Reserved, MUST = 0
End;
PSRB = ^TSRB;
TSRB_HAInquiry = packed record
SRB_Cmd : BYTE; // 00/000 ASPI command code = SC_HA_INQUIRY
SRB_Status : BYTE; // 01/001 ASPI command status byte
SRB_HaId : BYTE; // 02/002 ASPI host adapter number
SRB_Flags : BYTE; // 03/003 ASPI request flags
SRB_Hdr_Rsvd : DWORD; // 04/004 Reserved, MUST = 0
HA_Count : BYTE; // 08/008 Number of host adapters present
HA_SCSI_ID : BYTE; // 09/009 SCSI ID of host adapter
HA_ManagerId : array [0..15] of char; // 0A/010 String describing the manager
HA_Identifier : array [0..15] of char; // 1A/026 String describing the host adapter
HA_Unique : array [0..15] of char; // 2A/042 Host Adapter Unique parameters
HA_Rsvd1 : WORD; // 3A/058 Reserved, MUST = 0
end;
PSRB_HAInquiry = ^TSRB_HAInquiry;
TSRB_GDEVBlock = packed record
SRB_Cmd : BYTE; // 00/000 ASPI command code = SC_GET_DEV_TYPE
SRB_Status : BYTE; // 01/001 ASPI command status byte
SRB_HaId : BYTE; // 02/002 ASPI host adapter number
SRB_Flags : BYTE; // 03/003 Reserved, MUST = 0
SRB_Hdr_Rsvd : DWORD; // 04/004 Reserved, MUST = 0
SRB_Target : BYTE; // 08/008 Target's SCSI ID
SRB_Lun : BYTE; // 09/009 Target's LUN number
SRB_DeviceType : BYTE; // 0A/010 Target's peripheral device type
SRB_Rsvd1 : BYTE; // 0B/011 Reserved, MUST = 0
End;
PSRB_GDEVBlock = ^TSRB_GDEVBlock;
TSRB_ExecSCSICmd = packed record
SRB_Cmd : BYTE; // ASPI command code
SRB_Status : BYTE; // ASPI command status byte
SRB_HaId : BYTE; // ASPI host adapter number
SRB_Flags : BYTE; // ASPI request flags
SRB_Hdr_Rsvd : DWORD; // Reserved
SRB_Target : BYTE; // Target's SCSI ID
SRB_Lun : BYTE; // Target's LUN number
SRB_Rsvd1 : WORD; // Reserved for Alignment
SRB_BufLen : DWORD; // Data Allocation Length
SRB_BufPointer : Pointer; // Data Buffer Pointer
SRB_SenseLen : BYTE; // Sense Allocation Length
SRB_CDBLen : BYTE; // CDB Length
SRB_HaStat : BYTE; // Host Adapter Status
SRB_TargStat : BYTE; // Target Status
SRB_PostProc : THandle; // Post routine
SRB_Rsvd2 : array[0..19] of BYTE; // Reserved, MUST = 0
CDBByte : array[0..15] of BYTE; // SCSI CDB
SenseArea : array[0..(SENSE_LEN+1)] of BYTE; // Request Sense buffer
end;
PSRB_ExecSCSICmd = ^TSRB_ExecSCSICmd;
TSRB_BusDeviceReset = packed record
SRB_Cmd : BYTE; // ASPI command code = SC_RESET_DEV
SRB_Status : BYTE; // ASPI command status byte
SRB_HaId : BYTE; // ASPI host adapter number
SRB_Flags : BYTE; // Reserved, MUST = 0
SRB_Hdr_Rsvd : DWORD; // Reserved, MUST = 0
SRB_Target : BYTE; // Target's SCSI ID
SRB_Lun : BYTE; // Target's LUN number
SRB_DeviceType : BYTE; // Target's peripheral device type
SRB_Rsvd1 : array[0..11] of byte; // Reserved, MUST = 0
SRB_HaStat : BYTE; //
SRB_TargStat : BYTE; // Target Status
SRB_PostProc : THandle; // Post routine
SRB_Rsvd2 : array[0..35] of byte; // Reserved
End;
PSRB_BusDeviceReset = ^TSRB_BusDeviceReset;
TSRB_Abort = packed record
SRB_Cmd : Byte; // ASPI command code = SC_ABORT_SRB
SRB_Status : Byte; // ASPI command status byte
SRB_HaId : Byte; // ASPI host adapter number
SRB_Flags : Byte; // Reserved
SRB_Hdr_Rsvd : Integer; // Reserved
SRB_ToAbort : Pointer; // Pointer to SRB to abort
End;
PSRB_Abort = ^TSRB_Abort;
TSRB_GetDiskInfo = packed record
SRB_Cmd : Byte; // ASPI command code = SC_GET_DISK_INFO
SRB_Status : Byte; // ASPI command status Byte
SRB_HaId : Byte; // ASPI host adapter number
SRB_Flags : Byte; // Reserved
SRB_Hdr_Rsvd : Integer; // Reserved
SRB_Target : Byte; // Target's SCSI ID
SRB_Lun : Byte; // Target's LUN number
SRB_DriveFlags : Byte; // Driver flags
SRB_Int13HDriveInfo : Byte; // Host Adapter Status
SRB_Heads : Byte; // Preferred number of heads translation
SRB_Sectors : Byte; // Preferred number of sectors translation
SRB_Rsvd1 : array [0..9] of byte; // Reserved
End;
PSRB_GetDiskInfo = ^TSRB_GetDiskInfo;
TSRB_GetSetTimeOut = packed record
SRB_Cmd : Byte; // ASPI command code = SC_GET_SET_TIMEOUT
SRB_Status : Byte; // ASPI command status Byte
SRB_HaId : Byte; // ASPI host adapter number
SRB_Flags : Byte; // Reserved
SRB_Hdr_Rsvd : Integer; // Reserved
SRB_Target : Byte; // Target's SCSI ID
SRB_Lun : Byte; // Target's LUN number
SRB_TimeOut : DWord; // timeout in half seconds
End;
PSRB_GetSetTimeOut = ^TSRB_GetSetTimeOut;
TAspi32Buff = packed record
AB_BufPointer : PByteArray; // Pointer to the ASPI allocated buffer
AB_BufLen : DWord; // Length in bytes of the buffer
AB_ZeroFill : DWord; // Flag set to 1 if buffer should be zeroed
AB_Reserved : DWord; // Reserved, MUST = 0
End;
PAspi32Buff = ^TAspi32Buff;
{===============================================================================
Import WnASPI32.dll functions
===============================================================================}
Type
pfnGetASPI32SupportInfo = function : DWord; cdecl;
pfnSendASPI32Command = function(Srb : PSRB_ExecScsiCMD) : DWORD; cdecl;
pfnGetASPI32Buffer = function(Aspi32Buff : PAspi32buff) : boolean; cdecl;
pfnFreeASPI32Buffer = function(Aspi32Buff : PAspi32buff) : boolean; cdecl;
pfnTranslateASPI32Address = function(var AD1,AD2 : DWord) : boolean; cdecl;
pfnGetASPI32DLLVersion = function : integer; cdecl;
(* Poikosoft aspi *)
pLockASPINTVolume = function (bLock : Boolean; HaId, Target, Lun : byte) : boolean; cdecl;
pfnRegisterWOWPost = function (aParam : Dword) : boolean; cdecl;
pfnWOWDispatch = function (aParam : Dword) : boolean; cdecl;
implementation
end. |
Partager