2017-05-28 21:01:17 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : SSC.cs
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2017-05-28 21:01:17 +01:00
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : Core algorithms.
|
2017-05-28 21:01:17 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Creates reports from SCSI Streaming devices.
|
2017-05-28 21:01:17 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
|
// it under the terms of the GNU General Public License as
|
|
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
//
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2017-05-28 21:01:17 +01:00
|
|
|
|
// ****************************************************************************/
|
2017-12-19 03:50:57 +00:00
|
|
|
|
|
2018-06-25 19:08:16 +01:00
|
|
|
|
using DiscImageChef.CommonTypes.Metadata;
|
2017-05-28 21:01:17 +01:00
|
|
|
|
using DiscImageChef.Console;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using DiscImageChef.Decoders.SCSI;
|
|
|
|
|
|
using DiscImageChef.Decoders.SCSI.SSC;
|
2017-05-28 21:01:17 +01:00
|
|
|
|
using DiscImageChef.Devices;
|
|
|
|
|
|
|
2018-11-25 20:27:38 +00:00
|
|
|
|
namespace DiscImageChef.Core.Devices.Report
|
2017-05-28 21:01:17 +01:00
|
|
|
|
{
|
2018-11-25 20:27:38 +00:00
|
|
|
|
public partial class DeviceReport
|
2017-05-28 21:01:17 +01:00
|
|
|
|
{
|
2018-11-25 20:27:38 +00:00
|
|
|
|
public Ssc ReportScsiSsc()
|
2017-05-28 21:01:17 +01:00
|
|
|
|
{
|
2018-11-25 20:27:38 +00:00
|
|
|
|
Ssc report = new Ssc();
|
2017-05-28 21:01:17 +01:00
|
|
|
|
DicConsole.WriteLine("Querying SCSI READ BLOCK LIMITS...");
|
2018-11-25 20:27:38 +00:00
|
|
|
|
bool sense = dev.ReadBlockLimits(out byte[] buffer, out byte[] _, dev.Timeout, out _);
|
2017-05-28 21:01:17 +01:00
|
|
|
|
if(!sense)
|
|
|
|
|
|
{
|
2017-12-21 14:30:38 +00:00
|
|
|
|
BlockLimits.BlockLimitsData? decBl = BlockLimits.Decode(buffer);
|
2017-12-20 17:15:26 +00:00
|
|
|
|
if(decBl.HasValue)
|
2017-05-28 21:01:17 +01:00
|
|
|
|
{
|
2018-11-25 20:27:38 +00:00
|
|
|
|
if(decBl.Value.granularity > 0) report.BlockSizeGranularity = decBl.Value.granularity;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
|
2018-11-25 20:27:38 +00:00
|
|
|
|
if(decBl.Value.maxBlockLen > 0) report.MaxBlockLength = decBl.Value.maxBlockLen;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
|
2018-11-25 20:27:38 +00:00
|
|
|
|
if(decBl.Value.minBlockLen > 0) report.MinBlockLength = decBl.Value.minBlockLen;
|
2017-05-28 21:01:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT...");
|
2018-11-25 20:27:38 +00:00
|
|
|
|
sense = dev.ReportDensitySupport(out buffer, out byte[] _, false, false, dev.Timeout, out _);
|
2017-05-28 21:01:17 +01:00
|
|
|
|
if(!sense)
|
|
|
|
|
|
{
|
2017-12-23 17:41:23 +00:00
|
|
|
|
DensitySupport.DensitySupportHeader? dsh = DensitySupport.DecodeDensity(buffer);
|
2017-05-28 21:01:17 +01:00
|
|
|
|
if(dsh.HasValue)
|
|
|
|
|
|
{
|
2018-11-25 20:27:38 +00:00
|
|
|
|
report.SupportedDensities = new SupportedDensity[dsh.Value.descriptors.Length];
|
2017-05-28 21:01:17 +01:00
|
|
|
|
for(int i = 0; i < dsh.Value.descriptors.Length; i++)
|
|
|
|
|
|
{
|
2018-11-25 20:27:38 +00:00
|
|
|
|
report.SupportedDensities[i].BitsPerMm = dsh.Value.descriptors[i].bpmm;
|
|
|
|
|
|
report.SupportedDensities[i].Capacity = dsh.Value.descriptors[i].capacity;
|
|
|
|
|
|
report.SupportedDensities[i].DefaultDensity = dsh.Value.descriptors[i].defaultDensity;
|
|
|
|
|
|
report.SupportedDensities[i].Description = dsh.Value.descriptors[i].description;
|
|
|
|
|
|
report.SupportedDensities[i].Duplicate = dsh.Value.descriptors[i].duplicate;
|
|
|
|
|
|
report.SupportedDensities[i].Name = dsh.Value.descriptors[i].name;
|
|
|
|
|
|
report.SupportedDensities[i].Organization = dsh.Value.descriptors[i].organization;
|
|
|
|
|
|
report.SupportedDensities[i].PrimaryCode = dsh.Value.descriptors[i].primaryCode;
|
|
|
|
|
|
report.SupportedDensities[i].SecondaryCode = dsh.Value.descriptors[i].secondaryCode;
|
|
|
|
|
|
report.SupportedDensities[i].Tracks = dsh.Value.descriptors[i].tracks;
|
|
|
|
|
|
report.SupportedDensities[i].Width = dsh.Value.descriptors[i].width;
|
|
|
|
|
|
report.SupportedDensities[i].Writable = dsh.Value.descriptors[i].writable;
|
2017-05-28 21:01:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for medium types...");
|
2018-11-25 20:27:38 +00:00
|
|
|
|
sense = dev.ReportDensitySupport(out buffer, out byte[] _, true, false, dev.Timeout, out _);
|
|
|
|
|
|
if(sense) return report;
|
2017-05-28 21:01:17 +01:00
|
|
|
|
|
2018-11-25 20:27:38 +00:00
|
|
|
|
DensitySupport.MediaTypeSupportHeader? mtsh = DensitySupport.DecodeMediumType(buffer);
|
|
|
|
|
|
if(!mtsh.HasValue) return report;
|
2017-05-28 21:01:17 +01:00
|
|
|
|
|
2018-11-26 23:16:54 +00:00
|
|
|
|
report.SupportedMediaTypes = new SscSupportedMedia[mtsh.Value.descriptors.Length];
|
2018-11-25 20:27:38 +00:00
|
|
|
|
for(int i = 0; i < mtsh.Value.descriptors.Length; i++)
|
2017-05-28 21:01:17 +01:00
|
|
|
|
{
|
2018-11-25 20:27:38 +00:00
|
|
|
|
report.SupportedMediaTypes[i].Description = mtsh.Value.descriptors[i].description;
|
|
|
|
|
|
report.SupportedMediaTypes[i].Length = mtsh.Value.descriptors[i].length;
|
|
|
|
|
|
report.SupportedMediaTypes[i].MediumType = mtsh.Value.descriptors[i].mediumType;
|
|
|
|
|
|
report.SupportedMediaTypes[i].Name = mtsh.Value.descriptors[i].name;
|
|
|
|
|
|
report.SupportedMediaTypes[i].Organization = mtsh.Value.descriptors[i].organization;
|
|
|
|
|
|
report.SupportedMediaTypes[i].Width = mtsh.Value.descriptors[i].width;
|
|
|
|
|
|
if(mtsh.Value.descriptors[i].densityCodes == null) continue;
|
|
|
|
|
|
|
2018-11-26 23:16:54 +00:00
|
|
|
|
report.SupportedMediaTypes[i].DensityCodes =
|
|
|
|
|
|
new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
|
2018-11-25 20:27:38 +00:00
|
|
|
|
for(int j = 0; j < mtsh.Value.descriptors.Length; j++)
|
2018-11-26 23:16:54 +00:00
|
|
|
|
report.SupportedMediaTypes[i].DensityCodes[j] =
|
|
|
|
|
|
new DensityCode {Code = mtsh.Value.descriptors[i].densityCodes[j]};
|
2018-11-25 20:27:38 +00:00
|
|
|
|
}
|
2017-05-28 21:01:17 +01:00
|
|
|
|
|
2018-11-25 20:27:38 +00:00
|
|
|
|
return report;
|
|
|
|
|
|
}
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
2018-11-25 20:27:38 +00:00
|
|
|
|
public TestedSequentialMedia ReportSscMedia()
|
|
|
|
|
|
{
|
|
|
|
|
|
TestedSequentialMedia seqTest = new TestedSequentialMedia();
|
2017-05-28 21:01:17 +01:00
|
|
|
|
|
2018-11-25 20:27:38 +00:00
|
|
|
|
Modes.DecodedMode? decMode = null;
|
2017-05-28 21:01:17 +01:00
|
|
|
|
|
2018-11-25 20:27:38 +00:00
|
|
|
|
DicConsole.WriteLine("Querying SCSI MODE SENSE (10)...");
|
|
|
|
|
|
bool sense = dev.ModeSense10(out byte[] buffer, out byte[] _, false, true, ScsiModeSensePageControl.Current,
|
|
|
|
|
|
0x3F, 0x00, dev.Timeout, out _);
|
|
|
|
|
|
if(!sense && !dev.Error)
|
|
|
|
|
|
{
|
|
|
|
|
|
decMode = Modes.DecodeMode10(buffer, dev.ScsiType);
|
|
|
|
|
|
if(debug) seqTest.ModeSense10Data = buffer;
|
|
|
|
|
|
}
|
2017-05-28 21:01:17 +01:00
|
|
|
|
|
2018-11-25 20:27:38 +00:00
|
|
|
|
DicConsole.WriteLine("Querying SCSI MODE SENSE...");
|
|
|
|
|
|
sense = dev.ModeSense(out buffer, out byte[] _, dev.Timeout, out _);
|
|
|
|
|
|
if(!sense && !dev.Error)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(!decMode.HasValue) decMode = Modes.DecodeMode6(buffer, dev.ScsiType);
|
|
|
|
|
|
if(debug) seqTest.ModeSense6Data = buffer;
|
|
|
|
|
|
}
|
2017-05-28 21:01:17 +01:00
|
|
|
|
|
2018-11-25 20:27:38 +00:00
|
|
|
|
if(decMode.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
seqTest.MediumType = (byte)decMode.Value.Header.MediumType;
|
|
|
|
|
|
if(decMode.Value.Header.BlockDescriptors != null && decMode.Value.Header.BlockDescriptors.Length > 0)
|
|
|
|
|
|
seqTest.Density = (byte)decMode.Value.Header.BlockDescriptors[0].Density;
|
|
|
|
|
|
}
|
2017-05-28 21:01:17 +01:00
|
|
|
|
|
2018-11-25 20:27:38 +00:00
|
|
|
|
DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for current media...");
|
|
|
|
|
|
sense = dev.ReportDensitySupport(out buffer, out byte[] _, false, true, dev.Timeout, out _);
|
|
|
|
|
|
if(!sense)
|
|
|
|
|
|
{
|
|
|
|
|
|
DensitySupport.DensitySupportHeader? dsh = DensitySupport.DecodeDensity(buffer);
|
|
|
|
|
|
if(dsh.HasValue)
|
2017-12-21 06:06:19 +00:00
|
|
|
|
{
|
2018-11-25 20:27:38 +00:00
|
|
|
|
seqTest.SupportedDensities = new SupportedDensity[dsh.Value.descriptors.Length];
|
|
|
|
|
|
for(int i = 0; i < dsh.Value.descriptors.Length; i++)
|
2017-05-28 21:01:17 +01:00
|
|
|
|
{
|
2018-11-25 20:27:38 +00:00
|
|
|
|
seqTest.SupportedDensities[i].BitsPerMm = dsh.Value.descriptors[i].bpmm;
|
|
|
|
|
|
seqTest.SupportedDensities[i].Capacity = dsh.Value.descriptors[i].capacity;
|
|
|
|
|
|
seqTest.SupportedDensities[i].DefaultDensity = dsh.Value.descriptors[i].defaultDensity;
|
|
|
|
|
|
seqTest.SupportedDensities[i].Description = dsh.Value.descriptors[i].description;
|
|
|
|
|
|
seqTest.SupportedDensities[i].Duplicate = dsh.Value.descriptors[i].duplicate;
|
|
|
|
|
|
seqTest.SupportedDensities[i].Name = dsh.Value.descriptors[i].name;
|
|
|
|
|
|
seqTest.SupportedDensities[i].Organization = dsh.Value.descriptors[i].organization;
|
|
|
|
|
|
seqTest.SupportedDensities[i].PrimaryCode = dsh.Value.descriptors[i].primaryCode;
|
|
|
|
|
|
seqTest.SupportedDensities[i].SecondaryCode = dsh.Value.descriptors[i].secondaryCode;
|
|
|
|
|
|
seqTest.SupportedDensities[i].Tracks = dsh.Value.descriptors[i].tracks;
|
|
|
|
|
|
seqTest.SupportedDensities[i].Width = dsh.Value.descriptors[i].width;
|
|
|
|
|
|
seqTest.SupportedDensities[i].Writable = dsh.Value.descriptors[i].writable;
|
2017-05-28 21:01:17 +01:00
|
|
|
|
}
|
2017-12-21 06:06:19 +00:00
|
|
|
|
}
|
2018-11-25 20:27:38 +00:00
|
|
|
|
}
|
2017-05-28 21:01:17 +01:00
|
|
|
|
|
2018-11-25 20:27:38 +00:00
|
|
|
|
DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for medium types for current media...");
|
|
|
|
|
|
sense = dev.ReportDensitySupport(out buffer, out byte[] _, true, true, dev.Timeout, out _);
|
|
|
|
|
|
if(!sense)
|
|
|
|
|
|
{
|
|
|
|
|
|
DensitySupport.MediaTypeSupportHeader? mtsh = DensitySupport.DecodeMediumType(buffer);
|
|
|
|
|
|
if(mtsh.HasValue)
|
2017-12-21 06:06:19 +00:00
|
|
|
|
{
|
2018-11-26 23:16:54 +00:00
|
|
|
|
seqTest.SupportedMediaTypes = new SscSupportedMedia[mtsh.Value.descriptors.Length];
|
2018-11-25 20:27:38 +00:00
|
|
|
|
for(int i = 0; i < mtsh.Value.descriptors.Length; i++)
|
2017-05-28 21:01:17 +01:00
|
|
|
|
{
|
2018-11-25 20:27:38 +00:00
|
|
|
|
seqTest.SupportedMediaTypes[i].Description = mtsh.Value.descriptors[i].description;
|
|
|
|
|
|
seqTest.SupportedMediaTypes[i].Length = mtsh.Value.descriptors[i].length;
|
|
|
|
|
|
seqTest.SupportedMediaTypes[i].MediumType = mtsh.Value.descriptors[i].mediumType;
|
|
|
|
|
|
seqTest.SupportedMediaTypes[i].Name = mtsh.Value.descriptors[i].name;
|
|
|
|
|
|
seqTest.SupportedMediaTypes[i].Organization = mtsh.Value.descriptors[i].organization;
|
|
|
|
|
|
seqTest.SupportedMediaTypes[i].Width = mtsh.Value.descriptors[i].width;
|
|
|
|
|
|
if(mtsh.Value.descriptors[i].densityCodes == null) continue;
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
2018-11-25 20:27:38 +00:00
|
|
|
|
seqTest.SupportedMediaTypes[i].DensityCodes =
|
2018-11-26 23:16:54 +00:00
|
|
|
|
new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
|
2018-11-25 20:27:38 +00:00
|
|
|
|
for(int j = 0; j < mtsh.Value.descriptors.Length; j++)
|
2018-11-26 23:16:54 +00:00
|
|
|
|
seqTest.SupportedMediaTypes[i].DensityCodes[j] =
|
|
|
|
|
|
new DensityCode {Code = mtsh.Value.descriptors[i].densityCodes[j]};
|
2017-05-28 21:01:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2018-11-25 20:27:38 +00:00
|
|
|
|
DicConsole.WriteLine("Trying SCSI READ MEDIA SERIAL NUMBER...");
|
|
|
|
|
|
seqTest.CanReadMediaSerial = !dev.ReadMediaSerialNumber(out buffer, out byte[] _, dev.Timeout, out _);
|
|
|
|
|
|
|
|
|
|
|
|
return seqTest;
|
2017-05-28 21:01:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|