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.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : Device structures decoders.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Decodes SCSI MODE PAGE 1Ch: Informational exceptions 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-02-18 10:02:39 +00:00
|
|
|
|
// Copyright © 2011-2022 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;
|
|
|
|
|
|
|
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: Informational exceptions control page
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Informational exceptions control page Page code 0x1C 12 bytes in SPC-1, SPC-2, SPC-3, SPC-4</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public struct ModePage_1C
|
|
|
|
|
|
{
|
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>Informational exception operations should not affect performance</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public bool Perf;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Disable informational exception operations</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public bool DExcpt;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Create a test device failure at next interval time</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public bool Test;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Log informational exception conditions</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public bool LogErr;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Method of reporting informational exceptions</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public byte MRIE;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>100 ms period to report an informational exception condition</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public uint IntervalTimer;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>How many times to report informational exceptions</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public uint ReportCount;
|
|
|
|
|
|
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Enable background functions</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public bool EBF;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Warning reporting enabled</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public bool EWasc;
|
|
|
|
|
|
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Enable reporting of background self-test errors</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public bool EBACKERR;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static ModePage_1C? DecodeModePage_1C(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();
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
|
|
|
|
|
decoded.PS |= (pageResponse[0] & 0x80) == 0x80;
|
|
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
decoded.Perf |= (pageResponse[2] & 0x80) == 0x80;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
decoded.DExcpt |= (pageResponse[2] & 0x08) == 0x08;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
decoded.Test |= (pageResponse[2] & 0x04) == 0x04;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
decoded.LogErr |= (pageResponse[2] & 0x01) == 0x01;
|
|
|
|
|
|
|
|
|
|
|
|
decoded.MRIE = (byte)(pageResponse[3] & 0x0F);
|
|
|
|
|
|
|
|
|
|
|
|
decoded.IntervalTimer = (uint)((pageResponse[4] << 24) + (pageResponse[5] << 16) + (pageResponse[6] << 8) +
|
|
|
|
|
|
pageResponse[7]);
|
|
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
decoded.EBF |= (pageResponse[2] & 0x20) == 0x20;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
decoded.EWasc |= (pageResponse[2] & 0x10) == 0x10;
|
|
|
|
|
|
|
|
|
|
|
|
decoded.EBACKERR |= (pageResponse[2] & 0x02) == 0x02;
|
|
|
|
|
|
|
|
|
|
|
|
if(pageResponse.Length >= 12)
|
2018-06-22 08:08:38 +01:00
|
|
|
|
decoded.ReportCount = (uint)((pageResponse[8] << 24) + (pageResponse[9] << 16) +
|
|
|
|
|
|
(pageResponse[10] << 8) + pageResponse[11]);
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
|
|
|
|
|
return decoded;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-12-31 13:17:27 +00:00
|
|
|
|
public static string PrettifyModePage_1C(byte[] pageResponse) =>
|
|
|
|
|
|
PrettifyModePage_1C(DecodeModePage_1C(pageResponse));
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
|
|
|
|
|
public static string PrettifyModePage_1C(ModePage_1C? modePage)
|
|
|
|
|
|
{
|
2019-11-25 00:54:38 +00:00
|
|
|
|
if(!modePage.HasValue)
|
|
|
|
|
|
return null;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2019-11-25 00:54:38 +00:00
|
|
|
|
ModePage_1C page = modePage.Value;
|
|
|
|
|
|
var sb = new StringBuilder();
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
|
|
|
|
|
sb.AppendLine("SCSI Informational exceptions control 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.DExcpt)
|
|
|
|
|
|
sb.AppendLine("\tInformational exceptions are disabled");
|
2017-12-21 02:03:21 +00:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
sb.AppendLine("\tInformational exceptions are enabled");
|
|
|
|
|
|
|
|
|
|
|
|
switch(page.MRIE)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
sb.AppendLine("\tNo reporting of informational exception condition");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2017-12-21 02:03:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
sb.AppendLine("\tAsynchronous event reporting of informational exceptions");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2017-12-21 02:03:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
sb.AppendLine("\tGenerate unit attention on informational exceptions");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2017-12-21 02:03:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
sb.AppendLine("\tConditionally generate recovered error on informational exceptions");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2017-12-21 02:03:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
sb.AppendLine("\tUnconditionally generate recovered error on informational exceptions");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2017-12-21 02:03:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case 5:
|
|
|
|
|
|
sb.AppendLine("\tGenerate no sense on informational exceptions");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2017-12-21 02:03:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case 6:
|
|
|
|
|
|
sb.AppendLine("\tOnly report informational exception condition on request");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2017-12-21 02:03:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
sb.AppendFormat("\tUnknown method of reporting {0}", page.MRIE).AppendLine();
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2017-12-21 02:03:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-11-25 00:54:38 +00:00
|
|
|
|
if(page.Perf)
|
|
|
|
|
|
sb.AppendLine("\tInformational exceptions reporting should not affect drive performance");
|
|
|
|
|
|
|
|
|
|
|
|
if(page.Test)
|
|
|
|
|
|
sb.AppendLine("\tA test informational exception will raise on next timer");
|
|
|
|
|
|
|
|
|
|
|
|
if(page.LogErr)
|
|
|
|
|
|
sb.AppendLine("\tDrive shall log informational exception conditions");
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
|
|
|
|
|
if(page.IntervalTimer > 0)
|
2018-06-22 08:08:38 +01:00
|
|
|
|
if(page.IntervalTimer == 0xFFFFFFFF)
|
|
|
|
|
|
sb.AppendLine("\tTimer interval is vendor-specific");
|
|
|
|
|
|
else
|
|
|
|
|
|
sb.AppendFormat("\tTimer interval is {0} ms", page.IntervalTimer * 100).AppendLine();
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
|
|
|
|
|
if(page.ReportCount > 0)
|
|
|
|
|
|
sb.AppendFormat("\tInformational exception conditions will be reported a maximum of {0} times",
|
|
|
|
|
|
page.ReportCount);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-11-25 00:54:38 +00:00
|
|
|
|
if(page.EWasc)
|
|
|
|
|
|
sb.AppendLine("\tWarning reporting is enabled");
|
|
|
|
|
|
|
|
|
|
|
|
if(page.EBF)
|
|
|
|
|
|
sb.AppendLine("\tBackground functions are enabled");
|
|
|
|
|
|
|
|
|
|
|
|
if(page.EBACKERR)
|
|
|
|
|
|
sb.AppendLine("\tDrive will report background self-test errors");
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion Mode Page 0x1C: Informational exceptions control page
|
2017-12-21 07:36:47 +00:00
|
|
|
|
|
2017-12-21 02:03:21 +00:00
|
|
|
|
#region Mode Page 0x1C subpage 0x01: Background Control mode page
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Background Control mode page Page code 0x1A Subpage code 0x01 16 bytes in SPC-5</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public struct ModePage_1C_S01
|
|
|
|
|
|
{
|
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>Suspend on log full</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public bool S_L_Full;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Log only when intervention required</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public bool LOWIR;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Enable background medium scan</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public bool En_Bms;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Enable background pre-scan</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public bool En_Ps;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Time in hours between background medium scans</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public ushort BackgroundScanInterval;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Maximum time in hours for a background pre-scan to complete</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public ushort BackgroundPrescanTimeLimit;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Minimum time in ms being idle before resuming a background scan</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public ushort MinIdleBeforeBgScan;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Maximum time in ms to start processing commands while performing a background scan</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public ushort MaxTimeSuspendBgScan;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static ModePage_1C_S01? DecodeModePage_1C_S01(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] != 0x01)
|
|
|
|
|
|
return null;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2019-11-25 00:54:38 +00:00
|
|
|
|
if((pageResponse[2] << 8) + pageResponse[3] + 4 != pageResponse.Length)
|
|
|
|
|
|
return null;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2019-11-25 00:54:38 +00:00
|
|
|
|
if(pageResponse.Length < 16)
|
|
|
|
|
|
return null;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2019-11-25 00:54:38 +00:00
|
|
|
|
var decoded = new ModePage_1C_S01();
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
|
|
|
|
|
decoded.PS |= (pageResponse[0] & 0x80) == 0x80;
|
|
|
|
|
|
|
|
|
|
|
|
decoded.S_L_Full |= (pageResponse[4] & 0x04) == 0x04;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
decoded.LOWIR |= (pageResponse[4] & 0x02) == 0x02;
|
|
|
|
|
|
decoded.En_Bms |= (pageResponse[4] & 0x01) == 0x01;
|
|
|
|
|
|
decoded.En_Ps |= (pageResponse[5] & 0x01) == 0x01;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
decoded.BackgroundScanInterval = (ushort)((pageResponse[6] << 8) + pageResponse[7]);
|
|
|
|
|
|
decoded.BackgroundPrescanTimeLimit = (ushort)((pageResponse[8] << 8) + pageResponse[9]);
|
|
|
|
|
|
decoded.MinIdleBeforeBgScan = (ushort)((pageResponse[10] << 8) + pageResponse[11]);
|
|
|
|
|
|
decoded.MaxTimeSuspendBgScan = (ushort)((pageResponse[12] << 8) + pageResponse[13]);
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
|
|
|
|
|
return decoded;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-12-31 13:17:27 +00:00
|
|
|
|
public static string PrettifyModePage_1C_S01(byte[] pageResponse) =>
|
|
|
|
|
|
PrettifyModePage_1C_S01(DecodeModePage_1C_S01(pageResponse));
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
|
|
|
|
|
public static string PrettifyModePage_1C_S01(ModePage_1C_S01? modePage)
|
|
|
|
|
|
{
|
2019-11-25 00:54:38 +00:00
|
|
|
|
if(!modePage.HasValue)
|
|
|
|
|
|
return null;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
|
|
|
|
|
ModePage_1C_S01 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 Background Control page:");
|
|
|
|
|
|
|
2019-11-25 00:54:38 +00:00
|
|
|
|
if(page.PS)
|
|
|
|
|
|
sb.AppendLine("\tParameters can be saved");
|
|
|
|
|
|
|
|
|
|
|
|
if(page.S_L_Full)
|
|
|
|
|
|
sb.AppendLine("\tBackground scans will be halted if log is full");
|
|
|
|
|
|
|
|
|
|
|
|
if(page.LOWIR)
|
|
|
|
|
|
sb.AppendLine("\tBackground scans will only be logged if they require intervention");
|
|
|
|
|
|
|
|
|
|
|
|
if(page.En_Bms)
|
|
|
|
|
|
sb.AppendLine("\tBackground medium scans are enabled");
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2019-11-25 00:54:38 +00:00
|
|
|
|
if(page.En_Ps)
|
|
|
|
|
|
sb.AppendLine("\tBackground pre-scans are enabled");
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
|
|
|
|
|
if(page.BackgroundScanInterval > 0)
|
|
|
|
|
|
sb.AppendFormat("\t{0} hours shall be between the start of a background scan operation and the next",
|
|
|
|
|
|
page.BackgroundScanInterval).AppendLine();
|
|
|
|
|
|
|
|
|
|
|
|
if(page.BackgroundPrescanTimeLimit > 0)
|
|
|
|
|
|
sb.AppendFormat("\tBackgroun pre-scan operations can take a maximum of {0} hours",
|
|
|
|
|
|
page.BackgroundPrescanTimeLimit).AppendLine();
|
|
|
|
|
|
|
|
|
|
|
|
if(page.MinIdleBeforeBgScan > 0)
|
|
|
|
|
|
sb.AppendFormat("\tAt least {0} ms must be idle before resuming a suspended background scan operation",
|
|
|
|
|
|
page.MinIdleBeforeBgScan).AppendLine();
|
|
|
|
|
|
|
|
|
|
|
|
if(page.MaxTimeSuspendBgScan > 0)
|
2019-11-25 00:54:38 +00:00
|
|
|
|
sb.
|
|
|
|
|
|
AppendFormat("\tAt most {0} ms must be before suspending a background scan operation and processing received commands",
|
2018-06-22 08:08:38 +01:00
|
|
|
|
page.MaxTimeSuspendBgScan).AppendLine();
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion Mode Page 0x1C subpage 0x01: Background Control mode page
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|