// /*************************************************************************** // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // // Filename : Types.cs // Author(s) : Natalia Portillo // // Component : Device structures decoders. // // --[ Description ] ---------------------------------------------------------- // // Contains PCMCIA tuple structures. // // --[ 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 . // // ---------------------------------------------------------------------------- // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ using System.Diagnostics.CodeAnalysis; namespace Aaru.Decoders.PCMCIA; /// Basic classure of a PCMCIA tuple [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class Tuple { public TupleCodes Code; public byte[] Data; public byte Link; } /// Checksum tuple [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class ChecksumTuple { /// Modulo-256 sum of region public byte Checksum; /// /// /// public TupleCodes Code; /// Length of region to be checksummed public ushort Length; /// Link to next tuple public byte Link; /// Offset to region to be checksummed public short Offset; } /// Indirect Access PC Card Memory [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class IndirectTuple { /// /// /// public TupleCodes Code; /// Link to next tuple public byte Link; } /// Link target tuple [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class LinkTargetTuple { /// /// /// public TupleCodes Code; /// Link to next tuple public byte Link; /// 'C''I''S' in ASCII public byte[] Tag; } /// 16-bit PC Card Long Link Tuple [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class LongLinkTuple { /// Target address public uint Address; /// /// or or /// /// public TupleCodes Code; /// Link to next tuple public byte Link; } [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] public class ConfigurationAddress { /// Target address public uint Address; /// Target address space, 0 = attribute, 1 = common public byte TargetAddressSpace; } /// Multiple function link tuple [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class MultipleFunctionLinkTuple { /// Link to more configuration registers public ConfigurationAddress[] Addresses; /// /// /// public TupleCodes Code; /// Link to next tuple public byte Link; /// How many functions follow public byte NumberFunctions; } [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class NoLinkTuple { /// /// /// public TupleCodes Code; /// Link to next tuple public byte Link; } [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class AlternateStringTuple { /// /// /// public TupleCodes Code; /// Link to next tuple public byte Link; /// /// Array of strings. On memory they're preceded by an ISO Escape Code indicating codepage. Here they're stored as /// Unicode, so no need for it. /// public string[] Strings; } [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] public class ExtendedDeviceSpeed { /// Speed exponent public byte Exponent; /// Another extended follows public bool Extended; /// Speed mantisa public byte Mantissa; } [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public struct DeviceInfo { /// Device type code public DeviceTypeCodes Type; /// Write protected public bool WPS; /// Speed code public DeviceSpeedCodes Speed; /// Extended speeds public ExtendedDeviceSpeed[] ExtendedSpeeds; /// Extended types public byte[] ExtendedTypes; /// Size in units - 1 public byte Units; /// Code to define units unit public byte SizeCode; } [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class DeviceTuple { /// or public TupleCodes Code; /// Array of device information bytes public DeviceInfo[] Infos; /// Link to next tuple public byte Link; } [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public struct OtherConditionInfo { /// True if another other condition info follows public bool Extended; /// Vcc used public byte VccUsed; /// Supports WAIT# signal public bool MWAIT; } [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class OtherConditionTuple { /// or public TupleCodes Code; /// Array of device information bytes public DeviceInfo[] Infos; /// Link to next tuple public byte Link; /// Array of other condition information bytes public OtherConditionInfo[] OtherConditionInfos; } [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public struct DeviceGeometry { /// 1 << n-1 bytes, 2 = 16-bit PC Card, 3 = CardBus PC Card public byte CardInterface; /// /// Erase block size in 1 << n-1 increments of wide accesses. If n == 4, and /// == 16, erase block size = 32 * 4 = 128 bytes /// public byte EraseBlockSize; /// /// Read block size in 1 << n-1 increments of wide accesses. If n == 4, and /// == 16, read block size = 32 * 4 = 128 bytes /// public byte ReadBlockSize; /// /// Write block size in 1 << n-1 increments of wide accesses. If n == 4, and /// == 16, write block size = 32 * 4 = 128 bytes /// public byte WriteBlockSize; /// /// Device partitioning in granularity of 1 << n-1 erase blocks If n == 4, and erase block is 128 bytes, /// partitions must be aligned to 32 erase block, or 4096 bytes /// public byte Partitions; /// Card employs a multiple of 1 << n-1 times interleaving the entire memory arrays public byte Interleaving; } [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] [SuppressMessage("ReSharper", "NotAccessedField.Global")] public class DeviceGeometryTuple { /// or public TupleCodes Code; /// Array of device geometries public DeviceGeometry[] Geometries; /// Link to next tuple public byte Link; } [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class FunctionIdentificationTuple { /// /// /// public TupleCodes Code; /// Function code public FunctionCodes Function; /// Link to next tuple public byte Link; /// Device wants to be part of power-on-self-test public bool POST; /// Device contains boot ROM public bool ROM; } [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] [SuppressMessage("ReSharper", "NotAccessedField.Global")] public class ManufacturerIdentificationTuple { /// Card ID public ushort CardID; /// /// /// public TupleCodes Code; /// Link to next tuple public byte Link; /// Manufacturer ID public ushort ManufacturerID; } [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] [SuppressMessage("ReSharper", "NotAccessedField.Global")] public class Level1VersionTuple { /// Additional information strings public string[] AdditionalInformation; /// /// /// public TupleCodes Code; /// Link to next tuple public byte Link; /// Major version of standard compliance public byte MajorVersion; /// Manufacturer string public string Manufacturer; /// Minor version of standard compliance public byte MinorVersion; /// Product string public string Product; } [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class Level2VersionTuple { /// Address of first data byte public ushort Address; /// Number of copies of CIS present public byte CISCopies; /// /// /// public TupleCodes Code; /// Level of compliance public byte Compliance; /// Informational message about the card public string Information; /// Link to next tuple public byte Link; /// Vendor of software that formatted the card public string OEM; /// Version of this classure public byte StructureVersion; /// Vendor-specific byte public byte VendorSpecific1; /// Vendor-specific byte public byte VendorSpecific2; } [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class GeometryTuple { /// /// /// public TupleCodes Code; /// Cylinders public ushort Cylinders; /// Link to next tuple public byte Link; /// Sectors per track public byte SectorsPerTrack; /// Tracks per cylinder public byte TracksPerCylinder; }