Code restyling.

This commit is contained in:
2020-02-29 18:03:35 +00:00
parent 4ea327f0c6
commit f7e173710e
855 changed files with 43605 additions and 38045 deletions

View File

@@ -41,12 +41,16 @@ namespace Aaru.Devices
out double duration)
{
buffer = new byte[512];
AtaRegistersLba28 registers = new AtaRegistersLba28 {Command = (byte)AtaCommands.ReadBuffer};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
var registers = new AtaRegistersLba28
{
Command = (byte)AtaCommands.ReadBuffer
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "READ BUFFER took {0} ms.", duration);
@@ -58,10 +62,15 @@ namespace Aaru.Devices
out double duration)
{
buffer = new byte[512];
AtaRegistersLba28 registers = new AtaRegistersLba28 {Command = (byte)AtaCommands.ReadBufferDma};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.NoTransfer,
ref buffer, timeout, false, out duration, out bool sense);
var registers = new AtaRegistersLba28
{
Command = (byte)AtaCommands.ReadBufferDma
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.NoTransfer,
ref buffer, timeout, false, out duration, out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "READ BUFFER DMA took {0} ms.", duration);
@@ -69,29 +78,29 @@ namespace Aaru.Devices
return sense;
}
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count,
uint timeout, out double duration) =>
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count,
uint timeout, out double duration) =>
ReadDma(out buffer, out statusRegisters, true, lba, count, timeout, out duration);
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba,
byte count, uint timeout, out double duration)
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba,
byte count, uint timeout, out double duration)
{
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
AtaRegistersLba28 registers = new AtaRegistersLba28
var registers = new AtaRegistersLba28
{
SectorCount = count,
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
LbaMid = (byte)((lba & 0xFF00) / 0x100),
LbaLow = (byte)((lba & 0xFF) / 0x1),
SectorCount = count, DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
LbaMid = (byte)((lba & 0xFF00) / 0x100),
LbaLow = (byte)((lba & 0xFF) / 0x1),
Command = retry ? (byte)AtaCommands.ReadDmaRetry : (byte)AtaCommands.ReadDma
};
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma,
AtaTransferRegister.SectorCount,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
ref buffer, timeout, true, out duration, out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "READ DMA took {0} ms.", duration);
@@ -99,26 +108,24 @@ namespace Aaru.Devices
return sense;
}
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count,
uint timeout, out double duration)
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count,
uint timeout, out double duration)
{
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
AtaRegistersLba28 registers = new AtaRegistersLba28
var registers = new AtaRegistersLba28
{
Command = (byte)AtaCommands.ReadMultiple,
SectorCount = count,
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
LbaMid = (byte)((lba & 0xFF00) / 0x100),
LbaLow = (byte)((lba & 0xFF) / 0x1)
Command = (byte)AtaCommands.ReadMultiple, SectorCount = count,
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000), LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
LbaMid = (byte)((lba & 0xFF00) / 0x100), LbaLow = (byte)((lba & 0xFF) / 0x1)
};
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "READ MULTIPLE took {0} ms.", duration);
@@ -126,19 +133,23 @@ namespace Aaru.Devices
return sense;
}
public bool ReadNativeMaxAddress(out uint lba, out AtaErrorRegistersLba28 statusRegisters, uint timeout,
public bool ReadNativeMaxAddress(out uint lba, out AtaErrorRegistersLba28 statusRegisters, uint timeout,
out double duration)
{
lba = 0;
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28 {Command = (byte)AtaCommands.ReadNativeMaxAddress};
byte[] buffer = new byte[0];
var registers = new AtaRegistersLba28
{
Command = (byte)AtaCommands.ReadNativeMaxAddress
};
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
if((statusRegisters.Status & 0x23) == 0)
@@ -155,30 +166,30 @@ namespace Aaru.Devices
return sense;
}
public bool Read(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count,
uint timeout, out double duration) =>
public bool Read(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count,
uint timeout, out double duration) =>
Read(out buffer, out statusRegisters, true, lba, count, timeout, out duration);
public bool Read(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba,
byte count, uint timeout, out double duration)
public bool Read(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba,
byte count, uint timeout, out double duration)
{
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
AtaRegistersLba28 registers = new AtaRegistersLba28
var registers = new AtaRegistersLba28
{
SectorCount = count,
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
LbaMid = (byte)((lba & 0xFF00) / 0x100),
LbaLow = (byte)((lba & 0xFF) / 0x1),
SectorCount = count, DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
LbaMid = (byte)((lba & 0xFF00) / 0x100),
LbaLow = (byte)((lba & 0xFF) / 0x1),
Command = retry ? (byte)AtaCommands.ReadRetry : (byte)AtaCommands.Read
};
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "READ SECTORS took {0} ms.", duration);
@@ -186,31 +197,30 @@ namespace Aaru.Devices
return sense;
}
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, uint blockSize,
uint timeout, out double duration) =>
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, uint blockSize,
uint timeout, out double duration) =>
ReadLong(out buffer, out statusRegisters, true, lba, blockSize, timeout, out duration);
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry,
uint lba,
uint blockSize, uint timeout, out double duration)
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba,
uint blockSize, uint timeout, out double duration)
{
buffer = new byte[blockSize];
AtaRegistersLba28 registers = new AtaRegistersLba28
var registers = new AtaRegistersLba28
{
SectorCount = 1,
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
LbaMid = (byte)((lba & 0xFF00) / 0x100),
LbaLow = (byte)((lba & 0xFF) / 0x1),
SectorCount = 1, DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
LbaMid = (byte)((lba & 0xFF00) / 0x100),
LbaLow = (byte)((lba & 0xFF) / 0x1),
Command = retry ? (byte)AtaCommands.ReadLongRetry : (byte)AtaCommands.ReadLong
};
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "READ LONG took {0} ms.", duration);
@@ -221,21 +231,21 @@ namespace Aaru.Devices
public bool Seek(out AtaErrorRegistersLba28 statusRegisters, uint lba, uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28
var registers = new AtaRegistersLba28
{
Command = (byte)AtaCommands.Seek,
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
LbaMid = (byte)((lba & 0xFF00) / 0x100),
LbaLow = (byte)((lba & 0xFF) / 0x1)
Command = (byte)AtaCommands.Seek, DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
LbaMid = (byte)((lba & 0xFF00) / 0x100),
LbaLow = (byte)((lba & 0xFF) / 0x1)
};
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "SEEK took {0} ms.", duration);

