Move to file scoped namespaces.

This commit is contained in:
2022-03-06 13:29:37 +00:00
parent c7178d94c6
commit 3b6091c02c
119 changed files with 38048 additions and 38172 deletions

View File

@@ -35,95 +35,94 @@ using System.Diagnostics.CodeAnalysis;
using System.Text;
using Aaru.Helpers;
namespace Aaru.Decoders.SecureDigital
namespace Aaru.Decoders.SecureDigital;
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public class CID
{
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public class CID
public string ApplicationID;
public byte CRC;
public byte Manufacturer;
public ushort ManufacturingDate;
public string ProductName;
public byte ProductRevision;
public uint ProductSerialNumber;
}
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public static partial class Decoders
{
public static CID DecodeCID(uint[] response)
{
public string ApplicationID;
public byte CRC;
public byte Manufacturer;
public ushort ManufacturingDate;
public string ProductName;
public byte ProductRevision;
public uint ProductSerialNumber;
if(response?.Length != 4)
return null;
byte[] data = new byte[16];
byte[] tmp = BitConverter.GetBytes(response[0]);
Array.Copy(tmp, 0, data, 0, 4);
tmp = BitConverter.GetBytes(response[1]);
Array.Copy(tmp, 0, data, 4, 4);
tmp = BitConverter.GetBytes(response[2]);
Array.Copy(tmp, 0, data, 8, 4);
tmp = BitConverter.GetBytes(response[3]);
Array.Copy(tmp, 0, data, 12, 4);
return DecodeCID(data);
}
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public static partial class Decoders
public static CID DecodeCID(byte[] response)
{
public static CID DecodeCID(uint[] response)
if(response?.Length != 16)
return null;
var cid = new CID
{
if(response?.Length != 4)
return null;
Manufacturer = response[0],
ProductRevision = response[8],
ProductSerialNumber = Swapping.Swap(BitConverter.ToUInt32(response, 9)),
ManufacturingDate = (ushort)(((response[13] & 0x0F) << 8) + response[14]),
CRC = (byte)((response[15] & 0xFE) >> 1)
};
byte[] data = new byte[16];
byte[] tmp = new byte[2];
Array.Copy(response, 1, tmp, 0, 2);
cid.ApplicationID = StringHandlers.CToString(tmp);
tmp = new byte[5];
Array.Copy(response, 3, tmp, 0, 5);
cid.ProductName = StringHandlers.CToString(tmp);
byte[] tmp = BitConverter.GetBytes(response[0]);
Array.Copy(tmp, 0, data, 0, 4);
tmp = BitConverter.GetBytes(response[1]);
Array.Copy(tmp, 0, data, 4, 4);
tmp = BitConverter.GetBytes(response[2]);
Array.Copy(tmp, 0, data, 8, 4);
tmp = BitConverter.GetBytes(response[3]);
Array.Copy(tmp, 0, data, 12, 4);
return DecodeCID(data);
}
public static CID DecodeCID(byte[] response)
{
if(response?.Length != 16)
return null;
var cid = new CID
{
Manufacturer = response[0],
ProductRevision = response[8],
ProductSerialNumber = Swapping.Swap(BitConverter.ToUInt32(response, 9)),
ManufacturingDate = (ushort)(((response[13] & 0x0F) << 8) + response[14]),
CRC = (byte)((response[15] & 0xFE) >> 1)
};
byte[] tmp = new byte[2];
Array.Copy(response, 1, tmp, 0, 2);
cid.ApplicationID = StringHandlers.CToString(tmp);
tmp = new byte[5];
Array.Copy(response, 3, tmp, 0, 5);
cid.ProductName = StringHandlers.CToString(tmp);
return cid;
}
public static string PrettifyCID(CID cid)
{
if(cid == null)
return null;
var sb = new StringBuilder();
sb.AppendLine("SecureDigital Device Identification Register:");
sb.AppendFormat("\tManufacturer: {0}", VendorString.Prettify(cid.Manufacturer)).AppendLine();
sb.AppendFormat("\tApplication ID: {0}", cid.ApplicationID).AppendLine();
sb.AppendFormat("\tProduct name: {0}", cid.ProductName).AppendLine();
sb.AppendFormat("\tProduct revision: {0:X2}.{1:X2}", (cid.ProductRevision & 0xF0) >> 4,
cid.ProductRevision & 0x0F).AppendLine();
sb.AppendFormat("\tProduct serial number: {0}", cid.ProductSerialNumber).AppendLine();
sb.AppendFormat("\tDevice manufactured month {0} of {1}", (cid.ManufacturingDate & 0xF00) >> 8,
(cid.ManufacturingDate & 0xFF) + 2000).AppendLine();
sb.AppendFormat("\tCID CRC: 0x{0:X2}", cid.CRC).AppendLine();
return sb.ToString();
}
public static string PrettifyCID(uint[] response) => PrettifyCID(DecodeCID(response));
public static string PrettifyCID(byte[] response) => PrettifyCID(DecodeCID(response));
return cid;
}
public static string PrettifyCID(CID cid)
{
if(cid == null)
return null;
var sb = new StringBuilder();
sb.AppendLine("SecureDigital Device Identification Register:");
sb.AppendFormat("\tManufacturer: {0}", VendorString.Prettify(cid.Manufacturer)).AppendLine();
sb.AppendFormat("\tApplication ID: {0}", cid.ApplicationID).AppendLine();
sb.AppendFormat("\tProduct name: {0}", cid.ProductName).AppendLine();
sb.AppendFormat("\tProduct revision: {0:X2}.{1:X2}", (cid.ProductRevision & 0xF0) >> 4,
cid.ProductRevision & 0x0F).AppendLine();
sb.AppendFormat("\tProduct serial number: {0}", cid.ProductSerialNumber).AppendLine();
sb.AppendFormat("\tDevice manufactured month {0} of {1}", (cid.ManufacturingDate & 0xF00) >> 8,
(cid.ManufacturingDate & 0xFF) + 2000).AppendLine();
sb.AppendFormat("\tCID CRC: 0x{0:X2}", cid.CRC).AppendLine();
return sb.ToString();
}
public static string PrettifyCID(uint[] response) => PrettifyCID(DecodeCID(response));
public static string PrettifyCID(byte[] response) => PrettifyCID(DecodeCID(response));
}

