mirror of
https://github.com/aaru-dps/Aaru.CommonTypes.git
synced 2025-12-16 19:24:30 +00:00
[Aaru.CommonTypes] Reformat and cleanup.
This commit is contained in:
@@ -55,11 +55,12 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA;
|
||||
/// T13-1699D rev. 3f (ATA8-ACS) T13-1699D rev. 4a (ATA8-ACS) T13-2015D rev. 2 (ACS-2) T13-2161D rev. 5 (ACS-3) CF+
|
||||
/// & CF Specification rev. 1.4 (CFA)
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
|
||||
SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public static class Identify
|
||||
{
|
||||
const string MODULE_NAME = "ATA/ATAPI IDENTIFY decoder";
|
||||
#region CapabilitiesBit enum
|
||||
|
||||
/// <summary>Capabilities flag bits.</summary>
|
||||
[Flags]
|
||||
@@ -101,6 +102,10 @@ public static class Identify
|
||||
PhysicalAlignment0 = 0x0001
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CapabilitiesBit2 enum
|
||||
|
||||
/// <summary>More capabilities flag bits.</summary>
|
||||
[Flags]
|
||||
public enum CapabilitiesBit2 : ushort
|
||||
@@ -109,17 +114,29 @@ public static class Identify
|
||||
MustBeClear = 0x8000,
|
||||
/// <summary>MUST be set</summary>
|
||||
MustBeSet = 0x4000,
|
||||
#pragma warning disable 1591
|
||||
Reserved13 = 0x2000, Reserved12 = 0x1000, Reserved11 = 0x0800,
|
||||
Reserved10 = 0x0400, Reserved09 = 0x0200, Reserved08 = 0x0100,
|
||||
Reserved07 = 0x0080, Reserved06 = 0x0040, Reserved05 = 0x0020,
|
||||
Reserved04 = 0x0010, Reserved03 = 0x0008, Reserved02 = 0x0004,
|
||||
#pragma warning disable 1591
|
||||
Reserved13 = 0x2000,
|
||||
Reserved12 = 0x1000,
|
||||
Reserved11 = 0x0800,
|
||||
Reserved10 = 0x0400,
|
||||
Reserved09 = 0x0200,
|
||||
Reserved08 = 0x0100,
|
||||
Reserved07 = 0x0080,
|
||||
Reserved06 = 0x0040,
|
||||
Reserved05 = 0x0020,
|
||||
Reserved04 = 0x0010,
|
||||
Reserved03 = 0x0008,
|
||||
Reserved02 = 0x0004,
|
||||
Reserved01 = 0x0002,
|
||||
#pragma warning restore 1591
|
||||
#pragma warning restore 1591
|
||||
/// <summary>Indicates a device specific minimum standby timer value</summary>
|
||||
SpecificStandbyTimer = 0x0001
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CapabilitiesBit3 enum
|
||||
|
||||
/// <summary>Even more capabilities flag bits.</summary>
|
||||
[Flags]
|
||||
public enum CapabilitiesBit3 : byte
|
||||
@@ -136,13 +153,17 @@ public static class Identify
|
||||
SanitizeCommands = 0x0008,
|
||||
/// <summary>SANITIZE ANTIFREEZE LOCK EXT is supported</summary>
|
||||
SanitizeAntifreeze = 0x0004,
|
||||
#pragma warning disable 1591
|
||||
#pragma warning disable 1591
|
||||
Reserved01 = 0x0002,
|
||||
#pragma warning restore 1591
|
||||
#pragma warning restore 1591
|
||||
/// <summary>Multiple logical sector setting is valid</summary>
|
||||
MultipleValid = 0x0001
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CommandSetBit enum
|
||||
|
||||
/// <summary>Command set flag bits.</summary>
|
||||
[Flags]
|
||||
public enum CommandSetBit : ushort
|
||||
@@ -181,6 +202,10 @@ public static class Identify
|
||||
SMART = 0x0001
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CommandSetBit2 enum
|
||||
|
||||
/// <summary>More command set flag bits.</summary>
|
||||
[Flags]
|
||||
public enum CommandSetBit2 : ushort
|
||||
@@ -219,6 +244,10 @@ public static class Identify
|
||||
DownloadMicrocode = 0x0001
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CommandSetBit3 enum
|
||||
|
||||
/// <summary>Even more command set flag bits.</summary>
|
||||
[Flags]
|
||||
public enum CommandSetBit3 : ushort
|
||||
@@ -257,6 +286,10 @@ public static class Identify
|
||||
SMARTLog = 0x0001
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CommandSetBit4 enum
|
||||
|
||||
/// <summary>Yet more command set flag bits.</summary>
|
||||
[Flags]
|
||||
public enum CommandSetBit4 : ushort
|
||||
@@ -265,10 +298,12 @@ public static class Identify
|
||||
MustBeClear = 0x8000,
|
||||
/// <summary>MUST be set</summary>
|
||||
MustBeSet = 0x4000,
|
||||
#pragma warning disable 1591
|
||||
Reserved13 = 0x2000, Reserved12 = 0x1000, Reserved11 = 0x0800,
|
||||
#pragma warning disable 1591
|
||||
Reserved13 = 0x2000,
|
||||
Reserved12 = 0x1000,
|
||||
Reserved11 = 0x0800,
|
||||
Reserved10 = 0x0400,
|
||||
#pragma warning restore 1591
|
||||
#pragma warning restore 1591
|
||||
/// <summary>DSN feature set is supported</summary>
|
||||
DSN = 0x0200,
|
||||
/// <summary>Accessible Max Address Configuration is supported</summary>
|
||||
@@ -291,6 +326,10 @@ public static class Identify
|
||||
DT1825 = 0x0001
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CommandSetBit5 enum
|
||||
|
||||
/// <summary>Yet again more command set flag bits.</summary>
|
||||
[Flags]
|
||||
public enum CommandSetBit5 : ushort
|
||||
@@ -329,21 +368,39 @@ public static class Identify
|
||||
ZonedBit0 = 0x0001
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DataSetMgmtBit enum
|
||||
|
||||
/// <summary>Data set management flag bits.</summary>
|
||||
[Flags]
|
||||
public enum DataSetMgmtBit : ushort
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000,
|
||||
Reserved12 = 0x1000, Reserved11 = 0x0800, Reserved10 = 0x0400,
|
||||
Reserved09 = 0x0200, Reserved08 = 0x0100, Reserved07 = 0x0080,
|
||||
Reserved06 = 0x0040, Reserved05 = 0x0020, Reserved04 = 0x0010,
|
||||
Reserved03 = 0x0008, Reserved02 = 0x0004, Reserved01 = 0x0002,
|
||||
#pragma warning restore 1591
|
||||
#pragma warning disable 1591
|
||||
Reserved15 = 0x8000,
|
||||
Reserved14 = 0x4000,
|
||||
Reserved13 = 0x2000,
|
||||
Reserved12 = 0x1000,
|
||||
Reserved11 = 0x0800,
|
||||
Reserved10 = 0x0400,
|
||||
Reserved09 = 0x0200,
|
||||
Reserved08 = 0x0100,
|
||||
Reserved07 = 0x0080,
|
||||
Reserved06 = 0x0040,
|
||||
Reserved05 = 0x0020,
|
||||
Reserved04 = 0x0010,
|
||||
Reserved03 = 0x0008,
|
||||
Reserved02 = 0x0004,
|
||||
Reserved01 = 0x0002,
|
||||
#pragma warning restore 1591
|
||||
/// <summary>TRIM is supported</summary>
|
||||
Trim = 0x0001
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DeviceFormFactorEnum enum
|
||||
|
||||
/// <summary>Device form factor</summary>
|
||||
public enum DeviceFormFactorEnum : ushort
|
||||
{
|
||||
@@ -361,6 +418,10 @@ public static class Identify
|
||||
LessThanOnePointEight = 5
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ExtendedIdentifyBit enum
|
||||
|
||||
/// <summary>Extended identify flag bits.</summary>
|
||||
[Flags]
|
||||
public enum ExtendedIdentifyBit : byte
|
||||
@@ -383,6 +444,10 @@ public static class Identify
|
||||
Words54to58Valid = 0x01
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GeneralConfigurationBit enum
|
||||
|
||||
/// <summary>General configuration flag bits.</summary>
|
||||
[Flags]
|
||||
public enum GeneralConfigurationBit : ushort
|
||||
@@ -423,14 +488,20 @@ public static class Identify
|
||||
Reserved = 0x0001
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MajorVersionBit enum
|
||||
|
||||
/// <summary>Word 80 Major version</summary>
|
||||
[Flags]
|
||||
public enum MajorVersionBit : ushort
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000,
|
||||
#pragma warning disable 1591
|
||||
Reserved15 = 0x8000,
|
||||
Reserved14 = 0x4000,
|
||||
Reserved13 = 0x2000,
|
||||
Reserved12 = 0x1000,
|
||||
#pragma warning restore 1591
|
||||
#pragma warning restore 1591
|
||||
/// <summary>ACS-4</summary>
|
||||
ACS4 = 0x0800,
|
||||
/// <summary>ACS-3</summary>
|
||||
@@ -453,11 +524,15 @@ public static class Identify
|
||||
Ata2 = 0x0004,
|
||||
/// <summary>ATA-1</summary>
|
||||
Ata1 = 0x0002,
|
||||
#pragma warning disable 1591
|
||||
#pragma warning disable 1591
|
||||
Reserved00 = 0x0001
|
||||
#pragma warning restore 1591
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SATACapabilitiesBit enum
|
||||
|
||||
/// <summary>SATA capabilities flags</summary>
|
||||
[Flags]
|
||||
public enum SATACapabilitiesBit : ushort
|
||||
@@ -478,10 +553,12 @@ public static class Identify
|
||||
PowerReceipt = 0x0200,
|
||||
/// <summary>Supports NCQ</summary>
|
||||
NCQ = 0x0100,
|
||||
#pragma warning disable 1591
|
||||
Reserved07 = 0x0080, Reserved06 = 0x0040, Reserved05 = 0x0020,
|
||||
#pragma warning disable 1591
|
||||
Reserved07 = 0x0080,
|
||||
Reserved06 = 0x0040,
|
||||
Reserved05 = 0x0020,
|
||||
Reserved04 = 0x0010,
|
||||
#pragma warning restore 1591
|
||||
#pragma warning restore 1591
|
||||
/// <summary>Supports SATA Gen. 3 Signaling Speed (6.0Gb/s)</summary>
|
||||
Gen3Speed = 0x0008,
|
||||
/// <summary>Supports SATA Gen. 2 Signaling Speed (3.0Gb/s)</summary>
|
||||
@@ -492,15 +569,25 @@ public static class Identify
|
||||
Clear = 0x0001
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SATACapabilitiesBit2 enum
|
||||
|
||||
/// <summary>More SATA capabilities flags</summary>
|
||||
[Flags]
|
||||
public enum SATACapabilitiesBit2 : ushort
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000,
|
||||
Reserved12 = 0x1000, Reserved11 = 0x0800, Reserved10 = 0x0400,
|
||||
Reserved09 = 0x0200, Reserved08 = 0x0100, Reserved07 = 0x0080,
|
||||
#pragma warning restore 1591
|
||||
#pragma warning disable 1591
|
||||
Reserved15 = 0x8000,
|
||||
Reserved14 = 0x4000,
|
||||
Reserved13 = 0x2000,
|
||||
Reserved12 = 0x1000,
|
||||
Reserved11 = 0x0800,
|
||||
Reserved10 = 0x0400,
|
||||
Reserved09 = 0x0200,
|
||||
Reserved08 = 0x0100,
|
||||
Reserved07 = 0x0080,
|
||||
#pragma warning restore 1591
|
||||
/// <summary>Supports RECEIVE FPDMA QUEUED and SEND FPDMA QUEUED</summary>
|
||||
FPDMAQ = 0x0040,
|
||||
/// <summary>Supports NCQ Queue Management</summary>
|
||||
@@ -521,15 +608,24 @@ public static class Identify
|
||||
Clear = 0x0001
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SATAFeaturesBit enum
|
||||
|
||||
/// <summary>SATA features flags</summary>
|
||||
[Flags]
|
||||
public enum SATAFeaturesBit : ushort
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000,
|
||||
Reserved12 = 0x1000, Reserved11 = 0x0800, Reserved10 = 0x0400,
|
||||
Reserved09 = 0x0200, Reserved08 = 0x0100,
|
||||
#pragma warning restore 1591
|
||||
#pragma warning disable 1591
|
||||
Reserved15 = 0x8000,
|
||||
Reserved14 = 0x4000,
|
||||
Reserved13 = 0x2000,
|
||||
Reserved12 = 0x1000,
|
||||
Reserved11 = 0x0800,
|
||||
Reserved10 = 0x0400,
|
||||
Reserved09 = 0x0200,
|
||||
Reserved08 = 0x0100,
|
||||
#pragma warning restore 1591
|
||||
/// <summary>Supports NCQ autosense</summary>
|
||||
NCQAutoSense = 0x0080,
|
||||
/// <summary>Automatic Partial to Slumber transitions are enabled</summary>
|
||||
@@ -552,16 +648,26 @@ public static class Identify
|
||||
Clear = 0x0001
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SCTCommandTransportBit enum
|
||||
|
||||
/// <summary>SCT Command Transport flags</summary>
|
||||
[Flags]
|
||||
public enum SCTCommandTransportBit : ushort
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
Vendor15 = 0x8000, Vendor14 = 0x4000, Vendor13 = 0x2000,
|
||||
Vendor12 = 0x1000, Reserved11 = 0x0800, Reserved10 = 0x0400,
|
||||
Reserved09 = 0x0200, Reserved08 = 0x0100, Reserved07 = 0x0080,
|
||||
#pragma warning disable 1591
|
||||
Vendor15 = 0x8000,
|
||||
Vendor14 = 0x4000,
|
||||
Vendor13 = 0x2000,
|
||||
Vendor12 = 0x1000,
|
||||
Reserved11 = 0x0800,
|
||||
Reserved10 = 0x0400,
|
||||
Reserved09 = 0x0200,
|
||||
Reserved08 = 0x0100,
|
||||
Reserved07 = 0x0080,
|
||||
Reserved06 = 0x0040,
|
||||
#pragma warning restore 1591
|
||||
#pragma warning restore 1591
|
||||
/// <summary>SCT Command Transport Data Tables supported</summary>
|
||||
DataTables = 0x0020,
|
||||
/// <summary>SCT Command Transport Features Control supported</summary>
|
||||
@@ -576,20 +682,29 @@ public static class Identify
|
||||
Supported = 0x0001
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SecurityStatusBit enum
|
||||
|
||||
/// <summary>Security status flag bits.</summary>
|
||||
[Flags]
|
||||
public enum SecurityStatusBit : ushort
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000,
|
||||
Reserved12 = 0x1000, Reserved11 = 0x0800, Reserved10 = 0x0400,
|
||||
#pragma warning disable 1591
|
||||
Reserved15 = 0x8000,
|
||||
Reserved14 = 0x4000,
|
||||
Reserved13 = 0x2000,
|
||||
Reserved12 = 0x1000,
|
||||
Reserved11 = 0x0800,
|
||||
Reserved10 = 0x0400,
|
||||
Reserved09 = 0x0200,
|
||||
#pragma warning restore 1591
|
||||
#pragma warning restore 1591
|
||||
/// <summary>Maximum security level</summary>
|
||||
Maximum = 0x0100,
|
||||
#pragma warning disable 1591
|
||||
Reserved07 = 0x0080, Reserved06 = 0x0040,
|
||||
#pragma warning restore 1591
|
||||
#pragma warning disable 1591
|
||||
Reserved07 = 0x0080,
|
||||
Reserved06 = 0x0040,
|
||||
#pragma warning restore 1591
|
||||
/// <summary>Supports enhanced security erase</summary>
|
||||
Enhanced = 0x0020,
|
||||
/// <summary>Security count expired</summary>
|
||||
@@ -604,6 +719,10 @@ public static class Identify
|
||||
Supported = 0x0001
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SpecificConfigurationEnum enum
|
||||
|
||||
/// <summary>Specific configuration flags</summary>
|
||||
public enum SpecificConfigurationEnum : ushort
|
||||
{
|
||||
@@ -617,17 +736,30 @@ public static class Identify
|
||||
NotRequiresSetCompleteResponse = 0xC837
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TransferMode enum
|
||||
|
||||
/// <summary>Transfer mode flags</summary>
|
||||
[Flags]
|
||||
public enum TransferMode : byte
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
Mode7 = 0x80, Mode6 = 0x40, Mode5 = 0x20,
|
||||
Mode4 = 0x10, Mode3 = 0x08, Mode2 = 0x04,
|
||||
Mode1 = 0x02, Mode0 = 0x01
|
||||
#pragma warning restore 1591
|
||||
#pragma warning disable 1591
|
||||
Mode7 = 0x80,
|
||||
Mode6 = 0x40,
|
||||
Mode5 = 0x20,
|
||||
Mode4 = 0x10,
|
||||
Mode3 = 0x08,
|
||||
Mode2 = 0x04,
|
||||
Mode1 = 0x02,
|
||||
Mode0 = 0x01
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TrustedComputingBit enum
|
||||
|
||||
/// <summary>Trusted Computing flags</summary>
|
||||
[Flags]
|
||||
public enum TrustedComputingBit : ushort
|
||||
@@ -636,17 +768,158 @@ public static class Identify
|
||||
Clear = 0x8000,
|
||||
/// <summary>MUST be set</summary>
|
||||
Set = 0x4000,
|
||||
#pragma warning disable 1591
|
||||
Reserved13 = 0x2000, Reserved12 = 0x1000, Reserved11 = 0x0800,
|
||||
Reserved10 = 0x0400, Reserved09 = 0x0200, Reserved08 = 0x0100,
|
||||
Reserved07 = 0x0080, Reserved06 = 0x0040, Reserved05 = 0x0020,
|
||||
Reserved04 = 0x0010, Reserved03 = 0x0008, Reserved02 = 0x0004,
|
||||
#pragma warning disable 1591
|
||||
Reserved13 = 0x2000,
|
||||
Reserved12 = 0x1000,
|
||||
Reserved11 = 0x0800,
|
||||
Reserved10 = 0x0400,
|
||||
Reserved09 = 0x0200,
|
||||
Reserved08 = 0x0100,
|
||||
Reserved07 = 0x0080,
|
||||
Reserved06 = 0x0040,
|
||||
Reserved05 = 0x0020,
|
||||
Reserved04 = 0x0010,
|
||||
Reserved03 = 0x0008,
|
||||
Reserved02 = 0x0004,
|
||||
Reserved01 = 0x0002,
|
||||
#pragma warning restore 1591
|
||||
#pragma warning restore 1591
|
||||
/// <summary>Trusted Computing feature set is supported</summary>
|
||||
TrustedComputing = 0x0001
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
const string MODULE_NAME = "ATA/ATAPI IDENTIFY decoder";
|
||||
|
||||
/// <summary>Decodes a raw IDENTIFY DEVICE response</summary>
|
||||
/// <param name="IdentifyDeviceResponse">Raw IDENTIFY DEVICE response</param>
|
||||
/// <returns>Decoded IDENTIFY DEVICE</returns>
|
||||
public static IdentifyDevice? Decode(byte[] IdentifyDeviceResponse)
|
||||
{
|
||||
if(IdentifyDeviceResponse == null)
|
||||
return null;
|
||||
|
||||
if(IdentifyDeviceResponse.Length != 512)
|
||||
{
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME,
|
||||
Localization.IDENTIFY_response_is_different_than_512_bytes_not_decoding);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
IdentifyDevice ATAID = Marshal.ByteArrayToStructureLittleEndian<IdentifyDevice>(IdentifyDeviceResponse);
|
||||
|
||||
ATAID.WWN = DescrambleWWN(ATAID.WWN);
|
||||
ATAID.WWNExtension = DescrambleWWN(ATAID.WWNExtension);
|
||||
|
||||
ATAID.SerialNumber = DescrambleATAString(IdentifyDeviceResponse, 10 * 2, 20);
|
||||
ATAID.FirmwareRevision = DescrambleATAString(IdentifyDeviceResponse, 23 * 2, 8);
|
||||
ATAID.Model = DescrambleATAString(IdentifyDeviceResponse, 27 * 2, 40);
|
||||
ATAID.AdditionalPID = DescrambleATAString(IdentifyDeviceResponse, 170 * 2, 8);
|
||||
ATAID.MediaSerial = DescrambleATAString(IdentifyDeviceResponse, 176 * 2, 40);
|
||||
ATAID.MediaManufacturer = DescrambleATAString(IdentifyDeviceResponse, 196 * 2, 20);
|
||||
|
||||
return ATAID;
|
||||
}
|
||||
|
||||
/// <summary>Encodes a raw IDENTIFY DEVICE response</summary>
|
||||
/// <param name="identify">Decoded IDENTIFY DEVICE</param>
|
||||
/// <returns>Raw IDENTIFY DEVICE response</returns>
|
||||
public static byte[] Encode(IdentifyDevice? identify)
|
||||
{
|
||||
if(identify is null)
|
||||
return null;
|
||||
|
||||
IdentifyDevice ataId = identify.Value;
|
||||
|
||||
ataId.WWN = DescrambleWWN(ataId.WWN);
|
||||
ataId.WWNExtension = DescrambleWWN(ataId.WWNExtension);
|
||||
|
||||
var buf = new byte[512];
|
||||
nint ptr = System.Runtime.InteropServices.Marshal.AllocHGlobal(512);
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(ataId, ptr, false);
|
||||
System.Runtime.InteropServices.Marshal.Copy(ptr, buf, 0, 512);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(ptr);
|
||||
|
||||
byte[] str = ScrambleATAString(ataId.SerialNumber, 20);
|
||||
Array.Copy(str, 0, buf, 10 * 2, 20);
|
||||
str = ScrambleATAString(ataId.FirmwareRevision, 8);
|
||||
Array.Copy(str, 0, buf, 23 * 2, 8);
|
||||
str = ScrambleATAString(ataId.Model, 40);
|
||||
Array.Copy(str, 0, buf, 27 * 2, 40);
|
||||
str = ScrambleATAString(ataId.AdditionalPID, 8);
|
||||
Array.Copy(str, 0, buf, 170 * 2, 8);
|
||||
str = ScrambleATAString(ataId.MediaSerial, 40);
|
||||
Array.Copy(str, 0, buf, 176 * 2, 40);
|
||||
str = ScrambleATAString(ataId.MediaManufacturer, 20);
|
||||
Array.Copy(str, 0, buf, 196 * 2, 20);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static ulong DescrambleWWN(ulong WWN)
|
||||
{
|
||||
byte[] qwb = BitConverter.GetBytes(WWN);
|
||||
var qword = new byte[8];
|
||||
|
||||
qword[7] = qwb[1];
|
||||
qword[6] = qwb[0];
|
||||
qword[5] = qwb[3];
|
||||
qword[4] = qwb[2];
|
||||
qword[3] = qwb[5];
|
||||
qword[2] = qwb[4];
|
||||
qword[1] = qwb[7];
|
||||
qword[0] = qwb[6];
|
||||
|
||||
return BitConverter.ToUInt64(qword, 0);
|
||||
}
|
||||
|
||||
static string DescrambleATAString(IList<byte> buffer, int offset, int length)
|
||||
{
|
||||
byte[] outbuf = buffer[offset + length - 1] != 0x00 ? new byte[length + 1] : new byte[length];
|
||||
|
||||
for(var i = 0; i < length; i += 2)
|
||||
{
|
||||
outbuf[i] = buffer[offset + i + 1];
|
||||
outbuf[i + 1] = buffer[offset + i];
|
||||
}
|
||||
|
||||
string outStr = StringHandlers.CToString(outbuf);
|
||||
|
||||
return outStr.Trim();
|
||||
}
|
||||
|
||||
static byte[] ScrambleATAString(string str, int length)
|
||||
{
|
||||
var buf = new byte[length];
|
||||
|
||||
for(var i = 0; i < length; i++)
|
||||
buf[i] = 0x20;
|
||||
|
||||
if(str is null)
|
||||
return buf;
|
||||
|
||||
byte[] bytes = Encoding.ASCII.GetBytes(str);
|
||||
|
||||
if(bytes.Length % 2 != 0)
|
||||
{
|
||||
var tmp = new byte[bytes.Length + 1];
|
||||
tmp[^1] = 0x20;
|
||||
Array.Copy(bytes, 0, tmp, 0, bytes.Length);
|
||||
bytes = tmp;
|
||||
}
|
||||
|
||||
for(var i = 0; i < bytes.Length; i += 2)
|
||||
{
|
||||
buf[i] = bytes[i + 1];
|
||||
buf[i + 1] = bytes[i];
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
#region Nested type: IdentifyDevice
|
||||
|
||||
/// <summary>IDENTIFY DEVICE decoded response</summary>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 2)]
|
||||
public struct IdentifyDevice
|
||||
@@ -999,130 +1272,5 @@ public static class Identify
|
||||
public byte Checksum;
|
||||
}
|
||||
|
||||
/// <summary>Decodes a raw IDENTIFY DEVICE response</summary>
|
||||
/// <param name="IdentifyDeviceResponse">Raw IDENTIFY DEVICE response</param>
|
||||
/// <returns>Decoded IDENTIFY DEVICE</returns>
|
||||
public static IdentifyDevice? Decode(byte[] IdentifyDeviceResponse)
|
||||
{
|
||||
if(IdentifyDeviceResponse == null)
|
||||
return null;
|
||||
|
||||
if(IdentifyDeviceResponse.Length != 512)
|
||||
{
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME,
|
||||
Localization.IDENTIFY_response_is_different_than_512_bytes_not_decoding);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
IdentifyDevice ATAID = Marshal.ByteArrayToStructureLittleEndian<IdentifyDevice>(IdentifyDeviceResponse);
|
||||
|
||||
ATAID.WWN = DescrambleWWN(ATAID.WWN);
|
||||
ATAID.WWNExtension = DescrambleWWN(ATAID.WWNExtension);
|
||||
|
||||
ATAID.SerialNumber = DescrambleATAString(IdentifyDeviceResponse, 10 * 2, 20);
|
||||
ATAID.FirmwareRevision = DescrambleATAString(IdentifyDeviceResponse, 23 * 2, 8);
|
||||
ATAID.Model = DescrambleATAString(IdentifyDeviceResponse, 27 * 2, 40);
|
||||
ATAID.AdditionalPID = DescrambleATAString(IdentifyDeviceResponse, 170 * 2, 8);
|
||||
ATAID.MediaSerial = DescrambleATAString(IdentifyDeviceResponse, 176 * 2, 40);
|
||||
ATAID.MediaManufacturer = DescrambleATAString(IdentifyDeviceResponse, 196 * 2, 20);
|
||||
|
||||
return ATAID;
|
||||
}
|
||||
|
||||
/// <summary>Encodes a raw IDENTIFY DEVICE response</summary>
|
||||
/// <param name="identify">Decoded IDENTIFY DEVICE</param>
|
||||
/// <returns>Raw IDENTIFY DEVICE response</returns>
|
||||
public static byte[] Encode(IdentifyDevice? identify)
|
||||
{
|
||||
if(identify is null)
|
||||
return null;
|
||||
|
||||
IdentifyDevice ataId = identify.Value;
|
||||
|
||||
ataId.WWN = DescrambleWWN(ataId.WWN);
|
||||
ataId.WWNExtension = DescrambleWWN(ataId.WWNExtension);
|
||||
|
||||
byte[] buf = new byte[512];
|
||||
nint ptr = System.Runtime.InteropServices.Marshal.AllocHGlobal(512);
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(ataId, ptr, false);
|
||||
System.Runtime.InteropServices.Marshal.Copy(ptr, buf, 0, 512);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(ptr);
|
||||
|
||||
byte[] str = ScrambleATAString(ataId.SerialNumber, 20);
|
||||
Array.Copy(str, 0, buf, 10 * 2, 20);
|
||||
str = ScrambleATAString(ataId.FirmwareRevision, 8);
|
||||
Array.Copy(str, 0, buf, 23 * 2, 8);
|
||||
str = ScrambleATAString(ataId.Model, 40);
|
||||
Array.Copy(str, 0, buf, 27 * 2, 40);
|
||||
str = ScrambleATAString(ataId.AdditionalPID, 8);
|
||||
Array.Copy(str, 0, buf, 170 * 2, 8);
|
||||
str = ScrambleATAString(ataId.MediaSerial, 40);
|
||||
Array.Copy(str, 0, buf, 176 * 2, 40);
|
||||
str = ScrambleATAString(ataId.MediaManufacturer, 20);
|
||||
Array.Copy(str, 0, buf, 196 * 2, 20);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static ulong DescrambleWWN(ulong WWN)
|
||||
{
|
||||
byte[] qwb = BitConverter.GetBytes(WWN);
|
||||
byte[] qword = new byte[8];
|
||||
|
||||
qword[7] = qwb[1];
|
||||
qword[6] = qwb[0];
|
||||
qword[5] = qwb[3];
|
||||
qword[4] = qwb[2];
|
||||
qword[3] = qwb[5];
|
||||
qword[2] = qwb[4];
|
||||
qword[1] = qwb[7];
|
||||
qword[0] = qwb[6];
|
||||
|
||||
return BitConverter.ToUInt64(qword, 0);
|
||||
}
|
||||
|
||||
static string DescrambleATAString(IList<byte> buffer, int offset, int length)
|
||||
{
|
||||
byte[] outbuf = buffer[offset + length - 1] != 0x00 ? new byte[length + 1] : new byte[length];
|
||||
|
||||
for(int i = 0; i < length; i += 2)
|
||||
{
|
||||
outbuf[i] = buffer[offset + i + 1];
|
||||
outbuf[i + 1] = buffer[offset + i];
|
||||
}
|
||||
|
||||
string outStr = StringHandlers.CToString(outbuf);
|
||||
|
||||
return outStr.Trim();
|
||||
}
|
||||
|
||||
static byte[] ScrambleATAString(string str, int length)
|
||||
{
|
||||
byte[] buf = new byte[length];
|
||||
|
||||
for(int i = 0; i < length; i++)
|
||||
buf[i] = 0x20;
|
||||
|
||||
if(str is null)
|
||||
return buf;
|
||||
|
||||
byte[] bytes = Encoding.ASCII.GetBytes(str);
|
||||
|
||||
if(bytes.Length % 2 != 0)
|
||||
{
|
||||
byte[] tmp = new byte[bytes.Length + 1];
|
||||
tmp[^1] = 0x20;
|
||||
Array.Copy(bytes, 0, tmp, 0, bytes.Length);
|
||||
bytes = tmp;
|
||||
}
|
||||
|
||||
for(int i = 0; i < bytes.Length; i += 2)
|
||||
{
|
||||
buf[i] = bytes[i + 1];
|
||||
buf[i + 1] = bytes[i];
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -47,8 +47,9 @@ namespace Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||
/// 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")]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public struct Inquiry
|
||||
{
|
||||
const string MODULE_NAME = "SCSI INQUIRY decoder";
|
||||
@@ -149,7 +150,8 @@ public struct Inquiry
|
||||
|
||||
// Per DLT4000/DLT4500/DLT4700 Cartridge Tape Subsystem Product Manual
|
||||
|
||||
#region Quantum vendor unique inquiry data structure
|
||||
#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>
|
||||
@@ -188,9 +190,11 @@ public struct Inquiry
|
||||
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
|
||||
#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>
|
||||
@@ -199,9 +203,11 @@ public struct Inquiry
|
||||
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
|
||||
#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>
|
||||
@@ -210,9 +216,11 @@ public struct Inquiry
|
||||
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
|
||||
#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>
|
||||
@@ -225,9 +233,11 @@ public struct Inquiry
|
||||
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
|
||||
#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>
|
||||
@@ -236,23 +246,28 @@ public struct Inquiry
|
||||
public byte KreonSpace;
|
||||
/// <summary>Kreon version string Bytes 42 to 46</summary>
|
||||
public byte[] KreonVersion;
|
||||
#endregion Kreon vendor unique inquiry data structure
|
||||
|
||||
#region Sony Hi-MD data
|
||||
#endregion Kreon vendor unique inquiry data structure
|
||||
|
||||
#region Sony Hi-MD data
|
||||
|
||||
/// <summary>Set if Hi-MD signature is present</summary>
|
||||
public bool IsHiMD;
|
||||
/// <summary>Hi-MD signature, bytes 36 to 44</summary>
|
||||
public byte[] HiMDSignature;
|
||||
/// <summary>Unknown data, bytes 44 to 55</summary>
|
||||
public byte[] HiMDSpecific;
|
||||
#endregion Sony Hi-MD data
|
||||
|
||||
#endregion Sony Hi-MD data
|
||||
|
||||
static readonly byte[] HiMDSignatureContents = "Hi-MD "u8.ToArray();
|
||||
|
||||
/// <summary>Decodes a SCSI INQUIRY response</summary>
|
||||
/// <param name="SCSIInquiryResponse">INQUIRY raw response data</param>
|
||||
/// <returns>Decoded SCSI INQUIRY</returns>
|
||||
#region Public methods
|
||||
|
||||
#region Public methods
|
||||
|
||||
public static Inquiry? Decode(byte[] SCSIInquiryResponse)
|
||||
{
|
||||
if(SCSIInquiryResponse == null)
|
||||
@@ -465,8 +480,8 @@ public struct Inquiry
|
||||
|
||||
decoded.VersionDescriptors = new ushort[descriptorsNo];
|
||||
|
||||
for(int i = 0; i < descriptorsNo; i++)
|
||||
decoded.VersionDescriptors[i] = BitConverter.ToUInt16(SCSIInquiryResponse, 58 + (i * 2));
|
||||
for(var i = 0; i < descriptorsNo; i++)
|
||||
decoded.VersionDescriptors[i] = BitConverter.ToUInt16(SCSIInquiryResponse, 58 + i * 2);
|
||||
}
|
||||
|
||||
switch(SCSIInquiryResponse.Length)
|
||||
@@ -518,8 +533,8 @@ public struct Inquiry
|
||||
|
||||
Inquiry decoded = inq.Value;
|
||||
|
||||
byte[] buffer = new byte[512];
|
||||
byte length = 0;
|
||||
var buffer = new byte[512];
|
||||
byte length = 0;
|
||||
|
||||
buffer[0] = (byte)(decoded.PeripheralQualifier << 5);
|
||||
buffer[0] += decoded.PeripheralDeviceType;
|
||||
@@ -682,7 +697,7 @@ public struct Inquiry
|
||||
Array.Copy(decoded.Seagate_DriveSerialNumber, 0, buffer, 36, 8);
|
||||
}
|
||||
|
||||
if(decoded is { KreonIdentifier: {}, KreonVersion: {} })
|
||||
if(decoded is { KreonIdentifier: not null, KreonVersion: not null })
|
||||
{
|
||||
length = 46;
|
||||
Array.Copy(decoded.KreonIdentifier, 0, buffer, 36, 5);
|
||||
@@ -712,7 +727,7 @@ public struct Inquiry
|
||||
Array.Copy(decoded.HiMDSpecific, 0, buffer, 44, 12);
|
||||
}
|
||||
|
||||
if(decoded is { VendorSpecific: {}, IsHiMD: false })
|
||||
if(decoded is { VendorSpecific: not null, IsHiMD: false })
|
||||
{
|
||||
length = 56;
|
||||
Array.Copy(decoded.VendorSpecific, 0, buffer, 36, 20);
|
||||
@@ -742,10 +757,10 @@ public struct Inquiry
|
||||
|
||||
if(decoded.VersionDescriptors != null)
|
||||
{
|
||||
length = (byte)(58 + (decoded.VersionDescriptors.Length * 2));
|
||||
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);
|
||||
for(var i = 0; i < decoded.VersionDescriptors.Length; i++)
|
||||
Array.Copy(BitConverter.GetBytes(decoded.VersionDescriptors[i]), 0, buffer, 56 + i * 2, 2);
|
||||
}
|
||||
|
||||
if(decoded.Reserved5 != null)
|
||||
@@ -773,10 +788,11 @@ public struct Inquiry
|
||||
}
|
||||
|
||||
buffer[4] = length;
|
||||
byte[] dest = new byte[length];
|
||||
var dest = new byte[length];
|
||||
Array.Copy(buffer, 0, dest, 0, length);
|
||||
|
||||
return dest;
|
||||
}
|
||||
#endregion Public methods
|
||||
|
||||
#endregion Public methods
|
||||
}
|
||||
@@ -38,89 +38,128 @@ using System.Text.Json.Serialization;
|
||||
namespace Aaru.CommonTypes.Structs.Devices.SCSI.Modes;
|
||||
|
||||
#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>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
|
||||
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
|
||||
public class ModePage_2A
|
||||
{
|
||||
/// <summary>Write speed performance descriptors</summary>
|
||||
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; }
|
||||
|
||||
/// <summary>Can read packet media</summary>
|
||||
public bool Method2 { get; set; }
|
||||
|
||||
/// <summary>Can read CD-RW</summary>
|
||||
public bool ReadCDRW { get; set; }
|
||||
|
||||
/// <summary>Can read CD-R</summary>
|
||||
public bool ReadCDR { get; set; }
|
||||
|
||||
/// <summary>Can write CD-RW</summary>
|
||||
public bool WriteCDRW { get; set; }
|
||||
|
||||
/// <summary>Can write CD-R</summary>
|
||||
public bool WriteCDR { get; set; }
|
||||
|
||||
/// <summary>Supports IEC-958 digital output on port 2</summary>
|
||||
public bool DigitalPort2 { get; set; }
|
||||
|
||||
/// <summary>Supports IEC-958 digital output on port 1</summary>
|
||||
public bool DigitalPort1 { get; set; }
|
||||
|
||||
/// <summary>Can deliver a composite audio and video data stream</summary>
|
||||
public bool Composite { get; set; }
|
||||
|
||||
/// <summary>This bit controls the behavior of the LOAD/UNLOAD command when trying to load a Slot with no Disc present</summary>
|
||||
public bool SSS { get; set; }
|
||||
|
||||
/// <summary>Contains a changer that can report the exact contents of the slots</summary>
|
||||
public bool SDP { get; set; }
|
||||
|
||||
/// <summary>Page length</summary>
|
||||
public byte Length { get; set; }
|
||||
|
||||
/// <summary>Set if LSB comes first</summary>
|
||||
public bool LSBF { get; set; }
|
||||
|
||||
/// <summary>Set if HIGH on LRCK indicates left channel. Clear if HIGH on LRCK indicates right channel.</summary>
|
||||
public bool RCK { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Set if data valid on the falling edge of the BCK signal. Clear if data valid on the rising edge of the BCK
|
||||
/// signal
|
||||
@@ -129,37 +168,52 @@ public class ModePage_2A
|
||||
|
||||
/// <summary>Can do a test write</summary>
|
||||
public bool TestWrite { get; set; }
|
||||
|
||||
/// <summary>Maximum write speed</summary>
|
||||
public ushort MaxWriteSpeed { get; set; }
|
||||
|
||||
/// <summary>Current write speed</summary>
|
||||
public ushort CurrentWriteSpeed { get; set; }
|
||||
|
||||
/// <summary>Can read disc's barcode</summary>
|
||||
public bool ReadBarcode { get; set; }
|
||||
|
||||
/// <summary>Can read DVD-RAM</summary>
|
||||
public bool ReadDVDRAM { get; set; }
|
||||
|
||||
/// <summary>Can read DVD-R</summary>
|
||||
public bool ReadDVDR { get; set; }
|
||||
|
||||
/// <summary>Can read DVD-ROM</summary>
|
||||
public bool ReadDVDROM { get; set; }
|
||||
|
||||
/// <summary>Can write DVD-RAM</summary>
|
||||
public bool WriteDVDRAM { get; set; }
|
||||
|
||||
/// <summary>Can write DVD-R</summary>
|
||||
public bool WriteDVDR { get; set; }
|
||||
|
||||
/// <summary>Can read raw R-W subchannel from the Lead-In</summary>
|
||||
public bool LeadInPW { get; set; }
|
||||
|
||||
/// <summary>Can read both sides of a disc</summary>
|
||||
public bool SCC { get; set; }
|
||||
|
||||
/// <summary>Support copyright management</summary>
|
||||
public ushort CMRSupported { get; set; }
|
||||
|
||||
/// <summary>Supports buffer under-run free recording</summary>
|
||||
public bool BUF { get; set; }
|
||||
|
||||
/// <summary>Selected rotational control</summary>
|
||||
public byte RotationControlSelected { get; set; }
|
||||
|
||||
/// <summary>Current write speed selected</summary>
|
||||
public ushort CurrentWriteSpeedSelected { get; set; }
|
||||
|
||||
/// <summary>Database ID</summary>
|
||||
[JsonIgnore, Key]
|
||||
[JsonIgnore]
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>Decodes the page 2Ah of a MODE SENSE response</summary>
|
||||
@@ -263,15 +317,17 @@ public class ModePage_2A
|
||||
decoded.RotationControlSelected = (byte)(pageResponse[27] & 0x03);
|
||||
decoded.CurrentWriteSpeedSelected = (ushort)((pageResponse[28] << 8) + pageResponse[29]);
|
||||
|
||||
ushort descriptors = (ushort)((pageResponse.Length - 32) / 4);
|
||||
var descriptors = (ushort)((pageResponse.Length - 32) / 4);
|
||||
decoded.WriteSpeedPerformanceDescriptors = new ModePage_2A_WriteDescriptor[descriptors];
|
||||
|
||||
for(int i = 0; i < descriptors; i++)
|
||||
for(var 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)])
|
||||
RotationControl = (byte)(pageResponse[1 + 32 + i * 4] & 0x07),
|
||||
WriteSpeed = (ushort)((pageResponse[2 + 32 + i * 4] << 8) + pageResponse[3 + 32 + i * 4])
|
||||
};
|
||||
}
|
||||
|
||||
return decoded;
|
||||
}
|
||||
@@ -281,8 +337,8 @@ public class ModePage_2A
|
||||
/// <returns>Raw page 2Ah</returns>
|
||||
public static byte[] Encode(ModePage_2A decoded)
|
||||
{
|
||||
byte[] pageResponse = new byte[512];
|
||||
byte length = 16;
|
||||
var pageResponse = new byte[512];
|
||||
byte length = 16;
|
||||
|
||||
pageResponse[0] = 0x2A;
|
||||
|
||||
@@ -480,20 +536,20 @@ public class ModePage_2A
|
||||
{
|
||||
length = 32;
|
||||
|
||||
for(int i = 0; i < decoded.WriteSpeedPerformanceDescriptors.Length; i++)
|
||||
for(var i = 0; i < decoded.WriteSpeedPerformanceDescriptors.Length; i++)
|
||||
{
|
||||
length += 4;
|
||||
pageResponse[1 + 32 + (i * 4)] = decoded.WriteSpeedPerformanceDescriptors[i].RotationControl;
|
||||
length += 4;
|
||||
pageResponse[1 + 32 + i * 4] = decoded.WriteSpeedPerformanceDescriptors[i].RotationControl;
|
||||
|
||||
pageResponse[2 + 32 + (i * 4)] =
|
||||
pageResponse[2 + 32 + i * 4] =
|
||||
(byte)((decoded.WriteSpeedPerformanceDescriptors[i].WriteSpeed & 0xFF00) >> 8);
|
||||
|
||||
pageResponse[3 + 32 + (i * 4)] = (byte)(decoded.WriteSpeedPerformanceDescriptors[i].WriteSpeed & 0xFF);
|
||||
pageResponse[3 + 32 + i * 4] = (byte)(decoded.WriteSpeedPerformanceDescriptors[i].WriteSpeed & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
pageResponse[1] = (byte)(length - 2);
|
||||
byte[] buf = new byte[length];
|
||||
var buf = new byte[length];
|
||||
Array.Copy(pageResponse, 0, buf, 0, length);
|
||||
|
||||
return buf;
|
||||
@@ -509,4 +565,5 @@ public struct ModePage_2A_WriteDescriptor
|
||||
/// <summary>Write speed</summary>
|
||||
public ushort WriteSpeed;
|
||||
}
|
||||
|
||||
#endregion Mode Page 0x2A: CD-ROM capabilities page
|
||||
Reference in New Issue
Block a user