View File

@@ -37,18 +37,21 @@ namespace Aaru.Devices
{
public partial class Device
{
public bool GetNativeMaxAddressExt(out ulong lba, out AtaErrorRegistersLba48 statusRegisters, uint timeout,
public bool GetNativeMaxAddressExt(out ulong lba, out AtaErrorRegistersLba48 statusRegisters, uint timeout,
out double duration)
{
lba = 0;
byte[] buffer = new byte[0];
AtaRegistersLba48 registers =
new AtaRegistersLba48 {Command = (byte)AtaCommands.NativeMaxAddress, Feature = 0x0000};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
var registers = new AtaRegistersLba48
{
Command = (byte)AtaCommands.NativeMaxAddress, Feature = 0x0000
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
if((statusRegisters.Status & 0x23) == 0)
@@ -64,24 +67,23 @@ namespace Aaru.Devices
return sense;
}
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
uint timeout, out double duration)
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
uint timeout, out double duration)
{
buffer = count == 0 ? new byte[512 * 65536] : new byte[512 * count];
AtaRegistersLba48 registers = new AtaRegistersLba48
var registers = new AtaRegistersLba48
{
Command = (byte)AtaCommands.ReadDmaExt,
SectorCount = count,
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000),
LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
Command = (byte)AtaCommands.ReadDmaExt, SectorCount = count,
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000), LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
};
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma,
AtaTransferRegister.SectorCount,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
ref buffer, timeout, true, out duration, out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "READ DMA EXT took {0} ms.", duration);
@@ -89,25 +91,23 @@ namespace Aaru.Devices
return sense;
}
public bool ReadLog(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, byte logAddress,
ushort pageNumber, ushort count, uint timeout,
out double duration)
public bool ReadLog(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, byte logAddress,
ushort pageNumber, ushort count, uint timeout, out double duration)
{
buffer = new byte[512 * count];
AtaRegistersLba48 registers = new AtaRegistersLba48
var registers = new AtaRegistersLba48
{
Command = (byte)AtaCommands.ReadLogExt,
SectorCount = count,
LbaLow = (ushort)((pageNumber & 0xFF) * 0x100),
LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100)
Command = (byte)AtaCommands.ReadLogExt, SectorCount = count,
LbaLow = (ushort)((pageNumber & 0xFF) * 0x100), LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100)
};
registers.LbaLow += logAddress;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "READ LOG EXT took {0} ms.", duration);
@@ -115,24 +115,22 @@ namespace Aaru.Devices
return sense;
}
public bool ReadLogDma(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, byte logAddress,
ushort pageNumber, ushort count, uint timeout,
out double duration)
public bool ReadLogDma(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, byte logAddress,
ushort pageNumber, ushort count, uint timeout, out double duration)
{
buffer = new byte[512 * count];
AtaRegistersLba48 registers = new AtaRegistersLba48
var registers = new AtaRegistersLba48
{
Command = (byte)AtaCommands.ReadLogDmaExt,
SectorCount = count,
LbaLow = (ushort)((pageNumber & 0xFF) * 0x100),
LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100)
Command = (byte)AtaCommands.ReadLogDmaExt, SectorCount = count,
LbaLow = (ushort)((pageNumber & 0xFF) * 0x100), LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100)
};
registers.LbaLow += logAddress;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma,
AtaTransferRegister.SectorCount,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
ref buffer, timeout, true, out duration, out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "READ LOG DMA EXT took {0} ms.", duration);
@@ -140,26 +138,24 @@ namespace Aaru.Devices
return sense;
}
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba,
ushort count,
uint timeout, out double duration)
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
uint timeout, out double duration)
{
buffer = count == 0 ? new byte[512 * 65536] : new byte[512 * count];
AtaRegistersLba48 registers = new AtaRegistersLba48
var registers = new AtaRegistersLba48
{
Command = (byte)AtaCommands.ReadMultipleExt,
SectorCount = count,
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000),
LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
Command = (byte)AtaCommands.ReadMultipleExt, SectorCount = count,
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000), LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
};
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "READ MULTIPLE EXT took {0} ms.", duration);
@@ -167,19 +163,23 @@ namespace Aaru.Devices
return sense;
}
public bool ReadNativeMaxAddress(out ulong lba, out AtaErrorRegistersLba48 statusRegisters, uint timeout,
public bool ReadNativeMaxAddress(out ulong lba, out AtaErrorRegistersLba48 statusRegisters, uint timeout,
out double duration)
{
lba = 0;
byte[] buffer = new byte[0];
AtaRegistersLba48 registers = new AtaRegistersLba48 {Command = (byte)AtaCommands.ReadNativeMaxAddressExt};
byte[] buffer = new byte[0];
var registers = new AtaRegistersLba48
{
Command = (byte)AtaCommands.ReadNativeMaxAddressExt
};
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
if((statusRegisters.Status & 0x23) == 0)
@@ -195,25 +195,24 @@ namespace Aaru.Devices
return sense;
}
public bool Read(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
uint timeout, out double duration)
public bool Read(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
uint timeout, out double duration)
{
buffer = count == 0 ? new byte[512 * 65536] : new byte[512 * count];
AtaRegistersLba48 registers = new AtaRegistersLba48
var registers = new AtaRegistersLba48
{
Command = (byte)AtaCommands.ReadExt,
SectorCount = count,
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000),
LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
Command = (byte)AtaCommands.ReadExt, SectorCount = count,
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000), LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
};
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "READ SECTORS EXT took {0} ms.", duration);

