mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Move all files into project subdirectory
This commit is contained in:
1276
Aaru.CommonTypes/Structs/Devices/ATA/Identify.cs
Normal file
1276
Aaru.CommonTypes/Structs/Devices/ATA/Identify.cs
Normal file
File diff suppressed because it is too large
Load Diff
245
Aaru.CommonTypes/Structs/Devices/SCSI/Enums.cs
Normal file
245
Aaru.CommonTypes/Structs/Devices/SCSI/Enums.cs
Normal file
@@ -0,0 +1,245 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Enums.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common structures for SCSI devices.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Contains various SCSI enumerations.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// 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
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2023 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||
|
||||
/// <summary>List of known SCSI peripheral qualifiers</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public enum PeripheralQualifiers : byte
|
||||
{
|
||||
/// <summary>Peripheral qualifier: Device is connected and supported</summary>
|
||||
Supported = 0x00,
|
||||
/// <summary>Peripheral qualifier: Device is supported but not connected</summary>
|
||||
Unconnected = 0x01,
|
||||
/// <summary>Peripheral qualifier: Reserved value</summary>
|
||||
Reserved = 0x02,
|
||||
/// <summary>Peripheral qualifier: Device is connected but unsupported</summary>
|
||||
Unsupported = 0x03,
|
||||
/// <summary>Peripheral qualifier: Vendor values: 0x04, 0x05, 0x06 and 0x07</summary>
|
||||
VendorMask = 0x04
|
||||
}
|
||||
|
||||
/// <summary>List of known peripheral device types</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum PeripheralDeviceTypes : byte
|
||||
{
|
||||
/// <summary>Direct-access device</summary>
|
||||
DirectAccess = 0x00,
|
||||
/// <summary>Sequential-access device</summary>
|
||||
SequentialAccess = 0x01,
|
||||
/// <summary>Printer device</summary>
|
||||
PrinterDevice = 0x02,
|
||||
/// <summary>Processor device</summary>
|
||||
ProcessorDevice = 0x03,
|
||||
/// <summary>Write-once device</summary>
|
||||
WriteOnceDevice = 0x04,
|
||||
/// <summary>CD-ROM/DVD/etc device</summary>
|
||||
MultiMediaDevice = 0x05,
|
||||
/// <summary>Scanner device</summary>
|
||||
ScannerDevice = 0x06,
|
||||
/// <summary>Optical memory device</summary>
|
||||
OpticalDevice = 0x07,
|
||||
/// <summary>Medium change device</summary>
|
||||
MediumChangerDevice = 0x08,
|
||||
/// <summary>Communications device</summary>
|
||||
CommsDevice = 0x09,
|
||||
/// <summary>Graphics arts pre-press device (defined in ASC IT8)</summary>
|
||||
PrePressDevice1 = 0x0A,
|
||||
/// <summary>Graphics arts pre-press device (defined in ASC IT8)</summary>
|
||||
PrePressDevice2 = 0x0B,
|
||||
/// <summary>Array controller device</summary>
|
||||
ArrayControllerDevice = 0x0C,
|
||||
/// <summary>Enclosure services device</summary>
|
||||
EnclosureServiceDevice = 0x0D,
|
||||
/// <summary>Simplified direct-access device</summary>
|
||||
SimplifiedDevice = 0x0E,
|
||||
/// <summary>Optical card reader/writer device</summary>
|
||||
OCRWDevice = 0x0F,
|
||||
/// <summary>Bridging Expanders</summary>
|
||||
BridgingExpander = 0x10,
|
||||
/// <summary>Object-based Storage Device</summary>
|
||||
ObjectDevice = 0x11,
|
||||
/// <summary>Automation/Drive Interface</summary>
|
||||
ADCDevice = 0x12,
|
||||
/// <summary>Security Manager Device</summary>
|
||||
SCSISecurityManagerDevice = 0x13,
|
||||
/// <summary>Host managed zoned block device</summary>
|
||||
SCSIZonedBlockDevice = 0x14,
|
||||
/// <summary>Well known logical unit</summary>
|
||||
WellKnownDevice = 0x1E,
|
||||
/// <summary>Unknown or no device type</summary>
|
||||
UnknownDevice = 0x1F
|
||||
}
|
||||
|
||||
/// <summary>List of known ANSI SCSI standards</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum ANSIVersions : byte
|
||||
{
|
||||
/// <summary>Device does not claim conformance to any ANSI version</summary>
|
||||
ANSINoVersion = 0x00,
|
||||
/// <summary>Device complies with ANSI X3.131:1986</summary>
|
||||
ANSI1986Version = 0x01,
|
||||
/// <summary>Device complies with ANSI X3.131:1994</summary>
|
||||
ANSI1994Version = 0x02,
|
||||
/// <summary>Device complies with ANSI X3.301:1997</summary>
|
||||
ANSI1997Version = 0x03,
|
||||
/// <summary>Device complies with ANSI X3.351:2001</summary>
|
||||
ANSI2001Version = 0x04,
|
||||
/// <summary>Device complies with ANSI X3.408:2005.</summary>
|
||||
ANSI2005Version = 0x05,
|
||||
/// <summary>Device complies with SPC-4</summary>
|
||||
ANSI2008Version = 0x06
|
||||
}
|
||||
|
||||
/// <summary>List of known ECMA SCSI standards</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum ECMAVersions : byte
|
||||
{
|
||||
/// <summary>Device does not claim conformance to any ECMA version</summary>
|
||||
ECMANoVersion = 0x00,
|
||||
/// <summary>Device complies with a ECMA-111 standard</summary>
|
||||
ECMA111 = 0x01
|
||||
}
|
||||
|
||||
/// <summary>List of known ISO SCSI standards</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum ISOVersions : byte
|
||||
{
|
||||
/// <summary>Device does not claim conformance to any ISO/IEC version</summary>
|
||||
ISONoVersion = 0x00,
|
||||
/// <summary>Device complies with ISO/IEC 9316:1995</summary>
|
||||
ISO1995Version = 0x02
|
||||
}
|
||||
|
||||
/// <summary>List of known SCSI Parallel Interface clocking types</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum SPIClocking : byte
|
||||
{
|
||||
/// <summary>Supports only ST</summary>
|
||||
ST = 0x00,
|
||||
/// <summary>Supports only DT</summary>
|
||||
DT = 0x01,
|
||||
/// <summary>Reserved value</summary>
|
||||
Reserved = 0x02,
|
||||
/// <summary>Supports ST and DT</summary>
|
||||
STandDT = 0x03
|
||||
}
|
||||
|
||||
/// <summary>List of known TGPS values</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum TGPSValues : byte
|
||||
{
|
||||
/// <summary>Asymmetrical access not supported</summary>
|
||||
NotSupported = 0x00,
|
||||
/// <summary>Only implicit asymmetrical access is supported</summary>
|
||||
OnlyImplicit = 0x01,
|
||||
/// <summary>Only explicit asymmetrical access is supported</summary>
|
||||
OnlyExplicit = 0x02,
|
||||
/// <summary>Both implicit and explicit asymmetrical access are supported</summary>
|
||||
Both = 0x03
|
||||
}
|
||||
|
||||
/// <summary>List of known SCSI protocols</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum ProtocolIdentifiers : byte
|
||||
{
|
||||
/// <summary>Fibre Channel</summary>
|
||||
FibreChannel = 0,
|
||||
/// <summary>Parallel SCSI</summary>
|
||||
SCSI = 1,
|
||||
/// <summary>SSA</summary>
|
||||
SSA = 2,
|
||||
/// <summary>IEEE-1394</summary>
|
||||
Firewire = 3,
|
||||
/// <summary>SCSI Remote Direct Memory Access Protocol</summary>
|
||||
RDMAP = 4,
|
||||
/// <summary>Internet SCSI</summary>
|
||||
iSCSI = 5,
|
||||
/// <summary>Serial SCSI</summary>
|
||||
SAS = 6,
|
||||
/// <summary>Automation/Drive Interface Transport Protocol</summary>
|
||||
ADT = 7,
|
||||
/// <summary>AT Attachment Interface (ATA/ATAPI)</summary>
|
||||
ATA = 8,
|
||||
/// <summary>USB Attached SCSI</summary>
|
||||
UAS = 9,
|
||||
/// <summary>SCSI over PCI Express</summary>
|
||||
SCSIe = 10,
|
||||
/// <summary>PCI Express</summary>
|
||||
PCIe = 11,
|
||||
/// <summary>No specific protocol</summary>
|
||||
NoProtocol = 15
|
||||
}
|
||||
|
||||
/// <summary>List of known SCSI definitions</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum ScsiDefinitions : byte
|
||||
{
|
||||
/// <summary>Unknown</summary>
|
||||
Current = 0,
|
||||
/// <summary>SCSI-1</summary>
|
||||
SCSI1 = 1,
|
||||
/// <summary>Unknown</summary>
|
||||
CCS = 2,
|
||||
/// <summary>SCSI-2</summary>
|
||||
SCSI2 = 3,
|
||||
/// <summary>SCSI-3</summary>
|
||||
SCSI3 = 4
|
||||
}
|
||||
|
||||
/// <summary>List of known SCSI physical interfaces</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum PhysicalInterfaces : uint
|
||||
{
|
||||
/// <summary>Unspecified physical interface</summary>
|
||||
Unspecified = 0,
|
||||
/// <summary>SCSI</summary>
|
||||
SCSI = 1,
|
||||
/// <summary>ATAPI</summary>
|
||||
ATAPI = 2,
|
||||
/// <summary>IEEE-1394/1995</summary>
|
||||
IEEE1394 = 3,
|
||||
/// <summary>IEEE-1394A</summary>
|
||||
IEEE1394A = 4,
|
||||
/// <summary>Fibre Channel</summary>
|
||||
FC = 5,
|
||||
/// <summary>IEEE-1394B</summary>
|
||||
IEEE1394B = 6,
|
||||
/// <summary>Serial ATAPI</summary>
|
||||
SerialATAPI = 7,
|
||||
/// <summary>USB</summary>
|
||||
USB = 8,
|
||||
/// <summary>Vendor unique</summary>
|
||||
Vendor = 0xFFFF
|
||||
}
|
||||
792
Aaru.CommonTypes/Structs/Devices/SCSI/Inquiry.cs
Normal file
792
Aaru.CommonTypes/Structs/Devices/SCSI/Inquiry.cs
Normal file
@@ -0,0 +1,792 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Inquiry.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common structures for SCSI devices.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines a high level interpretation of the SCSI INQUIRY response.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2023 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||
|
||||
/// <summary>
|
||||
/// Information from the following standards: T9/375-D revision 10l T10/995-D revision 10 T10/1236-D revision 20
|
||||
/// T10/1416-D revision 23 T10/1731-D revision 16 T10/502 revision 05 RFC 7144 ECMA-111
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public struct Inquiry
|
||||
{
|
||||
const string MODULE_NAME = "SCSI INQUIRY decoder";
|
||||
/// <summary>Peripheral qualifier Byte 0, bits 7 to 5</summary>
|
||||
public byte PeripheralQualifier;
|
||||
/// <summary>Peripheral device type Byte 0, bits 4 to 0</summary>
|
||||
public byte PeripheralDeviceType;
|
||||
/// <summary>Removable device Byte 1, bit 7</summary>
|
||||
public bool RMB;
|
||||
/// <summary>SCSI-1 vendor-specific qualification codes Byte 1, bits 6 to 0</summary>
|
||||
public byte DeviceTypeModifier;
|
||||
/// <summary>ISO/IEC SCSI Standard Version Byte 2, bits 7 to 6, mask = 0xC0, >> 6</summary>
|
||||
public byte ISOVersion;
|
||||
/// <summary>ECMA SCSI Standard Version Byte 2, bits 5 to 3, mask = 0x38, >> 3</summary>
|
||||
public byte ECMAVersion;
|
||||
/// <summary>ANSI SCSI Standard Version Byte 2, bits 2 to 0, mask = 0x07</summary>
|
||||
public byte ANSIVersion;
|
||||
/// <summary>Asynchronous Event Reporting Capability supported Byte 3, bit 7</summary>
|
||||
public bool AERC;
|
||||
/// <summary>Device supports TERMINATE TASK command Byte 3, bit 6</summary>
|
||||
public bool TrmTsk;
|
||||
/// <summary>Supports setting Normal ACA Byte 3, bit 5</summary>
|
||||
public bool NormACA;
|
||||
/// <summary>Supports LUN hierarchical addressing Byte 3, bit 4</summary>
|
||||
public bool HiSup;
|
||||
/// <summary>Responde data format Byte 3, bit 3 to 0</summary>
|
||||
public byte ResponseDataFormat;
|
||||
/// <summary>Lenght of total INQUIRY response minus 4 Byte 4</summary>
|
||||
public byte AdditionalLength;
|
||||
/// <summary>Device contains an embedded storage array controller Byte 5, bit 7</summary>
|
||||
public bool SCCS;
|
||||
/// <summary>Device contains an Access Control Coordinator Byte 5, bit 6</summary>
|
||||
public bool ACC;
|
||||
/// <summary>Supports asymetrical logical unit access Byte 5, bits 5 to 4</summary>
|
||||
public byte TPGS;
|
||||
/// <summary>Supports third-party copy commands Byte 5, bit 3</summary>
|
||||
public bool ThreePC;
|
||||
/// <summary>Reserved Byte 5, bits 2 to 1</summary>
|
||||
public byte Reserved2;
|
||||
/// <summary>Supports protection information Byte 5, bit 0</summary>
|
||||
public bool Protect;
|
||||
/// <summary>Supports basic queueing Byte 6, bit 7</summary>
|
||||
public bool BQue;
|
||||
/// <summary>Device contains an embedded enclosure services component Byte 6, bit 6</summary>
|
||||
public bool EncServ;
|
||||
/// <summary>Vendor-specific Byte 6, bit 5</summary>
|
||||
public bool VS1;
|
||||
/// <summary>Multi-port device Byte 6, bit 4</summary>
|
||||
public bool MultiP;
|
||||
/// <summary>Device contains or is attached to a medium changer Byte 6, bit 3</summary>
|
||||
public bool MChngr;
|
||||
/// <summary>Device supports request and acknowledge handshakes Byte 6, bit 2</summary>
|
||||
public bool ACKREQQ;
|
||||
/// <summary>Supports 32-bit wide SCSI addresses Byte 6, bit 1</summary>
|
||||
public bool Addr32;
|
||||
/// <summary>Supports 16-bit wide SCSI addresses Byte 6, bit 0</summary>
|
||||
public bool Addr16;
|
||||
/// <summary>Device supports relative addressing Byte 7, bit 7</summary>
|
||||
public bool RelAddr;
|
||||
/// <summary>Supports 32-bit wide data transfers Byte 7, bit 6</summary>
|
||||
public bool WBus32;
|
||||
/// <summary>Supports 16-bit wide data transfers Byte 7, bit 5</summary>
|
||||
public bool WBus16;
|
||||
/// <summary>Supports synchronous data transfer Byte 7, bit 4</summary>
|
||||
public bool Sync;
|
||||
/// <summary>Supports linked commands Byte 7, bit 3</summary>
|
||||
public bool Linked;
|
||||
/// <summary>Supports CONTINUE TASK and TARGET TRANSFER DISABLE commands Byte 7, bit 2</summary>
|
||||
public bool TranDis;
|
||||
/// <summary>Supports TCQ queue Byte 7, bit 1</summary>
|
||||
public bool CmdQue;
|
||||
/// <summary>Indicates that the devices responds to RESET with soft reset Byte 7, bit 0</summary>
|
||||
public bool SftRe;
|
||||
/// <summary>Vendor identification Bytes 8 to 15</summary>
|
||||
public byte[] VendorIdentification;
|
||||
/// <summary>Product identification Bytes 16 to 31</summary>
|
||||
public byte[] ProductIdentification;
|
||||
/// <summary>Product revision level Bytes 32 to 35</summary>
|
||||
public byte[] ProductRevisionLevel;
|
||||
/// <summary>Vendor-specific data Bytes 36 to 55</summary>
|
||||
public byte[] VendorSpecific;
|
||||
/// <summary>Byte 56, bits 7 to 4</summary>
|
||||
public byte Reserved3;
|
||||
/// <summary>Supported SPI clocking Byte 56, bits 3 to 2</summary>
|
||||
public byte Clocking;
|
||||
/// <summary>Device supports Quick Arbitration and Selection Byte 56, bit 1</summary>
|
||||
public bool QAS;
|
||||
/// <summary>Supports information unit transfers Byte 56, bit 0</summary>
|
||||
public bool IUS;
|
||||
/// <summary>Reserved Byte 57</summary>
|
||||
public byte Reserved4;
|
||||
/// <summary>Array of version descriptors Bytes 58 to 73</summary>
|
||||
public ushort[] VersionDescriptors;
|
||||
/// <summary>Reserved Bytes 74 to 95</summary>
|
||||
public byte[] Reserved5;
|
||||
/// <summary>Reserved Bytes 96 to end</summary>
|
||||
public byte[] VendorSpecific2;
|
||||
|
||||
// Per DLT4000/DLT4500/DLT4700 Cartridge Tape Subsystem Product Manual
|
||||
|
||||
#region Quantum vendor unique inquiry data structure
|
||||
|
||||
/// <summary>Means that the INQUIRY response contains 56 bytes or more, so this data has been filled</summary>
|
||||
public bool QuantumPresent;
|
||||
/// <summary>The product family. Byte 36, bits 7 to 5</summary>
|
||||
public byte Qt_ProductFamily;
|
||||
/// <summary>The released firmware. Byte 36, bits 4 to 0</summary>
|
||||
public byte Qt_ReleasedFirmware;
|
||||
/// <summary>The firmware major version. Byte 37</summary>
|
||||
public byte Qt_FirmwareMajorVersion;
|
||||
/// <summary>The firmware minor version. Byte 38</summary>
|
||||
public byte Qt_FirmwareMinorVersion;
|
||||
/// <summary>The EEPROM format major version. Byte 39</summary>
|
||||
public byte Qt_EEPROMFormatMajorVersion;
|
||||
/// <summary>The EEPROM format minor version. Byte 40</summary>
|
||||
public byte Qt_EEPROMFormatMinorVersion;
|
||||
/// <summary>The firmware personality. Byte 41</summary>
|
||||
public byte Qt_FirmwarePersonality;
|
||||
/// <summary>The firmware sub personality. Byte 42</summary>
|
||||
public byte Qt_FirmwareSubPersonality;
|
||||
/// <summary>The tape directory format version. Byte 43</summary>
|
||||
public byte Qt_TapeDirectoryFormatVersion;
|
||||
/// <summary>The controller hardware version. Byte 44</summary>
|
||||
public byte Qt_ControllerHardwareVersion;
|
||||
/// <summary>The drive EEPROM version. Byte 45</summary>
|
||||
public byte Qt_DriveEEPROMVersion;
|
||||
/// <summary>The drive hardware version. Byte 46</summary>
|
||||
public byte Qt_DriveHardwareVersion;
|
||||
/// <summary>The media loader firmware version. Byte 47</summary>
|
||||
public byte Qt_MediaLoaderFirmwareVersion;
|
||||
/// <summary>The media loader hardware version. Byte 48</summary>
|
||||
public byte Qt_MediaLoaderHardwareVersion;
|
||||
/// <summary>The media loader mechanical version. Byte 49</summary>
|
||||
public byte Qt_MediaLoaderMechanicalVersion;
|
||||
/// <summary>Is a media loader present? Byte 50</summary>
|
||||
public bool Qt_MediaLoaderPresent;
|
||||
/// <summary>Is a library present? Byte 51</summary>
|
||||
public bool Qt_LibraryPresent;
|
||||
/// <summary>The module revision. Bytes 52 to 55</summary>
|
||||
public byte[] Qt_ModuleRevision;
|
||||
|
||||
#endregion Quantum vendor unique inquiry data structure
|
||||
|
||||
#region IBM vendor unique inquiry data structure
|
||||
|
||||
/// <summary>Means that the INQUIRY response contains 56 bytes or more, so this data has been filled</summary>
|
||||
public bool IBMPresent;
|
||||
/// <summary>Drive is not capable of automation Byte 36 bit 0</summary>
|
||||
public bool IBM_AutDis;
|
||||
/// <summary>If not zero, limit in MB/s = Max * (this / 256) Byte 37</summary>
|
||||
public byte IBM_PerformanceLimit;
|
||||
/// <summary>Byte 41</summary>
|
||||
public byte IBM_OEMSpecific;
|
||||
|
||||
#endregion IBM vendor unique inquiry data structure
|
||||
|
||||
#region HP vendor unique inquiry data structure
|
||||
|
||||
/// <summary>Means that the INQUIRY response contains 49 bytes or more, so this data has been filled</summary>
|
||||
public bool HPPresent;
|
||||
/// <summary>WORM version Byte 40 bits 7 to 1</summary>
|
||||
public byte HP_WORMVersion;
|
||||
/// <summary>WORM supported Byte 40 bit 0</summary>
|
||||
public bool HP_WORM;
|
||||
/// <summary>Bytes 43 to 48</summary>
|
||||
public byte[] HP_OBDR;
|
||||
|
||||
#endregion HP vendor unique inquiry data structure
|
||||
|
||||
#region Seagate vendor unique inquiry data structure
|
||||
|
||||
/// <summary>Means that bytes 36 to 43 are filled</summary>
|
||||
public bool SeagatePresent;
|
||||
/// <summary>Drive Serial Number Bytes 36 to 43</summary>
|
||||
public byte[] Seagate_DriveSerialNumber;
|
||||
/// <summary>Means that bytes 96 to 143 are filled</summary>
|
||||
public bool Seagate2Present;
|
||||
/// <summary>Contains Seagate copyright notice Bytes 96 to 143</summary>
|
||||
public byte[] Seagate_Copyright;
|
||||
/// <summary>Means that bytes 144 to 147 are filled</summary>
|
||||
public bool Seagate3Present;
|
||||
/// <summary>Reserved Seagate field Bytes 144 to 147</summary>
|
||||
public byte[] Seagate_ServoPROMPartNo;
|
||||
|
||||
#endregion Seagate vendor unique inquiry data structure
|
||||
|
||||
#region Kreon vendor unique inquiry data structure
|
||||
|
||||
/// <summary>Means that firmware is Kreon</summary>
|
||||
public bool KreonPresent;
|
||||
/// <summary>Kreon identifier Bytes 36 to 40</summary>
|
||||
public byte[] KreonIdentifier;
|
||||
/// <summary>Kreon just a 0x20 Bytes 41</summary>
|
||||
public byte KreonSpace;
|
||||
/// <summary>Kreon version string Bytes 42 to 46</summary>
|
||||
public byte[] KreonVersion;
|
||||
|
||||
#endregion Kreon vendor unique inquiry data structure
|
||||
|
||||
#region Sony Hi-MD data
|
||||
|
||||
/// <summary>Set if Hi-MD signature is present</summary>
|
||||
public bool IsHiMD;
|
||||
/// <summary>Hi-MD signature, bytes 36 to 44</summary>
|
||||
public byte[] HiMDSignature;
|
||||
/// <summary>Unknown data, bytes 44 to 55</summary>
|
||||
public byte[] HiMDSpecific;
|
||||
|
||||
#endregion Sony Hi-MD data
|
||||
|
||||
static readonly byte[] HiMDSignatureContents = "Hi-MD "u8.ToArray();
|
||||
|
||||
/// <summary>Decodes a SCSI INQUIRY response</summary>
|
||||
/// <param name="SCSIInquiryResponse">INQUIRY raw response data</param>
|
||||
/// <returns>Decoded SCSI INQUIRY</returns>
|
||||
|
||||
#region Public methods
|
||||
|
||||
public static Inquiry? Decode(byte[] SCSIInquiryResponse)
|
||||
{
|
||||
if(SCSIInquiryResponse == null)
|
||||
return null;
|
||||
|
||||
if(SCSIInquiryResponse.Length < 36 && SCSIInquiryResponse.Length != 5)
|
||||
{
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME,
|
||||
Localization.INQUIRY_response_is_0_bytes_less_than_minimum_of_36_bytes,
|
||||
SCSIInquiryResponse.Length);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length < SCSIInquiryResponse[4] + 4 &&
|
||||
SCSIInquiryResponse.Length != SCSIInquiryResponse[4])
|
||||
{
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME,
|
||||
Localization.
|
||||
INQUIRY_response_length_0_bytes_is_different_than_specified_in_length_field,
|
||||
SCSIInquiryResponse.Length, SCSIInquiryResponse[4] + 4);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var decoded = new Inquiry();
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 1)
|
||||
{
|
||||
decoded.PeripheralQualifier = (byte)((SCSIInquiryResponse[0] & 0xE0) >> 5);
|
||||
decoded.PeripheralDeviceType = (byte)(SCSIInquiryResponse[0] & 0x1F);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 2)
|
||||
{
|
||||
decoded.RMB = Convert.ToBoolean(SCSIInquiryResponse[1] & 0x80);
|
||||
decoded.DeviceTypeModifier = (byte)(SCSIInquiryResponse[1] & 0x7F);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 3)
|
||||
{
|
||||
decoded.ISOVersion = (byte)((SCSIInquiryResponse[2] & 0xC0) >> 6);
|
||||
decoded.ECMAVersion = (byte)((SCSIInquiryResponse[2] & 0x38) >> 3);
|
||||
decoded.ANSIVersion = (byte)(SCSIInquiryResponse[2] & 0x07);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 4)
|
||||
{
|
||||
decoded.AERC = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x80);
|
||||
decoded.TrmTsk = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x40);
|
||||
decoded.NormACA = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x20);
|
||||
decoded.HiSup = Convert.ToBoolean(SCSIInquiryResponse[3] & 0x10);
|
||||
decoded.ResponseDataFormat = (byte)(SCSIInquiryResponse[3] & 0x07);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 5)
|
||||
decoded.AdditionalLength = SCSIInquiryResponse[4];
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 6)
|
||||
{
|
||||
decoded.SCCS = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x80);
|
||||
decoded.ACC = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x40);
|
||||
decoded.TPGS = (byte)((SCSIInquiryResponse[5] & 0x30) >> 4);
|
||||
decoded.ThreePC = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x08);
|
||||
decoded.Reserved2 = (byte)((SCSIInquiryResponse[5] & 0x06) >> 1);
|
||||
decoded.Protect = Convert.ToBoolean(SCSIInquiryResponse[5] & 0x01);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 7)
|
||||
{
|
||||
decoded.BQue = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x80);
|
||||
decoded.EncServ = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x40);
|
||||
decoded.VS1 = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x20);
|
||||
decoded.MultiP = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x10);
|
||||
decoded.MChngr = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x08);
|
||||
decoded.ACKREQQ = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x04);
|
||||
decoded.Addr32 = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x02);
|
||||
decoded.Addr16 = Convert.ToBoolean(SCSIInquiryResponse[6] & 0x01);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 8)
|
||||
{
|
||||
decoded.RelAddr = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x80);
|
||||
decoded.WBus32 = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x40);
|
||||
decoded.WBus16 = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x20);
|
||||
decoded.Sync = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x10);
|
||||
decoded.Linked = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x08);
|
||||
decoded.TranDis = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x04);
|
||||
decoded.CmdQue = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x02);
|
||||
decoded.SftRe = Convert.ToBoolean(SCSIInquiryResponse[7] & 0x01);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 16)
|
||||
{
|
||||
decoded.VendorIdentification = new byte[8];
|
||||
Array.Copy(SCSIInquiryResponse, 8, decoded.VendorIdentification, 0, 8);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 32)
|
||||
{
|
||||
decoded.ProductIdentification = new byte[16];
|
||||
Array.Copy(SCSIInquiryResponse, 16, decoded.ProductIdentification, 0, 16);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 36)
|
||||
{
|
||||
decoded.ProductRevisionLevel = new byte[4];
|
||||
Array.Copy(SCSIInquiryResponse, 32, decoded.ProductRevisionLevel, 0, 4);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 44)
|
||||
{
|
||||
// Seagate 1
|
||||
decoded.SeagatePresent = true;
|
||||
decoded.Seagate_DriveSerialNumber = new byte[8];
|
||||
Array.Copy(SCSIInquiryResponse, 36, decoded.Seagate_DriveSerialNumber, 0, 8);
|
||||
|
||||
// Hi-MD
|
||||
decoded.HiMDSignature = new byte[8];
|
||||
Array.Copy(SCSIInquiryResponse, 36, decoded.HiMDSignature, 0, 8);
|
||||
decoded.IsHiMD = HiMDSignatureContents.SequenceEqual(decoded.HiMDSignature);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 46)
|
||||
{
|
||||
// Kreon
|
||||
decoded.KreonIdentifier = new byte[5];
|
||||
Array.Copy(SCSIInquiryResponse, 36, decoded.KreonIdentifier, 0, 5);
|
||||
decoded.KreonSpace = SCSIInquiryResponse[41];
|
||||
decoded.KreonVersion = new byte[5];
|
||||
Array.Copy(SCSIInquiryResponse, 42, decoded.KreonVersion, 0, 5);
|
||||
|
||||
if(decoded.KreonSpace == 0x20 && decoded.KreonIdentifier.SequenceEqual("KREON"u8.ToArray()))
|
||||
decoded.KreonPresent = true;
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 49)
|
||||
{
|
||||
// HP
|
||||
decoded.HPPresent = true;
|
||||
decoded.HP_WORM |= (SCSIInquiryResponse[40] & 0x01) == 0x01;
|
||||
decoded.HP_WORMVersion = (byte)((SCSIInquiryResponse[40] & 0x7F) >> 1);
|
||||
decoded.HP_OBDR = new byte[6];
|
||||
Array.Copy(SCSIInquiryResponse, 43, decoded.HP_OBDR, 0, 6);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 56)
|
||||
{
|
||||
if(decoded.IsHiMD)
|
||||
{
|
||||
decoded.HiMDSpecific = new byte[12];
|
||||
Array.Copy(SCSIInquiryResponse, 44, decoded.HiMDSpecific, 0, 12);
|
||||
}
|
||||
else
|
||||
{
|
||||
decoded.VendorSpecific = new byte[20];
|
||||
Array.Copy(SCSIInquiryResponse, 36, decoded.VendorSpecific, 0, 20);
|
||||
}
|
||||
|
||||
// Quantum
|
||||
decoded.QuantumPresent = true;
|
||||
decoded.Qt_ProductFamily = (byte)((SCSIInquiryResponse[36] & 0xF0) >> 4);
|
||||
decoded.Qt_ReleasedFirmware = (byte)(SCSIInquiryResponse[36] & 0x0F);
|
||||
decoded.Qt_FirmwareMajorVersion = SCSIInquiryResponse[37];
|
||||
decoded.Qt_FirmwareMinorVersion = SCSIInquiryResponse[38];
|
||||
decoded.Qt_EEPROMFormatMajorVersion = SCSIInquiryResponse[39];
|
||||
decoded.Qt_EEPROMFormatMinorVersion = SCSIInquiryResponse[40];
|
||||
decoded.Qt_FirmwarePersonality = SCSIInquiryResponse[41];
|
||||
decoded.Qt_FirmwareSubPersonality = SCSIInquiryResponse[42];
|
||||
decoded.Qt_TapeDirectoryFormatVersion = SCSIInquiryResponse[43];
|
||||
decoded.Qt_ControllerHardwareVersion = SCSIInquiryResponse[44];
|
||||
decoded.Qt_DriveEEPROMVersion = SCSIInquiryResponse[45];
|
||||
decoded.Qt_DriveHardwareVersion = SCSIInquiryResponse[46];
|
||||
decoded.Qt_MediaLoaderFirmwareVersion = SCSIInquiryResponse[47];
|
||||
decoded.Qt_MediaLoaderHardwareVersion = SCSIInquiryResponse[48];
|
||||
decoded.Qt_MediaLoaderMechanicalVersion = SCSIInquiryResponse[49];
|
||||
decoded.Qt_MediaLoaderPresent = SCSIInquiryResponse[50] > 0;
|
||||
decoded.Qt_LibraryPresent = SCSIInquiryResponse[51] > 0;
|
||||
decoded.Qt_ModuleRevision = new byte[4];
|
||||
Array.Copy(SCSIInquiryResponse, 52, decoded.Qt_ModuleRevision, 0, 4);
|
||||
|
||||
// IBM
|
||||
decoded.IBMPresent = true;
|
||||
decoded.IBM_AutDis |= (SCSIInquiryResponse[36] & 0x01) == 0x01;
|
||||
decoded.IBM_PerformanceLimit = SCSIInquiryResponse[37];
|
||||
decoded.IBM_OEMSpecific = SCSIInquiryResponse[41];
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 57)
|
||||
{
|
||||
decoded.Reserved3 = (byte)((SCSIInquiryResponse[56] & 0xF0) >> 4);
|
||||
decoded.Clocking = (byte)((SCSIInquiryResponse[56] & 0x0C) >> 2);
|
||||
decoded.QAS = Convert.ToBoolean(SCSIInquiryResponse[56] & 0x02);
|
||||
decoded.IUS = Convert.ToBoolean(SCSIInquiryResponse[56] & 0x01);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 58)
|
||||
decoded.Reserved4 = SCSIInquiryResponse[57];
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 60)
|
||||
{
|
||||
int descriptorsNo;
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 74)
|
||||
descriptorsNo = 8;
|
||||
else
|
||||
descriptorsNo = (SCSIInquiryResponse.Length - 58) / 2;
|
||||
|
||||
decoded.VersionDescriptors = new ushort[descriptorsNo];
|
||||
|
||||
for(var i = 0; i < descriptorsNo; i++)
|
||||
decoded.VersionDescriptors[i] = BitConverter.ToUInt16(SCSIInquiryResponse, 58 + i * 2);
|
||||
}
|
||||
|
||||
switch(SCSIInquiryResponse.Length)
|
||||
{
|
||||
case >= 75 and < 96:
|
||||
decoded.Reserved5 = new byte[SCSIInquiryResponse.Length - 74];
|
||||
Array.Copy(SCSIInquiryResponse, 74, decoded.Reserved5, 0, SCSIInquiryResponse.Length - 74);
|
||||
|
||||
break;
|
||||
case >= 96:
|
||||
decoded.Reserved5 = new byte[22];
|
||||
Array.Copy(SCSIInquiryResponse, 74, decoded.Reserved5, 0, 22);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length > 96)
|
||||
{
|
||||
decoded.VendorSpecific2 = new byte[SCSIInquiryResponse.Length - 96];
|
||||
Array.Copy(SCSIInquiryResponse, 96, decoded.VendorSpecific2, 0, SCSIInquiryResponse.Length - 96);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length >= 144)
|
||||
{
|
||||
// Seagate 2
|
||||
decoded.Seagate2Present = true;
|
||||
decoded.Seagate_Copyright = new byte[48];
|
||||
Array.Copy(SCSIInquiryResponse, 96, decoded.Seagate_Copyright, 0, 48);
|
||||
}
|
||||
|
||||
if(SCSIInquiryResponse.Length < 148)
|
||||
return decoded;
|
||||
|
||||
// Seagate 2
|
||||
decoded.Seagate3Present = true;
|
||||
decoded.Seagate_ServoPROMPartNo = new byte[4];
|
||||
Array.Copy(SCSIInquiryResponse, 144, decoded.Seagate_ServoPROMPartNo, 0, 4);
|
||||
|
||||
return decoded;
|
||||
}
|
||||
|
||||
/// <summary>Encodes a SCSI INQUIRY response</summary>
|
||||
/// <param name="inq">Decoded SCSI INQUIRY</param>
|
||||
/// <returns>Raw SCSI INQUIRY response</returns>
|
||||
public static byte[] Encode(Inquiry? inq)
|
||||
{
|
||||
if(inq is null)
|
||||
return null;
|
||||
|
||||
Inquiry decoded = inq.Value;
|
||||
|
||||
var buffer = new byte[512];
|
||||
byte length = 0;
|
||||
|
||||
buffer[0] = (byte)(decoded.PeripheralQualifier << 5);
|
||||
buffer[0] += decoded.PeripheralDeviceType;
|
||||
|
||||
if(decoded.RMB)
|
||||
buffer[1] = 0x80;
|
||||
|
||||
buffer[1] += decoded.DeviceTypeModifier;
|
||||
|
||||
buffer[2] = (byte)(decoded.ISOVersion << 6);
|
||||
buffer[2] += (byte)(decoded.ECMAVersion << 3);
|
||||
buffer[2] += decoded.ANSIVersion;
|
||||
|
||||
if(decoded.AERC)
|
||||
buffer[3] = 0x80;
|
||||
|
||||
if(decoded.TrmTsk)
|
||||
buffer[3] += 0x40;
|
||||
|
||||
if(decoded.NormACA)
|
||||
buffer[3] += 0x20;
|
||||
|
||||
if(decoded.HiSup)
|
||||
buffer[3] += 0x10;
|
||||
|
||||
buffer[3] += decoded.ResponseDataFormat;
|
||||
|
||||
if(decoded.AdditionalLength > 0)
|
||||
{
|
||||
length = 5;
|
||||
buffer[4] = decoded.AdditionalLength;
|
||||
}
|
||||
|
||||
if(decoded.SCCS ||
|
||||
decoded.ACC ||
|
||||
decoded.TPGS > 0 ||
|
||||
decoded.ThreePC ||
|
||||
decoded.Reserved2 > 0 ||
|
||||
decoded.Protect)
|
||||
{
|
||||
length = 6;
|
||||
|
||||
if(decoded.SCCS)
|
||||
buffer[5] = 0x80;
|
||||
|
||||
if(decoded.ACC)
|
||||
buffer[5] += 0x40;
|
||||
|
||||
buffer[5] += (byte)(decoded.TPGS << 4);
|
||||
|
||||
if(decoded.ThreePC)
|
||||
buffer[5] += 0x08;
|
||||
|
||||
buffer[5] += (byte)(decoded.Reserved2 << 1);
|
||||
|
||||
if(decoded.Protect)
|
||||
buffer[5] += 0x01;
|
||||
}
|
||||
|
||||
if(decoded.BQue ||
|
||||
decoded.EncServ ||
|
||||
decoded.VS1 ||
|
||||
decoded.MultiP ||
|
||||
decoded.MChngr ||
|
||||
decoded.ACKREQQ ||
|
||||
decoded.Addr32 ||
|
||||
decoded.Addr16)
|
||||
{
|
||||
length = 7;
|
||||
|
||||
if(decoded.BQue)
|
||||
buffer[6] = 0x80;
|
||||
|
||||
if(decoded.EncServ)
|
||||
buffer[6] += 0x40;
|
||||
|
||||
if(decoded.VS1)
|
||||
buffer[6] += 0x20;
|
||||
|
||||
if(decoded.MultiP)
|
||||
buffer[6] += 0x10;
|
||||
|
||||
if(decoded.MChngr)
|
||||
buffer[6] += 0x08;
|
||||
|
||||
if(decoded.ACKREQQ)
|
||||
buffer[6] += 0x04;
|
||||
|
||||
if(decoded.Addr32)
|
||||
buffer[6] += 0x02;
|
||||
|
||||
if(decoded.Addr16)
|
||||
buffer[6] += 0x01;
|
||||
}
|
||||
|
||||
if(decoded.RelAddr ||
|
||||
decoded.WBus32 ||
|
||||
decoded.WBus16 ||
|
||||
decoded.Sync ||
|
||||
decoded.Linked ||
|
||||
decoded.TranDis ||
|
||||
decoded.CmdQue ||
|
||||
decoded.SftRe)
|
||||
|
||||
{
|
||||
length = 8;
|
||||
|
||||
if(decoded.RelAddr)
|
||||
buffer[7] = 0x80;
|
||||
|
||||
if(decoded.WBus32)
|
||||
buffer[7] += 0x40;
|
||||
|
||||
if(decoded.WBus16)
|
||||
buffer[7] += 0x20;
|
||||
|
||||
if(decoded.Sync)
|
||||
buffer[7] += 0x10;
|
||||
|
||||
if(decoded.Linked)
|
||||
buffer[7] += 0x08;
|
||||
|
||||
if(decoded.TranDis)
|
||||
buffer[7] += 0x04;
|
||||
|
||||
if(decoded.CmdQue)
|
||||
buffer[7] += 0x02;
|
||||
|
||||
if(decoded.SftRe)
|
||||
buffer[7] += 0x01;
|
||||
}
|
||||
|
||||
if(decoded.VendorIdentification != null)
|
||||
{
|
||||
length = 16;
|
||||
|
||||
Array.Copy(decoded.VendorIdentification, 0, buffer, 8,
|
||||
decoded.VendorIdentification.Length >= 8 ? 8 : decoded.VendorIdentification.Length);
|
||||
}
|
||||
|
||||
if(decoded.ProductIdentification != null)
|
||||
{
|
||||
length = 32;
|
||||
|
||||
Array.Copy(decoded.ProductIdentification, 0, buffer, 16,
|
||||
decoded.ProductIdentification.Length >= 16 ? 16 : decoded.ProductIdentification.Length);
|
||||
}
|
||||
|
||||
if(decoded.ProductRevisionLevel != null)
|
||||
{
|
||||
length = 36;
|
||||
|
||||
Array.Copy(decoded.ProductRevisionLevel, 0, buffer, 32,
|
||||
decoded.ProductRevisionLevel.Length >= 4 ? 4 : decoded.ProductRevisionLevel.Length);
|
||||
}
|
||||
|
||||
if(decoded.Seagate_DriveSerialNumber != null)
|
||||
{
|
||||
length = 44;
|
||||
Array.Copy(decoded.Seagate_DriveSerialNumber, 0, buffer, 36, 8);
|
||||
}
|
||||
|
||||
if(decoded is { KreonIdentifier: not null, KreonVersion: not null })
|
||||
{
|
||||
length = 46;
|
||||
Array.Copy(decoded.KreonIdentifier, 0, buffer, 36, 5);
|
||||
buffer[41] = decoded.KreonSpace;
|
||||
Array.Copy(decoded.KreonVersion, 0, buffer, 42, 5);
|
||||
}
|
||||
|
||||
if(decoded.HP_WORM || decoded.HP_WORMVersion > 0 || decoded.HP_OBDR != null)
|
||||
{
|
||||
length = 49;
|
||||
|
||||
if(decoded.HP_WORM)
|
||||
buffer[40] = 0x01;
|
||||
|
||||
buffer[40] += (byte)(decoded.HP_WORMVersion << 1);
|
||||
Array.Copy(decoded.HP_OBDR, 0, buffer, 43, 6);
|
||||
}
|
||||
|
||||
if(decoded.IsHiMD)
|
||||
{
|
||||
length = 56;
|
||||
Array.Copy(HiMDSignatureContents, 0, buffer, 36, 8);
|
||||
|
||||
if(decoded.HiMDSpecific != null)
|
||||
Array.Copy(decoded.HiMDSpecific, 0, buffer, 44, 12);
|
||||
}
|
||||
|
||||
if(decoded is { VendorSpecific: not null, IsHiMD: false })
|
||||
{
|
||||
length = 56;
|
||||
Array.Copy(decoded.VendorSpecific, 0, buffer, 36, 20);
|
||||
}
|
||||
|
||||
if(decoded.Reserved3 > 0 || decoded.Clocking > 0 || decoded.QAS || decoded.IUS)
|
||||
{
|
||||
length = 57;
|
||||
buffer[56] = (byte)(decoded.Reserved3 << 4);
|
||||
buffer[56] += (byte)(decoded.Clocking << 2);
|
||||
|
||||
if(decoded.QAS)
|
||||
buffer[56] += 0x02;
|
||||
|
||||
if(decoded.IUS)
|
||||
buffer[56] += 0x01;
|
||||
}
|
||||
|
||||
if(decoded.Reserved4 != 0)
|
||||
{
|
||||
length = 58;
|
||||
buffer[57] = decoded.Reserved4;
|
||||
}
|
||||
|
||||
if(decoded.VersionDescriptors != null)
|
||||
{
|
||||
length = (byte)(58 + decoded.VersionDescriptors.Length * 2);
|
||||
|
||||
for(var i = 0; i < decoded.VersionDescriptors.Length; i++)
|
||||
Array.Copy(BitConverter.GetBytes(decoded.VersionDescriptors[i]), 0, buffer, 56 + i * 2, 2);
|
||||
}
|
||||
|
||||
if(decoded.Reserved5 != null)
|
||||
{
|
||||
length = (byte)(74 + decoded.Reserved5.Length);
|
||||
Array.Copy(decoded.Reserved5, 0, buffer, 74, decoded.Reserved5.Length);
|
||||
}
|
||||
|
||||
if(decoded.VendorSpecific2 != null)
|
||||
{
|
||||
length = (byte)(96 + decoded.VendorSpecific2.Length);
|
||||
Array.Copy(decoded.VendorSpecific2, 0, buffer, 96, decoded.VendorSpecific2.Length);
|
||||
}
|
||||
|
||||
if(decoded.Seagate_Copyright != null)
|
||||
{
|
||||
length = 144;
|
||||
Array.Copy(decoded.Seagate_Copyright, 0, buffer, 96, 48);
|
||||
}
|
||||
|
||||
if(decoded.Seagate_ServoPROMPartNo != null)
|
||||
{
|
||||
length = 148;
|
||||
Array.Copy(decoded.Seagate_ServoPROMPartNo, 0, buffer, 144, 4);
|
||||
}
|
||||
|
||||
buffer[4] = length;
|
||||
var dest = new byte[length];
|
||||
Array.Copy(buffer, 0, dest, 0, length);
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
#endregion Public methods
|
||||
}
|
||||
566
Aaru.CommonTypes/Structs/Devices/SCSI/Modes/2A.cs
Normal file
566
Aaru.CommonTypes/Structs/Devices/SCSI/Modes/2A.cs
Normal file
@@ -0,0 +1,566 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : 2A.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common structures for SCSI devices.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Decodes SCSI MODE PAGE 2Ah: CD-ROM capabilities page.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// 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
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2023 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Aaru.CommonTypes.Structs.Devices.SCSI.Modes;
|
||||
|
||||
#region Mode Page 0x2A: CD-ROM capabilities page
|
||||
|
||||
/// <summary>
|
||||
/// CD-ROM capabilities page Page code 0x2A 16 bytes in OB-U0077C 20 bytes in SFF-8020i 22 bytes in MMC-1 26 bytes
|
||||
/// in MMC-2 Variable bytes in MMC-3
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public class ModePage_2A
|
||||
{
|
||||
/// <summary>Write speed performance descriptors</summary>
|
||||
public ModePage_2A_WriteDescriptor[] WriteSpeedPerformanceDescriptors;
|
||||
|
||||
/// <summary>Parameters can be saved</summary>
|
||||
public bool PS { get; set; }
|
||||
|
||||
/// <summary>Drive supports multi-session and/or Photo-CD</summary>
|
||||
public bool MultiSession { get; set; }
|
||||
|
||||
/// <summary>Drive is capable of reading sectors in Mode 2 Form 2 format</summary>
|
||||
public bool Mode2Form2 { get; set; }
|
||||
|
||||
/// <summary>Drive is capable of reading sectors in Mode 2 Form 1 format</summary>
|
||||
public bool Mode2Form1 { get; set; }
|
||||
|
||||
/// <summary>Drive is capable of playing audio</summary>
|
||||
public bool AudioPlay { get; set; }
|
||||
|
||||
/// <summary>Drive can return the ISRC</summary>
|
||||
public bool ISRC { get; set; }
|
||||
|
||||
/// <summary>Drive can return the media catalogue number</summary>
|
||||
public bool UPC { get; set; }
|
||||
|
||||
/// <summary>Drive can return C2 pointers</summary>
|
||||
public bool C2Pointer { get; set; }
|
||||
|
||||
/// <summary>Drive can read, deinterlave and correct R-W subchannels</summary>
|
||||
public bool DeinterlaveSubchannel { get; set; }
|
||||
|
||||
/// <summary>Drive can read interleaved and uncorrected R-W subchannels</summary>
|
||||
public bool Subchannel { get; set; }
|
||||
|
||||
/// <summary>Drive can continue from a loss of streaming on audio reading</summary>
|
||||
public bool AccurateCDDA { get; set; }
|
||||
|
||||
/// <summary>Audio can be read as digital data</summary>
|
||||
public bool CDDACommand { get; set; }
|
||||
|
||||
/// <summary>Loading Mechanism Type</summary>
|
||||
public byte LoadingMechanism { get; set; }
|
||||
|
||||
/// <summary>Drive can eject discs</summary>
|
||||
public bool Eject { get; set; }
|
||||
|
||||
/// <summary>Drive's optional prevent jumper status</summary>
|
||||
public bool PreventJumper { get; set; }
|
||||
|
||||
/// <summary>Current lock status</summary>
|
||||
public bool LockState { get; set; }
|
||||
|
||||
/// <summary>Drive can lock media</summary>
|
||||
public bool Lock { get; set; }
|
||||
|
||||
/// <summary>Each channel can be muted independently</summary>
|
||||
public bool SeparateChannelMute { get; set; }
|
||||
|
||||
/// <summary>Each channel's volume can be controlled independently</summary>
|
||||
public bool SeparateChannelVolume { get; set; }
|
||||
|
||||
/// <summary>Maximum drive speed in Kbytes/second</summary>
|
||||
public ushort MaximumSpeed { get; set; }
|
||||
|
||||
/// <summary>Supported volume levels</summary>
|
||||
public ushort SupportedVolumeLevels { get; set; }
|
||||
|
||||
/// <summary>Buffer size in Kbytes</summary>
|
||||
public ushort BufferSize { get; set; }
|
||||
|
||||
/// <summary>Current drive speed in Kbytes/second</summary>
|
||||
public ushort CurrentSpeed { get; set; }
|
||||
|
||||
/// <summary>Can read packet media</summary>
|
||||
public bool Method2 { get; set; }
|
||||
|
||||
/// <summary>Can read CD-RW</summary>
|
||||
public bool ReadCDRW { get; set; }
|
||||
|
||||
/// <summary>Can read CD-R</summary>
|
||||
public bool ReadCDR { get; set; }
|
||||
|
||||
/// <summary>Can write CD-RW</summary>
|
||||
public bool WriteCDRW { get; set; }
|
||||
|
||||
/// <summary>Can write CD-R</summary>
|
||||
public bool WriteCDR { get; set; }
|
||||
|
||||
/// <summary>Supports IEC-958 digital output on port 2</summary>
|
||||
public bool DigitalPort2 { get; set; }
|
||||
|
||||
/// <summary>Supports IEC-958 digital output on port 1</summary>
|
||||
public bool DigitalPort1 { get; set; }
|
||||
|
||||
/// <summary>Can deliver a composite audio and video data stream</summary>
|
||||
public bool Composite { get; set; }
|
||||
|
||||
/// <summary>This bit controls the behavior of the LOAD/UNLOAD command when trying to load a Slot with no Disc present</summary>
|
||||
public bool SSS { get; set; }
|
||||
|
||||
/// <summary>Contains a changer that can report the exact contents of the slots</summary>
|
||||
public bool SDP { get; set; }
|
||||
|
||||
/// <summary>Page length</summary>
|
||||
public byte Length { get; set; }
|
||||
|
||||
/// <summary>Set if LSB comes first</summary>
|
||||
public bool LSBF { get; set; }
|
||||
|
||||
/// <summary>Set if HIGH on LRCK indicates left channel. Clear if HIGH on LRCK indicates right channel.</summary>
|
||||
public bool RCK { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Set if data valid on the falling edge of the BCK signal. Clear if data valid on the rising edge of the BCK
|
||||
/// signal
|
||||
/// </summary>
|
||||
public bool BCK { get; set; }
|
||||
|
||||
/// <summary>Can do a test write</summary>
|
||||
public bool TestWrite { get; set; }
|
||||
|
||||
/// <summary>Maximum write speed</summary>
|
||||
public ushort MaxWriteSpeed { get; set; }
|
||||
|
||||
/// <summary>Current write speed</summary>
|
||||
public ushort CurrentWriteSpeed { get; set; }
|
||||
|
||||
/// <summary>Can read disc's barcode</summary>
|
||||
public bool ReadBarcode { get; set; }
|
||||
|
||||
/// <summary>Can read DVD-RAM</summary>
|
||||
public bool ReadDVDRAM { get; set; }
|
||||
|
||||
/// <summary>Can read DVD-R</summary>
|
||||
public bool ReadDVDR { get; set; }
|
||||
|
||||
/// <summary>Can read DVD-ROM</summary>
|
||||
public bool ReadDVDROM { get; set; }
|
||||
|
||||
/// <summary>Can write DVD-RAM</summary>
|
||||
public bool WriteDVDRAM { get; set; }
|
||||
|
||||
/// <summary>Can write DVD-R</summary>
|
||||
public bool WriteDVDR { get; set; }
|
||||
|
||||
/// <summary>Can read raw R-W subchannel from the Lead-In</summary>
|
||||
public bool LeadInPW { get; set; }
|
||||
|
||||
/// <summary>Can read both sides of a disc</summary>
|
||||
public bool SCC { get; set; }
|
||||
|
||||
/// <summary>Support copyright management</summary>
|
||||
public ushort CMRSupported { get; set; }
|
||||
|
||||
/// <summary>Supports buffer under-run free recording</summary>
|
||||
public bool BUF { get; set; }
|
||||
|
||||
/// <summary>Selected rotational control</summary>
|
||||
public byte RotationControlSelected { get; set; }
|
||||
|
||||
/// <summary>Current write speed selected</summary>
|
||||
public ushort CurrentWriteSpeedSelected { get; set; }
|
||||
|
||||
/// <summary>Database ID</summary>
|
||||
[JsonIgnore]
|
||||
[Key]
|
||||
// ReSharper disable once UnusedMember.Global
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>Decodes the page 2Ah of a MODE SENSE response</summary>
|
||||
/// <param name="pageResponse">Raw page 2Ah</param>
|
||||
/// <returns>Decoded page 2Ah</returns>
|
||||
public static ModePage_2A Decode(byte[] pageResponse)
|
||||
{
|
||||
if((pageResponse?[0] & 0x40) == 0x40)
|
||||
return null;
|
||||
|
||||
if((pageResponse?[0] & 0x3F) != 0x2A)
|
||||
return null;
|
||||
|
||||
if(pageResponse[1] + 2 != pageResponse.Length)
|
||||
return null;
|
||||
|
||||
if(pageResponse.Length < 16)
|
||||
return null;
|
||||
|
||||
var decoded = new ModePage_2A();
|
||||
|
||||
decoded.PS |= (pageResponse[0] & 0x80) == 0x80;
|
||||
|
||||
decoded.AudioPlay |= (pageResponse[4] & 0x01) == 0x01;
|
||||
decoded.Mode2Form1 |= (pageResponse[4] & 0x10) == 0x10;
|
||||
decoded.Mode2Form2 |= (pageResponse[4] & 0x20) == 0x20;
|
||||
decoded.MultiSession |= (pageResponse[4] & 0x40) == 0x40;
|
||||
|
||||
decoded.CDDACommand |= (pageResponse[5] & 0x01) == 0x01;
|
||||
decoded.AccurateCDDA |= (pageResponse[5] & 0x02) == 0x02;
|
||||
decoded.Subchannel |= (pageResponse[5] & 0x04) == 0x04;
|
||||
decoded.DeinterlaveSubchannel |= (pageResponse[5] & 0x08) == 0x08;
|
||||
decoded.C2Pointer |= (pageResponse[5] & 0x10) == 0x10;
|
||||
decoded.UPC |= (pageResponse[5] & 0x20) == 0x20;
|
||||
decoded.ISRC |= (pageResponse[5] & 0x40) == 0x40;
|
||||
|
||||
decoded.LoadingMechanism = (byte)((pageResponse[6] & 0xE0) >> 5);
|
||||
decoded.Lock |= (pageResponse[6] & 0x01) == 0x01;
|
||||
decoded.LockState |= (pageResponse[6] & 0x02) == 0x02;
|
||||
decoded.PreventJumper |= (pageResponse[6] & 0x04) == 0x04;
|
||||
decoded.Eject |= (pageResponse[6] & 0x08) == 0x08;
|
||||
|
||||
decoded.SeparateChannelVolume |= (pageResponse[7] & 0x01) == 0x01;
|
||||
decoded.SeparateChannelMute |= (pageResponse[7] & 0x02) == 0x02;
|
||||
|
||||
decoded.MaximumSpeed = (ushort)((pageResponse[8] << 8) + pageResponse[9]);
|
||||
decoded.SupportedVolumeLevels = (ushort)((pageResponse[10] << 8) + pageResponse[11]);
|
||||
decoded.BufferSize = (ushort)((pageResponse[12] << 8) + pageResponse[13]);
|
||||
decoded.CurrentSpeed = (ushort)((pageResponse[14] << 8) + pageResponse[15]);
|
||||
|
||||
if(pageResponse.Length < 20)
|
||||
return decoded;
|
||||
|
||||
decoded.Method2 |= (pageResponse[2] & 0x04) == 0x04;
|
||||
decoded.ReadCDRW |= (pageResponse[2] & 0x02) == 0x02;
|
||||
decoded.ReadCDR |= (pageResponse[2] & 0x01) == 0x01;
|
||||
|
||||
decoded.WriteCDRW |= (pageResponse[3] & 0x02) == 0x02;
|
||||
decoded.WriteCDR |= (pageResponse[3] & 0x01) == 0x01;
|
||||
|
||||
decoded.Composite |= (pageResponse[4] & 0x02) == 0x02;
|
||||
decoded.DigitalPort1 |= (pageResponse[4] & 0x04) == 0x04;
|
||||
decoded.DigitalPort2 |= (pageResponse[4] & 0x08) == 0x08;
|
||||
|
||||
decoded.SDP |= (pageResponse[7] & 0x04) == 0x04;
|
||||
decoded.SSS |= (pageResponse[7] & 0x08) == 0x08;
|
||||
|
||||
decoded.Length = (byte)((pageResponse[17] & 0x30) >> 4);
|
||||
decoded.LSBF |= (pageResponse[17] & 0x08) == 0x08;
|
||||
decoded.RCK |= (pageResponse[17] & 0x04) == 0x04;
|
||||
decoded.BCK |= (pageResponse[17] & 0x02) == 0x02;
|
||||
|
||||
if(pageResponse.Length < 22)
|
||||
return decoded;
|
||||
|
||||
decoded.TestWrite |= (pageResponse[3] & 0x04) == 0x04;
|
||||
decoded.MaxWriteSpeed = (ushort)((pageResponse[18] << 8) + pageResponse[19]);
|
||||
decoded.CurrentWriteSpeed = (ushort)((pageResponse[20] << 8) + pageResponse[21]);
|
||||
|
||||
decoded.ReadBarcode |= (pageResponse[5] & 0x80) == 0x80;
|
||||
|
||||
if(pageResponse.Length < 26)
|
||||
return decoded;
|
||||
|
||||
decoded.ReadDVDRAM |= (pageResponse[2] & 0x20) == 0x20;
|
||||
decoded.ReadDVDR |= (pageResponse[2] & 0x10) == 0x10;
|
||||
decoded.ReadDVDROM |= (pageResponse[2] & 0x08) == 0x08;
|
||||
|
||||
decoded.WriteDVDRAM |= (pageResponse[3] & 0x20) == 0x20;
|
||||
decoded.WriteDVDR |= (pageResponse[3] & 0x10) == 0x10;
|
||||
|
||||
decoded.LeadInPW |= (pageResponse[3] & 0x20) == 0x20;
|
||||
decoded.SCC |= (pageResponse[3] & 0x10) == 0x10;
|
||||
|
||||
decoded.CMRSupported = (ushort)((pageResponse[22] << 8) + pageResponse[23]);
|
||||
|
||||
if(pageResponse.Length < 32)
|
||||
return decoded;
|
||||
|
||||
decoded.BUF |= (pageResponse[4] & 0x80) == 0x80;
|
||||
decoded.RotationControlSelected = (byte)(pageResponse[27] & 0x03);
|
||||
decoded.CurrentWriteSpeedSelected = (ushort)((pageResponse[28] << 8) + pageResponse[29]);
|
||||
|
||||
var descriptors = (ushort)((pageResponse.Length - 32) / 4);
|
||||
decoded.WriteSpeedPerformanceDescriptors = new ModePage_2A_WriteDescriptor[descriptors];
|
||||
|
||||
for(var i = 0; i < descriptors; i++)
|
||||
{
|
||||
decoded.WriteSpeedPerformanceDescriptors[i] = new ModePage_2A_WriteDescriptor
|
||||
{
|
||||
RotationControl = (byte)(pageResponse[1 + 32 + i * 4] & 0x07),
|
||||
WriteSpeed = (ushort)((pageResponse[2 + 32 + i * 4] << 8) + pageResponse[3 + 32 + i * 4])
|
||||
};
|
||||
}
|
||||
|
||||
return decoded;
|
||||
}
|
||||
|
||||
/// <summary>Encodes a page 2Ah of a MODE SENSE response</summary>
|
||||
/// <param name="decoded">Decoded page 2Ah</param>
|
||||
/// <returns>Raw page 2Ah</returns>
|
||||
public static byte[] Encode(ModePage_2A decoded)
|
||||
{
|
||||
var pageResponse = new byte[512];
|
||||
byte length = 16;
|
||||
|
||||
pageResponse[0] = 0x2A;
|
||||
|
||||
if(decoded.PS)
|
||||
pageResponse[0] += 0x80;
|
||||
|
||||
if(decoded.AudioPlay)
|
||||
pageResponse[4] += 0x01;
|
||||
|
||||
if(decoded.Mode2Form1)
|
||||
pageResponse[4] += 0x10;
|
||||
|
||||
if(decoded.Mode2Form2)
|
||||
pageResponse[4] += 0x20;
|
||||
|
||||
if(decoded.MultiSession)
|
||||
pageResponse[4] += 0x40;
|
||||
|
||||
if(decoded.CDDACommand)
|
||||
pageResponse[5] += 0x01;
|
||||
|
||||
if(decoded.AccurateCDDA)
|
||||
pageResponse[5] += 0x02;
|
||||
|
||||
if(decoded.Subchannel)
|
||||
pageResponse[5] += 0x04;
|
||||
|
||||
if(decoded.DeinterlaveSubchannel)
|
||||
pageResponse[5] += 0x08;
|
||||
|
||||
if(decoded.C2Pointer)
|
||||
pageResponse[5] += 0x10;
|
||||
|
||||
if(decoded.UPC)
|
||||
pageResponse[5] += 0x20;
|
||||
|
||||
if(decoded.ISRC)
|
||||
pageResponse[5] += 0x40;
|
||||
|
||||
decoded.LoadingMechanism = (byte)((pageResponse[6] & 0xE0) >> 5);
|
||||
|
||||
if(decoded.Lock)
|
||||
pageResponse[6] += 0x01;
|
||||
|
||||
if(decoded.LockState)
|
||||
pageResponse[6] += 0x02;
|
||||
|
||||
if(decoded.PreventJumper)
|
||||
pageResponse[6] += 0x04;
|
||||
|
||||
if(decoded.Eject)
|
||||
pageResponse[6] += 0x08;
|
||||
|
||||
if(decoded.SeparateChannelVolume)
|
||||
pageResponse[7] += 0x01;
|
||||
|
||||
if(decoded.SeparateChannelMute)
|
||||
pageResponse[7] += 0x02;
|
||||
|
||||
decoded.MaximumSpeed = (ushort)((pageResponse[8] << 8) + pageResponse[9]);
|
||||
decoded.SupportedVolumeLevels = (ushort)((pageResponse[10] << 8) + pageResponse[11]);
|
||||
decoded.BufferSize = (ushort)((pageResponse[12] << 8) + pageResponse[13]);
|
||||
decoded.CurrentSpeed = (ushort)((pageResponse[14] << 8) + pageResponse[15]);
|
||||
|
||||
if(decoded.Method2 ||
|
||||
decoded.ReadCDRW ||
|
||||
decoded.ReadCDR ||
|
||||
decoded.WriteCDRW ||
|
||||
decoded.WriteCDR ||
|
||||
decoded.Composite ||
|
||||
decoded.DigitalPort1 ||
|
||||
decoded.DigitalPort2 ||
|
||||
decoded.SDP ||
|
||||
decoded.SSS ||
|
||||
decoded.Length > 0 ||
|
||||
decoded.LSBF ||
|
||||
decoded.RCK ||
|
||||
decoded.BCK)
|
||||
{
|
||||
length = 20;
|
||||
|
||||
if(decoded.Method2)
|
||||
pageResponse[2] += 0x04;
|
||||
|
||||
if(decoded.ReadCDRW)
|
||||
pageResponse[2] += 0x02;
|
||||
|
||||
if(decoded.ReadCDR)
|
||||
pageResponse[2] += 0x01;
|
||||
|
||||
if(decoded.WriteCDRW)
|
||||
pageResponse[3] += 0x02;
|
||||
|
||||
if(decoded.WriteCDR)
|
||||
pageResponse[3] += 0x01;
|
||||
|
||||
if(decoded.Composite)
|
||||
pageResponse[4] += 0x02;
|
||||
|
||||
if(decoded.DigitalPort1)
|
||||
pageResponse[4] += 0x04;
|
||||
|
||||
if(decoded.DigitalPort2)
|
||||
pageResponse[4] += 0x08;
|
||||
|
||||
if(decoded.SDP)
|
||||
pageResponse[7] += 0x04;
|
||||
|
||||
if(decoded.SSS)
|
||||
pageResponse[7] += 0x08;
|
||||
|
||||
pageResponse[17] = (byte)(decoded.Length << 4);
|
||||
|
||||
if(decoded.LSBF)
|
||||
pageResponse[17] += 0x08;
|
||||
|
||||
if(decoded.RCK)
|
||||
pageResponse[17] += 0x04;
|
||||
|
||||
if(decoded.BCK)
|
||||
pageResponse[17] += 0x02;
|
||||
}
|
||||
|
||||
if(decoded.TestWrite || decoded.MaxWriteSpeed > 0 || decoded.CurrentWriteSpeed > 0 || decoded.ReadBarcode)
|
||||
{
|
||||
length = 22;
|
||||
|
||||
if(decoded.TestWrite)
|
||||
pageResponse[3] += 0x04;
|
||||
|
||||
pageResponse[18] = (byte)((decoded.MaxWriteSpeed & 0xFF00) >> 8);
|
||||
pageResponse[19] = (byte)(decoded.MaxWriteSpeed & 0xFF);
|
||||
pageResponse[20] = (byte)((decoded.CurrentWriteSpeed & 0xFF00) >> 8);
|
||||
pageResponse[21] = (byte)(decoded.CurrentWriteSpeed & 0xFF);
|
||||
|
||||
if(decoded.ReadBarcode)
|
||||
pageResponse[5] += 0x80;
|
||||
}
|
||||
|
||||
if(decoded.ReadDVDRAM ||
|
||||
decoded.ReadDVDR ||
|
||||
decoded.ReadDVDROM ||
|
||||
decoded.WriteDVDRAM ||
|
||||
decoded.WriteDVDR ||
|
||||
decoded.LeadInPW ||
|
||||
decoded.SCC ||
|
||||
decoded.CMRSupported > 0)
|
||||
|
||||
{
|
||||
length = 26;
|
||||
|
||||
if(decoded.ReadDVDRAM)
|
||||
pageResponse[2] += 0x20;
|
||||
|
||||
if(decoded.ReadDVDR)
|
||||
pageResponse[2] += 0x10;
|
||||
|
||||
if(decoded.ReadDVDROM)
|
||||
pageResponse[2] += 0x08;
|
||||
|
||||
if(decoded.WriteDVDRAM)
|
||||
pageResponse[3] += 0x20;
|
||||
|
||||
if(decoded.WriteDVDR)
|
||||
pageResponse[3] += 0x10;
|
||||
|
||||
if(decoded.LeadInPW)
|
||||
pageResponse[3] += 0x20;
|
||||
|
||||
if(decoded.SCC)
|
||||
pageResponse[3] += 0x10;
|
||||
|
||||
pageResponse[22] = (byte)((decoded.CMRSupported & 0xFF00) >> 8);
|
||||
pageResponse[23] = (byte)(decoded.CMRSupported & 0xFF);
|
||||
}
|
||||
|
||||
if(decoded.BUF || decoded.RotationControlSelected > 0 || decoded.CurrentWriteSpeedSelected > 0)
|
||||
{
|
||||
length = 32;
|
||||
|
||||
if(decoded.BUF)
|
||||
pageResponse[4] += 0x80;
|
||||
|
||||
pageResponse[27] += decoded.RotationControlSelected;
|
||||
pageResponse[28] = (byte)((decoded.CurrentWriteSpeedSelected & 0xFF00) >> 8);
|
||||
pageResponse[29] = (byte)(decoded.CurrentWriteSpeedSelected & 0xFF);
|
||||
}
|
||||
|
||||
if(decoded.WriteSpeedPerformanceDescriptors != null)
|
||||
{
|
||||
length = 32;
|
||||
|
||||
for(var i = 0; i < decoded.WriteSpeedPerformanceDescriptors.Length; i++)
|
||||
{
|
||||
length += 4;
|
||||
pageResponse[1 + 32 + i * 4] = decoded.WriteSpeedPerformanceDescriptors[i].RotationControl;
|
||||
|
||||
pageResponse[2 + 32 + i * 4] =
|
||||
(byte)((decoded.WriteSpeedPerformanceDescriptors[i].WriteSpeed & 0xFF00) >> 8);
|
||||
|
||||
pageResponse[3 + 32 + i * 4] = (byte)(decoded.WriteSpeedPerformanceDescriptors[i].WriteSpeed & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
pageResponse[1] = (byte)(length - 2);
|
||||
var buf = new byte[length];
|
||||
Array.Copy(pageResponse, 0, buf, 0, length);
|
||||
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Page 2Ah write descriptor</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public struct ModePage_2A_WriteDescriptor
|
||||
{
|
||||
/// <summary>Rotational control</summary>
|
||||
public byte RotationControl;
|
||||
/// <summary>Write speed</summary>
|
||||
public ushort WriteSpeed;
|
||||
}
|
||||
|
||||
#endregion Mode Page 0x2A: CD-ROM capabilities page
|
||||
297
Aaru.CommonTypes/Structs/Filesystems.cs
Normal file
297
Aaru.CommonTypes/Structs/Filesystems.cs
Normal file
@@ -0,0 +1,297 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Structs.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common structures.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Contains enumerations and structures of common usage by filesystem
|
||||
// plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2023 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Aaru.CommonTypes.Structs;
|
||||
|
||||
/// <summary>File attributes.</summary>
|
||||
[Flags]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public enum FileAttributes : ulong
|
||||
{
|
||||
/// <summary>File has no attributes</summary>
|
||||
None = 0,
|
||||
/// <summary>File is an alias (Mac OS)</summary>
|
||||
Alias = 0x01,
|
||||
/// <summary>Indicates that the file can only be writable appended</summary>
|
||||
AppendOnly = 0x02,
|
||||
/// <summary>File is candidate for archival/backup</summary>
|
||||
Archive = 0x04,
|
||||
/// <summary>File is a block device</summary>
|
||||
BlockDevice = 0x08,
|
||||
/// <summary>File is stored on filesystem block units instead of device sectors</summary>
|
||||
BlockUnits = 0x10,
|
||||
/// <summary>Directory is a bundle or file contains a BNDL resource</summary>
|
||||
Bundle = 0x20,
|
||||
/// <summary>File is a char device</summary>
|
||||
CharDevice = 0x40,
|
||||
/// <summary>File is compressed</summary>
|
||||
Compressed = 0x80,
|
||||
/// <summary>File is compressed and should not be uncompressed on read</summary>
|
||||
CompressedRaw = 0x100,
|
||||
/// <summary>File has compression errors</summary>
|
||||
CompressionError = 0x200,
|
||||
/// <summary>Compressed file is dirty</summary>
|
||||
CompressionDirty = 0x400,
|
||||
/// <summary>File is a device</summary>
|
||||
Device = 0x800,
|
||||
/// <summary>File is a directory</summary>
|
||||
Directory = 0x1000,
|
||||
/// <summary>File is encrypted</summary>
|
||||
Encrypted = 0x2000,
|
||||
/// <summary>File is stored on disk using extents</summary>
|
||||
Extents = 0x4000,
|
||||
/// <summary>File is a FIFO</summary>
|
||||
FIFO = 0x8000,
|
||||
/// <summary>File is a normal file</summary>
|
||||
File = 0x10000,
|
||||
/// <summary>File is a Mac OS file containing desktop databases that has already been added to the desktop database</summary>
|
||||
HasBeenInited = 0x20000,
|
||||
/// <summary>File contains an icon resource / EA</summary>
|
||||
HasCustomIcon = 0x40000,
|
||||
/// <summary>File is a Mac OS extension or control panel lacking INIT resources</summary>
|
||||
HasNoINITs = 0x80000,
|
||||
/// <summary>File is hidden/invisible</summary>
|
||||
Hidden = 0x100000,
|
||||
/// <summary>File cannot be written, deleted, modified or linked to</summary>
|
||||
Immutable = 0x200000,
|
||||
/// <summary>Directory is indexed using hashed trees</summary>
|
||||
IndexedDirectory = 0x400000,
|
||||
/// <summary>File contents are stored alongside its inode (or equivalent)</summary>
|
||||
Inline = 0x800000,
|
||||
/// <summary>File contains integrity checks</summary>
|
||||
IntegrityStream = 0x1000000,
|
||||
/// <summary>File is on desktop</summary>
|
||||
IsOnDesk = 0x2000000,
|
||||
/// <summary>File changes are written to filesystem journal before being written to file itself</summary>
|
||||
Journaled = 0x4000000,
|
||||
/// <summary>Access time will not be modified</summary>
|
||||
NoAccessTime = 0x8000000,
|
||||
/// <summary>File will not be subject to copy-on-write</summary>
|
||||
NoCopyOnWrite = 0x10000000,
|
||||
/// <summary>File will not be backed up</summary>
|
||||
NoDump = 0x20000000,
|
||||
/// <summary>File contents should not be scrubbed</summary>
|
||||
NoScrub = 0x40000000,
|
||||
/// <summary>File contents should not be indexed</summary>
|
||||
NotIndexed = 0x80000000,
|
||||
/// <summary>File is offline</summary>
|
||||
Offline = 0x100000000,
|
||||
/// <summary>File is password protected, but contents are not encrypted on disk</summary>
|
||||
Password = 0x200000000,
|
||||
/// <summary>File is read-only</summary>
|
||||
ReadOnly = 0x400000000,
|
||||
/// <summary>File is a reparse point</summary>
|
||||
ReparsePoint = 0x800000000,
|
||||
/// <summary>When file is removed its content will be overwritten with zeroes</summary>
|
||||
Secured = 0x1000000000,
|
||||
/// <summary>File contents are sparse</summary>
|
||||
Sparse = 0x2000000000,
|
||||
/// <summary>File is a shadow (OS/2)</summary>
|
||||
Shadow = 0x4000000000,
|
||||
/// <summary>File is shared</summary>
|
||||
Shared = 0x8000000000,
|
||||
/// <summary>File is a stationery</summary>
|
||||
Stationery = 0x10000000000,
|
||||
/// <summary>File is a symbolic link</summary>
|
||||
Symlink = 0x20000000000,
|
||||
/// <summary>File writes are synchronously written to disk</summary>
|
||||
Sync = 0x40000000000,
|
||||
/// <summary>File belongs to the operating system</summary>
|
||||
System = 0x80000000000,
|
||||
/// <summary>If file end is a partial block its content will be merged with other files</summary>
|
||||
TailMerged = 0x100000000000,
|
||||
/// <summary>File is temporary</summary>
|
||||
Temporary = 0x200000000000,
|
||||
/// <summary>Subdirectories inside of this directory are not related and should be allocated elsewhere</summary>
|
||||
TopDirectory = 0x400000000000,
|
||||
/// <summary>If file is deleted, contents should be stored, for a possible future undeletion</summary>
|
||||
Undeletable = 0x800000000000,
|
||||
/// <summary>File is a pipe</summary>
|
||||
Pipe = 0x1000000000000,
|
||||
/// <summary>File is a socket</summary>
|
||||
Socket = 0x2000000000000
|
||||
}
|
||||
|
||||
/// <summary>Information about a file entry</summary>
|
||||
public class FileEntryInfo
|
||||
{
|
||||
/// <summary>File attributes</summary>
|
||||
public FileAttributes Attributes { get; set; }
|
||||
|
||||
/// <summary>File length in blocks</summary>
|
||||
public long Blocks { get; set; }
|
||||
|
||||
/// <summary>File block size in bytes</summary>
|
||||
public long BlockSize { get; set; }
|
||||
|
||||
/// <summary>If file points to a device, device number. Null if the underlying filesystem does not support them.</summary>
|
||||
public ulong? DeviceNo { get; set; }
|
||||
|
||||
/// <summary>POSIX group ID. Null if the underlying filesystem does not support them.</summary>
|
||||
public ulong? GID { get; set; }
|
||||
|
||||
/// <summary>inode number for this file (or other unique identifier for the volume)</summary>
|
||||
public ulong Inode { get; set; }
|
||||
|
||||
/// <summary>File length in bytes</summary>
|
||||
public long Length { get; set; }
|
||||
|
||||
/// <summary>Number of hard links pointing to this file (. and .. entries count as hard links)</summary>
|
||||
public ulong Links { get; set; }
|
||||
|
||||
/// <summary>POSIX permissions/mode for this file. Null if the underlying filesystem does not support them.</summary>
|
||||
public uint? Mode { get; set; }
|
||||
|
||||
/// <summary>POSIX owner ID. Null if the underlying filesystem does not support them.</summary>
|
||||
public ulong? UID { get; set; }
|
||||
|
||||
/// <summary>File creation date in UTC. Null if the underlying filesystem does not support them.</summary>
|
||||
public DateTime? CreationTimeUtc { get; set; }
|
||||
|
||||
/// <summary>File last access date in UTC. Null if the underlying filesystem does not support them.</summary>
|
||||
public DateTime? AccessTimeUtc { get; set; }
|
||||
|
||||
/// <summary>File attributes change date in UTC. Null if the underlying filesystem does not support them.</summary>
|
||||
public DateTime? StatusChangeTimeUtc { get; set; }
|
||||
|
||||
/// <summary>File last backup date in UTC. Null if the underlying filesystem does not support them.</summary>
|
||||
public DateTime? BackupTimeUtc { get; set; }
|
||||
|
||||
/// <summary>File last modification date in UTC. Null if the underlying filesystem does not support them.</summary>
|
||||
public DateTime? LastWriteTimeUtc { get; set; }
|
||||
|
||||
/// <summary>File creation date. Null if the underlying filesystem does not support them.</summary>
|
||||
[JsonIgnore]
|
||||
public DateTime? CreationTime
|
||||
{
|
||||
get => CreationTimeUtc?.ToLocalTime();
|
||||
set => CreationTimeUtc = value?.ToUniversalTime();
|
||||
}
|
||||
|
||||
/// <summary>File last access date. Null if the underlying filesystem does not support them.</summary>
|
||||
[JsonIgnore]
|
||||
public DateTime? AccessTime
|
||||
{
|
||||
get => AccessTimeUtc?.ToLocalTime();
|
||||
set => AccessTimeUtc = value?.ToUniversalTime();
|
||||
}
|
||||
|
||||
/// <summary>File attributes change date. Null if the underlying filesystem does not support them.</summary>
|
||||
[JsonIgnore]
|
||||
public DateTime? StatusChangeTime
|
||||
{
|
||||
get => StatusChangeTimeUtc?.ToLocalTime();
|
||||
set => StatusChangeTimeUtc = value?.ToUniversalTime();
|
||||
}
|
||||
|
||||
/// <summary>File last backup date. Null if the underlying filesystem does not support them.</summary>
|
||||
[JsonIgnore]
|
||||
public DateTime? BackupTime
|
||||
{
|
||||
get => BackupTimeUtc?.ToLocalTime();
|
||||
set => BackupTimeUtc = value?.ToUniversalTime();
|
||||
}
|
||||
|
||||
/// <summary>File last modification date. Null if the underlying filesystem does not support them.</summary>
|
||||
[JsonIgnore]
|
||||
public DateTime? LastWriteTime
|
||||
{
|
||||
get => LastWriteTimeUtc?.ToLocalTime();
|
||||
set => LastWriteTimeUtc = value?.ToUniversalTime();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Information about a volume</summary>
|
||||
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
|
||||
public class FileSystemInfo
|
||||
{
|
||||
/// <summary>Blocks for this filesystem</summary>
|
||||
public ulong Blocks;
|
||||
/// <summary>Maximum length of filenames on this filesystem</summary>
|
||||
public ushort FilenameLength;
|
||||
/// <summary>Files on this filesystem</summary>
|
||||
public ulong Files;
|
||||
/// <summary>Blocks free on this filesystem</summary>
|
||||
public ulong FreeBlocks;
|
||||
/// <summary>Free inodes on this filesystem</summary>
|
||||
public ulong FreeFiles;
|
||||
/// <summary>Filesystem ID</summary>
|
||||
public FileSystemId Id;
|
||||
/// <summary>ID of plugin for this file</summary>
|
||||
public Guid PluginId;
|
||||
/// <summary>Filesystem type</summary>
|
||||
public string Type;
|
||||
|
||||
/// <summary>Initializes an empty instance of this structure</summary>
|
||||
public FileSystemInfo() => Id = new FileSystemId();
|
||||
|
||||
/// <summary>Gets a clone of this structure</summary>
|
||||
/// <returns>Clone of this structure</returns>
|
||||
public FileSystemInfo ShallowCopy() => (FileSystemInfo)MemberwiseClone();
|
||||
}
|
||||
|
||||
/// <summary>Stores a filesystem volume unique identifier or serial number</summary>
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct FileSystemId
|
||||
{
|
||||
/// <summary>Set to <c>true</c> if the identifier is a 32-bit integer</summary>
|
||||
[FieldOffset(0)]
|
||||
public bool IsInt;
|
||||
/// <summary>Set to <c>true</c> if the identifier is a 64-bit integer</summary>
|
||||
[FieldOffset(1)]
|
||||
public bool IsLong;
|
||||
/// <summary>Set to <c>true</c> if the identifier is a GUID</summary>
|
||||
[FieldOffset(2)]
|
||||
public bool IsGuid;
|
||||
|
||||
/// <summary>Identifier as a 32-bit integer</summary>
|
||||
[FieldOffset(3)]
|
||||
public uint Serial32;
|
||||
/// <summary>Identifier as a 64-bit integer</summary>
|
||||
[FieldOffset(3)]
|
||||
public ulong Serial64;
|
||||
/// <summary>Identifier as a GUID</summary>
|
||||
[FieldOffset(3)]
|
||||
public Guid uuid;
|
||||
}
|
||||
256
Aaru.CommonTypes/Structs/Images.cs
Normal file
256
Aaru.CommonTypes/Structs/Images.cs
Normal file
@@ -0,0 +1,256 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IMediaImage.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common structures.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines structures to be used by media image plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2023 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
|
||||
namespace Aaru.CommonTypes.Structs;
|
||||
|
||||
/// <summary>Contains information about a dump image and its contents</summary>
|
||||
public struct ImageInfo
|
||||
{
|
||||
/// <summary>Image contains partitions (or tracks for optical media)</summary>
|
||||
public bool HasPartitions;
|
||||
/// <summary>Image contains sessions (optical media only)</summary>
|
||||
public bool HasSessions;
|
||||
/// <summary>Size of the image without headers</summary>
|
||||
public ulong ImageSize;
|
||||
/// <summary>Sectors contained in the image</summary>
|
||||
public ulong Sectors;
|
||||
/// <summary>Size of sectors contained in the image</summary>
|
||||
public uint SectorSize;
|
||||
/// <summary>Media tags contained by the image</summary>
|
||||
public List<MediaTagType> ReadableMediaTags;
|
||||
/// <summary>Sector tags contained by the image</summary>
|
||||
public List<SectorTagType> ReadableSectorTags;
|
||||
/// <summary>Image version</summary>
|
||||
public string Version;
|
||||
/// <summary>Application that created the image</summary>
|
||||
public string Application;
|
||||
/// <summary>Version of the application that created the image</summary>
|
||||
public string ApplicationVersion;
|
||||
/// <summary>Who (person) created the image?</summary>
|
||||
public string Creator;
|
||||
/// <summary>Image creation time</summary>
|
||||
public DateTime CreationTime;
|
||||
/// <summary>Image last modification time</summary>
|
||||
public DateTime LastModificationTime;
|
||||
/// <summary>Title of the media represented by the image</summary>
|
||||
public string MediaTitle;
|
||||
/// <summary>Image comments</summary>
|
||||
public string Comments;
|
||||
/// <summary>Manufacturer of the media represented by the image</summary>
|
||||
public string MediaManufacturer;
|
||||
/// <summary>Model of the media represented by the image</summary>
|
||||
public string MediaModel;
|
||||
/// <summary>Serial number of the media represented by the image</summary>
|
||||
public string MediaSerialNumber;
|
||||
/// <summary>Barcode of the media represented by the image</summary>
|
||||
public string MediaBarcode;
|
||||
/// <summary>Part number of the media represented by the image</summary>
|
||||
public string MediaPartNumber;
|
||||
/// <summary>Media type represented by the image</summary>
|
||||
public MediaType MediaType;
|
||||
/// <summary>Number in sequence for the media represented by the image</summary>
|
||||
public int MediaSequence;
|
||||
/// <summary>Last media of the sequence the media represented by the image corresponds to</summary>
|
||||
public int LastMediaSequence;
|
||||
/// <summary>Manufacturer of the drive used to read the media represented by the image</summary>
|
||||
public string DriveManufacturer;
|
||||
/// <summary>Model of the drive used to read the media represented by the image</summary>
|
||||
public string DriveModel;
|
||||
/// <summary>Serial number of the drive used to read the media represented by the image</summary>
|
||||
public string DriveSerialNumber;
|
||||
/// <summary>Firmware revision of the drive used to read the media represented by the image</summary>
|
||||
public string DriveFirmwareRevision;
|
||||
/// <summary>Type of the media represented by the image to use in XML sidecars</summary>
|
||||
public MetadataMediaType MetadataMediaType;
|
||||
|
||||
// CHS geometry...
|
||||
/// <summary>Cylinders of the media represented by the image</summary>
|
||||
public uint Cylinders;
|
||||
/// <summary>Heads of the media represented by the image</summary>
|
||||
public uint Heads;
|
||||
/// <summary>Sectors per track of the media represented by the image (for variable image, the smallest)</summary>
|
||||
public uint SectorsPerTrack;
|
||||
}
|
||||
|
||||
/// <summary>Session defining structure.</summary>
|
||||
public struct Session
|
||||
{
|
||||
/// <summary>Session number, 1-started</summary>
|
||||
public ushort Sequence;
|
||||
/// <summary>First track present on this session</summary>
|
||||
public uint StartTrack;
|
||||
/// <summary>Last track present on this session</summary>
|
||||
public uint EndTrack;
|
||||
/// <summary>First sector present on this session</summary>
|
||||
public ulong StartSector;
|
||||
/// <summary>Last sector present on this session</summary>
|
||||
public ulong EndSector;
|
||||
}
|
||||
|
||||
/// <summary>Track defining structure.</summary>
|
||||
public class Track
|
||||
{
|
||||
/// <summary>How many main channel / user data bytes are per sector in this track</summary>
|
||||
public int BytesPerSector;
|
||||
/// <summary>Information that does not find space in this struct</summary>
|
||||
public string Description;
|
||||
/// <summary>Track ending sector</summary>
|
||||
public ulong EndSector;
|
||||
/// <summary>Which file stores this track</summary>
|
||||
public string File;
|
||||
/// <summary>Starting at which byte is this track stored</summary>
|
||||
public ulong FileOffset;
|
||||
/// <summary>What kind of file is storing this track</summary>
|
||||
public string FileType;
|
||||
/// <summary>Which filter stores this track</summary>
|
||||
public IFilter Filter;
|
||||
/// <summary>Indexes, 00 to 99 and sector offset</summary>
|
||||
public Dictionary<ushort, int> Indexes;
|
||||
/// <summary>Track pre-gap</summary>
|
||||
public ulong Pregap;
|
||||
/// <summary>How many main channel bytes per sector are in the file with this track</summary>
|
||||
public int RawBytesPerSector;
|
||||
/// <summary>Track number, 1-started</summary>
|
||||
public uint Sequence;
|
||||
/// <summary>Session this track belongs to</summary>
|
||||
public ushort Session;
|
||||
/// <summary>Track starting sector</summary>
|
||||
public ulong StartSector;
|
||||
/// <summary>Which file stores this track's subchannel</summary>
|
||||
public string SubchannelFile;
|
||||
/// <summary>Which filter stores this track's subchannel</summary>
|
||||
public IFilter SubchannelFilter;
|
||||
/// <summary>Starting at which byte are this track's subchannel stored</summary>
|
||||
public ulong SubchannelOffset;
|
||||
/// <summary>Type of subchannel stored for this track</summary>
|
||||
public TrackSubchannelType SubchannelType;
|
||||
/// <summary>Partition type</summary>
|
||||
public TrackType Type;
|
||||
|
||||
/// <summary>Initializes an empty instance of this structure</summary>
|
||||
public Track() => Indexes = new Dictionary<ushort, int>();
|
||||
}
|
||||
|
||||
/// <summary>Floppy physical characteristics structure.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public struct FloppyInfo
|
||||
{
|
||||
/// <summary>Physical floppy type.</summary>
|
||||
public FloppyTypes Type;
|
||||
/// <summary>Bitrate in bits per second used to write the floppy, 0 if unknown or track-variable.</summary>
|
||||
public uint Bitrate;
|
||||
/// <summary>Physical magnetic density (coercivity) of floppy medium.</summary>
|
||||
public FloppyDensities Coercivity;
|
||||
/// <summary>How many physical tracks are actually written in the floppy image.</summary>
|
||||
public ushort Tracks;
|
||||
/// <summary>How many physical heads are actually written in the floppy image.</summary>
|
||||
public byte Heads;
|
||||
/// <summary>How many tracks per inch are actually written in the floppy image.</summary>
|
||||
public ushort TrackDensity;
|
||||
}
|
||||
|
||||
/// <summary>Provides a map for linear memory structure</summary>
|
||||
public struct LinearMemoryMap
|
||||
{
|
||||
/// <summary>List of devices that are mapped to linear memory</summary>
|
||||
[NotNull]
|
||||
public LinearMemoryDevice[] Devices { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>Provides information about a linear memory device</summary>
|
||||
public struct LinearMemoryDevice
|
||||
{
|
||||
/// <summary>Device manufacturer</summary>
|
||||
public string Manufacturer { get; set; }
|
||||
|
||||
/// <summary>Device model</summary>
|
||||
public string Model { get; set; }
|
||||
|
||||
/// <summary>Device package, e.g. DIP28</summary>
|
||||
public string Package { get; set; }
|
||||
|
||||
/// <summary>Device location marking in PCB, e.g. U28</summary>
|
||||
public string Location { get; set; }
|
||||
|
||||
/// <summary>Device functional type</summary>
|
||||
public LinearMemoryType Type { get; set; }
|
||||
|
||||
/// <summary>Arbitrary device information</summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Physical addressing is the address considering all devices in the linear memory media, starting at the lowest
|
||||
/// marking in PCB and going up incrementally. This is the view of the memory inside Aaru.
|
||||
/// </summary>
|
||||
public LinearMemoryAddressing PhysicalAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Virtual addressing is the address as seen by the hardware directly accessing the linear memory media. This
|
||||
/// allows devices to be overlapped or banked.
|
||||
/// </summary>
|
||||
public LinearMemoryAddressing VirtualAddress { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>Maps the addressing of a linear memory device</summary>
|
||||
public class LinearMemoryAddressing
|
||||
{
|
||||
/// <summary>Start in memory where the device is mapped</summary>
|
||||
public ulong Start { get; set; }
|
||||
|
||||
/// <summary>Length in bytes of the device, not including interleaving</summary>
|
||||
public ulong Length { get; set; }
|
||||
|
||||
/// <summary>Interleaving information</summary>
|
||||
public LinearMemoryInterleave Interleave { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>Provides information about a device interleaving</summary>
|
||||
public class LinearMemoryInterleave
|
||||
{
|
||||
/// <summary>How many bytes to skip from start of map before device first byte starts</summary>
|
||||
public uint Offset { get; set; }
|
||||
|
||||
/// <summary>How many bytes in memory to skip every device byte</summary>
|
||||
public uint Value { get; set; }
|
||||
}
|
||||
52
Aaru.CommonTypes/Structs/TapeFile.cs
Normal file
52
Aaru.CommonTypes/Structs/TapeFile.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : TapeFile.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common structures.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines a structure to hold information about a tape file object.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2023 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.CommonTypes.Structs;
|
||||
|
||||
/// <summary>Describes a tape file</summary>
|
||||
public struct TapeFile
|
||||
{
|
||||
/// <summary>File number</summary>
|
||||
public uint File;
|
||||
/// <summary>Partition number</summary>
|
||||
public byte Partition;
|
||||
/// <summary>First block, inclusive, of the file</summary>
|
||||
public ulong FirstBlock;
|
||||
/// <summary>Last block, inclusive, of the file</summary>
|
||||
public ulong LastBlock;
|
||||
}
|
||||
50
Aaru.CommonTypes/Structs/TapePartition.cs
Normal file
50
Aaru.CommonTypes/Structs/TapePartition.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : TapeFile.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Common structures.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines a structure to hold information about a tape partition.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2023 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.CommonTypes.Structs;
|
||||
|
||||
/// <summary>Describes a tape partition</summary>
|
||||
public struct TapePartition
|
||||
{
|
||||
/// <summary>Partition number</summary>
|
||||
public byte Number;
|
||||
/// <summary>First block, inclusive, of the partition</summary>
|
||||
public ulong FirstBlock;
|
||||
/// <summary>Last block, inclusive, of the partition</summary>
|
||||
public ulong LastBlock;
|
||||
}
|
||||
Reference in New Issue
Block a user