File diff suppressed because it is too large Load Diff

View File

@@ -35,110 +35,109 @@ using System.Diagnostics.CodeAnalysis;
using System.Text;
using Aaru.Helpers;
namespace Aaru.Decoders.SecureDigital
namespace Aaru.Decoders.SecureDigital;
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "UnassignedField.Global"),
SuppressMessage("ReSharper", "NotAccessedField.Global")]
public class OCR
{
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "UnassignedField.Global"),
SuppressMessage("ReSharper", "NotAccessedField.Global")]
public class OCR
public bool CCS;
public bool LowPower;
public bool OneEight;
public bool PowerUp;
public bool ThreeFive;
public bool ThreeFour;
public bool ThreeOne;
public bool ThreeThree;
public bool ThreeTwo;
public bool ThreeZero;
public bool TwoEight;
public bool TwoNine;
public bool TwoSeven;
public bool UHS;
}
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public static partial class Decoders
{
public static OCR DecodeOCR(uint response)
{
public bool CCS;
public bool LowPower;
public bool OneEight;
public bool PowerUp;
public bool ThreeFive;
public bool ThreeFour;
public bool ThreeOne;
public bool ThreeThree;
public bool ThreeTwo;
public bool ThreeZero;
public bool TwoEight;
public bool TwoNine;
public bool TwoSeven;
public bool UHS;
response = Swapping.Swap(response);
return new OCR
{
PowerUp = (response & 0x80000000) == 0x80000000,
CCS = (response & 0x40000000) == 0x40000000,
UHS = (response & 0x20000000) == 0x20000000,
OneEight = (response & 0x01000000) == 0x01000000,
ThreeFive = (response & 0x00800000) == 0x00800000,
ThreeFour = (response & 0x00400000) == 0x00400000,
ThreeThree = (response & 0x00200000) == 0x00200000,
ThreeTwo = (response & 0x00100000) == 0x00100000,
ThreeOne = (response & 0x00080000) == 0x00080000,
ThreeZero = (response & 0x00040000) == 0x00040000,
TwoNine = (response & 0x00020000) == 0x00020000,
TwoEight = (response & 0x00010000) == 0x00010000,
TwoSeven = (response & 0x00008000) == 0x00008000,
LowPower = (response & 0x00000080) == 0x00000080
};
}
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public static partial class Decoders
public static OCR DecodeOCR(byte[] response) =>
response?.Length != 4 ? null : DecodeOCR(BitConverter.ToUInt32(response, 0));
public static string PrettifyOCR(OCR ocr)
{
public static OCR DecodeOCR(uint response)
{
response = Swapping.Swap(response);
if(ocr == null)
return null;
return new OCR
{
PowerUp = (response & 0x80000000) == 0x80000000,
CCS = (response & 0x40000000) == 0x40000000,
UHS = (response & 0x20000000) == 0x20000000,
OneEight = (response & 0x01000000) == 0x01000000,
ThreeFive = (response & 0x00800000) == 0x00800000,
ThreeFour = (response & 0x00400000) == 0x00400000,
ThreeThree = (response & 0x00200000) == 0x00200000,
ThreeTwo = (response & 0x00100000) == 0x00100000,
ThreeOne = (response & 0x00080000) == 0x00080000,
ThreeZero = (response & 0x00040000) == 0x00040000,
TwoNine = (response & 0x00020000) == 0x00020000,
TwoEight = (response & 0x00010000) == 0x00010000,
TwoSeven = (response & 0x00008000) == 0x00008000,
LowPower = (response & 0x00000080) == 0x00000080
};
}
var sb = new StringBuilder();
sb.AppendLine("SecureDigital Operation Conditions Register:");
public static OCR DecodeOCR(byte[] response) =>
response?.Length != 4 ? null : DecodeOCR(BitConverter.ToUInt32(response, 0));
if(!ocr.PowerUp)
sb.AppendLine("\tDevice is powering up");
public static string PrettifyOCR(OCR ocr)
{
if(ocr == null)
return null;
if(ocr.CCS)
sb.AppendLine("\tDevice is SDHC, SDXC or higher");
var sb = new StringBuilder();
sb.AppendLine("SecureDigital Operation Conditions Register:");
if(ocr.UHS)
sb.AppendLine("\tDevice is UHS-II or higher");
if(!ocr.PowerUp)
sb.AppendLine("\tDevice is powering up");
if(ocr.ThreeFive)
sb.AppendLine("\tDevice can work with supply 3.5~3.6V");
if(ocr.CCS)
sb.AppendLine("\tDevice is SDHC, SDXC or higher");
if(ocr.ThreeFour)
sb.AppendLine("\tDevice can work with supply 3.4~3.5V");
if(ocr.UHS)
sb.AppendLine("\tDevice is UHS-II or higher");
if(ocr.ThreeThree)
sb.AppendLine("\tDevice can work with supply 3.3~3.4V");
if(ocr.ThreeFive)
sb.AppendLine("\tDevice can work with supply 3.5~3.6V");
if(ocr.ThreeTwo)
sb.AppendLine("\tDevice can work with supply 3.2~3.3V");
if(ocr.ThreeFour)
sb.AppendLine("\tDevice can work with supply 3.4~3.5V");
if(ocr.ThreeOne)
sb.AppendLine("\tDevice can work with supply 3.1~3.2V");
if(ocr.ThreeThree)
sb.AppendLine("\tDevice can work with supply 3.3~3.4V");
if(ocr.TwoNine)
sb.AppendLine("\tDevice can work with supply 2.9~3.0V");
if(ocr.ThreeTwo)
sb.AppendLine("\tDevice can work with supply 3.2~3.3V");
if(ocr.TwoEight)
sb.AppendLine("\tDevice can work with supply 2.8~2.9V");
if(ocr.ThreeOne)
sb.AppendLine("\tDevice can work with supply 3.1~3.2V");
if(ocr.TwoSeven)
sb.AppendLine("\tDevice can work with supply 2.7~2.8V");
if(ocr.TwoNine)
sb.AppendLine("\tDevice can work with supply 2.9~3.0V");
if(ocr.OneEight)
sb.AppendLine("\tDevice can switch to work with 1.8V supply");
if(ocr.TwoEight)
sb.AppendLine("\tDevice can work with supply 2.8~2.9V");
if(ocr.LowPower)
sb.AppendLine("\tDevice is in low power mode");
if(ocr.TwoSeven)
sb.AppendLine("\tDevice can work with supply 2.7~2.8V");
if(ocr.OneEight)
sb.AppendLine("\tDevice can switch to work with 1.8V supply");
if(ocr.LowPower)
sb.AppendLine("\tDevice is in low power mode");
return sb.ToString();
}
public static string PrettifyOCR(byte[] response) => PrettifyOCR(DecodeOCR(response));
public static string PrettifyOCR(uint response) => PrettifyOCR(DecodeOCR(response));
return sb.ToString();
}
public static string PrettifyOCR(byte[] response) => PrettifyOCR(DecodeOCR(response));
public static string PrettifyOCR(uint response) => PrettifyOCR(DecodeOCR(response));
}