View File

@@ -37,18 +37,14 @@ namespace Aaru.Devices
{
public partial class Device
{
/// <summary>
/// Sends the ATA IDENTIFY DEVICE command to the device, using default device timeout
/// </summary>
/// <summary>Sends the ATA IDENTIFY DEVICE command to the device, using default device timeout</summary>
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters" /> contains the error registers.</returns>
/// <param name="buffer">Buffer.</param>
/// <param name="statusRegisters">Status registers.</param>
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters) =>
AtaIdentify(out buffer, out statusRegisters, Timeout);
/// <summary>
/// Sends the ATA IDENTIFY DEVICE command to the device, using default device timeout
/// </summary>
/// <summary>Sends the ATA IDENTIFY DEVICE command to the device, using default device timeout</summary>
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters" /> contains the error registers.</returns>
/// <param name="buffer">Buffer.</param>
/// <param name="statusRegisters">Status registers.</param>
@@ -56,9 +52,7 @@ namespace Aaru.Devices
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, out double duration) =>
AtaIdentify(out buffer, out statusRegisters, Timeout, out duration);
/// <summary>
/// Sends the ATA IDENTIFY DEVICE command to the device
/// </summary>
/// <summary>Sends the ATA IDENTIFY DEVICE command to the device</summary>
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters" /> contains the error registers.</returns>
/// <param name="buffer">Buffer.</param>
/// <param name="statusRegisters">Status registers.</param>
@@ -66,9 +60,7 @@ namespace Aaru.Devices
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, uint timeout) =>
AtaIdentify(out buffer, out statusRegisters, timeout, out _);
/// <summary>
/// Sends the ATA IDENTIFY DEVICE command to the device
/// </summary>
/// <summary>Sends the ATA IDENTIFY DEVICE command to the device</summary>
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters" /> contains the error registers.</returns>
/// <param name="buffer">Buffer.</param>
/// <param name="statusRegisters">Status registers.</param>
@@ -78,12 +70,16 @@ namespace Aaru.Devices
out double duration)
{
buffer = new byte[512];
AtaRegistersChs registers = new AtaRegistersChs {Command = (byte)AtaCommands.IdentifyDevice};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
var registers = new AtaRegistersChs
{
Command = (byte)AtaCommands.IdentifyDevice
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "IDENTIFY DEVICE took {0} ms.", duration);
@@ -91,30 +87,26 @@ namespace Aaru.Devices
return sense;
}
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder,
byte head,
byte sector, byte count, uint timeout,
out double duration) =>
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head,
byte sector, byte count, uint timeout, out double duration) =>
ReadDma(out buffer, out statusRegisters, true, cylinder, head, sector, count, timeout, out duration);
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, bool retry, ushort cylinder,
byte head, byte sector, byte count, uint timeout,
out double duration)
byte head, byte sector, byte count, uint timeout, out double duration)
{
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
AtaRegistersChs registers = new AtaRegistersChs
var registers = new AtaRegistersChs
{
SectorCount = count,
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
DeviceHead = (byte)(head & 0x0F),
Sector = sector,
Command = retry ? (byte)AtaCommands.ReadDmaRetry : (byte)AtaCommands.ReadDma
SectorCount = count, CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
CylinderLow = (byte)((cylinder & 0xFF) / 0x1), DeviceHead = (byte)(head & 0x0F),
Sector = sector,
Command = retry ? (byte)AtaCommands.ReadDmaRetry : (byte)AtaCommands.ReadDma
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma,
AtaTransferRegister.SectorCount,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
ref buffer, timeout, true, out duration, out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "READ DMA took {0} ms.", duration);
@@ -122,25 +114,22 @@ namespace Aaru.Devices
return sense;
}
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder,
byte head, byte sector, byte count,
uint timeout, out double duration)
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder,
byte head, byte sector, byte count, uint timeout, out double duration)
{
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
AtaRegistersChs registers = new AtaRegistersChs
var registers = new AtaRegistersChs
{
Command = (byte)AtaCommands.ReadMultiple,
SectorCount = count,
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
DeviceHead = (byte)(head & 0x0F),
Sector = sector
Command = (byte)AtaCommands.ReadMultiple, SectorCount = count,
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100), CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
DeviceHead = (byte)(head & 0x0F), Sector = sector
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "READ MULTIPLE took {0} ms.", duration);
@@ -149,29 +138,26 @@ namespace Aaru.Devices
}
public bool Read(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head,
byte sector, byte count, uint timeout,
out double duration) =>
byte sector, byte count, uint timeout, out double duration) =>
Read(out buffer, out statusRegisters, true, cylinder, head, sector, count, timeout, out duration);
public bool Read(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, bool retry, ushort cylinder,
byte head, byte sector, byte count, uint timeout,
out double duration)
byte head, byte sector, byte count, uint timeout, out double duration)
{
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
AtaRegistersChs registers = new AtaRegistersChs
var registers = new AtaRegistersChs
{
Command = retry ? (byte)AtaCommands.ReadRetry : (byte)AtaCommands.Read,
SectorCount = count,
Command = retry ? (byte)AtaCommands.ReadRetry : (byte)AtaCommands.Read, SectorCount = count,
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
DeviceHead = (byte)(head & 0x0F),
Sector = sector
DeviceHead = (byte)(head & 0x0F), Sector = sector
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "READ SECTORS took {0} ms.", duration);
@@ -179,32 +165,28 @@ namespace Aaru.Devices
return sense;
}
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder,
byte head,
byte sector, uint blockSize, uint timeout,
out double duration) =>
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head,
byte sector, uint blockSize, uint timeout, out double duration) =>
ReadLong(out buffer, out statusRegisters, true, cylinder, head, sector, blockSize, timeout, out duration);
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, bool retry,
ushort cylinder,
byte head, byte sector, uint blockSize,
uint timeout, out double duration)
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, bool retry, ushort cylinder,
byte head, byte sector, uint blockSize, uint timeout, out double duration)
{
buffer = new byte[blockSize];
AtaRegistersChs registers = new AtaRegistersChs
var registers = new AtaRegistersChs
{
Command = retry ? (byte)AtaCommands.ReadLongRetry : (byte)AtaCommands.ReadLong,
SectorCount = 1,
Command = retry ? (byte)AtaCommands.ReadLongRetry : (byte)AtaCommands.ReadLong, SectorCount = 1,
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
DeviceHead = (byte)(head & 0x0F),
Sector = sector
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "READ LONG took {0} ms.", duration);
@@ -212,22 +194,22 @@ namespace Aaru.Devices
return sense;
}
public bool Seek(out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head, byte sector,
uint timeout, out double duration)
public bool Seek(out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head, byte sector,
uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersChs registers = new AtaRegistersChs
var registers = new AtaRegistersChs
{
Command = (byte)AtaCommands.Seek,
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
DeviceHead = (byte)(head & 0x0F),
Sector = sector
Command = (byte)AtaCommands.Seek, CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
DeviceHead = (byte)(head & 0x0F), Sector = sector
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, true, out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, true, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "SEEK took {0} ms.", duration);
@@ -236,28 +218,27 @@ namespace Aaru.Devices
}
public bool SetFeatures(out AtaErrorRegistersChs statusRegisters, AtaFeatures feature, uint timeout,
out double duration) =>
out double duration) =>
SetFeatures(out statusRegisters, feature, 0, 0, 0, 0, timeout, out duration);
public bool SetFeatures(out AtaErrorRegistersChs statusRegisters, AtaFeatures feature, ushort cylinder,
byte head, byte sector, byte sectorCount,
uint timeout, out double duration)
byte head, byte sector, byte sectorCount, uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersChs registers = new AtaRegistersChs
var registers = new AtaRegistersChs
{
Command = (byte)AtaCommands.SetFeatures,
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
DeviceHead = (byte)(head & 0x0F),
Sector = sector,
SectorCount = sectorCount,
Feature = (byte)feature
Command = (byte)AtaCommands.SetFeatures, CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
DeviceHead = (byte)(head & 0x0F), Sector = sector,
SectorCount = sectorCount,
Feature = (byte)feature
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, true, out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, true, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "SET FEATURES took {0} ms.", duration);

