REFACTOR: Reformat code.

This commit is contained in:
2017-12-19 20:33:03 +00:00
parent 77edc7c91c
commit e6f6ace80b
704 changed files with 82627 additions and 83641 deletions

View File

@@ -42,8 +42,7 @@ namespace DiscImageChef.Core.Devices.Report
{
public static void Report(Device dev, ref DeviceReport report, bool debug, ref bool removable)
{
if(report == null)
return;
if(report == null) return;
Decoders.ATA.AtaErrorRegistersCHS errorRegs;
byte[] buffer;
@@ -51,14 +50,11 @@ namespace DiscImageChef.Core.Devices.Report
uint timeout = 5;
ConsoleKeyInfo pressedKey;
if(dev.IsUSB)
USB.Report(dev, ref report, debug, ref removable);
if(dev.IsUSB) USB.Report(dev, ref report, debug, ref removable);
if(dev.IsFireWire)
FireWire.Report(dev, ref report, debug, ref removable);
if(dev.IsFireWire) FireWire.Report(dev, ref report, debug, ref removable);
if(dev.IsPCMCIA)
PCMCIA.Report(dev, ref report, debug, ref removable);
if(dev.IsPCMCIA) PCMCIA.Report(dev, ref report, debug, ref removable);
DicConsole.WriteLine("Querying ATA IDENTIFY...");
@@ -74,7 +70,8 @@ namespace DiscImageChef.Core.Devices.Report
report.CompactFlashSpecified = true;
removable = false;
}
else if(!removable && ataId.GeneralConfiguration.HasFlag(Decoders.ATA.Identify.GeneralConfigurationBit.Removable))
else if(!removable &&
ataId.GeneralConfiguration.HasFlag(Decoders.ATA.Identify.GeneralConfigurationBit.Removable))
{
pressedKey = new ConsoleKeyInfo();
while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
@@ -488,9 +485,8 @@ namespace DiscImageChef.Core.Devices.Report
report.ATA.WRVSectorCountMode2 = ataId.WRVSectorCountMode2;
report.ATA.WRVSectorCountMode2Specified = true;
}
if(debug)
report.ATA.Identify = buffer;
if(debug) report.ATA.Identify = buffer;
if(removable)
{
List<testedMediaType> mediaTests = new List<testedMediaType>();
@@ -549,14 +545,17 @@ namespace DiscImageChef.Core.Devices.Report
mediaTest.BlocksSpecified = true;
}
if(ataId.CurrentCylinders > 0 && ataId.CurrentHeads > 0 && ataId.CurrentSectorsPerTrack > 0)
if(ataId.CurrentCylinders > 0 && ataId.CurrentHeads > 0 &&
ataId.CurrentSectorsPerTrack > 0)
{
mediaTest.CurrentCHS = new chsType();
mediaTest.CurrentCHS.Cylinders = ataId.CurrentCylinders;
mediaTest.CurrentCHS.Heads = ataId.CurrentHeads;
mediaTest.CurrentCHS.Sectors = ataId.CurrentSectorsPerTrack;
if(mediaTest.Blocks == 0)
mediaTest.Blocks = (ulong)(ataId.CurrentCylinders * ataId.CurrentHeads * ataId.CurrentSectorsPerTrack);
mediaTest.Blocks =
(ulong)(ataId.CurrentCylinders * ataId.CurrentHeads *
ataId.CurrentSectorsPerTrack);
mediaTest.BlocksSpecified = true;
}
@@ -576,8 +575,7 @@ namespace DiscImageChef.Core.Devices.Report
mediaTest.BlocksSpecified = true;
}
if(ataId.NominalRotationRate != 0x0000 &&
ataId.NominalRotationRate != 0xFFFF)
if(ataId.NominalRotationRate != 0x0000 && ataId.NominalRotationRate != 0xFFFF)
{
if(ataId.NominalRotationRate == 0x0001)
{
@@ -596,26 +594,24 @@ namespace DiscImageChef.Core.Devices.Report
uint logicalsectorsize = 0;
uint physicalsectorsize;
if((ataId.PhysLogSectorSize & 0x8000) == 0x0000 &&
(ataId.PhysLogSectorSize & 0x4000) == 0x4000)
(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 = ataId.LogicalSectorWords * 2;
}
else
logicalsectorsize = 512;
else logicalsectorsize = 512;
if((ataId.PhysLogSectorSize & 0x2000) == 0x2000)
{
#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created
physicalsectorsize = (uint)(logicalsectorsize * (1 << ataId.PhysLogSectorSize & 0xF));
physicalsectorsize =
(uint)(logicalsectorsize * (1 << ataId.PhysLogSectorSize & 0xF));
#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created
}
else
physicalsectorsize = logicalsectorsize;
else physicalsectorsize = logicalsectorsize;
}
else
{
@@ -631,7 +627,7 @@ namespace DiscImageChef.Core.Devices.Report
mediaTest.PhysicalBlockSizeSpecified = true;
if((ataId.LogicalAlignment & 0x8000) == 0x0000 &&
(ataId.LogicalAlignment & 0x4000) == 0x4000)
(ataId.LogicalAlignment & 0x4000) == 0x4000)
{
mediaTest.LogicalAlignment = (ushort)(ataId.LogicalAlignment & 0x3FFF);
mediaTest.LogicalAlignmentSpecified = true;
@@ -644,15 +640,16 @@ namespace DiscImageChef.Core.Devices.Report
mediaTest.LongBlockSizeSpecified = true;
}
if(ataId.UnformattedBPS > logicalsectorsize && (!mediaTest.LongBlockSizeSpecified || mediaTest.LongBlockSize == 516))
if(ataId.UnformattedBPS > logicalsectorsize &&
(!mediaTest.LongBlockSizeSpecified || mediaTest.LongBlockSize == 516))
{
mediaTest.LongBlockSize = ataId.UnformattedBPS;
mediaTest.LongBlockSizeSpecified = true;
}
if(ataId.CommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MustBeSet) &&
!ataId.CommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MustBeClear) &&
ataId.EnabledCommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MediaSerial))
!ataId.CommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MustBeClear) &&
ataId.EnabledCommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MediaSerial))
{
mediaTest.CanReadMediaSerial = true;
mediaTest.CanReadMediaSerialSpecified = true;
@@ -692,137 +689,213 @@ namespace DiscImageChef.Core.Devices.Report
DicConsole.WriteLine("Trying READ SECTOR(S) in CHS mode...");
sense = dev.Read(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration);
mediaTest.SupportsRead = (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
mediaTest.SupportsRead =
(!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readsectorschs", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readsectorschs",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
readBuf);
DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in CHS mode...");
sense = dev.Read(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration);
mediaTest.SupportsReadRetry = (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
mediaTest.SupportsReadRetry =
(!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readsectorsretrychs", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readsectorsretrychs",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
readBuf);
DicConsole.WriteLine("Trying READ DMA in CHS mode...");
sense = dev.ReadDma(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration);
mediaTest.SupportsReadDma = (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense = dev.ReadDma(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout,
out duration);
mediaTest.SupportsReadDma =
(!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readdmachs", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readdmachs",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
readBuf);
DicConsole.WriteLine("Trying READ DMA RETRY in CHS mode...");
sense = dev.ReadDma(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration);
mediaTest.SupportsReadDmaRetry = (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
mediaTest.SupportsReadDmaRetry =
(!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readdmaretrychs", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readdmaretrychs",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
readBuf);
DicConsole.WriteLine("Trying SEEK in CHS mode...");
sense = dev.Seek(out errorChs, 0, 0, 1, timeout, out duration);
mediaTest.SupportsSeek = (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}",
sense, errorChs.status, errorChs.error);
mediaTest.SupportsSeek =
(!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
errorChs.status, errorChs.error);
DicConsole.WriteLine("Trying READ SECTOR(S) in LBA mode...");
sense = dev.Read(out readBuf, out errorLba, false, 0, 1, timeout, out duration);
mediaTest.SupportsReadLba = (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
mediaTest.SupportsReadLba =
(!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readsectors", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readsectors",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
readBuf);
DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in LBA mode...");
sense = dev.Read(out readBuf, out errorLba, true, 0, 1, timeout, out duration);
mediaTest.SupportsReadRetryLba = (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
mediaTest.SupportsReadRetryLba =
(!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readsectorsretry", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readsectorsretry",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
readBuf);
DicConsole.WriteLine("Trying READ DMA in LBA mode...");
sense = dev.ReadDma(out readBuf, out errorLba, false, 0, 1, timeout, out duration);
mediaTest.SupportsReadDmaLba = (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
mediaTest.SupportsReadDmaLba =
(!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readdma", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readdma",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
readBuf);
DicConsole.WriteLine("Trying READ DMA RETRY in LBA mode...");
sense = dev.ReadDma(out readBuf, out errorLba, true, 0, 1, timeout, out duration);
mediaTest.SupportsReadDmaRetryLba = (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
mediaTest.SupportsReadDmaRetryLba =
(!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readdmaretry", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readdmaretry",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
readBuf);
DicConsole.WriteLine("Trying SEEK in LBA mode...");
sense = dev.Seek(out errorLba, 0, timeout, out duration);
mediaTest.SupportsSeekLba = (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}",
sense, errorChs.status, errorChs.error);
mediaTest.SupportsSeekLba =
(!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
errorChs.status, errorChs.error);
DicConsole.WriteLine("Trying READ SECTOR(S) in LBA48 mode...");
sense = dev.Read(out readBuf, out errorLba48, 0, 1, timeout, out duration);
mediaTest.SupportsReadLba48 = (!sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
mediaTest.SupportsReadLba48 =
(!sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 &&
readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readsectors48", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readsectors48",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
readBuf);
DicConsole.WriteLine("Trying READ DMA in LBA48 mode...");
sense = dev.ReadDma(out readBuf, out errorLba48, 0, 1, timeout, out duration);
mediaTest.SupportsReadDmaLba48 = (!sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
mediaTest.SupportsReadDmaLba48 =
(!sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 &&
readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readdma48", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readdma48",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
readBuf);
DicConsole.WriteLine("Trying READ LONG in CHS mode...");
sense = dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1, mediaTest.LongBlockSize, timeout, out duration);
mediaTest.SupportsReadLong = (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense = dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1, mediaTest.LongBlockSize,
timeout, out duration);
mediaTest.SupportsReadLong =
(!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readlongchs", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readlongchs",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
readBuf);
DicConsole.WriteLine("Trying READ LONG RETRY in CHS mode...");
sense = dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1, mediaTest.LongBlockSize, timeout, out duration);
mediaTest.SupportsReadLongRetry = (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense = dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1, mediaTest.LongBlockSize,
timeout, out duration);
mediaTest.SupportsReadLongRetry =
(!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readlongretrychs", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readlongretrychs",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
readBuf);
DicConsole.WriteLine("Trying READ LONG in LBA mode...");
sense = dev.ReadLong(out readBuf, out errorLba, false, 0, mediaTest.LongBlockSize, timeout, out duration);
mediaTest.SupportsReadLongLba = (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense = dev.ReadLong(out readBuf, out errorLba, false, 0, mediaTest.LongBlockSize,
timeout, out duration);
mediaTest.SupportsReadLongLba =
(!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readlong", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readlong",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
readBuf);
DicConsole.WriteLine("Trying READ LONG RETRY in LBA mode...");
sense = dev.ReadLong(out readBuf, out errorLba, true, 0, mediaTest.LongBlockSize, timeout, out duration);
mediaTest.SupportsReadLongRetryLba = (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense = dev.ReadLong(out readBuf, out errorLba, true, 0, mediaTest.LongBlockSize,
timeout, out duration);
mediaTest.SupportsReadLongRetryLba =
(!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readlongretry", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readlongretry",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
readBuf);
}
else
mediaTest.MediaIsRecognized = false;
else mediaTest.MediaIsRecognized = false;
mediaTests.Add(mediaTest);
}
}
report.ATA.RemovableMedias = mediaTests.ToArray();
}
else
@@ -846,7 +919,8 @@ namespace DiscImageChef.Core.Devices.Report
report.ATA.ReadCapabilities.CHS.Cylinders = ataId.Cylinders;
report.ATA.ReadCapabilities.CHS.Heads = ataId.Heads;
report.ATA.ReadCapabilities.CHS.Sectors = ataId.SectorsPerTrack;
report.ATA.ReadCapabilities.Blocks = (ulong)(ataId.Cylinders * ataId.Heads * ataId.SectorsPerTrack);
report.ATA.ReadCapabilities.Blocks =
(ulong)(ataId.Cylinders * ataId.Heads * ataId.SectorsPerTrack);
report.ATA.ReadCapabilities.BlocksSpecified = true;
}
@@ -856,7 +930,8 @@ namespace DiscImageChef.Core.Devices.Report
report.ATA.ReadCapabilities.CurrentCHS.Cylinders = ataId.CurrentCylinders;
report.ATA.ReadCapabilities.CurrentCHS.Heads = ataId.CurrentHeads;
report.ATA.ReadCapabilities.CurrentCHS.Sectors = ataId.CurrentSectorsPerTrack;
report.ATA.ReadCapabilities.Blocks = (ulong)(ataId.CurrentCylinders * ataId.CurrentHeads * ataId.CurrentSectorsPerTrack);
report.ATA.ReadCapabilities.Blocks =
(ulong)(ataId.CurrentCylinders * ataId.CurrentHeads * ataId.CurrentSectorsPerTrack);
report.ATA.ReadCapabilities.BlocksSpecified = true;
}
@@ -876,8 +951,7 @@ namespace DiscImageChef.Core.Devices.Report
report.ATA.ReadCapabilities.BlocksSpecified = true;
}
if(ataId.NominalRotationRate != 0x0000 &&
ataId.NominalRotationRate != 0xFFFF)
if(ataId.NominalRotationRate != 0x0000 && ataId.NominalRotationRate != 0xFFFF)
{
if(ataId.NominalRotationRate == 0x0001)
{
@@ -895,27 +969,24 @@ namespace DiscImageChef.Core.Devices.Report
uint logicalsectorsize = 0;
uint physicalsectorsize;
if((ataId.PhysLogSectorSize & 0x8000) == 0x0000 &&
(ataId.PhysLogSectorSize & 0x4000) == 0x4000)
if((ataId.PhysLogSectorSize & 0x8000) == 0x0000 && (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 = ataId.LogicalSectorWords * 2;
}
else
logicalsectorsize = 512;
else logicalsectorsize = 512;
if((ataId.PhysLogSectorSize & 0x2000) == 0x2000)
{
#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created
physicalsectorsize = logicalsectorsize * (uint)Math.Pow(2, (double)(ataId.PhysLogSectorSize & 0xF));
physicalsectorsize = logicalsectorsize *
(uint)Math.Pow(2, (double)(ataId.PhysLogSectorSize & 0xF));
#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created
}
else
physicalsectorsize = logicalsectorsize;
else physicalsectorsize = logicalsectorsize;
}
else
{
@@ -930,8 +1001,7 @@ namespace DiscImageChef.Core.Devices.Report
report.ATA.ReadCapabilities.PhysicalBlockSize = physicalsectorsize;
report.ATA.ReadCapabilities.PhysicalBlockSizeSpecified = true;
if((ataId.LogicalAlignment & 0x8000) == 0x0000 &&
(ataId.LogicalAlignment & 0x4000) == 0x4000)
if((ataId.LogicalAlignment & 0x8000) == 0x0000 && (ataId.LogicalAlignment & 0x4000) == 0x4000)
{
report.ATA.ReadCapabilities.LogicalAlignment = (ushort)(ataId.LogicalAlignment & 0x3FFF);
report.ATA.ReadCapabilities.LogicalAlignmentSpecified = true;
@@ -944,15 +1014,17 @@ namespace DiscImageChef.Core.Devices.Report
report.ATA.ReadCapabilities.LongBlockSizeSpecified = true;
}
if(ataId.UnformattedBPS > logicalsectorsize && (!report.ATA.ReadCapabilities.LongBlockSizeSpecified || report.ATA.ReadCapabilities.LongBlockSize == 516))
if(ataId.UnformattedBPS > logicalsectorsize &&
(!report.ATA.ReadCapabilities.LongBlockSizeSpecified ||
report.ATA.ReadCapabilities.LongBlockSize == 516))
{
report.ATA.ReadCapabilities.LongBlockSize = ataId.UnformattedBPS;
report.ATA.ReadCapabilities.LongBlockSizeSpecified = true;
}
if(ataId.CommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MustBeSet) &&
!ataId.CommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MustBeClear) &&
ataId.EnabledCommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MediaSerial))
!ataId.CommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MustBeClear) &&
ataId.EnabledCommandSet3.HasFlag(Decoders.ATA.Identify.CommandSetBit3.MediaSerial))
{
report.ATA.ReadCapabilities.CanReadMediaSerial = true;
report.ATA.ReadCapabilities.CanReadMediaSerialSpecified = true;
@@ -992,129 +1064,181 @@ namespace DiscImageChef.Core.Devices.Report
DicConsole.WriteLine("Trying READ SECTOR(S) in CHS mode...");
sense = dev.Read(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration);
report.ATA.ReadCapabilities.SupportsRead = (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
report.ATA.ReadCapabilities.SupportsRead =
(!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readsectorschs", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readsectorschs", "_debug_" + report.ATA.Model + ".bin",
"read results", readBuf);
DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in CHS mode...");
sense = dev.Read(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration);
report.ATA.ReadCapabilities.SupportsReadRetry = (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
report.ATA.ReadCapabilities.SupportsReadRetry =
(!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readsectorsretrychs", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readsectorsretrychs", "_debug_" + report.ATA.Model + ".bin",
"read results", readBuf);
DicConsole.WriteLine("Trying READ DMA in CHS mode...");
sense = dev.ReadDma(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration);
report.ATA.ReadCapabilities.SupportsReadDma = (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
report.ATA.ReadCapabilities.SupportsReadDma =
(!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readdmachs", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readdmachs", "_debug_" + report.ATA.Model + ".bin",
"read results", readBuf);
DicConsole.WriteLine("Trying READ DMA RETRY in CHS mode...");
sense = dev.ReadDma(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration);
report.ATA.ReadCapabilities.SupportsReadDmaRetry = (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
report.ATA.ReadCapabilities.SupportsReadDmaRetry =
(!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readdmaretrychs", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readdmaretrychs", "_debug_" + report.ATA.Model + ".bin",
"read results", readBuf);
DicConsole.WriteLine("Trying SEEK in CHS mode...");
sense = dev.Seek(out errorChs, 0, 0, 1, timeout, out duration);
report.ATA.ReadCapabilities.SupportsSeek = (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}",
sense, errorChs.status, errorChs.error);
report.ATA.ReadCapabilities.SupportsSeek =
(!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
errorChs.status, errorChs.error);
DicConsole.WriteLine("Trying READ SECTOR(S) in LBA mode...");
sense = dev.Read(out readBuf, out errorLba, false, 0, 1, timeout, out duration);
report.ATA.ReadCapabilities.SupportsReadLba = (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorLba.status, errorLba.error, readBuf.Length);
report.ATA.ReadCapabilities.SupportsReadLba =
(!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
errorLba.status, errorLba.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readsectors", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readsectors", "_debug_" + report.ATA.Model + ".bin",
"read results", readBuf);
DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in LBA mode...");
sense = dev.Read(out readBuf, out errorLba, true, 0, 1, timeout, out duration);
report.ATA.ReadCapabilities.SupportsReadRetryLba = (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorLba.status, errorLba.error, readBuf.Length);
report.ATA.ReadCapabilities.SupportsReadRetryLba =
(!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
errorLba.status, errorLba.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readsectorsretry", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readsectorsretry", "_debug_" + report.ATA.Model + ".bin",
"read results", readBuf);
DicConsole.WriteLine("Trying READ DMA in LBA mode...");
sense = dev.ReadDma(out readBuf, out errorLba, false, 0, 1, timeout, out duration);
report.ATA.ReadCapabilities.SupportsReadDmaLba = (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorLba.status, errorLba.error, readBuf.Length);
report.ATA.ReadCapabilities.SupportsReadDmaLba =
(!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
errorLba.status, errorLba.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readdma", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readdma", "_debug_" + report.ATA.Model + ".bin", "read results",
readBuf);
DicConsole.WriteLine("Trying READ DMA RETRY in LBA mode...");
sense = dev.ReadDma(out readBuf, out errorLba, true, 0, 1, timeout, out duration);
report.ATA.ReadCapabilities.SupportsReadDmaRetryLba = (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorLba.status, errorLba.error, readBuf.Length);
report.ATA.ReadCapabilities.SupportsReadDmaRetryLba =
(!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
errorLba.status, errorLba.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readdmaretry", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readdmaretry", "_debug_" + report.ATA.Model + ".bin",
"read results", readBuf);
DicConsole.WriteLine("Trying SEEK in LBA mode...");
sense = dev.Seek(out errorLba, 0, timeout, out duration);
report.ATA.ReadCapabilities.SupportsSeekLba = (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}",
sense, errorLba.status, errorLba.error);
report.ATA.ReadCapabilities.SupportsSeekLba =
(!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
errorLba.status, errorLba.error);
DicConsole.WriteLine("Trying READ SECTOR(S) in LBA48 mode...");
sense = dev.Read(out readBuf, out errorLba48, 0, 1, timeout, out duration);
report.ATA.ReadCapabilities.SupportsReadLba48 = (!sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorLba48.status, errorLba48.error, readBuf.Length);
report.ATA.ReadCapabilities.SupportsReadLba48 =
(!sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
errorLba48.status, errorLba48.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readsectors48", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readsectors48", "_debug_" + report.ATA.Model + ".bin",
"read results", readBuf);
DicConsole.WriteLine("Trying READ DMA in LBA48 mode...");
sense = dev.ReadDma(out readBuf, out errorLba48, 0, 1, timeout, out duration);
report.ATA.ReadCapabilities.SupportsReadDmaLba48 = (!sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorLba48.status, errorLba48.error, readBuf.Length);
report.ATA.ReadCapabilities.SupportsReadDmaLba48 =
(!sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
errorLba48.status, errorLba48.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readdma48", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readdma48", "_debug_" + report.ATA.Model + ".bin",
"read results", readBuf);
DicConsole.WriteLine("Trying READ LONG in CHS mode...");
sense = dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1, report.ATA.ReadCapabilities.LongBlockSize, timeout, out duration);
report.ATA.ReadCapabilities.SupportsReadLong = (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
sense = dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1,
report.ATA.ReadCapabilities.LongBlockSize, timeout, out duration);
report.ATA.ReadCapabilities.SupportsReadLong =
(!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 &&
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readlongchs", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readlongchs", "_debug_" + report.ATA.Model + ".bin",
"read results", readBuf);
DicConsole.WriteLine("Trying READ LONG RETRY in CHS mode...");
sense = dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1, report.ATA.ReadCapabilities.LongBlockSize, timeout, out duration);
report.ATA.ReadCapabilities.SupportsReadLongRetry = (!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorChs.status, errorChs.error, readBuf.Length);
sense = dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1,
report.ATA.ReadCapabilities.LongBlockSize, timeout, out duration);
report.ATA.ReadCapabilities.SupportsReadLongRetry =
(!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 &&
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
errorChs.status, errorChs.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readlongretrychs", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readlongretrychs", "_debug_" + report.ATA.Model + ".bin",
"read results", readBuf);
DicConsole.WriteLine("Trying READ LONG in LBA mode...");
sense = dev.ReadLong(out readBuf, out errorLba, false, 0, report.ATA.ReadCapabilities.LongBlockSize, timeout, out duration);
report.ATA.ReadCapabilities.SupportsReadLongLba = (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorLba.status, errorLba.error, readBuf.Length);
sense = dev.ReadLong(out readBuf, out errorLba, false, 0, report.ATA.ReadCapabilities.LongBlockSize,
timeout, out duration);
report.ATA.ReadCapabilities.SupportsReadLongLba =
(!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 &&
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
errorLba.status, errorLba.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readlong", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readlong", "_debug_" + report.ATA.Model + ".bin",
"read results", readBuf);
DicConsole.WriteLine("Trying READ LONG RETRY in LBA mode...");
sense = dev.ReadLong(out readBuf, out errorLba, true, 0, report.ATA.ReadCapabilities.LongBlockSize, timeout, out duration);
report.ATA.ReadCapabilities.SupportsReadLongRetryLba = (!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead);
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
sense, errorLba.status, errorLba.error, readBuf.Length);
sense = dev.ReadLong(out readBuf, out errorLba, true, 0, report.ATA.ReadCapabilities.LongBlockSize,
timeout, out duration);
report.ATA.ReadCapabilities.SupportsReadLongRetryLba =
(!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 &&
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead);
DicConsole.DebugWriteLine("ATA Report",
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
errorLba.status, errorLba.error, readBuf.Length);
if(debug)
DataFile.WriteTo("ATA Report", "readlongretry", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf);
DataFile.WriteTo("ATA Report", "readlongretry", "_debug_" + report.ATA.Model + ".bin",
"read results", readBuf);
}
}
}
}
}
}

