mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Remove DiscImageChef.CommonTypes dependence on DiscImageChef.Decoders.
This commit is contained in:
@@ -97,6 +97,10 @@
|
|||||||
<Compile Include="MediaType.cs" />
|
<Compile Include="MediaType.cs" />
|
||||||
<Compile Include="MediaTypeFromSCSI.cs" />
|
<Compile Include="MediaTypeFromSCSI.cs" />
|
||||||
<Compile Include="PluginBase.cs" />
|
<Compile Include="PluginBase.cs" />
|
||||||
|
<Compile Include="Structs\Devices\ATA\Identify.cs" />
|
||||||
|
<Compile Include="Structs\Devices\SCSI\Enums.cs" />
|
||||||
|
<Compile Include="Structs\Devices\SCSI\Inquiry.cs" />
|
||||||
|
<Compile Include="Structs\Devices\SCSI\Modes\2A.cs" />
|
||||||
<Compile Include="Structs\Filesystems.cs" />
|
<Compile Include="Structs\Filesystems.cs" />
|
||||||
<Compile Include="Structs\Images.cs" />
|
<Compile Include="Structs\Images.cs" />
|
||||||
<Compile Include="Structs\TapeFile.cs" />
|
<Compile Include="Structs\TapeFile.cs" />
|
||||||
@@ -115,7 +119,8 @@
|
|||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\DiscImageChef.Decoders\DiscImageChef.Decoders.csproj" />
|
<ProjectReference Include="..\DiscImageChef.Console\DiscImageChef.Console.csproj" />
|
||||||
|
<ProjectReference Include="..\DiscImageChef.Helpers\DiscImageChef.Helpers.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ProjectExtensions>
|
<ProjectExtensions>
|
||||||
<MonoDevelop>
|
<MonoDevelop>
|
||||||
|
|||||||
@@ -39,9 +39,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using DiscImageChef.Decoders.ATA;
|
using DiscImageChef.CommonTypes.Structs.Devices.ATA;
|
||||||
using DiscImageChef.Decoders.SCSI;
|
using DiscImageChef.CommonTypes.Structs.Devices.SCSI;
|
||||||
using DiscImageChef.Decoders.SCSI.MMC;
|
using DiscImageChef.CommonTypes.Structs.Devices.SCSI.Modes;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
@@ -484,57 +484,57 @@ namespace DiscImageChef.CommonTypes.Metadata
|
|||||||
|
|
||||||
public class mmcModeType
|
public class mmcModeType
|
||||||
{
|
{
|
||||||
public bool AccurateCDDA { get; set; }
|
public bool AccurateCDDA { get; set; }
|
||||||
public bool BCK { get; set; }
|
public bool BCK { get; set; }
|
||||||
public ushort BufferSize { get; set; }
|
public ushort BufferSize { get; set; }
|
||||||
public bool BufferUnderRunProtection { get; set; }
|
public bool BufferUnderRunProtection { get; set; }
|
||||||
public bool CanEject { get; set; }
|
public bool CanEject { get; set; }
|
||||||
public bool CanLockMedia { get; set; }
|
public bool CanLockMedia { get; set; }
|
||||||
public bool CDDACommand { get; set; }
|
public bool CDDACommand { get; set; }
|
||||||
public bool CompositeAudioVideo { get; set; }
|
public bool CompositeAudioVideo { get; set; }
|
||||||
public bool CSSandCPPMSupported { get; set; }
|
public bool CSSandCPPMSupported { get; set; }
|
||||||
public ushort CurrentSpeed { get; set; }
|
public ushort CurrentSpeed { get; set; }
|
||||||
public ushort CurrentWriteSpeed { get; set; }
|
public ushort CurrentWriteSpeed { get; set; }
|
||||||
public ushort CurrentWriteSpeedSelected { get; set; }
|
public ushort CurrentWriteSpeedSelected { get; set; }
|
||||||
public bool DeterministicSlotChanger { get; set; }
|
public bool DeterministicSlotChanger { get; set; }
|
||||||
public bool DigitalPort1 { get; set; }
|
public bool DigitalPort1 { get; set; }
|
||||||
public bool DigitalPort2 { get; set; }
|
public bool DigitalPort2 { get; set; }
|
||||||
public bool LeadInPW { get; set; }
|
public bool LeadInPW { get; set; }
|
||||||
public byte LoadingMechanismType { get; set; }
|
public byte LoadingMechanismType { get; set; }
|
||||||
public bool LockStatus { get; set; }
|
public bool LockStatus { get; set; }
|
||||||
public bool LSBF { get; set; }
|
public bool LSBF { get; set; }
|
||||||
public ushort MaximumSpeed { get; set; }
|
public ushort MaximumSpeed { get; set; }
|
||||||
public ushort MaximumWriteSpeed { get; set; }
|
public ushort MaximumWriteSpeed { get; set; }
|
||||||
public bool PlaysAudio { get; set; }
|
public bool PlaysAudio { get; set; }
|
||||||
public bool PreventJumperStatus { get; set; }
|
public bool PreventJumperStatus { get; set; }
|
||||||
public bool RCK { get; set; }
|
public bool RCK { get; set; }
|
||||||
public bool ReadsBarcode { get; set; }
|
public bool ReadsBarcode { get; set; }
|
||||||
public bool ReadsBothSides { get; set; }
|
public bool ReadsBothSides { get; set; }
|
||||||
public bool ReadsCDR { get; set; }
|
public bool ReadsCDR { get; set; }
|
||||||
public bool ReadsCDRW { get; set; }
|
public bool ReadsCDRW { get; set; }
|
||||||
public bool ReadsDeinterlavedSubchannel { get; set; }
|
public bool ReadsDeinterlavedSubchannel { get; set; }
|
||||||
public bool ReadsDVDR { get; set; }
|
public bool ReadsDVDR { get; set; }
|
||||||
public bool ReadsDVDRAM { get; set; }
|
public bool ReadsDVDRAM { get; set; }
|
||||||
public bool ReadsDVDROM { get; set; }
|
public bool ReadsDVDROM { get; set; }
|
||||||
public bool ReadsISRC { get; set; }
|
public bool ReadsISRC { get; set; }
|
||||||
public bool ReadsMode2Form2 { get; set; }
|
public bool ReadsMode2Form2 { get; set; }
|
||||||
public bool ReadsMode2Form1 { get; set; }
|
public bool ReadsMode2Form1 { get; set; }
|
||||||
public bool ReadsPacketCDR { get; set; }
|
public bool ReadsPacketCDR { get; set; }
|
||||||
public bool ReadsSubchannel { get; set; }
|
public bool ReadsSubchannel { get; set; }
|
||||||
public bool ReadsUPC { get; set; }
|
public bool ReadsUPC { get; set; }
|
||||||
public bool ReturnsC2Pointers { get; set; }
|
public bool ReturnsC2Pointers { get; set; }
|
||||||
public byte RotationControlSelected { get; set; }
|
public byte RotationControlSelected { get; set; }
|
||||||
public bool SeparateChannelMute { get; set; }
|
public bool SeparateChannelMute { get; set; }
|
||||||
public bool SeparateChannelVolume { get; set; }
|
public bool SeparateChannelVolume { get; set; }
|
||||||
public bool SSS { get; set; }
|
public bool SSS { get; set; }
|
||||||
public bool SupportsMultiSession { get; set; }
|
public bool SupportsMultiSession { get; set; }
|
||||||
public ushort SupportedVolumeLevels { get; set; }
|
public ushort SupportedVolumeLevels { get; set; }
|
||||||
public bool TestWrite { get; set; }
|
public bool TestWrite { get; set; }
|
||||||
public bool WritesCDR { get; set; }
|
public bool WritesCDR { get; set; }
|
||||||
public bool WritesCDRW { get; set; }
|
public bool WritesCDRW { get; set; }
|
||||||
public bool WritesDVDR { get; set; }
|
public bool WritesDVDR { get; set; }
|
||||||
public bool WritesDVDRAM { get; set; }
|
public bool WritesDVDRAM { get; set; }
|
||||||
public Modes.ModePage_2A_WriteDescriptor[] WriteSpeedPerformanceDescriptors { get; set; }
|
public ModePage_2A_WriteDescriptor[] WriteSpeedPerformanceDescriptors { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
public bool MaximumSpeedSpecified { get; set; }
|
public bool MaximumSpeedSpecified { get; set; }
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using DiscImageChef.CommonTypes.Enums;
|
using DiscImageChef.CommonTypes.Enums;
|
||||||
using DiscImageChef.Decoders.ATA;
|
using DiscImageChef.CommonTypes.Structs.Devices.ATA;
|
||||||
using DiscImageChef.Decoders.SCSI;
|
using DiscImageChef.CommonTypes.Structs.Devices.SCSI;
|
||||||
using DiscImageChef.Decoders.SCSI.MMC;
|
using DiscImageChef.CommonTypes.Structs.Devices.SCSI.Modes;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
// ReSharper disable VirtualMemberNeverOverridden.Global
|
// ReSharper disable VirtualMemberNeverOverridden.Global
|
||||||
@@ -474,10 +474,10 @@ namespace DiscImageChef.CommonTypes.Metadata
|
|||||||
if(ata.WRVSectorCountMode2Specified)
|
if(ata.WRVSectorCountMode2Specified)
|
||||||
identifyDevice.WRVSectorCountMode2 = ata.WRVSectorCountMode2;
|
identifyDevice.WRVSectorCountMode2 = ata.WRVSectorCountMode2;
|
||||||
|
|
||||||
Identify = Decoders.ATA.Identify.Encode(identifyDevice);
|
Identify = Structs.Devices.ATA.Identify.Encode(identifyDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Identify.IdentifyDevice? IdentifyDevice => Decoders.ATA.Identify.Decode(Identify);
|
public Identify.IdentifyDevice? IdentifyDevice => Structs.Devices.ATA.Identify.Decode(Identify);
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
@@ -550,7 +550,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
|||||||
if(InquiryData != null)
|
if(InquiryData != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var inq = new Inquiry.SCSIInquiry();
|
var inq = new Inquiry();
|
||||||
|
|
||||||
if(scsi.Inquiry.ANSIVersionSpecified)
|
if(scsi.Inquiry.ANSIVersionSpecified)
|
||||||
inq.ANSIVersion = scsi.Inquiry.ANSIVersion;
|
inq.ANSIVersion = scsi.Inquiry.ANSIVersion;
|
||||||
@@ -620,10 +620,10 @@ namespace DiscImageChef.CommonTypes.Metadata
|
|||||||
inq.WBus16 = scsi.Inquiry.WideBus16;
|
inq.WBus16 = scsi.Inquiry.WideBus16;
|
||||||
inq.WBus32 = scsi.Inquiry.WideBus32;
|
inq.WBus32 = scsi.Inquiry.WideBus32;
|
||||||
|
|
||||||
InquiryData = Decoders.SCSI.Inquiry.Encode(inq);
|
InquiryData = Structs.Devices.SCSI.Inquiry.Encode(inq);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inquiry.SCSIInquiry? Inquiry => Decoders.SCSI.Inquiry.Decode(InquiryData);
|
public Inquiry? Inquiry => Structs.Devices.SCSI.Inquiry.Decode(InquiryData);
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
@@ -766,7 +766,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
|||||||
public Mmc(mmcType mmc)
|
public Mmc(mmcType mmc)
|
||||||
{
|
{
|
||||||
if(mmc.ModeSense2A != null)
|
if(mmc.ModeSense2A != null)
|
||||||
ModeSense2AData = Modes.EncodeModePage_2A(new Modes.ModePage_2A
|
ModeSense2AData = ModePage_2A.Encode(new ModePage_2A
|
||||||
{
|
{
|
||||||
AccurateCDDA = mmc.ModeSense2A.AccurateCDDA, BCK = mmc.ModeSense2A.BCK,
|
AccurateCDDA = mmc.ModeSense2A.AccurateCDDA, BCK = mmc.ModeSense2A.BCK,
|
||||||
BufferSize = mmc.ModeSense2A.BufferSize,
|
BufferSize = mmc.ModeSense2A.BufferSize,
|
||||||
@@ -833,7 +833,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
|||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public virtual Modes.ModePage_2A ModeSense2A => Modes.DecodeModePage_2A(ModeSense2AData);
|
public virtual ModePage_2A ModeSense2A => ModePage_2A.Decode(ModeSense2AData);
|
||||||
public virtual MmcFeatures Features { get; set; }
|
public virtual MmcFeatures Features { get; set; }
|
||||||
public virtual List<TestedMedia> TestedMedia { get; set; }
|
public virtual List<TestedMedia> TestedMedia { get; set; }
|
||||||
public byte[] ModeSense2AData { get; set; }
|
public byte[] ModeSense2AData { get; set; }
|
||||||
|
|||||||
1036
Structs/Devices/ATA/Identify.cs
Normal file
1036
Structs/Devices/ATA/Identify.cs
Normal file
File diff suppressed because it is too large
Load Diff
227
Structs/Devices/SCSI/Enums.cs
Normal file
227
Structs/Devices/SCSI/Enums.cs
Normal file
@@ -0,0 +1,227 @@
|
|||||||
|
// /***************************************************************************
|
||||||
|
// The Disc Image Chef
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : Enums.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// Component : Device structures decoders.
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Contains various SCSI enumerations.
|
||||||
|
//
|
||||||
|
// --[ License ] --------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 2.1 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful, but
|
||||||
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Copyright © 2011-2020 Natalia Portillo
|
||||||
|
// ****************************************************************************/
|
||||||
|
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
|
namespace DiscImageChef.CommonTypes.Structs.Devices.SCSI
|
||||||
|
{
|
||||||
|
public enum PeripheralQualifiers : byte
|
||||||
|
{
|
||||||
|
/// <summary>Peripheral qualifier: Device is connected and supported</summary>
|
||||||
|
Supported = 0x00,
|
||||||
|
/// <summary>Peripheral qualifier: Device is supported but not connected</summary>
|
||||||
|
Unconnected = 0x01,
|
||||||
|
/// <summary>Peripheral qualifier: Reserved value</summary>
|
||||||
|
Reserved = 0x02,
|
||||||
|
/// <summary>Peripheral qualifier: Device is connected but unsupported</summary>
|
||||||
|
Unsupported = 0x03,
|
||||||
|
/// <summary>Peripheral qualifier: Vendor values: 0x04, 0x05, 0x06 and 0x07</summary>
|
||||||
|
VendorMask = 0x04
|
||||||
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||||
|
public enum PeripheralDeviceTypes : byte
|
||||||
|
{
|
||||||
|
/// <summary>Direct-access device</summary>
|
||||||
|
DirectAccess = 0x00,
|
||||||
|
/// <summary>Sequential-access device</summary>
|
||||||
|
SequentialAccess = 0x01,
|
||||||
|
/// <summary>Printer device</summary>
|
||||||
|
PrinterDevice = 0x02,
|
||||||
|
/// <summary>Processor device</summary>
|
||||||
|
ProcessorDevice = 0x03,
|
||||||
|
/// <summary>Write-once device</summary>
|
||||||
|
WriteOnceDevice = 0x04,
|
||||||
|
/// <summary>CD-ROM/DVD/etc device</summary>
|
||||||
|
MultiMediaDevice = 0x05,
|
||||||
|
/// <summary>Scanner device</summary>
|
||||||
|
ScannerDevice = 0x06,
|
||||||
|
/// <summary>Optical memory device</summary>
|
||||||
|
OpticalDevice = 0x07,
|
||||||
|
/// <summary>Medium change device</summary>
|
||||||
|
MediumChangerDevice = 0x08,
|
||||||
|
/// <summary>Communications device</summary>
|
||||||
|
CommsDevice = 0x09,
|
||||||
|
/// <summary>Graphics arts pre-press device (defined in ASC IT8)</summary>
|
||||||
|
PrePressDevice1 = 0x0A,
|
||||||
|
/// <summary>Graphics arts pre-press device (defined in ASC IT8)</summary>
|
||||||
|
PrePressDevice2 = 0x0B,
|
||||||
|
/// <summary>Array controller device</summary>
|
||||||
|
ArrayControllerDevice = 0x0C,
|
||||||
|
/// <summary>Enclosure services device</summary>
|
||||||
|
EnclosureServiceDevice = 0x0D,
|
||||||
|
/// <summary>Simplified direct-access device</summary>
|
||||||
|
SimplifiedDevice = 0x0E,
|
||||||
|
/// <summary>Optical card reader/writer device</summary>
|
||||||
|
OCRWDevice = 0x0F,
|
||||||
|
/// <summary>Bridging Expanders</summary>
|
||||||
|
BridgingExpander = 0x10,
|
||||||
|
/// <summary>Object-based Storage Device</summary>
|
||||||
|
ObjectDevice = 0x11,
|
||||||
|
/// <summary>Automation/Drive Interface</summary>
|
||||||
|
ADCDevice = 0x12,
|
||||||
|
/// <summary>Security Manager Device</summary>
|
||||||
|
SCSISecurityManagerDevice = 0x13,
|
||||||
|
/// <summary>Host managed zoned block device</summary>
|
||||||
|
SCSIZonedBlockDevice = 0x14,
|
||||||
|
/// <summary>Well known logical unit</summary>
|
||||||
|
WellKnownDevice = 0x1E,
|
||||||
|
/// <summary>Unknown or no device type</summary>
|
||||||
|
UnknownDevice = 0x1F
|
||||||
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||||
|
public enum ANSIVersions : byte
|
||||||
|
{
|
||||||
|
/// <summary>Device does not claim conformance to any ANSI version</summary>
|
||||||
|
ANSINoVersion = 0x00,
|
||||||
|
/// <summary>Device complies with ANSI X3.131:1986</summary>
|
||||||
|
ANSI1986Version = 0x01,
|
||||||
|
/// <summary>Device complies with ANSI X3.131:1994</summary>
|
||||||
|
ANSI1994Version = 0x02,
|
||||||
|
/// <summary>Device complies with ANSI X3.301:1997</summary>
|
||||||
|
ANSI1997Version = 0x03,
|
||||||
|
/// <summary>Device complies with ANSI X3.351:2001</summary>
|
||||||
|
ANSI2001Version = 0x04,
|
||||||
|
/// <summary>Device complies with ANSI X3.408:2005.</summary>
|
||||||
|
ANSI2005Version = 0x05,
|
||||||
|
/// <summary>Device complies with SPC-4</summary>
|
||||||
|
ANSI2008Version = 0x06
|
||||||
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||||
|
public enum ECMAVersions : byte
|
||||||
|
{
|
||||||
|
/// <summary>Device does not claim conformance to any ECMA version</summary>
|
||||||
|
ECMANoVersion = 0x00,
|
||||||
|
/// <summary>Device complies with a ECMA-111 standard</summary>
|
||||||
|
ECMA111 = 0x01
|
||||||
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||||
|
public enum ISOVersions : byte
|
||||||
|
{
|
||||||
|
/// <summary>Device does not claim conformance to any ISO/IEC version</summary>
|
||||||
|
ISONoVersion = 0x00,
|
||||||
|
/// <summary>Device complies with ISO/IEC 9316:1995</summary>
|
||||||
|
ISO1995Version = 0x02
|
||||||
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||||
|
public enum SPIClocking : byte
|
||||||
|
{
|
||||||
|
/// <summary>Supports only ST</summary>
|
||||||
|
ST = 0x00,
|
||||||
|
/// <summary>Supports only DT</summary>
|
||||||
|
DT = 0x01,
|
||||||
|
/// <summary>Reserved value</summary>
|
||||||
|
Reserved = 0x02,
|
||||||
|
/// <summary>Supports ST and DT</summary>
|
||||||
|
STandDT = 0x03
|
||||||
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||||
|
public enum TGPSValues : byte
|
||||||
|
{
|
||||||
|
/// <summary>Assymetrical access not supported</summary>
|
||||||
|
NotSupported = 0x00,
|
||||||
|
/// <summary>Only implicit assymetrical access is supported</summary>
|
||||||
|
OnlyImplicit = 0x01,
|
||||||
|
/// <summary>Only explicit assymetrical access is supported</summary>
|
||||||
|
OnlyExplicit = 0x02,
|
||||||
|
/// <summary>Both implicit and explicit assymetrical access are supported</summary>
|
||||||
|
Both = 0x03
|
||||||
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||||
|
public enum ProtocolIdentifiers : byte
|
||||||
|
{
|
||||||
|
/// <summary>Fibre Channel</summary>
|
||||||
|
FibreChannel = 0,
|
||||||
|
/// <summary>Parallel SCSI</summary>
|
||||||
|
SCSI = 1,
|
||||||
|
/// <summary>SSA</summary>
|
||||||
|
SSA = 2,
|
||||||
|
/// <summary>IEEE-1394</summary>
|
||||||
|
Firewire = 3,
|
||||||
|
/// <summary>SCSI Remote Direct Memory Access Protocol</summary>
|
||||||
|
RDMAP = 4,
|
||||||
|
/// <summary>Internet SCSI</summary>
|
||||||
|
iSCSI = 5,
|
||||||
|
/// <summary>Serial SCSI</summary>
|
||||||
|
SAS = 6,
|
||||||
|
/// <summary>Automation/Drive Interface Transport Protocol</summary>
|
||||||
|
ADT = 7,
|
||||||
|
/// <summary>AT Attachment Interface (ATA/ATAPI)</summary>
|
||||||
|
ATA = 8,
|
||||||
|
/// <summary>USB Attached SCSI</summary>
|
||||||
|
UAS = 9,
|
||||||
|
/// <summary>SCSI over PCI Express</summary>
|
||||||
|
SCSIe = 10,
|
||||||
|
/// <summary>PCI Express</summary>
|
||||||
|
PCIe = 11,
|
||||||
|
/// <summary>No specific protocol</summary>
|
||||||
|
NoProtocol = 15
|
||||||
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||||
|
public enum ScsiDefinitions : byte
|
||||||
|
{
|
||||||
|
Current = 0, SCSI1 = 1, CCS = 2,
|
||||||
|
SCSI2 = 3, SCSI3 = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||||
|
public enum PhysicalInterfaces : uint
|
||||||
|
{
|
||||||
|
/// <summary>Unspecified physical interface</summary>
|
||||||
|
Unspecified = 0,
|
||||||
|
/// <summary>SCSI</summary>
|
||||||
|
SCSI = 1,
|
||||||
|
/// <summary>ATAPI</summary>
|
||||||
|
ATAPI = 2,
|
||||||
|
/// <summary>IEEE-1394/1995</summary>
|
||||||
|
IEEE1394 = 3,
|
||||||
|
/// <summary>IEEE-1394A</summary>
|
||||||
|
IEEE1394A = 4,
|
||||||
|
/// <summary>Fibre Channel</summary>
|
||||||
|
FC = 5,
|
||||||
|
/// <summary>IEEE-1394B</summary>
|
||||||
|
IEEE1394B = 6,
|
||||||
|
/// <summary>Serial ATAPI</summary>
|
||||||
|
SerialATAPI = 7,
|
||||||
|
/// <summary>USB</summary>
|
||||||
|
USB = 8,
|
||||||
|
/// <summary>Vendor unique</summary>
|
||||||
|
Vendor = 0xFFFF
|
||||||
|
}
|
||||||
|
}
|
||||||
706
Structs/Devices/SCSI/Inquiry.cs
Normal file
706
Structs/Devices/SCSI/Inquiry.cs
Normal file
@@ -0,0 +1,706 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Linq;
|
||||||
|
using DiscImageChef.Console;
|
||||||
|
|
||||||
|
namespace DiscImageChef.CommonTypes.Structs.Devices.SCSI
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Information from the following standards: T9/375-D revision 10l T10/995-D revision 10 T10/1236-D revision 20
|
||||||
|
/// T10/1416-D revision 23 T10/1731-D revision 16 T10/502 revision 05 RFC 7144 ECMA-111
|
||||||
|
/// </summary>
|
||||||
|
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
|
||||||
|
SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
|
public struct Inquiry
|
||||||
|
{
|
||||||
|
/// <summary>Peripheral qualifier Byte 0, bits 7 to 5</summary>
|
||||||
|
public byte PeripheralQualifier;
|
||||||
|
/// <summary>Peripheral device type Byte 0, bits 4 to 0</summary>
|
||||||
|
public byte PeripheralDeviceType;
|
||||||
|
/// <summary>Removable device Byte 1, bit 7</summary>
|
||||||
|
public bool RMB;
|
||||||
|
/// <summary>SCSI-1 vendor-specific qualification codes Byte 1, bits 6 to 0</summary>
|
||||||
|
public byte DeviceTypeModifier;
|
||||||
|
/// <summary>ISO/IEC SCSI Standard Version Byte 2, bits 7 to 6, mask = 0xC0, >> 6</summary>
|
||||||
|
public byte ISOVersion;
|
||||||
|
/// <summary>ECMA SCSI Standard Version Byte 2, bits 5 to 3, mask = 0x38, >> 3</summary>
|
||||||
|
public byte ECMAVersion;
|
||||||
|
/// <summary>ANSI SCSI Standard Version Byte 2, bits 2 to 0, mask = 0x07</summary>
|
||||||
|
public byte ANSIVersion;
|
||||||
|
/// <summary>Asynchronous Event Reporting Capability supported Byte 3, bit 7</summary>
|
||||||
|
public bool AERC;
|
||||||
|
/// <summary>Device supports TERMINATE TASK command Byte 3, bit 6</summary>
|
||||||
|
public bool TrmTsk;
|
||||||
|
/// <summary>Supports setting Normal ACA Byte 3, bit 5</summary>
|
||||||
|
public bool NormACA;
|
||||||
|
/// <summary>Supports LUN hierarchical addressing Byte 3, bit 4</summary>
|
||||||
|
public bool HiSup;
|
||||||
|
/// <summary>Responde data format Byte 3, bit 3 to 0</summary>
|
||||||
|
public byte ResponseDataFormat;
|
||||||
|
/// <summary>Lenght of total INQUIRY response minus 4 Byte 4</summary>
|
||||||
|
public byte AdditionalLength;
|
||||||
|
/// <summary>Device contains an embedded storage array controller Byte 5, bit 7</summary>
|
||||||
|
public bool SCCS;
|
||||||
|
/// <summary>Device contains an Access Control Coordinator Byte 5, bit 6</summary>
|
||||||
|
public bool ACC;
|
||||||
|
/// <summary>Supports asymetrical logical unit access Byte 5, bits 5 to 4</summary>
|
||||||
|
public byte TPGS;
|
||||||
|
/// <summary>Supports third-party copy commands Byte 5, bit 3</summary>
|
||||||
|
public bool ThreePC;
|
||||||
|
/// <summary>Reserved Byte 5, bits 2 to 1</summary>
|
||||||
|
public byte Reserved2;
|
||||||
|
/// <summary>Supports protection information Byte 5, bit 0</summary>
|
||||||
|
public bool Protect;
|
||||||
|
/// <summary>Supports basic queueing Byte 6, bit 7</summary>
|
||||||
|
public bool BQue;
|
||||||
|
/// <summary>Device contains an embedded enclosure services component Byte 6, bit 6</summary>
|
||||||
|
public bool EncServ;
|
||||||
|
/// <summary>Vendor-specific Byte 6, bit 5</summary>
|
||||||
|
public bool VS1;
|
||||||
|
/// <summary>Multi-port device Byte 6, bit 4</summary>
|
||||||
|
public bool MultiP;
|
||||||
|
/// <summary>Device contains or is attached to a medium changer Byte 6, bit 3</summary>
|
||||||
|
public bool MChngr;
|
||||||
|
/// <summary>Device supports request and acknowledge handshakes Byte 6, bit 2</summary>
|
||||||
|
public bool ACKREQQ;
|
||||||
|
/// <summary>Supports 32-bit wide SCSI addresses Byte 6, bit 1</summary>
|
||||||
|
public bool Addr32;
|
||||||
|
/// <summary>Supports 16-bit wide SCSI addresses Byte 6, bit 0</summary>
|
||||||
|
public bool Addr16;
|
||||||
|
/// <summary>Device supports relative addressing Byte 7, bit 7</summary>
|
||||||
|
public bool RelAddr;
|
||||||
|
/// <summary>Supports 32-bit wide data transfers Byte 7, bit 6</summary>
|
||||||
|
public bool WBus32;
|
||||||
|
/// <summary>Supports 16-bit wide data transfers Byte 7, bit 5</summary>
|
||||||
|
public bool WBus16;
|
||||||
|
/// <summary>Supports synchronous data transfer Byte 7, bit 4</summary>
|
||||||
|
public bool Sync;
|
||||||
|
/// <summary>Supports linked commands Byte 7, bit 3</summary>
|
||||||
|
public bool Linked;
|
||||||
|
/// <summary>Supports CONTINUE TASK and TARGET TRANSFER DISABLE commands Byte 7, bit 2</summary>
|
||||||
|
public bool TranDis;
|
||||||
|
/// <summary>Supports TCQ queue Byte 7, bit 1</summary>
|
||||||
|
public bool CmdQue;
|
||||||
|
/// <summary>Indicates that the devices responds to RESET with soft reset Byte 7, bit 0</summary>
|
||||||
|
public bool SftRe;
|
||||||
|
/// <summary>Vendor identification Bytes 8 to 15</summary>
|
||||||
|
public byte[] VendorIdentification;
|
||||||
|
/// <summary>Product identification Bytes 16 to 31</summary>
|
||||||
|
public byte[] ProductIdentification;
|
||||||
|
/// <summary>Product revision level Bytes 32 to 35</summary>
|
||||||
|
public byte[] ProductRevisionLevel;
|
||||||
|
/// <summary>Vendor-specific data Bytes 36 to 55</summary>
|
||||||
|
public byte[] VendorSpecific;
|
||||||
|
/// <summary>Byte 56, bits 7 to 4</summary>
|
||||||
|
public byte Reserved3;
|
||||||
|
/// <summary>Supported SPI clocking Byte 56, bits 3 to 2</summary>
|
||||||
|
public byte Clocking;
|
||||||
|
/// <summary>Device supports Quick Arbitration and Selection Byte 56, bit 1</summary>
|
||||||
|
public bool QAS;
|
||||||
|
/// <summary>Supports information unit transfers Byte 56, bit 0</summary>
|
||||||
|
public bool IUS;
|
||||||
|
/// <summary>Reserved Byte 57</summary>
|
||||||
|
public byte Reserved4;
|
||||||
|
/// <summary>Array of version descriptors Bytes 58 to 73</summary>
|
||||||
|
public ushort[] VersionDescriptors;
|
||||||
|
/// <summary>Reserved Bytes 74 to 95</summary>
|
||||||
|
public byte[] Reserved5;
|
||||||
|
/// <summary>Reserved Bytes 96 to end</summary>
|
||||||
|
public byte[] VendorSpecific2;
|
||||||
|
|
||||||
|
// Per DLT4000/DLT4500/DLT4700 Cartridge Tape Subsystem Product Manual
|
||||||
|
|
||||||
|
#region Quantum vendor unique inquiry data structure
|
||||||
|
/// <summary>Means that the INQUIRY response contains 56 bytes or more, so this data has been filled</summary>
|
||||||
|
public bool QuantumPresent;
|
||||||
|
/// <summary>The product family. Byte 36, bits 7 to 5</summary>
|
||||||
|
public byte Qt_ProductFamily;
|
||||||
|
/// <summary>The released firmware. Byte 36, bits 4 to 0</summary>
|
||||||
|
public byte Qt_ReleasedFirmware;
|
||||||
|
/// <summary>The firmware major version. Byte 37</summary>
|
||||||
|
public byte Qt_FirmwareMajorVersion;
|
||||||
|
/// <summary>The firmware minor version. Byte 38</summary>
|
||||||
|
public byte Qt_FirmwareMinorVersion;
|
||||||
|
/// <summary>The EEPROM format major version. Byte 39</summary>
|
||||||
|
public byte Qt_EEPROMFormatMajorVersion;
|
||||||
|
/// <summary>The EEPROM format minor version. Byte 40</summary>
|
||||||
|
public byte Qt_EEPROMFormatMinorVersion;
|
||||||
|
/// <summary>The firmware personality. Byte 41</summary>
|
||||||
|
public byte Qt_FirmwarePersonality;
|
||||||
|
/// <summary>The firmware sub personality. Byte 42</summary>
|
||||||
|
public byte Qt_FirmwareSubPersonality;
|
||||||
|
/// <summary>The tape directory format version. Byte 43</summary>
|
||||||
|
public byte Qt_TapeDirectoryFormatVersion;
|
||||||
|
/// <summary>The controller hardware version. Byte 44</summary>
|
||||||
|
public byte Qt_ControllerHardwareVersion;
|
||||||
|
/// <summary>The drive EEPROM version. Byte 45</summary>
|
||||||
|
public byte Qt_DriveEEPROMVersion;
|
||||||
|
/// <summary>The drive hardware version. Byte 46</summary>
|
||||||
|
public byte Qt_DriveHardwareVersion;
|
||||||
|
/// <summary>The media loader firmware version. Byte 47</summary>
|
||||||
|
public byte Qt_MediaLoaderFirmwareVersion;
|
||||||
|
/// <summary>The media loader hardware version. Byte 48</summary>
|
||||||
|
public byte Qt_MediaLoaderHardwareVersion;
|
||||||
|
/// <summary>The media loader mechanical version. Byte 49</summary>
|
||||||
|
public byte Qt_MediaLoaderMechanicalVersion;
|
||||||
|
/// <summary>Is a media loader present? Byte 50</summary>
|
||||||
|
public bool Qt_MediaLoaderPresent;
|
||||||
|
/// <summary>Is a library present? Byte 51</summary>
|
||||||
|
public bool Qt_LibraryPresent;
|
||||||
|
/// <summary>The module revision. Bytes 52 to 55</summary>
|
||||||
|
public byte[] Qt_ModuleRevision;
|
||||||
|
#endregion Quantum vendor unique inquiry data structure
|
||||||
|
|
||||||
|
#region IBM vendor unique inquiry data structure
|
||||||
|
/// <summary>Means that the INQUIRY response contains 56 bytes or more, so this data has been filled</summary>
|
||||||
|
public bool IBMPresent;
|
||||||
|
/// <summary>Drive is not capable of automation Byte 36 bit 0</summary>
|
||||||
|
public bool IBM_AutDis;
|
||||||
|
/// <summary>If not zero, limit in MB/s = Max * (this / 256) Byte 37</summary>
|
||||||
|
public byte IBM_PerformanceLimit;
|
||||||
|
/// <summary>Byte 41</summary>
|
||||||
|
public byte IBM_OEMSpecific;
|
||||||
|
#endregion IBM vendor unique inquiry data structure
|
||||||
|
|
||||||
|
#region HP vendor unique inquiry data structure
|
||||||
|
/// <summary>Means that the INQUIRY response contains 49 bytes or more, so this data has been filled</summary>
|
||||||
|
public bool HPPresent;
|
||||||
|
/// <summary>WORM version Byte 40 bits 7 to 1</summary>
|
||||||
|
public byte HP_WORMVersion;
|
||||||
|
/// <summary>WORM supported Byte 40 bit 0</summary>
|
||||||
|
public bool HP_WORM;
|
||||||
|
/// <summary>Bytes 43 to 48</summary>
|
||||||
|
public byte[] HP_OBDR;
|
||||||
|
#endregion HP vendor unique inquiry data structure
|
||||||
|
|
||||||
|
#region Seagate vendor unique inquiry data structure
|
||||||
|
/// <summary>Means that bytes 36 to 43 are filled</summary>
|
||||||
|
public bool SeagatePresent;
|
||||||
|
/// <summary>Drive Serial Number Bytes 36 to 43</summary>
|
||||||
|
public byte[] Seagate_DriveSerialNumber;
|
||||||
|
/// <summary>Means that bytes 96 to 143 are filled</summary>
|
||||||
|
public bool Seagate2Present;
|
||||||
|
/// <summary>Contains Seagate copyright notice Bytes 96 to 143</summary>
|
||||||
|
public byte[] Seagate_Copyright;
|
||||||
|
/// <summary>Means that bytes 144 to 147 are filled</summary>
|
||||||
|
public bool Seagate3Present;
|
||||||
|
/// <summary>Reserved Seagate field Bytes 144 to 147</summary>
|
||||||
|
public byte[] Seagate_ServoPROMPartNo;
|
||||||
|
#endregion Seagate vendor unique inquiry data structure
|
||||||
|
|
||||||
|
#region Kreon vendor unique inquiry data structure
|
||||||
|
/// <summary>Means that firmware is Kreon</summary>
|
||||||
|
public bool KreonPresent;
|
||||||
|
/// <summary>Kreon identifier Bytes 36 to 40</summary>
|
||||||
|
public byte[] KreonIdentifier;
|
||||||
|
/// <summary>Kreon just a 0x20 Bytes 41</summary>
|
||||||
|
public byte KreonSpace;
|
||||||
|
/// <summary>Kreon version string Bytes 42 to 46</summary>
|
||||||
|
public byte[] KreonVersion;
|
||||||
|
#endregion Kreon vendor unique inquiry data structure
|
||||||
|
#region Public methods
|
||||||
|
public static Inquiry? Decode(byte[] SCSIInquiryResponse)
|
||||||
|
{
|
||||||
|
if(SCSIInquiryResponse == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length < 36 &&
|
||||||
|
SCSIInquiryResponse.Length != 5)
|
||||||
|
{
|
||||||
|
DicConsole.DebugWriteLine("SCSI INQUIRY decoder",
|
||||||
|
"INQUIRY response is {0} bytes, less than minimum of 36 bytes, decoded data can be incorrect, not decoding.",
|
||||||
|
SCSIInquiryResponse.Length);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length < SCSIInquiryResponse[4] + 4 &&
|
||||||
|
SCSIInquiryResponse.Length != SCSIInquiryResponse[4])
|
||||||
|
{
|
||||||
|
DicConsole.DebugWriteLine("SCSI INQUIRY decoder",
|
||||||
|
"INQUIRY response length ({0} bytes) is different than specified in length field ({1} bytes), decoded data can be incorrect, not decoding.",
|
||||||
|
SCSIInquiryResponse.Length, SCSIInquiryResponse[4] + 4);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var decoded = new Inquiry();
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 1)
|
||||||
|
{
|
||||||
|
decoded.PeripheralQualifier = (byte)((SCSIInquiryResponse[0] & 0xE0) >> 5);
|
||||||
|
decoded.PeripheralDeviceType = (byte)(SCSIInquiryResponse[0] & 0x1F);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 2)
|
||||||
|
{
|
||||||
|
decoded.RMB = Convert.ToBoolean(SCSIInquiryResponse[1] & 0x80);
|
||||||
|
decoded.DeviceTypeModifier = (byte)(SCSIInquiryResponse[1] & 0x7F);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 3)
|
||||||
|
{
|
||||||
|
decoded.ISOVersion = (byte)((SCSIInquiryResponse[2] & 0xC0) >> 6);
|
||||||
|
decoded.ECMAVersion = (byte)((SCSIInquiryResponse[2] & 0x38) >> 3);
|
||||||
|
decoded.ANSIVersion = (byte)(SCSIInquiryResponse[2] & 0x07);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 4)
|
||||||
|
{
|
||||||
|
decoded.AERC = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x80);
|
||||||
|
decoded.TrmTsk = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x40);
|
||||||
|
decoded.NormACA = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x20);
|
||||||
|
decoded.HiSup = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x10);
|
||||||
|
decoded.ResponseDataFormat = (byte)(SCSIInquiryResponse[3] & 0x07);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 5)
|
||||||
|
decoded.AdditionalLength = SCSIInquiryResponse[4];
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 6)
|
||||||
|
{
|
||||||
|
decoded.SCCS = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x80);
|
||||||
|
decoded.ACC = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x40);
|
||||||
|
decoded.TPGS = (byte)((SCSIInquiryResponse[5] & 0x30) >> 4);
|
||||||
|
decoded.ThreePC = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x08);
|
||||||
|
decoded.Reserved2 = (byte)((SCSIInquiryResponse[5] & 0x06) >> 1);
|
||||||
|
decoded.Protect = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 7)
|
||||||
|
{
|
||||||
|
decoded.BQue = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x80);
|
||||||
|
decoded.EncServ = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x40);
|
||||||
|
decoded.VS1 = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x20);
|
||||||
|
decoded.MultiP = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x10);
|
||||||
|
decoded.MChngr = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x08);
|
||||||
|
decoded.ACKREQQ = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x04);
|
||||||
|
decoded.Addr32 = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x02);
|
||||||
|
decoded.Addr16 = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 8)
|
||||||
|
{
|
||||||
|
decoded.RelAddr = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x80);
|
||||||
|
decoded.WBus32 = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x40);
|
||||||
|
decoded.WBus16 = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x20);
|
||||||
|
decoded.Sync = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x10);
|
||||||
|
decoded.Linked = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x08);
|
||||||
|
decoded.TranDis = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x04);
|
||||||
|
decoded.CmdQue = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x02);
|
||||||
|
decoded.SftRe = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 16)
|
||||||
|
{
|
||||||
|
decoded.VendorIdentification = new byte[8];
|
||||||
|
Array.Copy(SCSIInquiryResponse, 8, decoded.VendorIdentification, 0, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 32)
|
||||||
|
{
|
||||||
|
decoded.ProductIdentification = new byte[16];
|
||||||
|
Array.Copy(SCSIInquiryResponse, 16, decoded.ProductIdentification, 0, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 36)
|
||||||
|
{
|
||||||
|
decoded.ProductRevisionLevel = new byte[4];
|
||||||
|
Array.Copy(SCSIInquiryResponse, 32, decoded.ProductRevisionLevel, 0, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 44)
|
||||||
|
{
|
||||||
|
// Seagate 1
|
||||||
|
decoded.SeagatePresent = true;
|
||||||
|
decoded.Seagate_DriveSerialNumber = new byte[8];
|
||||||
|
Array.Copy(SCSIInquiryResponse, 36, decoded.Seagate_DriveSerialNumber, 0, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 46)
|
||||||
|
{
|
||||||
|
// Kreon
|
||||||
|
decoded.KreonIdentifier = new byte[5];
|
||||||
|
Array.Copy(SCSIInquiryResponse, 36, decoded.KreonIdentifier, 0, 5);
|
||||||
|
decoded.KreonSpace = SCSIInquiryResponse[41];
|
||||||
|
decoded.KreonVersion = new byte[5];
|
||||||
|
Array.Copy(SCSIInquiryResponse, 42, decoded.KreonVersion, 0, 5);
|
||||||
|
|
||||||
|
if(decoded.KreonSpace == 0x20 &&
|
||||||
|
decoded.KreonIdentifier.SequenceEqual(new byte[]
|
||||||
|
{
|
||||||
|
0x4B, 0x52, 0x45, 0x4F, 0x4E
|
||||||
|
}))
|
||||||
|
decoded.KreonPresent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 49)
|
||||||
|
{
|
||||||
|
// HP
|
||||||
|
decoded.HPPresent = true;
|
||||||
|
decoded.HP_WORM |= (SCSIInquiryResponse[40] & 0x01) == 0x01;
|
||||||
|
decoded.HP_WORMVersion = (byte)((SCSIInquiryResponse[40] & 0x7F) >> 1);
|
||||||
|
decoded.HP_OBDR = new byte[6];
|
||||||
|
Array.Copy(SCSIInquiryResponse, 43, decoded.HP_OBDR, 0, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 56)
|
||||||
|
{
|
||||||
|
decoded.VendorSpecific = new byte[20];
|
||||||
|
Array.Copy(SCSIInquiryResponse, 36, decoded.VendorSpecific, 0, 20);
|
||||||
|
|
||||||
|
// Quantum
|
||||||
|
decoded.QuantumPresent = true;
|
||||||
|
decoded.Qt_ProductFamily = (byte)((SCSIInquiryResponse[36] & 0xF0) >> 4);
|
||||||
|
decoded.Qt_ReleasedFirmware = (byte)(SCSIInquiryResponse[36] & 0x0F);
|
||||||
|
decoded.Qt_FirmwareMajorVersion = SCSIInquiryResponse[37];
|
||||||
|
decoded.Qt_FirmwareMinorVersion = SCSIInquiryResponse[38];
|
||||||
|
decoded.Qt_EEPROMFormatMajorVersion = SCSIInquiryResponse[39];
|
||||||
|
decoded.Qt_EEPROMFormatMinorVersion = SCSIInquiryResponse[40];
|
||||||
|
decoded.Qt_FirmwarePersonality = SCSIInquiryResponse[41];
|
||||||
|
decoded.Qt_FirmwareSubPersonality = SCSIInquiryResponse[42];
|
||||||
|
decoded.Qt_TapeDirectoryFormatVersion = SCSIInquiryResponse[43];
|
||||||
|
decoded.Qt_ControllerHardwareVersion = SCSIInquiryResponse[44];
|
||||||
|
decoded.Qt_DriveEEPROMVersion = SCSIInquiryResponse[45];
|
||||||
|
decoded.Qt_DriveHardwareVersion = SCSIInquiryResponse[46];
|
||||||
|
decoded.Qt_MediaLoaderFirmwareVersion = SCSIInquiryResponse[47];
|
||||||
|
decoded.Qt_MediaLoaderHardwareVersion = SCSIInquiryResponse[48];
|
||||||
|
decoded.Qt_MediaLoaderMechanicalVersion = SCSIInquiryResponse[49];
|
||||||
|
decoded.Qt_MediaLoaderPresent = SCSIInquiryResponse[50] > 0;
|
||||||
|
decoded.Qt_LibraryPresent = SCSIInquiryResponse[51] > 0;
|
||||||
|
decoded.Qt_ModuleRevision = new byte[4];
|
||||||
|
Array.Copy(SCSIInquiryResponse, 52, decoded.Qt_ModuleRevision, 0, 4);
|
||||||
|
|
||||||
|
// IBM
|
||||||
|
decoded.IBMPresent = true;
|
||||||
|
decoded.IBM_AutDis |= (SCSIInquiryResponse[36] & 0x01) == 0x01;
|
||||||
|
decoded.IBM_PerformanceLimit = SCSIInquiryResponse[37];
|
||||||
|
decoded.IBM_OEMSpecific = SCSIInquiryResponse[41];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 57)
|
||||||
|
{
|
||||||
|
decoded.Reserved3 = (byte)((SCSIInquiryResponse[56] & 0xF0) >> 4);
|
||||||
|
decoded.Clocking = (byte)((SCSIInquiryResponse[56] & 0x0C) >> 2);
|
||||||
|
decoded.QAS = Convert.ToBoolean(SCSIInquiryResponse[56] & 0x02);
|
||||||
|
decoded.IUS = Convert.ToBoolean(SCSIInquiryResponse[56] & 0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 58)
|
||||||
|
decoded.Reserved4 = SCSIInquiryResponse[57];
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 60)
|
||||||
|
{
|
||||||
|
int descriptorsNo;
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 74)
|
||||||
|
descriptorsNo = 8;
|
||||||
|
else
|
||||||
|
descriptorsNo = (SCSIInquiryResponse.Length - 58) / 2;
|
||||||
|
|
||||||
|
decoded.VersionDescriptors = new ushort[descriptorsNo];
|
||||||
|
|
||||||
|
for(int i = 0; i < descriptorsNo; i++)
|
||||||
|
decoded.VersionDescriptors[i] = BitConverter.ToUInt16(SCSIInquiryResponse, 58 + (i * 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 75 &&
|
||||||
|
SCSIInquiryResponse.Length < 96)
|
||||||
|
{
|
||||||
|
decoded.Reserved5 = new byte[SCSIInquiryResponse.Length - 74];
|
||||||
|
Array.Copy(SCSIInquiryResponse, 74, decoded.Reserved5, 0, SCSIInquiryResponse.Length - 74);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 96)
|
||||||
|
{
|
||||||
|
decoded.Reserved5 = new byte[22];
|
||||||
|
Array.Copy(SCSIInquiryResponse, 74, decoded.Reserved5, 0, 22);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length > 96)
|
||||||
|
{
|
||||||
|
decoded.VendorSpecific2 = new byte[SCSIInquiryResponse.Length - 96];
|
||||||
|
Array.Copy(SCSIInquiryResponse, 96, decoded.VendorSpecific2, 0, SCSIInquiryResponse.Length - 96);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length >= 144)
|
||||||
|
{
|
||||||
|
// Seagate 2
|
||||||
|
decoded.Seagate2Present = true;
|
||||||
|
decoded.Seagate_Copyright = new byte[48];
|
||||||
|
Array.Copy(SCSIInquiryResponse, 96, decoded.Seagate_Copyright, 0, 48);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SCSIInquiryResponse.Length < 148)
|
||||||
|
return decoded;
|
||||||
|
|
||||||
|
// Seagate 2
|
||||||
|
decoded.Seagate3Present = true;
|
||||||
|
decoded.Seagate_ServoPROMPartNo = new byte[4];
|
||||||
|
Array.Copy(SCSIInquiryResponse, 144, decoded.Seagate_ServoPROMPartNo, 0, 4);
|
||||||
|
|
||||||
|
return decoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] Encode(Inquiry? inq)
|
||||||
|
{
|
||||||
|
if(inq is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
Inquiry decoded = inq.Value;
|
||||||
|
|
||||||
|
byte[] buffer = new byte[512];
|
||||||
|
byte length = 0;
|
||||||
|
|
||||||
|
buffer[0] = (byte)(decoded.PeripheralQualifier << 5);
|
||||||
|
buffer[0] += decoded.PeripheralDeviceType;
|
||||||
|
|
||||||
|
if(decoded.RMB)
|
||||||
|
buffer[1] = 0x80;
|
||||||
|
|
||||||
|
buffer[1] += decoded.DeviceTypeModifier;
|
||||||
|
|
||||||
|
buffer[2] = (byte)(decoded.ISOVersion << 6);
|
||||||
|
buffer[2] += (byte)(decoded.ECMAVersion << 3);
|
||||||
|
buffer[2] += decoded.ANSIVersion;
|
||||||
|
|
||||||
|
if(decoded.AERC)
|
||||||
|
buffer[3] = 0x80;
|
||||||
|
|
||||||
|
if(decoded.TrmTsk)
|
||||||
|
buffer[3] += 0x40;
|
||||||
|
|
||||||
|
if(decoded.NormACA)
|
||||||
|
buffer[3] += 0x20;
|
||||||
|
|
||||||
|
if(decoded.HiSup)
|
||||||
|
buffer[3] += 0x10;
|
||||||
|
|
||||||
|
buffer[3] += decoded.ResponseDataFormat;
|
||||||
|
|
||||||
|
if(decoded.AdditionalLength > 0)
|
||||||
|
{
|
||||||
|
length = 5;
|
||||||
|
buffer[4] = decoded.AdditionalLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.SCCS ||
|
||||||
|
decoded.ACC ||
|
||||||
|
decoded.TPGS > 0 ||
|
||||||
|
decoded.ThreePC ||
|
||||||
|
decoded.Reserved2 > 0 ||
|
||||||
|
decoded.Protect)
|
||||||
|
{
|
||||||
|
length = 6;
|
||||||
|
|
||||||
|
if(decoded.SCCS)
|
||||||
|
buffer[5] = 0x80;
|
||||||
|
|
||||||
|
if(decoded.ACC)
|
||||||
|
buffer[5] += 0x40;
|
||||||
|
|
||||||
|
buffer[5] += (byte)(decoded.TPGS << 4);
|
||||||
|
|
||||||
|
if(decoded.ThreePC)
|
||||||
|
buffer[5] += 0x08;
|
||||||
|
|
||||||
|
buffer[5] += (byte)(decoded.Reserved2 << 1);
|
||||||
|
|
||||||
|
if(decoded.Protect)
|
||||||
|
buffer[5] += 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.BQue ||
|
||||||
|
decoded.EncServ ||
|
||||||
|
decoded.VS1 ||
|
||||||
|
decoded.MultiP ||
|
||||||
|
decoded.MChngr ||
|
||||||
|
decoded.ACKREQQ ||
|
||||||
|
decoded.Addr32 ||
|
||||||
|
decoded.Addr16)
|
||||||
|
{
|
||||||
|
length = 7;
|
||||||
|
|
||||||
|
if(decoded.BQue)
|
||||||
|
buffer[6] = 0x80;
|
||||||
|
|
||||||
|
if(decoded.EncServ)
|
||||||
|
buffer[6] += 0x40;
|
||||||
|
|
||||||
|
if(decoded.VS1)
|
||||||
|
buffer[6] += 0x20;
|
||||||
|
|
||||||
|
if(decoded.MultiP)
|
||||||
|
buffer[6] += 0x10;
|
||||||
|
|
||||||
|
if(decoded.MChngr)
|
||||||
|
buffer[6] += 0x08;
|
||||||
|
|
||||||
|
if(decoded.ACKREQQ)
|
||||||
|
buffer[6] += 0x04;
|
||||||
|
|
||||||
|
if(decoded.Addr32)
|
||||||
|
buffer[6] += 0x02;
|
||||||
|
|
||||||
|
if(decoded.Addr16)
|
||||||
|
buffer[6] += 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.RelAddr ||
|
||||||
|
decoded.WBus32 ||
|
||||||
|
decoded.WBus16 ||
|
||||||
|
decoded.Sync ||
|
||||||
|
decoded.Linked ||
|
||||||
|
decoded.TranDis ||
|
||||||
|
decoded.CmdQue ||
|
||||||
|
decoded.SftRe)
|
||||||
|
|
||||||
|
{
|
||||||
|
length = 8;
|
||||||
|
|
||||||
|
if(decoded.RelAddr)
|
||||||
|
buffer[7] = 0x80;
|
||||||
|
|
||||||
|
if(decoded.WBus32)
|
||||||
|
buffer[7] += 0x40;
|
||||||
|
|
||||||
|
if(decoded.WBus16)
|
||||||
|
buffer[7] += 0x20;
|
||||||
|
|
||||||
|
if(decoded.Sync)
|
||||||
|
buffer[7] += 0x10;
|
||||||
|
|
||||||
|
if(decoded.Linked)
|
||||||
|
buffer[7] += 0x08;
|
||||||
|
|
||||||
|
if(decoded.TranDis)
|
||||||
|
buffer[7] += 0x04;
|
||||||
|
|
||||||
|
if(decoded.CmdQue)
|
||||||
|
buffer[7] += 0x02;
|
||||||
|
|
||||||
|
if(decoded.SftRe)
|
||||||
|
buffer[7] += 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.VendorIdentification != null)
|
||||||
|
{
|
||||||
|
length = 16;
|
||||||
|
|
||||||
|
Array.Copy(decoded.VendorIdentification, 0, buffer, 8,
|
||||||
|
decoded.VendorIdentification.Length >= 8 ? 8 : decoded.VendorIdentification.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.ProductIdentification != null)
|
||||||
|
{
|
||||||
|
length = 32;
|
||||||
|
|
||||||
|
Array.Copy(decoded.ProductIdentification, 0, buffer, 16,
|
||||||
|
decoded.ProductIdentification.Length >= 16 ? 16 : decoded.ProductIdentification.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.ProductRevisionLevel != null)
|
||||||
|
{
|
||||||
|
length = 36;
|
||||||
|
|
||||||
|
Array.Copy(decoded.ProductRevisionLevel, 0, buffer, 32,
|
||||||
|
decoded.ProductRevisionLevel.Length >= 4 ? 4 : decoded.ProductRevisionLevel.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.Seagate_DriveSerialNumber != null)
|
||||||
|
{
|
||||||
|
length = 44;
|
||||||
|
Array.Copy(decoded.Seagate_DriveSerialNumber, 0, buffer, 36, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.KreonIdentifier != null &&
|
||||||
|
decoded.KreonVersion != null)
|
||||||
|
{
|
||||||
|
length = 46;
|
||||||
|
Array.Copy(decoded.KreonIdentifier, 0, buffer, 36, 5);
|
||||||
|
buffer[41] = decoded.KreonSpace;
|
||||||
|
Array.Copy(decoded.KreonVersion, 0, buffer, 42, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.HP_WORM ||
|
||||||
|
decoded.HP_WORMVersion > 0 ||
|
||||||
|
decoded.HP_OBDR != null)
|
||||||
|
{
|
||||||
|
length = 49;
|
||||||
|
|
||||||
|
if(decoded.HP_WORM)
|
||||||
|
buffer[40] = 0x01;
|
||||||
|
|
||||||
|
buffer[40] += (byte)(decoded.HP_WORMVersion << 1);
|
||||||
|
Array.Copy(decoded.HP_OBDR, 0, buffer, 43, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.VendorSpecific != null)
|
||||||
|
{
|
||||||
|
length = 56;
|
||||||
|
Array.Copy(decoded.VendorSpecific, 0, buffer, 36, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.Reserved3 > 0 ||
|
||||||
|
decoded.Clocking > 0 ||
|
||||||
|
decoded.QAS ||
|
||||||
|
decoded.IUS)
|
||||||
|
{
|
||||||
|
length = 57;
|
||||||
|
buffer[56] = (byte)(decoded.Reserved3 << 4);
|
||||||
|
buffer[56] += (byte)(decoded.Clocking << 2);
|
||||||
|
|
||||||
|
if(decoded.QAS)
|
||||||
|
buffer[56] += 0x02;
|
||||||
|
|
||||||
|
if(decoded.IUS)
|
||||||
|
buffer[56] += 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.Reserved4 != 0)
|
||||||
|
{
|
||||||
|
length = 58;
|
||||||
|
buffer[57] = decoded.Reserved4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.VersionDescriptors != null)
|
||||||
|
{
|
||||||
|
length = (byte)(58 + (decoded.VersionDescriptors.Length * 2));
|
||||||
|
|
||||||
|
for(int i = 0; i < decoded.VersionDescriptors.Length; i++)
|
||||||
|
Array.Copy(BitConverter.GetBytes(decoded.VersionDescriptors[i]), 0, buffer, 56 + (i * 2), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.Reserved5 != null)
|
||||||
|
{
|
||||||
|
length = (byte)(74 + decoded.Reserved5.Length);
|
||||||
|
Array.Copy(decoded.Reserved5, 0, buffer, 74, decoded.Reserved5.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.VendorSpecific2 != null)
|
||||||
|
{
|
||||||
|
length = (byte)(96 + decoded.VendorSpecific2.Length);
|
||||||
|
Array.Copy(decoded.VendorSpecific2, 0, buffer, 96, decoded.VendorSpecific2.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.Seagate_Copyright != null)
|
||||||
|
{
|
||||||
|
length = 144;
|
||||||
|
Array.Copy(decoded.Seagate_Copyright, 0, buffer, 96, 48);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.Seagate_ServoPROMPartNo != null)
|
||||||
|
{
|
||||||
|
length = 148;
|
||||||
|
Array.Copy(decoded.Seagate_ServoPROMPartNo, 0, buffer, 144, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer[4] = length;
|
||||||
|
byte[] dest = new byte[length];
|
||||||
|
Array.Copy(buffer, 0, dest, 0, length);
|
||||||
|
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
#endregion Public methods
|
||||||
|
}
|
||||||
|
}
|
||||||
474
Structs/Devices/SCSI/Modes/2A.cs
Normal file
474
Structs/Devices/SCSI/Modes/2A.cs
Normal file
@@ -0,0 +1,474 @@
|
|||||||
|
// /***************************************************************************
|
||||||
|
// The Disc Image Chef
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : 2A.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// Component : Device structures decoders.
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Decodes SCSI MODE PAGE 2Ah: CD-ROM capabilities page.
|
||||||
|
//
|
||||||
|
// --[ License ] --------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 2.1 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful, but
|
||||||
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Copyright © 2011-2020 Natalia Portillo
|
||||||
|
// ****************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace DiscImageChef.CommonTypes.Structs.Devices.SCSI.Modes
|
||||||
|
{
|
||||||
|
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
|
||||||
|
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
|
||||||
|
#region Mode Page 0x2A: CD-ROM capabilities page
|
||||||
|
/// <summary>
|
||||||
|
/// CD-ROM capabilities page Page code 0x2A 16 bytes in OB-U0077C 20 bytes in SFF-8020i 22 bytes in MMC-1 26 bytes
|
||||||
|
/// in MMC-2 Variable bytes in MMC-3
|
||||||
|
/// </summary>
|
||||||
|
public class ModePage_2A
|
||||||
|
{
|
||||||
|
public ModePage_2A_WriteDescriptor[] WriteSpeedPerformanceDescriptors;
|
||||||
|
/// <summary>Parameters can be saved</summary>
|
||||||
|
public bool PS { get; set; }
|
||||||
|
/// <summary>Drive supports multi-session and/or Photo-CD</summary>
|
||||||
|
public bool MultiSession { get; set; }
|
||||||
|
/// <summary>Drive is capable of reading sectors in Mode 2 Form 2 format</summary>
|
||||||
|
public bool Mode2Form2 { get; set; }
|
||||||
|
/// <summary>Drive is capable of reading sectors in Mode 2 Form 1 format</summary>
|
||||||
|
public bool Mode2Form1 { get; set; }
|
||||||
|
/// <summary>Drive is capable of playing audio</summary>
|
||||||
|
public bool AudioPlay { get; set; }
|
||||||
|
/// <summary>Drive can return the ISRC</summary>
|
||||||
|
public bool ISRC { get; set; }
|
||||||
|
/// <summary>Drive can return the media catalogue number</summary>
|
||||||
|
public bool UPC { get; set; }
|
||||||
|
/// <summary>Drive can return C2 pointers</summary>
|
||||||
|
public bool C2Pointer { get; set; }
|
||||||
|
/// <summary>Drive can read, deinterlave and correct R-W subchannels</summary>
|
||||||
|
public bool DeinterlaveSubchannel { get; set; }
|
||||||
|
/// <summary>Drive can read interleaved and uncorrected R-W subchannels</summary>
|
||||||
|
public bool Subchannel { get; set; }
|
||||||
|
/// <summary>Drive can continue from a loss of streaming on audio reading</summary>
|
||||||
|
public bool AccurateCDDA { get; set; }
|
||||||
|
/// <summary>Audio can be read as digital data</summary>
|
||||||
|
public bool CDDACommand { get; set; }
|
||||||
|
/// <summary>Loading Mechanism Type</summary>
|
||||||
|
public byte LoadingMechanism { get; set; }
|
||||||
|
/// <summary>Drive can eject discs</summary>
|
||||||
|
public bool Eject { get; set; }
|
||||||
|
/// <summary>Drive's optional prevent jumper status</summary>
|
||||||
|
public bool PreventJumper { get; set; }
|
||||||
|
/// <summary>Current lock status</summary>
|
||||||
|
public bool LockState { get; set; }
|
||||||
|
/// <summary>Drive can lock media</summary>
|
||||||
|
public bool Lock { get; set; }
|
||||||
|
/// <summary>Each channel can be muted independently</summary>
|
||||||
|
public bool SeparateChannelMute { get; set; }
|
||||||
|
/// <summary>Each channel's volume can be controlled independently</summary>
|
||||||
|
public bool SeparateChannelVolume { get; set; }
|
||||||
|
/// <summary>Maximum drive speed in Kbytes/second</summary>
|
||||||
|
public ushort MaximumSpeed { get; set; }
|
||||||
|
/// <summary>Supported volume levels</summary>
|
||||||
|
public ushort SupportedVolumeLevels { get; set; }
|
||||||
|
/// <summary>Buffer size in Kbytes</summary>
|
||||||
|
public ushort BufferSize { get; set; }
|
||||||
|
/// <summary>Current drive speed in Kbytes/second</summary>
|
||||||
|
public ushort CurrentSpeed { get; set; }
|
||||||
|
|
||||||
|
public bool Method2 { get; set; }
|
||||||
|
public bool ReadCDRW { get; set; }
|
||||||
|
public bool ReadCDR { get; set; }
|
||||||
|
public bool WriteCDRW { get; set; }
|
||||||
|
public bool WriteCDR { get; set; }
|
||||||
|
public bool DigitalPort2 { get; set; }
|
||||||
|
public bool DigitalPort1 { get; set; }
|
||||||
|
public bool Composite { get; set; }
|
||||||
|
public bool SSS { get; set; }
|
||||||
|
public bool SDP { get; set; }
|
||||||
|
public byte Length { get; set; }
|
||||||
|
public bool LSBF { get; set; }
|
||||||
|
public bool RCK { get; set; }
|
||||||
|
public bool BCK { get; set; }
|
||||||
|
|
||||||
|
public bool TestWrite { get; set; }
|
||||||
|
public ushort MaxWriteSpeed { get; set; }
|
||||||
|
public ushort CurrentWriteSpeed { get; set; }
|
||||||
|
|
||||||
|
public bool ReadBarcode { get; set; }
|
||||||
|
|
||||||
|
public bool ReadDVDRAM { get; set; }
|
||||||
|
public bool ReadDVDR { get; set; }
|
||||||
|
public bool ReadDVDROM { get; set; }
|
||||||
|
public bool WriteDVDRAM { get; set; }
|
||||||
|
public bool WriteDVDR { get; set; }
|
||||||
|
public bool LeadInPW { get; set; }
|
||||||
|
public bool SCC { get; set; }
|
||||||
|
public ushort CMRSupported { get; set; }
|
||||||
|
|
||||||
|
public bool BUF { get; set; }
|
||||||
|
public byte RotationControlSelected { get; set; }
|
||||||
|
public ushort CurrentWriteSpeedSelected { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore, Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public static ModePage_2A Decode(byte[] pageResponse)
|
||||||
|
{
|
||||||
|
if((pageResponse?[0] & 0x40) == 0x40)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if((pageResponse?[0] & 0x3F) != 0x2A)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if(pageResponse[1] + 2 != pageResponse.Length)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if(pageResponse.Length < 16)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var decoded = new ModePage_2A();
|
||||||
|
|
||||||
|
decoded.PS |= (pageResponse[0] & 0x80) == 0x80;
|
||||||
|
|
||||||
|
decoded.AudioPlay |= (pageResponse[4] & 0x01) == 0x01;
|
||||||
|
decoded.Mode2Form1 |= (pageResponse[4] & 0x10) == 0x10;
|
||||||
|
decoded.Mode2Form2 |= (pageResponse[4] & 0x20) == 0x20;
|
||||||
|
decoded.MultiSession |= (pageResponse[4] & 0x40) == 0x40;
|
||||||
|
|
||||||
|
decoded.CDDACommand |= (pageResponse[5] & 0x01) == 0x01;
|
||||||
|
decoded.AccurateCDDA |= (pageResponse[5] & 0x02) == 0x02;
|
||||||
|
decoded.Subchannel |= (pageResponse[5] & 0x04) == 0x04;
|
||||||
|
decoded.DeinterlaveSubchannel |= (pageResponse[5] & 0x08) == 0x08;
|
||||||
|
decoded.C2Pointer |= (pageResponse[5] & 0x10) == 0x10;
|
||||||
|
decoded.UPC |= (pageResponse[5] & 0x20) == 0x20;
|
||||||
|
decoded.ISRC |= (pageResponse[5] & 0x40) == 0x40;
|
||||||
|
|
||||||
|
decoded.LoadingMechanism = (byte)((pageResponse[6] & 0xE0) >> 5);
|
||||||
|
decoded.Lock |= (pageResponse[6] & 0x01) == 0x01;
|
||||||
|
decoded.LockState |= (pageResponse[6] & 0x02) == 0x02;
|
||||||
|
decoded.PreventJumper |= (pageResponse[6] & 0x04) == 0x04;
|
||||||
|
decoded.Eject |= (pageResponse[6] & 0x08) == 0x08;
|
||||||
|
|
||||||
|
decoded.SeparateChannelVolume |= (pageResponse[7] & 0x01) == 0x01;
|
||||||
|
decoded.SeparateChannelMute |= (pageResponse[7] & 0x02) == 0x02;
|
||||||
|
|
||||||
|
decoded.MaximumSpeed = (ushort)((pageResponse[8] << 8) + pageResponse[9]);
|
||||||
|
decoded.SupportedVolumeLevels = (ushort)((pageResponse[10] << 8) + pageResponse[11]);
|
||||||
|
decoded.BufferSize = (ushort)((pageResponse[12] << 8) + pageResponse[13]);
|
||||||
|
decoded.CurrentSpeed = (ushort)((pageResponse[14] << 8) + pageResponse[15]);
|
||||||
|
|
||||||
|
if(pageResponse.Length < 20)
|
||||||
|
return decoded;
|
||||||
|
|
||||||
|
decoded.Method2 |= (pageResponse[2] & 0x04) == 0x04;
|
||||||
|
decoded.ReadCDRW |= (pageResponse[2] & 0x02) == 0x02;
|
||||||
|
decoded.ReadCDR |= (pageResponse[2] & 0x01) == 0x01;
|
||||||
|
|
||||||
|
decoded.WriteCDRW |= (pageResponse[3] & 0x02) == 0x02;
|
||||||
|
decoded.WriteCDR |= (pageResponse[3] & 0x01) == 0x01;
|
||||||
|
|
||||||
|
decoded.Composite |= (pageResponse[4] & 0x02) == 0x02;
|
||||||
|
decoded.DigitalPort1 |= (pageResponse[4] & 0x04) == 0x04;
|
||||||
|
decoded.DigitalPort2 |= (pageResponse[4] & 0x08) == 0x08;
|
||||||
|
|
||||||
|
decoded.SDP |= (pageResponse[7] & 0x04) == 0x04;
|
||||||
|
decoded.SSS |= (pageResponse[7] & 0x08) == 0x08;
|
||||||
|
|
||||||
|
decoded.Length = (byte)((pageResponse[17] & 0x30) >> 4);
|
||||||
|
decoded.LSBF |= (pageResponse[17] & 0x08) == 0x08;
|
||||||
|
decoded.RCK |= (pageResponse[17] & 0x04) == 0x04;
|
||||||
|
decoded.BCK |= (pageResponse[17] & 0x02) == 0x02;
|
||||||
|
|
||||||
|
if(pageResponse.Length < 22)
|
||||||
|
return decoded;
|
||||||
|
|
||||||
|
decoded.TestWrite |= (pageResponse[3] & 0x04) == 0x04;
|
||||||
|
decoded.MaxWriteSpeed = (ushort)((pageResponse[18] << 8) + pageResponse[19]);
|
||||||
|
decoded.CurrentWriteSpeed = (ushort)((pageResponse[20] << 8) + pageResponse[21]);
|
||||||
|
|
||||||
|
decoded.ReadBarcode |= (pageResponse[5] & 0x80) == 0x80;
|
||||||
|
|
||||||
|
if(pageResponse.Length < 26)
|
||||||
|
return decoded;
|
||||||
|
|
||||||
|
decoded.ReadDVDRAM |= (pageResponse[2] & 0x20) == 0x20;
|
||||||
|
decoded.ReadDVDR |= (pageResponse[2] & 0x10) == 0x10;
|
||||||
|
decoded.ReadDVDROM |= (pageResponse[2] & 0x08) == 0x08;
|
||||||
|
|
||||||
|
decoded.WriteDVDRAM |= (pageResponse[3] & 0x20) == 0x20;
|
||||||
|
decoded.WriteDVDR |= (pageResponse[3] & 0x10) == 0x10;
|
||||||
|
|
||||||
|
decoded.LeadInPW |= (pageResponse[3] & 0x20) == 0x20;
|
||||||
|
decoded.SCC |= (pageResponse[3] & 0x10) == 0x10;
|
||||||
|
|
||||||
|
decoded.CMRSupported = (ushort)((pageResponse[22] << 8) + pageResponse[23]);
|
||||||
|
|
||||||
|
if(pageResponse.Length < 32)
|
||||||
|
return decoded;
|
||||||
|
|
||||||
|
decoded.BUF |= (pageResponse[4] & 0x80) == 0x80;
|
||||||
|
decoded.RotationControlSelected = (byte)(pageResponse[27] & 0x03);
|
||||||
|
decoded.CurrentWriteSpeedSelected = (ushort)((pageResponse[28] << 8) + pageResponse[29]);
|
||||||
|
|
||||||
|
ushort descriptors = (ushort)((pageResponse.Length - 32) / 4);
|
||||||
|
decoded.WriteSpeedPerformanceDescriptors = new ModePage_2A_WriteDescriptor[descriptors];
|
||||||
|
|
||||||
|
for(int i = 0; i < descriptors; i++)
|
||||||
|
decoded.WriteSpeedPerformanceDescriptors[i] = new ModePage_2A_WriteDescriptor
|
||||||
|
{
|
||||||
|
RotationControl =
|
||||||
|
(byte)(pageResponse[1 + 32 + (i * 4)] & 0x07),
|
||||||
|
WriteSpeed = (ushort)((pageResponse[2 + 32 + (i * 4)] << 8) + pageResponse[3 + 32 + (i * 4)])
|
||||||
|
};
|
||||||
|
|
||||||
|
return decoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] Encode(ModePage_2A decoded)
|
||||||
|
{
|
||||||
|
byte[] pageResponse = new byte[512];
|
||||||
|
byte length = 16;
|
||||||
|
|
||||||
|
pageResponse[0] = 0x2A;
|
||||||
|
|
||||||
|
if(decoded.PS)
|
||||||
|
pageResponse[0] += 0x80;
|
||||||
|
|
||||||
|
if(decoded.AudioPlay)
|
||||||
|
pageResponse[4] += 0x01;
|
||||||
|
|
||||||
|
if(decoded.Mode2Form1)
|
||||||
|
pageResponse[4] += 0x10;
|
||||||
|
|
||||||
|
if(decoded.Mode2Form2)
|
||||||
|
pageResponse[4] += 0x20;
|
||||||
|
|
||||||
|
if(decoded.MultiSession)
|
||||||
|
pageResponse[4] += 0x40;
|
||||||
|
|
||||||
|
if(decoded.CDDACommand)
|
||||||
|
pageResponse[5] += 0x01;
|
||||||
|
|
||||||
|
if(decoded.AccurateCDDA)
|
||||||
|
pageResponse[5] += 0x02;
|
||||||
|
|
||||||
|
if(decoded.Subchannel)
|
||||||
|
pageResponse[5] += 0x04;
|
||||||
|
|
||||||
|
if(decoded.DeinterlaveSubchannel)
|
||||||
|
pageResponse[5] += 0x08;
|
||||||
|
|
||||||
|
if(decoded.C2Pointer)
|
||||||
|
pageResponse[5] += 0x10;
|
||||||
|
|
||||||
|
if(decoded.UPC)
|
||||||
|
pageResponse[5] += 0x20;
|
||||||
|
|
||||||
|
if(decoded.ISRC)
|
||||||
|
pageResponse[5] += 0x40;
|
||||||
|
|
||||||
|
decoded.LoadingMechanism = (byte)((pageResponse[6] & 0xE0) >> 5);
|
||||||
|
|
||||||
|
if(decoded.Lock)
|
||||||
|
pageResponse[6] += 0x01;
|
||||||
|
|
||||||
|
if(decoded.LockState)
|
||||||
|
pageResponse[6] += 0x02;
|
||||||
|
|
||||||
|
if(decoded.PreventJumper)
|
||||||
|
pageResponse[6] += 0x04;
|
||||||
|
|
||||||
|
if(decoded.Eject)
|
||||||
|
pageResponse[6] += 0x08;
|
||||||
|
|
||||||
|
if(decoded.SeparateChannelVolume)
|
||||||
|
pageResponse[7] += 0x01;
|
||||||
|
|
||||||
|
if(decoded.SeparateChannelMute)
|
||||||
|
pageResponse[7] += 0x02;
|
||||||
|
|
||||||
|
decoded.MaximumSpeed = (ushort)((pageResponse[8] << 8) + pageResponse[9]);
|
||||||
|
decoded.SupportedVolumeLevels = (ushort)((pageResponse[10] << 8) + pageResponse[11]);
|
||||||
|
decoded.BufferSize = (ushort)((pageResponse[12] << 8) + pageResponse[13]);
|
||||||
|
decoded.CurrentSpeed = (ushort)((pageResponse[14] << 8) + pageResponse[15]);
|
||||||
|
|
||||||
|
if(decoded.Method2 ||
|
||||||
|
decoded.ReadCDRW ||
|
||||||
|
decoded.ReadCDR ||
|
||||||
|
decoded.WriteCDRW ||
|
||||||
|
decoded.WriteCDR ||
|
||||||
|
decoded.Composite ||
|
||||||
|
decoded.DigitalPort1 ||
|
||||||
|
decoded.DigitalPort2 ||
|
||||||
|
decoded.SDP ||
|
||||||
|
decoded.SSS ||
|
||||||
|
decoded.Length > 0 ||
|
||||||
|
decoded.LSBF ||
|
||||||
|
decoded.RCK ||
|
||||||
|
decoded.BCK)
|
||||||
|
{
|
||||||
|
length = 20;
|
||||||
|
|
||||||
|
if(decoded.Method2)
|
||||||
|
pageResponse[2] += 0x04;
|
||||||
|
|
||||||
|
if(decoded.ReadCDRW)
|
||||||
|
pageResponse[2] += 0x02;
|
||||||
|
|
||||||
|
if(decoded.ReadCDR)
|
||||||
|
pageResponse[2] += 0x01;
|
||||||
|
|
||||||
|
if(decoded.WriteCDRW)
|
||||||
|
pageResponse[3] += 0x02;
|
||||||
|
|
||||||
|
if(decoded.WriteCDR)
|
||||||
|
pageResponse[3] += 0x01;
|
||||||
|
|
||||||
|
if(decoded.Composite)
|
||||||
|
pageResponse[4] += 0x02;
|
||||||
|
|
||||||
|
if(decoded.DigitalPort1)
|
||||||
|
pageResponse[4] += 0x04;
|
||||||
|
|
||||||
|
if(decoded.DigitalPort2)
|
||||||
|
pageResponse[4] += 0x08;
|
||||||
|
|
||||||
|
if(decoded.SDP)
|
||||||
|
pageResponse[7] += 0x04;
|
||||||
|
|
||||||
|
if(decoded.SSS)
|
||||||
|
pageResponse[7] += 0x08;
|
||||||
|
|
||||||
|
pageResponse[17] = (byte)(decoded.Length << 4);
|
||||||
|
|
||||||
|
if(decoded.LSBF)
|
||||||
|
pageResponse[17] += 0x08;
|
||||||
|
|
||||||
|
if(decoded.RCK)
|
||||||
|
pageResponse[17] += 0x04;
|
||||||
|
|
||||||
|
if(decoded.BCK)
|
||||||
|
pageResponse[17] += 0x02;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.TestWrite ||
|
||||||
|
decoded.MaxWriteSpeed > 0 ||
|
||||||
|
decoded.CurrentWriteSpeed > 0 ||
|
||||||
|
decoded.ReadBarcode)
|
||||||
|
{
|
||||||
|
length = 22;
|
||||||
|
|
||||||
|
if(decoded.TestWrite)
|
||||||
|
pageResponse[3] += 0x04;
|
||||||
|
|
||||||
|
pageResponse[18] = (byte)((decoded.MaxWriteSpeed & 0xFF00) >> 8);
|
||||||
|
pageResponse[19] = (byte)(decoded.MaxWriteSpeed & 0xFF);
|
||||||
|
pageResponse[20] = (byte)((decoded.CurrentWriteSpeed & 0xFF00) >> 8);
|
||||||
|
pageResponse[21] = (byte)(decoded.CurrentWriteSpeed & 0xFF);
|
||||||
|
|
||||||
|
if(decoded.ReadBarcode)
|
||||||
|
pageResponse[5] += 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.ReadDVDRAM ||
|
||||||
|
decoded.ReadDVDR ||
|
||||||
|
decoded.ReadDVDROM ||
|
||||||
|
decoded.WriteDVDRAM ||
|
||||||
|
decoded.WriteDVDR ||
|
||||||
|
decoded.LeadInPW ||
|
||||||
|
decoded.SCC ||
|
||||||
|
decoded.CMRSupported > 0)
|
||||||
|
|
||||||
|
{
|
||||||
|
length = 26;
|
||||||
|
|
||||||
|
if(decoded.ReadDVDRAM)
|
||||||
|
pageResponse[2] += 0x20;
|
||||||
|
|
||||||
|
if(decoded.ReadDVDR)
|
||||||
|
pageResponse[2] += 0x10;
|
||||||
|
|
||||||
|
if(decoded.ReadDVDROM)
|
||||||
|
pageResponse[2] += 0x08;
|
||||||
|
|
||||||
|
if(decoded.WriteDVDRAM)
|
||||||
|
pageResponse[3] += 0x20;
|
||||||
|
|
||||||
|
if(decoded.WriteDVDR)
|
||||||
|
pageResponse[3] += 0x10;
|
||||||
|
|
||||||
|
if(decoded.LeadInPW)
|
||||||
|
pageResponse[3] += 0x20;
|
||||||
|
|
||||||
|
if(decoded.SCC)
|
||||||
|
pageResponse[3] += 0x10;
|
||||||
|
|
||||||
|
pageResponse[22] = (byte)((decoded.CMRSupported & 0xFF00) >> 8);
|
||||||
|
pageResponse[23] = (byte)(decoded.CMRSupported & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.BUF ||
|
||||||
|
decoded.RotationControlSelected > 0 ||
|
||||||
|
decoded.CurrentWriteSpeedSelected > 0)
|
||||||
|
{
|
||||||
|
length = 32;
|
||||||
|
|
||||||
|
if(decoded.BUF)
|
||||||
|
pageResponse[4] += 0x80;
|
||||||
|
|
||||||
|
pageResponse[27] += decoded.RotationControlSelected;
|
||||||
|
pageResponse[28] = (byte)((decoded.CurrentWriteSpeedSelected & 0xFF00) >> 8);
|
||||||
|
pageResponse[29] = (byte)(decoded.CurrentWriteSpeedSelected & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decoded.WriteSpeedPerformanceDescriptors != null)
|
||||||
|
{
|
||||||
|
length = 32;
|
||||||
|
|
||||||
|
for(int i = 0; i < decoded.WriteSpeedPerformanceDescriptors.Length; i++)
|
||||||
|
{
|
||||||
|
length += 4;
|
||||||
|
pageResponse[1 + 32 + (i * 4)] = decoded.WriteSpeedPerformanceDescriptors[i].RotationControl;
|
||||||
|
|
||||||
|
pageResponse[2 + 32 + (i * 4)] =
|
||||||
|
(byte)((decoded.WriteSpeedPerformanceDescriptors[i].WriteSpeed & 0xFF00) >> 8);
|
||||||
|
|
||||||
|
pageResponse[3 + 32 + (i * 4)] =
|
||||||
|
(byte)(decoded.WriteSpeedPerformanceDescriptors[i].WriteSpeed & 0xFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pageResponse[1] = (byte)(length - 2);
|
||||||
|
byte[] buf = new byte[length];
|
||||||
|
Array.Copy(pageResponse, 0, buf, 0, length);
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct ModePage_2A_WriteDescriptor
|
||||||
|
{
|
||||||
|
public byte RotationControl;
|
||||||
|
public ushort WriteSpeed;
|
||||||
|
}
|
||||||
|
#endregion Mode Page 0x2A: CD-ROM capabilities page
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user