[Aaru.Core] Reformat and cleanup.

This commit is contained in:
2023-10-03 22:57:50 +01:00
parent 57853b0d2a
commit af659f3fcb
85 changed files with 3303 additions and 1961 deletions

View File

@@ -46,7 +46,7 @@ public sealed partial class DeviceReport
/// <returns>Media report</returns>
public TestedMedia ReportAtaMedia()
{
bool sense = true;
var sense = true;
AtaErrorRegistersChs errorChs = new();
AtaErrorRegistersLba28 errorLba = new();
AtaErrorRegistersLba48 errorLba48 = new();
@@ -103,8 +103,10 @@ public sealed partial class DeviceReport
};
if(mediaTest.Blocks == 0)
{
mediaTest.Blocks =
(ulong)(ataId.CurrentCylinders * ataId.CurrentHeads * ataId.CurrentSectorsPerTrack);
}
}
if(ataId.Capabilities.HasFlag(Identify.CapabilitiesBit.LBASupport))
@@ -121,6 +123,7 @@ public sealed partial class DeviceReport
if(ataId.NominalRotationRate != 0x0000 &&
ataId.NominalRotationRate != 0xFFFF)
{
if(ataId.NominalRotationRate == 0x0001)
mediaTest.SolidStateDevice = true;
else
@@ -128,6 +131,7 @@ public sealed partial class DeviceReport
mediaTest.SolidStateDevice = false;
mediaTest.NominalRotationRate = ataId.NominalRotationRate;
}
}
uint logicalSectorSize;
uint physicalSectorSize;
@@ -136,16 +140,18 @@ public sealed partial class DeviceReport
(ataId.PhysLogSectorSize & 0x4000) == 0x4000)
{
if((ataId.PhysLogSectorSize & 0x1000) == 0x1000)
{
if(ataId.LogicalSectorWords <= 255 ||
ataId.LogicalAlignment == 0xFFFF)
logicalSectorSize = 512;
else
logicalSectorSize = ataId.LogicalSectorWords * 2;
}
else
logicalSectorSize = 512;
if((ataId.PhysLogSectorSize & 0x2000) == 0x2000)
physicalSectorSize = (uint)(logicalSectorSize * ((1 << ataId.PhysLogSectorSize) & 0xF));
physicalSectorSize = (uint)(logicalSectorSize * (1 << ataId.PhysLogSectorSize & 0xF));
else
physicalSectorSize = logicalSectorSize;
}
@@ -184,7 +190,7 @@ public sealed partial class DeviceReport
mediaTest.Manufacturer = ataId.MediaManufacturer;
}
ulong checkCorrectRead = BitConverter.ToUInt64(buffer, 0);
var checkCorrectRead = BitConverter.ToUInt64(buffer, 0);
Spectre.ProgressSingleSpinner(ctx =>
{
@@ -445,7 +451,7 @@ public sealed partial class DeviceReport
/// <summary>Creates a report of an ATA device</summary>
public TestedMedia ReportAta(Identify.IdentifyDevice ataId)
{
bool sense = true;
var sense = true;
byte[] readBuf = Array.Empty<byte>();
AtaErrorRegistersChs errorChs = new();
AtaErrorRegistersLba28 errorLba = new();
@@ -498,6 +504,7 @@ public sealed partial class DeviceReport
if(ataId.NominalRotationRate != 0x0000 &&
ataId.NominalRotationRate != 0xFFFF)
{
if(ataId.NominalRotationRate == 0x0001)
capabilities.SolidStateDevice = true;
else
@@ -505,6 +512,7 @@ public sealed partial class DeviceReport
capabilities.SolidStateDevice = false;
capabilities.NominalRotationRate = ataId.NominalRotationRate;
}
}
uint logicalSectorSize;
uint physicalSectorSize;
@@ -513,11 +521,13 @@ public sealed partial class DeviceReport
(ataId.PhysLogSectorSize & 0x4000) == 0x4000)
{
if((ataId.PhysLogSectorSize & 0x1000) == 0x1000)
{
if(ataId.LogicalSectorWords <= 255 ||
ataId.LogicalAlignment == 0xFFFF)
logicalSectorSize = 512;
else
logicalSectorSize = ataId.LogicalSectorWords * 2;
}
else
logicalSectorSize = 512;
@@ -819,9 +829,9 @@ public sealed partial class DeviceReport
/// <returns>IDENTIFY ATA DEVICE response without the private fields</returns>
public static byte[] ClearIdentify(byte[] buffer)
{
byte[] empty = new byte[512];
var empty = new byte[512];
Array.Copy(empty, 0, buffer, 20, 20);
Array.Copy(empty, 0, buffer, 20, 20);
Array.Copy(empty, 0, buffer, 216, 8);
Array.Copy(empty, 0, buffer, 224, 8);
Array.Copy(empty, 0, buffer, 352, 40);

View File

@@ -36,13 +36,12 @@ namespace Aaru.Core.Devices.Report;
public sealed partial class DeviceReport
{
const string GDROM_MODULE_NAME = "GD-ROM reporter";
const string ATA_MODULE_NAME = "ATA Report";
const string SCSI_MODULE_NAME = "SCSI Report";
readonly Device _dev;
/// <summary>Initializes a device report for the specified device (must be opened)</summary>
/// <param name="device">Device</param>
public DeviceReport(Device device) => _dev = device;
const string GDROM_MODULE_NAME = "GD-ROM reporter";
const string ATA_MODULE_NAME = "ATA Report";
const string SCSI_MODULE_NAME = "SCSI Report";
}

View File

@@ -81,7 +81,7 @@ public sealed partial class DeviceReport
AaruConsole.WriteLine(Localization.Core.Sending_READ_FULL_TOC_to_the_device);
int retries = 0;
var retries = 0;
bool sense;
byte[] buffer;
byte[] senseBuffer;
@@ -141,8 +141,8 @@ public sealed partial class DeviceReport
return;
}
int min = 0, sec, frame;
bool tocIsNotBcd = false;
int min = 0, sec, frame;
var tocIsNotBcd = false;
report.GdRomSwapDiscCapabilities.SwapDiscLeadOutPMIN = leadOutTrack.PMIN;
report.GdRomSwapDiscCapabilities.SwapDiscLeadOutPSEC = leadOutTrack.PSEC;
@@ -169,12 +169,12 @@ public sealed partial class DeviceReport
}
else
{
min += ((leadOutTrack.PMIN >> 4) * 10) + (leadOutTrack.PMIN & 0x0F);
sec = ((leadOutTrack.PSEC >> 4) * 10) + (leadOutTrack.PSEC & 0x0F);
frame = ((leadOutTrack.PFRAME >> 4) * 10) + (leadOutTrack.PFRAME & 0x0F);
min += (leadOutTrack.PMIN >> 4) * 10 + (leadOutTrack.PMIN & 0x0F);
sec = (leadOutTrack.PSEC >> 4) * 10 + (leadOutTrack.PSEC & 0x0F);
frame = (leadOutTrack.PFRAME >> 4) * 10 + (leadOutTrack.PFRAME & 0x0F);
}
int sectors = (min * 60 * 75) + (sec * 75) + frame - 150;
int sectors = min * 60 * 75 + sec * 75 + frame - 150;
AaruConsole.WriteLine(Localization.Core.Trap_disc_shows_0_sectors, sectors);
@@ -287,7 +287,8 @@ public sealed partial class DeviceReport
report.GdRomSwapDiscCapabilities.Lba0Sense = lba0Sense;
report.GdRomSwapDiscCapabilities.Lba0DecodedSense = Sense.PrettifySense(lba0Sense);
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba0Readable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba0Readable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_zero_as_audio_scrambled);
@@ -303,7 +304,8 @@ public sealed partial class DeviceReport
report.GdRomSwapDiscCapabilities.Lba0ScrambledSense = lba0ScrambledSense;
report.GdRomSwapDiscCapabilities.Lba0ScrambledDecodedSense = Sense.PrettifySense(lba0ScrambledSense);
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba0ScrambledReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba0ScrambledReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_100000_as_audio);
@@ -336,7 +338,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba100000AudioReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba100000AudioReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_50000_as_audio);
@@ -367,7 +370,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba50000AudioReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba50000AudioReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_450000_as_audio);
@@ -400,7 +404,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba450000AudioReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba450000AudioReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_400000_as_audio);
@@ -433,7 +438,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba400000AudioReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba400000AudioReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_45000_as_audio);
@@ -464,7 +470,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba45000AudioReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba45000AudioReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_44990_as_audio);
@@ -495,7 +502,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba44990AudioReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba44990AudioReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_100000_as_audio_with_PQ_subchannel);
@@ -529,7 +537,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba100000AudioPqReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba100000AudioPqReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_50000_as_audio_with_PQ_subchannel);
@@ -562,7 +571,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba50000AudioPqReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba50000AudioPqReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_450000_as_audio_with_PQ_subchannel);
@@ -596,7 +606,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba450000AudioPqReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba450000AudioPqReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_400000_as_audio_with_PQ_subchannel);
@@ -630,7 +641,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba400000AudioPqReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba400000AudioPqReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_45000_as_audio_with_PQ_subchannel);
@@ -663,7 +675,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba45000AudioPqReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba45000AudioPqReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_44990_as_audio_with_PQ_subchannel);
@@ -696,7 +709,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba44990AudioPqReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba44990AudioPqReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_100000_as_audio_with_RW_subchannel);
@@ -730,7 +744,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba100000AudioRwReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba100000AudioRwReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_50000_as_audio_with_RW_subchannel);
@@ -763,7 +778,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba50000AudioRwReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba50000AudioRwReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_450000_as_audio_with_RW_subchannel);
@@ -797,7 +813,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba450000AudioRwReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba450000AudioRwReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_400000_as_audio_with_RW_subchannel);
@@ -831,7 +848,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba400000AudioRwReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba400000AudioRwReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_45000_as_audio_with_RW_subchannel);
@@ -864,7 +882,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba45000AudioRwReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba45000AudioRwReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_44990_as_audio_with_RW_subchannel);
@@ -897,7 +916,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba44990AudioRwReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba44990AudioRwReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_100000);
@@ -927,7 +947,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba100000Readable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba100000Readable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_50000);
@@ -957,7 +978,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba50000Readable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba50000Readable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_450000);
@@ -987,7 +1009,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba450000Readable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba450000Readable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_400000);
@@ -1017,7 +1040,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba400000Readable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba400000Readable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_45000);
@@ -1047,7 +1071,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba45000Readable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba45000Readable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_44990);
@@ -1077,7 +1102,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba44990Readable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba44990Readable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_100000_with_PQ_subchannel);
@@ -1086,14 +1112,14 @@ public sealed partial class DeviceReport
while(true)
{
report.GdRomSwapDiscCapabilities.Lba100000PqReadable = !_dev.ReadCd(out byte[] lba100000PqBuffer,
out byte[] lba100000PqSenseBuffer,
100000, 2368, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Q16, _dev.Timeout,
out _);
out byte[] lba100000PqSenseBuffer,
100000, 2368, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Q16, _dev.Timeout,
out _);
report.GdRomSwapDiscCapabilities.Lba100000PqData = lba100000PqBuffer;
report.GdRomSwapDiscCapabilities.Lba100000PqSense = lba100000PqSenseBuffer;
@@ -1109,7 +1135,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba100000PqReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba100000PqReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_50000_with_PQ_subchannel);
@@ -1139,7 +1166,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba50000PqReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba50000PqReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_450000_with_PQ_subchannel);
@@ -1148,14 +1176,14 @@ public sealed partial class DeviceReport
while(true)
{
report.GdRomSwapDiscCapabilities.Lba450000PqReadable = !_dev.ReadCd(out byte[] lba450000PqBuffer,
out byte[] lba450000PqSenseBuffer,
450000, 2368, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Q16, _dev.Timeout,
out _);
out byte[] lba450000PqSenseBuffer,
450000, 2368, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Q16, _dev.Timeout,
out _);
report.GdRomSwapDiscCapabilities.Lba450000PqData = lba450000PqBuffer;
report.GdRomSwapDiscCapabilities.Lba450000PqSense = lba450000PqSenseBuffer;
@@ -1171,7 +1199,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba450000PqReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba450000PqReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_400000_with_PQ_subchannel);
@@ -1180,14 +1209,14 @@ public sealed partial class DeviceReport
while(true)
{
report.GdRomSwapDiscCapabilities.Lba400000PqReadable = !_dev.ReadCd(out byte[] lba400000PqBuffer,
out byte[] lba400000PqSenseBuffer,
400000, 2368, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Q16, _dev.Timeout,
out _);
out byte[] lba400000PqSenseBuffer,
400000, 2368, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Q16, _dev.Timeout,
out _);
report.GdRomSwapDiscCapabilities.Lba400000PqData = lba400000PqBuffer;
report.GdRomSwapDiscCapabilities.Lba400000PqSense = lba400000PqSenseBuffer;
@@ -1203,7 +1232,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba400000PqReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba400000PqReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_45000_with_PQ_subchannel);
@@ -1233,7 +1263,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba45000PqReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba45000PqReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_44990_with_PQ_subchannel);
@@ -1263,7 +1294,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba44990PqReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba44990PqReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_100000_with_RW_subchannel);
@@ -1272,14 +1304,14 @@ public sealed partial class DeviceReport
while(true)
{
report.GdRomSwapDiscCapabilities.Lba100000RwReadable = !_dev.ReadCd(out byte[] lba100000RwBuffer,
out byte[] lba100000RwSenseBuffer,
100000, 2448, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Raw, _dev.Timeout,
out _);
out byte[] lba100000RwSenseBuffer,
100000, 2448, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Raw, _dev.Timeout,
out _);
report.GdRomSwapDiscCapabilities.Lba100000RwData = lba100000RwBuffer;
report.GdRomSwapDiscCapabilities.Lba100000RwSense = lba100000RwSenseBuffer;
@@ -1295,7 +1327,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba100000RwReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba100000RwReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_50000_with_RW_subchannel);
@@ -1325,7 +1358,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba50000RwReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba50000RwReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_450000_with_RW_subchannel);
@@ -1334,14 +1368,14 @@ public sealed partial class DeviceReport
while(true)
{
report.GdRomSwapDiscCapabilities.Lba450000RwReadable = !_dev.ReadCd(out byte[] lba450000RwBuffer,
out byte[] lba450000RwSenseBuffer,
450000, 2448, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Raw, _dev.Timeout,
out _);
out byte[] lba450000RwSenseBuffer,
450000, 2448, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Raw, _dev.Timeout,
out _);
report.GdRomSwapDiscCapabilities.Lba450000RwData = lba450000RwBuffer;
report.GdRomSwapDiscCapabilities.Lba450000RwSense = lba450000RwSenseBuffer;
@@ -1357,7 +1391,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba450000RwReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba450000RwReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_400000_with_RW_subchannel);
@@ -1366,14 +1401,14 @@ public sealed partial class DeviceReport
while(true)
{
report.GdRomSwapDiscCapabilities.Lba400000RwReadable = !_dev.ReadCd(out byte[] lba400000RwBuffer,
out byte[] lba400000RwSenseBuffer,
400000, 2448, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Raw, _dev.Timeout,
out _);
out byte[] lba400000RwSenseBuffer,
400000, 2448, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Raw, _dev.Timeout,
out _);
report.GdRomSwapDiscCapabilities.Lba400000RwData = lba400000RwBuffer;
report.GdRomSwapDiscCapabilities.Lba400000RwSense = lba400000RwSenseBuffer;
@@ -1389,7 +1424,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba400000RwReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba400000RwReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_45000_with_RW_subchannel);
@@ -1419,7 +1455,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba45000RwReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba45000RwReadable
? Localization.Core.Success
: Localization.Core.FAIL);
AaruConsole.Write(Localization.Core.Reading_LBA_44990_with_RW_subchannel);
@@ -1449,7 +1486,8 @@ public sealed partial class DeviceReport
cluster /= 2;
}
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba44990RwReadable ? Localization.Core.Success
AaruConsole.WriteLine(report.GdRomSwapDiscCapabilities.Lba44990RwReadable
? Localization.Core.Success
: Localization.Core.FAIL);
if(report.GdRomSwapDiscCapabilities.Lba45000Readable == false &&
@@ -1479,8 +1517,8 @@ public sealed partial class DeviceReport
return;
uint startingSector = 45000;
bool readAsAudio = false;
bool aborted = false;
var readAsAudio = false;
var aborted = false;
MmcSubchannel subchannel = MmcSubchannel.None;
uint blockSize = 2352;
@@ -1617,7 +1655,7 @@ public sealed partial class DeviceReport
byte[] lastSuccessfulPq = null;
byte[] lastSuccessfulRw = null;
bool trackModeChange = false;
var trackModeChange = false;
AaruConsole.WriteLine();
@@ -1637,11 +1675,12 @@ public sealed partial class DeviceReport
sense = readAsAudio
? _dev.ReadCd(out buffer, out senseBuffer, lba, blockSize, cluster, MmcSectorTypes.Cdda, false,
false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None, subchannel,
_dev.Timeout, out _) : _dev.ReadCd(out buffer, out senseBuffer, lba, blockSize,
cluster, MmcSectorTypes.AllTypes, false, false,
true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.None, subchannel, _dev.Timeout,
out _);
_dev.Timeout, out _)
: _dev.ReadCd(out buffer, out senseBuffer, lba, blockSize,
cluster, MmcSectorTypes.AllTypes, false, false,
true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.None, subchannel, _dev.Timeout,
out _);
if(sense)
{

View File

@@ -52,8 +52,8 @@ public sealed partial class DeviceReport
while(offset + 4 < response.Length)
{
ushort code = (ushort)((response[offset + 0] << 8) + response[offset + 1]);
byte[] data = new byte[response[offset + 3] + 4];
var code = (ushort)((response[offset + 0] << 8) + response[offset + 1]);
var data = new byte[response[offset + 3] + 4];
if(code != 0x0108)
{
@@ -76,7 +76,7 @@ public sealed partial class DeviceReport
/// <returns>MMC features report</returns>
public MmcFeatures ReportMmcFeatures()
{
bool sense = true;
var sense = true;
byte[] buffer = Array.Empty<byte>();
Spectre.ProgressSingleSpinner(ctx =>
@@ -99,6 +99,7 @@ public sealed partial class DeviceReport
};
foreach(Features.FeatureDescriptor desc in ftr.Descriptors)
{
switch(desc.Code)
{
case 0x0001:
@@ -489,7 +490,7 @@ public sealed partial class DeviceReport
if(ftr010C.HasValue)
{
byte[] temp = new byte[4];
var temp = new byte[4];
temp[0] = (byte)((ftr010C.Value.Century & 0xFF00) >> 8);
temp[1] = (byte)(ftr010C.Value.Century & 0xFF);
temp[2] = (byte)((ftr010C.Value.Year & 0xFF00) >> 8);
@@ -522,12 +523,12 @@ public sealed partial class DeviceReport
int.Parse(shour), int.Parse(sminute), int.Parse(ssecond),
DateTimeKind.Utc);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
{
// ignored
}
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
}
}
@@ -574,6 +575,7 @@ public sealed partial class DeviceReport
break;
}
}
return report;
}
@@ -587,9 +589,9 @@ public sealed partial class DeviceReport
/// <param name="tryMediaTekF106">Try MediaTek vendor commands</param>
/// <returns></returns>
public TestedMedia ReportMmcMedia(string mediaType, bool tryPlextor, bool tryPioneer, bool tryNec, bool tryHldtst,
bool tryMediaTekF106)
bool tryMediaTekF106)
{
bool sense = true;
var sense = true;
byte[] buffer = Array.Empty<byte>();
byte[] senseBuffer = Array.Empty<byte>();
var mediaTest = new TestedMedia();
@@ -621,7 +623,7 @@ public sealed partial class DeviceReport
!_dev.Error)
{
mediaTest.SupportsReadCapacity16 = true;
byte[] temp = new byte[8];
var temp = new byte[8];
Array.Copy(buffer, 0, temp, 0, 8);
Array.Reverse(temp);
mediaTest.Blocks = BitConverter.ToUInt64(temp, 0) + 1;
@@ -668,7 +670,7 @@ public sealed partial class DeviceReport
mediaTest.Density = (byte?)decMode?.Header.BlockDescriptors?[0].Density;
}
if(mediaType.StartsWith("CD-", StringComparison.Ordinal) ||
if(mediaType.StartsWith("CD-", StringComparison.Ordinal) ||
mediaType.StartsWith("DDCD-", StringComparison.Ordinal) ||
mediaType == "Audio CD")
{
@@ -693,7 +695,7 @@ public sealed partial class DeviceReport
mediaTest.FullTocData = buffer;
}
if(mediaType.StartsWith("CD-R", StringComparison.Ordinal) ||
if(mediaType.StartsWith("CD-R", StringComparison.Ordinal) ||
mediaType.StartsWith("DDCD-R", StringComparison.Ordinal))
{
Spectre.ProgressSingleSpinner(ctx =>
@@ -717,10 +719,10 @@ public sealed partial class DeviceReport
mediaTest.PmaData = buffer;
}
if(mediaType.StartsWith("DVD-", StringComparison.Ordinal) ||
mediaType.StartsWith("DVD+", StringComparison.Ordinal) ||
if(mediaType.StartsWith("DVD-", StringComparison.Ordinal) ||
mediaType.StartsWith("DVD+", StringComparison.Ordinal) ||
mediaType.StartsWith("HD DVD-", StringComparison.Ordinal) ||
mediaType.StartsWith("PD-", StringComparison.Ordinal))
mediaType.StartsWith("PD-", StringComparison.Ordinal))
{
Spectre.ProgressSingleSpinner(ctx =>
{
@@ -1049,7 +1051,7 @@ public sealed partial class DeviceReport
if(mediaType.StartsWith("BD-R", StringComparison.Ordinal) ||
mediaType is "Ultra HD Blu-ray movie" or "PlayStation 3 game" or "PlayStation 4 game" or "PlayStation 5 game"
or "Xbox One game" or "Nintendo Wii game")
or "Xbox One game" or "Nintendo Wii game")
{
Spectre.ProgressSingleSpinner(ctx =>
{
@@ -1192,7 +1194,7 @@ public sealed partial class DeviceReport
mediaTest.Read16Data = buffer;
}
if(mediaType.StartsWith("CD-", StringComparison.Ordinal) ||
if(mediaType.StartsWith("CD-", StringComparison.Ordinal) ||
mediaType.StartsWith("DDCD-", StringComparison.Ordinal) ||
mediaType == "Audio CD")
{
@@ -1304,13 +1306,17 @@ public sealed partial class DeviceReport
{
// ReSharper disable IntVariableOverflowInUncheckedContext
if(mediaType == "Audio CD")
{
sense = _dev.ReadCd(out buffer, out senseBuffer, (uint)i, 2352, 1, MmcSectorTypes.Cdda,
false, false, false, MmcHeaderCodes.None, true, false,
MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, out _);
}
else
{
sense = _dev.ReadCd(out buffer, out senseBuffer, (uint)i, 2352, 1, MmcSectorTypes.AllTypes,
false, false, true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, out _);
}
// ReSharper restore IntVariableOverflowInUncheckedContext
@@ -1333,19 +1339,20 @@ public sealed partial class DeviceReport
{
ctx.AddTask(Localization.Core.Trying_to_read_CD_Lead_In).IsIndeterminate();
foreach(int i in new[]
{
-5000, -4000, -3000, -2000, -1000, -500, -250
})
foreach(int i in new[] { -5000, -4000, -3000, -2000, -1000, -500, -250 })
{
if(mediaType == "Audio CD")
{
sense = _dev.ReadCd(out buffer, out senseBuffer, (uint)i, 2352, 1, MmcSectorTypes.Cdda,
false, false, false, MmcHeaderCodes.None, true, false,
MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, out _);
}
else
{
sense = _dev.ReadCd(out buffer, out senseBuffer, (uint)i, 2352, 1, MmcSectorTypes.AllTypes,
false, false, true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, out _);
}
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, sense);
@@ -1367,18 +1374,22 @@ public sealed partial class DeviceReport
ctx.AddTask(Localization.Core.Trying_to_read_CD_Lead_Out).IsIndeterminate();
if(mediaType == "Audio CD")
{
mediaTest.CanReadLeadOut = !_dev.ReadCd(out buffer, out senseBuffer,
(uint)(mediaTest.Blocks + 1), 2352, 1,
MmcSectorTypes.Cdda, false, false, false,
MmcHeaderCodes.None, true, false, MmcErrorField.None,
MmcSubchannel.None, _dev.Timeout, out _);
}
else
{
mediaTest.CanReadLeadOut = !_dev.ReadCd(out buffer, out senseBuffer,
(uint)(mediaTest.Blocks + 1), 2352, 1,
MmcSectorTypes.AllTypes, false, false, true,
MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.None, MmcSubchannel.None, _dev.Timeout,
out _);
}
});
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0,
@@ -1405,11 +1416,13 @@ public sealed partial class DeviceReport
_dev.Timeout, out _);
if(!mediaTest.CanReadC2Pointers == true)
{
mediaTest.CanReadC2Pointers = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2648, 1,
MmcSectorTypes.Cdda, false, false, false,
MmcHeaderCodes.None, true, false,
MmcErrorField.C2PointersAndBlock,
MmcSubchannel.None, _dev.Timeout, out _);
}
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0,
!mediaTest.CanReadC2Pointers);
@@ -1480,11 +1493,13 @@ public sealed partial class DeviceReport
_dev.Timeout, out _);
if(mediaTest.CanReadPQSubchannelWithC2 == false)
{
mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2664, 1,
MmcSectorTypes.Cdda, false, false, false,
MmcHeaderCodes.None, true, false,
MmcErrorField.C2PointersAndBlock,
MmcSubchannel.Q16, _dev.Timeout, out _);
}
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0,
!mediaTest.CanReadPQSubchannelWithC2);
@@ -1498,11 +1513,13 @@ public sealed partial class DeviceReport
_dev.Timeout, out _);
if(mediaTest.CanReadRWSubchannelWithC2 == false)
{
mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2714, 1,
MmcSectorTypes.Cdda, false, false, false,
MmcHeaderCodes.None, true, false,
MmcErrorField.C2PointersAndBlock,
MmcSubchannel.Raw, _dev.Timeout, out _);
}
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0,
!mediaTest.CanReadRWSubchannelWithC2);
@@ -1516,6 +1533,7 @@ public sealed partial class DeviceReport
MmcSubchannel.Rw, _dev.Timeout, out _);
if(mediaTest.CanReadCorrectedSubchannelWithC2 == false)
{
mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11,
2714, 1, MmcSectorTypes.Cdda, false,
false, false, MmcHeaderCodes.None,
@@ -1523,6 +1541,7 @@ public sealed partial class DeviceReport
MmcErrorField.C2PointersAndBlock,
MmcSubchannel.Rw, _dev.Timeout,
out _);
}
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0,
!mediaTest.CanReadCorrectedSubchannelWithC2);
@@ -1549,11 +1568,13 @@ public sealed partial class DeviceReport
_dev.Timeout, out _);
if(mediaTest.CanReadC2Pointers == false)
{
mediaTest.CanReadC2Pointers = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2648, 1,
MmcSectorTypes.AllTypes, false, false, true,
MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.C2PointersAndBlock,
MmcSubchannel.None, _dev.Timeout, out _);
}
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0,
!mediaTest.CanReadC2Pointers);
@@ -1625,11 +1646,13 @@ public sealed partial class DeviceReport
_dev.Timeout, out _);
if(mediaTest.CanReadPQSubchannelWithC2 == false)
{
mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2664, 1,
MmcSectorTypes.AllTypes, false, false,
true, MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.C2PointersAndBlock,
MmcSubchannel.Q16, _dev.Timeout, out _);
}
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0,
!mediaTest.CanReadPQSubchannelWithC2);
@@ -1643,11 +1666,13 @@ public sealed partial class DeviceReport
_dev.Timeout, out _);
if(mediaTest.CanReadRWSubchannelWithC2 == false)
{
mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2714, 1,
MmcSectorTypes.AllTypes, false, false,
true, MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.C2PointersAndBlock,
MmcSubchannel.Raw, _dev.Timeout, out _);
}
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0,
!mediaTest.CanReadRWSubchannelWithC2);
@@ -1666,6 +1691,7 @@ public sealed partial class DeviceReport
else
{
if(mediaTest.CanReadCorrectedSubchannelWithC2 == false)
{
mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer,
16, 2714, 1,
MmcSectorTypes.AllTypes, false,
@@ -1675,6 +1701,7 @@ public sealed partial class DeviceReport
MmcErrorField.C2PointersAndBlock,
MmcSubchannel.Rw, _dev.Timeout,
out _);
}
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0,
!mediaTest.CanReadCorrectedSubchannelWithC2);
@@ -1701,11 +1728,13 @@ public sealed partial class DeviceReport
_dev.Timeout, out _);
if(mediaTest.CanReadC2Pointers == false)
{
mediaTest.CanReadC2Pointers = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2344, 1,
MmcSectorTypes.AllTypes, false, false, false,
MmcHeaderCodes.None, true, false,
MmcErrorField.C2PointersAndBlock,
MmcSubchannel.None, _dev.Timeout, out _);
}
});
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0,
@@ -1775,11 +1804,13 @@ public sealed partial class DeviceReport
_dev.Timeout, out _);
if(mediaTest.CanReadPQSubchannelWithC2 == false)
{
mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2360, 1,
MmcSectorTypes.AllTypes, false, false,
false, MmcHeaderCodes.None, true, false,
MmcErrorField.C2PointersAndBlock,
MmcSubchannel.Q16, _dev.Timeout, out _);
}
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0,
!mediaTest.CanReadPQSubchannelWithC2);
@@ -1793,11 +1824,13 @@ public sealed partial class DeviceReport
_dev.Timeout, out _);
if(mediaTest.CanReadRWSubchannelWithC2 == false)
{
mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2440, 1,
MmcSectorTypes.AllTypes, false, false,
false, MmcHeaderCodes.None, true, false,
MmcErrorField.C2PointersAndBlock,
MmcSubchannel.Raw, _dev.Timeout, out _);
}
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0,
!mediaTest.CanReadRWSubchannelWithC2);
@@ -1811,6 +1844,7 @@ public sealed partial class DeviceReport
MmcSubchannel.Rw, _dev.Timeout, out _);
if(mediaTest.CanReadCorrectedSubchannelWithC2 == false)
{
mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16,
2440, 1, MmcSectorTypes.AllTypes,
false, false, false,
@@ -1818,6 +1852,7 @@ public sealed partial class DeviceReport
MmcErrorField.C2PointersAndBlock,
MmcSubchannel.Rw, _dev.Timeout,
out _);
}
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0,
!mediaTest.CanReadCorrectedSubchannelWithC2);
@@ -1982,8 +2017,8 @@ public sealed partial class DeviceReport
if(tryMediaTekF106)
{
bool triedLba0 = false;
bool triedLeadOut = false;
var triedLba0 = false;
var triedLeadOut = false;
Spectre.ProgressSingleSpinner(ctx =>
{
@@ -2191,14 +2226,14 @@ public sealed partial class DeviceReport
secondSessionFirstTrack.PFRAME);
// Skip Lead-Out pre-gap
uint firstSessionLeadOutLba = (uint)((firstSessionLeadOutTrack.PMIN * 60 * 75) +
(firstSessionLeadOutTrack.PSEC * 75) +
firstSessionLeadOutTrack.PFRAME + 150);
var firstSessionLeadOutLba = (uint)(firstSessionLeadOutTrack.PMIN * 60 * 75 +
firstSessionLeadOutTrack.PSEC * 75 +
firstSessionLeadOutTrack.PFRAME + 150);
// Skip second session track pre-gap
uint secondSessionLeadInLba = (uint)((secondSessionFirstTrack.PMIN * 60 * 75) +
(secondSessionFirstTrack.PSEC * 75) +
secondSessionFirstTrack.PFRAME - 300);
var secondSessionLeadInLba = (uint)(secondSessionFirstTrack.PMIN * 60 * 75 +
secondSessionFirstTrack.PSEC * 75 +
secondSessionFirstTrack.PFRAME - 300);
Spectre.ProgressSingleSpinner(ctx =>
{
@@ -2222,12 +2257,14 @@ public sealed partial class DeviceReport
MmcSubchannel.Q16, _dev.Timeout, out _);
if(mediaTest.CanReadingIntersessionLeadOut == false)
{
mediaTest.CanReadingIntersessionLeadOut = !_dev.ReadCd(out buffer, out senseBuffer,
firstSessionLeadOutLba, 2352, 1,
MmcSectorTypes.AllTypes, false, false,
false, MmcHeaderCodes.AllHeaders, true,
false, MmcErrorField.None,
MmcSubchannel.None, _dev.Timeout, out _);
}
});
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0,
@@ -2257,12 +2294,14 @@ public sealed partial class DeviceReport
MmcSubchannel.Q16, _dev.Timeout, out _);
if(mediaTest.CanReadingIntersessionLeadIn == false)
{
mediaTest.CanReadingIntersessionLeadIn = !_dev.ReadCd(out buffer, out senseBuffer,
secondSessionLeadInLba, 2352, 1,
MmcSectorTypes.AllTypes, false, false,
false, MmcHeaderCodes.AllHeaders, true,
false, MmcErrorField.None,
MmcSubchannel.None, _dev.Timeout, out _);
}
});
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0,

