2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2016-01-13 03:47:25 +00:00
|
|
|
// The Disc Image Chef
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : SSC.cs
|
2016-07-28 18:13:49 +01:00
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2016-01-13 03:47:25 +00:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Component : SCSI Stream Commands.
|
2016-01-13 03:47:25 +00:00
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Contains SCSI commands defined in SSC standards.
|
2016-01-13 03:47:25 +00:00
|
|
|
//
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// 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
|
2016-01-13 03:47:25 +00:00
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// 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.
|
2016-01-13 03:47:25 +00:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// 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/>.
|
2016-01-13 03:47:25 +00:00
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2020-01-03 17:51:30 +00:00
|
|
|
// Copyright © 2011-2020 Natalia Portillo
|
2016-01-13 03:47:25 +00:00
|
|
|
// ****************************************************************************/
|
2016-07-28 18:13:49 +01:00
|
|
|
|
2016-01-13 03:47:25 +00:00
|
|
|
using System;
|
2020-02-27 00:33:26 +00:00
|
|
|
using Aaru.Console;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
2020-02-27 00:33:26 +00:00
|
|
|
namespace Aaru.Devices
|
2016-01-13 03:47:25 +00:00
|
|
|
{
|
|
|
|
|
public partial class Device
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Prepares the medium for reading
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <returns><c>true</c>, if load was successful, <c>false</c> otherwise.</returns>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-12-31 13:17:27 +00:00
|
|
|
public bool Load(out byte[] senseBuffer, uint timeout, out double duration) =>
|
|
|
|
|
LoadUnload(out senseBuffer, false, true, false, false, false, timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Prepares the medium for ejection
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <returns><c>true</c>, if unload was successful, <c>false</c> otherwise.</returns>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-12-31 13:17:27 +00:00
|
|
|
public bool Unload(out byte[] senseBuffer, uint timeout, out double duration) =>
|
|
|
|
|
LoadUnload(out senseBuffer, false, false, false, false, false, timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Prepares the medium for reading or ejection
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <returns><c>true</c>, if load/unload was successful, <c>false</c> otherwise.</returns>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="immediate">If set to <c>true</c>, return from the command immediately.</param>
|
|
|
|
|
/// <param name="load">If set to <c>true</c> load the medium for reading.</param>
|
|
|
|
|
/// <param name="retense">If set to <c>true</c> retense the tape.</param>
|
|
|
|
|
/// <param name="endOfTape">If set to <c>true</c> move the medium to the EOT mark.</param>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// <param name="hold">
|
|
|
|
|
/// If set to <c>true</c> and <paramref name="load" /> is also set to <c>true</c>, moves the medium to
|
|
|
|
|
/// the drive but does not prepare it for reading.
|
|
|
|
|
/// </param>
|
2016-01-13 03:47:25 +00:00
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool LoadUnload(out byte[] senseBuffer, bool immediate, bool load, bool retense, bool endOfTape,
|
|
|
|
|
bool hold, uint timeout, out double duration)
|
2016-01-13 03:47:25 +00:00
|
|
|
{
|
|
|
|
|
senseBuffer = new byte[32];
|
2018-06-22 08:08:38 +01:00
|
|
|
byte[] cdb = new byte[6];
|
2016-01-13 03:47:25 +00:00
|
|
|
byte[] buffer = new byte[0];
|
|
|
|
|
|
|
|
|
|
cdb[0] = (byte)ScsiCommands.LoadUnload;
|
2018-06-22 08:08:38 +01:00
|
|
|
if(immediate) cdb[1] = 0x01;
|
|
|
|
|
if(load) cdb[4] += 0x01;
|
|
|
|
|
if(retense) cdb[4] += 0x02;
|
2017-12-19 20:33:03 +00:00
|
|
|
if(endOfTape) cdb[4] += 0x04;
|
2018-06-22 08:08:38 +01:00
|
|
|
if(hold) cdb[4] += 0x08;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-21 07:19:46 +00:00
|
|
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
2017-12-22 03:13:43 +00:00
|
|
|
out bool sense);
|
2017-12-21 07:19:46 +00:00
|
|
|
Error = LastError != 0;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("SCSI Device", "LOAD UNLOAD (6) took {0} ms.", duration);
|
|
|
|
|
|
|
|
|
|
return sense;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Positions the medium to the specified block in the current partition
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="lba">Logical block address.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-12-31 13:17:27 +00:00
|
|
|
public bool Locate(out byte[] senseBuffer, uint lba, uint timeout, out double duration) =>
|
2019-05-07 01:22:30 +01:00
|
|
|
Locate(out senseBuffer, false, false, false, 0, lba, timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Positions the medium to the specified block in the specified partition
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="partition">Partition to position to.</param>
|
|
|
|
|
/// <param name="lba">Logical block address.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-12-31 13:17:27 +00:00
|
|
|
public bool Locate(out byte[] senseBuffer, byte partition, uint lba, uint timeout, out double duration) =>
|
2019-05-07 01:22:30 +01:00
|
|
|
Locate(out senseBuffer, false, false, false, partition, lba, timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Positions the medium to the specified block in the current partition
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="immediate">If set to <c>true</c>, return from the command immediately.</param>
|
|
|
|
|
/// <param name="lba">Logical block address.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-12-31 13:17:27 +00:00
|
|
|
public bool Locate(out byte[] senseBuffer, bool immediate, uint lba, uint timeout, out double duration) =>
|
2019-05-07 01:22:30 +01:00
|
|
|
Locate(out senseBuffer, immediate, false, false, 0, lba, timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Positions the medium to the specified block in the specified partition
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="immediate">If set to <c>true</c>, return from the command immediately.</param>
|
|
|
|
|
/// <param name="partition">Partition to position to.</param>
|
|
|
|
|
/// <param name="lba">Logical block address.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2017-12-19 20:33:03 +00:00
|
|
|
public bool Locate(out byte[] senseBuffer, bool immediate, byte partition, uint lba, uint timeout,
|
2018-12-31 13:17:27 +00:00
|
|
|
out double duration) =>
|
2019-05-07 01:22:30 +01:00
|
|
|
Locate(out senseBuffer, immediate, false, false, partition, lba, timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Positions the medium to the specified object identifier
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="immediate">If set to <c>true</c>, return from the command immediately.</param>
|
|
|
|
|
/// <param name="blockType">If set to <c>true</c> object identifier is vendor specified.</param>
|
|
|
|
|
/// <param name="changePartition">If set to <c>true</c> change partition.</param>
|
|
|
|
|
/// <param name="partition">Partition to position to.</param>
|
|
|
|
|
/// <param name="objectId">Object identifier.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool Locate(out byte[] senseBuffer, bool immediate, bool blockType, bool changePartition,
|
|
|
|
|
byte partition,
|
|
|
|
|
uint objectId, uint timeout, out double duration)
|
2016-01-13 03:47:25 +00:00
|
|
|
{
|
|
|
|
|
senseBuffer = new byte[32];
|
2018-06-22 08:08:38 +01:00
|
|
|
byte[] cdb = new byte[10];
|
2016-01-13 03:47:25 +00:00
|
|
|
byte[] buffer = new byte[0];
|
|
|
|
|
|
|
|
|
|
cdb[0] = (byte)ScsiCommands.Locate;
|
2018-06-22 08:08:38 +01:00
|
|
|
if(immediate) cdb[1] += 0x01;
|
2017-12-19 20:33:03 +00:00
|
|
|
if(changePartition) cdb[1] += 0x02;
|
2018-06-22 08:08:38 +01:00
|
|
|
if(blockType) cdb[1] += 0x04;
|
2016-01-13 03:47:25 +00:00
|
|
|
cdb[3] = (byte)((objectId & 0xFF000000) >> 24);
|
2018-06-22 08:08:38 +01:00
|
|
|
cdb[4] = (byte)((objectId & 0xFF0000) >> 16);
|
|
|
|
|
cdb[5] = (byte)((objectId & 0xFF00) >> 8);
|
2016-01-13 03:47:25 +00:00
|
|
|
cdb[6] = (byte)(objectId & 0xFF);
|
|
|
|
|
cdb[8] = partition;
|
|
|
|
|
|
2017-12-21 07:19:46 +00:00
|
|
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
2017-12-22 03:13:43 +00:00
|
|
|
out bool sense);
|
2017-12-21 07:19:46 +00:00
|
|
|
Error = LastError != 0;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("SCSI Device", "LOCATE (10) took {0} ms.", duration);
|
|
|
|
|
|
|
|
|
|
return sense;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Positions the medium to the specified block in the current partition
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="lba">Logical block address.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-12-31 13:17:27 +00:00
|
|
|
public bool Locate16(out byte[] senseBuffer, ulong lba, uint timeout, out double duration) =>
|
|
|
|
|
Locate16(out senseBuffer, false, false, SscLogicalIdTypes.ObjectId, false, 0, lba, timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Positions the medium to the specified block in the specified partition
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="partition">Partition to position to.</param>
|
|
|
|
|
/// <param name="lba">Logical block address.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-12-31 13:17:27 +00:00
|
|
|
public bool Locate16(out byte[] senseBuffer, byte partition, ulong lba, uint timeout, out double duration) =>
|
2019-05-07 01:22:30 +01:00
|
|
|
Locate16(out senseBuffer, false, false, SscLogicalIdTypes.ObjectId, false, partition, lba, timeout,
|
2018-12-31 13:17:27 +00:00
|
|
|
out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Positions the medium to the specified block in the current partition
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="immediate">If set to <c>true</c>, return from the command immediately.</param>
|
|
|
|
|
/// <param name="lba">Logical block address.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-12-31 13:17:27 +00:00
|
|
|
public bool Locate16(out byte[] senseBuffer, bool immediate, ulong lba, uint timeout, out double duration) =>
|
|
|
|
|
Locate16(out senseBuffer, immediate, false, SscLogicalIdTypes.ObjectId, false, 0, lba, timeout,
|
|
|
|
|
out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Positions the medium to the specified block in the specified partition
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="immediate">If set to <c>true</c>, return from the command immediately.</param>
|
|
|
|
|
/// <param name="partition">Partition to position to.</param>
|
|
|
|
|
/// <param name="lba">Logical block address.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2017-12-19 20:33:03 +00:00
|
|
|
public bool Locate16(out byte[] senseBuffer, bool immediate, byte partition, ulong lba, uint timeout,
|
2018-12-31 13:17:27 +00:00
|
|
|
out double duration) =>
|
2019-05-07 01:22:30 +01:00
|
|
|
Locate16(out senseBuffer, immediate, false, SscLogicalIdTypes.ObjectId, false, partition, lba, timeout,
|
2018-12-31 13:17:27 +00:00
|
|
|
out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Positions the medium to the specified object identifier
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="immediate">If set to <c>true</c>, return from the command immediately.</param>
|
|
|
|
|
/// <param name="changePartition">If set to <c>true</c> change partition.</param>
|
|
|
|
|
/// <param name="destType">Destination type.</param>
|
|
|
|
|
/// <param name="bam">If set to <c>true</c> objectId is explicit.</param>
|
|
|
|
|
/// <param name="partition">Partition to position to.</param>
|
|
|
|
|
/// <param name="identifier">Destination identifier.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool Locate16(out byte[] senseBuffer, bool immediate, bool changePartition, SscLogicalIdTypes destType,
|
|
|
|
|
bool bam, byte partition, ulong identifier, uint timeout,
|
|
|
|
|
out double duration)
|
2016-01-13 03:47:25 +00:00
|
|
|
{
|
|
|
|
|
senseBuffer = new byte[32];
|
2018-06-22 08:08:38 +01:00
|
|
|
byte[] cdb = new byte[16];
|
|
|
|
|
byte[] buffer = new byte[0];
|
2016-01-13 03:47:25 +00:00
|
|
|
byte[] idBytes = BitConverter.GetBytes(identifier);
|
|
|
|
|
|
|
|
|
|
cdb[0] = (byte)ScsiCommands.Locate16;
|
|
|
|
|
cdb[1] = (byte)((byte)destType << 3);
|
2018-06-22 08:08:38 +01:00
|
|
|
if(immediate) cdb[1] += 0x01;
|
2017-12-19 20:33:03 +00:00
|
|
|
if(changePartition) cdb[1] += 0x02;
|
2018-06-22 08:08:38 +01:00
|
|
|
if(bam) cdb[2] = 0x01;
|
2016-01-13 03:47:25 +00:00
|
|
|
cdb[3] = partition;
|
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
cdb[4] = idBytes[7];
|
|
|
|
|
cdb[5] = idBytes[6];
|
|
|
|
|
cdb[6] = idBytes[5];
|
|
|
|
|
cdb[7] = idBytes[4];
|
|
|
|
|
cdb[8] = idBytes[3];
|
|
|
|
|
cdb[9] = idBytes[2];
|
2016-01-13 03:47:25 +00:00
|
|
|
cdb[10] = idBytes[1];
|
|
|
|
|
cdb[11] = idBytes[0];
|
|
|
|
|
|
2017-12-21 07:19:46 +00:00
|
|
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
2017-12-22 03:13:43 +00:00
|
|
|
out bool sense);
|
2017-12-21 07:19:46 +00:00
|
|
|
Error = LastError != 0;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("SCSI Device", "LOCATE (16) took {0} ms.", duration);
|
|
|
|
|
|
|
|
|
|
return sense;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*/// <summary>
|
|
|
|
|
/// Reads the specified number of blocks from the medium
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="blocks">How many blocks to read.</param>
|
|
|
|
|
/// <param name="blockSize">Block size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
|
|
|
|
public bool Read6(out byte[] buffer, out byte[] senseBuffer, uint blocks, uint blockSize, uint timeout, out double duration)
|
|
|
|
|
{
|
|
|
|
|
return Read6(out buffer, out senseBuffer, false, true, blocks, blockSize, timeout, out duration);
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads the specified number of bytes or of blocks from the medium
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="sili">If set to <c>true</c> suppress the incorrect-length indication.</param>
|
|
|
|
|
/// <param name="transferLen">How many bytes to read.</param>
|
|
|
|
|
/// <param name="blockSize">Block size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool Read6(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen, uint blockSize,
|
2018-12-31 13:17:27 +00:00
|
|
|
uint timeout, out double duration) =>
|
|
|
|
|
Read6(out buffer, out senseBuffer, sili, false, transferLen, blockSize, timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads the specified number of bytes or of blocks from the medium
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// <param name="sili">
|
|
|
|
|
/// If set to <c>true</c> suppress the incorrect-length indication. Cannot be set while
|
|
|
|
|
/// <paramref name="fixedLen" /> is set also.
|
|
|
|
|
/// </param>
|
|
|
|
|
/// <param name="fixedLen">
|
|
|
|
|
/// If set to <c>true</c> <paramref name="transferLen" /> indicates how many blocks to read of a
|
|
|
|
|
/// fixed size.
|
|
|
|
|
/// </param>
|
|
|
|
|
/// <param name="transferLen">Transfer length in blocks or bytes depending of <paramref name="fixedLen" /> status.</param>
|
2016-01-13 03:47:25 +00:00
|
|
|
/// <param name="blockSize">Block size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool Read6(out byte[] buffer, out byte[] senseBuffer, bool sili, bool fixedLen,
|
|
|
|
|
uint transferLen,
|
|
|
|
|
uint blockSize, uint timeout, out double duration)
|
2016-01-13 03:47:25 +00:00
|
|
|
{
|
2017-12-22 03:13:43 +00:00
|
|
|
buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen];
|
2016-01-13 03:47:25 +00:00
|
|
|
byte[] cdb = new byte[6];
|
|
|
|
|
senseBuffer = new byte[32];
|
|
|
|
|
|
|
|
|
|
cdb[0] = (byte)ScsiCommands.Read6;
|
2017-12-19 20:33:03 +00:00
|
|
|
if(fixedLen) cdb[1] += 0x01;
|
2018-06-22 08:08:38 +01:00
|
|
|
if(sili) cdb[1] += 0x02;
|
2016-01-13 03:47:25 +00:00
|
|
|
cdb[2] = (byte)((transferLen & 0xFF0000) >> 16);
|
2018-06-22 08:08:38 +01:00
|
|
|
cdb[3] = (byte)((transferLen & 0xFF00) >> 8);
|
2016-01-13 03:47:25 +00:00
|
|
|
cdb[4] = (byte)(transferLen & 0xFF);
|
|
|
|
|
|
2017-12-21 07:19:46 +00:00
|
|
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
2017-12-22 03:13:43 +00:00
|
|
|
out bool sense);
|
2017-12-21 07:19:46 +00:00
|
|
|
Error = LastError != 0;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("SCSI Device", "READ (6) took {0} ms.", duration);
|
|
|
|
|
|
|
|
|
|
return sense;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads a number of fixed-length blocks starting at specified object
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="sili">If set to <c>true</c> suppress the incorrect-length indication.</param>
|
|
|
|
|
/// <param name="objectId">Object identifier.</param>
|
|
|
|
|
/// <param name="blocks">How many blocks to read.</param>
|
|
|
|
|
/// <param name="blockSize">Object size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool Read16(out byte[] buffer, out byte[] senseBuffer, bool sili, ulong objectId, uint blocks,
|
2018-12-31 13:17:27 +00:00
|
|
|
uint blockSize, uint timeout, out double duration) =>
|
|
|
|
|
Read16(out buffer, out senseBuffer, sili, false, 0, objectId, blocks, blockSize, timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads a number of fixed-length blocks starting at specified block from the specified partition
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="sili">If set to <c>true</c> suppress the incorrect-length indication.</param>
|
|
|
|
|
/// <param name="partition">Partition to read object from.</param>
|
|
|
|
|
/// <param name="objectId">Object identifier.</param>
|
|
|
|
|
/// <param name="blocks">How many blocks to read.</param>
|
|
|
|
|
/// <param name="blockSize">Object size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool Read16(out byte[] buffer, out byte[] senseBuffer, bool sili, byte partition,
|
|
|
|
|
ulong objectId,
|
2018-12-31 13:17:27 +00:00
|
|
|
uint blocks, uint blockSize, uint timeout, out double duration) =>
|
|
|
|
|
Read16(out buffer, out senseBuffer, sili, false, partition, objectId, blocks, blockSize, timeout,
|
|
|
|
|
out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads a number of fixed-length blocks starting at specified object
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="objectId">Object identifier.</param>
|
|
|
|
|
/// <param name="blocks">How many blocks to read.</param>
|
|
|
|
|
/// <param name="blockSize">Object size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool Read16(out byte[] buffer, out byte[] senseBuffer, ulong objectId, uint blocks, uint blockSize,
|
2018-12-31 13:17:27 +00:00
|
|
|
uint timeout, out double duration) =>
|
|
|
|
|
Read16(out buffer, out senseBuffer, false, true, 0, objectId, blocks, blockSize, timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads a number of fixed-length blocks starting at specified block from the specified partition
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="partition">Partition to read object from.</param>
|
|
|
|
|
/// <param name="objectId">Object identifier.</param>
|
|
|
|
|
/// <param name="blocks">How many blocks to read.</param>
|
|
|
|
|
/// <param name="blockSize">Object size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool Read16(out byte[] buffer, out byte[] senseBuffer, byte partition, ulong objectId,
|
|
|
|
|
uint blocks,
|
2018-12-31 13:17:27 +00:00
|
|
|
uint blockSize, uint timeout, out double duration) =>
|
|
|
|
|
Read16(out buffer, out senseBuffer, false, true, partition, objectId, blocks, blockSize, timeout,
|
|
|
|
|
out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads a number of bytes or objects starting at specified object from the specified partition
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// <param name="sili">
|
|
|
|
|
/// If set to <c>true</c> suppress the incorrect-length indication. Cannot be set while
|
|
|
|
|
/// <paramref name="fixedLen" /> is set also.
|
|
|
|
|
/// </param>
|
|
|
|
|
/// <param name="fixedLen">
|
|
|
|
|
/// If set to <c>true</c> <paramref name="transferLen" /> indicates how many blocks to read of a
|
|
|
|
|
/// fixed size.
|
|
|
|
|
/// </param>
|
2016-01-13 03:47:25 +00:00
|
|
|
/// <param name="partition">Partition to read object from.</param>
|
|
|
|
|
/// <param name="objectId">Object identifier.</param>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// <param name="transferLen">Transfer length in blocks or bytes depending of <paramref name="fixedLen" /> status.</param>
|
2016-01-13 03:47:25 +00:00
|
|
|
/// <param name="objectSize">Object size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool Read16(out byte[] buffer, out byte[] senseBuffer, bool sili, bool fixedLen,
|
|
|
|
|
byte partition,
|
|
|
|
|
ulong objectId, uint transferLen, uint objectSize, uint timeout,
|
|
|
|
|
out double duration)
|
2016-01-13 03:47:25 +00:00
|
|
|
{
|
2017-12-22 03:13:43 +00:00
|
|
|
buffer = fixedLen ? new byte[objectSize * transferLen] : new byte[transferLen];
|
2016-01-13 03:47:25 +00:00
|
|
|
byte[] cdb = new byte[6];
|
|
|
|
|
senseBuffer = new byte[32];
|
|
|
|
|
byte[] idBytes = BitConverter.GetBytes(objectId);
|
|
|
|
|
|
|
|
|
|
cdb[0] = (byte)ScsiCommands.Read16;
|
2017-12-19 20:33:03 +00:00
|
|
|
if(fixedLen) cdb[1] += 0x01;
|
2018-06-22 08:08:38 +01:00
|
|
|
if(sili) cdb[1] += 0x02;
|
|
|
|
|
cdb[3] = partition;
|
|
|
|
|
cdb[4] = idBytes[7];
|
|
|
|
|
cdb[5] = idBytes[6];
|
|
|
|
|
cdb[6] = idBytes[5];
|
|
|
|
|
cdb[7] = idBytes[4];
|
|
|
|
|
cdb[8] = idBytes[3];
|
|
|
|
|
cdb[9] = idBytes[2];
|
2016-01-13 03:47:25 +00:00
|
|
|
cdb[10] = idBytes[1];
|
|
|
|
|
cdb[11] = idBytes[0];
|
|
|
|
|
cdb[12] = (byte)((transferLen & 0xFF0000) >> 16);
|
2018-06-22 08:08:38 +01:00
|
|
|
cdb[13] = (byte)((transferLen & 0xFF00) >> 8);
|
2016-01-13 03:47:25 +00:00
|
|
|
cdb[14] = (byte)(transferLen & 0xFF);
|
|
|
|
|
|
2017-12-21 07:19:46 +00:00
|
|
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
2017-12-22 03:13:43 +00:00
|
|
|
out bool sense);
|
2017-12-21 07:19:46 +00:00
|
|
|
Error = LastError != 0;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("SCSI Device", "READ (16) took {0} ms.", duration);
|
|
|
|
|
|
|
|
|
|
return sense;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Requests the drive the maximum and minimum block size
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
|
|
|
|
public bool ReadBlockLimits(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
|
|
|
|
|
{
|
|
|
|
|
buffer = new byte[6];
|
|
|
|
|
byte[] cdb = new byte[6];
|
|
|
|
|
senseBuffer = new byte[32];
|
|
|
|
|
|
|
|
|
|
cdb[0] = (byte)ScsiCommands.ReadBlockLimits;
|
|
|
|
|
|
2017-12-21 07:19:46 +00:00
|
|
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
2017-12-22 03:13:43 +00:00
|
|
|
out bool sense);
|
2017-12-21 07:19:46 +00:00
|
|
|
Error = LastError != 0;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("SCSI Device", "READ BLOCK LIMITS took {0} ms.", duration);
|
|
|
|
|
|
|
|
|
|
return sense;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reports current reading/writing elements position on the medium
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-12-31 13:17:27 +00:00
|
|
|
public bool ReadPosition(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) =>
|
|
|
|
|
ReadPosition(out buffer, out senseBuffer, SscPositionForms.Short, timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reports current reading/writing elements position on the medium using 32 bytes response
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-12-31 13:17:27 +00:00
|
|
|
public bool ReadPositionLong(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) =>
|
|
|
|
|
ReadPosition(out buffer, out senseBuffer, SscPositionForms.Long, timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reports current reading/writing elements position on the medium
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="vendorType">Requests the position to be given in vendor-specified meaning.</param>
|
|
|
|
|
/// <param name="longForm">Requests the response to be 32 bytes format.</param>
|
|
|
|
|
/// <param name="totalPosition">Requests current logical position.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool ReadPosition(out byte[] buffer, out byte[] senseBuffer, bool vendorType, bool longForm,
|
|
|
|
|
bool totalPosition, uint timeout, out double duration)
|
2016-01-13 03:47:25 +00:00
|
|
|
{
|
2018-06-22 08:08:38 +01:00
|
|
|
byte responseForm = 0;
|
|
|
|
|
if(vendorType) responseForm += 0x01;
|
|
|
|
|
if(longForm) responseForm += 0x02;
|
2017-12-19 20:33:03 +00:00
|
|
|
if(totalPosition) responseForm += 0x04;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
return ReadPosition(out buffer, out senseBuffer, (SscPositionForms)responseForm, timeout, out duration);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reports current reading/writing elements position on the medium
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="responseForm">Response form.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2017-12-19 20:33:03 +00:00
|
|
|
public bool ReadPosition(out byte[] buffer, out byte[] senseBuffer, SscPositionForms responseForm, uint timeout,
|
|
|
|
|
out double duration)
|
2016-01-13 03:47:25 +00:00
|
|
|
{
|
2016-04-19 02:11:47 +01:00
|
|
|
switch(responseForm)
|
2016-01-13 03:47:25 +00:00
|
|
|
{
|
|
|
|
|
case SscPositionForms.Long:
|
|
|
|
|
case SscPositionForms.OldLong:
|
|
|
|
|
case SscPositionForms.OldLongTclpVendor:
|
|
|
|
|
case SscPositionForms.OldLongVendor:
|
|
|
|
|
case SscPositionForms.Extended:
|
|
|
|
|
buffer = new byte[32];
|
|
|
|
|
break;
|
|
|
|
|
case SscPositionForms.OldTclp:
|
|
|
|
|
case SscPositionForms.OldTclpVendor:
|
|
|
|
|
case SscPositionForms.Short:
|
|
|
|
|
case SscPositionForms.VendorShort:
|
|
|
|
|
buffer = new byte[20];
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
buffer = new byte[32]; // Invalid
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2016-01-13 03:47:25 +00:00
|
|
|
byte[] cdb = new byte[10];
|
|
|
|
|
senseBuffer = new byte[32];
|
|
|
|
|
|
|
|
|
|
cdb[0] = (byte)ScsiCommands.ReadPosition;
|
|
|
|
|
cdb[1] = (byte)((byte)responseForm & 0x1F);
|
|
|
|
|
if(responseForm == SscPositionForms.Extended)
|
|
|
|
|
{
|
|
|
|
|
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
|
|
|
|
|
cdb[8] = (byte)(buffer.Length & 0xFF);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-21 07:19:46 +00:00
|
|
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
2017-12-22 03:13:43 +00:00
|
|
|
out bool sense);
|
2017-12-21 07:19:46 +00:00
|
|
|
Error = LastError != 0;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("SCSI Device", "READ POSITION took {0} ms.", duration);
|
|
|
|
|
|
|
|
|
|
return sense;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads the specified number of blocks from the medium, backwards
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="blocks">How many blocks to read.</param>
|
|
|
|
|
/// <param name="blockSize">Block size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2017-12-19 20:33:03 +00:00
|
|
|
public bool ReadReverse6(out byte[] buffer, out byte[] senseBuffer, uint blocks, uint blockSize, uint timeout,
|
2018-12-31 13:17:27 +00:00
|
|
|
out double duration) =>
|
|
|
|
|
ReadReverse6(out buffer, out senseBuffer, false, false, true, blocks, blockSize, timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads the specified number of bytes or of blocks from the medium, backwards
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="sili">If set to <c>true</c> suppress the incorrect-length indication.</param>
|
|
|
|
|
/// <param name="transferLen">How many bytes to read.</param>
|
|
|
|
|
/// <param name="blockSize">Block size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool ReadReverse6(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen,
|
|
|
|
|
uint blockSize,
|
2018-12-31 13:17:27 +00:00
|
|
|
uint timeout, out double duration) =>
|
|
|
|
|
ReadReverse6(out buffer, out senseBuffer, false, sili, false, transferLen, blockSize, timeout,
|
|
|
|
|
out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads the specified number of bytes or of blocks from the medium, backwards
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="byteOrder">If set to <c>true</c> drive should un-reverse the blocks and bytes</param>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// <param name="sili">
|
|
|
|
|
/// If set to <c>true</c> suppress the incorrect-length indication. Cannot be set while
|
|
|
|
|
/// <paramref name="fixedLen" /> is set also.
|
|
|
|
|
/// </param>
|
|
|
|
|
/// <param name="fixedLen">
|
|
|
|
|
/// If set to <c>true</c> <paramref name="transferLen" /> indicates how many blocks to read of a
|
|
|
|
|
/// fixed size.
|
|
|
|
|
/// </param>
|
|
|
|
|
/// <param name="transferLen">Transfer length in blocks or bytes depending of <paramref name="fixedLen" /> status.</param>
|
2016-01-13 03:47:25 +00:00
|
|
|
/// <param name="blockSize">Block size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool ReadReverse6(out byte[] buffer, out byte[] senseBuffer, bool byteOrder, bool sili,
|
|
|
|
|
bool fixedLen,
|
|
|
|
|
uint transferLen, uint blockSize, uint timeout, out double duration)
|
2016-01-13 03:47:25 +00:00
|
|
|
{
|
2017-12-22 03:13:43 +00:00
|
|
|
buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen];
|
2016-01-13 03:47:25 +00:00
|
|
|
byte[] cdb = new byte[6];
|
|
|
|
|
senseBuffer = new byte[32];
|
|
|
|
|
|
|
|
|
|
cdb[0] = (byte)ScsiCommands.ReadReverse;
|
2018-06-22 08:08:38 +01:00
|
|
|
if(fixedLen) cdb[1] += 0x01;
|
|
|
|
|
if(sili) cdb[1] += 0x02;
|
2017-12-19 20:33:03 +00:00
|
|
|
if(byteOrder) cdb[1] += 0x04;
|
2016-01-13 03:47:25 +00:00
|
|
|
cdb[2] = (byte)((transferLen & 0xFF0000) >> 16);
|
2018-06-22 08:08:38 +01:00
|
|
|
cdb[3] = (byte)((transferLen & 0xFF00) >> 8);
|
2016-01-13 03:47:25 +00:00
|
|
|
cdb[4] = (byte)(transferLen & 0xFF);
|
|
|
|
|
|
2017-12-21 07:19:46 +00:00
|
|
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
2017-12-22 03:13:43 +00:00
|
|
|
out bool sense);
|
2017-12-21 07:19:46 +00:00
|
|
|
Error = LastError != 0;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("SCSI Device", "READ REVERSE (6) took {0} ms.", duration);
|
|
|
|
|
|
|
|
|
|
return sense;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads a number of fixed-length blocks starting at specified object, backwards
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="sili">If set to <c>true</c> suppress the incorrect-length indication.</param>
|
|
|
|
|
/// <param name="objectId">Object identifier.</param>
|
|
|
|
|
/// <param name="blocks">How many blocks to read.</param>
|
|
|
|
|
/// <param name="blockSize">Object size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, bool sili, ulong objectId,
|
|
|
|
|
uint blocks,
|
2018-12-31 13:17:27 +00:00
|
|
|
uint blockSize, uint timeout, out double duration) =>
|
|
|
|
|
ReadReverse16(out buffer, out senseBuffer, false, sili, false, 0, objectId, blocks, blockSize, timeout,
|
|
|
|
|
out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads a number of fixed-length blocks starting at specified block from the specified partition, backwards
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="sili">If set to <c>true</c> suppress the incorrect-length indication.</param>
|
|
|
|
|
/// <param name="partition">Partition to read object from.</param>
|
|
|
|
|
/// <param name="objectId">Object identifier.</param>
|
|
|
|
|
/// <param name="blocks">How many blocks to read.</param>
|
|
|
|
|
/// <param name="blockSize">Object size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, bool sili, byte partition,
|
|
|
|
|
ulong objectId,
|
2018-12-31 13:17:27 +00:00
|
|
|
uint blocks, uint blockSize, uint timeout, out double duration) =>
|
|
|
|
|
ReadReverse16(out buffer, out senseBuffer, false, sili, false, partition, objectId, blocks, blockSize,
|
|
|
|
|
timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads a number of fixed-length blocks starting at specified object, backwards
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="objectId">Object identifier.</param>
|
|
|
|
|
/// <param name="blocks">How many blocks to read.</param>
|
|
|
|
|
/// <param name="blockSize">Object size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, ulong objectId, uint blocks,
|
2018-12-31 13:17:27 +00:00
|
|
|
uint blockSize, uint timeout, out double duration) =>
|
|
|
|
|
ReadReverse16(out buffer, out senseBuffer, false, false, true, 0, objectId, blocks, blockSize, timeout,
|
|
|
|
|
out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads a number of fixed-length blocks starting at specified block from the specified partition, backwards
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="partition">Partition to read object from.</param>
|
|
|
|
|
/// <param name="objectId">Object identifier.</param>
|
|
|
|
|
/// <param name="blocks">How many blocks to read.</param>
|
|
|
|
|
/// <param name="blockSize">Object size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, byte partition, ulong objectId,
|
2018-12-31 13:17:27 +00:00
|
|
|
uint blocks, uint blockSize, uint timeout, out double duration) =>
|
|
|
|
|
ReadReverse16(out buffer, out senseBuffer, false, false, true, partition, objectId, blocks, blockSize,
|
|
|
|
|
timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads a number of bytes or objects starting at specified object from the specified partition, backwards
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="byteOrder">If set to <c>true</c> drive should un-reverse the blocks and bytes</param>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// <param name="sili">
|
|
|
|
|
/// If set to <c>true</c> suppress the incorrect-length indication. Cannot be set while
|
|
|
|
|
/// <paramref name="fixedLen" /> is set also.
|
|
|
|
|
/// </param>
|
|
|
|
|
/// <param name="fixedLen">
|
|
|
|
|
/// If set to <c>true</c> <paramref name="transferLen" /> indicates how many blocks to read of a
|
|
|
|
|
/// fixed size.
|
|
|
|
|
/// </param>
|
2016-01-13 03:47:25 +00:00
|
|
|
/// <param name="partition">Partition to read object from.</param>
|
|
|
|
|
/// <param name="objectId">Object identifier.</param>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// <param name="transferLen">Transfer length in blocks or bytes depending of <paramref name="fixedLen" /> status.</param>
|
2016-01-13 03:47:25 +00:00
|
|
|
/// <param name="objectSize">Object size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, bool byteOrder, bool sili,
|
|
|
|
|
bool fixedLen,
|
|
|
|
|
byte partition, ulong objectId, uint transferLen, uint objectSize,
|
|
|
|
|
uint timeout,
|
2017-12-19 20:33:03 +00:00
|
|
|
out double duration)
|
2016-01-13 03:47:25 +00:00
|
|
|
{
|
2017-12-22 03:13:43 +00:00
|
|
|
buffer = fixedLen ? new byte[objectSize * transferLen] : new byte[transferLen];
|
2016-01-13 03:47:25 +00:00
|
|
|
byte[] cdb = new byte[6];
|
|
|
|
|
senseBuffer = new byte[32];
|
|
|
|
|
byte[] idBytes = BitConverter.GetBytes(objectId);
|
|
|
|
|
|
|
|
|
|
cdb[0] = (byte)ScsiCommands.Read16;
|
2018-06-22 08:08:38 +01:00
|
|
|
if(fixedLen) cdb[1] += 0x01;
|
|
|
|
|
if(sili) cdb[1] += 0x02;
|
2017-12-19 20:33:03 +00:00
|
|
|
if(byteOrder) cdb[1] += 0x04;
|
2018-06-22 08:08:38 +01:00
|
|
|
cdb[3] = partition;
|
|
|
|
|
cdb[4] = idBytes[7];
|
|
|
|
|
cdb[5] = idBytes[6];
|
|
|
|
|
cdb[6] = idBytes[5];
|
|
|
|
|
cdb[7] = idBytes[4];
|
|
|
|
|
cdb[8] = idBytes[3];
|
|
|
|
|
cdb[9] = idBytes[2];
|
2016-01-13 03:47:25 +00:00
|
|
|
cdb[10] = idBytes[1];
|
|
|
|
|
cdb[11] = idBytes[0];
|
|
|
|
|
cdb[12] = (byte)((transferLen & 0xFF0000) >> 16);
|
2018-06-22 08:08:38 +01:00
|
|
|
cdb[13] = (byte)((transferLen & 0xFF00) >> 8);
|
2016-01-13 03:47:25 +00:00
|
|
|
cdb[14] = (byte)(transferLen & 0xFF);
|
|
|
|
|
|
2017-12-21 07:19:46 +00:00
|
|
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
2017-12-22 03:13:43 +00:00
|
|
|
out bool sense);
|
2017-12-21 07:19:46 +00:00
|
|
|
Error = LastError != 0;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("SCSI Device", "READ REVERSE (16) took {0} ms.", duration);
|
|
|
|
|
|
|
|
|
|
return sense;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads the specified number of blocks from the device's buffer
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="blocks">How many blocks to read.</param>
|
|
|
|
|
/// <param name="blockSize">Block size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, uint blocks, uint blockSize,
|
2018-12-31 13:17:27 +00:00
|
|
|
uint timeout, out double duration) =>
|
|
|
|
|
RecoverBufferedData(out buffer, out senseBuffer, false, true, blocks, blockSize, timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads the specified number of bytes or of blocks from the device's buffer
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="sili">If set to <c>true</c> suppress the incorrect-length indication.</param>
|
|
|
|
|
/// <param name="transferLen">How many bytes to read.</param>
|
|
|
|
|
/// <param name="blockSize">Block size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen,
|
2018-12-31 13:17:27 +00:00
|
|
|
uint blockSize, uint timeout, out double duration) =>
|
|
|
|
|
RecoverBufferedData(out buffer, out senseBuffer, sili, false, transferLen, blockSize, timeout,
|
|
|
|
|
out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reads the specified number of bytes or of blocks from the device's buffer
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// <param name="sili">
|
|
|
|
|
/// If set to <c>true</c> suppress the incorrect-length indication. Cannot be set while
|
|
|
|
|
/// <paramref name="fixedLen" /> is set also.
|
|
|
|
|
/// </param>
|
|
|
|
|
/// <param name="fixedLen">
|
|
|
|
|
/// If set to <c>true</c> <paramref name="transferLen" /> indicates how many blocks to read of a
|
|
|
|
|
/// fixed size.
|
|
|
|
|
/// </param>
|
|
|
|
|
/// <param name="transferLen">Transfer length in blocks or bytes depending of <paramref name="fixedLen" /> status.</param>
|
2016-01-13 03:47:25 +00:00
|
|
|
/// <param name="blockSize">Block size in bytes.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, bool sili,
|
|
|
|
|
bool fixedLen,
|
|
|
|
|
uint transferLen, uint blockSize, uint timeout,
|
|
|
|
|
out double duration)
|
2016-01-13 03:47:25 +00:00
|
|
|
{
|
2017-12-22 03:13:43 +00:00
|
|
|
buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen];
|
2016-01-13 03:47:25 +00:00
|
|
|
byte[] cdb = new byte[6];
|
|
|
|
|
senseBuffer = new byte[32];
|
|
|
|
|
|
|
|
|
|
cdb[0] = (byte)ScsiCommands.RecoverBufferedData;
|
2017-12-19 20:33:03 +00:00
|
|
|
if(fixedLen) cdb[1] += 0x01;
|
2018-06-22 08:08:38 +01:00
|
|
|
if(sili) cdb[1] += 0x02;
|
2016-01-13 03:47:25 +00:00
|
|
|
cdb[2] = (byte)((transferLen & 0xFF0000) >> 16);
|
2018-06-22 08:08:38 +01:00
|
|
|
cdb[3] = (byte)((transferLen & 0xFF00) >> 8);
|
2016-01-13 03:47:25 +00:00
|
|
|
cdb[4] = (byte)(transferLen & 0xFF);
|
|
|
|
|
|
2017-12-21 07:19:46 +00:00
|
|
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
2017-12-22 03:13:43 +00:00
|
|
|
out bool sense);
|
2017-12-21 07:19:46 +00:00
|
|
|
Error = LastError != 0;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("SCSI Device", "RECOVER BUFFERED DATA took {0} ms.", duration);
|
|
|
|
|
|
|
|
|
|
return sense;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Requests the device to return descriptors for supported densities or medium types
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-12-31 13:17:27 +00:00
|
|
|
public bool
|
|
|
|
|
ReportDensitySupport(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) =>
|
|
|
|
|
ReportDensitySupport(out buffer, out senseBuffer, false, false, timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Requests the device to return descriptors for supported densities or medium types
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="currentMedia">If set to <c>true</c> descriptors should apply to currently inserted media.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2017-12-19 20:33:03 +00:00
|
|
|
public bool ReportDensitySupport(out byte[] buffer, out byte[] senseBuffer, bool currentMedia, uint timeout,
|
2018-12-31 13:17:27 +00:00
|
|
|
out double duration) =>
|
|
|
|
|
ReportDensitySupport(out buffer, out senseBuffer, false, currentMedia, timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Requests the device to return descriptors for supported densities or medium types
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="buffer">Buffer.</param>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="mediumType">If set to <c>true</c> descriptors should be about medium types.</param>
|
|
|
|
|
/// <param name="currentMedia">If set to <c>true</c> descriptors should apply to currently inserted media.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool ReportDensitySupport(out byte[] buffer, out byte[] senseBuffer, bool mediumType, bool currentMedia,
|
|
|
|
|
uint timeout, out double duration)
|
2016-01-13 03:47:25 +00:00
|
|
|
{
|
|
|
|
|
buffer = new byte[256];
|
|
|
|
|
byte[] cdb = new byte[10];
|
|
|
|
|
senseBuffer = new byte[32];
|
|
|
|
|
|
|
|
|
|
cdb[0] = (byte)ScsiCommands.ReportDensitySupport;
|
2017-12-19 20:33:03 +00:00
|
|
|
if(currentMedia) cdb[1] += 0x01;
|
2018-06-22 08:08:38 +01:00
|
|
|
if(mediumType) cdb[1] += 0x02;
|
2016-01-13 03:47:25 +00:00
|
|
|
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
|
|
|
|
|
cdb[8] = (byte)(buffer.Length & 0xFF);
|
|
|
|
|
|
2017-12-21 07:19:46 +00:00
|
|
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
2017-12-22 03:13:43 +00:00
|
|
|
out bool sense);
|
2017-12-21 07:19:46 +00:00
|
|
|
Error = LastError != 0;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
if(sense) return true;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
2017-12-21 14:30:38 +00:00
|
|
|
ushort availableLength = (ushort)((buffer[0] << 8) + buffer[1] + 2);
|
2018-06-22 08:08:38 +01:00
|
|
|
buffer = new byte[availableLength];
|
|
|
|
|
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
|
|
|
|
|
cdb[8] = (byte)(buffer.Length & 0xFF);
|
2016-01-13 03:47:25 +00:00
|
|
|
senseBuffer = new byte[32];
|
|
|
|
|
|
2017-12-21 07:19:46 +00:00
|
|
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
2017-12-19 20:33:03 +00:00
|
|
|
out sense);
|
2017-12-21 07:19:46 +00:00
|
|
|
Error = LastError != 0;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("SCSI Device", "REPORT DENSITY SUPPORT took {0} ms.", duration);
|
|
|
|
|
|
|
|
|
|
return sense;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Positions the reading/writing element to the beginning of current partition
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
2018-12-31 13:17:27 +00:00
|
|
|
public bool Rewind(out byte[] senseBuffer, uint timeout, out double duration) =>
|
|
|
|
|
Rewind(out senseBuffer, false, timeout, out duration);
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Positions the reading/writing element to the beginning of current partition
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="immediate">If set to <c>true</c> return from the command immediately.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
|
|
|
|
public bool Rewind(out byte[] senseBuffer, bool immediate, uint timeout, out double duration)
|
|
|
|
|
{
|
|
|
|
|
senseBuffer = new byte[32];
|
2018-06-22 08:08:38 +01:00
|
|
|
byte[] cdb = new byte[6];
|
2016-01-13 03:47:25 +00:00
|
|
|
byte[] buffer = new byte[0];
|
|
|
|
|
|
|
|
|
|
cdb[0] = (byte)ScsiCommands.Rewind;
|
2017-12-19 20:33:03 +00:00
|
|
|
if(immediate) cdb[1] += 0x01;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
2017-12-21 07:19:46 +00:00
|
|
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
2017-12-22 03:13:43 +00:00
|
|
|
out bool sense);
|
2017-12-21 07:19:46 +00:00
|
|
|
Error = LastError != 0;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("SCSI Device", "REWIND took {0} ms.", duration);
|
|
|
|
|
|
|
|
|
|
return sense;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Selects the specified track
|
2016-01-13 03:47:25 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <returns><c>true</c>, if select was tracked, <c>false</c> otherwise.</returns>
|
|
|
|
|
/// <param name="senseBuffer">Sense buffer.</param>
|
|
|
|
|
/// <param name="track">Track.</param>
|
|
|
|
|
/// <param name="timeout">Timeout.</param>
|
|
|
|
|
/// <param name="duration">Duration.</param>
|
|
|
|
|
public bool TrackSelect(out byte[] senseBuffer, byte track, uint timeout, out double duration)
|
|
|
|
|
{
|
|
|
|
|
senseBuffer = new byte[32];
|
2018-06-22 08:08:38 +01:00
|
|
|
byte[] cdb = new byte[6];
|
2016-01-13 03:47:25 +00:00
|
|
|
byte[] buffer = new byte[0];
|
|
|
|
|
|
|
|
|
|
cdb[0] = (byte)ScsiCommands.TrackSelect;
|
|
|
|
|
cdb[5] = track;
|
|
|
|
|
|
2017-12-21 07:19:46 +00:00
|
|
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
2017-12-22 03:13:43 +00:00
|
|
|
out bool sense);
|
2017-12-21 07:19:46 +00:00
|
|
|
Error = LastError != 0;
|
2016-01-13 03:47:25 +00:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("SCSI Device", "TRACK SELECT took {0} ms.", duration);
|
|
|
|
|
|
|
|
|
|
return sense;
|
|
|
|
|
}
|
2016-10-12 06:16:41 +01:00
|
|
|
|
|
|
|
|
public bool Space(out byte[] senseBuffer, SscSpaceCodes code, int count, uint timeout, out double duration)
|
|
|
|
|
{
|
|
|
|
|
senseBuffer = new byte[32];
|
2018-06-22 08:08:38 +01:00
|
|
|
byte[] cdb = new byte[6];
|
2016-10-12 06:16:41 +01:00
|
|
|
byte[] buffer = new byte[0];
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] countB = BitConverter.GetBytes(count);
|
2016-10-12 06:16:41 +01:00
|
|
|
|
|
|
|
|
cdb[0] = (byte)ScsiCommands.Space;
|
|
|
|
|
cdb[1] = (byte)((byte)code & 0x0F);
|
2017-12-20 17:15:26 +00:00
|
|
|
cdb[2] = countB[2];
|
|
|
|
|
cdb[3] = countB[1];
|
|
|
|
|
cdb[4] = countB[0];
|
2016-10-12 06:16:41 +01:00
|
|
|
|
2017-12-21 07:19:46 +00:00
|
|
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
2017-12-22 03:13:43 +00:00
|
|
|
out bool sense);
|
2017-12-21 07:19:46 +00:00
|
|
|
Error = LastError != 0;
|
2016-10-12 06:16:41 +01:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("SCSI Device", "SPACE took {0} ms.", duration);
|
|
|
|
|
|
|
|
|
|
return sense;
|
|
|
|
|
}
|
2016-01-13 03:47:25 +00:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|