View File

@@ -40,8 +40,7 @@ namespace DiscImageChef.Core.Devices.Report
{
public static void Report(Device dev, ref DeviceReport report, bool debug, ref bool removable)
{
if(report == null)
return;
if(report == null) return;
byte[] buffer;
double duration;
@@ -453,9 +452,8 @@ namespace DiscImageChef.Core.Devices.Report
report.ATAPI.WRVSectorCountMode2 = atapiId.WRVSectorCountMode2;
report.ATAPI.WRVSectorCountMode2Specified = true;
}
if(debug)
report.ATAPI.Identify = buffer;
if(debug) report.ATAPI.Identify = buffer;
}
}
}
}
}

View File

@@ -41,8 +41,7 @@ namespace DiscImageChef.Core.Devices.Report
{
public static void Report(Device dev, ref DeviceReport report, bool debug, ref bool removable)
{
if(report == null)
return;
if(report == null) return;
ConsoleKeyInfo pressedKey = new ConsoleKeyInfo();
while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
@@ -73,4 +72,4 @@ namespace DiscImageChef.Core.Devices.Report
}
}
}
}
}

View File

@@ -40,10 +40,9 @@ namespace DiscImageChef.Core.Devices.Report
{
public static void Report(Device dev, ref DeviceReport report, bool debug, ref bool removable)
{
if(report == null)
return;
if(report == null) return;
throw new NotImplementedException("NVMe devices not yet supported.");
}
}
}
}

View File

@@ -75,4 +75,4 @@ namespace DiscImageChef.Core.Devices.Report
}
}
}
}
}

View File

@@ -43,8 +43,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{
public static void Report(Device dev, ref DeviceReport report, bool debug, ref bool removable)
{
if(report == null)
return;
if(report == null) return;
byte[] senseBuffer;
byte[] buffer;
@@ -53,14 +52,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
uint timeout = 5;
ConsoleKeyInfo pressedKey;
if(dev.IsUSB)
USB.Report(dev, ref report, debug, ref removable);
if(dev.IsUSB) USB.Report(dev, ref report, debug, ref removable);
if(dev.IsFireWire)
FireWire.Report(dev, ref report, debug, ref removable);
if(dev.IsFireWire) FireWire.Report(dev, ref report, debug, ref removable);
if(dev.IsPCMCIA)
PCMCIA.Report(dev, ref report, debug, ref removable);
if(dev.IsPCMCIA) PCMCIA.Report(dev, ref report, debug, ref removable);
if(!dev.IsUSB && !dev.IsFireWire && dev.IsRemovable)
{
@@ -75,8 +71,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
removable = pressedKey.Key == ConsoleKey.Y;
}
if(dev.Type == DeviceType.ATAPI)
ATAPI.Report(dev, ref report, debug, ref removable);
if(dev.Type == DeviceType.ATAPI) ATAPI.Report(dev, ref report, debug, ref removable);
DicConsole.WriteLine("Querying SCSI INQUIRY...");
sense = dev.ScsiInquiry(out buffer, out senseBuffer);
@@ -117,19 +112,22 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
}
if(!string.IsNullOrWhiteSpace(StringHandlers.CToString(inq.VendorIdentification)))
{
report.SCSI.Inquiry.VendorIdentification = StringHandlers.CToString(inq.VendorIdentification).Trim();
report.SCSI.Inquiry.VendorIdentification =
StringHandlers.CToString(inq.VendorIdentification).Trim();
if(!string.IsNullOrWhiteSpace(report.SCSI.Inquiry.VendorIdentification))
report.SCSI.Inquiry.VendorIdentificationSpecified = true;
}
if(!string.IsNullOrWhiteSpace(StringHandlers.CToString(inq.ProductIdentification)))
{
report.SCSI.Inquiry.ProductIdentification = StringHandlers.CToString(inq.ProductIdentification).Trim();
report.SCSI.Inquiry.ProductIdentification =
StringHandlers.CToString(inq.ProductIdentification).Trim();
if(!string.IsNullOrWhiteSpace(report.SCSI.Inquiry.ProductIdentification))
report.SCSI.Inquiry.ProductIdentificationSpecified = true;
}
if(!string.IsNullOrWhiteSpace(StringHandlers.CToString(inq.ProductRevisionLevel)))
{
report.SCSI.Inquiry.ProductRevisionLevel = StringHandlers.CToString(inq.ProductRevisionLevel).Trim();
report.SCSI.Inquiry.ProductRevisionLevel =
StringHandlers.CToString(inq.ProductRevisionLevel).Trim();
if(!string.IsNullOrWhiteSpace(report.SCSI.Inquiry.ProductRevisionLevel))
report.SCSI.Inquiry.ProductRevisionLevelSpecified = true;
}
@@ -137,8 +135,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{
foreach(ushort descriptor in inq.VersionDescriptors)
{
if(descriptor != 0)
versionDescriptors.Add(descriptor);
if(descriptor != 0) versionDescriptors.Add(descriptor);
}
if(versionDescriptors.Count > 0)
@@ -146,7 +143,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
}
report.SCSI.Inquiry.PeripheralQualifier = (Decoders.SCSI.PeripheralQualifiers)inq.PeripheralQualifier;
report.SCSI.Inquiry.PeripheralDeviceType = (Decoders.SCSI.PeripheralDeviceTypes)inq.PeripheralDeviceType;
report.SCSI.Inquiry.PeripheralDeviceType =
(Decoders.SCSI.PeripheralDeviceTypes)inq.PeripheralDeviceType;
report.SCSI.Inquiry.AsymmetricalLUNAccess = (Decoders.SCSI.TGPSValues)inq.TPGS;
report.SCSI.Inquiry.SPIClocking = (Decoders.SCSI.SPIClocking)inq.Clocking;
@@ -177,8 +175,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
report.SCSI.Inquiry.WideBus16 = inq.WBus16;
report.SCSI.Inquiry.WideBus32 = inq.WBus32;
if(debug)
report.SCSI.Inquiry.Data = buffer;
if(debug) report.SCSI.Inquiry.Data = buffer;
}
DicConsole.WriteLine("Querying list of SCSI EVPDs...");
@@ -205,8 +202,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
}
}
}
if(evpds.Count > 0)
report.SCSI.EVPDPages = evpds.ToArray();
if(evpds.Count > 0) report.SCSI.EVPDPages = evpds.ToArray();
}
}
@@ -231,11 +228,13 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
Decoders.SCSI.PeripheralDeviceTypes devType = dev.SCSIType;
DicConsole.WriteLine("Querying all mode pages and subpages using SCSI MODE SENSE (10)...");
sense = dev.ModeSense10(out byte[] mode10Buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Default, 0x3F, 0xFF, timeout, out duration);
sense = dev.ModeSense10(out byte[] mode10Buffer, out senseBuffer, false, true,
ScsiModeSensePageControl.Default, 0x3F, 0xFF, timeout, out duration);
if(sense || dev.Error)
{
DicConsole.WriteLine("Querying all mode pages using SCSI MODE SENSE (10)...");
sense = dev.ModeSense10(out mode10Buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Default, 0x3F, 0x00, timeout, out duration);
sense = dev.ModeSense10(out mode10Buffer, out senseBuffer, false, true,
ScsiModeSensePageControl.Default, 0x3F, 0x00, timeout, out duration);
if(!sense && !dev.Error)
{
report.SCSI.SupportsModeSense10 = true;
@@ -251,19 +250,20 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
}
DicConsole.WriteLine("Querying all mode pages and subpages using SCSI MODE SENSE (6)...");
sense = dev.ModeSense6(out byte[] mode6Buffer, out senseBuffer, false, ScsiModeSensePageControl.Default, 0x3F, 0xFF, timeout, out duration);
sense = dev.ModeSense6(out byte[] mode6Buffer, out senseBuffer, false, ScsiModeSensePageControl.Default,
0x3F, 0xFF, timeout, out duration);
if(sense || dev.Error)
{
DicConsole.WriteLine("Querying all mode pages using SCSI MODE SENSE (6)...");
sense = dev.ModeSense6(out mode6Buffer, out senseBuffer, false, ScsiModeSensePageControl.Default, 0x3F, 0x00, timeout, out duration);
sense = dev.ModeSense6(out mode6Buffer, out senseBuffer, false, ScsiModeSensePageControl.Default, 0x3F,
0x00, timeout, out duration);
if(sense || dev.Error)
{
DicConsole.WriteLine("Querying SCSI MODE SENSE (6)...");
sense = dev.ModeSense(out mode6Buffer, out senseBuffer, timeout, out duration);
}
}
else
report.SCSI.SupportsModeSubpages = true;
else report.SCSI.SupportsModeSubpages = true;
if(!sense && !dev.Error && !decMode.HasValue)
decMode = Decoders.SCSI.Modes.DecodeMode6(mode6Buffer, devType);
@@ -272,10 +272,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
Decoders.SCSI.Modes.ModePage_2A? cdromMode = null;
if(debug && report.SCSI.SupportsModeSense6)
report.SCSI.ModeSense6Data = mode6Buffer;
if(debug && report.SCSI.SupportsModeSense10)
report.SCSI.ModeSense10Data = mode10Buffer;
if(debug && report.SCSI.SupportsModeSense6) report.SCSI.ModeSense6Data = mode6Buffer;
if(debug && report.SCSI.SupportsModeSense10) report.SCSI.ModeSense10Data = mode10Buffer;
if(decMode.HasValue)
{
@@ -313,8 +311,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
}
}
if(modePages.Count > 0)
report.SCSI.ModeSense.ModePages = modePages.ToArray();
if(modePages.Count > 0) report.SCSI.ModeSense.ModePages = modePages.ToArray();
}
}
@@ -372,8 +369,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.Write("\rWaiting for drive to become ready");
System.Threading.Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration);
if(!sense)
break;
if(!sense) break;
leftRetries--;
}
@@ -388,19 +384,16 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.Write("\rWaiting for drive to become ready");
System.Threading.Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration);
if(!sense)
break;
if(!sense) break;
leftRetries--;
}
mediaTest.MediaIsRecognized &= !sense;
}
else
mediaTest.MediaIsRecognized = false;
else mediaTest.MediaIsRecognized = false;
}
else
mediaTest.MediaIsRecognized = false;
else mediaTest.MediaIsRecognized = false;
}
if(mediaTest.MediaIsRecognized)
@@ -413,8 +406,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
if(!sense && !dev.Error)
{
mediaTest.SupportsReadCapacity = true;
mediaTest.Blocks = (ulong)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + (buffer[3])) + 1;
mediaTest.BlockSize = (uint)((buffer[4] << 24) + (buffer[5] << 16) + (buffer[6] << 8) + (buffer[7]));
mediaTest.Blocks =
(ulong)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) +
(buffer[3])) + 1;
mediaTest.BlockSize =
(uint)((buffer[4] << 24) + (buffer[5] << 16) + (buffer[6] << 8) + (buffer[7]));
mediaTest.BlocksSpecified = true;
mediaTest.BlockSizeSpecified = true;
}
@@ -428,7 +424,9 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
Array.Copy(buffer, 0, temp, 0, 8);
Array.Reverse(temp);
mediaTest.Blocks = BitConverter.ToUInt64(temp, 0) + 1;
mediaTest.BlockSize = (uint)((buffer[8] << 24) + (buffer[9] << 16) + (buffer[10] << 8) + (buffer[11]));
mediaTest.BlockSize =
(uint)((buffer[8] << 24) + (buffer[9] << 16) + (buffer[10] << 8) +
(buffer[11]));
mediaTest.BlocksSpecified = true;
mediaTest.BlockSizeSpecified = true;
}
@@ -436,13 +434,14 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
decMode = null;
DicConsole.WriteLine("Querying SCSI MODE SENSE (10)...");
sense = dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Current, 0x3F, 0x00, timeout, out duration);
sense = dev.ModeSense10(out buffer, out senseBuffer, false, true,
ScsiModeSensePageControl.Current, 0x3F, 0x00, timeout,
out duration);
if(!sense && !dev.Error)
{
report.SCSI.SupportsModeSense10 = true;
decMode = Decoders.SCSI.Modes.DecodeMode10(buffer, dev.SCSIType);
if(debug)
mediaTest.ModeSense10Data = buffer;
if(debug) mediaTest.ModeSense10Data = buffer;
}
DicConsole.WriteLine("Querying SCSI MODE SENSE...");
@@ -452,15 +451,15 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
report.SCSI.SupportsModeSense6 = true;
if(!decMode.HasValue)
decMode = Decoders.SCSI.Modes.DecodeMode6(buffer, dev.SCSIType);
if(debug)
mediaTest.ModeSense6Data = buffer;
if(debug) mediaTest.ModeSense6Data = buffer;
}
if(decMode.HasValue)
{
mediaTest.MediumType = (byte)decMode.Value.Header.MediumType;
mediaTest.MediumTypeSpecified = true;
if(decMode.Value.Header.BlockDescriptors != null && decMode.Value.Header.BlockDescriptors.Length > 0)
if(decMode.Value.Header.BlockDescriptors != null &&
decMode.Value.Header.BlockDescriptors.Length > 0)
{
mediaTest.Density = (byte)decMode.Value.Header.BlockDescriptors[0].Density;
mediaTest.DensitySpecified = true;
@@ -474,44 +473,61 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.SupportsReadLongSpecified = true;
DicConsole.WriteLine("Trying SCSI READ (6)...");
mediaTest.SupportsRead = !dev.Read6(out buffer, out senseBuffer, 0, mediaTest.BlockSize, timeout, out duration);
mediaTest.SupportsRead = !dev.Read6(out buffer, out senseBuffer, 0, mediaTest.BlockSize,
timeout, out duration);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead);
if(debug)
DataFile.WriteTo("SCSI Report", "read6", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", buffer);
DataFile.WriteTo("SCSI Report", "read6",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
buffer);
DicConsole.WriteLine("Trying SCSI READ (10)...");
mediaTest.SupportsRead10 = !dev.Read10(out buffer, out senseBuffer, 0, false, true, false, false, 0, mediaTest.BlockSize, 0, 1, timeout, out duration);
mediaTest.SupportsRead10 =
!dev.Read10(out buffer, out senseBuffer, 0, false, true, false, false, 0,
mediaTest.BlockSize, 0, 1, timeout, out duration);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead10);
if(debug)
DataFile.WriteTo("SCSI Report", "read10", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", buffer);
DataFile.WriteTo("SCSI Report", "read10",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
buffer);
DicConsole.WriteLine("Trying SCSI READ (12)...");
mediaTest.SupportsRead12 = !dev.Read12(out buffer, out senseBuffer, 0, false, true, false, false, 0, mediaTest.BlockSize, 0, 1, false, timeout, out duration);
mediaTest.SupportsRead12 =
!dev.Read12(out buffer, out senseBuffer, 0, false, true, false, false, 0,
mediaTest.BlockSize, 0, 1, false, timeout, out duration);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead12);
if(debug)
DataFile.WriteTo("SCSI Report", "read12", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", buffer);
DataFile.WriteTo("SCSI Report", "read12",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
buffer);
DicConsole.WriteLine("Trying SCSI READ (16)...");
mediaTest.SupportsRead16 = !dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 0, mediaTest.BlockSize, 0, 1, false, timeout, out duration);
mediaTest.SupportsRead16 =
!dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 0,
mediaTest.BlockSize, 0, 1, false, timeout, out duration);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead16);
if(debug)
DataFile.WriteTo("SCSI Report", "read16", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", buffer);
DataFile.WriteTo("SCSI Report", "read16",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
buffer);
mediaTest.LongBlockSize = mediaTest.BlockSize;
DicConsole.WriteLine("Trying SCSI READ LONG (10)...");
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 0xFFFF, timeout, out duration);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 0xFFFF, timeout,
out duration);
if(sense && !dev.Error)
{
Decoders.SCSI.FixedSense? decSense = Decoders.SCSI.Sense.DecodeFixed(senseBuffer);
if(decSense.HasValue)
{
if(decSense.Value.SenseKey == Decoders.SCSI.SenseKeys.IllegalRequest &&
decSense.Value.ASC == 0x24 && decSense.Value.ASCQ == 0x00)
decSense.Value.ASC == 0x24 && decSense.Value.ASCQ == 0x00)
{
mediaTest.SupportsReadLong = true;
if(decSense.Value.InformationValid && decSense.Value.ILI)
{
mediaTest.LongBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF);
mediaTest.LongBlockSize =
0xFFFF - (decSense.Value.Information & 0xFFFF);
mediaTest.LongBlockSizeSpecified = true;
}
}
@@ -522,15 +538,18 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{
if(mediaTest.BlockSize == 512)
{
foreach(ushort testSize in new[] {
foreach(ushort testSize in new[]
{
// Long sector sizes for floppies
514,
// Long sector sizes for SuperDisk
536, 558,
// Long sector sizes for 512-byte magneto-opticals
600, 610, 630 })
600, 610, 630
})
{
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize, timeout, out duration);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
testSize, timeout, out duration);
if(!sense && !dev.Error)
{
mediaTest.SupportsReadLong = true;
@@ -542,13 +561,16 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
}
else if(mediaTest.BlockSize == 1024)
{
foreach(ushort testSize in new[] {
foreach(ushort testSize in new[]
{
// Long sector sizes for floppies
1026,
// Long sector sizes for 1024-byte magneto-opticals
1200 })
1200
})
{
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize, timeout, out duration);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
testSize, timeout, out duration);
if(!sense && !dev.Error)
{
mediaTest.SupportsReadLong = true;
@@ -560,7 +582,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
}
else if(mediaTest.BlockSize == 2048)
{
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380, timeout, out duration);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380,
timeout, out duration);
if(!sense && !dev.Error)
{
mediaTest.SupportsReadLong = true;
@@ -570,7 +593,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
}
else if(mediaTest.BlockSize == 4096)
{
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 4760, timeout, out duration);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 4760,
timeout, out duration);
if(!sense && !dev.Error)
{
mediaTest.SupportsReadLong = true;
@@ -580,7 +604,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
}
else if(mediaTest.BlockSize == 8192)
{
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 9424, timeout, out duration);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 9424,
timeout, out duration);
if(!sense && !dev.Error)
{
mediaTest.SupportsReadLong = true;
@@ -595,7 +620,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
pressedKey = new ConsoleKeyInfo();
while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
DicConsole.Write("Drive supports SCSI READ LONG but I cannot find the correct size. Do you want me to try? (This can take hours) (Y/N): ");
DicConsole
.Write("Drive supports SCSI READ LONG but I cannot find the correct size. Do you want me to try? (This can take hours) (Y/N): ");
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
@@ -605,7 +631,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
for(ushort i = (ushort)mediaTest.BlockSize; i <= ushort.MaxValue; i++)
{
DicConsole.Write("\rTrying to READ LONG with a size of {0} bytes...", i);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, i, timeout, out duration);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, i,
timeout, out duration);
if(!sense)
{
mediaTest.LongBlockSize = i;
@@ -613,27 +640,34 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
break;
}
if(i == ushort.MaxValue)
break;
if(i == ushort.MaxValue) break;
}
DicConsole.WriteLine();
}
}
if(debug && mediaTest.SupportsReadLong && mediaTest.LongBlockSizeSpecified && mediaTest.LongBlockSize != mediaTest.BlockSize)
if(debug && mediaTest.SupportsReadLong && mediaTest.LongBlockSizeSpecified &&
mediaTest.LongBlockSize != mediaTest.BlockSize)
{
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, (ushort)mediaTest.LongBlockSize, timeout, out duration);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
(ushort)mediaTest.LongBlockSize, timeout, out duration);
if(!sense)
DataFile.WriteTo("SCSI Report", "readlong10", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", buffer);
DataFile.WriteTo("SCSI Report", "readlong10",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
buffer);
}
mediaTest.CanReadMediaSerialSpecified = true;
DicConsole.WriteLine("Trying SCSI READ MEDIA SERIAL NUMBER...");
mediaTest.CanReadMediaSerial = !dev.ReadMediaSerialNumber(out buffer, out senseBuffer, timeout, out duration);
mediaTest.CanReadMediaSerial =
!dev.ReadMediaSerialNumber(out buffer, out senseBuffer, timeout, out duration);
}
mediaTests.Add(mediaTest);
}
}
report.SCSI.RemovableMedias = mediaTests.ToArray();
}
else
@@ -650,8 +684,10 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
if(!sense && !dev.Error)
{
report.SCSI.ReadCapabilities.SupportsReadCapacity = true;
report.SCSI.ReadCapabilities.Blocks = (ulong)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + (buffer[3])) + 1;
report.SCSI.ReadCapabilities.BlockSize = (uint)((buffer[4] << 24) + (buffer[5] << 16) + (buffer[6] << 8) + (buffer[7]));
report.SCSI.ReadCapabilities.Blocks =
(ulong)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + (buffer[3])) + 1;
report.SCSI.ReadCapabilities.BlockSize =
(uint)((buffer[4] << 24) + (buffer[5] << 16) + (buffer[6] << 8) + (buffer[7]));
report.SCSI.ReadCapabilities.BlocksSpecified = true;
report.SCSI.ReadCapabilities.BlockSizeSpecified = true;
}
@@ -665,7 +701,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
Array.Copy(buffer, 0, temp, 0, 8);
Array.Reverse(temp);
report.SCSI.ReadCapabilities.Blocks = BitConverter.ToUInt64(temp, 0) + 1;
report.SCSI.ReadCapabilities.BlockSize = (uint)((buffer[8] << 24) + (buffer[9] << 16) + (buffer[10] << 8) + (buffer[11]));
report.SCSI.ReadCapabilities.BlockSize =
(uint)((buffer[8] << 24) + (buffer[9] << 16) + (buffer[10] << 8) + (buffer[11]));
report.SCSI.ReadCapabilities.BlocksSpecified = true;
report.SCSI.ReadCapabilities.BlockSizeSpecified = true;
}
@@ -673,13 +710,13 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
decMode = null;
DicConsole.WriteLine("Querying SCSI MODE SENSE (10)...");
sense = dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Current, 0x3F, 0x00, timeout, out duration);
sense = dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Current,
0x3F, 0x00, timeout, out duration);
if(!sense && !dev.Error)
{
report.SCSI.SupportsModeSense10 = true;
decMode = Decoders.SCSI.Modes.DecodeMode10(buffer, dev.SCSIType);
if(debug)
report.SCSI.ReadCapabilities.ModeSense10Data = buffer;
if(debug) report.SCSI.ReadCapabilities.ModeSense10Data = buffer;
}
DicConsole.WriteLine("Querying SCSI MODE SENSE...");
@@ -687,19 +724,19 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
if(!sense && !dev.Error)
{
report.SCSI.SupportsModeSense6 = true;
if(!decMode.HasValue)
decMode = Decoders.SCSI.Modes.DecodeMode6(buffer, dev.SCSIType);
if(debug)
report.SCSI.ReadCapabilities.ModeSense6Data = buffer;
if(!decMode.HasValue) decMode = Decoders.SCSI.Modes.DecodeMode6(buffer, dev.SCSIType);
if(debug) report.SCSI.ReadCapabilities.ModeSense6Data = buffer;
}
if(decMode.HasValue)
{
report.SCSI.ReadCapabilities.MediumType = (byte)decMode.Value.Header.MediumType;
report.SCSI.ReadCapabilities.MediumTypeSpecified = true;
if(decMode.Value.Header.BlockDescriptors != null && decMode.Value.Header.BlockDescriptors.Length > 0)
if(decMode.Value.Header.BlockDescriptors != null &&
decMode.Value.Header.BlockDescriptors.Length > 0)
{
report.SCSI.ReadCapabilities.Density = (byte)decMode.Value.Header.BlockDescriptors[0].Density;
report.SCSI.ReadCapabilities.Density =
(byte)decMode.Value.Header.BlockDescriptors[0].Density;
report.SCSI.ReadCapabilities.DensitySpecified = true;
}
}
@@ -711,28 +748,47 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
report.SCSI.ReadCapabilities.SupportsReadLongSpecified = true;
DicConsole.WriteLine("Trying SCSI READ (6)...");
report.SCSI.ReadCapabilities.SupportsRead = !dev.Read6(out buffer, out senseBuffer, 0, report.SCSI.ReadCapabilities.BlockSize, timeout, out duration);
report.SCSI.ReadCapabilities.SupportsRead = !dev.Read6(out buffer, out senseBuffer, 0,
report.SCSI.ReadCapabilities.BlockSize,
timeout, out duration);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !report.SCSI.ReadCapabilities.SupportsRead);
if(debug)
DataFile.WriteTo("SCSI Report", "read6", "_debug_" + report.SCSI.Inquiry.ProductIdentification + ".bin", "read results", buffer);
DataFile.WriteTo("SCSI Report", "read6",
"_debug_" + report.SCSI.Inquiry.ProductIdentification + ".bin", "read results",
buffer);
DicConsole.WriteLine("Trying SCSI READ (10)...");
report.SCSI.ReadCapabilities.SupportsRead10 = !dev.Read10(out buffer, out senseBuffer, 0, false, true, false, false, 0, report.SCSI.ReadCapabilities.BlockSize, 0, 1, timeout, out duration);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !report.SCSI.ReadCapabilities.SupportsRead10);
report.SCSI.ReadCapabilities.SupportsRead10 =
!dev.Read10(out buffer, out senseBuffer, 0, false, true, false, false, 0,
report.SCSI.ReadCapabilities.BlockSize, 0, 1, timeout, out duration);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!report.SCSI.ReadCapabilities.SupportsRead10);
if(debug)
DataFile.WriteTo("SCSI Report", "read10", "_debug_" + report.SCSI.Inquiry.ProductIdentification + ".bin", "read results", buffer);
DataFile.WriteTo("SCSI Report", "read10",
"_debug_" + report.SCSI.Inquiry.ProductIdentification + ".bin", "read results",
buffer);
DicConsole.WriteLine("Trying SCSI READ (12)...");
report.SCSI.ReadCapabilities.SupportsRead12 = !dev.Read12(out buffer, out senseBuffer, 0, false, true, false, false, 0, report.SCSI.ReadCapabilities.BlockSize, 0, 1, false, timeout, out duration);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !report.SCSI.ReadCapabilities.SupportsRead12);
report.SCSI.ReadCapabilities.SupportsRead12 =
!dev.Read12(out buffer, out senseBuffer, 0, false, true, false, false, 0,
report.SCSI.ReadCapabilities.BlockSize, 0, 1, false, timeout, out duration);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!report.SCSI.ReadCapabilities.SupportsRead12);
if(debug)
DataFile.WriteTo("SCSI Report", "read12", "_debug_" + report.SCSI.Inquiry.ProductIdentification + ".bin", "read results", buffer);
DataFile.WriteTo("SCSI Report", "read12",
"_debug_" + report.SCSI.Inquiry.ProductIdentification + ".bin", "read results",
buffer);
DicConsole.WriteLine("Trying SCSI READ (16)...");
report.SCSI.ReadCapabilities.SupportsRead16 = !dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 0, report.SCSI.ReadCapabilities.BlockSize, 0, 1, false, timeout, out duration);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !report.SCSI.ReadCapabilities.SupportsRead16);
report.SCSI.ReadCapabilities.SupportsRead16 =
!dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 0,
report.SCSI.ReadCapabilities.BlockSize, 0, 1, false, timeout, out duration);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!report.SCSI.ReadCapabilities.SupportsRead16);
if(debug)
DataFile.WriteTo("SCSI Report", "read16", "_debug_" + report.SCSI.Inquiry.ProductIdentification + ".bin", "read results", buffer);
DataFile.WriteTo("SCSI Report", "read16",
"_debug_" + report.SCSI.Inquiry.ProductIdentification + ".bin", "read results",
buffer);
report.SCSI.ReadCapabilities.LongBlockSize = report.SCSI.ReadCapabilities.BlockSize;
DicConsole.WriteLine("Trying SCSI READ LONG (10)...");
@@ -743,19 +799,21 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
if(decSense.HasValue)
{
if(decSense.Value.SenseKey == Decoders.SCSI.SenseKeys.IllegalRequest &&
decSense.Value.ASC == 0x24 && decSense.Value.ASCQ == 0x00)
decSense.Value.ASC == 0x24 && decSense.Value.ASCQ == 0x00)
{
report.SCSI.ReadCapabilities.SupportsReadLong = true;
if(decSense.Value.InformationValid && decSense.Value.ILI)
{
report.SCSI.ReadCapabilities.LongBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF);
report.SCSI.ReadCapabilities.LongBlockSize =
0xFFFF - (decSense.Value.Information & 0xFFFF);
report.SCSI.ReadCapabilities.LongBlockSizeSpecified = true;
}
}
}
}
if(report.SCSI.ReadCapabilities.SupportsReadLong && report.SCSI.ReadCapabilities.LongBlockSize == report.SCSI.ReadCapabilities.BlockSize)
if(report.SCSI.ReadCapabilities.SupportsReadLong && report.SCSI.ReadCapabilities.LongBlockSize ==
report.SCSI.ReadCapabilities.BlockSize)
{
if(report.SCSI.ReadCapabilities.BlockSize == 512)
{
@@ -803,7 +861,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
}
else if(report.SCSI.ReadCapabilities.BlockSize == 2048)
{
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380, timeout, out duration);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380, timeout,
out duration);
if(!sense && !dev.Error)
{
report.SCSI.ReadCapabilities.SupportsReadLong = true;
@@ -813,7 +872,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
}
else if(report.SCSI.ReadCapabilities.BlockSize == 4096)
{
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 4760, timeout, out duration);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 4760, timeout,
out duration);
if(!sense && !dev.Error)
{
report.SCSI.ReadCapabilities.SupportsReadLong = true;
@@ -823,7 +883,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
}
else if(report.SCSI.ReadCapabilities.BlockSize == 8192)
{
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 9424, timeout, out duration);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 9424, timeout,
out duration);
if(!sense && !dev.Error)
{
report.SCSI.ReadCapabilities.SupportsReadLong = true;
@@ -833,12 +894,14 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
}
}
if(report.SCSI.ReadCapabilities.SupportsReadLong && report.SCSI.ReadCapabilities.LongBlockSize == report.SCSI.ReadCapabilities.BlockSize)
if(report.SCSI.ReadCapabilities.SupportsReadLong && report.SCSI.ReadCapabilities.LongBlockSize ==
report.SCSI.ReadCapabilities.BlockSize)
{
pressedKey = new ConsoleKeyInfo();
while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
DicConsole.Write("Drive supports SCSI READ LONG but I cannot find the correct size. Do you want me to try? (This can take hours) (Y/N): ");
DicConsole
.Write("Drive supports SCSI READ LONG but I cannot find the correct size. Do you want me to try? (This can take hours) (Y/N): ");
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
@@ -848,12 +911,15 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
for(ushort i = (ushort)report.SCSI.ReadCapabilities.BlockSize; i <= ushort.MaxValue; i++)
{
DicConsole.Write("\rTrying to READ LONG with a size of {0} bytes...", i);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, i, timeout, out duration);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, i, timeout,
out duration);
if(!sense)
{
if(debug)
{
FileStream bingo = new FileStream(string.Format("{0}_readlong.bin", dev.Model), FileMode.Create);
FileStream bingo =
new FileStream(string.Format("{0}_readlong.bin", dev.Model),
FileMode.Create);
bingo.Write(buffer, 0, buffer.Length);
bingo.Close();
}
@@ -862,21 +928,27 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
break;
}
if(i == ushort.MaxValue)
break;
if(i == ushort.MaxValue) break;
}
DicConsole.WriteLine();
}
}
if(debug && report.SCSI.ReadCapabilities.SupportsReadLong && report.SCSI.ReadCapabilities.LongBlockSizeSpecified && report.SCSI.ReadCapabilities.LongBlockSize != report.SCSI.ReadCapabilities.BlockSize)
if(debug && report.SCSI.ReadCapabilities.SupportsReadLong &&
report.SCSI.ReadCapabilities.LongBlockSizeSpecified &&
report.SCSI.ReadCapabilities.LongBlockSize != report.SCSI.ReadCapabilities.BlockSize)
{
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, (ushort)report.SCSI.ReadCapabilities.LongBlockSize, timeout, out duration);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
(ushort)report.SCSI.ReadCapabilities.LongBlockSize, timeout,
out duration);
if(!sense)
DataFile.WriteTo("SCSI Report", "readlong10", "_debug_" + report.SCSI.Inquiry.ProductIdentification + ".bin", "read results", buffer);
DataFile.WriteTo("SCSI Report", "readlong10",
"_debug_" + report.SCSI.Inquiry.ProductIdentification + ".bin",
"read results", buffer);
}
}
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -42,8 +42,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{
internal static void Report(Device dev, ref DeviceReport report, bool debug)
{
if(report == null)
return;
if(report == null) return;
byte[] senseBuffer;
byte[] buffer;
@@ -83,21 +82,29 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
sense = dev.ReportDensitySupport(out buffer, out senseBuffer, false, false, timeout, out duration);
if(!sense)
{
Decoders.SCSI.SSC.DensitySupport.DensitySupportHeader? dsh = Decoders.SCSI.SSC.DensitySupport.DecodeDensity(buffer);
Decoders.SCSI.SSC.DensitySupport.DensitySupportHeader? dsh =
Decoders.SCSI.SSC.DensitySupport.DecodeDensity(buffer);
if(dsh.HasValue)
{
report.SCSI.SequentialDevice.SupportedDensities = new SupportedDensity[dsh.Value.descriptors.Length];
report.SCSI.SequentialDevice.SupportedDensities =
new SupportedDensity[dsh.Value.descriptors.Length];
for(int i = 0; i < dsh.Value.descriptors.Length; i++)
{
report.SCSI.SequentialDevice.SupportedDensities[i].BitsPerMm = dsh.Value.descriptors[i].bpmm;
report.SCSI.SequentialDevice.SupportedDensities[i].Capacity = dsh.Value.descriptors[i].capacity;
report.SCSI.SequentialDevice.SupportedDensities[i].DefaultDensity = dsh.Value.descriptors[i].defaultDensity;
report.SCSI.SequentialDevice.SupportedDensities[i].Description = dsh.Value.descriptors[i].description;
report.SCSI.SequentialDevice.SupportedDensities[i].Duplicate = dsh.Value.descriptors[i].duplicate;
report.SCSI.SequentialDevice.SupportedDensities[i].DefaultDensity =
dsh.Value.descriptors[i].defaultDensity;
report.SCSI.SequentialDevice.SupportedDensities[i].Description =
dsh.Value.descriptors[i].description;
report.SCSI.SequentialDevice.SupportedDensities[i].Duplicate =
dsh.Value.descriptors[i].duplicate;
report.SCSI.SequentialDevice.SupportedDensities[i].Name = dsh.Value.descriptors[i].name;
report.SCSI.SequentialDevice.SupportedDensities[i].Organization = dsh.Value.descriptors[i].organization;
report.SCSI.SequentialDevice.SupportedDensities[i].PrimaryCode = dsh.Value.descriptors[i].primaryCode;
report.SCSI.SequentialDevice.SupportedDensities[i].SecondaryCode = dsh.Value.descriptors[i].secondaryCode;
report.SCSI.SequentialDevice.SupportedDensities[i].Organization =
dsh.Value.descriptors[i].organization;
report.SCSI.SequentialDevice.SupportedDensities[i].PrimaryCode =
dsh.Value.descriptors[i].primaryCode;
report.SCSI.SequentialDevice.SupportedDensities[i].SecondaryCode =
dsh.Value.descriptors[i].secondaryCode;
report.SCSI.SequentialDevice.SupportedDensities[i].Tracks = dsh.Value.descriptors[i].tracks;
report.SCSI.SequentialDevice.SupportedDensities[i].Width = dsh.Value.descriptors[i].width;
report.SCSI.SequentialDevice.SupportedDensities[i].Writable = dsh.Value.descriptors[i].writable;
@@ -109,23 +116,30 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
sense = dev.ReportDensitySupport(out buffer, out senseBuffer, true, false, timeout, out duration);
if(!sense)
{
Decoders.SCSI.SSC.DensitySupport.MediaTypeSupportHeader? mtsh = Decoders.SCSI.SSC.DensitySupport.DecodeMediumType(buffer);
Decoders.SCSI.SSC.DensitySupport.MediaTypeSupportHeader? mtsh =
Decoders.SCSI.SSC.DensitySupport.DecodeMediumType(buffer);
if(mtsh.HasValue)
{
report.SCSI.SequentialDevice.SupportedMediaTypes = new SupportedMedia[mtsh.Value.descriptors.Length];
report.SCSI.SequentialDevice.SupportedMediaTypes =
new SupportedMedia[mtsh.Value.descriptors.Length];
for(int i = 0; i < mtsh.Value.descriptors.Length; i++)
{
report.SCSI.SequentialDevice.SupportedMediaTypes[i].Description = mtsh.Value.descriptors[i].description;
report.SCSI.SequentialDevice.SupportedMediaTypes[i].Description =
mtsh.Value.descriptors[i].description;
report.SCSI.SequentialDevice.SupportedMediaTypes[i].Length = mtsh.Value.descriptors[i].length;
report.SCSI.SequentialDevice.SupportedMediaTypes[i].MediumType = mtsh.Value.descriptors[i].mediumType;
report.SCSI.SequentialDevice.SupportedMediaTypes[i].MediumType =
mtsh.Value.descriptors[i].mediumType;
report.SCSI.SequentialDevice.SupportedMediaTypes[i].Name = mtsh.Value.descriptors[i].name;
report.SCSI.SequentialDevice.SupportedMediaTypes[i].Organization = mtsh.Value.descriptors[i].organization;
report.SCSI.SequentialDevice.SupportedMediaTypes[i].Organization =
mtsh.Value.descriptors[i].organization;
report.SCSI.SequentialDevice.SupportedMediaTypes[i].Width = mtsh.Value.descriptors[i].width;
if(mtsh.Value.descriptors[i].densityCodes != null)
{
report.SCSI.SequentialDevice.SupportedMediaTypes[i].DensityCodes = new int[mtsh.Value.descriptors[i].densityCodes.Length];
report.SCSI.SequentialDevice.SupportedMediaTypes[i].DensityCodes =
new int[mtsh.Value.descriptors[i].densityCodes.Length];
for(int j = 0; j < mtsh.Value.descriptors.Length; j++)
report.SCSI.SequentialDevice.SupportedMediaTypes[i].DensityCodes[j] = mtsh.Value.descriptors[i].densityCodes[j];
report.SCSI.SequentialDevice.SupportedMediaTypes[i].DensityCodes[j] =
mtsh.Value.descriptors[i].densityCodes[j];
}
}
}
@@ -174,8 +188,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.Write("\rWaiting for drive to become ready");
System.Threading.Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration);
if(!sense)
break;
if(!sense) break;
leftRetries--;
}
@@ -190,19 +203,16 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.Write("\rWaiting for drive to become ready");
System.Threading.Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration);
if(!sense)
break;
if(!sense) break;
leftRetries--;
}
seqTest.MediaIsRecognized &= !sense;
}
else
seqTest.MediaIsRecognized = false;
else seqTest.MediaIsRecognized = false;
}
else
seqTest.MediaIsRecognized = false;
else seqTest.MediaIsRecognized = false;
}
if(seqTest.MediaIsRecognized)
@@ -210,13 +220,13 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
decMode = null;
DicConsole.WriteLine("Querying SCSI MODE SENSE (10)...");
sense = dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Current, 0x3F, 0x00, timeout, out duration);
sense = dev.ModeSense10(out buffer, out senseBuffer, false, true,
ScsiModeSensePageControl.Current, 0x3F, 0x00, timeout, out duration);
if(!sense && !dev.Error)
{
report.SCSI.SupportsModeSense10 = true;
decMode = Decoders.SCSI.Modes.DecodeMode10(buffer, dev.SCSIType);
if(debug)
seqTest.ModeSense10Data = buffer;
if(debug) seqTest.ModeSense10Data = buffer;
}
DicConsole.WriteLine("Querying SCSI MODE SENSE...");
@@ -224,17 +234,16 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
if(!sense && !dev.Error)
{
report.SCSI.SupportsModeSense6 = true;
if(!decMode.HasValue)
decMode = Decoders.SCSI.Modes.DecodeMode6(buffer, dev.SCSIType);
if(debug)
seqTest.ModeSense6Data = buffer;
if(!decMode.HasValue) decMode = Decoders.SCSI.Modes.DecodeMode6(buffer, dev.SCSIType);
if(debug) seqTest.ModeSense6Data = buffer;
}
if(decMode.HasValue)
{
seqTest.MediumType = (byte)decMode.Value.Header.MediumType;
seqTest.MediumTypeSpecified = true;
if(decMode.Value.Header.BlockDescriptors != null && decMode.Value.Header.BlockDescriptors.Length > 0)
if(decMode.Value.Header.BlockDescriptors != null &&
decMode.Value.Header.BlockDescriptors.Length > 0)
{
seqTest.Density = (byte)decMode.Value.Header.BlockDescriptors[0].Density;
seqTest.DensitySpecified = true;
@@ -246,7 +255,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
sense = dev.ReportDensitySupport(out buffer, out senseBuffer, false, true, timeout, out duration);
if(!sense)
{
Decoders.SCSI.SSC.DensitySupport.DensitySupportHeader? dsh = Decoders.SCSI.SSC.DensitySupport.DecodeDensity(buffer);
Decoders.SCSI.SSC.DensitySupport.DensitySupportHeader? dsh =
Decoders.SCSI.SSC.DensitySupport.DecodeDensity(buffer);
if(dsh.HasValue)
{
seqTest.SupportedDensities = new SupportedDensity[dsh.Value.descriptors.Length];
@@ -272,7 +282,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
sense = dev.ReportDensitySupport(out buffer, out senseBuffer, true, true, timeout, out duration);
if(!sense)
{
Decoders.SCSI.SSC.DensitySupport.MediaTypeSupportHeader? mtsh = Decoders.SCSI.SSC.DensitySupport.DecodeMediumType(buffer);
Decoders.SCSI.SSC.DensitySupport.MediaTypeSupportHeader? mtsh =
Decoders.SCSI.SSC.DensitySupport.DecodeMediumType(buffer);
if(mtsh.HasValue)
{
seqTest.SupportedMediaTypes = new SupportedMedia[mtsh.Value.descriptors.Length];
@@ -286,9 +297,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
seqTest.SupportedMediaTypes[i].Width = mtsh.Value.descriptors[i].width;
if(mtsh.Value.descriptors[i].densityCodes != null)
{
seqTest.SupportedMediaTypes[i].DensityCodes = new int[mtsh.Value.descriptors[i].densityCodes.Length];
seqTest.SupportedMediaTypes[i].DensityCodes =
new int[mtsh.Value.descriptors[i].densityCodes.Length];
for(int j = 0; j < mtsh.Value.descriptors.Length; j++)
seqTest.SupportedMediaTypes[i].DensityCodes[j] = mtsh.Value.descriptors[i].densityCodes[j];
seqTest.SupportedMediaTypes[i].DensityCodes[j] =
mtsh.Value.descriptors[i].densityCodes[j];
}
}
}
@@ -296,11 +309,13 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
seqTest.CanReadMediaSerialSpecified = true;
DicConsole.WriteLine("Trying SCSI READ MEDIA SERIAL NUMBER...");
seqTest.CanReadMediaSerial = !dev.ReadMediaSerialNumber(out buffer, out senseBuffer, timeout, out duration);
seqTest.CanReadMediaSerial =
!dev.ReadMediaSerialNumber(out buffer, out senseBuffer, timeout, out duration);
seqTests.Add(seqTest);
}
}
report.SCSI.SequentialDevice.TestedMedia = seqTests.ToArray();
}
}
}
}

View File

@@ -40,13 +40,10 @@ namespace DiscImageChef.Core.Devices.Report
{
public static void Report(Device dev, ref DeviceReport report, bool debug, ref bool removable)
{
if(report == null)
return;
if(report == null) return;
if(dev.Type == DeviceType.MMC)
report.MultiMediaCard = new mmcsdType();
else if(dev.Type == DeviceType.SecureDigital)
report.SecureDigital = new mmcsdType();
if(dev.Type == DeviceType.MMC) report.MultiMediaCard = new mmcsdType();
else if(dev.Type == DeviceType.SecureDigital) report.SecureDigital = new mmcsdType();
DicConsole.WriteLine("Trying to get CID...");
bool sense = dev.ReadCID(out byte[] cid, out uint[] response, dev.Timeout, out double duration);
@@ -77,8 +74,7 @@ namespace DiscImageChef.Core.Devices.Report
report.MultiMediaCard.CID = cid;
}
}
else
DicConsole.WriteLine("Could not read CID...");
else DicConsole.WriteLine("Could not read CID...");
DicConsole.WriteLine("Trying to get CSD...");
sense = dev.ReadCSD(out byte[] csd, out response, dev.Timeout, out duration);
@@ -87,13 +83,10 @@ namespace DiscImageChef.Core.Devices.Report
{
DicConsole.WriteLine("CSD obtained correctly...");
if(dev.Type == DeviceType.MMC)
report.MultiMediaCard.CSD = csd;
else if(dev.Type == DeviceType.SecureDigital)
report.SecureDigital.CSD = csd;
if(dev.Type == DeviceType.MMC) report.MultiMediaCard.CSD = csd;
else if(dev.Type == DeviceType.SecureDigital) report.SecureDigital.CSD = csd;
}
else
DicConsole.WriteLine("Could not read CSD...");
else DicConsole.WriteLine("Could not read CSD...");
if(dev.Type == DeviceType.MMC)
{
@@ -105,8 +98,7 @@ namespace DiscImageChef.Core.Devices.Report
DicConsole.WriteLine("OCR obtained correctly...");
report.MultiMediaCard.OCR = ocr;
}
else
DicConsole.WriteLine("Could not read OCR...");
else DicConsole.WriteLine("Could not read OCR...");
DicConsole.WriteLine("Trying to get Extended CSD...");
sense = dev.ReadExtendedCSD(out byte[] ecsd, out response, dev.Timeout, out duration);
@@ -116,8 +108,7 @@ namespace DiscImageChef.Core.Devices.Report
DicConsole.WriteLine("Extended CSD obtained correctly...");
report.MultiMediaCard.ExtendedCSD = ecsd;
}
else
DicConsole.WriteLine("Could not read Extended CSD...");
else DicConsole.WriteLine("Could not read Extended CSD...");
}
else if(dev.Type == DeviceType.SecureDigital)
{
@@ -129,8 +120,7 @@ namespace DiscImageChef.Core.Devices.Report
DicConsole.WriteLine("OCR obtained correctly...");
report.SecureDigital.OCR = ocr;
}
else
DicConsole.WriteLine("Could not read OCR...");
else DicConsole.WriteLine("Could not read OCR...");
DicConsole.WriteLine("Trying to get SCR...");
sense = dev.ReadSCR(out byte[] scr, out response, dev.Timeout, out duration);
@@ -140,10 +130,8 @@ namespace DiscImageChef.Core.Devices.Report
DicConsole.WriteLine("SCR obtained correctly...");
report.SecureDigital.SCR = scr;
}
else
DicConsole.WriteLine("Could not read SCR...");
else DicConsole.WriteLine("Could not read SCR...");
}
}
}
}
}

View File

@@ -41,8 +41,7 @@ namespace DiscImageChef.Core.Devices.Report
{
public static void Report(Device dev, ref DeviceReport report, bool debug, ref bool removable)
{
if(report == null)
return;
if(report == null) return;
ConsoleKeyInfo pressedKey = new ConsoleKeyInfo();
while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
@@ -70,9 +69,8 @@ namespace DiscImageChef.Core.Devices.Report
report.USB.RemovableMedia = pressedKey.Key == ConsoleKey.Y;
removable = report.USB.RemovableMedia;
if(debug)
report.USB.Descriptors = dev.USBDescriptors;
if(debug) report.USB.Descriptors = dev.USBDescriptors;
}
}
}
}
}