📄 scsitypes.pas
字号:
{-----------------------------------------------------------------------------
Unit Name: SCSITypes
Author: Sergey Kabikov
Purpose: SCSI Types
History: Some Types by Sergey Kabikov based on his code ASPI/SCSI Library
Added to by Dancemammal
-----------------------------------------------------------------------------}
unit SCSITypes;
interface
uses Windows, Wnaspi32;
const
ScsiModePageParamsLength = 255;
ScsiModeTemplateParamsLength = ScsiModePageParamsLength + 128;
CDSTATUS_READ_CD_R = 1; // Device is capable to read CD-R media
// as defined in Orange Book Part II
CDSTATUS_READ_CD_RW = 2; // Device is capable to read CD-RW media
// as defined in Orange Book Part III
CDSTATUS_READ_METHOD2 = 4; // Device is capable to read CD-R written
// using fixed packet tracks (Addressing Method 2)
CDSTATUS_READ_DVD_ROM = 8; // Device is capable to read DVD media
CDSTATUS_READ_DVD_R = $10; // Device is capable to read DVD-R media
CDSTATUS_READ_DVD_RAM = $20; // Device is capable to read DVD-RAM media
// ====== Bit constants for TScsiModePageCdStatus.Flags[1] ======
CDSTATUS_WRITE_CD_R = 1; // Device is capable to write CD-R media
CDSTATUS_WRITE_CD_RW = 2; // Device is capable to write CD-RW media
CDSTATUS_TEST_MODE = 4; // If this flag is set, device shall only
// accept data and not write to the media
CDSTATUS_WRITE_DVD_R = $10; // Device is capable to write DVD-R media
CDSTATUS_WRITE_DVD_RAM = $20; // Device is capable to write DVD-RAM media
// ====== Bit constants for TScsiModePageCdStatus.Flags[2] ======
CDSTATUS_AUDIO_PLAY = 1; // Device is capable to AUDIO PLAY
CDSTATUS_AUDIO_COMPOSITE = 2; // Device is capable of delivering a
// composite audio and video data stream
CDSTATUS_AUDIO_DIGIPORT1 = 4; // Device supports digital output
CDSTATUS_AUDIO_DIGIPORT2 = 8; // (IEC958) on port 1/2
CDSTATUS_READ_MODE2_FORM1 = $10; // Device is capable to read Mode 2
// Form 1 fomat (eXtended Audio, CD-XA format)
CDSTATUS_READ_MODE2_FORM2 = $20; // Device is capable to read Mode 2
// Form 2 format
CDSTATUS_READ_MULTISESSION = $40; // Device is capable to read PhotoCD
// format with multiple sessions on disc
CDSTATUS_BURN_PROOF = $80; // DEVICE HAS BURN PROOF INSTALLED ??
// ====== Bit constants for TScsiModePageCdStatus.Flags[3] ======
CDSTATUS_CDDA_CAPABLE = 1; // Device supports an audio CD
// (Red Book) reading using READ CD command
CDSTATUS_CDDA_STREAM_ACCURATE = 2; // Device returns to an audio
// location without losing place to continue reading
CDSTATUS_CDDA_RW_SUPPORT = 4; // Device supports an audio CD
// subchannel combined R-W information reading
CDSTATUS_CDDA_RW_CORRECTED = 8; // The R-W subchannel data will
// be returned de-interleaved and error-corrected
CDSTATUS_CDDA_C2_POINTERS = $10; // Device is capable to return
// C2 Error Pointers and C2 Block Error Flags
CDSTATUS_CDDA_ISRC = $20; // Device can return the
// International Standard Recording Code information
CDSTATUS_CDDA_UPC = $40; // Device can return the
// Media Catalog Number (UPC) for an audio CD
CDSTATUS_CDDA_BARCODE = $80; // Device can read disc bar code
// ====== Bit constants for TScsiModePageCdStatus.Flags[4] ======
CDSTATUS_LOCK_CAPABLE = 1; // Device is capable to execute the
// PREVENT/ALLOW MEDIA REMOVAL command and performs
// an actually locking the media into drive
CDSTATUS_LOCK_STATE = 2; // Current state of device (1=locked)
CDSTATUS_PREVENT_JUMPER = 4; // Current state of the (optional)
// Prevent/Allow media removal jumper.
CDSTATUS_EJECT_CAPABLE = 8; // Device is capable to eject media
// via the START/STOP command with LoEj bit set.
// ====== Bit constants for TScsiModePageCdStatus.Flags[5] ======
CDSTATUS_SEPARATE_VOLUME = 1; // Device supports the separate audio
// level control for each channel
CDSTATUS_SEPARATE_MUTE = 2; // Device supports the independent
// mute capability for each channel
CDSTATUS_REPORTS_HAVE_DISK = 4; // The response to the MECHANISM STATUS
// command will contain valid DiscPresent field.
CDSTATUS_SLOT_SELECTION = 8; // Controls the behavior of LOAD/UNLOAD
// command when trying to load a Slot with no disc
CDSTATUS_SIDE_CHANGE = $10; // Device is capable to select both
// sides of disc (for disc changers only)
CDSTATUS_CDDA_RW_LEAD_IN = $20; // Device supports an audio CD R-W
// subchannel information reading from the Lead-in
// ====== Bit constants for TScsiModePageCdStatus.DigiPortFormat ======
CDSTATUS_DIGIPORT_BCKF = 2; // Port data valid on rising(0) or
// falling(1) edge of BCK signal.
CDSTATUS_DIGIPORT_RCK = 4; // HIGH on LRCK indicates right(0)
// or left(1) channel.
CDSTATUS_DIGIPORT_LSBF = 8; // Data are sent MSB(0) or LSB(1) first.
CDSTATUS_DIGIPORT_BCKLEN0 = $10; // Two bits indicates length in BCKs :
CDSTATUS_DIGIPORT_BCKLEN1 = $20; // 00=32, 01=16, 10=24, 11=24(FS)
type
TBurnerID = DWORD;
type
TCDBurnerInfo = record
DriveIndex: Integer;
DriveLetter: Char;
DriveID: DWORD;
ProductID: string;
VendorID: string;
VendorName: string;
VendorSpec: string;
Revision: string;
SptiHandle: THandle;
HaId: Byte;
Target: Byte;
Lun: Byte;
end;
TCdRomModePageType = (MPTcurrent, MPTchangeable, MPTdefault, MPTsaved);
type
TScsiError = {======== Errors from SRB_Status field ========}
(Err_None, Err_Aborted, Err_InvalidRequest,
Err_HAerror, Err_InvalidHostAdapter, Err_NoDevice,
Err_InvalidSrb, Err_BufferAlign, Err_AspiIsBusy,
Err_BufferTooBig, Err_Unknown,
{======== Errors from SRB_HaStat field ========}
Err_CommandTimeout,
Err_SrbTimeout,
Err_MessageReject,
Err_BusReset,
Err_ParityError,
Err_RequestSenseFailed,
Err_SelectionTimeout,
Err_DataOverrun, //... or underrun
Err_UnexpectedBusFree,
Err_BusPhaseSequence, //... failure
{======== Errors from SRB_TargStat field ========}
Err_CheckCondition,
Err_TargetBusy,
Err_TargetReservationConflict,
Err_TargetQueueFull,
{======== Errors of SendScsiCommand ========}
Err_InvalidDevice, // Trying to exec SCSI command for non-exist device
Err_NoEvent, // Unable to get event handle for notification
Err_NotifyTimeout, // WaitForSingleObject result was unacceptable
{======== Errors of SCSIxxxx() procedures =======}
Err_InvalidArgument,
{======== Errors from SRB_Sense area ========}
Err_SenseUnknown, // Unknown SRB_Sense.ErrorCode value
Err_SenseFileMark,
Err_SenseEndOfMedia,
Err_SenseIllegalLength,
Err_SenseIncorrectLength,
Err_SenseNoSense, // There is no sense key info to be reported
Err_SenseRecoveredError, // Last command completed successfully with
// some recovery action performed by the target.
Err_SenseNotReady, // Unit addressed cannot be accessed.
// Operator intervention may be required.
Err_SenseMediumError, // Command terminated with a non-recovered
// error condition that was probably caused by a flaw
// in the medium or an error in the recorded data.
Err_SenseHardwareError, // Non-recoverable hardware failure detected
Err_SenseIllegalRequest, // Illegal parameter detected in the command
// descriptor block or in the additional parameters.
Err_SenseUnitAttention, // Removable medium may have been changed or
// the target has been reset.
Err_SenseDataProtect, // Read/Write Command was applied to the
// block that is protected from this operation.
Err_SenseBlankCheck, // Write-once device or a sequential-access
// device encountered blank medium or end-of-data
// indication while reading or a write-once device
// encountered a non-blank medium while writing.
Err_SenseVendorSpecific,
Err_SenseCopyAborted, // COPY, COMPARE, or COPY AND VERIFY command
// was aborted due to an error condition on the source
// device, the destination device, or both.
Err_SenseAbortedCommand, // Target aborted the command. Host may be
// able to recover by trying the command again.
Err_SenseEqual, // SEARCH DATA has satisfied an equal comparison.
Err_SenseVolumeOverflow, // Buffered peripheral device has reached
// the end-of-partition and data may remain in the
// buffer that has not been written to the medium.
// RECOVER BUFFERED DATA command may be issued to read
// the unwritten data from the buffer.
Err_SenseMiscompare, // Source data did not match the data read
// from the medium.
Err_SenseReserved
);
PScsiDefaults = ^TScsiDefaults;
TASPIcommandSendingEvent = procedure(
DeviceID: TCDBurnerInfo;
Pcdb: pointer;
CdbLen: DWORD;
Pbuf: pointer;
BufLen: DWORD;
Direction: DWORD;
pSDF: PScsiDefaults;
AspiResult: TScsiError) of object;
TScsiDefaults = record
Timeout: DWORD; // Timeout for all "fast" commands in milliseconds
ReadTimeout: DWORD; // Same for CD media reading commands
AudioTimeout: DWORD; // Same for audio CD commands
SpindleTimeout: DWORD; // Same for SCSIstartStopUnit()
fOnCommandSending, // ASPIsendScsiCommand() logging events
fOnCommandSent: TASPIcommandSendingEvent;
ModePageType: TCdRomModePageType; // For MODE SENSE/MODE SELECT cmds
Sense: TscsiSenseInfo; // Command resulting Sense info
end;
type
TLogicalUnitWriteSpeedTable = packed record
Reserved: Byte;
RotationControl: Byte;
WriteSpeedSupported: Word;
end;
TModeParametersHeader = packed record
ModeDataLength: Word;
Reserved1: Byte;
Reserved2: Byte;
Reserved3: Byte;
Reserved4: Byte;
BlockDescriptorLength: Word;
end;
type
TScsiModePageCdStatus = packed record
// ModeParametersHeader : TModeParametersHeader; //8
PSPageCode: byte; {PS bit 7} {PageCode bits 0-6}
PageLength: byte; {=$32}
// Resv : array[0..6] of BYTE;
Flags: array[0..5] of BYTE; // BitSet - see above
MaxReadSpeed: WORD; // Obsolete
MaxVolumeLevels: WORD; // Number of discrete levels for audio volume.
// If the device only supports turning audio on
// and off, this field shall be set to 2.
MaxBufferSize: WORD; // Size of buffer dedicated to the data stream
// in kilobytes. Zero means device have no cache.
CurrentReadSpeed: WORD; // Obsolete
Reserved3: BYTE;
DigiPortFormat: BYTE; // BitSet - see above. Dexcribes the format
// of digital output (IEC958). Valid only if one
// of CDSTATUS_AUDIO_DIGIPORTn flags is set.
MaxWriteSpeed: WORD; // Obsolete
CurWriteSpeed_Res: WORD; // Obsolete
CopyMgRevision: WORD; // Copy Management Revision Version supported
// by device (DVD devices only, zero for all others)
Reserved6: BYTE;
Reserved7: BYTE;
RotationControlSpeed: Byte;
CurrentWriteSpeed: Word;
NoWriteSpeedDescTables: Word;
WriteSpeeds: array[0..99] of TLogicalUnitWriteSpeedTable;
end;
type
PScsiModePageRecord = ^TScsiModePageRecord;
TScsiModePageRecord = packed record
PageCode: BYTE; // six LSBs of page code plus
// MSbit is PSAV flag (MODE SENSE only)
ParamLength: BYTE;
Params: array[0..ScsiModePageParamsLength - 1] of BYTE;
end;
type
TScsiModePageTemplate10 = packed record
ModeDataLength10: WORD; // full record length except itself
MediumType10: BYTE; // Reserved - OBSOLETE
DeviceSpecific10: BYTE; // Reserved - OBSOLETE
Reserved10: WORD;
DescriptorLength10: WORD; // equal to 8*Number of Block Descriptors
// must be zero when DBD = TRUE
Params10: array[0..ScsiModeTemplateParamsLength - 1] of BYTE;
end;
type
TScsiModePageTemplate2 = packed record
ModeDataLength10: WORD; // full record length except itself
MediumType10: BYTE; // Reserved - OBSOLETE
DeviceSpecific10: BYTE; // Reserved - OBSOLETE
Reserved10: WORD;
DescriptorLength10: WORD; // equal to 8*Number of Block Descriptors
// must be zero when DBD = TRUE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -