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

108 lines
3.7 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 : 3D_HP.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Device structures decoders.
//
// --[ Description ] ----------------------------------------------------------
//
// Decodes HP MODE PAGE 3Dh: Extended Reset 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/>.
//
// ----------------------------------------------------------------------------
2020-01-03 17:51:28 +00:00
// Copyright © 2011-2020 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;
2020-02-27 00:33:24 +00:00
namespace Aaru.Decoders.SCSI
2017-12-21 02:03:21 +00:00
{
2019-11-25 00:54:38 +00:00
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
2017-12-21 02:03:21 +00:00
public static partial class Modes
{
#region HP Mode Page 0x3D: Extended Reset Mode page
public struct HP_ModePage_3D
{
2019-11-25 00:54:38 +00:00
/// <summary>Parameters can be saved</summary>
2017-12-21 02:03:21 +00:00
public bool PS;
public byte ResetBehaviour;
}
public static HP_ModePage_3D? DecodeHPModePage_3D(byte[] pageResponse)
{
2019-11-25 00:54:38 +00:00
if((pageResponse?[0] & 0x40) == 0x40)
return null;
2017-12-21 02:03:21 +00:00
2019-11-25 00:54:38 +00:00
if((pageResponse?[0] & 0x3F) != 0x3D)
return null;
2017-12-21 02:03:21 +00:00
2019-11-25 00:54:38 +00:00
if(pageResponse[1] + 2 != pageResponse.Length)
return null;
2017-12-21 02:03:21 +00:00
2019-11-25 00:54:38 +00:00
if(pageResponse.Length != 4)
return null;
2017-12-21 02:03:21 +00:00
2019-11-25 00:54:38 +00:00
var decoded = new HP_ModePage_3D();
2017-12-21 02:03:21 +00:00
2018-06-22 08:08:38 +01:00
decoded.PS |= (pageResponse[0] & 0x80) == 0x80;
decoded.ResetBehaviour = (byte)(pageResponse[2] & 0x03);
2017-12-21 02:03:21 +00:00
return decoded;
}
2018-12-31 13:17:27 +00:00
public static string PrettifyHPModePage_3D(byte[] pageResponse) =>
PrettifyHPModePage_3D(DecodeHPModePage_3D(pageResponse));
2017-12-21 02:03:21 +00:00
public static string PrettifyHPModePage_3D(HP_ModePage_3D? modePage)
{
2019-11-25 00:54:38 +00:00
if(!modePage.HasValue)
return null;
2017-12-21 02:03:21 +00:00
HP_ModePage_3D page = modePage.Value;
2019-11-25 00:54:38 +00:00
var sb = new StringBuilder();
2017-12-21 02:03:21 +00:00
sb.AppendLine("HP Extended Reset Mode Page:");
2019-11-25 00:54:38 +00:00
if(page.PS)
sb.AppendLine("\tParameters can be saved");
2017-12-21 02:03:21 +00:00
switch(page.ResetBehaviour)
{
case 0:
sb.AppendLine("\tNormal reset behaviour");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 1:
sb.AppendLine("\tDrive will flush and position itself on a LUN or target reset");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 2:
sb.AppendLine("\tDrive will maintain position on a LUN or target reset");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
}
return sb.ToString();
}
#endregion HP Mode Page 0x3D: Extended Reset Mode page
}
}