mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
REFACTOR: Reformat code.
This commit is contained in:
@@ -47,7 +47,8 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||
/// <param name="lba">Starting block.</param>
|
||||
/// <param name="blockSize">Block size in bytes.</param>
|
||||
public bool Read6(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize, uint timeout, out double duration)
|
||||
public bool Read6(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
return Read6(out buffer, out senseBuffer, lba, blockSize, 1, timeout, out duration);
|
||||
}
|
||||
@@ -63,7 +64,8 @@ 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];
|
||||
@@ -75,12 +77,11 @@ namespace DiscImageChef.Devices
|
||||
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 sense);
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("SCSI Device", "READ (6) took {0} ms.", duration);
|
||||
@@ -105,7 +106,9 @@ 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];
|
||||
@@ -113,14 +116,10 @@ namespace DiscImageChef.Devices
|
||||
|
||||
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(relAddr)
|
||||
cdb[1] += 0x01;
|
||||
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);
|
||||
@@ -131,7 +130,8 @@ namespace DiscImageChef.Devices
|
||||
|
||||
buffer = new byte[transferLength * blockSize];
|
||||
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense);
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("SCSI Device", "READ (10) took {0} ms.", duration);
|
||||
@@ -157,7 +157,9 @@ 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];
|
||||
@@ -165,14 +167,10 @@ namespace DiscImageChef.Devices
|
||||
|
||||
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(relAddr)
|
||||
cdb[1] += 0x01;
|
||||
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);
|
||||
@@ -182,12 +180,12 @@ namespace DiscImageChef.Devices
|
||||
cdb[8] = (byte)((transferLength & 0xFF00) >> 8);
|
||||
cdb[9] = (byte)(transferLength & 0xFF);
|
||||
cdb[10] = (byte)(groupNumber & 0x1F);
|
||||
if(streaming)
|
||||
cdb[10] += 0x80;
|
||||
if(streaming) cdb[10] += 0x80;
|
||||
|
||||
buffer = new byte[transferLength * blockSize];
|
||||
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense);
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("SCSI Device", "READ (12) took {0} ms.", duration);
|
||||
@@ -212,7 +210,9 @@ 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];
|
||||
@@ -221,12 +221,9 @@ namespace DiscImageChef.Devices
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.Read16;
|
||||
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;
|
||||
cdb[2] = lbaBytes[7];
|
||||
cdb[3] = lbaBytes[6];
|
||||
cdb[4] = lbaBytes[5];
|
||||
@@ -240,12 +237,12 @@ namespace DiscImageChef.Devices
|
||||
cdb[12] = (byte)((transferLength & 0xFF00) >> 8);
|
||||
cdb[13] = (byte)(transferLength & 0xFF);
|
||||
cdb[14] = (byte)(groupNumber & 0x1F);
|
||||
if(streaming)
|
||||
cdb[14] += 0x80;
|
||||
if(streaming) cdb[14] += 0x80;
|
||||
|
||||
buffer = new byte[transferLength * blockSize];
|
||||
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense);
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("SCSI Device", "READ (16) took {0} ms.", duration);
|
||||
@@ -265,17 +262,16 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="correct">If set to <c>true</c> ask the drive to try to correct errors in the sector.</param>
|
||||
/// <param name="lba">LBA to read.</param>
|
||||
/// <param name="transferBytes">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];
|
||||
bool sense;
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadLong;
|
||||
if(correct)
|
||||
cdb[1] += 0x02;
|
||||
if(relAddr)
|
||||
cdb[1] += 0x01;
|
||||
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);
|
||||
@@ -285,7 +281,8 @@ namespace DiscImageChef.Devices
|
||||
|
||||
buffer = new byte[transferBytes];
|
||||
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense);
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("SCSI Device", "READ LONG (10) took {0} ms.", duration);
|
||||
@@ -304,7 +301,8 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="correct">If set to <c>true</c> ask the drive to try to correct errors in the sector.</param>
|
||||
/// <param name="lba">LBA to read.</param>
|
||||
/// <param name="transferBytes">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];
|
||||
@@ -323,12 +321,12 @@ namespace DiscImageChef.Devices
|
||||
cdb[9] = lbaBytes[0];
|
||||
cdb[12] = (byte)((transferBytes & 0xFF00) >> 8);
|
||||
cdb[13] = (byte)(transferBytes & 0xFF);
|
||||
if(correct)
|
||||
cdb[14] += 0x01;
|
||||
if(correct) cdb[14] += 0x01;
|
||||
|
||||
buffer = new byte[transferBytes];
|
||||
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense);
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("SCSI Device", "READ LONG (16) took {0} ms.", duration);
|
||||
@@ -355,7 +353,8 @@ namespace DiscImageChef.Devices
|
||||
cdb[2] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[3] = (byte)(lba & 0xFF);
|
||||
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense);
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||
out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("SCSI Device", "SEEK (6) took {0} ms.", duration);
|
||||
@@ -383,7 +382,8 @@ namespace DiscImageChef.Devices
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense);
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||
out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("SCSI Device", "SEEK (10) took {0} ms.", duration);
|
||||
@@ -391,5 +391,4 @@ namespace DiscImageChef.Devices
|
||||
return sense;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user