From d901e3b8e0a0e9e64f603abbd786621a3c0d7215 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Wed, 14 Oct 2015 03:17:39 +0100 Subject: [PATCH] * DiscImageChef.Devices/Device/AtaCommands.cs: Added ATA IDENTIFY DEVICE command. * DiscImageChef.Devices/Device/AtapiCommands.cs: Added ATAPI IDENTIFY PACKET DEVICE command. * DiscImageChef.Devices/Structs.cs: * DiscImageChef.Devices/Device/ScsiCommands.cs: Added header description. * DiscImageChef.Devices/DiscImageChef.Devices.csproj: Added ATA IDENTIFY DEVICE command. Added ATAPI IDENTIFY PACKET DEVICE command. --- DiscImageChef.Devices/ChangeLog | 16 ++++ DiscImageChef.Devices/Device/AtaCommands.cs | 76 +++++++++++++++++++ DiscImageChef.Devices/Device/AtapiCommands.cs | 76 +++++++++++++++++++ DiscImageChef.Devices/Device/ScsiCommands.cs | 4 +- .../DiscImageChef.Devices.csproj | 2 + DiscImageChef.Devices/Structs.cs | 4 +- 6 files changed, 174 insertions(+), 4 deletions(-) create mode 100644 DiscImageChef.Devices/Device/AtaCommands.cs create mode 100644 DiscImageChef.Devices/Device/AtapiCommands.cs diff --git a/DiscImageChef.Devices/ChangeLog b/DiscImageChef.Devices/ChangeLog index 4120bc90..24ac21c7 100644 --- a/DiscImageChef.Devices/ChangeLog +++ b/DiscImageChef.Devices/ChangeLog @@ -1,3 +1,19 @@ +2015-10-14 Natalia Portillo + + * Device/AtaCommands.cs: + Added ATA IDENTIFY DEVICE command. + + * Device/AtapiCommands.cs: + Added ATAPI IDENTIFY PACKET DEVICE command. + + * Structs.cs: + * Device/ScsiCommands.cs: + Added header description. + + * DiscImageChef.Devices.csproj: + Added ATA IDENTIFY DEVICE command. + Added ATAPI IDENTIFY PACKET DEVICE command. + 2015-10-14 Natalia Portillo * Structs.cs: diff --git a/DiscImageChef.Devices/Device/AtaCommands.cs b/DiscImageChef.Devices/Device/AtaCommands.cs new file mode 100644 index 00000000..39b29a24 --- /dev/null +++ b/DiscImageChef.Devices/Device/AtaCommands.cs @@ -0,0 +1,76 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : AtaCommands.cs +// Version : 1.0 +// Author(s) : Natalia Portillo +// +// Component : Direct device access +// +// Revision : $Revision$ +// Last change by : $Author$ +// Date : $Date$ +// +// --[ Description ] ---------------------------------------------------------- +// +// Contains ATA commands +// +// --[ 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; + +namespace DiscImageChef.Devices +{ + public partial class Device + { + public bool AtaIdentify(out byte[] buffer, out Structs.AtaErrorRegistersCHS statusRegisters) + { + return AtaIdentify(out buffer, out statusRegisters, Timeout); + } + + public bool AtaIdentify(out byte[] buffer, out Structs.AtaErrorRegistersCHS statusRegisters, out double duration) + { + return AtaIdentify(out buffer, out statusRegisters, Timeout, out duration); + } + + public bool AtaIdentify(out byte[] buffer, out Structs.AtaErrorRegistersCHS statusRegisters, uint timeout) + { + double duration; + return AtaIdentify(out buffer, out statusRegisters, timeout, out duration); + } + + public bool AtaIdentify(out byte[] buffer, out Structs.AtaErrorRegistersCHS statusRegisters, uint timeout, out double duration) + { + buffer = new byte[512]; + Structs.AtaRegistersCHS registers = new Structs.AtaRegistersCHS(); + bool sense; + + registers.command = (byte)Enums.AtaCommands.IdentifyDevice; + + lastError = SendAtaCommand(registers, out statusRegisters, Enums.AtaProtocol.PioOut, Enums.AtaTransferRegister.NoTransfer, + ref buffer, timeout, false, out duration, out sense); + error = lastError != 0; + + return sense; + } + } +} + diff --git a/DiscImageChef.Devices/Device/AtapiCommands.cs b/DiscImageChef.Devices/Device/AtapiCommands.cs new file mode 100644 index 00000000..1346525a --- /dev/null +++ b/DiscImageChef.Devices/Device/AtapiCommands.cs @@ -0,0 +1,76 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : AtapiCommands.cs +// Version : 1.0 +// Author(s) : Natalia Portillo +// +// Component : Direct device access +// +// Revision : $Revision$ +// Last change by : $Author$ +// Date : $Date$ +// +// --[ Description ] ---------------------------------------------------------- +// +// Contains ATAPI commands +// +// --[ 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; + +namespace DiscImageChef.Devices +{ + public partial class Device + { + public bool AtapiIdentify(out byte[] buffer, out Structs.AtaErrorRegistersCHS statusRegisters) + { + return AtapiIdentify(out buffer, out statusRegisters, Timeout); + } + + public bool AtapiIdentify(out byte[] buffer, out Structs.AtaErrorRegistersCHS statusRegisters, out double duration) + { + return AtapiIdentify(out buffer, out statusRegisters, Timeout, out duration); + } + + public bool AtapiIdentify(out byte[] buffer, out Structs.AtaErrorRegistersCHS statusRegisters, uint timeout) + { + double duration; + return AtapiIdentify(out buffer, out statusRegisters, timeout, out duration); + } + + public bool AtapiIdentify(out byte[] buffer, out Structs.AtaErrorRegistersCHS statusRegisters, uint timeout, out double duration) + { + buffer = new byte[512]; + Structs.AtaRegistersCHS registers = new Structs.AtaRegistersCHS(); + bool sense; + + registers.command = (byte)Enums.AtaCommands.IdentifyPacketDevice; + + lastError = SendAtaCommand(registers, out statusRegisters, Enums.AtaProtocol.PioOut, Enums.AtaTransferRegister.NoTransfer, + ref buffer, timeout, false, out duration, out sense); + error = lastError != 0; + + return sense; + } + } +} + diff --git a/DiscImageChef.Devices/Device/ScsiCommands.cs b/DiscImageChef.Devices/Device/ScsiCommands.cs index f6270615..bb24e9d6 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands.cs @@ -6,7 +6,7 @@ // Version : 1.0 // Author(s) : Natalia Portillo // -// Component : Component +// Component : Direct device access // // Revision : $Revision$ // Last change by : $Author$ @@ -14,7 +14,7 @@ // // --[ Description ] ---------------------------------------------------------- // -// Description +// Contains SCSI commands // // --[ License ] -------------------------------------------------------------- // diff --git a/DiscImageChef.Devices/DiscImageChef.Devices.csproj b/DiscImageChef.Devices/DiscImageChef.Devices.csproj index dedb491d..0553d755 100644 --- a/DiscImageChef.Devices/DiscImageChef.Devices.csproj +++ b/DiscImageChef.Devices/DiscImageChef.Devices.csproj @@ -51,6 +51,8 @@ + + diff --git a/DiscImageChef.Devices/Structs.cs b/DiscImageChef.Devices/Structs.cs index a0e8dd67..5a3dcb6f 100644 --- a/DiscImageChef.Devices/Structs.cs +++ b/DiscImageChef.Devices/Structs.cs @@ -6,7 +6,7 @@ // Version : 1.0 // Author(s) : Natalia Portillo // -// Component : Component +// Component : Direct device access // // Revision : $Revision$ // Last change by : $Author$ @@ -14,7 +14,7 @@ // // --[ Description ] ---------------------------------------------------------- // -// Description +// Contains enumerations that are common to all operating systems // // --[ License ] -------------------------------------------------------------- //