View File

@@ -52,6 +52,7 @@ public sealed partial class DeviceReport
return pcmciaReport;
foreach(Tuple tuple in tuples)
{
switch(tuple.Code)
{
case TupleCodes.CISTPL_MANFID:
@@ -77,6 +78,7 @@ public sealed partial class DeviceReport
break;
}
}
return pcmciaReport;
}

View File

@@ -47,7 +47,7 @@ public sealed partial class DeviceReport
public Ssc ReportScsiSsc()
{
var report = new Ssc();
bool sense = true;
var sense = true;
byte[] buffer = Array.Empty<byte>();
Spectre.ProgressSingleSpinner(ctx =>
@@ -82,9 +82,10 @@ public sealed partial class DeviceReport
if(dsh.HasValue)
{
SupportedDensity[] array = new SupportedDensity[dsh.Value.descriptors.Length];
var array = new SupportedDensity[dsh.Value.descriptors.Length];
for(int i = 0; i < dsh.Value.descriptors.Length; i++)
for(var i = 0; i < dsh.Value.descriptors.Length; i++)
{
array[i] = new SupportedDensity
{
BitsPerMm = dsh.Value.descriptors[i].bpmm,
@@ -100,6 +101,7 @@ public sealed partial class DeviceReport
Width = dsh.Value.descriptors[i].width,
Writable = dsh.Value.descriptors[i].writable
};
}
report.SupportedDensities = array.ToList();
}
@@ -119,9 +121,9 @@ public sealed partial class DeviceReport
if(!mtsh.HasValue)
return report;
SscSupportedMedia[] array2 = new SscSupportedMedia[mtsh.Value.descriptors.Length];
var array2 = new SscSupportedMedia[mtsh.Value.descriptors.Length];
for(int i = 0; i < mtsh.Value.descriptors.Length; i++)
for(var i = 0; i < mtsh.Value.descriptors.Length; i++)
{
array2[i] = new SscSupportedMedia
{
@@ -136,13 +138,15 @@ public sealed partial class DeviceReport
if(mtsh.Value.descriptors[i].densityCodes == null)
continue;
DensityCode[] array3 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
var array3 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
for(int j = 0; j < mtsh.Value.descriptors[i].densityCodes.Length; j++)
for(var j = 0; j < mtsh.Value.descriptors[i].densityCodes.Length; j++)
{
array3[j] = new DensityCode
{
Code = mtsh.Value.descriptors[i].densityCodes[j]
};
}
array2[i].DensityCodes = array3.Distinct().ToList();
}
@@ -157,7 +161,7 @@ public sealed partial class DeviceReport
public TestedSequentialMedia ReportSscMedia()
{
var seqTest = new TestedSequentialMedia();
bool sense = true;
var sense = true;
byte[] buffer = Array.Empty<byte>();
Modes.DecodedMode? decMode = null;
@@ -211,9 +215,10 @@ public sealed partial class DeviceReport
if(dsh.HasValue)
{
SupportedDensity[] array = new SupportedDensity[dsh.Value.descriptors.Length];
var array = new SupportedDensity[dsh.Value.descriptors.Length];
for(int i = 0; i < dsh.Value.descriptors.Length; i++)
for(var i = 0; i < dsh.Value.descriptors.Length; i++)
{
array[i] = new SupportedDensity
{
BitsPerMm = dsh.Value.descriptors[i].bpmm,
@@ -229,6 +234,7 @@ public sealed partial class DeviceReport
Width = dsh.Value.descriptors[i].width,
Writable = dsh.Value.descriptors[i].writable
};
}
seqTest.SupportedDensities = array.ToList();
}
@@ -248,9 +254,9 @@ public sealed partial class DeviceReport
if(mtsh.HasValue)
{
SscSupportedMedia[] array = new SscSupportedMedia[mtsh.Value.descriptors.Length];
var array = new SscSupportedMedia[mtsh.Value.descriptors.Length];
for(int i = 0; i < mtsh.Value.descriptors.Length; i++)
for(var i = 0; i < mtsh.Value.descriptors.Length; i++)
{
array[i] = new SscSupportedMedia
{
@@ -265,13 +271,15 @@ public sealed partial class DeviceReport
if(mtsh.Value.descriptors[i].densityCodes == null)
continue;
DensityCode[] array2 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
var array2 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
for(int j = 0; j < mtsh.Value.descriptors[i].densityCodes.Length; j++)
for(var j = 0; j < mtsh.Value.descriptors[i].densityCodes.Length; j++)
{
array2[j] = new DensityCode
{
Code = mtsh.Value.descriptors[i].densityCodes[j]
};
}
array[i].DensityCodes = array2.Distinct().ToList();
}

View File

@@ -50,7 +50,7 @@ public sealed partial class DeviceReport
/// <returns>SCSI report</returns>
public Scsi ReportScsiInquiry()
{
bool sense = true;
var sense = true;
byte[] buffer = Array.Empty<byte>();
Spectre.ProgressSingleSpinner(ctx =>
@@ -88,7 +88,7 @@ public sealed partial class DeviceReport
return inquiry;
// Clear Seagate serial number
for(int i = 36; i <= 43; i++)
for(var i = 36; i <= 43; i++)
inquiry[i] = 0;
return inquiry;
@@ -99,7 +99,7 @@ public sealed partial class DeviceReport
/// <returns>List of decoded SCSI EVPD pages</returns>
public List<ScsiPage> ReportEvpdPages(string vendor)
{
bool sense = false;
var sense = false;
byte[] buffer = Array.Empty<byte>();
Spectre.ProgressSingleSpinner(ctx =>
@@ -141,7 +141,7 @@ public sealed partial class DeviceReport
break;
case 0x80:
byte[] identify = new byte[512];
var identify = new byte[512];
Array.Copy(buffer, 60, identify, 0, 512);
identify = ClearIdentify(identify);
Array.Copy(identify, 0, buffer, 60, 512);
@@ -155,7 +155,7 @@ public sealed partial class DeviceReport
break;
case 0xC1 when vendor == "ibm":
empty = new byte[12];
Array.Copy(empty, 0, buffer, 4, 12);
Array.Copy(empty, 0, buffer, 4, 12);
Array.Copy(empty, 0, buffer, 16, 12);
break;
@@ -193,7 +193,7 @@ public sealed partial class DeviceReport
if(pageResponse.Length < 6)
return null;
int position = 4;
var position = 4;
while(position < pageResponse.Length)
{
@@ -202,7 +202,7 @@ public sealed partial class DeviceReport
if(length + position + 4 >= pageResponse.Length)
length = (byte)(pageResponse.Length - position - 4);
byte[] empty = new byte[length];
var empty = new byte[length];
Array.Copy(empty, 0, pageResponse, position + 4, length);
position += 4 + length;
@@ -216,7 +216,7 @@ public sealed partial class DeviceReport
/// <param name="cdromMode">Returns raw MODE SENSE page 2Ah, aka CD-ROM page</param>
/// <param name="mediumType">Returns decoded list of supported media types response</param>
public void ReportScsiModes(ref CommonTypes.Metadata.DeviceReport report, out byte[] cdromMode,
out MediumTypes mediumType)
out MediumTypes mediumType)
{
Modes.DecodedMode? decMode = null;
PeripheralDeviceTypes devType = _dev.ScsiType;
@@ -236,7 +236,7 @@ public sealed partial class DeviceReport
ScsiModeSensePageControl.Changeable
})
{
bool saveBuffer = false;
var saveBuffer = false;
sense = _dev.ModeSense10(out byte[] mode10Buffer, out _, false, true, pageControl, 0x3F, 0xFF,
_dev.Timeout, out _);
@@ -319,7 +319,7 @@ public sealed partial class DeviceReport
ScsiModeSensePageControl.Changeable
})
{
bool saveBuffer = false;
var saveBuffer = false;
sense = _dev.ModeSense6(out byte[] mode6Buffer, out _, true, pageControl, 0x3F, 0xFF, _dev.Timeout,
out _);
@@ -467,7 +467,7 @@ public sealed partial class DeviceReport
public TestedMedia ReportScsiMedia()
{
var mediaTest = new TestedMedia();
bool sense = true;
var sense = true;
byte[] buffer = Array.Empty<byte>();
byte[] senseBuffer = Array.Empty<byte>();
@@ -498,7 +498,7 @@ public sealed partial class DeviceReport
!_dev.Error)
{
mediaTest.SupportsReadCapacity16 = true;
byte[] temp = new byte[8];
var temp = new byte[8];
Array.Copy(buffer, 0, temp, 0, 8);
Array.Reverse(temp);
mediaTest.Blocks = BitConverter.ToUInt64(temp, 0) + 1;
@@ -651,7 +651,7 @@ public sealed partial class DeviceReport
}
}
if((mediaTest.SupportsReadLong != true && mediaTest.SupportsReadLong16 != true) ||
if(mediaTest.SupportsReadLong != true && mediaTest.SupportsReadLong16 != true ||
mediaTest.LongBlockSize != mediaTest.BlockSize)
return;
@@ -673,8 +673,9 @@ public sealed partial class DeviceReport
{
sense = mediaTest.SupportsReadLong16 == true
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout,
out _) : _dev.ReadLong10(out buffer, out senseBuffer, false,
false, 0, testSize, _dev.Timeout, out _);
out _)
: _dev.ReadLong10(out buffer, out senseBuffer, false,
false, 0, testSize, _dev.Timeout, out _);
if(sense || _dev.Error)
continue;
@@ -699,8 +700,9 @@ public sealed partial class DeviceReport
{
sense = mediaTest.SupportsReadLong16 == true
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout,
out _) : _dev.ReadLong10(out buffer, out senseBuffer, false,
false, 0, testSize, _dev.Timeout, out _);
out _)
: _dev.ReadLong10(out buffer, out senseBuffer, false,
false, 0, testSize, _dev.Timeout, out _);
if(sense || _dev.Error)
continue;
@@ -769,7 +771,7 @@ public sealed partial class DeviceReport
/// <returns>Media report</returns>
public TestedMedia ReportScsi()
{
bool sense = true;
var sense = true;
byte[] buffer = Array.Empty<byte>();
byte[] senseBuffer = Array.Empty<byte>();
@@ -805,7 +807,7 @@ public sealed partial class DeviceReport
!_dev.Error)
{
capabilities.SupportsReadCapacity16 = true;
byte[] temp = new byte[8];
var temp = new byte[8];
Array.Copy(buffer, 0, temp, 0, 8);
Array.Reverse(temp);
capabilities.Blocks = BitConverter.ToUInt64(temp, 0) + 1;
@@ -960,13 +962,14 @@ public sealed partial class DeviceReport
}
}
if((capabilities.SupportsReadLong != true && capabilities.SupportsReadLong16 != true) ||
if(capabilities.SupportsReadLong != true && capabilities.SupportsReadLong16 != true ||
capabilities.LongBlockSize != capabilities.BlockSize)
return capabilities;
Spectre.ProgressSingleSpinner(ctx =>
{
ctx.AddTask(capabilities.SupportsReadLong16 == true ? Localization.Core.Trying_SCSI_READ_LONG_16
ctx.AddTask(capabilities.SupportsReadLong16 == true
? Localization.Core.Trying_SCSI_READ_LONG_16
: Localization.Core.Trying_SCSI_READ_LONG_10).IsIndeterminate();
switch(capabilities.BlockSize)
@@ -987,8 +990,9 @@ public sealed partial class DeviceReport
{
sense = capabilities.SupportsReadLong16 == true
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout,
out _) : _dev.ReadLong10(out buffer, out senseBuffer, false,
false, 0, testSize, _dev.Timeout, out _);
out _)
: _dev.ReadLong10(out buffer, out senseBuffer, false,
false, 0, testSize, _dev.Timeout, out _);
if(sense || _dev.Error)
continue;
@@ -1014,8 +1018,9 @@ public sealed partial class DeviceReport
{
sense = capabilities.SupportsReadLong16 == true
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout,
out _) : _dev.ReadLong10(out buffer, out senseBuffer, false,
false, 0, testSize, _dev.Timeout, out _);
out _)
: _dev.ReadLong10(out buffer, out senseBuffer, false,
false, 0, testSize, _dev.Timeout, out _);
if(sense || _dev.Error)
continue;

View File

@@ -45,7 +45,7 @@ public sealed partial class DeviceReport
public MmcSd MmcSdReport()
{
var report = new MmcSd();
bool sense = true;
var sense = true;
byte[] cid = Array.Empty<byte>();
byte[] csd = Array.Empty<byte>();
byte[] ecsd = Array.Empty<byte>();
@@ -111,11 +111,11 @@ public sealed partial class DeviceReport
ctx.AddTask(Localization.Core.Trying_to_get_OCR).IsIndeterminate();
sense = _dev.Type switch
{
DeviceType.MMC => _dev.ReadOcr(out ocr, out _, _dev.Timeout, out _),
DeviceType.SecureDigital => _dev.ReadSdocr(out ocr, out _, _dev.Timeout, out _),
_ => sense
};
{
DeviceType.MMC => _dev.ReadOcr(out ocr, out _, _dev.Timeout, out _),
DeviceType.SecureDigital => _dev.ReadSdocr(out ocr, out _, _dev.Timeout, out _),
_ => sense
};
});
if(!sense)