REFACTOR: All refactor in DiscImageChef.Decoders.

This commit is contained in:
2017-12-22 02:04:18 +00:00
parent 7f829422a8
commit 49144eeb01
148 changed files with 2606 additions and 1939 deletions

View File

@@ -158,7 +158,7 @@ namespace DiscImageChef.Devices
}
}
internal static int SendAtaCommand(object fd, AtaRegistersCHS registers, out AtaErrorRegistersCHS errorRegisters,
internal static int SendAtaCommand(object fd, AtaRegistersChs registers, out AtaErrorRegistersChs errorRegisters,
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
uint timeout, bool transferBlocks, out double duration, out bool sense)
{
@@ -168,8 +168,8 @@ namespace DiscImageChef.Devices
timeout, transferBlocks, out duration, out sense);
}
internal static int SendAtaCommand(PlatformID ptId, object fd, AtaRegistersCHS registers,
out AtaErrorRegistersCHS errorRegisters, AtaProtocol protocol,
internal static int SendAtaCommand(PlatformID ptId, object fd, AtaRegistersChs registers,
out AtaErrorRegistersChs errorRegisters, AtaProtocol protocol,
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{
@@ -205,8 +205,8 @@ namespace DiscImageChef.Devices
}
}
internal static int SendAtaCommand(object fd, AtaRegistersLBA28 registers,
out AtaErrorRegistersLBA28 errorRegisters, AtaProtocol protocol,
internal static int SendAtaCommand(object fd, AtaRegistersLba28 registers,
out AtaErrorRegistersLba28 errorRegisters, AtaProtocol protocol,
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{
@@ -216,8 +216,8 @@ namespace DiscImageChef.Devices
timeout, transferBlocks, out duration, out sense);
}
internal static int SendAtaCommand(PlatformID ptId, object fd, AtaRegistersLBA28 registers,
out AtaErrorRegistersLBA28 errorRegisters, AtaProtocol protocol,
internal static int SendAtaCommand(PlatformID ptId, object fd, AtaRegistersLba28 registers,
out AtaErrorRegistersLba28 errorRegisters, AtaProtocol protocol,
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{
@@ -253,8 +253,8 @@ namespace DiscImageChef.Devices
}
}
internal static int SendAtaCommand(object fd, AtaRegistersLBA48 registers,
out AtaErrorRegistersLBA48 errorRegisters, AtaProtocol protocol,
internal static int SendAtaCommand(object fd, AtaRegistersLba48 registers,
out AtaErrorRegistersLba48 errorRegisters, AtaProtocol protocol,
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{
@@ -264,8 +264,8 @@ namespace DiscImageChef.Devices
timeout, transferBlocks, out duration, out sense);
}
internal static int SendAtaCommand(PlatformID ptId, object fd, AtaRegistersLBA48 registers,
out AtaErrorRegistersLBA48 errorRegisters, AtaProtocol protocol,
internal static int SendAtaCommand(PlatformID ptId, object fd, AtaRegistersLba48 registers,
out AtaErrorRegistersLba48 errorRegisters, AtaProtocol protocol,
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{

View File

@@ -37,14 +37,14 @@ namespace DiscImageChef.Devices
{
public partial class Device
{
public bool ReadBuffer(out byte[] buffer, out AtaErrorRegistersLBA28 statusRegisters, uint timeout,
public bool ReadBuffer(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint timeout,
out double duration)
{
buffer = new byte[512];
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
registers.command = (byte)AtaCommands.ReadBuffer;
registers.Command = (byte)AtaCommands.ReadBuffer;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
@@ -56,14 +56,14 @@ namespace DiscImageChef.Devices
return sense;
}
public bool ReadBufferDma(out byte[] buffer, out AtaErrorRegistersLBA28 statusRegisters, uint timeout,
public bool ReadBufferDma(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint timeout,
out double duration)
{
buffer = new byte[512];
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
registers.command = (byte)AtaCommands.ReadBufferDma;
registers.Command = (byte)AtaCommands.ReadBufferDma;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.NoTransfer,
ref buffer, timeout, false, out duration, out sense);
@@ -74,28 +74,28 @@ namespace DiscImageChef.Devices
return sense;
}
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLBA28 statusRegisters, uint lba, byte count,
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count,
uint timeout, out double duration)
{
return ReadDma(out buffer, out statusRegisters, true, lba, count, timeout, out duration);
}
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLBA28 statusRegisters, bool retry, uint lba,
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba,
byte count, uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 256];
else buffer = new byte[512 * count];
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
if(retry) registers.command = (byte)AtaCommands.ReadDmaRetry;
else registers.command = (byte)AtaCommands.ReadDma;
registers.sectorCount = count;
registers.deviceHead = (byte)((lba & 0xF000000) / 0x1000000);
registers.lbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
registers.lbaMid = (byte)((lba & 0xFF00) / 0x100);
registers.lbaLow = (byte)((lba & 0xFF) / 0x1);
registers.deviceHead += 0x40;
if(retry) registers.Command = (byte)AtaCommands.ReadDmaRetry;
else registers.Command = (byte)AtaCommands.ReadDma;
registers.SectorCount = count;
registers.DeviceHead = (byte)((lba & 0xF000000) / 0x1000000);
registers.LbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
registers.LbaMid = (byte)((lba & 0xFF00) / 0x100);
registers.LbaLow = (byte)((lba & 0xFF) / 0x1);
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
ref buffer, timeout, true, out duration, out sense);
@@ -106,21 +106,21 @@ namespace DiscImageChef.Devices
return sense;
}
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersLBA28 statusRegisters, uint lba, byte count,
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count,
uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 256];
else buffer = new byte[512 * count];
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
registers.command = (byte)AtaCommands.ReadMultiple;
registers.sectorCount = count;
registers.deviceHead = (byte)((lba & 0xF000000) / 0x1000000);
registers.lbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
registers.lbaMid = (byte)((lba & 0xFF00) / 0x100);
registers.lbaLow = (byte)((lba & 0xFF) / 0x1);
registers.deviceHead += 0x40;
registers.Command = (byte)AtaCommands.ReadMultiple;
registers.SectorCount = count;
registers.DeviceHead = (byte)((lba & 0xF000000) / 0x1000000);
registers.LbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
registers.LbaMid = (byte)((lba & 0xFF00) / 0x100);
registers.LbaLow = (byte)((lba & 0xFF) / 0x1);
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
@@ -132,29 +132,29 @@ namespace DiscImageChef.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();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
registers.command = (byte)AtaCommands.ReadNativeMaxAddress;
registers.deviceHead += 0x40;
registers.Command = (byte)AtaCommands.ReadNativeMaxAddress;
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
Error = LastError != 0;
if((statusRegisters.status & 0x23) == 0)
if((statusRegisters.Status & 0x23) == 0)
{
lba += (uint)(statusRegisters.deviceHead & 0xF);
lba += (uint)(statusRegisters.DeviceHead & 0xF);
lba *= 0x1000000;
lba += (uint)(statusRegisters.lbaHigh << 16);
lba += (uint)(statusRegisters.lbaMid << 8);
lba += statusRegisters.lbaLow;
lba += (uint)(statusRegisters.LbaHigh << 16);
lba += (uint)(statusRegisters.LbaMid << 8);
lba += statusRegisters.LbaLow;
}
DicConsole.DebugWriteLine("ATA Device", "READ NATIVE MAX ADDRESS took {0} ms.", duration);
@@ -162,28 +162,28 @@ namespace DiscImageChef.Devices
return sense;
}
public bool Read(out byte[] buffer, out AtaErrorRegistersLBA28 statusRegisters, uint lba, byte count,
public bool Read(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count,
uint timeout, out double duration)
{
return Read(out buffer, out statusRegisters, true, lba, count, timeout, out duration);
}
public bool Read(out byte[] buffer, out AtaErrorRegistersLBA28 statusRegisters, bool retry, uint lba,
public bool Read(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba,
byte count, uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 256];
else buffer = new byte[512 * count];
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
if(retry) registers.command = (byte)AtaCommands.ReadRetry;
else registers.command = (byte)AtaCommands.Read;
registers.sectorCount = count;
registers.deviceHead = (byte)((lba & 0xF000000) / 0x1000000);
registers.lbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
registers.lbaMid = (byte)((lba & 0xFF00) / 0x100);
registers.lbaLow = (byte)((lba & 0xFF) / 0x1);
registers.deviceHead += 0x40;
if(retry) registers.Command = (byte)AtaCommands.ReadRetry;
else registers.Command = (byte)AtaCommands.Read;
registers.SectorCount = count;
registers.DeviceHead = (byte)((lba & 0xF000000) / 0x1000000);
registers.LbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
registers.LbaMid = (byte)((lba & 0xFF00) / 0x100);
registers.LbaLow = (byte)((lba & 0xFF) / 0x1);
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
@@ -195,27 +195,27 @@ namespace DiscImageChef.Devices
return sense;
}
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersLBA28 statusRegisters, uint lba, uint blockSize,
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, uint blockSize,
uint timeout, out double duration)
{
return ReadLong(out buffer, out statusRegisters, true, lba, blockSize, timeout, out duration);
}
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersLBA28 statusRegisters, bool retry, uint lba,
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();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
if(retry) registers.command = (byte)AtaCommands.ReadLongRetry;
else registers.command = (byte)AtaCommands.ReadLong;
registers.sectorCount = 1;
registers.deviceHead = (byte)((lba & 0xF000000) / 0x1000000);
registers.lbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
registers.lbaMid = (byte)((lba & 0xFF00) / 0x100);
registers.lbaLow = (byte)((lba & 0xFF) / 0x1);
registers.deviceHead += 0x40;
if(retry) registers.Command = (byte)AtaCommands.ReadLongRetry;
else registers.Command = (byte)AtaCommands.ReadLong;
registers.SectorCount = 1;
registers.DeviceHead = (byte)((lba & 0xF000000) / 0x1000000);
registers.LbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
registers.LbaMid = (byte)((lba & 0xFF00) / 0x100);
registers.LbaLow = (byte)((lba & 0xFF) / 0x1);
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
@@ -227,18 +227,18 @@ namespace DiscImageChef.Devices
return sense;
}
public bool Seek(out AtaErrorRegistersLBA28 statusRegisters, uint lba, uint timeout, out double duration)
public bool Seek(out AtaErrorRegistersLba28 statusRegisters, uint lba, uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
registers.command = (byte)AtaCommands.Seek;
registers.deviceHead = (byte)((lba & 0xF000000) / 0x1000000);
registers.lbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
registers.lbaMid = (byte)((lba & 0xFF00) / 0x100);
registers.lbaLow = (byte)((lba & 0xFF) / 0x1);
registers.deviceHead += 0x40;
registers.Command = (byte)AtaCommands.Seek;
registers.DeviceHead = (byte)((lba & 0xF000000) / 0x1000000);
registers.LbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
registers.LbaMid = (byte)((lba & 0xFF00) / 0x100);
registers.LbaLow = (byte)((lba & 0xFF) / 0x1);
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,

View File

@@ -37,28 +37,28 @@ namespace DiscImageChef.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;
AtaRegistersLBA48 registers = new AtaRegistersLBA48();
AtaRegistersLba48 registers = new AtaRegistersLba48();
bool sense;
byte[] buffer = new byte[0];
registers.command = (byte)AtaCommands.NativeMaxAddress;
registers.feature = 0x0000;
registers.Command = (byte)AtaCommands.NativeMaxAddress;
registers.Feature = 0x0000;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
Error = LastError != 0;
if((statusRegisters.status & 0x23) == 0)
if((statusRegisters.Status & 0x23) == 0)
{
lba = statusRegisters.lbaHigh;
lba = statusRegisters.LbaHigh;
lba *= 0x100000000;
lba += (ulong)(statusRegisters.lbaMid << 16);
lba += statusRegisters.lbaLow;
lba += (ulong)(statusRegisters.LbaMid << 16);
lba += statusRegisters.LbaLow;
}
DicConsole.DebugWriteLine("ATA Device", "GET NATIVE MAX ADDRESS EXT took {0} ms.", duration);
@@ -66,20 +66,20 @@ namespace DiscImageChef.Devices
return sense;
}
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLBA48 statusRegisters, ulong lba, ushort count,
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 65536];
else buffer = new byte[512 * count];
AtaRegistersLBA48 registers = new AtaRegistersLBA48();
AtaRegistersLba48 registers = new AtaRegistersLba48();
bool sense;
registers.command = (byte)AtaCommands.ReadDmaExt;
registers.sectorCount = count;
registers.lbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000);
registers.lbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000);
registers.lbaLow = (ushort)((lba & 0xFFFF) / 0x1);
registers.deviceHead += 0x40;
registers.Command = (byte)AtaCommands.ReadDmaExt;
registers.SectorCount = count;
registers.LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000);
registers.LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000);
registers.LbaLow = (ushort)((lba & 0xFFFF) / 0x1);
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
ref buffer, timeout, true, out duration, out sense);
@@ -90,18 +90,18 @@ namespace DiscImageChef.Devices
return sense;
}
public bool ReadLog(out byte[] buffer, out AtaErrorRegistersLBA48 statusRegisters, byte logAddress,
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();
AtaRegistersLba48 registers = new AtaRegistersLba48();
bool sense;
registers.command = (byte)AtaCommands.ReadLogExt;
registers.sectorCount = count;
registers.lbaLow = (ushort)((pageNumber & 0xFF) * 0x100);
registers.lbaLow += logAddress;
registers.lbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100);
registers.Command = (byte)AtaCommands.ReadLogExt;
registers.SectorCount = count;
registers.LbaLow = (ushort)((pageNumber & 0xFF) * 0x100);
registers.LbaLow += logAddress;
registers.LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100);
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
@@ -113,18 +113,18 @@ namespace DiscImageChef.Devices
return sense;
}
public bool ReadLogDma(out byte[] buffer, out AtaErrorRegistersLBA48 statusRegisters, byte logAddress,
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();
AtaRegistersLba48 registers = new AtaRegistersLba48();
bool sense;
registers.command = (byte)AtaCommands.ReadLogDmaExt;
registers.sectorCount = count;
registers.lbaLow = (ushort)((pageNumber & 0xFF) * 0x100);
registers.lbaLow += logAddress;
registers.lbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100);
registers.Command = (byte)AtaCommands.ReadLogDmaExt;
registers.SectorCount = count;
registers.LbaLow = (ushort)((pageNumber & 0xFF) * 0x100);
registers.LbaLow += logAddress;
registers.LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100);
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
ref buffer, timeout, true, out duration, out sense);
@@ -135,20 +135,20 @@ namespace DiscImageChef.Devices
return sense;
}
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersLBA48 statusRegisters, ulong lba, ushort count,
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 65536];
else buffer = new byte[512 * count];
AtaRegistersLBA48 registers = new AtaRegistersLBA48();
AtaRegistersLba48 registers = new AtaRegistersLba48();
bool sense;
registers.command = (byte)AtaCommands.ReadMultipleExt;
registers.sectorCount = count;
registers.lbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000);
registers.lbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000);
registers.lbaLow = (ushort)((lba & 0xFFFF) / 0x1);
registers.deviceHead += 0x40;
registers.Command = (byte)AtaCommands.ReadMultipleExt;
registers.SectorCount = count;
registers.LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000);
registers.LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000);
registers.LbaLow = (ushort)((lba & 0xFFFF) / 0x1);
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
@@ -160,28 +160,28 @@ namespace DiscImageChef.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();
AtaRegistersLba48 registers = new AtaRegistersLba48();
bool sense;
registers.command = (byte)AtaCommands.ReadNativeMaxAddressExt;
registers.deviceHead += 0x40;
registers.Command = (byte)AtaCommands.ReadNativeMaxAddressExt;
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
Error = LastError != 0;
if((statusRegisters.status & 0x23) == 0)
if((statusRegisters.Status & 0x23) == 0)
{
lba = statusRegisters.lbaHigh;
lba = statusRegisters.LbaHigh;
lba *= 0x100000000;
lba += (ulong)(statusRegisters.lbaMid << 16);
lba += statusRegisters.lbaLow;
lba += (ulong)(statusRegisters.LbaMid << 16);
lba += statusRegisters.LbaLow;
}
DicConsole.DebugWriteLine("ATA Device", "READ NATIVE MAX ADDRESS EXT took {0} ms.", duration);
@@ -189,20 +189,20 @@ namespace DiscImageChef.Devices
return sense;
}
public bool Read(out byte[] buffer, out AtaErrorRegistersLBA48 statusRegisters, ulong lba, ushort count,
public bool Read(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 65536];
else buffer = new byte[512 * count];
AtaRegistersLBA48 registers = new AtaRegistersLBA48();
AtaRegistersLba48 registers = new AtaRegistersLba48();
bool sense;
registers.command = (byte)AtaCommands.ReadExt;
registers.sectorCount = count;
registers.lbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000);
registers.lbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000);
registers.lbaLow = (ushort)((lba & 0xFFFF) / 0x1);
registers.deviceHead += 0x40;
registers.Command = (byte)AtaCommands.ReadExt;
registers.SectorCount = count;
registers.LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000);
registers.LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000);
registers.LbaLow = (ushort)((lba & 0xFFFF) / 0x1);
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,

