// /*************************************************************************** // The Disc Image Chef // ---------------------------------------------------------------------------- // // Filename : ArchiveCorp.cs // Version : 1.0 // Author(s) : Natalia Portillo // // Component : Archive Corp. vendor commands // // Revision : $Revision$ // Last change by : $Author$ // Date : $Date$ // // --[ Description ] ---------------------------------------------------------- // // Description // // --[ License ] -------------------------------------------------------------- // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // ---------------------------------------------------------------------------- // Copyright (C) 2011-2015 Claunia.com // ****************************************************************************/ // //$Id$ using System; using DiscImageChef.Console; namespace DiscImageChef.Devices { public partial class Device { /// /// Gets the underlying drive cylinder, head and index bytes for the specified SCSI LBA. /// /// Buffer. /// Sense buffer. /// Timeout. /// Duration. public bool ArchiveCorpRequestBlockAddress(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) { buffer = new byte[3]; byte[] cdb = new byte[6]; senseBuffer = new byte[32]; bool sense; cdb[0] = (byte)ScsiCommands.Archive_RequestBlockAddress; cdb[4] = 3; lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); error = lastError != 0; DicConsole.DebugWriteLine("SCSI Device", "ARCHIVE CORP. REQUEST BLOCK ADDRESS took {0} ms.", duration); return sense; } /// /// Gets the underlying drive cylinder, head and index bytes for the specified SCSI LBA. /// /// Sense buffer. /// Logical Block Address, starting from 1. /// Timeout. /// Duration. public bool ArchiveCorpSeekBlock(out byte[] senseBuffer, uint lba, uint timeout, out double duration) { return ArchiveCorpSeekBlock(out senseBuffer, false, lba, timeout, out duration); } /// /// Positions the tape at the specified block address /// /// Sense buffer. /// If set to true, return from the command immediately. /// Logical Block Address, starting from 1. /// Timeout. /// Duration. public bool ArchiveCorpSeekBlock(out byte[] senseBuffer, bool immediate, uint lba, uint timeout, out double duration) { byte[] buffer = new byte[0]; byte[] cdb = new byte[6]; senseBuffer = new byte[32]; bool sense; cdb[0] = (byte)ScsiCommands.Archive_SeekBlock; cdb[1] = (byte)((lba & 0x1F0000) >> 16); cdb[2] = (byte)((lba & 0xFF00) >> 8); cdb[3] = (byte)(lba & 0xFF); if(immediate) cdb[1] += 0x01; lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense); error = lastError != 0; DicConsole.DebugWriteLine("SCSI Device", "ARCHIVE CORP. SEEK BLOCK took {0} ms.", duration); return sense; } } }