mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
* DiscImageChef.Devices/Device/AtaCommands/Cfa.cs:
* DiscImageChef.Devices/Device/AtaCommands/MCPT.cs: * DiscImageChef.Devices/Device/AtaCommands/Ata28.cs: * DiscImageChef.Devices/Device/AtaCommands/Ata48.cs: * DiscImageChef.Devices/Device/AtaCommands/Smart.cs: * DiscImageChef.Devices/Device/AtaCommands/AtaCHS.cs: * DiscImageChef.Devices/DiscImageChef.Devices.csproj: Implemented ATA commands. * DiscImageChef.Devices/Device/ScsiCommands/SPC.cs: Make MODE SENSE (6) buffer big enought. * DiscImageChef.Devices/Enums.cs: Added new command found in ACS-3 rev. 6
This commit is contained in:
@@ -103,6 +103,141 @@ namespace DiscImageChef.Devices
|
||||
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, ushort cylinder, byte head, byte sector, byte count, uint timeout, out double duration)
|
||||
{
|
||||
return ReadDma(out buffer, out statusRegisters, true, cylinder, head, sector, count, timeout, out duration);
|
||||
}
|
||||
|
||||
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, bool retry, ushort cylinder, byte head, byte sector, byte count, uint timeout, out double duration)
|
||||
{
|
||||
if (count == 0)
|
||||
buffer = new byte[512 * 256];
|
||||
else
|
||||
buffer = new byte[512 * count];
|
||||
AtaRegistersCHS registers = new AtaRegistersCHS();
|
||||
bool sense;
|
||||
|
||||
if(retry)
|
||||
registers.command = (byte)AtaCommands.ReadDmaRetry;
|
||||
else
|
||||
registers.command = (byte)AtaCommands.ReadDma;
|
||||
registers.sectorCount = count;
|
||||
registers.cylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
|
||||
registers.cylinderLow = (byte)((cylinder & 0xFF) / 0x1);
|
||||
registers.deviceHead = (byte)(head & 0x0F);
|
||||
registers.sector = sector;
|
||||
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
|
||||
ref buffer, timeout, true, out duration, out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("ATA Device", "READ DMA took {0} ms.", duration);
|
||||
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, ushort cylinder, byte head, byte sector, byte count, uint timeout, out double duration)
|
||||
{
|
||||
if (count == 0)
|
||||
buffer = new byte[512 * 256];
|
||||
else
|
||||
buffer = new byte[512 * count];
|
||||
AtaRegistersCHS registers = new AtaRegistersCHS();
|
||||
bool sense;
|
||||
|
||||
registers.command = (byte)AtaCommands.ReadMultiple;
|
||||
registers.sectorCount = count;
|
||||
registers.cylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
|
||||
registers.cylinderLow = (byte)((cylinder & 0xFF) / 0x1);
|
||||
registers.deviceHead = (byte)(head & 0x0F);
|
||||
registers.sector = sector;
|
||||
|
||||
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);
|
||||
|
||||
return sense;
|
||||
}
|
||||
|
||||
|
||||
public bool Read(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, ushort cylinder, byte head, byte sector, byte count, uint timeout, out double duration)
|
||||
{
|
||||
if (count == 0)
|
||||
buffer = new byte[512 * 256];
|
||||
else
|
||||
buffer = new byte[512 * count];
|
||||
AtaRegistersCHS registers = new AtaRegistersCHS();
|
||||
bool sense;
|
||||
|
||||
registers.command = (byte)AtaCommands.ReadRetry;
|
||||
registers.sectorCount = count;
|
||||
registers.cylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
|
||||
registers.cylinderLow = (byte)((cylinder & 0xFF) / 0x1);
|
||||
registers.deviceHead = (byte)(head & 0x0F);
|
||||
registers.sector = sector;
|
||||
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount,
|
||||
ref buffer, timeout, true, out duration, out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("ATA Device", "READ SECTORS took {0} ms.", duration);
|
||||
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, ushort cylinder, byte head, byte sector, int blockSize, uint timeout, out double duration)
|
||||
{
|
||||
return ReadLong(out buffer, out statusRegisters, true, cylinder, head, sector, blockSize, timeout, out duration);
|
||||
}
|
||||
|
||||
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, bool retry, ushort cylinder, byte head, byte sector, int blockSize, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[blockSize];
|
||||
AtaRegistersCHS registers = new AtaRegistersCHS();
|
||||
bool sense;
|
||||
|
||||
if(retry)
|
||||
registers.command = (byte)AtaCommands.ReadLong;
|
||||
else
|
||||
registers.command = (byte)AtaCommands.ReadLongRetry;
|
||||
registers.sectorCount = 1;
|
||||
registers.cylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
|
||||
registers.cylinderLow = (byte)((cylinder & 0xFF) / 0x1);
|
||||
registers.deviceHead = (byte)(head & 0x0F);
|
||||
registers.sector = sector;
|
||||
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount,
|
||||
ref buffer, timeout, true, out duration, out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("ATA Device", "READ LONG took {0} ms.", duration);
|
||||
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool Seek(out AtaErrorRegistersCHS statusRegisters, ushort cylinder, byte head, byte sector, uint timeout, out double duration)
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersCHS registers = new AtaRegistersCHS();
|
||||
bool sense;
|
||||
|
||||
registers.command = (byte)AtaCommands.Seek;
|
||||
registers.cylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
|
||||
registers.cylinderLow = (byte)((cylinder & 0xFF) / 0x1);
|
||||
registers.deviceHead = (byte)(head & 0x0F);
|
||||
registers.sector = sector;
|
||||
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount,
|
||||
ref buffer, timeout, true, out duration, out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("ATA Device", "SEEK took {0} ms.", duration);
|
||||
|
||||
return sense;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user