View File

@@ -43,7 +43,7 @@ namespace DiscImageChef.Devices
/// <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)
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters)
{
return AtaIdentify(out buffer, out statusRegisters, Timeout);
}
@@ -55,7 +55,7 @@ namespace DiscImageChef.Devices
/// <param name="buffer">Buffer.</param>
/// <param name="statusRegisters">Status registers.</param>
/// <param name="duration">Duration.</param>
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, out double duration)
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, out double duration)
{
return AtaIdentify(out buffer, out statusRegisters, Timeout, out duration);
}
@@ -67,7 +67,7 @@ namespace DiscImageChef.Devices
/// <param name="buffer">Buffer.</param>
/// <param name="statusRegisters">Status registers.</param>
/// <param name="timeout">Timeout.</param>
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, uint timeout)
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, uint timeout)
{
double duration;
return AtaIdentify(out buffer, out statusRegisters, timeout, out duration);
@@ -81,14 +81,14 @@ namespace DiscImageChef.Devices
/// <param name="statusRegisters">Status registers.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, uint timeout,
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, uint timeout,
out double duration)
{
buffer = new byte[512];
AtaRegistersCHS registers = new AtaRegistersCHS();
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
registers.command = (byte)AtaCommands.IdentifyDevice;
registers.Command = (byte)AtaCommands.IdentifyDevice;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
@@ -100,27 +100,27 @@ namespace DiscImageChef.Devices
return sense;
}
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, ushort cylinder, byte head,
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head,
byte sector, byte count, uint timeout, out double duration)
{
return 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,
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, bool retry, ushort cylinder,
byte head, byte sector, byte count, uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 256];
else buffer = new byte[512 * count];
AtaRegistersCHS registers = new AtaRegistersCHS();
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
if(retry) registers.command = (byte)AtaCommands.ReadDmaRetry;
else registers.command = (byte)AtaCommands.ReadDma;
registers.sectorCount = count;
registers.cylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
registers.cylinderLow = (byte)((cylinder & 0xFF) / 0x1);
registers.deviceHead = (byte)(head & 0x0F);
registers.sector = sector;
if(retry) registers.Command = (byte)AtaCommands.ReadDmaRetry;
else registers.Command = (byte)AtaCommands.ReadDma;
registers.SectorCount = count;
registers.CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
registers.CylinderLow = (byte)((cylinder & 0xFF) / 0x1);
registers.DeviceHead = (byte)(head & 0x0F);
registers.Sector = sector;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
ref buffer, timeout, true, out duration, out sense);
@@ -131,20 +131,20 @@ namespace DiscImageChef.Devices
return sense;
}
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, ushort cylinder,
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder,
byte head, byte sector, byte count, uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 256];
else buffer = new byte[512 * count];
AtaRegistersCHS registers = new AtaRegistersCHS();
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
registers.command = (byte)AtaCommands.ReadMultiple;
registers.sectorCount = count;
registers.cylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
registers.cylinderLow = (byte)((cylinder & 0xFF) / 0x1);
registers.deviceHead = (byte)(head & 0x0F);
registers.sector = sector;
registers.Command = (byte)AtaCommands.ReadMultiple;
registers.SectorCount = count;
registers.CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
registers.CylinderLow = (byte)((cylinder & 0xFF) / 0x1);
registers.DeviceHead = (byte)(head & 0x0F);
registers.Sector = sector;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
@@ -156,27 +156,27 @@ namespace DiscImageChef.Devices
return sense;
}
public bool Read(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, ushort cylinder, byte head,
public bool Read(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head,
byte sector, byte count, uint timeout, out double duration)
{
return 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,
public bool Read(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, bool retry, ushort cylinder,
byte head, byte sector, byte count, uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 256];
else buffer = new byte[512 * count];
AtaRegistersCHS registers = new AtaRegistersCHS();
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
if(retry) registers.command = (byte)AtaCommands.ReadRetry;
else registers.command = (byte)AtaCommands.Read;
registers.sectorCount = count;
registers.cylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
registers.cylinderLow = (byte)((cylinder & 0xFF) / 0x1);
registers.deviceHead = (byte)(head & 0x0F);
registers.sector = sector;
if(retry) registers.Command = (byte)AtaCommands.ReadRetry;
else registers.Command = (byte)AtaCommands.Read;
registers.SectorCount = count;
registers.CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
registers.CylinderLow = (byte)((cylinder & 0xFF) / 0x1);
registers.DeviceHead = (byte)(head & 0x0F);
registers.Sector = sector;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
@@ -188,27 +188,27 @@ namespace DiscImageChef.Devices
return sense;
}
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, ushort cylinder, byte head,
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head,
byte sector, uint blockSize, uint timeout, out double duration)
{
return 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,
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();
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
if(retry) registers.command = (byte)AtaCommands.ReadLongRetry;
else registers.command = (byte)AtaCommands.ReadLong;
registers.sectorCount = 1;
registers.cylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
registers.cylinderLow = (byte)((cylinder & 0xFF) / 0x1);
registers.deviceHead = (byte)(head & 0x0F);
registers.sector = sector;
if(retry) registers.Command = (byte)AtaCommands.ReadLongRetry;
else registers.Command = (byte)AtaCommands.ReadLong;
registers.SectorCount = 1;
registers.CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
registers.CylinderLow = (byte)((cylinder & 0xFF) / 0x1);
registers.DeviceHead = (byte)(head & 0x0F);
registers.Sector = sector;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
@@ -220,18 +220,18 @@ namespace DiscImageChef.Devices
return sense;
}
public bool Seek(out AtaErrorRegistersCHS statusRegisters, ushort cylinder, byte head, byte sector,
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();
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
registers.command = (byte)AtaCommands.Seek;
registers.cylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
registers.cylinderLow = (byte)((cylinder & 0xFF) / 0x1);
registers.deviceHead = (byte)(head & 0x0F);
registers.sector = sector;
registers.Command = (byte)AtaCommands.Seek;
registers.CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
registers.CylinderLow = (byte)((cylinder & 0xFF) / 0x1);
registers.DeviceHead = (byte)(head & 0x0F);
registers.Sector = sector;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, true, out duration,

View File

@@ -43,7 +43,7 @@ namespace DiscImageChef.Devices
/// <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)
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters)
{
return AtapiIdentify(out buffer, out statusRegisters, Timeout);
}
@@ -55,7 +55,7 @@ namespace DiscImageChef.Devices
/// <param name="buffer">Buffer.</param>
/// <param name="statusRegisters">Status registers.</param>
/// <param name="duration">Duration.</param>
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, out double duration)
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, out double duration)
{
return AtapiIdentify(out buffer, out statusRegisters, Timeout, out duration);
}
@@ -67,7 +67,7 @@ namespace DiscImageChef.Devices
/// <param name="buffer">Buffer.</param>
/// <param name="statusRegisters">Status registers.</param>
/// <param name="timeout">Timeout.</param>
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, uint timeout)
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, uint timeout)
{
double duration;
return AtapiIdentify(out buffer, out statusRegisters, timeout, out duration);
@@ -81,14 +81,14 @@ namespace DiscImageChef.Devices
/// <param name="statusRegisters">Status registers.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, uint timeout,
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, uint timeout,
out double duration)
{
buffer = new byte[512];
AtaRegistersCHS registers = new AtaRegistersCHS();
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
registers.command = (byte)AtaCommands.IdentifyPacketDevice;
registers.Command = (byte)AtaCommands.IdentifyPacketDevice;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,

View File

@@ -37,19 +37,19 @@ namespace DiscImageChef.Devices
{
public partial class Device
{
public bool TranslateSector(out byte[] buffer, out AtaErrorRegistersLBA28 statusRegisters, uint lba,
public bool TranslateSector(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba,
uint timeout, out double duration)
{
buffer = new byte[512];
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
registers.command = (byte)AtaCommands.TranslateSector;
registers.deviceHead = (byte)((lba & 0xF000000) / 0x1000000);
registers.lbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
registers.lbaMid = (byte)((lba & 0xFF00) / 0x100);
registers.lbaLow = (byte)((lba & 0xFF) / 0x1);
registers.deviceHead += 0x40;
registers.Command = (byte)AtaCommands.TranslateSector;
registers.DeviceHead = (byte)((lba & 0xF000000) / 0x1000000);
registers.LbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
registers.LbaMid = (byte)((lba & 0xFF00) / 0x100);
registers.LbaLow = (byte)((lba & 0xFF) / 0x1);
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
@@ -61,18 +61,18 @@ namespace DiscImageChef.Devices
return sense;
}
public bool TranslateSector(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, ushort cylinder,
public bool TranslateSector(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder,
byte head, byte sector, uint timeout, out double duration)
{
buffer = new byte[512];
AtaRegistersCHS registers = new AtaRegistersCHS();
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
registers.command = (byte)AtaCommands.TranslateSector;
registers.cylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
registers.cylinderLow = (byte)((cylinder & 0xFF) / 0x1);
registers.sector = sector;
registers.deviceHead = (byte)(head & 0x0F);
registers.Command = (byte)AtaCommands.TranslateSector;
registers.CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
registers.CylinderLow = (byte)((cylinder & 0xFF) / 0x1);
registers.Sector = sector;
registers.DeviceHead = (byte)(head & 0x0F);
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
@@ -84,21 +84,21 @@ namespace DiscImageChef.Devices
return sense;
}
public bool RequestExtendedErrorCode(out byte errorCode, out AtaErrorRegistersLBA28 statusRegisters,
public bool RequestExtendedErrorCode(out byte errorCode, out AtaErrorRegistersLba28 statusRegisters,
uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
registers.command = (byte)AtaCommands.RequestSense;
registers.Command = (byte)AtaCommands.RequestSense;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
Error = LastError != 0;
errorCode = statusRegisters.error;
errorCode = statusRegisters.Error;
DicConsole.DebugWriteLine("ATA Device", "CFA REQUEST EXTENDED ERROR CODE took {0} ms.", duration);

View File

@@ -37,27 +37,27 @@ namespace DiscImageChef.Devices
{
public partial class Device
{
public bool EnableMediaCardPassThrough(out AtaErrorRegistersCHS statusRegisters, uint timeout,
public bool EnableMediaCardPassThrough(out AtaErrorRegistersChs statusRegisters, uint timeout,
out double duration)
{
return CheckMediaCardType(1, out statusRegisters, timeout, out duration);
}
public bool DisableMediaCardPassThrough(out AtaErrorRegistersCHS statusRegisters, uint timeout,
public bool DisableMediaCardPassThrough(out AtaErrorRegistersChs statusRegisters, uint timeout,
out double duration)
{
return 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();
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
registers.command = (byte)AtaCommands.CheckMediaCardType;
registers.feature = feature;
registers.Command = (byte)AtaCommands.CheckMediaCardType;
registers.Feature = feature;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,

View File

@@ -37,16 +37,16 @@ namespace DiscImageChef.Devices
{
public partial class Device
{
public bool SmartDisable(out AtaErrorRegistersLBA28 statusRegisters, uint timeout, out double duration)
public bool SmartDisable(out AtaErrorRegistersLba28 statusRegisters, uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
registers.command = (byte)AtaCommands.Smart;
registers.feature = (byte)AtaSmartSubCommands.Disable;
registers.lbaHigh = 0xC2;
registers.lbaMid = 0x4F;
registers.Command = (byte)AtaCommands.Smart;
registers.Feature = (byte)AtaSmartSubCommands.Disable;
registers.LbaHigh = 0xC2;
registers.LbaMid = 0x4F;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
@@ -58,18 +58,18 @@ namespace DiscImageChef.Devices
return sense;
}
public bool SmartEnableAttributeAutosave(out AtaErrorRegistersLBA28 statusRegisters, uint timeout,
public bool SmartEnableAttributeAutosave(out AtaErrorRegistersLba28 statusRegisters, uint timeout,
out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
registers.command = (byte)AtaCommands.Smart;
registers.feature = (byte)AtaSmartSubCommands.EnableDisableAttributeAutosave;
registers.lbaHigh = 0xC2;
registers.lbaMid = 0x4F;
registers.sectorCount = 0xF1;
registers.Command = (byte)AtaCommands.Smart;
registers.Feature = (byte)AtaSmartSubCommands.EnableDisableAttributeAutosave;
registers.LbaHigh = 0xC2;
registers.LbaMid = 0x4F;
registers.SectorCount = 0xF1;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
@@ -81,17 +81,17 @@ namespace DiscImageChef.Devices
return sense;
}
public bool SmartDisableAttributeAutosave(out AtaErrorRegistersLBA28 statusRegisters, uint timeout,
public bool SmartDisableAttributeAutosave(out AtaErrorRegistersLba28 statusRegisters, uint timeout,
out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
registers.command = (byte)AtaCommands.Smart;
registers.feature = (byte)AtaSmartSubCommands.EnableDisableAttributeAutosave;
registers.lbaHigh = 0xC2;
registers.lbaMid = 0x4F;
registers.Command = (byte)AtaCommands.Smart;
registers.Feature = (byte)AtaSmartSubCommands.EnableDisableAttributeAutosave;
registers.LbaHigh = 0xC2;
registers.LbaMid = 0x4F;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
@@ -103,16 +103,16 @@ namespace DiscImageChef.Devices
return sense;
}
public bool SmartEnable(out AtaErrorRegistersLBA28 statusRegisters, uint timeout, out double duration)
public bool SmartEnable(out AtaErrorRegistersLba28 statusRegisters, uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
registers.command = (byte)AtaCommands.Smart;
registers.feature = (byte)AtaSmartSubCommands.Enable;
registers.lbaHigh = 0xC2;
registers.lbaMid = 0x4F;
registers.Command = (byte)AtaCommands.Smart;
registers.Feature = (byte)AtaSmartSubCommands.Enable;
registers.LbaHigh = 0xC2;
registers.LbaMid = 0x4F;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
@@ -124,18 +124,18 @@ namespace DiscImageChef.Devices
return sense;
}
public bool SmartExecuteOffLineImmediate(out AtaErrorRegistersLBA28 statusRegisters, byte subcommand,
public bool SmartExecuteOffLineImmediate(out AtaErrorRegistersLba28 statusRegisters, byte subcommand,
uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
registers.command = (byte)AtaCommands.Smart;
registers.feature = (byte)AtaSmartSubCommands.ExecuteOfflineImmediate;
registers.lbaHigh = 0xC2;
registers.lbaMid = 0x4F;
registers.lbaLow = subcommand;
registers.Command = (byte)AtaCommands.Smart;
registers.Feature = (byte)AtaSmartSubCommands.ExecuteOfflineImmediate;
registers.LbaHigh = 0xC2;
registers.LbaMid = 0x4F;
registers.LbaLow = subcommand;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
@@ -147,17 +147,17 @@ namespace DiscImageChef.Devices
return sense;
}
public bool SmartReadData(out byte[] buffer, out AtaErrorRegistersLBA28 statusRegisters, uint timeout,
public bool SmartReadData(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint timeout,
out double duration)
{
buffer = new byte[512];
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
registers.command = (byte)AtaCommands.Smart;
registers.feature = (byte)AtaSmartSubCommands.ReadData;
registers.lbaHigh = 0xC2;
registers.lbaMid = 0x4F;
registers.Command = (byte)AtaCommands.Smart;
registers.Feature = (byte)AtaSmartSubCommands.ReadData;
registers.LbaHigh = 0xC2;
registers.LbaMid = 0x4F;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
@@ -169,18 +169,18 @@ namespace DiscImageChef.Devices
return sense;
}
public bool SmartReadLog(out byte[] buffer, out AtaErrorRegistersLBA28 statusRegisters, byte logAddress,
public bool SmartReadLog(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, byte logAddress,
uint timeout, out double duration)
{
buffer = new byte[512];
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
registers.command = (byte)AtaCommands.Smart;
registers.feature = (byte)AtaSmartSubCommands.ReadLog;
registers.lbaHigh = 0xC2;
registers.lbaMid = 0x4F;
registers.lbaLow = logAddress;
registers.Command = (byte)AtaCommands.Smart;
registers.Feature = (byte)AtaSmartSubCommands.ReadLog;
registers.LbaHigh = 0xC2;
registers.LbaMid = 0x4F;
registers.LbaLow = logAddress;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
@@ -192,16 +192,16 @@ namespace DiscImageChef.Devices
return sense;
}
public bool SmartReturnStatus(out AtaErrorRegistersLBA28 statusRegisters, uint timeout, out double duration)
public bool SmartReturnStatus(out AtaErrorRegistersLba28 statusRegisters, uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
registers.command = (byte)AtaCommands.Smart;
registers.feature = (byte)AtaSmartSubCommands.ReturnStatus;
registers.lbaHigh = 0xC2;
registers.lbaMid = 0x4F;
registers.Command = (byte)AtaCommands.Smart;
registers.Feature = (byte)AtaSmartSubCommands.ReturnStatus;
registers.LbaHigh = 0xC2;
registers.LbaMid = 0x4F;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,

View File

@@ -68,7 +68,7 @@ namespace DiscImageChef.Devices
/// <param name="transferBlocks">If set to <c>true</c>, transfer is indicated in blocks, otherwise, it is indicated in bytes.</param>
/// <param name="duration">Time it took to execute the command in milliseconds</param>
/// <param name="sense"><c>True</c> if ATA/ATAPI command returned non-OK status</param>
public int SendAtaCommand(AtaRegistersCHS registers, out AtaErrorRegistersCHS errorRegisters,
public int SendAtaCommand(AtaRegistersChs registers, out AtaErrorRegistersChs errorRegisters,
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
uint timeout, bool transferBlocks, out double duration, out bool sense)
{
@@ -89,7 +89,7 @@ namespace DiscImageChef.Devices
/// <param name="transferBlocks">If set to <c>true</c>, transfer is indicated in blocks, otherwise, it is indicated in bytes.</param>
/// <param name="duration">Time it took to execute the command in milliseconds</param>
/// <param name="sense"><c>True</c> if ATA/ATAPI command returned non-OK status</param>
public int SendAtaCommand(AtaRegistersLBA28 registers, out AtaErrorRegistersLBA28 errorRegisters,
public int SendAtaCommand(AtaRegistersLba28 registers, out AtaErrorRegistersLba28 errorRegisters,
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
uint timeout, bool transferBlocks, out double duration, out bool sense)
{
@@ -110,7 +110,7 @@ namespace DiscImageChef.Devices
/// <param name="transferBlocks">If set to <c>true</c>, transfer is indicated in blocks, otherwise, it is indicated in bytes.</param>
/// <param name="duration">Time it took to execute the command in milliseconds</param>
/// <param name="sense"><c>True</c> if ATA/ATAPI command returned non-OK status</param>
public int SendAtaCommand(AtaRegistersLBA48 registers, out AtaErrorRegistersLBA48 errorRegisters,
public int SendAtaCommand(AtaRegistersLba48 registers, out AtaErrorRegistersLba48 errorRegisters,
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
uint timeout, bool transferBlocks, out double duration, out bool sense)
{

View File

@@ -125,7 +125,7 @@ namespace DiscImageChef.Devices
Type = DeviceType.Unknown;
ScsiType = PeripheralDeviceTypes.UnknownDevice;
AtaErrorRegistersCHS errorRegisters;
AtaErrorRegistersChs errorRegisters;
byte[] ataBuf;
byte[] senseBuf;

View File

@@ -271,13 +271,13 @@ namespace DiscImageChef.Devices.FreeBSD
}
}
internal static int SendAtaCommand(IntPtr dev, AtaRegistersCHS registers,
out AtaErrorRegistersCHS errorRegisters, AtaProtocol protocol,
internal static int SendAtaCommand(IntPtr dev, AtaRegistersChs registers,
out AtaErrorRegistersChs errorRegisters, AtaProtocol protocol,
ref byte[] buffer, uint timeout, out double duration, out bool sense)
{
duration = 0;
sense = false;
errorRegisters = new AtaErrorRegistersCHS();
errorRegisters = new AtaErrorRegistersChs();
if(buffer == null) return -1;
@@ -307,13 +307,13 @@ namespace DiscImageChef.Devices.FreeBSD
break;
}
ataio.cmd.command = registers.command;
ataio.cmd.lba_high = registers.cylinderHigh;
ataio.cmd.lba_mid = registers.cylinderLow;
ataio.cmd.device = (byte)(0x40 | registers.deviceHead);
ataio.cmd.features = registers.feature;
ataio.cmd.sector_count = registers.sectorCount;
ataio.cmd.lba_low = registers.sector;
ataio.cmd.command = registers.Command;
ataio.cmd.lba_high = registers.CylinderHigh;
ataio.cmd.lba_mid = registers.CylinderLow;
ataio.cmd.device = (byte)(0x40 | registers.DeviceHead);
ataio.cmd.features = registers.Feature;
ataio.cmd.sector_count = registers.SectorCount;
ataio.cmd.lba_low = registers.Sector;
Marshal.Copy(buffer, 0, ataio.data_ptr, buffer.Length);
Marshal.StructureToPtr(ataio, ccbPtr, false);
@@ -336,13 +336,13 @@ namespace DiscImageChef.Devices.FreeBSD
if((ataio.ccb_h.status & CamStatus.CamStatusMask) == CamStatus.CamAtaStatusError) sense = true;
errorRegisters.cylinderHigh = ataio.res.lba_high;
errorRegisters.cylinderLow = ataio.res.lba_mid;
errorRegisters.deviceHead = ataio.res.device;
errorRegisters.error = ataio.res.error;
errorRegisters.sector = ataio.res.lba_low;
errorRegisters.sectorCount = ataio.res.sector_count;
errorRegisters.status = ataio.res.status;
errorRegisters.CylinderHigh = ataio.res.lba_high;
errorRegisters.CylinderLow = ataio.res.lba_mid;
errorRegisters.DeviceHead = ataio.res.device;
errorRegisters.Error = ataio.res.error;
errorRegisters.Sector = ataio.res.lba_low;
errorRegisters.SectorCount = ataio.res.sector_count;
errorRegisters.Status = ataio.res.status;
buffer = new byte[ataio.dxfer_len];
@@ -352,18 +352,18 @@ namespace DiscImageChef.Devices.FreeBSD
Marshal.FreeHGlobal(ataio.data_ptr);
cam_freeccb(ccbPtr);
sense = errorRegisters.error != 0 || (errorRegisters.status & 0xA5) != 0 || error != 0;
sense = errorRegisters.Error != 0 || (errorRegisters.Status & 0xA5) != 0 || error != 0;
return error;
}
internal static int SendAtaCommand(IntPtr dev, AtaRegistersLBA28 registers,
out AtaErrorRegistersLBA28 errorRegisters, AtaProtocol protocol,
internal static int SendAtaCommand(IntPtr dev, AtaRegistersLba28 registers,
out AtaErrorRegistersLba28 errorRegisters, AtaProtocol protocol,
ref byte[] buffer, uint timeout, out double duration, out bool sense)
{
duration = 0;
sense = false;
errorRegisters = new AtaErrorRegistersLBA28();
errorRegisters = new AtaErrorRegistersLba28();
if(buffer == null) return -1;
@@ -393,13 +393,13 @@ namespace DiscImageChef.Devices.FreeBSD
break;
}
ataio.cmd.command = registers.command;
ataio.cmd.lba_high = registers.lbaHigh;
ataio.cmd.lba_mid = registers.lbaMid;
ataio.cmd.device = (byte)(0x40 | registers.deviceHead);
ataio.cmd.features = registers.feature;
ataio.cmd.sector_count = registers.sectorCount;
ataio.cmd.lba_low = registers.lbaLow;
ataio.cmd.command = registers.Command;
ataio.cmd.lba_high = registers.LbaHigh;
ataio.cmd.lba_mid = registers.LbaMid;
ataio.cmd.device = (byte)(0x40 | registers.DeviceHead);
ataio.cmd.features = registers.Feature;
ataio.cmd.sector_count = registers.SectorCount;
ataio.cmd.lba_low = registers.LbaLow;
Marshal.Copy(buffer, 0, ataio.data_ptr, buffer.Length);
Marshal.StructureToPtr(ataio, ccbPtr, false);
@@ -422,13 +422,13 @@ namespace DiscImageChef.Devices.FreeBSD
if((ataio.ccb_h.status & CamStatus.CamStatusMask) == CamStatus.CamAtaStatusError) sense = true;
errorRegisters.lbaHigh = ataio.res.lba_high;
errorRegisters.lbaMid = ataio.res.lba_mid;
errorRegisters.deviceHead = ataio.res.device;
errorRegisters.error = ataio.res.error;
errorRegisters.lbaLow = ataio.res.lba_low;
errorRegisters.sectorCount = ataio.res.sector_count;
errorRegisters.status = ataio.res.status;
errorRegisters.LbaHigh = ataio.res.lba_high;
errorRegisters.LbaMid = ataio.res.lba_mid;
errorRegisters.DeviceHead = ataio.res.device;
errorRegisters.Error = ataio.res.error;
errorRegisters.LbaLow = ataio.res.lba_low;
errorRegisters.SectorCount = ataio.res.sector_count;
errorRegisters.Status = ataio.res.status;
buffer = new byte[ataio.dxfer_len];
@@ -438,18 +438,18 @@ namespace DiscImageChef.Devices.FreeBSD
Marshal.FreeHGlobal(ataio.data_ptr);
cam_freeccb(ccbPtr);
sense = errorRegisters.error != 0 || (errorRegisters.status & 0xA5) != 0 || error != 0;
sense = errorRegisters.Error != 0 || (errorRegisters.Status & 0xA5) != 0 || error != 0;
return error;
}
internal static int SendAtaCommand(IntPtr dev, AtaRegistersLBA48 registers,
out AtaErrorRegistersLBA48 errorRegisters, AtaProtocol protocol,
internal static int SendAtaCommand(IntPtr dev, AtaRegistersLba48 registers,
out AtaErrorRegistersLba48 errorRegisters, AtaProtocol protocol,
ref byte[] buffer, uint timeout, out double duration, out bool sense)
{
duration = 0;
sense = false;
errorRegisters = new AtaErrorRegistersLBA48();
errorRegisters = new AtaErrorRegistersLba48();
// 48-bit ATA CAM commands can crash FreeBSD < 9.2-RELEASE
if(Environment.Version.Major == 9 && Environment.Version.Minor < 2 ||
@@ -483,18 +483,18 @@ namespace DiscImageChef.Devices.FreeBSD
break;
}
ataio.cmd.lba_high_exp = (byte)((registers.lbaHigh & 0xFF00) >> 8);
ataio.cmd.lba_mid_exp = (byte)((registers.lbaMid & 0xFF00) >> 8);
ataio.cmd.features_exp = (byte)((registers.feature & 0xFF00) >> 8);
ataio.cmd.sector_count_exp = (byte)((registers.sectorCount & 0xFF00) >> 8);
ataio.cmd.lba_low_exp = (byte)((registers.lbaLow & 0xFF00) >> 8);
ataio.cmd.lba_high = (byte)(registers.lbaHigh & 0xFF);
ataio.cmd.lba_mid = (byte)(registers.lbaMid & 0xFF);
ataio.cmd.features = (byte)(registers.feature & 0xFF);
ataio.cmd.sector_count = (byte)(registers.sectorCount & 0xFF);
ataio.cmd.lba_low = (byte)(registers.lbaLow & 0xFF);
ataio.cmd.command = registers.command;
ataio.cmd.device = (byte)(0x40 | registers.deviceHead);
ataio.cmd.lba_high_exp = (byte)((registers.LbaHigh & 0xFF00) >> 8);
ataio.cmd.lba_mid_exp = (byte)((registers.LbaMid & 0xFF00) >> 8);
ataio.cmd.features_exp = (byte)((registers.Feature & 0xFF00) >> 8);
ataio.cmd.sector_count_exp = (byte)((registers.SectorCount & 0xFF00) >> 8);
ataio.cmd.lba_low_exp = (byte)((registers.LbaLow & 0xFF00) >> 8);
ataio.cmd.lba_high = (byte)(registers.LbaHigh & 0xFF);
ataio.cmd.lba_mid = (byte)(registers.LbaMid & 0xFF);
ataio.cmd.features = (byte)(registers.Feature & 0xFF);
ataio.cmd.sector_count = (byte)(registers.SectorCount & 0xFF);
ataio.cmd.lba_low = (byte)(registers.LbaLow & 0xFF);
ataio.cmd.command = registers.Command;
ataio.cmd.device = (byte)(0x40 | registers.DeviceHead);
Marshal.Copy(buffer, 0, ataio.data_ptr, buffer.Length);
Marshal.StructureToPtr(ataio, ccbPtr, false);
@@ -517,13 +517,13 @@ namespace DiscImageChef.Devices.FreeBSD
if((ataio.ccb_h.status & CamStatus.CamStatusMask) == CamStatus.CamAtaStatusError) sense = true;
errorRegisters.sectorCount = (ushort)((ataio.res.sector_count_exp << 8) + ataio.res.sector_count);
errorRegisters.lbaLow = (ushort)((ataio.res.lba_low_exp << 8) + ataio.res.lba_low);
errorRegisters.lbaMid = (ushort)((ataio.res.lba_mid_exp << 8) + ataio.res.lba_mid);
errorRegisters.lbaHigh = (ushort)((ataio.res.lba_high_exp << 8) + ataio.res.lba_high);
errorRegisters.deviceHead = ataio.res.device;
errorRegisters.error = ataio.res.error;
errorRegisters.status = ataio.res.status;
errorRegisters.SectorCount = (ushort)((ataio.res.sector_count_exp << 8) + ataio.res.sector_count);
errorRegisters.LbaLow = (ushort)((ataio.res.lba_low_exp << 8) + ataio.res.lba_low);
errorRegisters.LbaMid = (ushort)((ataio.res.lba_mid_exp << 8) + ataio.res.lba_mid);
errorRegisters.LbaHigh = (ushort)((ataio.res.lba_high_exp << 8) + ataio.res.lba_high);
errorRegisters.DeviceHead = ataio.res.device;
errorRegisters.Error = ataio.res.error;
errorRegisters.Status = ataio.res.status;
buffer = new byte[ataio.dxfer_len];
@@ -533,7 +533,7 @@ namespace DiscImageChef.Devices.FreeBSD
Marshal.FreeHGlobal(ataio.data_ptr);
cam_freeccb(ccbPtr);
sense = errorRegisters.error != 0 || (errorRegisters.status & 0xA5) != 0 || error != 0;
sense = errorRegisters.Error != 0 || (errorRegisters.Status & 0xA5) != 0 || error != 0;
return error;
}

View File

@@ -120,14 +120,14 @@ namespace DiscImageChef.Devices.Linux
}
}
internal static int SendAtaCommand(int fd, AtaRegistersCHS registers, out AtaErrorRegistersCHS errorRegisters,
internal static int SendAtaCommand(int fd, AtaRegistersChs registers, out AtaErrorRegistersChs errorRegisters,
AtaProtocol protocol, AtaTransferRegister transferRegister,
ref byte[] buffer, uint timeout, bool transferBlocks, out double duration,
out bool sense)
{
duration = 0;
sense = false;
errorRegisters = new AtaErrorRegistersCHS();
errorRegisters = new AtaErrorRegistersChs();
if(buffer == null) return -1;
@@ -154,13 +154,13 @@ namespace DiscImageChef.Devices.Linux
//cdb[2] |= 0x20;
cdb[4] = registers.feature;
cdb[6] = registers.sectorCount;
cdb[8] = registers.sector;
cdb[10] = registers.cylinderLow;
cdb[12] = registers.cylinderHigh;
cdb[13] = registers.deviceHead;
cdb[14] = registers.command;
cdb[4] = registers.Feature;
cdb[6] = registers.SectorCount;
cdb[8] = registers.Sector;
cdb[10] = registers.CylinderLow;
cdb[12] = registers.CylinderHigh;
cdb[13] = registers.DeviceHead;
cdb[14] = registers.Command;
byte[] senseBuffer;
int error = SendScsiCommand(fd, cdb, ref buffer, out senseBuffer, timeout,
@@ -168,28 +168,28 @@ namespace DiscImageChef.Devices.Linux
if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error;
errorRegisters.error = senseBuffer[11];
errorRegisters.Error = senseBuffer[11];
errorRegisters.sectorCount = senseBuffer[13];
errorRegisters.sector = senseBuffer[15];
errorRegisters.cylinderLow = senseBuffer[17];
errorRegisters.cylinderHigh = senseBuffer[19];
errorRegisters.deviceHead = senseBuffer[20];
errorRegisters.status = senseBuffer[21];
errorRegisters.SectorCount = senseBuffer[13];
errorRegisters.Sector = senseBuffer[15];
errorRegisters.CylinderLow = senseBuffer[17];
errorRegisters.CylinderHigh = senseBuffer[19];
errorRegisters.DeviceHead = senseBuffer[20];
errorRegisters.Status = senseBuffer[21];
sense = errorRegisters.error != 0 || (errorRegisters.status & 0xA5) != 0;
sense = errorRegisters.Error != 0 || (errorRegisters.Status & 0xA5) != 0;
return error;
}
internal static int SendAtaCommand(int fd, AtaRegistersLBA28 registers,
out AtaErrorRegistersLBA28 errorRegisters, AtaProtocol protocol,
internal static int SendAtaCommand(int fd, AtaRegistersLba28 registers,
out AtaErrorRegistersLba28 errorRegisters, AtaProtocol protocol,
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{
duration = 0;
sense = false;
errorRegisters = new AtaErrorRegistersLBA28();
errorRegisters = new AtaErrorRegistersLba28();
if(buffer == null) return -1;
@@ -216,13 +216,13 @@ namespace DiscImageChef.Devices.Linux
cdb[2] |= 0x20;
cdb[4] = registers.feature;
cdb[6] = registers.sectorCount;
cdb[8] = registers.lbaLow;
cdb[10] = registers.lbaMid;
cdb[12] = registers.lbaHigh;
cdb[13] = registers.deviceHead;
cdb[14] = registers.command;
cdb[4] = registers.Feature;
cdb[6] = registers.SectorCount;
cdb[8] = registers.LbaLow;
cdb[10] = registers.LbaMid;
cdb[12] = registers.LbaHigh;
cdb[13] = registers.DeviceHead;
cdb[14] = registers.Command;
byte[] senseBuffer;
int error = SendScsiCommand(fd, cdb, ref buffer, out senseBuffer, timeout,
@@ -230,28 +230,28 @@ namespace DiscImageChef.Devices.Linux
if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error;
errorRegisters.error = senseBuffer[11];
errorRegisters.Error = senseBuffer[11];
errorRegisters.sectorCount = senseBuffer[13];
errorRegisters.lbaLow = senseBuffer[15];
errorRegisters.lbaMid = senseBuffer[17];
errorRegisters.lbaHigh = senseBuffer[19];
errorRegisters.deviceHead = senseBuffer[20];
errorRegisters.status = senseBuffer[21];
errorRegisters.SectorCount = senseBuffer[13];
errorRegisters.LbaLow = senseBuffer[15];
errorRegisters.LbaMid = senseBuffer[17];
errorRegisters.LbaHigh = senseBuffer[19];
errorRegisters.DeviceHead = senseBuffer[20];
errorRegisters.Status = senseBuffer[21];
sense = errorRegisters.error != 0 || (errorRegisters.status & 0xA5) != 0;
sense = errorRegisters.Error != 0 || (errorRegisters.Status & 0xA5) != 0;
return error;
}
internal static int SendAtaCommand(int fd, AtaRegistersLBA48 registers,
out AtaErrorRegistersLBA48 errorRegisters, AtaProtocol protocol,
internal static int SendAtaCommand(int fd, AtaRegistersLba48 registers,
out AtaErrorRegistersLba48 errorRegisters, AtaProtocol protocol,
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{
duration = 0;
sense = false;
errorRegisters = new AtaErrorRegistersLBA48();
errorRegisters = new AtaErrorRegistersLba48();
if(buffer == null) return -1;
@@ -279,18 +279,18 @@ namespace DiscImageChef.Devices.Linux
cdb[2] |= 0x20;
cdb[3] = (byte)((registers.feature & 0xFF00) >> 8);
cdb[4] = (byte)(registers.feature & 0xFF);
cdb[5] = (byte)((registers.sectorCount & 0xFF00) >> 8);
cdb[6] = (byte)(registers.sectorCount & 0xFF);
cdb[7] = (byte)((registers.lbaLow & 0xFF00) >> 8);
cdb[8] = (byte)(registers.lbaLow & 0xFF);
cdb[9] = (byte)((registers.lbaMid & 0xFF00) >> 8);
cdb[10] = (byte)(registers.lbaMid & 0xFF);
cdb[11] = (byte)((registers.lbaHigh & 0xFF00) >> 8);
cdb[12] = (byte)(registers.lbaHigh & 0xFF);
cdb[13] = registers.deviceHead;
cdb[14] = registers.command;
cdb[3] = (byte)((registers.Feature & 0xFF00) >> 8);
cdb[4] = (byte)(registers.Feature & 0xFF);
cdb[5] = (byte)((registers.SectorCount & 0xFF00) >> 8);
cdb[6] = (byte)(registers.SectorCount & 0xFF);
cdb[7] = (byte)((registers.LbaLow & 0xFF00) >> 8);
cdb[8] = (byte)(registers.LbaLow & 0xFF);
cdb[9] = (byte)((registers.LbaMid & 0xFF00) >> 8);
cdb[10] = (byte)(registers.LbaMid & 0xFF);
cdb[11] = (byte)((registers.LbaHigh & 0xFF00) >> 8);
cdb[12] = (byte)(registers.LbaHigh & 0xFF);
cdb[13] = registers.DeviceHead;
cdb[14] = registers.Command;
byte[] senseBuffer;
int error = SendScsiCommand(fd, cdb, ref buffer, out senseBuffer, timeout,
@@ -298,16 +298,16 @@ namespace DiscImageChef.Devices.Linux
if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error;
errorRegisters.error = senseBuffer[11];
errorRegisters.Error = senseBuffer[11];
errorRegisters.sectorCount = (ushort)((senseBuffer[12] << 8) + senseBuffer[13]);
errorRegisters.lbaLow = (ushort)((senseBuffer[14] << 8) + senseBuffer[15]);
errorRegisters.lbaMid = (ushort)((senseBuffer[16] << 8) + senseBuffer[17]);
errorRegisters.lbaHigh = (ushort)((senseBuffer[18] << 8) + senseBuffer[19]);
errorRegisters.deviceHead = senseBuffer[20];
errorRegisters.status = senseBuffer[21];
errorRegisters.SectorCount = (ushort)((senseBuffer[12] << 8) + senseBuffer[13]);
errorRegisters.LbaLow = (ushort)((senseBuffer[14] << 8) + senseBuffer[15]);
errorRegisters.LbaMid = (ushort)((senseBuffer[16] << 8) + senseBuffer[17]);
errorRegisters.LbaHigh = (ushort)((senseBuffer[18] << 8) + senseBuffer[19]);
errorRegisters.DeviceHead = senseBuffer[20];
errorRegisters.Status = senseBuffer[21];
sense = errorRegisters.error != 0 || (errorRegisters.status & 0xA5) != 0;
sense = errorRegisters.Error != 0 || (errorRegisters.Status & 0xA5) != 0;
sense |= error != 0;

View File

@@ -104,13 +104,13 @@ namespace DiscImageChef.Devices.Windows
return error;
}
internal static int SendAtaCommand(SafeFileHandle fd, AtaRegistersCHS registers,
out AtaErrorRegistersCHS errorRegisters, AtaProtocol protocol,
internal static int SendAtaCommand(SafeFileHandle fd, AtaRegistersChs registers,
out AtaErrorRegistersChs errorRegisters, AtaProtocol protocol,
ref byte[] buffer, uint timeout, out double duration, out bool sense)
{
duration = 0;
sense = false;
errorRegisters = new AtaErrorRegistersCHS();
errorRegisters = new AtaErrorRegistersChs();
if(buffer == null) return -1;
@@ -127,13 +127,13 @@ namespace DiscImageChef.Devices.Windows
PreviousTaskFile = new AtaTaskFile(),
CurrentTaskFile = new AtaTaskFile
{
Command = registers.command,
CylinderHigh = registers.cylinderHigh,
CylinderLow = registers.cylinderLow,
DeviceHead = registers.deviceHead,
Features = registers.feature,
SectorCount = registers.sectorCount,
SectorNumber = registers.sector
Command = registers.Command,
CylinderHigh = registers.CylinderHigh,
CylinderLow = registers.CylinderLow,
DeviceHead = registers.DeviceHead,
Features = registers.Feature,
SectorCount = registers.SectorCount,
SectorNumber = registers.Sector
}
},
dataBuffer = new byte[64 * 512]
@@ -180,27 +180,27 @@ namespace DiscImageChef.Devices.Windows
duration = (end - start).TotalMilliseconds;
errorRegisters.command = aptdBuf.aptd.CurrentTaskFile.Command;
errorRegisters.cylinderHigh = aptdBuf.aptd.CurrentTaskFile.CylinderHigh;
errorRegisters.cylinderLow = aptdBuf.aptd.CurrentTaskFile.CylinderLow;
errorRegisters.deviceHead = aptdBuf.aptd.CurrentTaskFile.DeviceHead;
errorRegisters.error = aptdBuf.aptd.CurrentTaskFile.Error;
errorRegisters.sector = aptdBuf.aptd.CurrentTaskFile.SectorNumber;
errorRegisters.sectorCount = aptdBuf.aptd.CurrentTaskFile.SectorCount;
errorRegisters.status = aptdBuf.aptd.CurrentTaskFile.Status;
errorRegisters.Command = aptdBuf.aptd.CurrentTaskFile.Command;
errorRegisters.CylinderHigh = aptdBuf.aptd.CurrentTaskFile.CylinderHigh;
errorRegisters.CylinderLow = aptdBuf.aptd.CurrentTaskFile.CylinderLow;
errorRegisters.DeviceHead = aptdBuf.aptd.CurrentTaskFile.DeviceHead;
errorRegisters.Error = aptdBuf.aptd.CurrentTaskFile.Error;
errorRegisters.Sector = aptdBuf.aptd.CurrentTaskFile.SectorNumber;
errorRegisters.SectorCount = aptdBuf.aptd.CurrentTaskFile.SectorCount;
errorRegisters.Status = aptdBuf.aptd.CurrentTaskFile.Status;
sense = errorRegisters.error != 0 || (errorRegisters.status & 0xA5) != 0;
sense = errorRegisters.Error != 0 || (errorRegisters.Status & 0xA5) != 0;
return error;
}
internal static int SendAtaCommand(SafeFileHandle fd, AtaRegistersLBA28 registers,
out AtaErrorRegistersLBA28 errorRegisters, AtaProtocol protocol,
internal static int SendAtaCommand(SafeFileHandle fd, AtaRegistersLba28 registers,
out AtaErrorRegistersLba28 errorRegisters, AtaProtocol protocol,
ref byte[] buffer, uint timeout, out double duration, out bool sense)
{
duration = 0;
sense = false;
errorRegisters = new AtaErrorRegistersLBA28();
errorRegisters = new AtaErrorRegistersLba28();
if(buffer == null) return -1;
@@ -217,13 +217,13 @@ namespace DiscImageChef.Devices.Windows
PreviousTaskFile = new AtaTaskFile(),
CurrentTaskFile = new AtaTaskFile
{
Command = registers.command,
CylinderHigh = registers.lbaHigh,
CylinderLow = registers.lbaMid,
DeviceHead = registers.deviceHead,
Features = registers.feature,
SectorCount = registers.sectorCount,
SectorNumber = registers.lbaLow
Command = registers.Command,
CylinderHigh = registers.LbaHigh,
CylinderLow = registers.LbaMid,
DeviceHead = registers.DeviceHead,
Features = registers.Feature,
SectorCount = registers.SectorCount,
SectorNumber = registers.LbaLow
}
},
dataBuffer = new byte[64 * 512]
@@ -270,27 +270,27 @@ namespace DiscImageChef.Devices.Windows
duration = (end - start).TotalMilliseconds;
errorRegisters.command = aptdBuf.aptd.CurrentTaskFile.Command;
errorRegisters.lbaHigh = aptdBuf.aptd.CurrentTaskFile.CylinderHigh;
errorRegisters.lbaMid = aptdBuf.aptd.CurrentTaskFile.CylinderLow;
errorRegisters.deviceHead = aptdBuf.aptd.CurrentTaskFile.DeviceHead;
errorRegisters.error = aptdBuf.aptd.CurrentTaskFile.Error;
errorRegisters.lbaLow = aptdBuf.aptd.CurrentTaskFile.SectorNumber;
errorRegisters.sectorCount = aptdBuf.aptd.CurrentTaskFile.SectorCount;
errorRegisters.status = aptdBuf.aptd.CurrentTaskFile.Status;
errorRegisters.Command = aptdBuf.aptd.CurrentTaskFile.Command;
errorRegisters.LbaHigh = aptdBuf.aptd.CurrentTaskFile.CylinderHigh;
errorRegisters.LbaMid = aptdBuf.aptd.CurrentTaskFile.CylinderLow;
errorRegisters.DeviceHead = aptdBuf.aptd.CurrentTaskFile.DeviceHead;
errorRegisters.Error = aptdBuf.aptd.CurrentTaskFile.Error;
errorRegisters.LbaLow = aptdBuf.aptd.CurrentTaskFile.SectorNumber;
errorRegisters.SectorCount = aptdBuf.aptd.CurrentTaskFile.SectorCount;
errorRegisters.Status = aptdBuf.aptd.CurrentTaskFile.Status;
sense = errorRegisters.error != 0 || (errorRegisters.status & 0xA5) != 0;
sense = errorRegisters.Error != 0 || (errorRegisters.Status & 0xA5) != 0;
return error;
}
internal static int SendAtaCommand(SafeFileHandle fd, AtaRegistersLBA48 registers,
out AtaErrorRegistersLBA48 errorRegisters, AtaProtocol protocol,
internal static int SendAtaCommand(SafeFileHandle fd, AtaRegistersLba48 registers,
out AtaErrorRegistersLba48 errorRegisters, AtaProtocol protocol,
ref byte[] buffer, uint timeout, out double duration, out bool sense)
{
duration = 0;
sense = false;
errorRegisters = new AtaErrorRegistersLBA48();
errorRegisters = new AtaErrorRegistersLba48();
if(buffer == null) return -1;
@@ -307,21 +307,21 @@ namespace DiscImageChef.Devices.Windows
PreviousTaskFile =
new AtaTaskFile
{
CylinderHigh = (byte)((registers.lbaHigh & 0xFF00) >> 8),
CylinderLow = (byte)((registers.lbaMid & 0xFF00) >> 8),
Features = (byte)((registers.feature & 0xFF00) >> 8),
SectorCount = (byte)((registers.sectorCount & 0xFF00) >> 8),
SectorNumber = (byte)((registers.lbaLow & 0xFF00) >> 8)
CylinderHigh = (byte)((registers.LbaHigh & 0xFF00) >> 8),
CylinderLow = (byte)((registers.LbaMid & 0xFF00) >> 8),
Features = (byte)((registers.Feature & 0xFF00) >> 8),
SectorCount = (byte)((registers.SectorCount & 0xFF00) >> 8),
SectorNumber = (byte)((registers.LbaLow & 0xFF00) >> 8)
},
CurrentTaskFile = new AtaTaskFile
{
Command = registers.command,
CylinderHigh = (byte)(registers.lbaHigh & 0xFF),
CylinderLow = (byte)(registers.lbaMid & 0xFF),
DeviceHead = registers.deviceHead,
Features = (byte)(registers.feature & 0xFF),
SectorCount = (byte)(registers.sectorCount & 0xFF),
SectorNumber = (byte)(registers.lbaLow & 0xFF)
Command = registers.Command,
CylinderHigh = (byte)(registers.LbaHigh & 0xFF),
CylinderLow = (byte)(registers.LbaMid & 0xFF),
DeviceHead = registers.DeviceHead,
Features = (byte)(registers.Feature & 0xFF),
SectorCount = (byte)(registers.SectorCount & 0xFF),
SectorNumber = (byte)(registers.LbaLow & 0xFF)
}
},
dataBuffer = new byte[64 * 512]
@@ -368,31 +368,31 @@ namespace DiscImageChef.Devices.Windows
duration = (end - start).TotalMilliseconds;
errorRegisters.sectorCount = (ushort)((aptdBuf.aptd.PreviousTaskFile.SectorCount << 8) +
errorRegisters.SectorCount = (ushort)((aptdBuf.aptd.PreviousTaskFile.SectorCount << 8) +
aptdBuf.aptd.CurrentTaskFile.SectorCount);
errorRegisters.lbaLow = (ushort)((aptdBuf.aptd.PreviousTaskFile.SectorNumber << 8) +
errorRegisters.LbaLow = (ushort)((aptdBuf.aptd.PreviousTaskFile.SectorNumber << 8) +
aptdBuf.aptd.CurrentTaskFile.SectorNumber);
errorRegisters.lbaMid = (ushort)((aptdBuf.aptd.PreviousTaskFile.CylinderLow << 8) +
errorRegisters.LbaMid = (ushort)((aptdBuf.aptd.PreviousTaskFile.CylinderLow << 8) +
aptdBuf.aptd.CurrentTaskFile.CylinderLow);
errorRegisters.lbaHigh = (ushort)((aptdBuf.aptd.PreviousTaskFile.CylinderHigh << 8) +
errorRegisters.LbaHigh = (ushort)((aptdBuf.aptd.PreviousTaskFile.CylinderHigh << 8) +
aptdBuf.aptd.CurrentTaskFile.CylinderHigh);
errorRegisters.command = aptdBuf.aptd.CurrentTaskFile.Command;
errorRegisters.deviceHead = aptdBuf.aptd.CurrentTaskFile.DeviceHead;
errorRegisters.error = aptdBuf.aptd.CurrentTaskFile.Error;
errorRegisters.status = aptdBuf.aptd.CurrentTaskFile.Status;
errorRegisters.Command = aptdBuf.aptd.CurrentTaskFile.Command;
errorRegisters.DeviceHead = aptdBuf.aptd.CurrentTaskFile.DeviceHead;
errorRegisters.Error = aptdBuf.aptd.CurrentTaskFile.Error;
errorRegisters.Status = aptdBuf.aptd.CurrentTaskFile.Status;
sense = errorRegisters.error != 0 || (errorRegisters.status & 0xA5) != 0;
sense = errorRegisters.Error != 0 || (errorRegisters.Status & 0xA5) != 0;
return error;
}
internal static int SendIdeCommand(SafeFileHandle fd, AtaRegistersCHS registers,
out AtaErrorRegistersCHS errorRegisters, AtaProtocol protocol,
internal static int SendIdeCommand(SafeFileHandle fd, AtaRegistersChs registers,
out AtaErrorRegistersChs errorRegisters, AtaProtocol protocol,
ref byte[] buffer, uint timeout, out double duration, out bool sense)
{
duration = 0;
sense = false;
errorRegisters = new AtaErrorRegistersCHS();
errorRegisters = new AtaErrorRegistersChs();
if(buffer == null || buffer.Length > 512) return -1;
@@ -400,13 +400,13 @@ namespace DiscImageChef.Devices.Windows
{
CurrentTaskFile = new AtaTaskFile
{
Command = registers.command,
CylinderHigh = registers.cylinderHigh,
CylinderLow = registers.cylinderLow,
DeviceHead = registers.deviceHead,
Features = registers.feature,
SectorCount = registers.sectorCount,
SectorNumber = registers.sector
Command = registers.Command,
CylinderHigh = registers.CylinderHigh,
CylinderLow = registers.CylinderLow,
DeviceHead = registers.DeviceHead,
Features = registers.Feature,
SectorCount = registers.SectorCount,
SectorNumber = registers.Sector
},
DataBufferSize = 512,
DataBuffer = new byte[512]
@@ -430,27 +430,27 @@ namespace DiscImageChef.Devices.Windows
duration = (end - start).TotalMilliseconds;
errorRegisters.command = iptd.CurrentTaskFile.Command;
errorRegisters.cylinderHigh = iptd.CurrentTaskFile.CylinderHigh;
errorRegisters.cylinderLow = iptd.CurrentTaskFile.CylinderLow;
errorRegisters.deviceHead = iptd.CurrentTaskFile.DeviceHead;
errorRegisters.error = iptd.CurrentTaskFile.Error;
errorRegisters.sector = iptd.CurrentTaskFile.SectorNumber;
errorRegisters.sectorCount = iptd.CurrentTaskFile.SectorCount;
errorRegisters.status = iptd.CurrentTaskFile.Status;
errorRegisters.Command = iptd.CurrentTaskFile.Command;
errorRegisters.CylinderHigh = iptd.CurrentTaskFile.CylinderHigh;
errorRegisters.CylinderLow = iptd.CurrentTaskFile.CylinderLow;
errorRegisters.DeviceHead = iptd.CurrentTaskFile.DeviceHead;
errorRegisters.Error = iptd.CurrentTaskFile.Error;
errorRegisters.Sector = iptd.CurrentTaskFile.SectorNumber;
errorRegisters.SectorCount = iptd.CurrentTaskFile.SectorCount;
errorRegisters.Status = iptd.CurrentTaskFile.Status;
sense = errorRegisters.error != 0 || (errorRegisters.status & 0xA5) != 0;
sense = errorRegisters.Error != 0 || (errorRegisters.Status & 0xA5) != 0;
return error;
}
internal static int SendIdeCommand(SafeFileHandle fd, AtaRegistersLBA28 registers,
out AtaErrorRegistersLBA28 errorRegisters, AtaProtocol protocol,
internal static int SendIdeCommand(SafeFileHandle fd, AtaRegistersLba28 registers,
out AtaErrorRegistersLba28 errorRegisters, AtaProtocol protocol,
ref byte[] buffer, uint timeout, out double duration, out bool sense)
{
duration = 0;
sense = false;
errorRegisters = new AtaErrorRegistersLBA28();
errorRegisters = new AtaErrorRegistersLba28();
if(buffer == null) return -1;
@@ -460,13 +460,13 @@ namespace DiscImageChef.Devices.Windows
{
CurrentTaskFile = new AtaTaskFile
{
Command = registers.command,
CylinderHigh = registers.lbaHigh,
CylinderLow = registers.lbaMid,
DeviceHead = registers.deviceHead,
Features = registers.feature,
SectorCount = registers.sectorCount,
SectorNumber = registers.lbaLow
Command = registers.Command,
CylinderHigh = registers.LbaHigh,
CylinderLow = registers.LbaMid,
DeviceHead = registers.DeviceHead,
Features = registers.Feature,
SectorCount = registers.SectorCount,
SectorNumber = registers.LbaLow
},
DataBufferSize = 512,
DataBuffer = new byte[512]
@@ -490,16 +490,16 @@ namespace DiscImageChef.Devices.Windows
duration = (end - start).TotalMilliseconds;
errorRegisters.command = iptd.CurrentTaskFile.Command;
errorRegisters.lbaHigh = iptd.CurrentTaskFile.CylinderHigh;
errorRegisters.lbaMid = iptd.CurrentTaskFile.CylinderLow;
errorRegisters.deviceHead = iptd.CurrentTaskFile.DeviceHead;
errorRegisters.error = iptd.CurrentTaskFile.Error;
errorRegisters.lbaLow = iptd.CurrentTaskFile.SectorNumber;
errorRegisters.sectorCount = iptd.CurrentTaskFile.SectorCount;
errorRegisters.status = iptd.CurrentTaskFile.Status;
errorRegisters.Command = iptd.CurrentTaskFile.Command;
errorRegisters.LbaHigh = iptd.CurrentTaskFile.CylinderHigh;
errorRegisters.LbaMid = iptd.CurrentTaskFile.CylinderLow;
errorRegisters.DeviceHead = iptd.CurrentTaskFile.DeviceHead;
errorRegisters.Error = iptd.CurrentTaskFile.Error;
errorRegisters.LbaLow = iptd.CurrentTaskFile.SectorNumber;
errorRegisters.SectorCount = iptd.CurrentTaskFile.SectorCount;
errorRegisters.Status = iptd.CurrentTaskFile.Status;
sense = errorRegisters.error != 0 || (errorRegisters.status & 0xA5) != 0;
sense = errorRegisters.Error != 0 || (errorRegisters.Status & 0xA5) != 0;
return error;
}