2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
// Aaru Data Preservation Suite
|
2016-07-28 18:13:49 +01:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : MCPT.cs
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
//
|
|
|
|
|
// Component : ATA commands.
|
|
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Contains Media Card Pass-Thru commands.
|
|
|
|
|
//
|
|
|
|
|
// --[ 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/>.
|
|
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2024-12-19 10:45:18 +00:00
|
|
|
// Copyright © 2011-2025 Natalia Portillo
|
2016-07-28 18:13:49 +01:00
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
2023-10-05 01:05:23 +01:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2020-02-27 00:33:26 +00:00
|
|
|
using Aaru.Decoders.ATA;
|
2025-08-17 05:50:25 +01:00
|
|
|
using Aaru.Logging;
|
2016-02-08 00:13:49 +00:00
|
|
|
|
2023-10-05 01:05:23 +01:00
|
|
|
// ReSharper disable UnusedMember.Global
|
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
namespace Aaru.Devices;
|
|
|
|
|
|
2023-10-05 01:05:23 +01:00
|
|
|
[SuppressMessage("ReSharper", "UnusedMethodReturnValue.Global")]
|
|
|
|
|
[SuppressMessage("ReSharper", "OutParameterValueIsAlwaysDiscarded.Global")]
|
|
|
|
|
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
2022-03-26 18:31:04 +00:00
|
|
|
public partial class Device
|
2016-02-08 00:13:49 +00:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
/// <summary>Enables media card pass through</summary>
|
|
|
|
|
/// <param name="statusRegisters">Status registers.</param>
|
|
|
|
|
/// <param name="timeout">Timeout in seconds</param>
|
|
|
|
|
/// <param name="duration">Time it took to execute the command in milliseconds</param>
|
|
|
|
|
/// <returns><c>true</c> if the device set an error condition, <c>false</c> otherwise</returns>
|
|
|
|
|
public bool EnableMediaCardPassThrough(out AtaErrorRegistersChs statusRegisters, uint timeout,
|
2023-10-03 23:12:01 +01:00
|
|
|
out double duration) =>
|
2022-03-06 13:29:38 +00:00
|
|
|
CheckMediaCardType(1, out statusRegisters, timeout, out duration);
|
2016-02-08 00:13:49 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
/// <summary>Disables media card pass through</summary>
|
|
|
|
|
/// <param name="statusRegisters">Status registers.</param>
|
|
|
|
|
/// <param name="timeout">Timeout in seconds</param>
|
|
|
|
|
/// <param name="duration">Time it took to execute the command in milliseconds</param>
|
|
|
|
|
/// <returns><c>true</c> if the device set an error condition, <c>false</c> otherwise</returns>
|
|
|
|
|
public bool DisableMediaCardPassThrough(out AtaErrorRegistersChs statusRegisters, uint timeout,
|
2023-10-03 23:12:01 +01:00
|
|
|
out double duration) =>
|
2022-03-06 13:29:38 +00:00
|
|
|
CheckMediaCardType(0, out statusRegisters, timeout, out duration);
|
2017-09-08 18:00:01 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
/// <summary>Checks media card pass through</summary>
|
|
|
|
|
/// <param name="feature">Feature</param>
|
|
|
|
|
/// <param name="statusRegisters">Status registers.</param>
|
|
|
|
|
/// <param name="timeout">Timeout in seconds</param>
|
|
|
|
|
/// <param name="duration">Time it took to execute the command in milliseconds</param>
|
|
|
|
|
/// <returns><c>true</c> if the device set an error condition, <c>false</c> otherwise</returns>
|
2023-10-03 23:12:01 +01:00
|
|
|
public bool CheckMediaCardType(byte feature, out AtaErrorRegistersChs statusRegisters, uint timeout,
|
2022-03-06 13:29:38 +00:00
|
|
|
out double duration)
|
|
|
|
|
{
|
2024-05-01 04:39:38 +01:00
|
|
|
byte[] buffer = [];
|
2016-02-08 00:13:49 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
var registers = new AtaRegistersChs
|
|
|
|
|
{
|
|
|
|
|
Command = (byte)AtaCommands.CheckMediaCardType,
|
|
|
|
|
Feature = feature
|
|
|
|
|
};
|
2020-02-29 18:03:35 +00:00
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
LastError = SendAtaCommand(registers,
|
|
|
|
|
out statusRegisters,
|
|
|
|
|
AtaProtocol.NonData,
|
|
|
|
|
AtaTransferRegister.NoTransfer,
|
|
|
|
|
ref buffer,
|
|
|
|
|
timeout,
|
|
|
|
|
false,
|
|
|
|
|
out duration,
|
|
|
|
|
out bool sense);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
Error = LastError != 0;
|
2016-02-08 00:13:49 +00:00
|
|
|
|
2025-08-17 06:11:22 +01:00
|
|
|
AaruLogging.Debug(ATA_MODULE_NAME, Localization.CHECK_MEDIA_CARD_TYPE_took_0_ms, duration);
|
2016-02-08 00:13:49 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
return sense;
|
2016-02-08 00:13:49 +00:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|