View File

@@ -34,199 +34,198 @@ using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;
namespace Aaru.Decoders.SecureDigital
namespace Aaru.Decoders.SecureDigital;
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
public class SCR
{
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
public class SCR
public BusWidth BusWidth;
public CommandSupport CommandSupport;
public bool DataStatusAfterErase;
public byte ExtendedSecurity;
public byte[] ManufacturerReserved;
public byte Security;
public byte Spec;
public bool Spec3;
public bool Spec4;
public byte SpecX;
public byte Structure;
}
[Flags]
public enum BusWidth : byte
{
OneBit = 1 << 0, FourBit = 1 << 2
}
[Flags]
public enum CommandSupport : byte
{
SpeedClassControl = 1 << 0, SetBlockCount = 1 << 1, ExtensionRegisterSingleBlock = 1 << 2,
ExtensionRegisterMultiBlock = 1 << 3
}
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "InconsistentNaming")]
public static partial class Decoders
{
public static SCR DecodeSCR(uint[] response)
{
public BusWidth BusWidth;
public CommandSupport CommandSupport;
public bool DataStatusAfterErase;
public byte ExtendedSecurity;
public byte[] ManufacturerReserved;
public byte Security;
public byte Spec;
public bool Spec3;
public bool Spec4;
public byte SpecX;
public byte Structure;
if(response?.Length != 2)
return null;
byte[] data = new byte[8];
byte[] tmp = BitConverter.GetBytes(response[0]);
Array.Copy(tmp, 0, data, 0, 4);
tmp = BitConverter.GetBytes(response[1]);
Array.Copy(tmp, 0, data, 4, 4);
return DecodeSCR(data);
}
[Flags]
public enum BusWidth : byte
public static SCR DecodeSCR(byte[] response)
{
OneBit = 1 << 0, FourBit = 1 << 2
}
if(response?.Length != 8)
return null;
[Flags]
public enum CommandSupport : byte
{
SpeedClassControl = 1 << 0, SetBlockCount = 1 << 1, ExtensionRegisterSingleBlock = 1 << 2,
ExtensionRegisterMultiBlock = 1 << 3
}
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "InconsistentNaming")]
public static partial class Decoders
{
public static SCR DecodeSCR(uint[] response)
var scr = new SCR
{
if(response?.Length != 2)
return null;
Structure = (byte)((response[0] & 0xF0) >> 4),
Spec = (byte)(response[0] & 0x0F),
DataStatusAfterErase = (response[1] & 0x80) == 0x80,
Security = (byte)((response[1] & 0x70) >> 4),
BusWidth = (BusWidth)(response[1] & 0x0F),
Spec3 = (response[2] & 0x80) == 0x80,
ExtendedSecurity = (byte)((response[2] & 0x78) >> 3),
Spec4 = (response[2] & 0x04) == 0x04,
SpecX = (byte)(((response[2] & 0x03) << 2) + ((response[3] & 0xC0) >> 6)),
CommandSupport = (CommandSupport)(response[3] & 0x0F),
ManufacturerReserved = new byte[4]
};
byte[] data = new byte[8];
Array.Copy(response, 4, scr.ManufacturerReserved, 0, 4);
byte[] tmp = BitConverter.GetBytes(response[0]);
Array.Copy(tmp, 0, data, 0, 4);
tmp = BitConverter.GetBytes(response[1]);
Array.Copy(tmp, 0, data, 4, 4);
return scr;
}
return DecodeSCR(data);
public static string PrettifySCR(SCR scr)
{
if(scr == null)
return null;
var sb = new StringBuilder();
sb.AppendLine("SecureDigital Device Configuration Register:");
if(scr.Structure != 0)
sb.AppendFormat("\tUnknown register version {0}", scr.Structure).AppendLine();
switch(scr.Spec)
{
case 0 when scr.Spec3 == false && scr.Spec4 == false && scr.SpecX == 0:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 1.0x");
break;
case 1 when scr.Spec3 == false && scr.Spec4 == false && scr.SpecX == 0:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 1.10");
break;
case 2 when scr.Spec3 == false && scr.Spec4 == false && scr.SpecX == 0:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 2.00");
break;
case 2 when scr.Spec3 && scr.Spec4 == false && scr.SpecX == 0:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 3.0x");
break;
case 2 when scr.Spec3 && scr.Spec4 && scr.SpecX == 0:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 4.xx");
break;
case 2 when scr.Spec3:
switch(scr.SpecX)
{
case 1:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 5.xx");
break;
case 2:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 6.xx");
break;
case 3:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 7.xx");
break;
case 4:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 8.xx");
break;
}
break;
default:
sb.
AppendFormat("\tDevice follows SecureDigital Physical Layer Specification with unknown version {0}.{1}.{2}.{3}",
scr.Spec, scr.Spec3, scr.Spec4, scr.SpecX).AppendLine();
break;
}
public static SCR DecodeSCR(byte[] response)
switch(scr.Security)
{
if(response?.Length != 8)
return null;
case 0:
sb.AppendLine("\tDevice does not support CPRM");
var scr = new SCR
{
Structure = (byte)((response[0] & 0xF0) >> 4),
Spec = (byte)(response[0] & 0x0F),
DataStatusAfterErase = (response[1] & 0x80) == 0x80,
Security = (byte)((response[1] & 0x70) >> 4),
BusWidth = (BusWidth)(response[1] & 0x0F),
Spec3 = (response[2] & 0x80) == 0x80,
ExtendedSecurity = (byte)((response[2] & 0x78) >> 3),
Spec4 = (response[2] & 0x04) == 0x04,
SpecX = (byte)(((response[2] & 0x03) << 2) + ((response[3] & 0xC0) >> 6)),
CommandSupport = (CommandSupport)(response[3] & 0x0F),
ManufacturerReserved = new byte[4]
};
break;
case 1:
sb.AppendLine("\tDevice does not use CPRM");
Array.Copy(response, 4, scr.ManufacturerReserved, 0, 4);
break;
case 2:
sb.AppendLine("\tDevice uses CPRM according to specification version 1.01");
return scr;
break;
case 3:
sb.AppendLine("\tDevice uses CPRM according to specification version 2.00");
break;
case 4:
sb.AppendLine("\tDevice uses CPRM according to specification version 3.xx");
break;
default:
sb.AppendFormat("\tDevice uses unknown CPRM specification with code {0}", scr.Security).
AppendLine();
break;
}
public static string PrettifySCR(SCR scr)
{
if(scr == null)
return null;
if(scr.BusWidth.HasFlag(BusWidth.OneBit))
sb.AppendLine("\tDevice supports 1-bit data bus");
var sb = new StringBuilder();
sb.AppendLine("SecureDigital Device Configuration Register:");
if(scr.BusWidth.HasFlag(BusWidth.FourBit))
sb.AppendLine("\tDevice supports 4-bit data bus");
if(scr.Structure != 0)
sb.AppendFormat("\tUnknown register version {0}", scr.Structure).AppendLine();
if(scr.ExtendedSecurity != 0)
sb.AppendLine("\tDevice supports extended security");
switch(scr.Spec)
{
case 0 when scr.Spec3 == false && scr.Spec4 == false && scr.SpecX == 0:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 1.0x");
if(scr.CommandSupport.HasFlag(CommandSupport.ExtensionRegisterMultiBlock))
sb.AppendLine("\tDevice supports extension register multi-block commands");
break;
case 1 when scr.Spec3 == false && scr.Spec4 == false && scr.SpecX == 0:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 1.10");
if(scr.CommandSupport.HasFlag(CommandSupport.ExtensionRegisterSingleBlock))
sb.AppendLine("\tDevice supports extension register single-block commands");
break;
case 2 when scr.Spec3 == false && scr.Spec4 == false && scr.SpecX == 0:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 2.00");
if(scr.CommandSupport.HasFlag(CommandSupport.SetBlockCount))
sb.AppendLine("\tDevice supports set block count command");
break;
case 2 when scr.Spec3 && scr.Spec4 == false && scr.SpecX == 0:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 3.0x");
if(scr.CommandSupport.HasFlag(CommandSupport.SpeedClassControl))
sb.AppendLine("\tDevice supports speed class control command");
break;
case 2 when scr.Spec3 && scr.Spec4 && scr.SpecX == 0:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 4.xx");
break;
case 2 when scr.Spec3:
switch(scr.SpecX)
{
case 1:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 5.xx");
break;
case 2:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 6.xx");
break;
case 3:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 7.xx");
break;
case 4:
sb.AppendLine("\tDevice follows SecureDigital Physical Layer Specification version 8.xx");
break;
}
break;
default:
sb.
AppendFormat("\tDevice follows SecureDigital Physical Layer Specification with unknown version {0}.{1}.{2}.{3}",
scr.Spec, scr.Spec3, scr.Spec4, scr.SpecX).AppendLine();
break;
}
switch(scr.Security)
{
case 0:
sb.AppendLine("\tDevice does not support CPRM");
break;
case 1:
sb.AppendLine("\tDevice does not use CPRM");
break;
case 2:
sb.AppendLine("\tDevice uses CPRM according to specification version 1.01");
break;
case 3:
sb.AppendLine("\tDevice uses CPRM according to specification version 2.00");
break;
case 4:
sb.AppendLine("\tDevice uses CPRM according to specification version 3.xx");
break;
default:
sb.AppendFormat("\tDevice uses unknown CPRM specification with code {0}", scr.Security).
AppendLine();
break;
}
if(scr.BusWidth.HasFlag(BusWidth.OneBit))
sb.AppendLine("\tDevice supports 1-bit data bus");
if(scr.BusWidth.HasFlag(BusWidth.FourBit))
sb.AppendLine("\tDevice supports 4-bit data bus");
if(scr.ExtendedSecurity != 0)
sb.AppendLine("\tDevice supports extended security");
if(scr.CommandSupport.HasFlag(CommandSupport.ExtensionRegisterMultiBlock))
sb.AppendLine("\tDevice supports extension register multi-block commands");
if(scr.CommandSupport.HasFlag(CommandSupport.ExtensionRegisterSingleBlock))
sb.AppendLine("\tDevice supports extension register single-block commands");
if(scr.CommandSupport.HasFlag(CommandSupport.SetBlockCount))
sb.AppendLine("\tDevice supports set block count command");
if(scr.CommandSupport.HasFlag(CommandSupport.SpeedClassControl))
sb.AppendLine("\tDevice supports speed class control command");
return sb.ToString();
}
public static string PrettifySCR(uint[] response) => PrettifySCR(DecodeSCR(response));
public static string PrettifySCR(byte[] response) => PrettifySCR(DecodeSCR(response));
return sb.ToString();
}
public static string PrettifySCR(uint[] response) => PrettifySCR(DecodeSCR(response));
public static string PrettifySCR(byte[] response) => PrettifySCR(DecodeSCR(response));
}

