mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
REFACTOR: All refactor in DiscImageChef.Decoders.
This commit is contained in:
@@ -32,11 +32,15 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DiscImageChef.Decoders.PCMCIA
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public static class CIS
|
||||
{
|
||||
// TODO: Handle links? Or are they removed in lower layers of the operating system drivers?
|
||||
@@ -47,9 +51,7 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
|
||||
while(position < data.Length)
|
||||
{
|
||||
Tuple tuple = new Tuple();
|
||||
|
||||
tuple.Code = (TupleCodes)data[position];
|
||||
Tuple tuple = new Tuple {Code = (TupleCodes)data[position]};
|
||||
|
||||
if(tuple.Code == TupleCodes.CISTPL_NULL) continue;
|
||||
|
||||
@@ -75,28 +77,27 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
|
||||
if(tuple.Code != TupleCodes.CISTPL_DEVICEGEO && tuple.Code != TupleCodes.CISTPL_DEVICEGEO_A) return null;
|
||||
|
||||
if(tuple.Data == null) return null;
|
||||
|
||||
return DecodeDeviceGeometryTuple(tuple.Data);
|
||||
return tuple.Data == null ? null : DecodeDeviceGeometryTuple(tuple.Data);
|
||||
}
|
||||
|
||||
public static DeviceGeometryTuple DecodeDeviceGeometryTuple(byte[] data)
|
||||
{
|
||||
if(data == null) return null;
|
||||
if((data.Length - 2) % 6 != 0) return null;
|
||||
if((data?.Length - 2) % 6 != 0) return null;
|
||||
|
||||
DeviceGeometryTuple tuple = new DeviceGeometryTuple();
|
||||
List<DeviceGeometry> geometries = new List<DeviceGeometry>();
|
||||
|
||||
for(int position = 2; position < data.Length; position += 6)
|
||||
{
|
||||
DeviceGeometry geometry = new DeviceGeometry();
|
||||
geometry.CardInterface = data[position];
|
||||
geometry.EraseBlockSize = data[position + 1];
|
||||
geometry.ReadBlockSize = data[position + 2];
|
||||
geometry.WriteBlockSize = data[position + 3];
|
||||
geometry.Partitions = data[position + 4];
|
||||
geometry.Interleaving = data[position + 5];
|
||||
DeviceGeometry geometry = new DeviceGeometry
|
||||
{
|
||||
CardInterface = data[position],
|
||||
EraseBlockSize = data[position + 1],
|
||||
ReadBlockSize = data[position + 2],
|
||||
WriteBlockSize = data[position + 3],
|
||||
Partitions = data[position + 4],
|
||||
Interleaving = data[position + 5]
|
||||
};
|
||||
geometries.Add(geometry);
|
||||
}
|
||||
|
||||
@@ -145,13 +146,9 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
|
||||
public static ManufacturerIdentificationTuple DecodeManufacturerIdentificationTuple(Tuple tuple)
|
||||
{
|
||||
if(tuple == null) return null;
|
||||
if(tuple?.Code != TupleCodes.CISTPL_MANFID) return null;
|
||||
|
||||
if(tuple.Code != TupleCodes.CISTPL_MANFID) return null;
|
||||
|
||||
if(tuple.Data == null) return null;
|
||||
|
||||
return DecodeManufacturerIdentificationTuple(tuple.Data);
|
||||
return tuple.Data == null ? null : DecodeManufacturerIdentificationTuple(tuple.Data);
|
||||
}
|
||||
|
||||
public static ManufacturerIdentificationTuple DecodeManufacturerIdentificationTuple(byte[] data)
|
||||
@@ -160,20 +157,18 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
|
||||
if(data.Length < 6) return null;
|
||||
|
||||
ManufacturerIdentificationTuple tuple = new ManufacturerIdentificationTuple();
|
||||
tuple.Code = (TupleCodes)data[0];
|
||||
tuple.Link = data[1];
|
||||
tuple.ManufacturerID = BitConverter.ToUInt16(data, 2);
|
||||
tuple.CardID = BitConverter.ToUInt16(data, 4);
|
||||
|
||||
return tuple;
|
||||
return new ManufacturerIdentificationTuple
|
||||
{
|
||||
Code = (TupleCodes)data[0],
|
||||
Link = data[1],
|
||||
ManufacturerID = BitConverter.ToUInt16(data, 2),
|
||||
CardID = BitConverter.ToUInt16(data, 4)
|
||||
};
|
||||
}
|
||||
|
||||
public static string PrettifyManufacturerIdentificationTuple(ManufacturerIdentificationTuple tuple)
|
||||
{
|
||||
if(tuple == null) return null;
|
||||
|
||||
if(tuple.Code != TupleCodes.CISTPL_MANFID) return null;
|
||||
if(tuple?.Code != TupleCodes.CISTPL_MANFID) return null;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine("PCMCIA Manufacturer Identification Tuple:");
|
||||
@@ -195,13 +190,9 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
|
||||
public static Level1VersionTuple DecodeLevel1VersionTuple(Tuple tuple)
|
||||
{
|
||||
if(tuple == null) return null;
|
||||
if(tuple?.Code != TupleCodes.CISTPL_VERS_1) return null;
|
||||
|
||||
if(tuple.Code != TupleCodes.CISTPL_VERS_1) return null;
|
||||
|
||||
if(tuple.Data == null) return null;
|
||||
|
||||
return DecodeLevel1VersionTuple(tuple.Data);
|
||||
return tuple.Data == null ? null : DecodeLevel1VersionTuple(tuple.Data);
|
||||
}
|
||||
|
||||
public static Level1VersionTuple DecodeLevel1VersionTuple(byte[] data)
|
||||
@@ -215,11 +206,13 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
bool firstString = false;
|
||||
bool secondString = false;
|
||||
|
||||
Level1VersionTuple tuple = new Level1VersionTuple();
|
||||
tuple.Code = (TupleCodes)data[0];
|
||||
tuple.Link = data[1];
|
||||
tuple.MajorVersion = data[2];
|
||||
tuple.MinorVersion = data[3];
|
||||
Level1VersionTuple tuple = new Level1VersionTuple
|
||||
{
|
||||
Code = (TupleCodes)data[0],
|
||||
Link = data[1],
|
||||
MajorVersion = data[2],
|
||||
MinorVersion = data[3]
|
||||
};
|
||||
|
||||
for(int position = 4; position < data.Length; position++)
|
||||
{
|
||||
@@ -259,9 +252,7 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
|
||||
public static string PrettifyLevel1VersionTuple(Level1VersionTuple tuple)
|
||||
{
|
||||
if(tuple == null) return null;
|
||||
|
||||
if(tuple.Code != TupleCodes.CISTPL_VERS_1) return null;
|
||||
if(tuple?.Code != TupleCodes.CISTPL_VERS_1) return null;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine("PCMCIA Level 1 Version / Product Information Tuple:");
|
||||
|
||||
@@ -30,11 +30,14 @@
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace DiscImageChef.Decoders.PCMCIA
|
||||
{
|
||||
/// <summary>
|
||||
/// Tuple codes.
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum TupleCodes : byte
|
||||
{
|
||||
/// <summary>
|
||||
@@ -199,6 +202,7 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
CISTPL_SPCL = 0x90
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum DeviceTypeCodes : byte
|
||||
{
|
||||
/// <summary>
|
||||
@@ -243,6 +247,7 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
DTYPE_EXTEND = 14
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum DeviceSpeedCodes : byte
|
||||
{
|
||||
/// <summary>
|
||||
@@ -271,6 +276,7 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
DSPEED_EXT = 7
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum FunctionCodes : byte
|
||||
{
|
||||
MultiFunction = 0x00,
|
||||
|
||||
@@ -30,11 +30,16 @@
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace DiscImageChef.Decoders.PCMCIA
|
||||
{
|
||||
/// <summary>
|
||||
/// Basic classure of a PCMCIA tuple
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public class Tuple
|
||||
{
|
||||
public TupleCodes Code;
|
||||
@@ -45,6 +50,9 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
/// <summary>
|
||||
/// Checksum tuple
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public class ChecksumTuple
|
||||
{
|
||||
/// <summary>
|
||||
@@ -72,6 +80,9 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
/// <summary>
|
||||
/// Indirect Access PC Card Memory
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public class IndirectTuple
|
||||
{
|
||||
/// <summary>
|
||||
@@ -87,6 +98,9 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
/// <summary>
|
||||
/// Link target tuple
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public class LinkTargetTuple
|
||||
{
|
||||
/// <summary>
|
||||
@@ -106,6 +120,9 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
/// <summary>
|
||||
/// 16-bit PC Card Long Link Tuple
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public class LongLinkTuple
|
||||
{
|
||||
/// <summary>
|
||||
@@ -122,6 +139,10 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
public uint Address;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
|
||||
public class ConfigurationAddress
|
||||
{
|
||||
/// <summary>
|
||||
@@ -137,6 +158,9 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
/// <summary>
|
||||
/// Multiple function link tuple
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public class MultipleFunctionLinkTuple
|
||||
{
|
||||
/// <summary>
|
||||
@@ -157,6 +181,9 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
public ConfigurationAddress[] Addresses;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public class NoLinkTuple
|
||||
{
|
||||
/// <summary>
|
||||
@@ -169,6 +196,9 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
public byte Link;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public class AlternateStringTuple
|
||||
{
|
||||
/// <summary>
|
||||
@@ -185,6 +215,10 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
public string[] Strings;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
|
||||
public class ExtendedDeviceSpeed
|
||||
{
|
||||
/// <summary>
|
||||
@@ -201,6 +235,9 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
public byte Exponent;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public struct DeviceInfo
|
||||
{
|
||||
/// <summary>
|
||||
@@ -233,6 +270,9 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
public byte SizeCode;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public class DeviceTuple
|
||||
{
|
||||
/// <summary>
|
||||
@@ -249,6 +289,9 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
public DeviceInfo[] Infos;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public struct OtherConditionInfo
|
||||
{
|
||||
/// <summary>
|
||||
@@ -265,6 +308,9 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
public bool MWAIT;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public class OtherConditionTuple
|
||||
{
|
||||
/// <summary>
|
||||
@@ -285,6 +331,9 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
public DeviceInfo[] Infos;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public struct DeviceGeometry
|
||||
{
|
||||
/// <summary>
|
||||
@@ -317,6 +366,10 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
public byte Interleaving;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
|
||||
public class DeviceGeometryTuple
|
||||
{
|
||||
/// <summary>
|
||||
@@ -333,6 +386,9 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
public DeviceGeometry[] Geometries;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public class FunctionIdentificationTuple
|
||||
{
|
||||
/// <summary>
|
||||
@@ -357,6 +413,10 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
public bool POST;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
|
||||
public class ManufacturerIdentificationTuple
|
||||
{
|
||||
/// <summary>
|
||||
@@ -377,6 +437,10 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
public ushort CardID;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
|
||||
public class Level1VersionTuple
|
||||
{
|
||||
/// <summary>
|
||||
@@ -409,6 +473,9 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
public string[] AdditionalInformation;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public class Level2VersionTuple
|
||||
{
|
||||
/// <summary>
|
||||
@@ -453,6 +520,9 @@ namespace DiscImageChef.Decoders.PCMCIA
|
||||
public string Information;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public class GeometryTuple
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -30,8 +30,11 @@
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace DiscImageChef.Decoders.PCMCIA
|
||||
{
|
||||
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
||||
public static class VendorCode
|
||||
{
|
||||
public static string Prettify(ushort id)
|
||||
|
||||
Reference in New Issue
Block a user