Files
Aaru/Aaru.Decoders/SCSI/Modes/3E_Fujitsu.cs

148 lines
5.5 KiB
C#
Raw Normal View History

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 : 3E_Fujitsu.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Device structures decoders.
//
// --[ Description ] ----------------------------------------------------------
//
// Decodes Fujitsu MODE PAGE 3Eh: Verify Control 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/>.
//
// ----------------------------------------------------------------------------
2024-12-19 10:45:18 +00:00
// Copyright © 2011-2025 Natalia Portillo
2017-12-21 02:03:21 +00:00
// ****************************************************************************/
using System;
using System.Diagnostics.CodeAnalysis;
2017-12-21 02:03:21 +00:00
using System.Text;
2020-02-27 00:33:24 +00:00
using Aaru.CommonTypes.Structs.Devices.SCSI;
2017-12-21 02:03:21 +00:00
namespace Aaru.Decoders.SCSI;
2023-10-03 23:09:28 +01:00
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
[SuppressMessage("ReSharper", "NotAccessedField.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 Fujitsu Mode Page 0x3E: Verify Control page
2023-10-05 01:05:20 +01:00
[SuppressMessage("ReSharper", "UnusedMember.Global")]
2022-03-06 13:29:37 +00:00
public enum Fujitsu_VerifyModes : byte
2017-12-21 02:03:21 +00:00
{
2022-03-06 13:29:37 +00:00
/// <summary>Always verify after writing</summary>
Always = 0,
/// <summary>Never verify after writing</summary>
Never = 1,
/// <summary>Verify after writing depending on condition</summary>
2023-10-03 23:09:28 +01:00
Depends = 2,
Reserved = 4
2022-03-06 13:29:37 +00:00
}
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
public struct Fujitsu_ModePage_3E
{
/// <summary>Parameters can be saved</summary>
public bool PS;
/// <summary>If set, AV data support mode is applied</summary>
public bool audioVisualMode;
/// <summary>If set the test write operation is restricted</summary>
public bool streamingMode;
public byte Reserved1;
/// <summary>Verify mode for WRITE commands</summary>
public Fujitsu_VerifyModes verifyMode;
public byte Reserved2;
/// <summary>Device type provided in response to INQUIRY</summary>
public PeripheralDeviceTypes devType;
public byte[] Reserved3;
}
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
public static Fujitsu_ModePage_3E? DecodeFujitsuModePage_3E(byte[] pageResponse)
{
2024-05-01 04:05:22 +01:00
if((pageResponse?[0] & 0x40) == 0x40) return null;
2017-12-21 02:03:21 +00:00
2024-05-01 04:05:22 +01:00
if((pageResponse?[0] & 0x3F) != 0x3E) return null;
2017-12-21 02:03:21 +00:00
2024-05-01 04:05:22 +01:00
if(pageResponse[1] + 2 != pageResponse.Length) return null;
2017-12-21 02:03:21 +00:00
2024-05-01 04:05:22 +01:00
if(pageResponse.Length != 8) return null;
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
var decoded = new Fujitsu_ModePage_3E();
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.audioVisualMode |= (pageResponse[2] & 0x80) == 0x80;
decoded.streamingMode |= (pageResponse[2] & 0x40) == 0x40;
decoded.Reserved1 = (byte)((pageResponse[2] & 0x3C) >> 2);
decoded.verifyMode = (Fujitsu_VerifyModes)(pageResponse[2] & 0x03);
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
decoded.Reserved2 = (byte)((pageResponse[3] & 0xE0) >> 5);
decoded.devType = (PeripheralDeviceTypes)(pageResponse[3] & 0x1F);
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
decoded.Reserved3 = new byte[4];
Array.Copy(pageResponse, 4, decoded.Reserved3, 0, 4);
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 PrettifyFujitsuModePage_3E(byte[] pageResponse) =>
PrettifyFujitsuModePage_3E(DecodeFujitsuModePage_3E(pageResponse));
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
public static string PrettifyFujitsuModePage_3E(Fujitsu_ModePage_3E? modePage)
{
2024-05-01 04:05:22 +01:00
if(!modePage.HasValue) return null;
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
Fujitsu_ModePage_3E page = modePage.Value;
var sb = new StringBuilder();
2017-12-21 02:03:21 +00:00
sb.AppendLine(Localization.Fujitsu_Verify_Control_Page);
2017-12-21 02:03:21 +00:00
2024-05-01 04:05:22 +01:00
if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved);
2019-11-25 00:54:38 +00:00
2024-05-01 04:05:22 +01:00
if(page.audioVisualMode) sb.AppendLine("\t" + Localization.Audio_Visual_data_support_mode_is_applied);
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.streamingMode)
sb.AppendLine("\t" + Localization.Test_write_operation_is_restricted_during_read_or_write_operations);
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
switch(page.verifyMode)
{
case Fujitsu_VerifyModes.Always:
sb.AppendLine("\t" + Localization.Always_apply_the_verify_operation);
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
case Fujitsu_VerifyModes.Never:
sb.AppendLine("\t" + Localization.Never_apply_the_verify_operation);
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
case Fujitsu_VerifyModes.Depends:
sb.AppendLine("\t" + Localization.Apply_the_verify_operation_depending_on_the_condition);
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
}
2017-12-21 02:03:21 +00:00
sb.AppendFormat("\t" + Localization.The_device_type_that_would_be_provided_in_the_INQUIRY_response_is_0,
2024-05-01 04:05:22 +01:00
page.devType)
.AppendLine();
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 Fujitsu Mode Page 0x3E: Verify Control page
2017-12-21 02:03:21 +00:00
}