Skip to content

Commit

Permalink
Merge Aaru.Decoders into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
claunia committed Dec 19, 2023
2 parents 68a23a6 + eca03c2 commit efa6c7a
Show file tree
Hide file tree
Showing 127 changed files with 98,820 additions and 0 deletions.
1,342 changes: 1,342 additions & 0 deletions Aaru.Decoders/.editorconfig

Large diffs are not rendered by default.

595 changes: 595 additions & 0 deletions Aaru.Decoders/.gitignore

Large diffs are not rendered by default.

2,372 changes: 2,372 additions & 0 deletions Aaru.Decoders/ATA/Identify.cs

Large diffs are not rendered by default.

113 changes: 113 additions & 0 deletions Aaru.Decoders/ATA/Registers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : Errors.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Device structures decoders.
//
// --[ Description ] ----------------------------------------------------------
//
// Decodes ATA error registers.
//
// --[ 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.Runtime.InteropServices;

namespace Aaru.Decoders.ATA;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AtaRegistersChs
{
public byte Feature;
public byte SectorCount;
public byte Sector;
public byte CylinderLow;
public byte CylinderHigh;
public byte DeviceHead;
public byte Command;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AtaRegistersLba28
{
public byte Feature;
public byte SectorCount;
public byte LbaLow;
public byte LbaMid;
public byte LbaHigh;
public byte DeviceHead;
public byte Command;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AtaRegistersLba48
{
public ushort Feature;
public ushort SectorCount;
public byte LbaLowPrevious;
public byte LbaLowCurrent;
public byte LbaMidPrevious;
public byte LbaMidCurrent;
public byte LbaHighPrevious;
public byte LbaHighCurrent;
public byte DeviceHead;
public byte Command;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AtaErrorRegistersChs
{
public byte Status;
public byte Error;
public byte SectorCount;
public byte Sector;
public byte CylinderLow;
public byte CylinderHigh;
public byte DeviceHead;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AtaErrorRegistersLba28
{
public byte Status;
public byte Error;
public byte SectorCount;
public byte LbaLow;
public byte LbaMid;
public byte LbaHigh;
public byte DeviceHead;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AtaErrorRegistersLba48
{
public byte Status;
public byte Error;
public ushort SectorCount;
public byte LbaLowPrevious;
public byte LbaLowCurrent;
public byte LbaMidPrevious;
public byte LbaMidCurrent;
public byte LbaHighPrevious;
public byte LbaHighCurrent;
public byte DeviceHead;
}
77 changes: 77 additions & 0 deletions Aaru.Decoders/Aaru.Decoders.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0BEB3088-B634-4289-AE17-CDF2D25D00D5}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Aaru.Decoders</RootNamespace>
<AssemblyName>Aaru.Decoders</AssemblyName>
<ReleaseVersion>$(Version)</ReleaseVersion>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<Version>6.0.0-alpha9</Version>
<Company>Claunia.com</Company>
<Copyright>Copyright © 2011-2023 Natalia Portillo</Copyright>
<Product>Aaru Data Preservation Suite</Product>
<Title>Aaru.Decoders</Title>
<ApplicationVersion>$(Version)</ApplicationVersion>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12</LangVersion>
<Description>Binary structure decoders used by the Aaru Data Preservation Suite.</Description>
<PackageProjectUrl>https://github.com/aaru-dps/</PackageProjectUrl>
<PackageLicenseExpression>LGPL-2.1-only</PackageLicenseExpression>
<RepositoryUrl>https://github.com/aaru-dps/Aaru</RepositoryUrl>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<NeutralLanguage>en-US</NeutralLanguage>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Authors>Natalia Portillo &lt;claunia@claunia.com&gt;</Authors>
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<NoWarn>CS1591;CS1574</NoWarn>
</PropertyGroup>
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<InternalsVisibleTo Include="Aaru.Tests"/>
<InternalsVisibleTo Include="Aaru.Tests.Devices"/>
</ItemGroup>
<PropertyGroup>
<NrtRevisionFormat>$(Version)+{chash:8}</NrtRevisionFormat>
<NrtResolveSimpleAttributes>true</NrtResolveSimpleAttributes>
<NrtShowRevision>true</NrtShowRevision>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Aaru.Checksums\Aaru.Checksums.csproj"/>
<ProjectReference Include="..\Aaru.CommonTypes\Aaru.CommonTypes.csproj"/>
<ProjectReference Include="..\Aaru.Helpers\Aaru.Helpers.csproj"/>
<ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj"/>
</ItemGroup>
<ItemGroup>
<Folder Include="Bluray"/>
<Folder Include="SCSI\"/>
<Folder Include="ATA\"/>
<Folder Include="SCSI\MMC\"/>
<Folder Include="CD\"/>
<Folder Include="Floppy\"/>
<Folder Include="Xbox\"/>
<Folder Include="SCSI\SSC\"/>
<Folder Include="PCMCIA\"/>
<Folder Include="MMC\"/>
<Folder Include="SecureDigital\"/>
<Folder Include="Sega\"/>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\LICENSE.LGPL">
<Link>LICENSE.LGPL</Link>
</EmbeddedResource>
<EmbeddedResource Update="Localization\Localization.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Localization.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.ComponentModel.Annotations" Version="6.0.0-preview.4.21253.7"/>
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.4.3" PrivateAssets="all"/>
</ItemGroup>
</Project>
6 changes: 6 additions & 0 deletions Aaru.Decoders/Aaru.Decoders.csproj.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<wpf:ResourceDictionary xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:System;assembly=mscorlib"
xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xml:space="preserve">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=localization/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=scsi_005Cmodes/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
136 changes: 136 additions & 0 deletions Aaru.Decoders/Bluray/BCA.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : BCA.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Device structures decoders.
//
// --[ Description ] ----------------------------------------------------------
//
// Decodes Blu-ray Burst Cutting Area.
//
// --[ 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.Diagnostics.CodeAnalysis;
using System.Text;
using Aaru.Console;
using Aaru.Helpers;

namespace Aaru.Decoders.Bluray;

// Information from the following standards:
// ANSI X3.304-1997
// T10/1048-D revision 9.0
// T10/1048-D revision 10a
// T10/1228-D revision 7.0c
// T10/1228-D revision 11a
// T10/1363-D revision 10g
// T10/1545-D revision 1d
// T10/1545-D revision 5
// T10/1545-D revision 5a
// T10/1675-D revision 2c
// T10/1675-D revision 4
// T10/1836-D revision 2g
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
public static class BCA
{
const string MODULE_NAME = "BD BCA decoder";

#region Nested type: BurstCuttingArea

#region Public structures

public struct BurstCuttingArea
{
/// <summary>Bytes 0 to 1 Always 66</summary>
public ushort DataLength;
/// <summary>Byte 2 Reserved</summary>
public byte Reserved1;
/// <summary>Byte 3 Reserved</summary>
public byte Reserved2;
/// <summary>Byte 4 to 67 BCA data</summary>
public byte[] BCA;
}

#endregion Public structures

#endregion

#region Public methods

public static BurstCuttingArea? Decode(byte[] BCAResponse)
{
if(BCAResponse == null)
return null;

if(BCAResponse.Length != 68)
{
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_incorrect_Blu_ray_BCA_size_0_bytes,
BCAResponse.Length);

return null;
}

var decoded = new BurstCuttingArea
{
DataLength = BigEndianBitConverter.ToUInt16(BCAResponse, 0),
Reserved1 = BCAResponse[2],
Reserved2 = BCAResponse[3],
BCA = new byte[64]
};

Array.Copy(BCAResponse, 4, decoded.BCA, 0, 64);

return decoded;
}

public static string Prettify(BurstCuttingArea? BCAResponse)
{
if(BCAResponse == null)
return null;

BurstCuttingArea response = BCAResponse.Value;

var sb = new StringBuilder();

#if DEBUG
if(response.Reserved1 != 0)
sb.AppendFormat(Localization.Reserved1_equals_0_X8, response.Reserved1).AppendLine();

if(response.Reserved2 != 0)
sb.AppendFormat(Localization.Reserved2_equals_0_X8, response.Reserved2).AppendLine();
#endif

sb.AppendFormat(Localization.Blu_ray_Burst_Cutting_Area_in_hex_follows);
sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.BCA, 80));

return sb.ToString();
}

public static string Prettify(byte[] BCAResponse) => Prettify(Decode(BCAResponse));

#endregion Public methods
}
Loading

0 comments on commit efa6c7a

Please sign in to comment.