2018-09-01 19:22:46 +01:00
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
// Aaru Data Preservation Suite
|
2018-09-01 19:22:46 +01:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : DeviceInfo.cs
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
//
|
|
|
|
|
// Component : Core.
|
|
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Retrieves the device info.
|
|
|
|
|
//
|
|
|
|
|
// --[ 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/>.
|
|
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-02-18 10:02:53 +00:00
|
|
|
// Copyright © 2011-2022 Natalia Portillo
|
|
|
|
|
// Copyright © 2021-2022 Rebecca Wallander
|
2018-09-01 19:22:46 +01:00
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
using DVDDecryption = Aaru.Decryption.DVD.Dump;
|
|
|
|
|
|
|
|
|
|
namespace Aaru.Core.Devices.Info;
|
|
|
|
|
|
2018-09-01 19:22:46 +01:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2020-02-27 00:33:26 +00:00
|
|
|
using Aaru.CommonTypes.Enums;
|
|
|
|
|
using Aaru.CommonTypes.Structs.Devices.SCSI;
|
|
|
|
|
using Aaru.Console;
|
|
|
|
|
using Aaru.Decoders.ATA;
|
2021-01-24 18:25:48 +01:00
|
|
|
using Aaru.Decoders.DVD;
|
2020-02-27 00:33:26 +00:00
|
|
|
using Aaru.Decoders.SCSI;
|
2021-01-24 18:25:48 +01:00
|
|
|
using Aaru.Decryption;
|
2020-02-27 00:33:26 +00:00
|
|
|
using Aaru.Devices;
|
2020-07-20 15:43:52 +01:00
|
|
|
using Aaru.Helpers;
|
2020-02-27 00:33:26 +00:00
|
|
|
using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry;
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
/// <summary>Obtains and contains information about a device</summary>
|
|
|
|
|
public partial class DeviceInfo
|
2018-09-01 19:22:46 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
/// <summary>Initializes an instance of this class for the specified device</summary>
|
|
|
|
|
/// <param name="dev">Device</param>
|
|
|
|
|
public DeviceInfo(Device dev)
|
2018-09-01 19:22:46 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
Type = dev.Type;
|
|
|
|
|
Manufacturer = dev.Manufacturer;
|
|
|
|
|
Model = dev.Model;
|
|
|
|
|
FirmwareRevision = dev.FirmwareRevision;
|
|
|
|
|
Serial = dev.Serial;
|
|
|
|
|
ScsiType = dev.ScsiType;
|
|
|
|
|
IsRemovable = dev.IsRemovable;
|
|
|
|
|
IsUsb = dev.IsUsb;
|
|
|
|
|
UsbVendorId = dev.UsbVendorId;
|
|
|
|
|
UsbProductId = dev.UsbProductId;
|
|
|
|
|
UsbDescriptors = dev.UsbDescriptors;
|
|
|
|
|
UsbManufacturerString = dev.UsbManufacturerString;
|
|
|
|
|
UsbProductString = dev.UsbProductString;
|
|
|
|
|
UsbSerialString = dev.UsbSerialString;
|
|
|
|
|
IsFireWire = dev.IsFireWire;
|
|
|
|
|
FireWireGuid = dev.FireWireGuid;
|
|
|
|
|
FireWireModel = dev.FireWireModel;
|
|
|
|
|
FireWireModelName = dev.FireWireModelName;
|
|
|
|
|
FireWireVendor = dev.FireWireVendor;
|
|
|
|
|
FireWireVendorName = dev.FireWireVendorName;
|
|
|
|
|
IsCompactFlash = dev.IsCompactFlash;
|
|
|
|
|
IsPcmcia = dev.IsPcmcia;
|
|
|
|
|
Cis = dev.Cis;
|
|
|
|
|
|
|
|
|
|
switch(dev.Type)
|
2018-09-01 19:22:46 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
case DeviceType.ATA:
|
2018-09-01 19:22:46 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
bool sense = dev.AtaIdentify(out byte[] ataBuf, out AtaErrorRegistersChs errorRegisters);
|
|
|
|
|
|
|
|
|
|
if(sense)
|
2018-09-01 19:22:46 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
AaruConsole.DebugWriteLine("Device-Info command", "STATUS = 0x{0:X2}", errorRegisters.Status);
|
|
|
|
|
AaruConsole.DebugWriteLine("Device-Info command", "ERROR = 0x{0:X2}", errorRegisters.Error);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
AaruConsole.DebugWriteLine("Device-Info command", "NSECTOR = 0x{0:X2}", errorRegisters.SectorCount);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
AaruConsole.DebugWriteLine("Device-Info command", "SECTOR = 0x{0:X2}", errorRegisters.Sector);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
AaruConsole.DebugWriteLine("Device-Info command", "CYLHIGH = 0x{0:X2}",
|
|
|
|
|
errorRegisters.CylinderHigh);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
AaruConsole.DebugWriteLine("Device-Info command", "CYLLOW = 0x{0:X2}", errorRegisters.CylinderLow);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
AaruConsole.DebugWriteLine("Device-Info command", "DEVICE = 0x{0:X2}", errorRegisters.DeviceHead);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
AaruConsole.DebugWriteLine("Device-Info command", "Error code = {0}", dev.LastError);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(dev.Error)
|
|
|
|
|
{
|
|
|
|
|
AaruConsole.ErrorWriteLine("Error {0} querying ATA IDENTIFY", dev.LastError);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
AtaIdentify = ataBuf;
|
2018-09-02 15:29:10 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
dev.EnableMediaCardPassThrough(out errorRegisters, dev.Timeout, out _);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(errorRegisters.Sector == 0xAA &&
|
|
|
|
|
errorRegisters.SectorCount == 0x55)
|
|
|
|
|
AtaMcptError = errorRegisters;
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
case DeviceType.ATAPI:
|
|
|
|
|
{
|
|
|
|
|
bool sense = dev.AtapiIdentify(out byte[] ataBuf, out AtaErrorRegistersChs errorRegisters);
|
2019-05-11 20:49:32 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(sense)
|
2018-09-01 19:22:46 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
AaruConsole.DebugWriteLine("Device-Info command", "STATUS = 0x{0:X2}", errorRegisters.Status);
|
|
|
|
|
AaruConsole.DebugWriteLine("Device-Info command", "ERROR = 0x{0:X2}", errorRegisters.Error);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
AaruConsole.DebugWriteLine("Device-Info command", "NSECTOR = 0x{0:X2}", errorRegisters.SectorCount);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
AaruConsole.DebugWriteLine("Device-Info command", "SECTOR = 0x{0:X2}", errorRegisters.Sector);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
AaruConsole.DebugWriteLine("Device-Info command", "CYLHIGH = 0x{0:X2}",
|
|
|
|
|
errorRegisters.CylinderHigh);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
AaruConsole.DebugWriteLine("Device-Info command", "CYLLOW = 0x{0:X2}", errorRegisters.CylinderLow);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
AaruConsole.DebugWriteLine("Device-Info command", "DEVICE = 0x{0:X2}", errorRegisters.DeviceHead);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
AaruConsole.DebugWriteLine("Device-Info command", "Error code = {0}", dev.LastError);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!dev.Error)
|
|
|
|
|
AtapiIdentify = ataBuf;
|
|
|
|
|
else
|
|
|
|
|
AaruConsole.ErrorWriteLine("Error {0} querying ATA PACKET IDENTIFY", dev.LastError);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
// ATAPI devices are also SCSI devices
|
|
|
|
|
goto case DeviceType.SCSI;
|
|
|
|
|
}
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
case DeviceType.SCSI:
|
|
|
|
|
{
|
|
|
|
|
bool sense = dev.ScsiInquiry(out byte[] inqBuf, out byte[] senseBuf);
|
2019-05-11 20:49:32 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(sense)
|
2018-09-01 19:22:46 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
AaruConsole.ErrorWriteLine("SCSI error:\n{0}", Sense.PrettifySense(senseBuf));
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
ScsiInquiryData = inqBuf;
|
|
|
|
|
ScsiInquiry = Inquiry.Decode(inqBuf);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, 0x00);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!sense)
|
|
|
|
|
{
|
|
|
|
|
ScsiEvpdPages = new Dictionary<byte, byte[]>();
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
byte[] pages = EVPD.DecodePage00(inqBuf);
|
|
|
|
|
|
|
|
|
|
if(pages != null)
|
|
|
|
|
foreach(byte page in pages)
|
|
|
|
|
{
|
|
|
|
|
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(sense)
|
|
|
|
|
continue;
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
ScsiEvpdPages.Add(page, inqBuf);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
var devType = (PeripheralDeviceTypes)ScsiInquiry.Value.PeripheralDeviceType;
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
sense = dev.ModeSense10(out byte[] modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current,
|
|
|
|
|
0x3F, 0xFF, 5, out _);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!sense &&
|
|
|
|
|
!dev.Error)
|
|
|
|
|
ScsiModeSense10 = modeBuf;
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(sense || dev.Error)
|
|
|
|
|
{
|
2022-03-07 07:36:44 +00:00
|
|
|
sense = dev.ModeSense10(out modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current,
|
|
|
|
|
0x3F, 0x00, 5, out _);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2020-01-09 15:02:21 +00:00
|
|
|
if(!sense &&
|
|
|
|
|
!dev.Error)
|
|
|
|
|
ScsiModeSense10 = modeBuf;
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!sense &&
|
|
|
|
|
!dev.Error)
|
|
|
|
|
ScsiMode = Modes.DecodeMode10(modeBuf, devType);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
bool useMode10 = !(sense || dev.Error || !ScsiMode.HasValue);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
sense = dev.ModeSense6(out modeBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, 0xFF,
|
|
|
|
|
5, out _);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!sense &&
|
|
|
|
|
!dev.Error)
|
|
|
|
|
ScsiModeSense6 = modeBuf;
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(sense || dev.Error)
|
|
|
|
|
{
|
2018-09-01 19:22:46 +01:00
|
|
|
sense = dev.ModeSense6(out modeBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F,
|
2022-03-06 13:29:38 +00:00
|
|
|
0x00, 5, out _);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2020-01-09 15:02:21 +00:00
|
|
|
if(!sense &&
|
|
|
|
|
!dev.Error)
|
|
|
|
|
ScsiModeSense6 = modeBuf;
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(sense || dev.Error)
|
|
|
|
|
{
|
|
|
|
|
sense = dev.ModeSense(out modeBuf, out senseBuf, 5, out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!sense &&
|
|
|
|
|
!dev.Error)
|
|
|
|
|
ScsiModeSense6 = modeBuf;
|
|
|
|
|
}
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!sense &&
|
|
|
|
|
!dev.Error &&
|
|
|
|
|
!useMode10)
|
|
|
|
|
ScsiMode = Modes.DecodeMode6(modeBuf, devType);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
switch(devType)
|
|
|
|
|
{
|
|
|
|
|
case PeripheralDeviceTypes.MultiMediaDevice:
|
2018-09-01 19:22:46 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
sense = dev.GetConfiguration(out byte[] confBuf, out senseBuf, dev.Timeout, out _);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!sense)
|
|
|
|
|
MmcConfiguration = confBuf;
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
var dvdDecrypt = new DVDDecryption(dev);
|
2021-01-24 18:25:48 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
sense = dvdDecrypt.ReadRpc(out byte[] cmdBuf, out _, DvdCssKeyClass.DvdCssCppmOrCprm,
|
|
|
|
|
dev.Timeout, out _);
|
2021-01-24 18:25:48 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!sense)
|
|
|
|
|
{
|
|
|
|
|
CSS_CPRM.RegionalPlaybackControlState? rpc =
|
|
|
|
|
CSS_CPRM.DecodeRegionalPlaybackControlState(cmdBuf);
|
2021-01-24 18:25:48 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(rpc.HasValue)
|
|
|
|
|
RPC = rpc;
|
|
|
|
|
}
|
2021-01-24 18:25:48 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
// TODO: DVD drives respond correctly to BD status.
|
|
|
|
|
// While specification says if no medium is present
|
|
|
|
|
// it should inform all possible capabilities,
|
|
|
|
|
// testing drives show only supported media capabilities.
|
|
|
|
|
/*
|
|
|
|
|
byte[] strBuf;
|
|
|
|
|
sense = dev.ReadDiscStructure(out strBuf, out senseBuf, MmcDiscStructureMediaType.DVD, 0, 0, MmcDiscStructureFormat.CapabilityList, 0, dev.Timeout, out _);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if (!sense)
|
|
|
|
|
{
|
|
|
|
|
Decoders.SCSI.DiscStructureCapabilities.Capability[] caps = Decoders.SCSI.DiscStructureCapabilities.Decode(strBuf);
|
|
|
|
|
if (caps != null)
|
2018-09-01 19:22:46 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
foreach (Decoders.SCSI.DiscStructureCapabilities.Capability cap in caps)
|
2018-09-01 19:22:46 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
if (cap.SDS && cap.RDS)
|
|
|
|
|
AaruConsole.WriteLine("Drive can READ/SEND DISC STRUCTURE format {0:X2}h", cap.FormatCode);
|
|
|
|
|
else if (cap.SDS)
|
|
|
|
|
AaruConsole.WriteLine("Drive can SEND DISC STRUCTURE format {0:X2}h", cap.FormatCode);
|
|
|
|
|
else if (cap.RDS)
|
|
|
|
|
AaruConsole.WriteLine("Drive can READ DISC STRUCTURE format {0:X2}h", cap.FormatCode);
|
2018-09-01 19:22:46 +01:00
|
|
|
}
|
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
sense = dev.ReadDiscStructure(out strBuf, out senseBuf, MmcDiscStructureMediaType.BD, 0, 0, MmcDiscStructureFormat.CapabilityList, 0, dev.Timeout, out _);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if (!sense)
|
|
|
|
|
{
|
|
|
|
|
Decoders.SCSI.DiscStructureCapabilities.Capability[] caps = Decoders.SCSI.DiscStructureCapabilities.Decode(strBuf);
|
|
|
|
|
if (caps != null)
|
2018-09-01 19:22:46 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
foreach (Decoders.SCSI.DiscStructureCapabilities.Capability cap in caps)
|
2018-09-01 19:22:46 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
if (cap.SDS && cap.RDS)
|
|
|
|
|
AaruConsole.WriteLine("Drive can READ/SEND DISC STRUCTURE format {0:X2}h", cap.FormatCode);
|
|
|
|
|
else if (cap.SDS)
|
|
|
|
|
AaruConsole.WriteLine("Drive can SEND DISC STRUCTURE format {0:X2}h", cap.FormatCode);
|
|
|
|
|
else if (cap.RDS)
|
|
|
|
|
AaruConsole.WriteLine("Drive can READ DISC STRUCTURE format {0:X2}h", cap.FormatCode);
|
2018-09-01 19:22:46 +01:00
|
|
|
}
|
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
|
|
|
|
*/
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
#region Plextor
|
|
|
|
|
if(dev.Manufacturer == "PLEXTOR")
|
|
|
|
|
{
|
2022-03-07 07:36:44 +00:00
|
|
|
var plxtSense = true;
|
|
|
|
|
var plxtDvd = false;
|
2022-03-06 13:29:38 +00:00
|
|
|
byte[] plxtBuf = null;
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
switch(dev.Model)
|
|
|
|
|
{
|
|
|
|
|
case "DVDR PX-708A":
|
|
|
|
|
case "DVDR PX-708A2":
|
|
|
|
|
case "DVDR PX-712A":
|
|
|
|
|
plxtDvd = true;
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
plxtSense = dev.PlextorReadEeprom(out plxtBuf, out senseBuf, dev.Timeout, out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
break;
|
|
|
|
|
case "DVDR PX-714A":
|
|
|
|
|
case "DVDR PX-716A":
|
|
|
|
|
case "DVDR PX-716AL":
|
|
|
|
|
case "DVDR PX-755A":
|
|
|
|
|
case "DVDR PX-760A":
|
|
|
|
|
{
|
|
|
|
|
plxtBuf = new byte[256 * 4];
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
for(byte i = 0; i < 4; i++)
|
|
|
|
|
{
|
2022-03-07 07:36:44 +00:00
|
|
|
plxtSense = dev.PlextorReadEepromBlock(out byte[] plxtBufSmall, out senseBuf, i,
|
|
|
|
|
256, dev.Timeout, out _);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(plxtSense)
|
|
|
|
|
break;
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
Array.Copy(plxtBufSmall, 0, plxtBuf, i * 256, 256);
|
2018-09-01 19:22:46 +01:00
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
plxtDvd = true;
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
break;
|
2018-09-01 19:22:46 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
default:
|
2020-01-09 15:02:21 +00:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
if(dev.Model.StartsWith("CD-R ", StringComparison.Ordinal))
|
|
|
|
|
plxtSense = dev.PlextorReadEepromCdr(out plxtBuf, out senseBuf, dev.Timeout,
|
|
|
|
|
out _);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
PlextorFeatures = new Plextor
|
|
|
|
|
{
|
|
|
|
|
IsDvd = plxtDvd
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if(!plxtSense)
|
|
|
|
|
{
|
|
|
|
|
PlextorFeatures.Eeprom = plxtBuf;
|
|
|
|
|
|
|
|
|
|
if(plxtDvd)
|
|
|
|
|
{
|
|
|
|
|
PlextorFeatures.Discs = BigEndianBitConverter.ToUInt16(plxtBuf, 0x0120);
|
|
|
|
|
PlextorFeatures.CdReadTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x0122);
|
|
|
|
|
PlextorFeatures.CdWriteTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x0126);
|
|
|
|
|
PlextorFeatures.DvdReadTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x012A);
|
|
|
|
|
PlextorFeatures.DvdWriteTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x012E);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PlextorFeatures.Discs = BigEndianBitConverter.ToUInt16(plxtBuf, 0x0078);
|
|
|
|
|
PlextorFeatures.CdReadTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x006C);
|
|
|
|
|
PlextorFeatures.CdWriteTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x007A);
|
2018-09-01 19:22:46 +01:00
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
plxtSense = dev.PlextorGetPoweRec(out senseBuf, out bool plxtPwrRecEnabled,
|
|
|
|
|
out ushort plxtPwrRecSpeed, dev.Timeout, out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!plxtSense)
|
|
|
|
|
{
|
|
|
|
|
PlextorFeatures.PoweRec = true;
|
|
|
|
|
|
|
|
|
|
if(plxtPwrRecEnabled)
|
2018-09-01 19:22:46 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
PlextorFeatures.PoweRecEnabled = true;
|
|
|
|
|
PlextorFeatures.PoweRecRecommendedSpeed = plxtPwrRecSpeed;
|
|
|
|
|
|
|
|
|
|
plxtSense = dev.PlextorGetSpeeds(out senseBuf, out ushort plxtPwrRecSelected,
|
|
|
|
|
out ushort plxtPwrRecMax,
|
|
|
|
|
out ushort plxtPwrRecLast, dev.Timeout, out _);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!plxtSense)
|
2018-09-01 19:22:46 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
PlextorFeatures.PoweRecSelected = plxtPwrRecSelected;
|
|
|
|
|
PlextorFeatures.PoweRecMax = plxtPwrRecMax;
|
|
|
|
|
PlextorFeatures.PoweRecLast = plxtPwrRecLast;
|
2018-09-01 19:22:46 +01:00
|
|
|
}
|
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
// TODO: Check it with a drive
|
|
|
|
|
plxtSense = dev.PlextorGetSilentMode(out plxtBuf, out senseBuf, dev.Timeout, out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!plxtSense)
|
|
|
|
|
if(plxtBuf[0] == 1)
|
|
|
|
|
{
|
|
|
|
|
PlextorFeatures.SilentModeEnabled = true;
|
|
|
|
|
PlextorFeatures.AccessTimeLimit = plxtBuf[1];
|
|
|
|
|
|
|
|
|
|
PlextorFeatures.CdReadSpeedLimit = plxtBuf[2];
|
|
|
|
|
PlextorFeatures.DvdReadSpeedLimit = plxtBuf[3];
|
|
|
|
|
PlextorFeatures.CdWriteSpeedLimit = plxtBuf[4];
|
|
|
|
|
|
|
|
|
|
// TODO: Check which one is each one
|
|
|
|
|
/*
|
|
|
|
|
if(plxtBuf[6] > 0)
|
|
|
|
|
AaruConsole.WriteLine("\tTray eject speed limited to {0}",
|
|
|
|
|
-(plxtBuf[6] + 48));
|
|
|
|
|
if(plxtBuf[7] > 0)
|
|
|
|
|
AaruConsole.WriteLine("\tTray eject speed limited to {0}",
|
|
|
|
|
plxtBuf[7] - 47);
|
|
|
|
|
*/
|
|
|
|
|
}
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
plxtSense = dev.PlextorGetGigaRec(out plxtBuf, out senseBuf, dev.Timeout, out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!plxtSense)
|
|
|
|
|
PlextorFeatures.GigaRec = true;
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
plxtSense = dev.PlextorGetSecuRec(out plxtBuf, out senseBuf, dev.Timeout, out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!plxtSense)
|
|
|
|
|
PlextorFeatures.SecuRec = true;
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
plxtSense = dev.PlextorGetSpeedRead(out plxtBuf, out senseBuf, dev.Timeout, out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!plxtSense)
|
|
|
|
|
{
|
|
|
|
|
PlextorFeatures.SpeedRead = true;
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if((plxtBuf[2] & 0x01) == 0x01)
|
|
|
|
|
PlextorFeatures.SpeedReadEnabled = true;
|
|
|
|
|
}
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
plxtSense = dev.PlextorGetHiding(out plxtBuf, out senseBuf, dev.Timeout, out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!plxtSense)
|
|
|
|
|
{
|
|
|
|
|
PlextorFeatures.Hiding = true;
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if((plxtBuf[2] & 0x02) == 0x02)
|
|
|
|
|
PlextorFeatures.HidesRecordables = true;
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if((plxtBuf[2] & 0x01) == 0x01)
|
|
|
|
|
PlextorFeatures.HidesSessions = true;
|
|
|
|
|
}
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
plxtSense = dev.PlextorGetVariRec(out plxtBuf, out senseBuf, false, dev.Timeout, out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!plxtSense)
|
|
|
|
|
PlextorFeatures.VariRec = true;
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(plxtDvd)
|
|
|
|
|
{
|
2022-03-07 07:36:44 +00:00
|
|
|
plxtSense = dev.PlextorGetVariRec(out plxtBuf, out senseBuf, true, dev.Timeout, out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!plxtSense)
|
|
|
|
|
PlextorFeatures.VariRecDvd = true;
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
plxtSense = dev.PlextorGetBitsetting(out plxtBuf, out senseBuf, false, dev.Timeout,
|
|
|
|
|
out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!plxtSense)
|
|
|
|
|
PlextorFeatures.BitSetting = true;
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
plxtSense = dev.PlextorGetBitsetting(out plxtBuf, out senseBuf, true, dev.Timeout,
|
|
|
|
|
out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!plxtSense)
|
|
|
|
|
PlextorFeatures.BitSettingDl = true;
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
plxtSense = dev.PlextorGetTestWriteDvdPlus(out plxtBuf, out senseBuf, dev.Timeout,
|
|
|
|
|
out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!plxtSense)
|
|
|
|
|
PlextorFeatures.DvdPlusWriteTest = true;
|
2018-09-01 19:22:46 +01:00
|
|
|
}
|
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
#endregion Plextor
|
2019-05-11 20:49:32 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(ScsiInquiry.Value.KreonPresent)
|
2022-03-07 07:36:44 +00:00
|
|
|
if(!dev.KreonGetFeatureList(out senseBuf, out KreonFeatures krFeatures, dev.Timeout, out _))
|
2022-03-06 13:29:38 +00:00
|
|
|
KreonFeatures = krFeatures;
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
case PeripheralDeviceTypes.SequentialAccess:
|
|
|
|
|
{
|
|
|
|
|
sense = dev.ReadBlockLimits(out byte[] seqBuf, out senseBuf, dev.Timeout, out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(sense)
|
|
|
|
|
AaruConsole.ErrorWriteLine("READ BLOCK LIMITS:\n{0}", Sense.PrettifySense(senseBuf));
|
|
|
|
|
else
|
|
|
|
|
BlockLimits = seqBuf;
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
sense = dev.ReportDensitySupport(out seqBuf, out senseBuf, dev.Timeout, out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(sense)
|
2022-03-07 07:36:44 +00:00
|
|
|
AaruConsole.ErrorWriteLine("REPORT DENSITY SUPPORT:\n{0}", Sense.PrettifySense(senseBuf));
|
2022-03-06 13:29:38 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DensitySupport = seqBuf;
|
|
|
|
|
DensitySupportHeader = Decoders.SCSI.SSC.DensitySupport.DecodeDensity(seqBuf);
|
|
|
|
|
}
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
sense = dev.ReportDensitySupport(out seqBuf, out senseBuf, true, false, dev.Timeout, out _);
|
|
|
|
|
|
|
|
|
|
if(sense)
|
|
|
|
|
AaruConsole.ErrorWriteLine("REPORT DENSITY SUPPORT (MEDIUM):\n{0}",
|
|
|
|
|
Sense.PrettifySense(senseBuf));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MediumDensitySupport = seqBuf;
|
|
|
|
|
MediaTypeSupportHeader = Decoders.SCSI.SSC.DensitySupport.DecodeMediumType(seqBuf);
|
2018-09-01 19:22:46 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2018-09-01 19:22:46 +01:00
|
|
|
}
|
2019-05-11 20:49:32 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
case DeviceType.MMC:
|
|
|
|
|
{
|
|
|
|
|
bool sense = dev.ReadCid(out byte[] mmcBuf, out _, dev.Timeout, out _);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!sense)
|
|
|
|
|
CID = mmcBuf;
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
sense = dev.ReadCsd(out mmcBuf, out _, dev.Timeout, out _);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!sense)
|
|
|
|
|
CSD = mmcBuf;
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
sense = dev.ReadOcr(out mmcBuf, out _, dev.Timeout, out _);
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!sense)
|
|
|
|
|
OCR = mmcBuf;
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
sense = dev.ReadExtendedCsd(out mmcBuf, out _, dev.Timeout, out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!sense &&
|
|
|
|
|
!ArrayHelpers.ArrayIsNullOrEmpty(mmcBuf))
|
|
|
|
|
ExtendedCSD = mmcBuf;
|
|
|
|
|
}
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
break;
|
|
|
|
|
case DeviceType.SecureDigital:
|
|
|
|
|
{
|
|
|
|
|
bool sense = dev.ReadCid(out byte[] sdBuf, out _, dev.Timeout, out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!sense)
|
|
|
|
|
CID = sdBuf;
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
sense = dev.ReadCsd(out sdBuf, out _, dev.Timeout, out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!sense)
|
|
|
|
|
CSD = sdBuf;
|
2018-09-01 19:22:46 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
sense = dev.ReadSdocr(out sdBuf, out _, dev.Timeout, out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!sense)
|
|
|
|
|
OCR = sdBuf;
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
sense = dev.ReadScr(out sdBuf, out _, dev.Timeout, out _);
|
2020-01-09 15:02:21 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(!sense)
|
|
|
|
|
SCR = sdBuf;
|
2018-09-01 19:22:46 +01:00
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
AaruConsole.ErrorWriteLine("Unknown device type {0}, cannot get information.", dev.Type);
|
|
|
|
|
|
|
|
|
|
break;
|
2018-09-01 19:22:46 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|