View File

@@ -30,22 +30,21 @@
// Copyright © 2011-2022 Natalia Portillo
// ****************************************************************************/
namespace Aaru.Decoders.SecureDigital
namespace Aaru.Decoders.SecureDigital;
/// <summary>Decodes SecureDigital vendors</summary>
public static class VendorString
{
/// <summary>Decodes SecureDigital vendors</summary>
public static class VendorString
/// <summary>Converts the byte value of a SecureDigital vendor ID to the manufacturer's name string</summary>
/// <param name="sdVendorId">SD vendor ID</param>
/// <returns>Manufacturer</returns>
public static string Prettify(byte sdVendorId) => sdVendorId switch
{
/// <summary>Converts the byte value of a SecureDigital vendor ID to the manufacturer's name string</summary>
/// <param name="sdVendorId">SD vendor ID</param>
/// <returns>Manufacturer</returns>
public static string Prettify(byte sdVendorId) => sdVendorId switch
{
0x41 => "Kingston",
0x02 => "Kingston",
0x03 => "Sandisk",
0x27 => "CnMemory",
0xAA => "QEMU",
_ => $"Unknown manufacturer ID 0x{sdVendorId:X2}"
};
}
0x41 => "Kingston",
0x02 => "Kingston",
0x03 => "Sandisk",
0x27 => "CnMemory",
0xAA => "QEMU",
_ => $"Unknown manufacturer ID 0x{sdVendorId:X2}"
};
}