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 : 24_IBM.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : Device structures decoders.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Decodes IBM MODE PAGE 24h: 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
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
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 IBM Mode Page 0x24: Drive Capabilities Control Mode page
|
|
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
public struct IBM_ModePage_24
|
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 ModeControl;
|
|
|
|
|
|
public byte VelocitySetting;
|
|
|
|
|
|
public bool EncryptionEnabled;
|
|
|
|
|
|
public bool EncryptionCapable;
|
|
|
|
|
|
}
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
public static IBM_ModePage_24? DecodeIBMModePage_24(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) != 0x24)
|
|
|
|
|
|
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 != 8)
|
|
|
|
|
|
return null;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
var decoded = new IBM_ModePage_24();
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
decoded.PS |= (pageResponse[0] & 0x80) == 0x80;
|
|
|
|
|
|
decoded.ModeControl = pageResponse[2];
|
|
|
|
|
|
decoded.VelocitySetting = pageResponse[3];
|
|
|
|
|
|
decoded.EncryptionEnabled |= (pageResponse[7] & 0x08) == 0x08;
|
|
|
|
|
|
decoded.EncryptionCapable |= (pageResponse[7] & 0x01) == 0x01;
|
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 PrettifyIBMModePage_24(byte[] pageResponse) =>
|
|
|
|
|
|
PrettifyIBMModePage_24(DecodeIBMModePage_24(pageResponse));
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
public static string PrettifyIBMModePage_24(IBM_ModePage_24? modePage)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(!modePage.HasValue)
|
|
|
|
|
|
return null;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
IBM_ModePage_24 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.IBM_Vendor_Specific_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);
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2023-10-03 23:09:28 +01:00
|
|
|
|
sb.AppendFormat("\t" + Localization.Vendor_specific_mode_control_0, page.ModeControl);
|
2022-11-27 13:33:47 +00:00
|
|
|
|
sb.AppendFormat("\t" + Localization.Vendor_specific_velocity_setting_0, page.VelocitySetting);
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
if(!page.EncryptionCapable)
|
|
|
|
|
|
return sb.ToString();
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
2022-11-27 13:33:47 +00:00
|
|
|
|
sb.AppendLine("\t" + Localization.Drive_supports_encryption);
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
|
if(page.EncryptionEnabled)
|
2022-11-27 13:33:47 +00:00
|
|
|
|
sb.AppendLine("\t" + Localization.Drive_has_encryption_enabled);
|
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 IBM Mode Page 0x24: Drive Capabilities Control Mode page
|
2017-12-21 02:03:21 +00:00
|
|
|
|
}
|