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:
@@ -37,7 +37,8 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
public partial class Device
|
||||
{
|
||||
public bool ReadBuffer(out byte[] buffer, out AtaErrorRegistersLBA28 statusRegisters, uint timeout, out double duration)
|
||||
public bool ReadBuffer(out byte[] buffer, out AtaErrorRegistersLBA28 statusRegisters, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
buffer = new byte[512];
|
||||
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
|
||||
@@ -45,8 +46,9 @@ namespace DiscImageChef.Devices
|
||||
|
||||
registers.command = (byte)AtaCommands.ReadBuffer;
|
||||
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.NoTransfer,
|
||||
ref buffer, timeout, false, out duration, out sense);
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("ATA Device", "READ BUFFER took {0} ms.", duration);
|
||||
@@ -54,7 +56,8 @@ namespace DiscImageChef.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadBufferDma(out byte[] buffer, out AtaErrorRegistersLBA28 statusRegisters, uint timeout, out double duration)
|
||||
public bool ReadBufferDma(out byte[] buffer, out AtaErrorRegistersLBA28 statusRegisters, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
buffer = new byte[512];
|
||||
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
|
||||
@@ -71,24 +74,22 @@ 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)
|
||||
{
|
||||
if(count == 0)
|
||||
buffer = new byte[512 * 256];
|
||||
else
|
||||
buffer = new byte[512 * count];
|
||||
if(count == 0) buffer = new byte[512 * 256];
|
||||
else buffer = new byte[512 * count];
|
||||
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
|
||||
bool sense;
|
||||
|
||||
if(retry)
|
||||
registers.command = (byte)AtaCommands.ReadDmaRetry;
|
||||
else
|
||||
registers.command = (byte)AtaCommands.ReadDma;
|
||||
if(retry) registers.command = (byte)AtaCommands.ReadDmaRetry;
|
||||
else registers.command = (byte)AtaCommands.ReadDma;
|
||||
registers.sectorCount = count;
|
||||
registers.deviceHead = (byte)((lba & 0xF000000) / 0x1000000);
|
||||
registers.lbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
|
||||
@@ -105,12 +106,11 @@ 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)
|
||||
{
|
||||
if(count == 0)
|
||||
buffer = new byte[512 * 256];
|
||||
else
|
||||
buffer = new byte[512 * count];
|
||||
if(count == 0) buffer = new byte[512 * 256];
|
||||
else buffer = new byte[512 * count];
|
||||
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
|
||||
bool sense;
|
||||
|
||||
@@ -122,8 +122,9 @@ namespace DiscImageChef.Devices
|
||||
registers.lbaLow = (byte)((lba & 0xFF) / 0x1);
|
||||
registers.deviceHead += 0x40;
|
||||
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount,
|
||||
ref buffer, timeout, true, out duration, out sense);
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||
out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("ATA Device", "READ MULTIPLE took {0} ms.", duration);
|
||||
@@ -131,7 +132,8 @@ namespace DiscImageChef.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadNativeMaxAddress(out uint lba, out AtaErrorRegistersLBA28 statusRegisters, uint timeout, out double duration)
|
||||
public bool ReadNativeMaxAddress(out uint lba, out AtaErrorRegistersLBA28 statusRegisters, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
lba = 0;
|
||||
byte[] buffer = new byte[0];
|
||||
@@ -141,8 +143,9 @@ namespace DiscImageChef.Devices
|
||||
registers.command = (byte)AtaCommands.ReadNativeMaxAddress;
|
||||
registers.deviceHead += 0x40;
|
||||
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer,
|
||||
ref buffer, timeout, false, out duration, out sense);
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
if((statusRegisters.status & 0x23) == 0)
|
||||
@@ -159,24 +162,22 @@ 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)
|
||||
{
|
||||
if(count == 0)
|
||||
buffer = new byte[512 * 256];
|
||||
else
|
||||
buffer = new byte[512 * count];
|
||||
if(count == 0) buffer = new byte[512 * 256];
|
||||
else buffer = new byte[512 * count];
|
||||
AtaRegistersLBA28 registers = new AtaRegistersLBA28();
|
||||
bool sense;
|
||||
|
||||
if(retry)
|
||||
registers.command = (byte)AtaCommands.ReadRetry;
|
||||
else
|
||||
registers.command = (byte)AtaCommands.Read;
|
||||
if(retry) registers.command = (byte)AtaCommands.ReadRetry;
|
||||
else registers.command = (byte)AtaCommands.Read;
|
||||
registers.sectorCount = count;
|
||||
registers.deviceHead = (byte)((lba & 0xF000000) / 0x1000000);
|
||||
registers.lbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
|
||||
@@ -184,8 +185,9 @@ namespace DiscImageChef.Devices
|
||||
registers.lbaLow = (byte)((lba & 0xFF) / 0x1);
|
||||
registers.deviceHead += 0x40;
|
||||
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount,
|
||||
ref buffer, timeout, true, out duration, out sense);
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||
out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("ATA Device", "READ SECTORS took {0} ms.", duration);
|
||||
@@ -193,22 +195,21 @@ 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();
|
||||
bool sense;
|
||||
|
||||
if(retry)
|
||||
registers.command = (byte)AtaCommands.ReadLongRetry;
|
||||
else
|
||||
registers.command = (byte)AtaCommands.ReadLong;
|
||||
if(retry) registers.command = (byte)AtaCommands.ReadLongRetry;
|
||||
else registers.command = (byte)AtaCommands.ReadLong;
|
||||
registers.sectorCount = 1;
|
||||
registers.deviceHead = (byte)((lba & 0xF000000) / 0x1000000);
|
||||
registers.lbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
|
||||
@@ -216,8 +217,9 @@ namespace DiscImageChef.Devices
|
||||
registers.lbaLow = (byte)((lba & 0xFF) / 0x1);
|
||||
registers.deviceHead += 0x40;
|
||||
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount,
|
||||
ref buffer, timeout, true, out duration, out sense);
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||
out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("ATA Device", "READ LONG took {0} ms.", duration);
|
||||
@@ -238,8 +240,9 @@ namespace DiscImageChef.Devices
|
||||
registers.lbaLow = (byte)((lba & 0xFF) / 0x1);
|
||||
registers.deviceHead += 0x40;
|
||||
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer,
|
||||
ref buffer, timeout, false, out duration, out sense);
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("ATA Device", "SEEK took {0} ms.", duration);
|
||||
@@ -247,5 +250,4 @@ namespace DiscImageChef.Devices
|
||||
return sense;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user