2017-05-28 21:01:17 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : ATAPI.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 ATAPI 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.ATA;
|
2017-05-28 21:01:17 +01:00
|
|
|
|
using DiscImageChef.Devices;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DiscImageChef.Core.Devices.Report
|
|
|
|
|
|
{
|
2017-12-23 01:46:08 +00:00
|
|
|
|
/// <summary>
|
2017-12-23 17:41:23 +00:00
|
|
|
|
/// Implements creating a report for an ATAPI device
|
2017-12-23 01:46:08 +00:00
|
|
|
|
/// </summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
|
static class Atapi
|
2017-05-28 21:01:17 +01:00
|
|
|
|
{
|
2017-12-23 01:46:08 +00:00
|
|
|
|
/// <summary>
|
2017-12-23 17:41:23 +00:00
|
|
|
|
/// Fills a SCSI device report with parameters specific to an ATAPI device
|
2017-12-23 01:46:08 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dev">Device</param>
|
|
|
|
|
|
/// <param name="report">Device report</param>
|
|
|
|
|
|
/// <param name="debug">If debug is enabled</param>
|
2018-11-25 17:47:14 +00:00
|
|
|
|
internal static void Report(Device dev, ref DeviceReportV2 report, bool debug)
|
2017-05-28 21:01:17 +01:00
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(report == null) return;
|
2017-05-28 21:01:17 +01:00
|
|
|
|
|
2017-12-21 23:00:30 +00:00
|
|
|
|
const uint TIMEOUT = 5;
|
2017-05-28 21:01:17 +01:00
|
|
|
|
|
|
|
|
|
|
DicConsole.WriteLine("Querying ATAPI IDENTIFY...");
|
|
|
|
|
|
|
2017-12-21 23:00:30 +00:00
|
|
|
|
dev.AtapiIdentify(out byte[] buffer, out _, TIMEOUT, out _);
|
2017-05-28 21:01:17 +01:00
|
|
|
|
|
2017-12-21 14:30:38 +00:00
|
|
|
|
if(!Identify.Decode(buffer).HasValue) return;
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
2017-12-21 17:10:37 +00:00
|
|
|
|
Identify.IdentifyDevice? atapiIdNullable = Identify.Decode(buffer);
|
2018-11-25 17:47:14 +00:00
|
|
|
|
if(atapiIdNullable != null) report.ATAPI = new CommonTypes.Metadata.Ata {IdentifyDevice = atapiIdNullable};
|
2018-06-22 08:08:38 +01:00
|
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
|
if(debug) report.ATAPI.Identify = buffer;
|
2017-05-28 21:01:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|