2017-12-21 02:03:21 +00:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : 04.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : Device structures decoders.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Decodes SCSI MODE PAGE 04h: Rigid disk drive geometry 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
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
2017-12-22 02:04:18 +00:00
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DiscImageChef.Decoders.SCSI
|
|
|
|
|
|
{
|
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 0x04: Rigid disk drive geometry page
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Disconnect-reconnect page Page code 0x04 24 bytes in SCSI-2, SBC-1</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public struct ModePage_04
|
|
|
|
|
|
{
|
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>Cylinders used for data storage</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public uint Cylinders;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Heads for reading and/or writing</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public byte Heads;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Cylinder where write precompensation starts</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public uint WritePrecompCylinder;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Cylinder where write current reduction starts</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public uint WriteReduceCylinder;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Step rate in 100 ns units</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public ushort DriveStepRate;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Cylinder where the heads park</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public int LandingCylinder;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Rotational position locking</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public byte RPL;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Rotational skew to apply when synchronized</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public byte RotationalOffset;
|
2019-11-25 00:54:38 +00:00
|
|
|
|
/// <summary>Medium speed in rpm</summary>
|
2017-12-21 02:03:21 +00:00
|
|
|
|
public ushort MediumRotationRate;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static ModePage_04? DecodeModePage_04(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) != 0x04)
|
|
|
|
|
|
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 < 20)
|
|
|
|
|
|
return null;
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2019-11-25 00:54:38 +00:00
|
|
|
|
var decoded = new ModePage_04();
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
decoded.PS |= (pageResponse[0] & 0x80) == 0x80;
|
|
|
|
|
|
decoded.Cylinders = (uint)((pageResponse[2] << 16) + (pageResponse[3] << 8) + pageResponse[4]);
|
|
|
|
|
|
decoded.Heads = pageResponse[5];
|
|
|
|
|
|
decoded.WritePrecompCylinder = (uint)((pageResponse[6] << 16) + (pageResponse[7] << 8) + pageResponse[8]);
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
decoded.WriteReduceCylinder =
|
|
|
|
|
|
(uint)((pageResponse[9] << 16) + (pageResponse[10] << 8) + pageResponse[11]);
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
decoded.DriveStepRate =
|
|
|
|
|
|
(ushort)((pageResponse[12] << 8) + pageResponse[13]);
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
decoded.LandingCylinder = (pageResponse[14] << 16) + (pageResponse[15] << 8) + pageResponse[16];
|
|
|
|
|
|
decoded.RPL = (byte)(pageResponse[17] & 0x03);
|
2017-12-21 02:03:21 +00:00
|
|
|
|
decoded.RotationalOffset = pageResponse[18];
|
|
|
|
|
|
|
|
|
|
|
|
if(pageResponse.Length >= 22)
|
|
|
|
|
|
decoded.MediumRotationRate = (ushort)((pageResponse[20] << 8) + pageResponse[21]);
|
|
|
|
|
|
|
|
|
|
|
|
return decoded;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-12-31 13:17:27 +00:00
|
|
|
|
public static string PrettifyModePage_04(byte[] pageResponse) =>
|
|
|
|
|
|
PrettifyModePage_04(DecodeModePage_04(pageResponse));
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
|
|
|
|
|
public static string PrettifyModePage_04(ModePage_04? 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_04 page = modePage.Value;
|
|
|
|
|
|
var sb = new StringBuilder();
|
2017-12-21 02:03:21 +00:00
|
|
|
|
|
|
|
|
|
|
sb.AppendLine("SCSI Rigid disk drive geometry 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
|
|
|
|
|
|
|
|
|
|
sb.AppendFormat("\t{0} heads", page.Heads).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("\t{0} cylinders", page.Cylinders).AppendLine();
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2017-12-21 02:03:21 +00:00
|
|
|
|
if(page.WritePrecompCylinder < page.Cylinders)
|
2019-11-25 00:54:38 +00:00
|
|
|
|
sb.AppendFormat("\tWrite pre-compensation starts at cylinder {0}", page.WritePrecompCylinder).
|
|
|
|
|
|
AppendLine();
|
|
|
|
|
|
|
2017-12-21 02:03:21 +00:00
|
|
|
|
if(page.WriteReduceCylinder < page.Cylinders)
|
2019-11-25 00:54:38 +00:00
|
|
|
|
sb.AppendFormat("\tWrite current reduction starts at cylinder {0}", page.WriteReduceCylinder).
|
|
|
|
|
|
AppendLine();
|
|
|
|
|
|
|
2017-12-21 02:03:21 +00:00
|
|
|
|
if(page.DriveStepRate > 0)
|
|
|
|
|
|
sb.AppendFormat("\tDrive steps in {0} ns", (uint)page.DriveStepRate * 100).AppendLine();
|
|
|
|
|
|
|
|
|
|
|
|
sb.AppendFormat("\tHeads park in cylinder {0}", page.LandingCylinder).AppendLine();
|
|
|
|
|
|
|
|
|
|
|
|
if(page.MediumRotationRate > 0)
|
|
|
|
|
|
sb.AppendFormat("\tMedium rotates at {0} rpm", page.MediumRotationRate).AppendLine();
|
|
|
|
|
|
|
|
|
|
|
|
switch(page.RPL)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
sb.AppendLine("\tSpindle synchronization is disable or unsupported");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2017-12-21 02:03:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
sb.AppendLine("\tTarget operates as a synchronized-spindle slave");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2017-12-21 02:03:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
sb.AppendLine("\tTarget operates as a synchronized-spindle master");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2017-12-21 02:03:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
sb.AppendLine("\tTarget operates as a synchronized-spindle master control");
|
2019-11-25 00:54:38 +00:00
|
|
|
|
|
2017-12-21 02:03:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion Mode Page 0x04: Rigid disk drive geometry page
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|