* DiscImageChef.Devices/Structs.cs:

* DiscImageChef.Devices/DiscImageChef.Devices.csproj:
	  Added structs with ATA registers.

	* DiscImageChef.Devices/Command.cs:
	* DiscImageChef.Devices/Device/Commands.cs:
	  Added ATA commands.

	* DiscImageChef.Devices/Enums.cs:
	  Added SCSI's ATA Command Pass-Through enumerations.

	* DiscImageChef.Devices/Linux/Command.cs:
	  Added ATA commands using libATA's SATL.
This commit is contained in:
2015-10-14 02:53:46 +01:00
parent d7546d4e88
commit 8d121d22b7
7 changed files with 574 additions and 0 deletions

View File

@@ -128,6 +128,102 @@ namespace DiscImageChef.Devices
throw new InvalidOperationException(String.Format("Platform {0} not yet supported.", ptID));
}
}
public static int SendAtaCommand(object fd, Structs.AtaRegistersCHS registers,
out Structs.AtaErrorRegistersCHS errorRegisters, Enums.AtaProtocol protocol,
Enums.AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{
Interop.PlatformID ptID = DetectOS.GetRealPlatformID();
return SendAtaCommand(ptID, fd, registers, out errorRegisters, protocol,
transferRegister, ref buffer, timeout, transferBlocks, out duration, out sense);
}
public static int SendAtaCommand(Interop.PlatformID ptID, object fd, Structs.AtaRegistersCHS registers,
out Structs.AtaErrorRegistersCHS errorRegisters, Enums.AtaProtocol protocol,
Enums.AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{
switch (ptID)
{
case Interop.PlatformID.Win32NT:
{
throw new NotImplementedException();
}
case Interop.PlatformID.Linux:
{
return Linux.Command.SendAtaCommand((int)fd, registers, out errorRegisters, protocol,
transferRegister, ref buffer, timeout, transferBlocks, out duration, out sense);
}
default:
throw new InvalidOperationException(String.Format("Platform {0} not yet supported.", ptID));
}
}
public static int SendAtaCommand(object fd, Structs.AtaRegistersLBA28 registers,
out Structs.AtaErrorRegistersLBA28 errorRegisters, Enums.AtaProtocol protocol,
Enums.AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{
Interop.PlatformID ptID = DetectOS.GetRealPlatformID();
return SendAtaCommand(ptID, fd, registers, out errorRegisters, protocol,
transferRegister, ref buffer, timeout, transferBlocks, out duration, out sense);
}
public static int SendAtaCommand(Interop.PlatformID ptID, object fd, Structs.AtaRegistersLBA28 registers,
out Structs.AtaErrorRegistersLBA28 errorRegisters, Enums.AtaProtocol protocol,
Enums.AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{
switch (ptID)
{
case Interop.PlatformID.Win32NT:
{
throw new NotImplementedException();
}
case Interop.PlatformID.Linux:
{
return Linux.Command.SendAtaCommand((int)fd, registers, out errorRegisters, protocol,
transferRegister, ref buffer, timeout, transferBlocks, out duration, out sense);
}
default:
throw new InvalidOperationException(String.Format("Platform {0} not yet supported.", ptID));
}
}
public static int SendAtaCommand(object fd, Structs.AtaRegistersLBA48 registers,
out Structs.AtaErrorRegistersLBA48 errorRegisters, Enums.AtaProtocol protocol,
Enums.AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{
Interop.PlatformID ptID = DetectOS.GetRealPlatformID();
return SendAtaCommand(ptID, fd, registers, out errorRegisters, protocol,
transferRegister, ref buffer, timeout, transferBlocks, out duration, out sense);
}
public static int SendAtaCommand(Interop.PlatformID ptID, object fd, Structs.AtaRegistersLBA48 registers,
out Structs.AtaErrorRegistersLBA48 errorRegisters, Enums.AtaProtocol protocol,
Enums.AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{
switch (ptID)
{
case Interop.PlatformID.Win32NT:
{
throw new NotImplementedException();
}
case Interop.PlatformID.Linux:
{
return Linux.Command.SendAtaCommand((int)fd, registers, out errorRegisters, protocol,
transferRegister, ref buffer, timeout, transferBlocks, out duration, out sense);
}
default:
throw new InvalidOperationException(String.Format("Platform {0} not yet supported.", ptID));
}
}
}
}