View File

@@ -37,18 +37,14 @@ namespace Aaru.Devices
{
public partial class Device
{
/// <summary>
/// Sends the ATA IDENTIFY PACKET DEVICE command to the device, using default device timeout
/// </summary>
/// <summary>Sends the ATA IDENTIFY PACKET DEVICE command to the device, using default device timeout</summary>
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters" /> contains the error registers.</returns>
/// <param name="buffer">Buffer.</param>
/// <param name="statusRegisters">Status registers.</param>
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters) =>
AtapiIdentify(out buffer, out statusRegisters, Timeout);
/// <summary>
/// Sends the ATA IDENTIFY PACKET DEVICE command to the device, using default device timeout
/// </summary>
/// <summary>Sends the ATA IDENTIFY PACKET DEVICE command to the device, using default device timeout</summary>
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters" /> contains the error registers.</returns>
/// <param name="buffer">Buffer.</param>
/// <param name="statusRegisters">Status registers.</param>
@@ -56,9 +52,7 @@ namespace Aaru.Devices
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, out double duration) =>
AtapiIdentify(out buffer, out statusRegisters, Timeout, out duration);
/// <summary>
/// Sends the ATA IDENTIFY PACKET DEVICE command to the device
/// </summary>
/// <summary>Sends the ATA IDENTIFY PACKET DEVICE command to the device</summary>
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters" /> contains the error registers.</returns>
/// <param name="buffer">Buffer.</param>
/// <param name="statusRegisters">Status registers.</param>
@@ -66,9 +60,7 @@ namespace Aaru.Devices
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, uint timeout) =>
AtapiIdentify(out buffer, out statusRegisters, timeout, out _);
/// <summary>
/// Sends the ATA IDENTIFY PACKET DEVICE command to the device
/// </summary>
/// <summary>Sends the ATA IDENTIFY PACKET DEVICE command to the device</summary>
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters" /> contains the error registers.</returns>
/// <param name="buffer">Buffer.</param>
/// <param name="statusRegisters">Status registers.</param>
@@ -78,12 +70,16 @@ namespace Aaru.Devices
out double duration)
{
buffer = new byte[512];
AtaRegistersChs registers = new AtaRegistersChs {Command = (byte)AtaCommands.IdentifyPacketDevice};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
var registers = new AtaRegistersChs
{
Command = (byte)AtaCommands.IdentifyPacketDevice
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "IDENTIFY PACKET DEVICE took {0} ms.", duration);

View File

@@ -37,25 +37,25 @@ namespace Aaru.Devices
{
public partial class Device
{
public bool TranslateSector(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba,
uint timeout, out double duration)
public bool TranslateSector(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba,
uint timeout, out double duration)
{
buffer = new byte[512];
AtaRegistersLba28 registers = new AtaRegistersLba28
var registers = new AtaRegistersLba28
{
Command = (byte)AtaCommands.TranslateSector,
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
LbaMid = (byte)((lba & 0xFF00) / 0x100),
LbaLow = (byte)((lba & 0xFF) / 0x1)
Command = (byte)AtaCommands.TranslateSector, DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
LbaMid = (byte)((lba & 0xFF00) / 0x100),
LbaLow = (byte)((lba & 0xFF) / 0x1)
};
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "CFA TRANSLATE SECTOR took {0} ms.", duration);
@@ -64,23 +64,21 @@ namespace Aaru.Devices
}
public bool TranslateSector(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder,
byte head, byte sector, uint timeout,
out double duration)
byte head, byte sector, uint timeout, out double duration)
{
buffer = new byte[512];
AtaRegistersChs registers = new AtaRegistersChs
var registers = new AtaRegistersChs
{
Command = (byte)AtaCommands.TranslateSector,
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
Sector = sector,
DeviceHead = (byte)(head & 0x0F)
Command = (byte)AtaCommands.TranslateSector, CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
Sector = sector, DeviceHead = (byte)(head & 0x0F)
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "CFA TRANSLATE SECTOR took {0} ms.", duration);
@@ -89,15 +87,19 @@ namespace Aaru.Devices
}
public bool RequestExtendedErrorCode(out byte errorCode, out AtaErrorRegistersLba28 statusRegisters,
uint timeout, out double duration)
uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28 {Command = (byte)AtaCommands.RequestSense};
byte[] buffer = new byte[0];
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
var registers = new AtaRegistersLba28
{
Command = (byte)AtaCommands.RequestSense
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
errorCode = statusRegisters.Error;

View File

@@ -38,24 +38,27 @@ namespace Aaru.Devices
public partial class Device
{
public bool EnableMediaCardPassThrough(out AtaErrorRegistersChs statusRegisters, uint timeout,
out double duration) =>
out double duration) =>
CheckMediaCardType(1, out statusRegisters, timeout, out duration);
public bool DisableMediaCardPassThrough(out AtaErrorRegistersChs statusRegisters, uint timeout,
out double duration) =>
out double duration) =>
CheckMediaCardType(0, out statusRegisters, timeout, out duration);
public bool CheckMediaCardType(byte feature, out AtaErrorRegistersChs statusRegisters, uint timeout,
public bool CheckMediaCardType(byte feature, out AtaErrorRegistersChs statusRegisters, uint timeout,
out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersChs registers =
new AtaRegistersChs {Command = (byte)AtaCommands.CheckMediaCardType, Feature = feature};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
var registers = new AtaRegistersChs
{
Command = (byte)AtaCommands.CheckMediaCardType, Feature = feature
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "CHECK MEDIA CARD TYPE took {0} ms.", duration);

View File

@@ -40,18 +40,17 @@ namespace Aaru.Devices
public bool SmartDisable(out AtaErrorRegistersLba28 statusRegisters, uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28
var registers = new AtaRegistersLba28
{
Command = (byte)AtaCommands.Smart,
Feature = (byte)AtaSmartSubCommands.Disable,
LbaHigh = 0xC2,
Command = (byte)AtaCommands.Smart, Feature = (byte)AtaSmartSubCommands.Disable, LbaHigh = 0xC2,
LbaMid = 0x4F
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "SMART DISABLE OPERATIONS took {0} ms.", duration);
@@ -60,22 +59,20 @@ namespace Aaru.Devices
}
public bool SmartEnableAttributeAutosave(out AtaErrorRegistersLba28 statusRegisters, uint timeout,
out double duration)
out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28
var registers = new AtaRegistersLba28
{
Command = (byte)AtaCommands.Smart,
Feature = (byte)AtaSmartSubCommands.EnableDisableAttributeAutosave,
LbaHigh = 0xC2,
LbaMid = 0x4F,
SectorCount = 0xF1
Command = (byte)AtaCommands.Smart, Feature = (byte)AtaSmartSubCommands.EnableDisableAttributeAutosave,
LbaHigh = 0xC2, LbaMid = 0x4F, SectorCount = 0xF1
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "SMART ENABLE ATTRIBUTE AUTOSAVE took {0} ms.", duration);
@@ -84,21 +81,20 @@ namespace Aaru.Devices
}
public bool SmartDisableAttributeAutosave(out AtaErrorRegistersLba28 statusRegisters, uint timeout,
out double duration)
out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28
var registers = new AtaRegistersLba28
{
Command = (byte)AtaCommands.Smart,
Feature = (byte)AtaSmartSubCommands.EnableDisableAttributeAutosave,
LbaHigh = 0xC2,
LbaMid = 0x4F
Command = (byte)AtaCommands.Smart, Feature = (byte)AtaSmartSubCommands.EnableDisableAttributeAutosave,
LbaHigh = 0xC2, LbaMid = 0x4F
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "SMART DISABLE ATTRIBUTE AUTOSAVE took {0} ms.", duration);
@@ -109,18 +105,17 @@ namespace Aaru.Devices
public bool SmartEnable(out AtaErrorRegistersLba28 statusRegisters, uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28
var registers = new AtaRegistersLba28
{
Command = (byte)AtaCommands.Smart,
Feature = (byte)AtaSmartSubCommands.Enable,
LbaHigh = 0xC2,
Command = (byte)AtaCommands.Smart, Feature = (byte)AtaSmartSubCommands.Enable, LbaHigh = 0xC2,
LbaMid = 0x4F
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "SMART ENABLE OPERATIONS took {0} ms.", duration);
@@ -128,23 +123,21 @@ namespace Aaru.Devices
return sense;
}
public bool SmartExecuteOffLineImmediate(out AtaErrorRegistersLba28 statusRegisters, byte subcommand,
uint timeout, out double duration)
public bool SmartExecuteOffLineImmediate(out AtaErrorRegistersLba28 statusRegisters, byte subcommand,
uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28
var registers = new AtaRegistersLba28
{
Command = (byte)AtaCommands.Smart,
Feature = (byte)AtaSmartSubCommands.ExecuteOfflineImmediate,
LbaHigh = 0xC2,
LbaMid = 0x4F,
LbaLow = subcommand
Command = (byte)AtaCommands.Smart, Feature = (byte)AtaSmartSubCommands.ExecuteOfflineImmediate,
LbaHigh = 0xC2, LbaMid = 0x4F, LbaLow = subcommand
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "SMART EXECUTE OFF-LINE IMMEDIATE took {0} ms.", duration);
@@ -156,18 +149,17 @@ namespace Aaru.Devices
out double duration)
{
buffer = new byte[512];
AtaRegistersLba28 registers = new AtaRegistersLba28
var registers = new AtaRegistersLba28
{
Command = (byte)AtaCommands.Smart,
Feature = (byte)AtaSmartSubCommands.ReadData,
LbaHigh = 0xC2,
Command = (byte)AtaCommands.Smart, Feature = (byte)AtaSmartSubCommands.ReadData, LbaHigh = 0xC2,
LbaMid = 0x4F
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "SMART READ DATA took {0} ms.", duration);
@@ -175,23 +167,21 @@ namespace Aaru.Devices
return sense;
}
public bool SmartReadLog(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, byte logAddress,
uint timeout, out double duration)
public bool SmartReadLog(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, byte logAddress,
uint timeout, out double duration)
{
buffer = new byte[512];
AtaRegistersLba28 registers = new AtaRegistersLba28
var registers = new AtaRegistersLba28
{
Command = (byte)AtaCommands.Smart,
Feature = (byte)AtaSmartSubCommands.ReadLog,
LbaHigh = 0xC2,
LbaMid = 0x4F,
LbaLow = logAddress
Command = (byte)AtaCommands.Smart, Feature = (byte)AtaSmartSubCommands.ReadLog, LbaHigh = 0xC2,
LbaMid = 0x4F, LbaLow = logAddress
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "SMART READ LOG took {0} ms.", duration);
@@ -202,18 +192,17 @@ namespace Aaru.Devices
public bool SmartReturnStatus(out AtaErrorRegistersLba28 statusRegisters, uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28
var registers = new AtaRegistersLba28
{
Command = (byte)AtaCommands.Smart,
Feature = (byte)AtaSmartSubCommands.ReturnStatus,
LbaHigh = 0xC2,
Command = (byte)AtaCommands.Smart, Feature = (byte)AtaSmartSubCommands.ReturnStatus, LbaHigh = 0xC2,
LbaMid = 0x4F
};
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
out duration,
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out bool sense);
Error = LastError != 0;
AaruConsole.DebugWriteLine("ATA Device", "SMART RETURN STATUS took {0} ms.", duration);