Code cleanup.

This commit is contained in:
2020-07-20 04:34:15 +01:00
parent a941b26dc9
commit 5d161c998d
36 changed files with 387 additions and 298 deletions

View File

@@ -79,7 +79,8 @@ namespace Aaru.Decoders.SecureDigital
var cid = new CID
{
Manufacturer = response[0], ProductRevision = response[8],
Manufacturer = response[0],
ProductRevision = response[8],
ProductSerialNumber = BitConverter.ToUInt32(response, 9),
ManufacturingDate = (ushort)(((response[13] & 0x0F) << 4) + response[14]),
CRC = (byte)((response[15] & 0xFE) >> 1)
@@ -113,8 +114,7 @@ namespace Aaru.Decoders.SecureDigital
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();
(cid.ManufacturingDate & 0xFF) + 2000).AppendLine();
sb.AppendFormat("\tCID CRC: 0x{0:X2}", cid.CRC).AppendLine();

View File

@@ -100,15 +100,17 @@ namespace Aaru.Decoders.SecureDigital
var csd = new CSD
{
Structure = (byte)((response[0] & 0xC0) >> 6), TAAC = response[1],
Structure = (byte)((response[0] & 0xC0) >> 6),
TAAC = response[1],
NSAC = response[2],
Speed = response[3],
Classes = (ushort)((response[4] << 4) + ((response[5] & 0xF0) >> 4)),
ReadBlockLength = (byte)(response[5] & 0x0F), ReadsPartialBlocks = (response[6] & 0x80) == 0x80,
WriteMisalignment = (response[6] & 0x40) == 0x40,
ReadMisalignment = (response[6] & 0x20) == 0x20,
DSRImplemented = (response[6] & 0x10) == 0x10,
EraseBlockEnable = (response[10] & 0x40) == 0x40,
ReadBlockLength = (byte)(response[5] & 0x0F),
ReadsPartialBlocks = (response[6] & 0x80) == 0x80,
WriteMisalignment = (response[6] & 0x40) == 0x40,
ReadMisalignment = (response[6] & 0x20) == 0x20,
DSRImplemented = (response[6] & 0x10) == 0x10,
EraseBlockEnable = (response[10] & 0x40) == 0x40,
EraseSectorSize = (byte)(((response[10] & 0x3F) << 1) + ((response[11] & 0x80) >> 7)),
WriteProtectGroupSize = (byte)(response[11] & 0x7F),
WriteProtectGroupEnable = (response[12] & 0x80) == 0x80,
@@ -120,8 +122,7 @@ namespace Aaru.Decoders.SecureDigital
PermanentWriteProtect = (response[14] & 0x20) == 0x20,
TemporaryWriteProtect = (response[14] & 0x10) == 0x10,
FileFormat = (byte)((response[14] & 0x0C) >> 2),
CRC =
(byte)((response[15] & 0xFE) >> 1)
CRC = (byte)((response[15] & 0xFE) >> 1)
};
if(csd.Structure == 0)

View File

@@ -62,13 +62,20 @@ namespace Aaru.Decoders.SecureDigital
{
public static OCR DecodeOCR(uint response) => 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
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
};
public static OCR DecodeOCR(byte[] response) =>

View File

@@ -78,15 +78,17 @@ namespace Aaru.Decoders.SecureDigital
var scr = new SCR
{
Structure = (byte)((response[0] & 0xF0) >> 4), Spec = (byte)(response[0] & 0x0F),
DataStatusAfterErase = (response[1] & 0x80) == 0x80,
Structure = (byte)((response[0] & 0xF0) >> 4),
Spec = (byte)(response[0] & 0x0F),
DataStatusAfterErase = (response[1] & 0x80) == 0x80,
Security = (byte)((response[1] & 0x70) >> 4),
BusWidth = (byte)(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 = (byte)(response[3] & 0x0F), ManufacturerReserved = new byte[4]
CommandSupport = (byte)(response[3] & 0x0F),
ManufacturerReserved = new byte[4]
};
Array.Copy(response, 4, scr.ManufacturerReserved, 0, 4);