2017-12-21 02:03:21 +00:00
|
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:23 +00:00
|
|
|
|
// Aaru Data Preservation Suite
|
2017-12-21 02:03:21 +00:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : 10.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : Device structures decoders.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Decodes SCSI MODE PAGE 10h: XOR control mode 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-12-03 16:07:08 +00:00
|
|
|
|
// Copyright © 2011-2023 Natalia Portillo
|
2017-12-21 02:03:21 +00:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
2017-12-22 02:04:18 +00:00
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
2022-11-15 15:58:41 +00:00
|
|
|
|
namespace Aaru.Decoders.SCSI;
|
|
|
|
|
|
|
2023-10-03 23:09:28 +01:00
|
|
|
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
|
|
|
|
|
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
|
|
|
|
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
2022-03-06 13:29:37 +00:00
|
|
|
|
public static partial class Modes
|
2017-12-21 02:03:21 +00:00
|
|
|
|
{
|
2023-10-03 23:09:28 +01:00
|
|
|
|
#region Mode Page 0x10: XOR control mode page
|
|
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
/// <summary>XOR control mode page Page code 0x10 24 bytes in SBC-1, SBC-2</summary>
|
|
|
|
|
|
public struct ModePage_10
|
2017-12-21 02:03:21 +00:00
|
|
|
|
{
|
2022-03-06 13:29:37 +00:00
|
|
|
|
/// <summary>Parameters can be saved</summary>
|
|
|
|
|
|
public bool PS;
|
|
|
|
|
|
/// <summary>Disables XOR operations</summary>
|
|
|
|
|
|
public bool XORDIS;
|
|
|
|
|
|
/// <summary>Maximum transfer length in blocks for a XOR command</summary>
|
|
|
|
|
|
public uint MaxXorWrite;
|
|
|
|
|
|
/// <summary>Maximum regenerate length in blocks</summary>
|
|
|
|
|
|
public uint MaxRegenSize;
|
|
|
|
|
|
/// <summary>Maximum transfer length in blocks for READ during a rebuild</summary>
|
|
|
|
|
|
public uint MaxRebuildRead;
|
|
|
|
|
|
/// <summary>Minimum time in ms between READs during a rebuild</summary>
|
|
|
|
|
|
public ushort RebuildDelay;
|
|
|
|
|
|
}
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
public static ModePage_10? DecodeModePage_10(byte[] pageResponse)
|
|
|
|
|
|
{
|
|
|
|
|
|
if((pageResponse?[0] & 0x40) == 0x40)
|
|
|
|
|
|
return null;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
if((pageResponse?[0] & 0x3F) != 0x10)
|
|
|
|
|
|
return null;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
if(pageResponse[1] + 2 != pageResponse.Length)
|
|
|
|
|
|
return null;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
if(pageResponse.Length < 24)
|
|
|
|
|
|
return null;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
var decoded = new ModePage_10();
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
decoded.PS |= (pageResponse[0] & 0x80) == 0x80;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
decoded.XORDIS |= (pageResponse[2] & 0x02) == 0x02;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2023-10-04 17:34:36 +01:00
|
|
|
|
decoded.MaxXorWrite =
|
|
|
|
|
|
(uint)((pageResponse[4] << 24) + (pageResponse[5] << 16) + (pageResponse[6] << 8) + pageResponse[7]);
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2023-10-04 17:34:36 +01:00
|
|
|
|
decoded.MaxRegenSize = (uint)((pageResponse[12] << 24) +
|
|
|
|
|
|
(pageResponse[13] << 16) +
|
|
|
|
|
|
(pageResponse[14] << 8) +
|
2022-03-07 07:36:42 +00:00
|
|
|
|
pageResponse[15]);
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2023-10-04 17:34:36 +01:00
|
|
|
|
decoded.MaxRebuildRead = (uint)((pageResponse[16] << 24) +
|
|
|
|
|
|
(pageResponse[17] << 16) +
|
|
|
|
|
|
(pageResponse[18] << 8) +
|
2022-03-07 07:36:42 +00:00
|
|
|
|
pageResponse[19]);
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
decoded.RebuildDelay = (ushort)((pageResponse[22] << 8) + pageResponse[23]);
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
return decoded;
|
|
|
|
|
|
}
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
public static string PrettifyModePage_10(byte[] pageResponse) =>
|
|
|
|
|
|
PrettifyModePage_10(DecodeModePage_10(pageResponse));
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
public static string PrettifyModePage_10(ModePage_10? modePage)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(!modePage.HasValue)
|
|
|
|
|
|
return null;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
ModePage_10 page = modePage.Value;
|
|
|
|
|
|
var sb = new StringBuilder();
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-11-27 13:33:47 +00:00
|
|
|
|
sb.AppendLine(Localization.SCSI_XOR_control_mode_page);
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
if(page.PS)
|
2022-11-27 13:33:47 +00:00
|
|
|
|
sb.AppendLine("\t" + Localization.Parameters_can_be_saved);
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
if(page.XORDIS)
|
2022-11-27 13:33:47 +00:00
|
|
|
|
sb.AppendLine("\t" + Localization.XOR_operations_are_disabled);
|
2022-03-06 13:29:37 +00:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if(page.MaxXorWrite > 0)
|
2023-10-03 23:09:28 +01:00
|
|
|
|
{
|
2022-11-27 13:33:47 +00:00
|
|
|
|
sb.AppendFormat("\t" + Localization.Drive_accepts_a_maximum_of_0_blocks_in_a_single_XOR_WRITE_command,
|
2023-10-04 17:34:36 +01:00
|
|
|
|
page.MaxXorWrite).
|
|
|
|
|
|
AppendLine();
|
2023-10-03 23:09:28 +01:00
|
|
|
|
}
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
if(page.MaxRegenSize > 0)
|
2023-10-03 23:09:28 +01:00
|
|
|
|
{
|
2022-11-27 13:33:47 +00:00
|
|
|
|
sb.AppendFormat("\t" + Localization.Drive_accepts_a_maximum_of_0_blocks_in_a_REGENERATE_command,
|
2023-10-04 17:34:36 +01:00
|
|
|
|
page.MaxRegenSize).
|
|
|
|
|
|
AppendLine();
|
2023-10-03 23:09:28 +01:00
|
|
|
|
}
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
if(page.MaxRebuildRead > 0)
|
2023-10-03 23:09:28 +01:00
|
|
|
|
{
|
2022-11-27 13:33:47 +00:00
|
|
|
|
sb.
|
2023-10-04 17:34:36 +01:00
|
|
|
|
AppendFormat("\t" + Localization.Drive_accepts_a_maximum_of_0_blocks_in_a_READ_command_during_rebuild,
|
|
|
|
|
|
page.MaxRebuildRead).
|
|
|
|
|
|
AppendLine();
|
2023-10-03 23:09:28 +01:00
|
|
|
|
}
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
if(page.RebuildDelay > 0)
|
2023-10-03 23:09:28 +01:00
|
|
|
|
{
|
2022-11-27 13:33:47 +00:00
|
|
|
|
sb.AppendFormat("\t" + Localization.Drive_needs_a_minimum_of_0_ms_between_READ_commands_during_rebuild,
|
2023-10-04 17:34:36 +01:00
|
|
|
|
page.RebuildDelay).
|
|
|
|
|
|
AppendLine();
|
2023-10-03 23:09:28 +01:00
|
|
|
|
}
|
2017-12-21 02:03:21 +00:00
|
|
|
|
}
|
2022-03-06 13:29:37 +00:00
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
2017-12-21 02:03:21 +00:00
|
|
|
|
}
|
2023-10-03 23:09:28 +01:00
|
|
|
|
|
|
|
|
|
|
#endregion Mode Page 0x10: XOR control mode page
|
2017-12-21 02:03:21 +00:00
|
|
|
|
}
|