Files
Aaru/SCSI/Modes/21_Certance.cs

208 lines
7.4 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 : 21_Certance.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Device structures decoders.
//
// --[ Description ] ----------------------------------------------------------
//
// Decodes Certance MODE PAGE 21h: Drive Capabilities 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
// ****************************************************************************/
using System.Diagnostics.CodeAnalysis;
2017-12-21 02:03:21 +00:00
using System.Text;
namespace Aaru.Decoders.SCSI;
2022-03-06 13:29:37 +00:00
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public static partial class Modes
2017-12-21 02:03:21 +00:00
{
2022-03-06 13:29:37 +00:00
#region Certance Mode Page 0x21: Drive Capabilities Control Mode page
public struct Certance_ModePage_21
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;
public byte OperatingSystemsSupport;
public byte FirmwareTestControl2;
public byte ExtendedPOSTMode;
public byte InquiryStringControl;
public byte FirmwareTestControl;
public byte DataCompressionControl;
public bool HostUnloadOverride;
public byte AutoUnloadMode;
}
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
public static Certance_ModePage_21? DecodeCertanceModePage_21(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) != 0x21)
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 != 9)
return null;
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
var decoded = new Certance_ModePage_21();
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
decoded.PS |= (pageResponse[0] & 0x80) == 0x80;
decoded.OperatingSystemsSupport = pageResponse[2];
decoded.FirmwareTestControl2 = pageResponse[3];
decoded.ExtendedPOSTMode = pageResponse[4];
decoded.InquiryStringControl = pageResponse[5];
decoded.FirmwareTestControl = pageResponse[6];
decoded.DataCompressionControl = pageResponse[7];
decoded.HostUnloadOverride |= (pageResponse[8] & 0x80) == 0x80;
decoded.AutoUnloadMode = (byte)(pageResponse[8] & 0x7F);
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 PrettifyCertanceModePage_21(byte[] pageResponse) =>
PrettifyCertanceModePage_21(DecodeCertanceModePage_21(pageResponse));
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
public static string PrettifyCertanceModePage_21(Certance_ModePage_21? modePage)
{
if(!modePage.HasValue)
return null;
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
Certance_ModePage_21 page = modePage.Value;
var sb = new StringBuilder();
2017-12-21 02:03:21 +00:00
sb.AppendLine(Localization.Certance_Drive_Capabilities_Control_Mode_Page);
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.PS)
sb.AppendLine("\t" + Localization.Parameters_can_be_saved);
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
switch(page.OperatingSystemsSupport)
{
case 0:
sb.AppendLine("\t" + Localization.Operating_systems_support_is_standard_LTO);
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
default:
sb.AppendFormat("\t" + Localization.Operating_systems_support_is_unknown_code_0,
page.OperatingSystemsSupport).AppendLine();
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
2022-03-06 13:29:37 +00:00
if(page.FirmwareTestControl == page.FirmwareTestControl2)
switch(page.FirmwareTestControl)
2017-12-21 02:03:21 +00:00
{
case 0:
sb.AppendLine("\t" + Localization.Factory_test_code_is_disabled);
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 1:
sb.AppendLine("\t" + Localization.Factory_test_code_1_is_disabled);
2022-03-06 13:29:37 +00:00
break;
case 2:
sb.AppendLine("\t" + Localization.Factory_test_code_2_is_disabled);
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
default:
sb.AppendFormat("\t" + Localization.Unknown_factory_test_code_0, page.FirmwareTestControl).
AppendLine();
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
}
2022-03-06 13:29:37 +00:00
switch(page.ExtendedPOSTMode)
{
case 0:
sb.AppendLine("\t" + Localization.Power_On_Self_Test_is_enabled);
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
case 1:
sb.AppendLine("\t" + Localization.Power_On_Self_Test_is_disabled);
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
default:
sb.AppendFormat("\t" + Localization.Unknown_Power_On_Self_Test_code_0, page.ExtendedPOSTMode).
AppendLine();
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
}
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
switch(page.DataCompressionControl)
{
case 0:
sb.AppendLine("\t" + Localization.Compression_is_controlled_using_mode_pages_0Fh_and_10h);
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
break;
case 1:
sb.AppendLine("\t" + Localization.Compression_is_enabled_and_not_controllable);
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
break;
case 2:
sb.AppendLine("\t" + Localization.Compression_is_disabled_and_not_controllable);
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
default:
sb.AppendFormat("\t" + Localization.Unknown_compression_control_code_0, page.DataCompressionControl).
AppendLine();
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
}
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.HostUnloadOverride)
sb.AppendLine("\t" + Localization.SCSI_UNLOAD_command_will_not_eject_the_cartridge);
2019-11-25 00:54:38 +00:00
sb.Append("\t" + Localization.
How_should_tapes_be_unloaded_in_a_power_cycle_tape_incompatibility_firmware_download_or_cleaning_end);
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
switch(page.AutoUnloadMode)
{
case 0:
sb.AppendLine("\t" + Localization.Tape_will_stay_threaded_at_beginning);
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
case 1:
sb.AppendLine("\t" + Localization.Tape_will_be_unthreaded);
2022-03-06 13:29:37 +00:00
break;
case 2:
sb.AppendLine("\t" + Localization.Tape_will_be_unthreaded_and_unloaded);
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
break;
case 3:
sb.AppendLine("\t" + Localization.Data_tapes_will_be_threaded_at_beginning_rest_will_be_unloaded);
2022-03-06 13:29:37 +00:00
break;
default:
sb.AppendFormat("\t" + Localization.Unknown_auto_unload_code_0, page.AutoUnloadMode).AppendLine();
2022-03-06 13:29:37 +00:00
break;
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
}
2022-03-06 13:29:37 +00:00
#endregion Certance Mode Page 0x21: Drive Capabilities Control Mode page
2017-12-21 02:03:21 +00:00
}