2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
// Aaru Data Preservation Suite
|
2015-10-12 19:55:00 +01:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : Variables.cs
|
2016-07-28 18:13:49 +01:00
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2015-10-12 19:55:00 +01:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Component : Direct device access.
|
2015-10-12 19:55:00 +01:00
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Contains various device variables.
|
2015-10-12 19:55:00 +01:00
|
|
|
//
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// This library is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
// published by the Free Software Foundation; either version 2.1 of the
|
2015-10-12 19:55:00 +01:00
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// This library 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
|
|
|
|
|
// Lesser General Public License for more details.
|
2015-10-12 19:55:00 +01:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2015-10-12 19:55:00 +01:00
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2024-12-19 10:45:18 +00:00
|
|
|
// Copyright © 2011-2025 Natalia Portillo
|
2015-10-12 19:55:00 +01:00
|
|
|
// ****************************************************************************/
|
2016-07-28 18:13:49 +01:00
|
|
|
|
2020-02-27 00:33:26 +00:00
|
|
|
using Aaru.CommonTypes.Enums;
|
|
|
|
|
using Aaru.CommonTypes.Interop;
|
|
|
|
|
using Aaru.CommonTypes.Structs.Devices.SCSI;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
namespace Aaru.Devices;
|
|
|
|
|
|
2022-03-26 18:31:04 +00:00
|
|
|
public partial class Device
|
2015-10-12 19:55:00 +01:00
|
|
|
{
|
2023-10-05 01:52:48 +01:00
|
|
|
const string ATA_MODULE_NAME = "ATA Device";
|
|
|
|
|
const string SCSI_MODULE_NAME = "SCSI Device";
|
|
|
|
|
const string SD_MODULE_NAME = "SecureDigital Device";
|
|
|
|
|
const string MMC_MODULE_NAME = "MultiMediaCard Device";
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets the Platform ID for this device</summary>
|
|
|
|
|
/// <value>The Platform ID</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public PlatformID PlatformId { get; private protected set; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets or sets the standard timeout for commands sent to this device</summary>
|
|
|
|
|
/// <value>The timeout in seconds</value>
|
2022-03-26 17:46:59 +00:00
|
|
|
public uint Timeout { get; set; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets a value indicating whether this <see cref="Device" /> is in error.</summary>
|
|
|
|
|
/// <value><c>true</c> if error; otherwise, <c>false</c>.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public bool Error { get; private protected set; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets the last error number.</summary>
|
|
|
|
|
/// <value>The last error.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public int LastError { get; private protected set; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets the device type.</summary>
|
|
|
|
|
/// <value>The device type.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public DeviceType Type { get; private protected set; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets the device's manufacturer</summary>
|
|
|
|
|
/// <value>The manufacturer.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public string Manufacturer { get; private protected set; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets the device model</summary>
|
|
|
|
|
/// <value>The model.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public string Model { get; private protected set; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets the device's firmware version.</summary>
|
|
|
|
|
/// <value>The firmware version.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public string FirmwareRevision { get; private protected set; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets the device's serial number.</summary>
|
|
|
|
|
/// <value>The serial number.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public string Serial { get; private protected set; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets the device's SCSI peripheral device type</summary>
|
|
|
|
|
/// <value>The SCSI peripheral device type.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public PeripheralDeviceTypes ScsiType { get; private protected set; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets a value indicating whether this device's media is removable.</summary>
|
|
|
|
|
/// <value><c>true</c> if this device's media is removable; otherwise, <c>false</c>.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public bool IsRemovable { get; private protected set; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets a value indicating whether this device is attached via USB.</summary>
|
|
|
|
|
/// <value><c>true</c> if this device is attached via USB; otherwise, <c>false</c>.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public bool IsUsb { get; private protected set; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets the USB vendor ID.</summary>
|
|
|
|
|
/// <value>The USB vendor ID.</value>
|
2023-10-05 01:52:48 +01:00
|
|
|
public ushort UsbVendorId => UsbVendor;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets the USB product ID.</summary>
|
|
|
|
|
/// <value>The USB product ID.</value>
|
2023-10-05 01:52:48 +01:00
|
|
|
public ushort UsbProductId => UsbProduct;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets the USB descriptors.</summary>
|
|
|
|
|
/// <value>The USB descriptors.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public byte[] UsbDescriptors { get; private protected set; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets the USB manufacturer string.</summary>
|
|
|
|
|
/// <value>The USB manufacturer string.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public string UsbManufacturerString { get; private protected set; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets the USB product string.</summary>
|
|
|
|
|
/// <value>The USB product string.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public string UsbProductString { get; private protected set; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets the USB serial string.</summary>
|
|
|
|
|
/// <value>The USB serial string.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public string UsbSerialString { get; private protected set; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets a value indicating whether this device is attached via FireWire.</summary>
|
|
|
|
|
/// <value><c>true</c> if this device is attached via FireWire; otherwise, <c>false</c>.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public bool IsFireWire { get; private protected set; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets the FireWire GUID</summary>
|
|
|
|
|
/// <value>The FireWire GUID.</value>
|
2023-10-05 01:52:48 +01:00
|
|
|
public ulong FireWireGuid => FirewireGuid;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets the FireWire model number</summary>
|
|
|
|
|
/// <value>The FireWire model.</value>
|
2023-10-05 01:52:48 +01:00
|
|
|
public uint FireWireModel => FirewireModel;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>Gets the FireWire model name.</summary>
|
|
|
|
|
/// <value>The FireWire model name.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public string FireWireModelName { get; private protected set; }
|
2015-12-31 16:33:20 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
/// <summary>Gets the FireWire vendor number.</summary>
|
|
|
|
|
/// <value>The FireWire vendor number.</value>
|
2023-10-05 01:52:48 +01:00
|
|
|
public uint FireWireVendor => FirewireVendor;
|
2015-12-31 16:33:20 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
/// <summary>Gets the FireWire vendor name.</summary>
|
|
|
|
|
/// <value>The FireWire vendor name.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public string FireWireVendorName { get; private protected set; }
|
2016-10-17 04:41:27 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
/// <summary>Gets a value indicating whether this device is a CompactFlash device.</summary>
|
|
|
|
|
/// <value><c>true</c> if this device is a CompactFlash device; otherwise, <c>false</c>.</value>
|
2022-03-26 17:46:59 +00:00
|
|
|
public bool IsCompactFlash { get; private set; }
|
2016-10-17 04:41:27 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
/// <summary>Gets a value indicating whether this device is a PCMCIA device.</summary>
|
|
|
|
|
/// <value><c>true</c> if this device is a PCMCIA device; otherwise, <c>false</c>.</value>
|
2022-03-26 18:31:04 +00:00
|
|
|
public bool IsPcmcia { get; private protected set; }
|
2016-10-17 04:41:27 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
/// <summary>Contains the PCMCIA CIS if applicable</summary>
|
2022-03-26 18:31:04 +00:00
|
|
|
public byte[] Cis { get; private protected set; }
|
2024-05-06 04:34:43 +01:00
|
|
|
|
|
|
|
|
// MMC and SecureDigital, values that need to be get with card idle, something that may
|
|
|
|
|
// not be possible to do but usually is already done by the SDHCI driver.
|
|
|
|
|
#pragma warning disable PH2070 // Risks are known. TODO: Maybe protected property?
|
|
|
|
|
private protected byte[] CachedCid;
|
|
|
|
|
private protected byte[] CachedCsd;
|
|
|
|
|
private protected byte[] CachedOcr;
|
|
|
|
|
private protected byte[] CachedScr;
|
|
|
|
|
|
|
|
|
|
private protected string DevicePath;
|
|
|
|
|
private protected ulong FirewireGuid;
|
|
|
|
|
private protected uint FirewireModel;
|
|
|
|
|
private protected uint FirewireVendor;
|
|
|
|
|
private protected ushort UsbProduct;
|
|
|
|
|
private protected ushort UsbVendor;
|
|
|
|
|
#pragma warning restore PH2070
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|