mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Code cleanup.
This commit is contained in:
@@ -43,8 +43,9 @@ namespace DiscImageChef.Devices
|
||||
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,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
out bool sense);
|
||||
Error = LastError != 0;
|
||||
|
||||
@@ -59,8 +60,8 @@ namespace DiscImageChef.Devices
|
||||
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);
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.NoTransfer,
|
||||
ref buffer, timeout, false, out duration, out bool sense);
|
||||
Error = LastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("ATA Device", "READ BUFFER DMA took {0} ms.", duration);
|
||||
@@ -68,29 +69,30 @@ namespace DiscImageChef.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)
|
||||
{
|
||||
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,
|
||||
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
|
||||
{
|
||||
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
|
||||
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;
|
||||
|
||||
@@ -99,24 +101,25 @@ namespace DiscImageChef.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
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadMultiple,
|
||||
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)
|
||||
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;
|
||||
|
||||
@@ -125,17 +128,18 @@ 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];
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersLba28 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;
|
||||
|
||||
@@ -144,7 +148,7 @@ namespace DiscImageChef.Devices
|
||||
lba += (uint)(statusRegisters.DeviceHead & 0xF);
|
||||
lba *= 0x1000000;
|
||||
lba += (uint)(statusRegisters.LbaHigh << 16);
|
||||
lba += (uint)(statusRegisters.LbaMid << 8);
|
||||
lba += (uint)(statusRegisters.LbaMid << 8);
|
||||
lba += statusRegisters.LbaLow;
|
||||
}
|
||||
|
||||
@@ -153,30 +157,31 @@ namespace DiscImageChef.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)
|
||||
{
|
||||
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,
|
||||
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
|
||||
{
|
||||
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
|
||||
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;
|
||||
|
||||
@@ -185,30 +190,32 @@ namespace DiscImageChef.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)
|
||||
{
|
||||
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,
|
||||
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
|
||||
{
|
||||
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
|
||||
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;
|
||||
|
||||
@@ -222,17 +229,18 @@ namespace DiscImageChef.Devices
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||
{
|
||||
Command = (byte)AtaCommands.Seek,
|
||||
Command = (byte)AtaCommands.Seek,
|
||||
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||
LbaLow = (byte)((lba & 0xFF) / 0x1)
|
||||
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;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ 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;
|
||||
@@ -45,14 +45,15 @@ namespace DiscImageChef.Devices
|
||||
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,
|
||||
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)
|
||||
{
|
||||
lba = statusRegisters.LbaHigh;
|
||||
lba = statusRegisters.LbaHigh;
|
||||
lba *= 0x100000000;
|
||||
lba += (ulong)(statusRegisters.LbaMid << 16);
|
||||
lba += statusRegisters.LbaLow;
|
||||
@@ -63,22 +64,23 @@ namespace DiscImageChef.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
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadDmaExt,
|
||||
Command = (byte)AtaCommands.ReadDmaExt,
|
||||
SectorCount = count,
|
||||
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
|
||||
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000),
|
||||
LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
|
||||
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;
|
||||
|
||||
@@ -87,22 +89,24 @@ namespace DiscImageChef.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
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadLogExt,
|
||||
Command = (byte)AtaCommands.ReadLogExt,
|
||||
SectorCount = count,
|
||||
LbaLow = (ushort)((pageNumber & 0xFF) * 0x100),
|
||||
LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100)
|
||||
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;
|
||||
|
||||
@@ -111,21 +115,23 @@ namespace DiscImageChef.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
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadLogDmaExt,
|
||||
Command = (byte)AtaCommands.ReadLogDmaExt,
|
||||
SectorCount = count,
|
||||
LbaLow = (ushort)((pageNumber & 0xFF) * 0x100),
|
||||
LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100)
|
||||
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;
|
||||
|
||||
@@ -134,23 +140,25 @@ namespace DiscImageChef.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
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadMultipleExt,
|
||||
Command = (byte)AtaCommands.ReadMultipleExt,
|
||||
SectorCount = count,
|
||||
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
|
||||
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000),
|
||||
LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
|
||||
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;
|
||||
|
||||
@@ -159,23 +167,24 @@ 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];
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersLba48 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)
|
||||
{
|
||||
lba = statusRegisters.LbaHigh;
|
||||
lba = statusRegisters.LbaHigh;
|
||||
lba *= 0x100000000;
|
||||
lba += (ulong)(statusRegisters.LbaMid << 16);
|
||||
lba += statusRegisters.LbaLow;
|
||||
@@ -186,23 +195,24 @@ namespace DiscImageChef.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
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadExt,
|
||||
Command = (byte)AtaCommands.ReadExt,
|
||||
SectorCount = count,
|
||||
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
|
||||
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000),
|
||||
LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
|
||||
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;
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace DiscImageChef.Devices
|
||||
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
buffer = new byte[512];
|
||||
buffer = new byte[512];
|
||||
AtaRegistersChs registers = new AtaRegistersChs {Command = (byte)AtaCommands.IdentifyDevice};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
@@ -106,16 +106,16 @@ namespace DiscImageChef.Devices
|
||||
}
|
||||
|
||||
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, bool retry, ushort cylinder,
|
||||
byte head, byte sector, byte count, uint timeout,
|
||||
byte head, byte sector, byte count, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
|
||||
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
|
||||
AtaRegistersChs registers = new AtaRegistersChs
|
||||
{
|
||||
SectorCount = count,
|
||||
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
Sector = sector,
|
||||
Command = retry ? (byte)AtaCommands.ReadDmaRetry : (byte)AtaCommands.ReadDma
|
||||
};
|
||||
@@ -130,18 +130,18 @@ namespace DiscImageChef.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];
|
||||
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
|
||||
AtaRegistersChs registers = new AtaRegistersChs
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadMultiple,
|
||||
SectorCount = count,
|
||||
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
Sector = sector
|
||||
};
|
||||
|
||||
@@ -157,24 +157,24 @@ namespace DiscImageChef.Devices
|
||||
}
|
||||
|
||||
public bool Read(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head,
|
||||
byte sector, byte count, uint timeout,
|
||||
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,
|
||||
byte head, byte sector, byte count, uint timeout,
|
||||
byte head, byte sector, byte count, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
|
||||
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
|
||||
AtaRegistersChs registers = new AtaRegistersChs
|
||||
{
|
||||
Command = retry ? (byte)AtaCommands.ReadRetry : (byte)AtaCommands.Read,
|
||||
SectorCount = count,
|
||||
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
Sector = sector
|
||||
};
|
||||
|
||||
@@ -198,18 +198,19 @@ namespace DiscImageChef.Devices
|
||||
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];
|
||||
buffer = new byte[blockSize];
|
||||
AtaRegistersChs registers = new AtaRegistersChs
|
||||
{
|
||||
Command = retry ? (byte)AtaCommands.ReadLongRetry : (byte)AtaCommands.ReadLong,
|
||||
SectorCount = 1,
|
||||
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
Sector = sector
|
||||
};
|
||||
|
||||
@@ -224,16 +225,16 @@ namespace DiscImageChef.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];
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersChs registers = new AtaRegistersChs
|
||||
{
|
||||
Command = (byte)AtaCommands.Seek,
|
||||
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
Sector = sector
|
||||
};
|
||||
|
||||
@@ -254,16 +255,16 @@ namespace DiscImageChef.Devices
|
||||
}
|
||||
|
||||
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];
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersChs registers = new AtaRegistersChs
|
||||
{
|
||||
Command = (byte)AtaCommands.SetFeatures,
|
||||
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
Sector = sector,
|
||||
SectorCount = sectorCount,
|
||||
Feature = (byte)feature
|
||||
|
||||
@@ -86,8 +86,9 @@ namespace DiscImageChef.Devices
|
||||
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,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
out bool sense);
|
||||
Error = LastError != 0;
|
||||
|
||||
|
||||
@@ -37,23 +37,24 @@ namespace DiscImageChef.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
|
||||
{
|
||||
Command = (byte)AtaCommands.TranslateSector,
|
||||
Command = (byte)AtaCommands.TranslateSector,
|
||||
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||
LbaLow = (byte)((lba & 0xFF) / 0x1)
|
||||
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;
|
||||
|
||||
@@ -63,20 +64,22 @@ namespace DiscImageChef.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
|
||||
{
|
||||
Command = (byte)AtaCommands.TranslateSector,
|
||||
Command = (byte)AtaCommands.TranslateSector,
|
||||
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
Sector = sector,
|
||||
DeviceHead = (byte)(head & 0x0F)
|
||||
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;
|
||||
|
||||
@@ -86,13 +89,14 @@ namespace DiscImageChef.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];
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28 {Command = (byte)AtaCommands.RequestSense};
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -38,26 +38,27 @@ namespace DiscImageChef.Devices
|
||||
public partial class Device
|
||||
{
|
||||
public bool EnableMediaCardPassThrough(out AtaErrorRegistersChs statusRegisters, uint timeout,
|
||||
out double duration)
|
||||
out double duration)
|
||||
{
|
||||
return CheckMediaCardType(1, out statusRegisters, timeout, out duration);
|
||||
}
|
||||
|
||||
public bool DisableMediaCardPassThrough(out AtaErrorRegistersChs statusRegisters, uint timeout,
|
||||
out double duration)
|
||||
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 {Command = (byte)AtaCommands.CheckMediaCardType, Feature = feature};
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -45,11 +45,12 @@ namespace DiscImageChef.Devices
|
||||
Command = (byte)AtaCommands.Smart,
|
||||
Feature = (byte)AtaSmartSubCommands.Disable,
|
||||
LbaHigh = 0xC2,
|
||||
LbaMid = 0x4F
|
||||
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;
|
||||
|
||||
@@ -59,20 +60,21 @@ namespace DiscImageChef.Devices
|
||||
}
|
||||
|
||||
public bool SmartEnableAttributeAutosave(out AtaErrorRegistersLba28 statusRegisters, uint timeout,
|
||||
out double duration)
|
||||
out double duration)
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersLba28 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,
|
||||
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;
|
||||
|
||||
@@ -82,7 +84,7 @@ namespace DiscImageChef.Devices
|
||||
}
|
||||
|
||||
public bool SmartDisableAttributeAutosave(out AtaErrorRegistersLba28 statusRegisters, uint timeout,
|
||||
out double duration)
|
||||
out double duration)
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||
@@ -90,11 +92,12 @@ namespace DiscImageChef.Devices
|
||||
Command = (byte)AtaCommands.Smart,
|
||||
Feature = (byte)AtaSmartSubCommands.EnableDisableAttributeAutosave,
|
||||
LbaHigh = 0xC2,
|
||||
LbaMid = 0x4F
|
||||
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;
|
||||
|
||||
@@ -111,11 +114,12 @@ namespace DiscImageChef.Devices
|
||||
Command = (byte)AtaCommands.Smart,
|
||||
Feature = (byte)AtaSmartSubCommands.Enable,
|
||||
LbaHigh = 0xC2,
|
||||
LbaMid = 0x4F
|
||||
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;
|
||||
|
||||
@@ -124,8 +128,8 @@ namespace DiscImageChef.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
|
||||
@@ -133,12 +137,13 @@ namespace DiscImageChef.Devices
|
||||
Command = (byte)AtaCommands.Smart,
|
||||
Feature = (byte)AtaSmartSubCommands.ExecuteOfflineImmediate,
|
||||
LbaHigh = 0xC2,
|
||||
LbaMid = 0x4F,
|
||||
LbaLow = subcommand
|
||||
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;
|
||||
|
||||
@@ -156,11 +161,12 @@ namespace DiscImageChef.Devices
|
||||
Command = (byte)AtaCommands.Smart,
|
||||
Feature = (byte)AtaSmartSubCommands.ReadData,
|
||||
LbaHigh = 0xC2,
|
||||
LbaMid = 0x4F
|
||||
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;
|
||||
|
||||
@@ -169,8 +175,8 @@ namespace DiscImageChef.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
|
||||
@@ -178,12 +184,13 @@ namespace DiscImageChef.Devices
|
||||
Command = (byte)AtaCommands.Smart,
|
||||
Feature = (byte)AtaSmartSubCommands.ReadLog,
|
||||
LbaHigh = 0xC2,
|
||||
LbaMid = 0x4F,
|
||||
LbaLow = logAddress
|
||||
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;
|
||||
|
||||
@@ -200,11 +207,12 @@ namespace DiscImageChef.Devices
|
||||
Command = (byte)AtaCommands.Smart,
|
||||
Feature = (byte)AtaSmartSubCommands.ReturnStatus,
|
||||
LbaHigh = 0xC2,
|
||||
LbaMid = 0x4F
|
||||
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;
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ namespace DiscImageChef.Devices
|
||||
/// <c>True</c> if SCSI command returned non-OK status and <paramref name="senseBuffer" /> contains
|
||||
/// SCSI sense
|
||||
/// </param>
|
||||
public int SendScsiCommand(byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, uint timeout,
|
||||
ScsiDirection direction, out double duration, out bool sense)
|
||||
public int SendScsiCommand(byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, uint timeout,
|
||||
ScsiDirection direction, out double duration, out bool sense)
|
||||
{
|
||||
return Command.SendScsiCommand(PlatformId, FileHandle, cdb, ref buffer, out senseBuffer, timeout, direction,
|
||||
out duration, out sense);
|
||||
@@ -77,8 +77,10 @@ namespace DiscImageChef.Devices
|
||||
/// <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,
|
||||
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
|
||||
uint timeout, bool transferBlocks, out double duration, out bool sense)
|
||||
AtaProtocol protocol, AtaTransferRegister transferRegister,
|
||||
ref byte[] buffer,
|
||||
uint timeout, bool transferBlocks,
|
||||
out double duration, out bool sense)
|
||||
{
|
||||
return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol,
|
||||
transferRegister, ref buffer, timeout, transferBlocks, out duration,
|
||||
@@ -102,8 +104,10 @@ namespace DiscImageChef.Devices
|
||||
/// <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,
|
||||
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
|
||||
uint timeout, bool transferBlocks, out double duration, out bool sense)
|
||||
AtaProtocol protocol, AtaTransferRegister transferRegister,
|
||||
ref byte[] buffer,
|
||||
uint timeout, bool transferBlocks,
|
||||
out double duration, out bool sense)
|
||||
{
|
||||
return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol,
|
||||
transferRegister, ref buffer, timeout, transferBlocks, out duration,
|
||||
@@ -127,8 +131,10 @@ namespace DiscImageChef.Devices
|
||||
/// <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,
|
||||
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
|
||||
uint timeout, bool transferBlocks, out double duration, out bool sense)
|
||||
AtaProtocol protocol, AtaTransferRegister transferRegister,
|
||||
ref byte[] buffer,
|
||||
uint timeout, bool transferBlocks,
|
||||
out double duration, out bool sense)
|
||||
{
|
||||
return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol,
|
||||
transferRegister, ref buffer, timeout, transferBlocks, out duration,
|
||||
@@ -151,9 +157,10 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="argument">Command argument</param>
|
||||
/// <param name="response">Response registers</param>
|
||||
/// <param name="blockSize">Size of block in bytes</param>
|
||||
public int SendMmcCommand(MmcCommands command, bool write, bool isApplication, MmcFlags flags, uint argument,
|
||||
uint blockSize, uint blocks, ref byte[] buffer, out uint[] response,
|
||||
out double duration, out bool sense, uint timeout = 0)
|
||||
public int SendMmcCommand(MmcCommands command, bool write, bool isApplication, MmcFlags flags,
|
||||
uint argument,
|
||||
uint blockSize, uint blocks, ref byte[] buffer, out uint[] response,
|
||||
out double duration, out bool sense, uint timeout = 0)
|
||||
{
|
||||
switch(command)
|
||||
{
|
||||
@@ -163,7 +170,7 @@ namespace DiscImageChef.Devices
|
||||
buffer = new byte[cachedCid.Length];
|
||||
Array.Copy(cachedCid, buffer, buffer.Length);
|
||||
response = new uint[4];
|
||||
sense = false;
|
||||
sense = false;
|
||||
DateTime end = DateTime.Now;
|
||||
duration = (end - start).TotalMilliseconds;
|
||||
return 0;
|
||||
@@ -174,7 +181,7 @@ namespace DiscImageChef.Devices
|
||||
buffer = new byte[cachedCsd.Length];
|
||||
Array.Copy(cachedCsd, buffer, buffer.Length);
|
||||
response = new uint[4];
|
||||
sense = false;
|
||||
sense = false;
|
||||
DateTime end = DateTime.Now;
|
||||
duration = (end - start).TotalMilliseconds;
|
||||
return 0;
|
||||
@@ -185,7 +192,7 @@ namespace DiscImageChef.Devices
|
||||
buffer = new byte[cachedScr.Length];
|
||||
Array.Copy(cachedScr, buffer, buffer.Length);
|
||||
response = new uint[4];
|
||||
sense = false;
|
||||
sense = false;
|
||||
DateTime end = DateTime.Now;
|
||||
duration = (end - start).TotalMilliseconds;
|
||||
return 0;
|
||||
@@ -203,7 +210,7 @@ namespace DiscImageChef.Devices
|
||||
buffer = new byte[cachedOcr.Length];
|
||||
Array.Copy(cachedOcr, buffer, buffer.Length);
|
||||
response = new uint[4];
|
||||
sense = false;
|
||||
sense = false;
|
||||
DateTime end = DateTime.Now;
|
||||
duration = (end - start).TotalMilliseconds;
|
||||
return 0;
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace DiscImageChef.Devices
|
||||
public string Model;
|
||||
public string Serial;
|
||||
public string Bus;
|
||||
public bool Supported;
|
||||
public bool Supported;
|
||||
}
|
||||
|
||||
public partial class Device
|
||||
@@ -53,7 +53,7 @@ namespace DiscImageChef.Devices
|
||||
switch(DetectOS.GetRealPlatformID())
|
||||
{
|
||||
case PlatformID.Win32NT: return Windows.ListDevices.GetList();
|
||||
case PlatformID.Linux: return Linux.ListDevices.GetList();
|
||||
case PlatformID.Linux: return Linux.ListDevices.GetList();
|
||||
case PlatformID.FreeBSD: return FreeBSD.ListDevices.GetList();
|
||||
default:
|
||||
throw new InvalidOperationException($"Platform {DetectOS.GetRealPlatformID()} not yet supported.");
|
||||
|
||||
@@ -40,9 +40,12 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
buffer = new byte[16];
|
||||
|
||||
LastError = SendMmcCommand(MmcCommands.SendCsd, false, false,
|
||||
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1,
|
||||
ref buffer, out response, out duration, out bool sense, timeout);
|
||||
LastError = SendMmcCommand(MmcCommands.SendCsd, false,
|
||||
false,
|
||||
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0,
|
||||
16, 1,
|
||||
ref buffer, out response,
|
||||
out duration, out bool sense, timeout);
|
||||
Error = LastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("MMC Device", "SEND_CSD took {0} ms.", duration);
|
||||
@@ -54,9 +57,12 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
buffer = new byte[16];
|
||||
|
||||
LastError = SendMmcCommand(MmcCommands.SendCid, false, false,
|
||||
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1,
|
||||
ref buffer, out response, out duration, out bool sense, timeout);
|
||||
LastError = SendMmcCommand(MmcCommands.SendCid, false,
|
||||
false,
|
||||
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0,
|
||||
16, 1,
|
||||
ref buffer, out response,
|
||||
out duration, out bool sense, timeout);
|
||||
Error = LastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("MMC Device", "SEND_CID took {0} ms.", duration);
|
||||
@@ -68,9 +74,12 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
buffer = new byte[4];
|
||||
|
||||
LastError = SendMmcCommand(MmcCommands.SendOpCond, false, true,
|
||||
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0, 4, 1,
|
||||
ref buffer, out response, out duration, out bool sense, timeout);
|
||||
LastError = SendMmcCommand(MmcCommands.SendOpCond, false,
|
||||
true,
|
||||
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0,
|
||||
4, 1,
|
||||
ref buffer, out response,
|
||||
out duration, out bool sense, timeout);
|
||||
Error = LastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("SecureDigital Device", "SEND_OP_COND took {0} ms.", duration);
|
||||
@@ -82,9 +91,12 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
buffer = new byte[512];
|
||||
|
||||
LastError = SendMmcCommand(MmcCommands.SendExtCsd, false, false,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 512, 1,
|
||||
ref buffer, out response, out duration, out bool sense, timeout);
|
||||
LastError = SendMmcCommand(MmcCommands.SendExtCsd, false,
|
||||
false,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0,
|
||||
512, 1,
|
||||
ref buffer,
|
||||
out response, out duration, out bool sense, timeout);
|
||||
Error = LastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("MMC Device", "SEND_EXT_CSD took {0} ms.", duration);
|
||||
@@ -96,9 +108,12 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
|
||||
LastError = SendMmcCommand(MmcCommands.SetBlocklen, false, false,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, length, 0, 0,
|
||||
ref buffer, out response, out duration, out bool sense, timeout);
|
||||
LastError = SendMmcCommand(MmcCommands.SetBlocklen, false,
|
||||
false,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, length,
|
||||
0, 0,
|
||||
ref buffer, out response,
|
||||
out duration, out bool sense, timeout);
|
||||
Error = LastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("MMC Device", "SET_BLOCKLEN took {0} ms.", duration);
|
||||
@@ -106,28 +121,34 @@ namespace DiscImageChef.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool Read(out byte[] buffer, out uint[] response, uint lba, uint blockSize, uint transferLength,
|
||||
bool byteAddressed, uint timeout, out double duration)
|
||||
public bool Read(out byte[] buffer, out uint[] response, uint lba, uint blockSize,
|
||||
uint transferLength,
|
||||
bool byteAddressed, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[transferLength * blockSize];
|
||||
uint address;
|
||||
if(byteAddressed) address = lba * blockSize;
|
||||
else address = lba;
|
||||
else address = lba;
|
||||
|
||||
MmcCommands command = transferLength > 1 ? MmcCommands.ReadMultipleBlock : MmcCommands.ReadSingleBlock;
|
||||
|
||||
LastError = SendMmcCommand(command, false, false,
|
||||
LastError = SendMmcCommand(command, false,
|
||||
false,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, address,
|
||||
blockSize, transferLength, ref buffer, out response, out duration,
|
||||
blockSize,
|
||||
transferLength, ref buffer, out response, out duration,
|
||||
out bool sense, timeout);
|
||||
Error = LastError != 0;
|
||||
|
||||
if(transferLength > 1)
|
||||
{
|
||||
byte[] foo = new byte[0];
|
||||
SendMmcCommand(MmcCommands.StopTransmission, false, false,
|
||||
MmcFlags.ResponseR1B | MmcFlags.ResponseSpiR1B | MmcFlags.CommandAc, 0, 0, 0, ref foo,
|
||||
out _, out double stopDuration, out bool _, timeout);
|
||||
SendMmcCommand(MmcCommands.StopTransmission, false,
|
||||
false,
|
||||
MmcFlags.ResponseR1B | MmcFlags.ResponseSpiR1B | MmcFlags.CommandAc, 0,
|
||||
0, 0, ref foo,
|
||||
out _,
|
||||
out double stopDuration, out bool _, timeout);
|
||||
duration += stopDuration;
|
||||
DicConsole.DebugWriteLine("MMC Device", "READ_MULTIPLE_BLOCK took {0} ms.", duration);
|
||||
}
|
||||
@@ -140,9 +161,12 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
buffer = new byte[4];
|
||||
|
||||
LastError = SendMmcCommand(MmcCommands.SendStatus, false, true,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, 0, 4, 1,
|
||||
ref buffer, out response, out duration, out bool sense, timeout);
|
||||
LastError = SendMmcCommand(MmcCommands.SendStatus, false,
|
||||
true,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, 0,
|
||||
4, 1,
|
||||
ref buffer, out response,
|
||||
out duration, out bool sense, timeout);
|
||||
Error = LastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("SecureDigital Device", "SEND_STATUS took {0} ms.", duration);
|
||||
|
||||
@@ -40,9 +40,12 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
buffer = new byte[64];
|
||||
|
||||
LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendStatus, false, true,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 64, 1,
|
||||
ref buffer, out response, out duration, out bool sense, timeout);
|
||||
LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendStatus, false,
|
||||
true,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0,
|
||||
64, 1,
|
||||
ref buffer,
|
||||
out response, out duration, out bool sense, timeout);
|
||||
Error = LastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("SecureDigital Device", "SD_STATUS took {0} ms.", duration);
|
||||
@@ -54,9 +57,12 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
buffer = new byte[4];
|
||||
|
||||
LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendOperatingCondition, false, true,
|
||||
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0, 4, 1,
|
||||
ref buffer, out response, out duration, out bool sense, timeout);
|
||||
LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendOperatingCondition, false,
|
||||
true,
|
||||
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0,
|
||||
4, 1,
|
||||
ref buffer, out response,
|
||||
out duration, out bool sense, timeout);
|
||||
Error = LastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("SecureDigital Device", "SD_SEND_OP_COND took {0} ms.", duration);
|
||||
@@ -68,9 +74,12 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
buffer = new byte[8];
|
||||
|
||||
LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendScr, false, true,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 8, 1,
|
||||
ref buffer, out response, out duration, out bool sense, timeout);
|
||||
LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendScr, false,
|
||||
true,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0,
|
||||
8, 1,
|
||||
ref buffer,
|
||||
out response, out duration, out bool sense, timeout);
|
||||
Error = LastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("SecureDigital Device", "SEND_SCR took {0} ms.", duration);
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace DiscImageChef.Devices
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.AdaptecTranslate;
|
||||
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
|
||||
cdb[2] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[2] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)(lba & 0xFF);
|
||||
if(drive1) cdb[1] += 0x20;
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="drive1">If set to <c>true</c> set the threshold from drive 1.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool AdaptecSetErrorThreshold(byte threshold, out byte[] senseBuffer, bool drive1, uint timeout,
|
||||
public bool AdaptecSetErrorThreshold(byte threshold, out byte[] senseBuffer, bool drive1, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
byte[] buffer = new byte[1];
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace DiscImageChef.Devices
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ArchiveRequestBlockAddress;
|
||||
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
|
||||
cdb[2] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[2] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)(lba & 0xFF);
|
||||
cdb[4] = 3;
|
||||
|
||||
@@ -90,12 +90,12 @@ namespace DiscImageChef.Devices
|
||||
out double duration)
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] cdb = new byte[6];
|
||||
senseBuffer = new byte[32];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ArchiveSeekBlock;
|
||||
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
|
||||
cdb[2] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[2] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)(lba & 0xFF);
|
||||
if(immediate) cdb[1] += 0x01;
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace DiscImageChef.Devices
|
||||
public bool CertanceParkUnpark(out byte[] senseBuffer, bool park, uint timeout, out double duration)
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] cdb = new byte[6];
|
||||
senseBuffer = new byte[32];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.CertanceParkUnpark;
|
||||
|
||||
@@ -38,22 +38,23 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
public partial class Device
|
||||
{
|
||||
public bool FujitsuDisplay(out byte[] senseBuffer, bool flash, FujitsuDisplayModes mode, string firstHalf,
|
||||
string secondHalf, uint timeout, out double duration)
|
||||
public bool FujitsuDisplay(out byte[] senseBuffer, bool flash, FujitsuDisplayModes mode, string firstHalf,
|
||||
string secondHalf, uint timeout, out double duration)
|
||||
{
|
||||
byte[] tmp;
|
||||
byte[] firstHalfBytes = new byte[8];
|
||||
byte[] firstHalfBytes = new byte[8];
|
||||
byte[] secondHalfBytes = new byte[8];
|
||||
byte[] buffer = new byte[17];
|
||||
bool displayLen = false;
|
||||
bool halfMsg = false;
|
||||
byte[] cdb = new byte[10];
|
||||
byte[] buffer = new byte[17];
|
||||
bool displayLen = false;
|
||||
bool halfMsg = false;
|
||||
byte[] cdb = new byte[10];
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(firstHalf))
|
||||
{
|
||||
tmp = Encoding.ASCII.GetBytes(firstHalf);
|
||||
Array.Copy(tmp, 0, firstHalfBytes, 0, 8);
|
||||
}
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(secondHalf))
|
||||
{
|
||||
tmp = Encoding.ASCII.GetBytes(secondHalf);
|
||||
@@ -62,17 +63,18 @@ namespace DiscImageChef.Devices
|
||||
|
||||
if(mode != FujitsuDisplayModes.Half)
|
||||
if(!ArrayHelpers.ArrayIsNullOrWhiteSpace(firstHalfBytes) &&
|
||||
!ArrayHelpers.ArrayIsNullOrWhiteSpace(secondHalfBytes)) displayLen = true;
|
||||
!ArrayHelpers.ArrayIsNullOrWhiteSpace(secondHalfBytes))
|
||||
displayLen = true;
|
||||
else if(!ArrayHelpers.ArrayIsNullOrWhiteSpace(firstHalfBytes) &&
|
||||
ArrayHelpers.ArrayIsNullOrWhiteSpace(secondHalfBytes)) halfMsg = true;
|
||||
|
||||
buffer[0] = (byte)((byte)mode << 5);
|
||||
if(displayLen) buffer[0] += 0x10;
|
||||
if(flash) buffer[0] += 0x08;
|
||||
if(halfMsg) buffer[0] += 0x04;
|
||||
if(flash) buffer[0] += 0x08;
|
||||
if(halfMsg) buffer[0] += 0x04;
|
||||
buffer[0] += 0x01; // Always ASCII
|
||||
|
||||
Array.Copy(firstHalfBytes, 0, buffer, 1, 8);
|
||||
Array.Copy(firstHalfBytes, 0, buffer, 1, 8);
|
||||
Array.Copy(secondHalfBytes, 0, buffer, 9, 8);
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.FujitsuDisplay;
|
||||
|
||||
@@ -46,22 +46,22 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||
/// <param name="lba">Start block address.</param>
|
||||
/// <param name="transferLength">How many blocks to read.</param>
|
||||
public bool HlDtStReadRawDvd(out byte[] buffer, out byte[] senseBuffer, uint lba, uint transferLength,
|
||||
uint timeout, out double duration)
|
||||
public bool HlDtStReadRawDvd(out byte[] buffer, out byte[] senseBuffer, uint lba, uint transferLength,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
buffer = new byte[2064 * transferLength];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.HlDtStVendor;
|
||||
cdb[1] = 0x48;
|
||||
cdb[2] = 0x49;
|
||||
cdb[3] = 0x54;
|
||||
cdb[4] = 0x01;
|
||||
cdb[6] = (byte)((lba & 0xFF000000) >> 24);
|
||||
cdb[7] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[8] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(lba & 0xFF);
|
||||
cdb[0] = (byte)ScsiCommands.HlDtStVendor;
|
||||
cdb[1] = 0x48;
|
||||
cdb[2] = 0x49;
|
||||
cdb[3] = 0x54;
|
||||
cdb[4] = 0x01;
|
||||
cdb[6] = (byte)((lba & 0xFF000000) >> 24);
|
||||
cdb[7] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[8] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(lba & 0xFF);
|
||||
cdb[10] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[11] = (byte)(buffer.Length & 0xFF);
|
||||
|
||||
|
||||
@@ -48,8 +48,9 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="pba">If set to <c>true</c> address contain physical block address.</param>
|
||||
/// <param name="timeout">Timeout in seconds.</param>
|
||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||
public bool HpReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address, ushort blockBytes,
|
||||
bool pba, uint timeout, out double duration)
|
||||
public bool HpReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address,
|
||||
ushort blockBytes,
|
||||
bool pba, uint timeout, out double duration)
|
||||
{
|
||||
return HpReadLong(out buffer, out senseBuffer, relAddr, address, 0, blockBytes, pba, false, timeout,
|
||||
out duration);
|
||||
@@ -72,8 +73,9 @@ namespace DiscImageChef.Devices
|
||||
/// </param>
|
||||
/// <param name="timeout">Timeout in seconds.</param>
|
||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||
public bool HpReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address,
|
||||
ushort transferLen, ushort blockBytes, bool pba, bool sectorCount, uint timeout,
|
||||
public bool HpReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address,
|
||||
ushort transferLen, ushort blockBytes, bool pba, bool sectorCount,
|
||||
uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
@@ -82,12 +84,12 @@ namespace DiscImageChef.Devices
|
||||
cdb[0] = (byte)ScsiCommands.ReadLong;
|
||||
if(relAddr) cdb[1] += 0x01;
|
||||
cdb[2] = (byte)((address & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((address & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((address & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)((address & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((address & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(address & 0xFF);
|
||||
cdb[7] = (byte)((transferLen & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(transferLen & 0xFF);
|
||||
if(pba) cdb[9] += 0x80;
|
||||
if(pba) cdb[9] += 0x80;
|
||||
if(sectorCount) cdb[9] += 0x40;
|
||||
|
||||
buffer = sectorCount ? new byte[blockBytes * transferLen] : new byte[transferLen];
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace DiscImageChef.Devices
|
||||
public bool KreonDeprecatedUnlock(out byte[] senseBuffer, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] buffer = new byte[0];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.KreonCommand;
|
||||
@@ -111,7 +111,7 @@ namespace DiscImageChef.Devices
|
||||
public bool KreonSetLockState(out byte[] senseBuffer, KreonLockStates state, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] buffer = new byte[0];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.KreonCommand;
|
||||
@@ -141,7 +141,7 @@ namespace DiscImageChef.Devices
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] buffer = new byte[26];
|
||||
features = 0;
|
||||
|
||||
@@ -214,22 +214,22 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="buffer">The SS sector.</param>
|
||||
/// <param name="requestNumber">Request number.</param>
|
||||
public bool KreonExtractSs(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration,
|
||||
byte requestNumber = 0x00)
|
||||
byte requestNumber = 0x00)
|
||||
{
|
||||
buffer = new byte[2048];
|
||||
byte[] cdb = new byte[12];
|
||||
senseBuffer = new byte[32];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.KreonSsCommand;
|
||||
cdb[1] = 0x00;
|
||||
cdb[2] = 0xFF;
|
||||
cdb[3] = 0x02;
|
||||
cdb[4] = 0xFD;
|
||||
cdb[5] = 0xFF;
|
||||
cdb[6] = 0xFE;
|
||||
cdb[7] = 0x00;
|
||||
cdb[8] = 0x08;
|
||||
cdb[9] = 0x00;
|
||||
cdb[0] = (byte)ScsiCommands.KreonSsCommand;
|
||||
cdb[1] = 0x00;
|
||||
cdb[2] = 0xFF;
|
||||
cdb[3] = 0x02;
|
||||
cdb[4] = 0xFD;
|
||||
cdb[5] = 0xFF;
|
||||
cdb[6] = 0xFE;
|
||||
cdb[7] = 0x00;
|
||||
cdb[8] = 0x08;
|
||||
cdb[9] = 0x00;
|
||||
cdb[10] = requestNumber;
|
||||
cdb[11] = 0xC0;
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="startingFeatureNumber">Feature number where the feature list should start from</param>
|
||||
/// <param name="timeout">Timeout in seconds.</param>
|
||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||
public bool GetConfiguration(out byte[] buffer, out byte[] senseBuffer, ushort startingFeatureNumber,
|
||||
public bool GetConfiguration(out byte[] buffer, out byte[] senseBuffer, ushort startingFeatureNumber,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
return GetConfiguration(out buffer, out senseBuffer, startingFeatureNumber, MmcGetConfigurationRt.All,
|
||||
@@ -78,19 +78,20 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||
/// <param name="startingFeatureNumber">Starting Feature number.</param>
|
||||
/// <param name="rt">Return type, <see cref="MmcGetConfigurationRt" />.</param>
|
||||
public bool GetConfiguration(out byte[] buffer, out byte[] senseBuffer, ushort startingFeatureNumber,
|
||||
MmcGetConfigurationRt rt, uint timeout, out double duration)
|
||||
public bool GetConfiguration(out byte[] buffer, out byte[] senseBuffer,
|
||||
ushort startingFeatureNumber,
|
||||
MmcGetConfigurationRt rt, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[10];
|
||||
buffer = new byte[8];
|
||||
byte[] cdb = new byte[10];
|
||||
buffer = new byte[8];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.GetConfiguration;
|
||||
cdb[1] = (byte)((byte)rt & 0x03);
|
||||
cdb[1] = (byte)((byte)rt & 0x03);
|
||||
cdb[2] = (byte)((startingFeatureNumber & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)(startingFeatureNumber & 0xFF);
|
||||
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(buffer.Length & 0xFF);
|
||||
cdb[3] = (byte)(startingFeatureNumber & 0xFF);
|
||||
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(buffer.Length & 0xFF);
|
||||
cdb[9] = 0;
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -100,10 +101,10 @@ namespace DiscImageChef.Devices
|
||||
if(sense) return true;
|
||||
|
||||
ushort confLength = (ushort)((buffer[2] << 8) + buffer[3] + 4);
|
||||
buffer = new byte[confLength];
|
||||
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(buffer.Length & 0xFF);
|
||||
senseBuffer = new byte[32];
|
||||
buffer = new byte[confLength];
|
||||
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(buffer.Length & 0xFF);
|
||||
senseBuffer = new byte[32];
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out sense);
|
||||
@@ -127,26 +128,26 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="format">Which disc structure are we requesting</param>
|
||||
/// <param name="agid">AGID used in medium copy protection</param>
|
||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||
public bool ReadDiscStructure(out byte[] buffer, out byte[] senseBuffer, MmcDiscStructureMediaType mediaType,
|
||||
uint address, byte layerNumber, MmcDiscStructureFormat format,
|
||||
public bool ReadDiscStructure(out byte[] buffer, out byte[] senseBuffer, MmcDiscStructureMediaType mediaType,
|
||||
uint address, byte layerNumber, MmcDiscStructureFormat format,
|
||||
byte agid,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
buffer = new byte[8];
|
||||
byte[] cdb = new byte[12];
|
||||
buffer = new byte[8];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadDiscStructure;
|
||||
cdb[1] = (byte)((byte)mediaType & 0x0F);
|
||||
cdb[2] = (byte)((address & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((address & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((address & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(address & 0xFF);
|
||||
cdb[2] = (byte)((address & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((address & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((address & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(address & 0xFF);
|
||||
cdb[6] = layerNumber;
|
||||
cdb[7] = (byte)format;
|
||||
cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(buffer.Length & 0xFF);
|
||||
cdb[10] = (byte)((agid & 0x03) << 6);
|
||||
cdb[9] = (byte)(buffer.Length & 0xFF);
|
||||
cdb[10] = (byte)((agid & 0x03) << 6);
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out bool sense);
|
||||
@@ -155,10 +156,9 @@ namespace DiscImageChef.Devices
|
||||
if(sense) return true;
|
||||
|
||||
ushort strctLength = (ushort)((buffer[0] << 8) + buffer[1] + 2);
|
||||
|
||||
|
||||
// WORKAROUND: Some drives return incorrect length information. As these structures are fixed length just apply known length.
|
||||
if(mediaType == MmcDiscStructureMediaType.Bd)
|
||||
{
|
||||
switch(format)
|
||||
{
|
||||
case MmcDiscStructureFormat.DiscInformation:
|
||||
@@ -180,12 +180,10 @@ namespace DiscImageChef.Devices
|
||||
buffer = new byte[strctLength];
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
buffer = new byte[strctLength];
|
||||
cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(buffer.Length & 0xFF);
|
||||
senseBuffer = new byte[32];
|
||||
else buffer = new byte[strctLength];
|
||||
cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(buffer.Length & 0xFF);
|
||||
senseBuffer = new byte[32];
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out sense);
|
||||
@@ -319,27 +317,27 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="trackSessionNumber">Track/Session number</param>
|
||||
/// <param name="timeout">Timeout in seconds.</param>
|
||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||
public bool ReadTocPmaAtip(out byte[] buffer, out byte[] senseBuffer, bool msf, byte format,
|
||||
byte trackSessionNumber, uint timeout, out double duration)
|
||||
public bool ReadTocPmaAtip(out byte[] buffer, out byte[] senseBuffer, bool msf, byte format,
|
||||
byte trackSessionNumber, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[10];
|
||||
byte[] cdb = new byte[10];
|
||||
|
||||
byte[] tmpBuffer = (format & 0x0F) == 5 ? new byte[32768] : new byte[1024];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadTocPmaAtip;
|
||||
cdb[0] = (byte)ScsiCommands.ReadTocPmaAtip;
|
||||
if(msf) cdb[1] = 0x02;
|
||||
cdb[2] = (byte)(format & 0x0F);
|
||||
cdb[6] = trackSessionNumber;
|
||||
cdb[7] = (byte)((tmpBuffer.Length & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(tmpBuffer.Length & 0xFF);
|
||||
cdb[2] = (byte)(format & 0x0F);
|
||||
cdb[6] = trackSessionNumber;
|
||||
cdb[7] = (byte)((tmpBuffer.Length & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(tmpBuffer.Length & 0xFF);
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out bool sense);
|
||||
Error = LastError != 0;
|
||||
|
||||
uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2);
|
||||
buffer = new byte[strctLength];
|
||||
buffer = new byte[strctLength];
|
||||
|
||||
if(buffer.Length <= tmpBuffer.Length)
|
||||
{
|
||||
@@ -386,23 +384,23 @@ namespace DiscImageChef.Devices
|
||||
MmcDiscInformationDataTypes dataType,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[10];
|
||||
byte[] tmpBuffer = new byte[804];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadDiscInformation;
|
||||
cdb[1] = (byte)dataType;
|
||||
cdb[7] = (byte)((tmpBuffer.Length & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(tmpBuffer.Length & 0xFF);
|
||||
cdb[8] = (byte)(tmpBuffer.Length & 0xFF);
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out bool sense);
|
||||
Error = LastError != 0;
|
||||
|
||||
uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2);
|
||||
uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2);
|
||||
if(strctLength > tmpBuffer.Length) strctLength = (uint)tmpBuffer.Length;
|
||||
|
||||
buffer = new byte[strctLength];
|
||||
buffer = new byte[strctLength];
|
||||
Array.Copy(tmpBuffer, 0, buffer, 0, buffer.Length);
|
||||
|
||||
DicConsole.DebugWriteLine("SCSI Device", "READ DISC INFORMATION took {0} ms.", duration);
|
||||
@@ -430,32 +428,34 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="edcEcc">If set to <c>true</c> we request the EDC/ECC fields for data sectors.</param>
|
||||
/// <param name="c2Error">C2 error options.</param>
|
||||
/// <param name="subchannel">Subchannel selection.</param>
|
||||
public bool ReadCd(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
|
||||
uint transferLength,
|
||||
MmcSectorTypes expectedSectorType, bool dap, bool relAddr, bool sync,
|
||||
MmcHeaderCodes headerCodes, bool userData, bool edcEcc, MmcErrorField c2Error,
|
||||
MmcSubchannel subchannel, uint timeout, out double duration)
|
||||
public bool ReadCd(out byte[] buffer, out byte[] senseBuffer, uint lba,
|
||||
uint blockSize, uint transferLength,
|
||||
MmcSectorTypes expectedSectorType, bool dap, bool relAddr,
|
||||
bool sync,
|
||||
MmcHeaderCodes headerCodes, bool userData, bool edcEcc,
|
||||
MmcErrorField c2Error,
|
||||
MmcSubchannel subchannel, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadCd;
|
||||
cdb[1] = (byte)((byte)expectedSectorType << 2);
|
||||
if(dap) cdb[1] += 0x02;
|
||||
if(relAddr) cdb[1] += 0x01;
|
||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
cdb[6] = (byte)((transferLength & 0xFF0000) >> 16);
|
||||
cdb[7] = (byte)((transferLength & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(transferLength & 0xFF);
|
||||
cdb[9] = (byte)((byte)c2Error << 1);
|
||||
cdb[9] += (byte)((byte)headerCodes << 5);
|
||||
cdb[0] = (byte)ScsiCommands.ReadCd;
|
||||
cdb[1] = (byte)((byte)expectedSectorType << 2);
|
||||
if(dap) cdb[1] += 0x02;
|
||||
if(relAddr) cdb[1] += 0x01;
|
||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
cdb[6] = (byte)((transferLength & 0xFF0000) >> 16);
|
||||
cdb[7] = (byte)((transferLength & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(transferLength & 0xFF);
|
||||
cdb[9] = (byte)((byte)c2Error << 1);
|
||||
cdb[9] += (byte)((byte)headerCodes << 5);
|
||||
if(sync) cdb[9] += 0x80;
|
||||
if(userData) cdb[9] += 0x10;
|
||||
if(edcEcc) cdb[9] += 0x08;
|
||||
cdb[10] = (byte)subchannel;
|
||||
cdb[10] = (byte)subchannel;
|
||||
|
||||
buffer = new byte[blockSize * transferLength];
|
||||
|
||||
@@ -487,32 +487,32 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="edcEcc">If set to <c>true</c> we request the EDC/ECC fields for data sectors.</param>
|
||||
/// <param name="c2Error">C2 error options.</param>
|
||||
/// <param name="subchannel">Subchannel selection.</param>
|
||||
public bool ReadCdMsf(out byte[] buffer, out byte[] senseBuffer, uint startMsf,
|
||||
uint endMsf, uint blockSize,
|
||||
MmcSectorTypes expectedSectorType, bool dap, bool sync,
|
||||
public bool ReadCdMsf(out byte[] buffer, out byte[] senseBuffer, uint startMsf,
|
||||
uint endMsf, uint blockSize,
|
||||
MmcSectorTypes expectedSectorType, bool dap, bool sync,
|
||||
MmcHeaderCodes headerCodes,
|
||||
bool userData, bool edcEcc, MmcErrorField c2Error,
|
||||
bool userData, bool edcEcc, MmcErrorField c2Error,
|
||||
MmcSubchannel subchannel, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadCdMsf;
|
||||
cdb[1] = (byte)((byte)expectedSectorType << 2);
|
||||
if(dap) cdb[1] += 0x02;
|
||||
cdb[3] = (byte)((startMsf & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((startMsf & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(startMsf & 0xFF);
|
||||
cdb[6] = (byte)((endMsf & 0xFF0000) >> 16);
|
||||
cdb[7] = (byte)((endMsf & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(endMsf & 0xFF);
|
||||
cdb[9] = (byte)((byte)c2Error << 1);
|
||||
cdb[9] += (byte)((byte)headerCodes << 5);
|
||||
cdb[0] = (byte)ScsiCommands.ReadCdMsf;
|
||||
cdb[1] = (byte)((byte)expectedSectorType << 2);
|
||||
if(dap) cdb[1] += 0x02;
|
||||
cdb[3] = (byte)((startMsf & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((startMsf & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(startMsf & 0xFF);
|
||||
cdb[6] = (byte)((endMsf & 0xFF0000) >> 16);
|
||||
cdb[7] = (byte)((endMsf & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(endMsf & 0xFF);
|
||||
cdb[9] = (byte)((byte)c2Error << 1);
|
||||
cdb[9] += (byte)((byte)headerCodes << 5);
|
||||
if(sync) cdb[9] += 0x80;
|
||||
if(userData) cdb[9] += 0x10;
|
||||
if(edcEcc) cdb[9] += 0x08;
|
||||
cdb[10] = (byte)subchannel;
|
||||
cdb[10] = (byte)subchannel;
|
||||
|
||||
uint transferLength = (uint)((cdb[6] - cdb[3]) * 60 * 75 + (cdb[7] - cdb[4]) * 75 + (cdb[8] - cdb[5]));
|
||||
|
||||
@@ -540,11 +540,11 @@ namespace DiscImageChef.Devices
|
||||
public bool PreventAllowMediumRemoval(out byte[] senseBuffer, bool persistent, bool prevent, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] buffer = new byte[0];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval;
|
||||
cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval;
|
||||
if(prevent) cdb[4] += 0x01;
|
||||
if(persistent) cdb[4] += 0x02;
|
||||
|
||||
@@ -577,15 +577,15 @@ namespace DiscImageChef.Devices
|
||||
return StartStopUnit(out senseBuffer, false, 0, 0, false, false, false, timeout, out duration);
|
||||
}
|
||||
|
||||
public bool StartStopUnit(out byte[] senseBuffer, bool immediate, byte formatLayer, byte powerConditions,
|
||||
bool changeFormatLayer, bool loadEject, bool start, uint timeout,
|
||||
public bool StartStopUnit(out byte[] senseBuffer, bool immediate, byte formatLayer, byte powerConditions,
|
||||
bool changeFormatLayer, bool loadEject, bool start, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] buffer = new byte[0];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.StartStopUnit;
|
||||
cdb[0] = (byte)ScsiCommands.StartStopUnit;
|
||||
if(immediate) cdb[1] += 0x01;
|
||||
if(changeFormatLayer)
|
||||
{
|
||||
@@ -613,15 +613,15 @@ namespace DiscImageChef.Devices
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[10];
|
||||
mcn = null;
|
||||
byte[] cdb = new byte[10];
|
||||
mcn = null;
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadSubChannel;
|
||||
cdb[1] = 0;
|
||||
cdb[2] = 0x40;
|
||||
cdb[3] = 0x02;
|
||||
cdb[7] = (23 & 0xFF00) >> 8;
|
||||
cdb[8] = 23 & 0xFF;
|
||||
cdb[8] = 23 & 0xFF;
|
||||
|
||||
buffer = new byte[23];
|
||||
|
||||
@@ -636,12 +636,13 @@ namespace DiscImageChef.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadIsrc(byte trackNumber, out string isrc, out byte[] buffer, out byte[] senseBuffer, uint timeout,
|
||||
out double duration)
|
||||
public bool ReadIsrc(byte trackNumber, out string isrc, out byte[] buffer, out byte[] senseBuffer,
|
||||
uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[10];
|
||||
isrc = null;
|
||||
byte[] cdb = new byte[10];
|
||||
isrc = null;
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadSubChannel;
|
||||
cdb[1] = 0;
|
||||
@@ -649,7 +650,7 @@ namespace DiscImageChef.Devices
|
||||
cdb[3] = 0x03;
|
||||
cdb[6] = trackNumber;
|
||||
cdb[7] = (23 & 0xFF00) >> 8;
|
||||
cdb[8] = 23 & 0xFF;
|
||||
cdb[8] = 23 & 0xFF;
|
||||
|
||||
buffer = new byte[23];
|
||||
|
||||
|
||||
@@ -54,8 +54,8 @@ namespace DiscImageChef.Devices
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.NecReadCdDa;
|
||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
cdb[7] = (byte)((transferLength & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(transferLength & 0xFF);
|
||||
|
||||
@@ -48,21 +48,21 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="transferLength">How many blocks to read.</param>
|
||||
/// <param name="blockSize">Block size.</param>
|
||||
/// <param name="subchannel">Subchannel selection.</param>
|
||||
public bool PioneerReadCdDa(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
|
||||
uint transferLength, PioneerSubchannel subchannel, uint timeout,
|
||||
public bool PioneerReadCdDa(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
|
||||
uint transferLength, PioneerSubchannel subchannel, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadCdDa;
|
||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
cdb[7] = (byte)((transferLength & 0xFF0000) >> 16);
|
||||
cdb[8] = (byte)((transferLength & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(transferLength & 0xFF);
|
||||
cdb[0] = (byte)ScsiCommands.ReadCdDa;
|
||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
cdb[7] = (byte)((transferLength & 0xFF0000) >> 16);
|
||||
cdb[8] = (byte)((transferLength & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(transferLength & 0xFF);
|
||||
cdb[10] = (byte)subchannel;
|
||||
|
||||
buffer = new byte[blockSize * transferLength];
|
||||
@@ -88,19 +88,21 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="endMsf">End MM:SS:FF of read encoded as 0x00MMSSFF.</param>
|
||||
/// <param name="blockSize">Block size.</param>
|
||||
/// <param name="subchannel">Subchannel selection.</param>
|
||||
public bool PioneerReadCdDaMsf(out byte[] buffer, out byte[] senseBuffer, uint startMsf, uint endMsf,
|
||||
uint blockSize, PioneerSubchannel subchannel, uint timeout, out double duration)
|
||||
public bool PioneerReadCdDaMsf(out byte[] buffer, out byte[] senseBuffer, uint startMsf,
|
||||
uint endMsf,
|
||||
uint blockSize, PioneerSubchannel subchannel, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadCdDaMsf;
|
||||
cdb[3] = (byte)((startMsf & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((startMsf & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(startMsf & 0xFF);
|
||||
cdb[7] = (byte)((endMsf & 0xFF0000) >> 16);
|
||||
cdb[8] = (byte)((endMsf & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(endMsf & 0xFF);
|
||||
cdb[0] = (byte)ScsiCommands.ReadCdDaMsf;
|
||||
cdb[3] = (byte)((startMsf & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((startMsf & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(startMsf & 0xFF);
|
||||
cdb[7] = (byte)((endMsf & 0xFF0000) >> 16);
|
||||
cdb[8] = (byte)((endMsf & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(endMsf & 0xFF);
|
||||
cdb[10] = (byte)subchannel;
|
||||
|
||||
uint transferLength = (uint)((cdb[7] - cdb[3]) * 60 * 75 + (cdb[8] - cdb[4]) * 75 + (cdb[9] - cdb[5]));
|
||||
@@ -130,19 +132,20 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="wholeSector">If set to <c>true</c>, returns all 2352 bytes of sector data.</param>
|
||||
/// <param name="lba">Start block address.</param>
|
||||
/// <param name="transferLength">How many blocks to read.</param>
|
||||
public bool PioneerReadCdXa(out byte[] buffer, out byte[] senseBuffer, uint lba, uint transferLength,
|
||||
bool errorFlags, bool wholeSector, uint timeout, out double duration)
|
||||
public bool PioneerReadCdXa(out byte[] buffer, out byte[] senseBuffer, uint lba,
|
||||
uint transferLength,
|
||||
bool errorFlags, bool wholeSector, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadCdXa;
|
||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
cdb[7] = (byte)((transferLength & 0xFF0000) >> 16);
|
||||
cdb[8] = (byte)((transferLength & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)((transferLength & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(transferLength & 0xFF);
|
||||
|
||||
if(errorFlags)
|
||||
|
||||
@@ -48,8 +48,8 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="pba">If set to <c>true</c> address contain physical block address.</param>
|
||||
/// <param name="timeout">Timeout in seconds.</param>
|
||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||
public bool PlasmonReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address,
|
||||
ushort blockBytes, bool pba, uint timeout, out double duration)
|
||||
public bool PlasmonReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address,
|
||||
ushort blockBytes, bool pba, uint timeout, out double duration)
|
||||
{
|
||||
return HpReadLong(out buffer, out senseBuffer, relAddr, address, 0, blockBytes, pba, false, timeout,
|
||||
out duration);
|
||||
@@ -72,12 +72,13 @@ namespace DiscImageChef.Devices
|
||||
/// </param>
|
||||
/// <param name="timeout">Timeout in seconds.</param>
|
||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||
public bool PlasmonReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address,
|
||||
ushort transferLen, ushort blockBytes, bool pba, bool sectorCount, uint timeout,
|
||||
public bool PlasmonReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address,
|
||||
ushort transferLen, ushort blockBytes, bool pba, bool sectorCount,
|
||||
uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
return HpReadLong(out buffer, out senseBuffer, relAddr, address, transferLen, blockBytes, pba, sectorCount,
|
||||
timeout, out duration);
|
||||
timeout, out duration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -90,16 +91,16 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="pba">If set to <c>true</c> address contain a physical block address.</param>
|
||||
/// <param name="timeout">Timeout in seconds.</param>
|
||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||
public bool PlasmonReadSectorLocation(out byte[] buffer, out byte[] senseBuffer, uint address, bool pba,
|
||||
uint timeout, out double duration)
|
||||
public bool PlasmonReadSectorLocation(out byte[] buffer, out byte[] senseBuffer, uint address, bool pba,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[10];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.PlasmonReadSectorLocation;
|
||||
cdb[2] = (byte)((address & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((address & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((address & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)((address & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((address & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(address & 0xFF);
|
||||
if(pba) cdb[9] += 0x80;
|
||||
|
||||
|
||||
@@ -49,22 +49,22 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="transferLength">How many blocks to read.</param>
|
||||
/// <param name="blockSize">Block size.</param>
|
||||
/// <param name="subchannel">Subchannel selection.</param>
|
||||
public bool PlextorReadCdDa(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
|
||||
uint transferLength, PlextorSubchannel subchannel, uint timeout,
|
||||
public bool PlextorReadCdDa(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
|
||||
uint transferLength, PlextorSubchannel subchannel, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadCdDa;
|
||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
cdb[6] = (byte)((transferLength & 0xFF000000) >> 24);
|
||||
cdb[7] = (byte)((transferLength & 0xFF0000) >> 16);
|
||||
cdb[8] = (byte)((transferLength & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(transferLength & 0xFF);
|
||||
cdb[0] = (byte)ScsiCommands.ReadCdDa;
|
||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
cdb[6] = (byte)((transferLength & 0xFF000000) >> 24);
|
||||
cdb[7] = (byte)((transferLength & 0xFF0000) >> 16);
|
||||
cdb[8] = (byte)((transferLength & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(transferLength & 0xFF);
|
||||
cdb[10] = (byte)subchannel;
|
||||
|
||||
buffer = new byte[blockSize * transferLength];
|
||||
@@ -88,8 +88,8 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||
/// <param name="lba">Start block address.</param>
|
||||
/// <param name="transferLength">How many blocks to read.</param>
|
||||
public bool PlextorReadRawDvd(out byte[] buffer, out byte[] senseBuffer, uint lba, uint transferLength,
|
||||
uint timeout, out double duration)
|
||||
public bool PlextorReadRawDvd(out byte[] buffer, out byte[] senseBuffer, uint lba, uint transferLength,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[10];
|
||||
@@ -98,10 +98,10 @@ namespace DiscImageChef.Devices
|
||||
cdb[0] = (byte)ScsiCommands.ReadBuffer;
|
||||
cdb[1] = 0x02;
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
cdb[3] = (byte)((buffer.Length & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[4] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(buffer.Length & 0xFF);
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -123,7 +123,7 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool PlextorReadEepromCdr(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[256];
|
||||
buffer = new byte[256];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool PlextorReadEeprom(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[512];
|
||||
buffer = new byte[512];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
@@ -175,10 +175,10 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="blockSize">How many bytes are in the EEPROM block</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool PlextorReadEepromBlock(out byte[] buffer, out byte[] senseBuffer, byte block, ushort blockSize,
|
||||
uint timeout, out double duration)
|
||||
public bool PlextorReadEepromBlock(out byte[] buffer, out byte[] senseBuffer, byte block, ushort blockSize,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[blockSize];
|
||||
buffer = new byte[blockSize];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
@@ -208,15 +208,15 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool PlextorGetSpeeds(out byte[] senseBuffer, out ushort selected, out ushort max, out ushort last,
|
||||
uint timeout, out double duration)
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
byte[] buf = new byte[10];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
selected = 0;
|
||||
max = 0;
|
||||
last = 0;
|
||||
max = 0;
|
||||
last = 0;
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.PlextorPoweRec;
|
||||
cdb[9] = (byte)buf.Length;
|
||||
@@ -230,9 +230,9 @@ namespace DiscImageChef.Devices
|
||||
if(sense || Error) return sense;
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
selected = BigEndianBitConverter.ToUInt16(buf, 4);
|
||||
max = BigEndianBitConverter.ToUInt16(buf, 6);
|
||||
last = BigEndianBitConverter.ToUInt16(buf, 8);
|
||||
selected = BigEndianBitConverter.ToUInt16(buf, 4);
|
||||
max = BigEndianBitConverter.ToUInt16(buf, 6);
|
||||
last = BigEndianBitConverter.ToUInt16(buf, 8);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -254,7 +254,7 @@ namespace DiscImageChef.Devices
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
enabled = false;
|
||||
speed = 0;
|
||||
speed = 0;
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.PlextorExtend2;
|
||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||
@@ -269,8 +269,8 @@ namespace DiscImageChef.Devices
|
||||
if(sense || Error) return sense;
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
enabled = buf[2] != 0;
|
||||
speed = BigEndianBitConverter.ToUInt16(buf, 4);
|
||||
enabled = buf[2] != 0;
|
||||
speed = BigEndianBitConverter.ToUInt16(buf, 4);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -285,14 +285,14 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool PlextorGetSilentMode(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[8];
|
||||
buffer = new byte[8];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||
cdb[2] = (byte)PlextorSubCommands.Silent;
|
||||
cdb[3] = 4;
|
||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||
cdb[2] = (byte)PlextorSubCommands.Silent;
|
||||
cdb[3] = 4;
|
||||
cdb[10] = (byte)buffer.Length;
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -314,13 +314,13 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool PlextorGetGigaRec(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[8];
|
||||
buffer = new byte[8];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||
cdb[2] = (byte)PlextorSubCommands.GigaRec;
|
||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||
cdb[2] = (byte)PlextorSubCommands.GigaRec;
|
||||
cdb[10] = (byte)buffer.Length;
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -344,17 +344,17 @@ namespace DiscImageChef.Devices
|
||||
public bool PlextorGetVariRec(out byte[] buffer, out byte[] senseBuffer, bool dvd, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
buffer = new byte[8];
|
||||
buffer = new byte[8];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||
cdb[2] = (byte)PlextorSubCommands.VariRec;
|
||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||
cdb[2] = (byte)PlextorSubCommands.VariRec;
|
||||
cdb[10] = (byte)buffer.Length;
|
||||
|
||||
if(dvd) cdb[3] = 0x12;
|
||||
else cdb[3] = 0x02;
|
||||
else cdb[3] = 0x02;
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out bool sense);
|
||||
@@ -375,12 +375,12 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool PlextorGetSecuRec(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[8];
|
||||
buffer = new byte[8];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||
cdb[2] = (byte)PlextorSubCommands.SecuRec;
|
||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||
cdb[2] = (byte)PlextorSubCommands.SecuRec;
|
||||
cdb[10] = (byte)buffer.Length;
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -402,13 +402,13 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool PlextorGetSpeedRead(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[8];
|
||||
buffer = new byte[8];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||
cdb[2] = (byte)PlextorSubCommands.SpeedRead;
|
||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||
cdb[2] = (byte)PlextorSubCommands.SpeedRead;
|
||||
cdb[10] = (byte)buffer.Length;
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -430,7 +430,7 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool PlextorGetHiding(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[8];
|
||||
buffer = new byte[8];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
@@ -460,7 +460,7 @@ namespace DiscImageChef.Devices
|
||||
public bool PlextorGetBitsetting(out byte[] buffer, out byte[] senseBuffer, bool dualLayer, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
buffer = new byte[8];
|
||||
buffer = new byte[8];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
@@ -470,7 +470,7 @@ namespace DiscImageChef.Devices
|
||||
cdb[9] = (byte)buffer.Length;
|
||||
|
||||
if(dualLayer) cdb[3] = (byte)PlextorSubCommands.BitSetRdl;
|
||||
else cdb[3] = (byte)PlextorSubCommands.BitSetR;
|
||||
else cdb[3] = (byte)PlextorSubCommands.BitSetR;
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out bool sense);
|
||||
@@ -492,13 +492,13 @@ namespace DiscImageChef.Devices
|
||||
public bool PlextorGetTestWriteDvdPlus(out byte[] buffer, out byte[] senseBuffer, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
buffer = new byte[8];
|
||||
buffer = new byte[8];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||
cdb[2] = (byte)PlextorSubCommands.TestWriteDvdPlus;
|
||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||
cdb[2] = (byte)PlextorSubCommands.TestWriteDvdPlus;
|
||||
cdb[10] = (byte)buffer.Length;
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
|
||||
@@ -64,20 +64,20 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="lba">Starting block.</param>
|
||||
/// <param name="blockSize">Block size in bytes.</param>
|
||||
/// <param name="transferLength">How many blocks to read.</param>
|
||||
public bool Read6(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize, byte transferLength,
|
||||
uint timeout, out double duration)
|
||||
public bool Read6(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize, byte transferLength,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[6];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.Read6;
|
||||
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
|
||||
cdb[2] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[2] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)(lba & 0xFF);
|
||||
cdb[4] = transferLength;
|
||||
|
||||
if(transferLength == 0) buffer = new byte[256 * blockSize];
|
||||
else buffer = new byte[transferLength * blockSize];
|
||||
if(transferLength == 0) buffer = new byte[256 * blockSize];
|
||||
else buffer = new byte[transferLength * blockSize];
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out bool sense);
|
||||
@@ -111,23 +111,25 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="groupNumber">Group number where attributes associated with this command should be collected.</param>
|
||||
/// <param name="transferLength">How many blocks to read.</param>
|
||||
/// <param name="relAddr">If set to <c>true</c> address is relative to current position.</param>
|
||||
public bool Read10(out byte[] buffer, out byte[] senseBuffer, byte rdprotect, bool dpo, bool fua, bool fuaNv,
|
||||
bool relAddr, uint lba, uint blockSize, byte groupNumber, ushort transferLength,
|
||||
uint timeout, out double duration)
|
||||
public bool Read10(out byte[] buffer, out byte[] senseBuffer, byte rdprotect, bool dpo, bool fua,
|
||||
bool fuaNv,
|
||||
bool relAddr, uint lba, uint blockSize, byte groupNumber,
|
||||
ushort transferLength,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[10];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.Read10;
|
||||
cdb[1] = (byte)((rdprotect & 0x07) << 5);
|
||||
if(dpo) cdb[1] += 0x10;
|
||||
if(fua) cdb[1] += 0x08;
|
||||
if(fuaNv) cdb[1] += 0x02;
|
||||
if(dpo) cdb[1] += 0x10;
|
||||
if(fua) cdb[1] += 0x08;
|
||||
if(fuaNv) cdb[1] += 0x02;
|
||||
if(relAddr) cdb[1] += 0x01;
|
||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
cdb[6] = (byte)(groupNumber & 0x1F);
|
||||
cdb[7] = (byte)((transferLength & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(transferLength & 0xFF);
|
||||
@@ -167,28 +169,30 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="transferLength">How many blocks to read.</param>
|
||||
/// <param name="streaming">If set to <c>true</c> the stream playback operation should be used (MMC only).</param>
|
||||
/// <param name="relAddr">If set to <c>true</c> address is relative to current position.</param>
|
||||
public bool Read12(out byte[] buffer, out byte[] senseBuffer, byte rdprotect, bool dpo, bool fua, bool fuaNv,
|
||||
bool relAddr, uint lba, uint blockSize, byte groupNumber, uint transferLength,
|
||||
bool streaming, uint timeout, out double duration)
|
||||
public bool Read12(out byte[] buffer, out byte[] senseBuffer, byte rdprotect, bool dpo,
|
||||
bool fua, bool fuaNv,
|
||||
bool relAddr, uint lba, uint blockSize, byte groupNumber,
|
||||
uint transferLength,
|
||||
bool streaming, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.Read12;
|
||||
cdb[1] = (byte)((rdprotect & 0x07) << 5);
|
||||
if(dpo) cdb[1] += 0x10;
|
||||
if(fua) cdb[1] += 0x08;
|
||||
if(fuaNv) cdb[1] += 0x02;
|
||||
if(dpo) cdb[1] += 0x10;
|
||||
if(fua) cdb[1] += 0x08;
|
||||
if(fuaNv) cdb[1] += 0x02;
|
||||
if(relAddr) cdb[1] += 0x01;
|
||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
cdb[6] = (byte)((transferLength & 0xFF000000) >> 24);
|
||||
cdb[7] = (byte)((transferLength & 0xFF0000) >> 16);
|
||||
cdb[8] = (byte)((transferLength & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(transferLength & 0xFF);
|
||||
cdb[10] = (byte)(groupNumber & 0x1F);
|
||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
cdb[6] = (byte)((transferLength & 0xFF000000) >> 24);
|
||||
cdb[7] = (byte)((transferLength & 0xFF0000) >> 16);
|
||||
cdb[8] = (byte)((transferLength & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(transferLength & 0xFF);
|
||||
cdb[10] = (byte)(groupNumber & 0x1F);
|
||||
if(streaming) cdb[10] += 0x80;
|
||||
|
||||
buffer = new byte[transferLength * blockSize];
|
||||
@@ -225,32 +229,34 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="groupNumber">Group number where attributes associated with this command should be collected.</param>
|
||||
/// <param name="transferLength">How many blocks to read.</param>
|
||||
/// <param name="streaming">If set to <c>true</c> the stream playback operation should be used (MMC only).</param>
|
||||
public bool Read16(out byte[] buffer, out byte[] senseBuffer, byte rdprotect, bool dpo, bool fua, bool fuaNv,
|
||||
ulong lba, uint blockSize, byte groupNumber, uint transferLength, bool streaming,
|
||||
uint timeout, out double duration)
|
||||
public bool Read16(out byte[] buffer, out byte[] senseBuffer, byte rdprotect, bool dpo, bool fua,
|
||||
bool fuaNv,
|
||||
ulong lba, uint blockSize, byte groupNumber, uint transferLength,
|
||||
bool streaming,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[16];
|
||||
byte[] cdb = new byte[16];
|
||||
byte[] lbaBytes = BitConverter.GetBytes(lba);
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.Read16;
|
||||
cdb[1] = (byte)((rdprotect & 0x07) << 5);
|
||||
if(dpo) cdb[1] += 0x10;
|
||||
if(fua) cdb[1] += 0x08;
|
||||
if(dpo) cdb[1] += 0x10;
|
||||
if(fua) cdb[1] += 0x08;
|
||||
if(fuaNv) cdb[1] += 0x02;
|
||||
cdb[2] = lbaBytes[7];
|
||||
cdb[3] = lbaBytes[6];
|
||||
cdb[4] = lbaBytes[5];
|
||||
cdb[5] = lbaBytes[4];
|
||||
cdb[6] = lbaBytes[3];
|
||||
cdb[7] = lbaBytes[2];
|
||||
cdb[8] = lbaBytes[1];
|
||||
cdb[9] = lbaBytes[0];
|
||||
cdb[2] = lbaBytes[7];
|
||||
cdb[3] = lbaBytes[6];
|
||||
cdb[4] = lbaBytes[5];
|
||||
cdb[5] = lbaBytes[4];
|
||||
cdb[6] = lbaBytes[3];
|
||||
cdb[7] = lbaBytes[2];
|
||||
cdb[8] = lbaBytes[1];
|
||||
cdb[9] = lbaBytes[0];
|
||||
cdb[10] = (byte)((transferLength & 0xFF000000) >> 24);
|
||||
cdb[11] = (byte)((transferLength & 0xFF0000) >> 16);
|
||||
cdb[12] = (byte)((transferLength & 0xFF00) >> 8);
|
||||
cdb[11] = (byte)((transferLength & 0xFF0000) >> 16);
|
||||
cdb[12] = (byte)((transferLength & 0xFF00) >> 8);
|
||||
cdb[13] = (byte)(transferLength & 0xFF);
|
||||
cdb[14] = (byte)(groupNumber & 0x1F);
|
||||
cdb[14] = (byte)(groupNumber & 0x1F);
|
||||
if(streaming) cdb[14] += 0x80;
|
||||
|
||||
buffer = new byte[transferLength * blockSize];
|
||||
@@ -279,8 +285,9 @@ namespace DiscImageChef.Devices
|
||||
/// How many bytes to read. If the number is not exactly the drive's size, the command will
|
||||
/// fail and incidate a delta of the size in SENSE.
|
||||
/// </param>
|
||||
public bool ReadLong10(out byte[] buffer, out byte[] senseBuffer, bool correct, bool relAddr, uint lba,
|
||||
ushort transferBytes, uint timeout, out double duration)
|
||||
public bool ReadLong10(out byte[] buffer, out byte[] senseBuffer, bool correct, bool relAddr,
|
||||
uint lba,
|
||||
ushort transferBytes, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[10];
|
||||
@@ -289,8 +296,8 @@ namespace DiscImageChef.Devices
|
||||
if(correct) cdb[1] += 0x02;
|
||||
if(relAddr) cdb[1] += 0x01;
|
||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
cdb[7] = (byte)((transferBytes & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(transferBytes & 0xFF);
|
||||
@@ -320,23 +327,23 @@ namespace DiscImageChef.Devices
|
||||
/// How many bytes to read. If the number is not exactly the drive's size, the command will
|
||||
/// fail and incidate a delta of the size in SENSE.
|
||||
/// </param>
|
||||
public bool ReadLong16(out byte[] buffer, out byte[] senseBuffer, bool correct, ulong lba, uint transferBytes,
|
||||
uint timeout, out double duration)
|
||||
public bool ReadLong16(out byte[] buffer, out byte[] senseBuffer, bool correct, ulong lba, uint transferBytes,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[16];
|
||||
byte[] cdb = new byte[16];
|
||||
byte[] lbaBytes = BitConverter.GetBytes(lba);
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ServiceActionIn;
|
||||
cdb[1] = (byte)ScsiServiceActions.ReadLong16;
|
||||
cdb[2] = lbaBytes[7];
|
||||
cdb[3] = lbaBytes[6];
|
||||
cdb[4] = lbaBytes[5];
|
||||
cdb[5] = lbaBytes[4];
|
||||
cdb[6] = lbaBytes[3];
|
||||
cdb[7] = lbaBytes[2];
|
||||
cdb[8] = lbaBytes[1];
|
||||
cdb[9] = lbaBytes[0];
|
||||
cdb[0] = (byte)ScsiCommands.ServiceActionIn;
|
||||
cdb[1] = (byte)ScsiServiceActions.ReadLong16;
|
||||
cdb[2] = lbaBytes[7];
|
||||
cdb[3] = lbaBytes[6];
|
||||
cdb[4] = lbaBytes[5];
|
||||
cdb[5] = lbaBytes[4];
|
||||
cdb[6] = lbaBytes[3];
|
||||
cdb[7] = lbaBytes[2];
|
||||
cdb[8] = lbaBytes[1];
|
||||
cdb[9] = lbaBytes[0];
|
||||
cdb[12] = (byte)((transferBytes & 0xFF00) >> 8);
|
||||
cdb[13] = (byte)(transferBytes & 0xFF);
|
||||
if(correct) cdb[14] += 0x01;
|
||||
@@ -362,12 +369,12 @@ namespace DiscImageChef.Devices
|
||||
public bool Seek6(out byte[] senseBuffer, uint lba, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] buffer = new byte[0];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.Seek6;
|
||||
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
|
||||
cdb[2] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[2] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)(lba & 0xFF);
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||
@@ -389,13 +396,13 @@ namespace DiscImageChef.Devices
|
||||
public bool Seek10(out byte[] senseBuffer, uint lba, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[10];
|
||||
byte[] cdb = new byte[10];
|
||||
byte[] buffer = new byte[0];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.Seek10;
|
||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||
|
||||
@@ -50,26 +50,28 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="cache">If set to <c>true</c> device can return cached data.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action, ushort element,
|
||||
byte elementType, byte volume, byte partition, ushort firstAttribute, bool cache,
|
||||
uint timeout, out double duration)
|
||||
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
|
||||
ushort element,
|
||||
byte elementType, byte volume, byte partition,
|
||||
ushort firstAttribute, bool cache,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[256];
|
||||
byte[] cdb = new byte[16];
|
||||
senseBuffer = new byte[32];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadAttribute;
|
||||
cdb[1] = (byte)((byte)action & 0x1F);
|
||||
cdb[2] = (byte)((element & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)(element & 0xFF);
|
||||
cdb[4] = (byte)(elementType & 0x0F);
|
||||
cdb[5] = volume;
|
||||
cdb[7] = partition;
|
||||
cdb[8] = (byte)((firstAttribute & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(firstAttribute & 0xFF);
|
||||
cdb[0] = (byte)ScsiCommands.ReadAttribute;
|
||||
cdb[1] = (byte)((byte)action & 0x1F);
|
||||
cdb[2] = (byte)((element & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)(element & 0xFF);
|
||||
cdb[4] = (byte)(elementType & 0x0F);
|
||||
cdb[5] = volume;
|
||||
cdb[7] = partition;
|
||||
cdb[8] = (byte)((firstAttribute & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(firstAttribute & 0xFF);
|
||||
cdb[10] = (byte)((buffer.Length & 0xFF000000) >> 24);
|
||||
cdb[11] = (byte)((buffer.Length & 0xFF0000) >> 16);
|
||||
cdb[12] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[11] = (byte)((buffer.Length & 0xFF0000) >> 16);
|
||||
cdb[12] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[13] = (byte)(buffer.Length & 0xFF);
|
||||
if(cache) cdb[14] += 0x01;
|
||||
|
||||
@@ -80,11 +82,11 @@ namespace DiscImageChef.Devices
|
||||
if(sense) return true;
|
||||
|
||||
uint attrLen = (uint)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3] + 4);
|
||||
buffer = new byte[attrLen];
|
||||
cdb[10] = (byte)((buffer.Length & 0xFF000000) >> 24);
|
||||
cdb[11] = (byte)((buffer.Length & 0xFF0000) >> 16);
|
||||
cdb[12] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[13] = (byte)(buffer.Length & 0xFF);
|
||||
buffer = new byte[attrLen];
|
||||
cdb[10] = (byte)((buffer.Length & 0xFF000000) >> 24);
|
||||
cdb[11] = (byte)((buffer.Length & 0xFF0000) >> 16);
|
||||
cdb[12] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[13] = (byte)(buffer.Length & 0xFF);
|
||||
senseBuffer = new byte[32];
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||
public bool ScsiInquiry(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[36];
|
||||
buffer = new byte[36];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = {(byte)ScsiCommands.Inquiry, 0, 0, 0, 36, 0};
|
||||
|
||||
@@ -97,8 +97,8 @@ namespace DiscImageChef.Devices
|
||||
|
||||
byte pagesLength = (byte)(buffer[4] + 5);
|
||||
|
||||
cdb = new byte[] {(byte)ScsiCommands.Inquiry, 0, 0, 0, pagesLength, 0};
|
||||
buffer = new byte[pagesLength];
|
||||
cdb = new byte[] {(byte)ScsiCommands.Inquiry, 0, 0, 0, pagesLength, 0};
|
||||
buffer = new byte[pagesLength];
|
||||
senseBuffer = new byte[32];
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -159,7 +159,7 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="page">The Extended Vital Product Data</param>
|
||||
public bool ScsiInquiry(out byte[] buffer, out byte[] senseBuffer, byte page, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[36];
|
||||
buffer = new byte[36];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = {(byte)ScsiCommands.Inquiry, 1, page, 0, 36, 0};
|
||||
|
||||
@@ -174,8 +174,8 @@ namespace DiscImageChef.Devices
|
||||
|
||||
byte pagesLength = (byte)(buffer[3] + 4);
|
||||
|
||||
cdb = new byte[] {(byte)ScsiCommands.Inquiry, 1, page, 0, pagesLength, 0};
|
||||
buffer = new byte[pagesLength];
|
||||
cdb = new byte[] {(byte)ScsiCommands.Inquiry, 1, page, 0, pagesLength, 0};
|
||||
buffer = new byte[pagesLength];
|
||||
senseBuffer = new byte[32];
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -197,7 +197,7 @@ namespace DiscImageChef.Devices
|
||||
public bool ScsiTestUnitReady(out byte[] senseBuffer, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = {(byte)ScsiCommands.TestUnitReady, 0, 0, 0, 0, 0};
|
||||
byte[] cdb = {(byte)ScsiCommands.TestUnitReady, 0, 0, 0, 0, 0};
|
||||
byte[] buffer = new byte[0];
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||
@@ -234,8 +234,9 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="dbd">If set to <c>true</c> device MUST not return any block descriptor.</param>
|
||||
/// <param name="pageControl">Page control.</param>
|
||||
/// <param name="pageCode">Page code.</param>
|
||||
public bool ModeSense6(out byte[] buffer, out byte[] senseBuffer, bool dbd,
|
||||
ScsiModeSensePageControl pageControl, byte pageCode, uint timeout, out double duration)
|
||||
public bool ModeSense6(out byte[] buffer, out byte[] senseBuffer, bool dbd,
|
||||
ScsiModeSensePageControl pageControl, byte pageCode, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
return ModeSense6(out buffer, out senseBuffer, dbd, pageControl, pageCode, 0, timeout, out duration);
|
||||
}
|
||||
@@ -252,9 +253,10 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="pageControl">Page control.</param>
|
||||
/// <param name="pageCode">Page code.</param>
|
||||
/// <param name="subPageCode">Sub-page code.</param>
|
||||
public bool ModeSense6(out byte[] buffer, out byte[] senseBuffer, bool dbd,
|
||||
ScsiModeSensePageControl pageControl, byte pageCode, byte subPageCode, uint timeout,
|
||||
out double duration)
|
||||
public bool ModeSense6(out byte[] buffer, out byte[] senseBuffer, bool dbd,
|
||||
ScsiModeSensePageControl pageControl, byte pageCode, byte subPageCode,
|
||||
uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[6];
|
||||
@@ -264,9 +266,9 @@ namespace DiscImageChef.Devices
|
||||
if(dbd) cdb[1] = 0x08;
|
||||
cdb[2] |= (byte)pageControl;
|
||||
cdb[2] |= (byte)(pageCode & 0x3F);
|
||||
cdb[3] = subPageCode;
|
||||
cdb[4] = (byte)buffer.Length;
|
||||
cdb[5] = 0;
|
||||
cdb[3] = subPageCode;
|
||||
cdb[4] = (byte)buffer.Length;
|
||||
cdb[5] = 0;
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out bool sense);
|
||||
@@ -275,8 +277,8 @@ namespace DiscImageChef.Devices
|
||||
if(sense) return true;
|
||||
|
||||
byte modeLength = (byte)(buffer[0] + 1);
|
||||
buffer = new byte[modeLength];
|
||||
cdb[4] = (byte)buffer.Length;
|
||||
buffer = new byte[modeLength];
|
||||
cdb[4] = (byte)buffer.Length;
|
||||
senseBuffer = new byte[32];
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -299,8 +301,9 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="dbd">If set to <c>true</c> device MUST not return any block descriptor.</param>
|
||||
/// <param name="pageControl">Page control.</param>
|
||||
/// <param name="pageCode">Page code.</param>
|
||||
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool dbd,
|
||||
ScsiModeSensePageControl pageControl, byte pageCode, uint timeout, out double duration)
|
||||
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool dbd,
|
||||
ScsiModeSensePageControl pageControl, byte pageCode, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
return ModeSense10(out buffer, out senseBuffer, false, dbd, pageControl, pageCode, 0, timeout,
|
||||
out duration);
|
||||
@@ -318,8 +321,10 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="pageControl">Page control.</param>
|
||||
/// <param name="pageCode">Page code.</param>
|
||||
/// <param name="llbaa">If set means 64-bit LBAs are accepted by the caller.</param>
|
||||
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool llbaa, bool dbd,
|
||||
ScsiModeSensePageControl pageControl, byte pageCode, uint timeout, out double duration)
|
||||
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool llbaa,
|
||||
bool dbd,
|
||||
ScsiModeSensePageControl pageControl, byte pageCode, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
return ModeSense10(out buffer, out senseBuffer, llbaa, dbd, pageControl, pageCode, 0, timeout,
|
||||
out duration);
|
||||
@@ -338,9 +343,11 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="pageCode">Page code.</param>
|
||||
/// <param name="subPageCode">Sub-page code.</param>
|
||||
/// <param name="llbaa">If set means 64-bit LBAs are accepted by the caller.</param>
|
||||
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool llbaa, bool dbd,
|
||||
ScsiModeSensePageControl pageControl, byte pageCode, byte subPageCode, uint timeout,
|
||||
out double duration)
|
||||
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool llbaa,
|
||||
bool dbd,
|
||||
ScsiModeSensePageControl pageControl, byte pageCode, byte subPageCode,
|
||||
uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[10];
|
||||
@@ -348,13 +355,13 @@ namespace DiscImageChef.Devices
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ModeSense10;
|
||||
if(llbaa) cdb[1] |= 0x10;
|
||||
if(dbd) cdb[1] |= 0x08;
|
||||
if(dbd) cdb[1] |= 0x08;
|
||||
cdb[2] |= (byte)pageControl;
|
||||
cdb[2] |= (byte)(pageCode & 0x3F);
|
||||
cdb[3] = subPageCode;
|
||||
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(buffer.Length & 0xFF);
|
||||
cdb[9] = 0;
|
||||
cdb[3] = subPageCode;
|
||||
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(buffer.Length & 0xFF);
|
||||
cdb[9] = 0;
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out bool sense);
|
||||
@@ -363,9 +370,9 @@ namespace DiscImageChef.Devices
|
||||
if(sense) return true;
|
||||
|
||||
ushort modeLength = (ushort)((buffer[0] << 8) + buffer[1] + 2);
|
||||
buffer = new byte[modeLength];
|
||||
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(buffer.Length & 0xFF);
|
||||
buffer = new byte[modeLength];
|
||||
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(buffer.Length & 0xFF);
|
||||
senseBuffer = new byte[32];
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -431,7 +438,7 @@ namespace DiscImageChef.Devices
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] buffer = new byte[0];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval;
|
||||
@@ -470,8 +477,8 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="pmi">If set, it is requesting partial media capacity</param>
|
||||
/// <param name="timeout">Timeout in seconds.</param>
|
||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||
public bool ReadCapacity(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address, bool pmi,
|
||||
uint timeout, out double duration)
|
||||
public bool ReadCapacity(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address, bool pmi,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[10];
|
||||
@@ -485,8 +492,8 @@ namespace DiscImageChef.Devices
|
||||
if(relAddr) cdb[1] = 0x01;
|
||||
|
||||
cdb[2] = (byte)((address & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((address & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((address & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)((address & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((address & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(address & 0xFF);
|
||||
}
|
||||
|
||||
@@ -547,8 +554,8 @@ namespace DiscImageChef.Devices
|
||||
}
|
||||
|
||||
cdb[10] = (byte)((buffer.Length & 0xFF000000) >> 24);
|
||||
cdb[11] = (byte)((buffer.Length & 0xFF0000) >> 16);
|
||||
cdb[12] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[11] = (byte)((buffer.Length & 0xFF0000) >> 16);
|
||||
cdb[12] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[13] = (byte)(buffer.Length & 0xFF);
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -577,8 +584,8 @@ namespace DiscImageChef.Devices
|
||||
cdb[0] = (byte)ScsiCommands.ReadSerialNumber;
|
||||
cdb[1] = 0x01;
|
||||
cdb[6] = (byte)((buffer.Length & 0xFF000000) >> 24);
|
||||
cdb[7] = (byte)((buffer.Length & 0xFF0000) >> 16);
|
||||
cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[7] = (byte)((buffer.Length & 0xFF0000) >> 16);
|
||||
cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(buffer.Length & 0xFF);
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -588,11 +595,11 @@ namespace DiscImageChef.Devices
|
||||
if(sense) return true;
|
||||
|
||||
uint strctLength = (uint)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3] + 4);
|
||||
buffer = new byte[strctLength];
|
||||
cdb[6] = (byte)((buffer.Length & 0xFF000000) >> 24);
|
||||
cdb[7] = (byte)((buffer.Length & 0xFF0000) >> 16);
|
||||
cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(buffer.Length & 0xFF);
|
||||
buffer = new byte[strctLength];
|
||||
cdb[6] = (byte)((buffer.Length & 0xFF000000) >> 24);
|
||||
cdb[7] = (byte)((buffer.Length & 0xFF0000) >> 16);
|
||||
cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(buffer.Length & 0xFF);
|
||||
senseBuffer = new byte[32];
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -615,11 +622,13 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="cache">If set to <c>true</c> device can return cached data.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action, byte partition,
|
||||
ushort firstAttribute, bool cache, uint timeout, out double duration)
|
||||
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
|
||||
byte partition,
|
||||
ushort firstAttribute, bool cache, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
return ReadAttribute(out buffer, out senseBuffer, action, 0, 0, 0, partition, firstAttribute, cache,
|
||||
timeout, out duration);
|
||||
timeout, out duration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -632,8 +641,9 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="cache">If set to <c>true</c> device can return cached data.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
|
||||
ushort firstAttribute, bool cache, uint timeout, out double duration)
|
||||
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
|
||||
ushort firstAttribute, bool cache, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
return ReadAttribute(out buffer, out senseBuffer, action, 0, 0, 0, 0, firstAttribute, cache, timeout,
|
||||
out duration);
|
||||
@@ -649,11 +659,12 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="firstAttribute">First attribute identifier.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action, byte partition,
|
||||
ushort firstAttribute, uint timeout, out double duration)
|
||||
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
|
||||
byte partition,
|
||||
ushort firstAttribute, uint timeout, out double duration)
|
||||
{
|
||||
return ReadAttribute(out buffer, out senseBuffer, action, 0, 0, 0, partition, firstAttribute, false,
|
||||
timeout, out duration);
|
||||
timeout, out duration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -665,8 +676,8 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="firstAttribute">First attribute identifier.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
|
||||
ushort firstAttribute, uint timeout, out double duration)
|
||||
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
|
||||
ushort firstAttribute, uint timeout, out double duration)
|
||||
{
|
||||
return ReadAttribute(out buffer, out senseBuffer, action, 0, 0, 0, 0, firstAttribute, false, timeout,
|
||||
out duration);
|
||||
@@ -683,11 +694,13 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="firstAttribute">First attribute identifier.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action, byte volume,
|
||||
byte partition, ushort firstAttribute, uint timeout, out double duration)
|
||||
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
|
||||
byte volume,
|
||||
byte partition, ushort firstAttribute, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
return ReadAttribute(out buffer, out senseBuffer, action, 0, 0, volume, partition, firstAttribute, false,
|
||||
timeout, out duration);
|
||||
timeout, out duration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -702,11 +715,13 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="cache">If set to <c>true</c> device can return cached data.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action, byte volume,
|
||||
byte partition, ushort firstAttribute, bool cache, uint timeout, out double duration)
|
||||
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
|
||||
byte volume,
|
||||
byte partition, ushort firstAttribute, bool cache,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
return ReadAttribute(out buffer, out senseBuffer, action, 0, 0, volume, partition, firstAttribute, cache,
|
||||
timeout, out duration);
|
||||
timeout, out duration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -719,7 +734,7 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="timeout">Timeout in seconds.</param>
|
||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||
/// <param name="pageFormat">Set if page is formatted.</param>
|
||||
public bool ModeSelect(byte[] buffer, out byte[] senseBuffer, bool pageFormat, bool savePages, uint timeout,
|
||||
public bool ModeSelect(byte[] buffer, out byte[] senseBuffer, bool pageFormat, bool savePages, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
@@ -727,11 +742,11 @@ namespace DiscImageChef.Devices
|
||||
// Prevent overflows
|
||||
if(buffer.Length > 255)
|
||||
{
|
||||
if(PlatformId != PlatformID.Win32NT && PlatformId != PlatformID.Win32S &&
|
||||
PlatformId != PlatformID.Win32Windows && PlatformId != PlatformID.WinCE &&
|
||||
if(PlatformId != PlatformID.Win32NT && PlatformId != PlatformID.Win32S &&
|
||||
PlatformId != PlatformID.Win32Windows && PlatformId != PlatformID.WinCE &&
|
||||
PlatformId != PlatformID.WindowsPhone && PlatformId != PlatformID.Xbox) LastError = 75;
|
||||
else LastError = 111;
|
||||
Error = true;
|
||||
else LastError = 111;
|
||||
Error = true;
|
||||
duration = 0;
|
||||
return true;
|
||||
}
|
||||
@@ -740,7 +755,7 @@ namespace DiscImageChef.Devices
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ModeSelect;
|
||||
if(pageFormat) cdb[1] += 0x10;
|
||||
if(savePages) cdb[1] += 0x01;
|
||||
if(savePages) cdb[1] += 0x01;
|
||||
cdb[4] = (byte)buffer.Length;
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
|
||||
@@ -762,7 +777,8 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="timeout">Timeout in seconds.</param>
|
||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||
/// <param name="pageFormat">Set if page is formatted.</param>
|
||||
public bool ModeSelect10(byte[] buffer, out byte[] senseBuffer, bool pageFormat, bool savePages, uint timeout,
|
||||
public bool ModeSelect10(byte[] buffer, out byte[] senseBuffer, bool pageFormat, bool savePages,
|
||||
uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
@@ -770,11 +786,11 @@ namespace DiscImageChef.Devices
|
||||
// Prevent overflows
|
||||
if(buffer.Length > 65535)
|
||||
{
|
||||
if(PlatformId != PlatformID.Win32NT && PlatformId != PlatformID.Win32S &&
|
||||
PlatformId != PlatformID.Win32Windows && PlatformId != PlatformID.WinCE &&
|
||||
if(PlatformId != PlatformID.Win32NT && PlatformId != PlatformID.Win32S &&
|
||||
PlatformId != PlatformID.Win32Windows && PlatformId != PlatformID.WinCE &&
|
||||
PlatformId != PlatformID.WindowsPhone && PlatformId != PlatformID.Xbox) LastError = 75;
|
||||
else LastError = 111;
|
||||
Error = true;
|
||||
else LastError = 111;
|
||||
Error = true;
|
||||
duration = 0;
|
||||
return true;
|
||||
}
|
||||
@@ -783,7 +799,7 @@ namespace DiscImageChef.Devices
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ModeSelect10;
|
||||
if(pageFormat) cdb[1] += 0x10;
|
||||
if(savePages) cdb[1] += 0x01;
|
||||
if(savePages) cdb[1] += 0x01;
|
||||
cdb[7] = (byte)((buffer.Length & 0xFF00) << 8);
|
||||
cdb[8] = (byte)(buffer.Length & 0xFF);
|
||||
|
||||
|
||||
@@ -76,19 +76,19 @@ namespace DiscImageChef.Devices
|
||||
/// </param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool LoadUnload(out byte[] senseBuffer, bool immediate, bool load, bool retense, bool endOfTape,
|
||||
bool hold, uint timeout, out double duration)
|
||||
public bool LoadUnload(out byte[] senseBuffer, bool immediate, bool load, bool retense, bool endOfTape,
|
||||
bool hold, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] buffer = new byte[0];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.LoadUnload;
|
||||
if(immediate) cdb[1] = 0x01;
|
||||
if(load) cdb[4] += 0x01;
|
||||
if(retense) cdb[4] += 0x02;
|
||||
if(immediate) cdb[1] = 0x01;
|
||||
if(load) cdb[4] += 0x01;
|
||||
if(retense) cdb[4] += 0x02;
|
||||
if(endOfTape) cdb[4] += 0x04;
|
||||
if(hold) cdb[4] += 0x08;
|
||||
if(hold) cdb[4] += 0x08;
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||
out bool sense);
|
||||
@@ -163,20 +163,21 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="objectId">Object identifier.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool Locate(out byte[] senseBuffer, bool immediate, bool blockType, bool changePartition, byte partition,
|
||||
uint objectId, uint timeout, out double duration)
|
||||
public bool Locate(out byte[] senseBuffer, bool immediate, bool blockType, bool changePartition,
|
||||
byte partition,
|
||||
uint objectId, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[10];
|
||||
byte[] cdb = new byte[10];
|
||||
byte[] buffer = new byte[0];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.Locate;
|
||||
if(immediate) cdb[1] += 0x01;
|
||||
if(immediate) cdb[1] += 0x01;
|
||||
if(changePartition) cdb[1] += 0x02;
|
||||
if(blockType) cdb[1] += 0x04;
|
||||
if(blockType) cdb[1] += 0x04;
|
||||
cdb[3] = (byte)((objectId & 0xFF000000) >> 24);
|
||||
cdb[4] = (byte)((objectId & 0xFF0000) >> 16);
|
||||
cdb[5] = (byte)((objectId & 0xFF00) >> 8);
|
||||
cdb[4] = (byte)((objectId & 0xFF0000) >> 16);
|
||||
cdb[5] = (byte)((objectId & 0xFF00) >> 8);
|
||||
cdb[6] = (byte)(objectId & 0xFF);
|
||||
cdb[8] = partition;
|
||||
|
||||
@@ -243,7 +244,7 @@ namespace DiscImageChef.Devices
|
||||
out double duration)
|
||||
{
|
||||
return Locate16(out senseBuffer, immediate, true, SscLogicalIdTypes.ObjectId, false, partition, lba,
|
||||
timeout, out duration);
|
||||
timeout, out duration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -258,27 +259,28 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="identifier">Destination identifier.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool Locate16(out byte[] senseBuffer, bool immediate, bool changePartition, SscLogicalIdTypes destType,
|
||||
bool bam, byte partition, ulong identifier, uint timeout, out double duration)
|
||||
public bool Locate16(out byte[] senseBuffer, bool immediate, bool changePartition, SscLogicalIdTypes destType,
|
||||
bool bam, byte partition, ulong identifier, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[16];
|
||||
byte[] buffer = new byte[0];
|
||||
byte[] cdb = new byte[16];
|
||||
byte[] buffer = new byte[0];
|
||||
byte[] idBytes = BitConverter.GetBytes(identifier);
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.Locate16;
|
||||
cdb[1] = (byte)((byte)destType << 3);
|
||||
if(immediate) cdb[1] += 0x01;
|
||||
if(immediate) cdb[1] += 0x01;
|
||||
if(changePartition) cdb[1] += 0x02;
|
||||
if(bam) cdb[2] = 0x01;
|
||||
if(bam) cdb[2] = 0x01;
|
||||
cdb[3] = partition;
|
||||
|
||||
cdb[4] = idBytes[7];
|
||||
cdb[5] = idBytes[6];
|
||||
cdb[6] = idBytes[5];
|
||||
cdb[7] = idBytes[4];
|
||||
cdb[8] = idBytes[3];
|
||||
cdb[9] = idBytes[2];
|
||||
cdb[4] = idBytes[7];
|
||||
cdb[5] = idBytes[6];
|
||||
cdb[6] = idBytes[5];
|
||||
cdb[7] = idBytes[4];
|
||||
cdb[8] = idBytes[3];
|
||||
cdb[9] = idBytes[2];
|
||||
cdb[10] = idBytes[1];
|
||||
cdb[11] = idBytes[0];
|
||||
|
||||
@@ -315,8 +317,8 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="blockSize">Block size in bytes.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool Read6(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen, uint blockSize,
|
||||
uint timeout, out double duration)
|
||||
public bool Read6(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen, uint blockSize,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
return Read6(out buffer, out senseBuffer, sili, false, transferLen, blockSize, timeout, out duration);
|
||||
}
|
||||
@@ -338,8 +340,9 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="blockSize">Block size in bytes.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool Read6(out byte[] buffer, out byte[] senseBuffer, bool sili, bool fixedLen, uint transferLen,
|
||||
uint blockSize, uint timeout, out double duration)
|
||||
public bool Read6(out byte[] buffer, out byte[] senseBuffer, bool sili, bool fixedLen,
|
||||
uint transferLen,
|
||||
uint blockSize, uint timeout, out double duration)
|
||||
{
|
||||
buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen];
|
||||
byte[] cdb = new byte[6];
|
||||
@@ -347,9 +350,9 @@ namespace DiscImageChef.Devices
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.Read6;
|
||||
if(fixedLen) cdb[1] += 0x01;
|
||||
if(sili) cdb[1] += 0x02;
|
||||
if(sili) cdb[1] += 0x02;
|
||||
cdb[2] = (byte)((transferLen & 0xFF0000) >> 16);
|
||||
cdb[3] = (byte)((transferLen & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)((transferLen & 0xFF00) >> 8);
|
||||
cdb[4] = (byte)(transferLen & 0xFF);
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -372,8 +375,8 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="blockSize">Object size in bytes.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool Read16(out byte[] buffer, out byte[] senseBuffer, bool sili, ulong objectId, uint blocks,
|
||||
uint blockSize, uint timeout, out double duration)
|
||||
public bool Read16(out byte[] buffer, out byte[] senseBuffer, bool sili, ulong objectId, uint blocks,
|
||||
uint blockSize, uint timeout, out double duration)
|
||||
{
|
||||
return Read16(out buffer, out senseBuffer, sili, false, 0, objectId, blocks, blockSize, timeout,
|
||||
out duration);
|
||||
@@ -391,8 +394,9 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="blockSize">Object size in bytes.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool Read16(out byte[] buffer, out byte[] senseBuffer, bool sili, byte partition, ulong objectId,
|
||||
uint blocks, uint blockSize, uint timeout, out double duration)
|
||||
public bool Read16(out byte[] buffer, out byte[] senseBuffer, bool sili, byte partition,
|
||||
ulong objectId,
|
||||
uint blocks, uint blockSize, uint timeout, out double duration)
|
||||
{
|
||||
return Read16(out buffer, out senseBuffer, sili, false, partition, objectId, blocks, blockSize, timeout,
|
||||
out duration);
|
||||
@@ -408,8 +412,8 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="blockSize">Object size in bytes.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool Read16(out byte[] buffer, out byte[] senseBuffer, ulong objectId, uint blocks, uint blockSize,
|
||||
uint timeout, out double duration)
|
||||
public bool Read16(out byte[] buffer, out byte[] senseBuffer, ulong objectId, uint blocks, uint blockSize,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
return Read16(out buffer, out senseBuffer, false, true, 0, objectId, blocks, blockSize, timeout,
|
||||
out duration);
|
||||
@@ -426,8 +430,9 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="blockSize">Object size in bytes.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool Read16(out byte[] buffer, out byte[] senseBuffer, byte partition, ulong objectId, uint blocks,
|
||||
uint blockSize, uint timeout, out double duration)
|
||||
public bool Read16(out byte[] buffer, out byte[] senseBuffer, byte partition, ulong objectId,
|
||||
uint blocks,
|
||||
uint blockSize, uint timeout, out double duration)
|
||||
{
|
||||
return Read16(out buffer, out senseBuffer, false, true, partition, objectId, blocks, blockSize, timeout,
|
||||
out duration);
|
||||
@@ -452,8 +457,10 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="objectSize">Object size in bytes.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool Read16(out byte[] buffer, out byte[] senseBuffer, bool sili, bool fixedLen, byte partition,
|
||||
ulong objectId, uint transferLen, uint objectSize, uint timeout, out double duration)
|
||||
public bool Read16(out byte[] buffer, out byte[] senseBuffer, bool sili, bool fixedLen,
|
||||
byte partition,
|
||||
ulong objectId, uint transferLen, uint objectSize, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
buffer = fixedLen ? new byte[objectSize * transferLen] : new byte[transferLen];
|
||||
byte[] cdb = new byte[6];
|
||||
@@ -462,18 +469,18 @@ namespace DiscImageChef.Devices
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.Read16;
|
||||
if(fixedLen) cdb[1] += 0x01;
|
||||
if(sili) cdb[1] += 0x02;
|
||||
cdb[3] = partition;
|
||||
cdb[4] = idBytes[7];
|
||||
cdb[5] = idBytes[6];
|
||||
cdb[6] = idBytes[5];
|
||||
cdb[7] = idBytes[4];
|
||||
cdb[8] = idBytes[3];
|
||||
cdb[9] = idBytes[2];
|
||||
if(sili) cdb[1] += 0x02;
|
||||
cdb[3] = partition;
|
||||
cdb[4] = idBytes[7];
|
||||
cdb[5] = idBytes[6];
|
||||
cdb[6] = idBytes[5];
|
||||
cdb[7] = idBytes[4];
|
||||
cdb[8] = idBytes[3];
|
||||
cdb[9] = idBytes[2];
|
||||
cdb[10] = idBytes[1];
|
||||
cdb[11] = idBytes[0];
|
||||
cdb[12] = (byte)((transferLen & 0xFF0000) >> 16);
|
||||
cdb[13] = (byte)((transferLen & 0xFF00) >> 8);
|
||||
cdb[13] = (byte)((transferLen & 0xFF00) >> 8);
|
||||
cdb[14] = (byte)(transferLen & 0xFF);
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -543,12 +550,12 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="totalPosition">Requests current logical position.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool ReadPosition(out byte[] buffer, out byte[] senseBuffer, bool vendorType, bool longForm,
|
||||
bool totalPosition, uint timeout, out double duration)
|
||||
public bool ReadPosition(out byte[] buffer, out byte[] senseBuffer, bool vendorType, bool longForm,
|
||||
bool totalPosition, uint timeout, out double duration)
|
||||
{
|
||||
byte responseForm = 0;
|
||||
if(vendorType) responseForm += 0x01;
|
||||
if(longForm) responseForm += 0x02;
|
||||
byte responseForm = 0;
|
||||
if(vendorType) responseForm += 0x01;
|
||||
if(longForm) responseForm += 0x02;
|
||||
if(totalPosition) responseForm += 0x04;
|
||||
|
||||
return ReadPosition(out buffer, out senseBuffer, (SscPositionForms)responseForm, timeout, out duration);
|
||||
@@ -631,8 +638,9 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="blockSize">Block size in bytes.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool ReadReverse6(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen, uint blockSize,
|
||||
uint timeout, out double duration)
|
||||
public bool ReadReverse6(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen,
|
||||
uint blockSize,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
return ReadReverse6(out buffer, out senseBuffer, false, sili, false, transferLen, blockSize, timeout,
|
||||
out duration);
|
||||
@@ -656,19 +664,20 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="blockSize">Block size in bytes.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool ReadReverse6(out byte[] buffer, out byte[] senseBuffer, bool byteOrder, bool sili, bool fixedLen,
|
||||
uint transferLen, uint blockSize, uint timeout, out double duration)
|
||||
public bool ReadReverse6(out byte[] buffer, out byte[] senseBuffer, bool byteOrder, bool sili,
|
||||
bool fixedLen,
|
||||
uint transferLen, uint blockSize, uint timeout, out double duration)
|
||||
{
|
||||
buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen];
|
||||
byte[] cdb = new byte[6];
|
||||
senseBuffer = new byte[32];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadReverse;
|
||||
if(fixedLen) cdb[1] += 0x01;
|
||||
if(sili) cdb[1] += 0x02;
|
||||
if(fixedLen) cdb[1] += 0x01;
|
||||
if(sili) cdb[1] += 0x02;
|
||||
if(byteOrder) cdb[1] += 0x04;
|
||||
cdb[2] = (byte)((transferLen & 0xFF0000) >> 16);
|
||||
cdb[3] = (byte)((transferLen & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)((transferLen & 0xFF00) >> 8);
|
||||
cdb[4] = (byte)(transferLen & 0xFF);
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -691,11 +700,12 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="blockSize">Object size in bytes.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, bool sili, ulong objectId, uint blocks,
|
||||
uint blockSize, uint timeout, out double duration)
|
||||
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, bool sili, ulong objectId,
|
||||
uint blocks,
|
||||
uint blockSize, uint timeout, out double duration)
|
||||
{
|
||||
return ReadReverse16(out buffer, out senseBuffer, false, sili, false, 0, objectId, blocks, blockSize,
|
||||
timeout, out duration);
|
||||
timeout, out duration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -710,11 +720,12 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="blockSize">Object size in bytes.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, bool sili, byte partition, ulong objectId,
|
||||
uint blocks, uint blockSize, uint timeout, out double duration)
|
||||
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, bool sili, byte partition,
|
||||
ulong objectId,
|
||||
uint blocks, uint blockSize, uint timeout, out double duration)
|
||||
{
|
||||
return ReadReverse16(out buffer, out senseBuffer, false, sili, false, partition, objectId, blocks,
|
||||
blockSize, timeout, out duration);
|
||||
blockSize, timeout, out duration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -727,11 +738,11 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="blockSize">Object size in bytes.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, ulong objectId, uint blocks,
|
||||
uint blockSize, uint timeout, out double duration)
|
||||
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, ulong objectId, uint blocks,
|
||||
uint blockSize, uint timeout, out double duration)
|
||||
{
|
||||
return ReadReverse16(out buffer, out senseBuffer, false, false, true, 0, objectId, blocks, blockSize,
|
||||
timeout, out duration);
|
||||
timeout, out duration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -745,11 +756,11 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="blockSize">Object size in bytes.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, byte partition, ulong objectId,
|
||||
uint blocks, uint blockSize, uint timeout, out double duration)
|
||||
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, byte partition, ulong objectId,
|
||||
uint blocks, uint blockSize, uint timeout, out double duration)
|
||||
{
|
||||
return ReadReverse16(out buffer, out senseBuffer, false, false, true, partition, objectId, blocks,
|
||||
blockSize, timeout, out duration);
|
||||
blockSize, timeout, out duration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -772,8 +783,10 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="objectSize">Object size in bytes.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, bool byteOrder, bool sili, bool fixedLen,
|
||||
byte partition, ulong objectId, uint transferLen, uint objectSize, uint timeout,
|
||||
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, bool byteOrder, bool sili,
|
||||
bool fixedLen,
|
||||
byte partition, ulong objectId, uint transferLen, uint objectSize,
|
||||
uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
buffer = fixedLen ? new byte[objectSize * transferLen] : new byte[transferLen];
|
||||
@@ -782,20 +795,20 @@ namespace DiscImageChef.Devices
|
||||
byte[] idBytes = BitConverter.GetBytes(objectId);
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.Read16;
|
||||
if(fixedLen) cdb[1] += 0x01;
|
||||
if(sili) cdb[1] += 0x02;
|
||||
if(fixedLen) cdb[1] += 0x01;
|
||||
if(sili) cdb[1] += 0x02;
|
||||
if(byteOrder) cdb[1] += 0x04;
|
||||
cdb[3] = partition;
|
||||
cdb[4] = idBytes[7];
|
||||
cdb[5] = idBytes[6];
|
||||
cdb[6] = idBytes[5];
|
||||
cdb[7] = idBytes[4];
|
||||
cdb[8] = idBytes[3];
|
||||
cdb[9] = idBytes[2];
|
||||
cdb[3] = partition;
|
||||
cdb[4] = idBytes[7];
|
||||
cdb[5] = idBytes[6];
|
||||
cdb[6] = idBytes[5];
|
||||
cdb[7] = idBytes[4];
|
||||
cdb[8] = idBytes[3];
|
||||
cdb[9] = idBytes[2];
|
||||
cdb[10] = idBytes[1];
|
||||
cdb[11] = idBytes[0];
|
||||
cdb[12] = (byte)((transferLen & 0xFF0000) >> 16);
|
||||
cdb[13] = (byte)((transferLen & 0xFF00) >> 8);
|
||||
cdb[13] = (byte)((transferLen & 0xFF00) >> 8);
|
||||
cdb[14] = (byte)(transferLen & 0xFF);
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -816,8 +829,8 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="blockSize">Block size in bytes.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, uint blocks, uint blockSize,
|
||||
uint timeout, out double duration)
|
||||
public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, uint blocks, uint blockSize,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
return RecoverBufferedData(out buffer, out senseBuffer, false, true, blocks, blockSize, timeout,
|
||||
out duration);
|
||||
@@ -833,8 +846,8 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="blockSize">Block size in bytes.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen,
|
||||
uint blockSize, uint timeout, out double duration)
|
||||
public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen,
|
||||
uint blockSize, uint timeout, out double duration)
|
||||
{
|
||||
return RecoverBufferedData(out buffer, out senseBuffer, sili, false, transferLen, blockSize, timeout,
|
||||
out duration);
|
||||
@@ -857,8 +870,10 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="blockSize">Block size in bytes.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, bool sili, bool fixedLen,
|
||||
uint transferLen, uint blockSize, uint timeout, out double duration)
|
||||
public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, bool sili,
|
||||
bool fixedLen,
|
||||
uint transferLen, uint blockSize, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen];
|
||||
byte[] cdb = new byte[6];
|
||||
@@ -866,9 +881,9 @@ namespace DiscImageChef.Devices
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.RecoverBufferedData;
|
||||
if(fixedLen) cdb[1] += 0x01;
|
||||
if(sili) cdb[1] += 0x02;
|
||||
if(sili) cdb[1] += 0x02;
|
||||
cdb[2] = (byte)((transferLen & 0xFF0000) >> 16);
|
||||
cdb[3] = (byte)((transferLen & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)((transferLen & 0xFF00) >> 8);
|
||||
cdb[4] = (byte)(transferLen & 0xFF);
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -915,8 +930,8 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="currentMedia">If set to <c>true</c> descriptors should apply to currently inserted media.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool ReportDensitySupport(out byte[] buffer, out byte[] senseBuffer, bool mediumType, bool currentMedia,
|
||||
uint timeout, out double duration)
|
||||
public bool ReportDensitySupport(out byte[] buffer, out byte[] senseBuffer, bool mediumType, bool currentMedia,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[256];
|
||||
byte[] cdb = new byte[10];
|
||||
@@ -924,7 +939,7 @@ namespace DiscImageChef.Devices
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReportDensitySupport;
|
||||
if(currentMedia) cdb[1] += 0x01;
|
||||
if(mediumType) cdb[1] += 0x02;
|
||||
if(mediumType) cdb[1] += 0x02;
|
||||
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(buffer.Length & 0xFF);
|
||||
|
||||
@@ -935,9 +950,9 @@ namespace DiscImageChef.Devices
|
||||
if(sense) return true;
|
||||
|
||||
ushort availableLength = (ushort)((buffer[0] << 8) + buffer[1] + 2);
|
||||
buffer = new byte[availableLength];
|
||||
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(buffer.Length & 0xFF);
|
||||
buffer = new byte[availableLength];
|
||||
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(buffer.Length & 0xFF);
|
||||
senseBuffer = new byte[32];
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
@@ -970,7 +985,7 @@ namespace DiscImageChef.Devices
|
||||
public bool Rewind(out byte[] senseBuffer, bool immediate, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] buffer = new byte[0];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.Rewind;
|
||||
@@ -996,7 +1011,7 @@ namespace DiscImageChef.Devices
|
||||
public bool TrackSelect(out byte[] senseBuffer, byte track, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] buffer = new byte[0];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.TrackSelect;
|
||||
@@ -1014,7 +1029,7 @@ namespace DiscImageChef.Devices
|
||||
public bool Space(out byte[] senseBuffer, SscSpaceCodes code, int count, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] buffer = new byte[0];
|
||||
byte[] countB = BitConverter.GetBytes(count);
|
||||
|
||||
|
||||
@@ -81,20 +81,21 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="readLong">If set to <c>true</c> drive will return ECC bytes and disable error detection.</param>
|
||||
/// <param name="blockSize">Block size in bytes.</param>
|
||||
/// <param name="transferLength">How many blocks to read.</param>
|
||||
public bool SyQuestRead6(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
|
||||
byte transferLength, bool inhibitDma, bool readLong, uint timeout, out double duration)
|
||||
public bool SyQuestRead6(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
|
||||
byte transferLength, bool inhibitDma, bool readLong, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[6];
|
||||
bool sense;
|
||||
bool sense;
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.Read6;
|
||||
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
|
||||
cdb[2] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[2] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)(lba & 0xFF);
|
||||
cdb[4] = transferLength;
|
||||
if(inhibitDma) cdb[5] += 0x80;
|
||||
if(readLong) cdb[5] += 0x40;
|
||||
if(readLong) cdb[5] += 0x40;
|
||||
|
||||
if(!inhibitDma && !readLong)
|
||||
buffer = transferLength == 0 ? new byte[256 * blockSize] : new byte[transferLength * blockSize];
|
||||
@@ -161,23 +162,23 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="readLong">If set to <c>true</c> drive will return ECC bytes and disable error detection.</param>
|
||||
/// <param name="blockSize">Block size in bytes.</param>
|
||||
/// <param name="transferLength">How many blocks to read.</param>
|
||||
public bool SyQuestRead10(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
|
||||
ushort transferLength, bool inhibitDma, bool readLong, uint timeout,
|
||||
public bool SyQuestRead10(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
|
||||
ushort transferLength, bool inhibitDma, bool readLong, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[10];
|
||||
bool sense;
|
||||
bool sense;
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.Read10;
|
||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
cdb[7] = (byte)((transferLength & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(transferLength & 0xFF);
|
||||
if(inhibitDma) cdb[9] += 0x80;
|
||||
if(readLong) cdb[9] += 0x40;
|
||||
if(readLong) cdb[9] += 0x40;
|
||||
|
||||
if(!inhibitDma && !readLong) buffer = new byte[transferLength * blockSize];
|
||||
else if(readLong)
|
||||
|
||||
@@ -39,9 +39,9 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
readonly ushort usbVendor;
|
||||
readonly ushort usbProduct;
|
||||
readonly ulong firewireGuid;
|
||||
readonly uint firewireModel;
|
||||
readonly uint firewireVendor;
|
||||
readonly ulong firewireGuid;
|
||||
readonly uint firewireModel;
|
||||
readonly uint firewireVendor;
|
||||
|
||||
// MMC and SecureDigital, values that need to be get with card idle, something that may
|
||||
// not be possible to do but usually is already done by the SDHCI driver.
|
||||
|
||||
Reference in New Issue
Block a user