Files
Aaru/SCSI/Modes/1C_SFF.cs

175 lines
6.8 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 : 1C_SFF.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Device structures decoders.
//
// --[ Description ] ----------------------------------------------------------
//
// Decodes SCSI MODE PAGE 1Ch: Timer & Protect 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 Mode Page 0x1C: Timer & Protect page
2019-11-25 00:54:38 +00:00
/// <summary>Timer &amp; Protect page Page code 0x1C 8 bytes in INF-8070</summary>
2017-12-21 02:03:21 +00:00
public struct ModePage_1C_SFF
{
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;
2019-11-25 00:54:38 +00:00
/// <summary>Time the device shall remain in the current state after seek, read or write operation</summary>
2017-12-21 02:03:21 +00:00
public byte InactivityTimeMultiplier;
2019-11-25 00:54:38 +00:00
/// <summary>Disabled until power cycle</summary>
2017-12-21 02:03:21 +00:00
public bool DISP;
2019-11-25 00:54:38 +00:00
/// <summary>Software Write Protect until Power-down</summary>
2017-12-21 02:03:21 +00:00
public bool SWPP;
}
public static ModePage_1C_SFF? DecodeModePage_1C_SFF(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) != 0x1C)
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 < 8)
return null;
2017-12-21 02:03:21 +00:00
2019-11-25 00:54:38 +00:00
var decoded = new ModePage_1C_SFF();
2017-12-21 02:03:21 +00:00
2018-06-22 08:08:38 +01:00
decoded.PS |= (pageResponse[0] & 0x80) == 0x80;
2017-12-21 02:03:21 +00:00
decoded.DISP |= (pageResponse[2] & 0x02) == 0x02;
decoded.SWPP |= (pageResponse[3] & 0x01) == 0x01;
decoded.InactivityTimeMultiplier = (byte)(pageResponse[3] & 0x0F);
return decoded;
}
2018-12-31 13:17:27 +00:00
public static string PrettifyModePage_1C_SFF(byte[] pageResponse) =>
PrettifyModePage_1C_SFF(DecodeModePage_1C_SFF(pageResponse));
2017-12-21 02:03:21 +00:00
public static string PrettifyModePage_1C_SFF(ModePage_1C_SFF? modePage)
{
2019-11-25 00:54:38 +00:00
if(!modePage.HasValue)
return null;
2017-12-21 02:03:21 +00:00
ModePage_1C_SFF 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("SCSI Timer & Protect 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
2019-11-25 00:54:38 +00:00
if(page.DISP)
sb.AppendLine("\tDrive is disabled until power is cycled");
if(page.SWPP)
sb.AppendLine("\tDrive is software write-protected until powered down");
2017-12-21 02:03:21 +00:00
switch(page.InactivityTimeMultiplier)
{
case 0:
sb.AppendLine("\tDrive will remain in same status a vendor-specified time after a seek, read or write operation");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 1:
sb.AppendLine("\tDrive will remain in same status 125 ms after a seek, read or write operation");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 2:
sb.AppendLine("\tDrive will remain in same status 250 ms after a seek, read or write operation");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 3:
sb.AppendLine("\tDrive will remain in same status 500 ms after a seek, read or write operation");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 4:
sb.AppendLine("\tDrive will remain in same status 1 second after a seek, read or write operation");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 5:
sb.AppendLine("\tDrive will remain in same status 2 seconds after a seek, read or write operation");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 6:
sb.AppendLine("\tDrive will remain in same status 4 seconds after a seek, read or write operation");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 7:
sb.AppendLine("\tDrive will remain in same status 8 seconds after a seek, read or write operation");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 8:
sb.AppendLine("\tDrive will remain in same status 16 seconds after a seek, read or write operation");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 9:
sb.AppendLine("\tDrive will remain in same status 32 seconds after a seek, read or write operation");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 10:
sb.AppendLine("\tDrive will remain in same status 1 minute after a seek, read or write operation");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 11:
sb.AppendLine("\tDrive will remain in same status 2 minutes after a seek, read or write operation");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 12:
sb.AppendLine("\tDrive will remain in same status 4 minutes after a seek, read or write operation");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 13:
sb.AppendLine("\tDrive will remain in same status 8 minutes after a seek, read or write operation");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 14:
sb.AppendLine("\tDrive will remain in same status 16 minutes after a seek, read or write operation");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 15:
sb.AppendLine("\tDrive will remain in same status 32 minutes after a seek, read or write operation");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
}
return sb.ToString();
}
#endregion Mode Page 0x1C: Timer & Protect page
}
}