mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Moved devices enums and structs out of classes.
This commit is contained in:
@@ -1,3 +1,15 @@
|
||||
2015-10-19 Natalia Portillo <claunia@claunia.com>
|
||||
|
||||
* Enums.cs:
|
||||
* Structs.cs:
|
||||
* Command.cs:
|
||||
* Linux/Command.cs:
|
||||
* Device/Commands.cs:
|
||||
* Device/AtaCommands.cs:
|
||||
* Device/ScsiCommands.cs:
|
||||
* Device/AtapiCommands.cs:
|
||||
Moved devices enums and structs out of classes.
|
||||
|
||||
2015-10-19 Natalia Portillo <claunia@claunia.com>
|
||||
|
||||
* Device/ScsiCommands.cs:
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="direction">SCSI command transfer direction</param>
|
||||
/// <param name="duration">Time it took to execute the command in milliseconds</param>
|
||||
/// <param name="sense"><c>True</c> if SCSI error returned non-OK status and <paramref name="senseBuffer"/> contains SCSI sense</param>
|
||||
public static int SendScsiCommand(object fd, byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, uint timeout, Enums.ScsiDirection direction, out double duration, out bool sense)
|
||||
public static int SendScsiCommand(object fd, byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, uint timeout, ScsiDirection direction, out double duration, out bool sense)
|
||||
{
|
||||
Interop.PlatformID ptID = DetectOS.GetRealPlatformID();
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="direction">SCSI command transfer direction</param>
|
||||
/// <param name="duration">Time it took to execute the command in milliseconds</param>
|
||||
/// <param name="sense"><c>True</c> if SCSI error returned non-OK status and <paramref name="senseBuffer"/> contains SCSI sense</param>
|
||||
public static int SendScsiCommand(Interop.PlatformID ptID, object fd, byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, uint timeout, Enums.ScsiDirection direction, out double duration, out bool sense)
|
||||
public static int SendScsiCommand(Interop.PlatformID ptID, object fd, byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, uint timeout, ScsiDirection direction, out double duration, out bool sense)
|
||||
{
|
||||
switch (ptID)
|
||||
{
|
||||
@@ -86,10 +86,10 @@ namespace DiscImageChef.Devices
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case Enums.ScsiDirection.In:
|
||||
case ScsiDirection.In:
|
||||
dir = Windows.ScsiIoctlDirection.In;
|
||||
break;
|
||||
case Enums.ScsiDirection.Out:
|
||||
case ScsiDirection.Out:
|
||||
dir = Windows.ScsiIoctlDirection.Out;
|
||||
break;
|
||||
default:
|
||||
@@ -105,16 +105,16 @@ namespace DiscImageChef.Devices
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case Enums.ScsiDirection.In:
|
||||
case ScsiDirection.In:
|
||||
dir = Linux.ScsiIoctlDirection.In;
|
||||
break;
|
||||
case Enums.ScsiDirection.Out:
|
||||
case ScsiDirection.Out:
|
||||
dir = Linux.ScsiIoctlDirection.Out;
|
||||
break;
|
||||
case Enums.ScsiDirection.Bidirectional:
|
||||
case ScsiDirection.Bidirectional:
|
||||
dir = Linux.ScsiIoctlDirection.Unspecified;
|
||||
break;
|
||||
case Enums.ScsiDirection.None:
|
||||
case ScsiDirection.None:
|
||||
dir = Linux.ScsiIoctlDirection.None;
|
||||
break;
|
||||
default:
|
||||
@@ -129,9 +129,9 @@ namespace DiscImageChef.Devices
|
||||
}
|
||||
}
|
||||
|
||||
public static int SendAtaCommand(object fd, Structs.AtaRegistersCHS registers,
|
||||
out Structs.AtaErrorRegistersCHS errorRegisters, Enums.AtaProtocol protocol,
|
||||
Enums.AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
public static int SendAtaCommand(object fd, AtaRegistersCHS registers,
|
||||
out AtaErrorRegistersCHS errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
Interop.PlatformID ptID = DetectOS.GetRealPlatformID();
|
||||
@@ -140,9 +140,9 @@ namespace DiscImageChef.Devices
|
||||
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,
|
||||
public static int SendAtaCommand(Interop.PlatformID ptID, object fd, AtaRegistersCHS registers,
|
||||
out AtaErrorRegistersCHS errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
switch (ptID)
|
||||
@@ -161,9 +161,9 @@ namespace DiscImageChef.Devices
|
||||
}
|
||||
}
|
||||
|
||||
public static int SendAtaCommand(object fd, Structs.AtaRegistersLBA28 registers,
|
||||
out Structs.AtaErrorRegistersLBA28 errorRegisters, Enums.AtaProtocol protocol,
|
||||
Enums.AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
public static int SendAtaCommand(object fd, AtaRegistersLBA28 registers,
|
||||
out AtaErrorRegistersLBA28 errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
Interop.PlatformID ptID = DetectOS.GetRealPlatformID();
|
||||
@@ -172,9 +172,9 @@ namespace DiscImageChef.Devices
|
||||
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,
|
||||
public static int SendAtaCommand(Interop.PlatformID ptID, object fd, AtaRegistersLBA28 registers,
|
||||
out AtaErrorRegistersLBA28 errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
switch (ptID)
|
||||
@@ -193,9 +193,9 @@ namespace DiscImageChef.Devices
|
||||
}
|
||||
}
|
||||
|
||||
public static int SendAtaCommand(object fd, Structs.AtaRegistersLBA48 registers,
|
||||
out Structs.AtaErrorRegistersLBA48 errorRegisters, Enums.AtaProtocol protocol,
|
||||
Enums.AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
public static int SendAtaCommand(object fd, AtaRegistersLBA48 registers,
|
||||
out AtaErrorRegistersLBA48 errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
Interop.PlatformID ptID = DetectOS.GetRealPlatformID();
|
||||
@@ -204,9 +204,9 @@ namespace DiscImageChef.Devices
|
||||
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,
|
||||
public static int SendAtaCommand(Interop.PlatformID ptID, object fd, AtaRegistersLBA48 registers,
|
||||
out AtaErrorRegistersLBA48 errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
switch (ptID)
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace DiscImageChef.Devices
|
||||
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters"/> contains the error registers.</returns>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
/// <param name="statusRegisters">Status registers.</param>
|
||||
public bool AtaIdentify(out byte[] buffer, out Structs.AtaErrorRegistersCHS statusRegisters)
|
||||
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters)
|
||||
{
|
||||
return AtaIdentify(out buffer, out statusRegisters, Timeout);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
/// <param name="statusRegisters">Status registers.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool AtaIdentify(out byte[] buffer, out Structs.AtaErrorRegistersCHS statusRegisters, out double duration)
|
||||
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, out double duration)
|
||||
{
|
||||
return AtaIdentify(out buffer, out statusRegisters, Timeout, out duration);
|
||||
}
|
||||
@@ -72,7 +72,7 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
/// <param name="statusRegisters">Status registers.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
public bool AtaIdentify(out byte[] buffer, out Structs.AtaErrorRegistersCHS statusRegisters, uint timeout)
|
||||
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, uint timeout)
|
||||
{
|
||||
double duration;
|
||||
return AtaIdentify(out buffer, out statusRegisters, timeout, out duration);
|
||||
@@ -86,15 +86,15 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="statusRegisters">Status registers.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool AtaIdentify(out byte[] buffer, out Structs.AtaErrorRegistersCHS statusRegisters, uint timeout, out double duration)
|
||||
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[512];
|
||||
Structs.AtaRegistersCHS registers = new Structs.AtaRegistersCHS();
|
||||
AtaRegistersCHS registers = new AtaRegistersCHS();
|
||||
bool sense;
|
||||
|
||||
registers.command = (byte)Enums.AtaCommands.IdentifyDevice;
|
||||
registers.command = (byte)AtaCommands.IdentifyDevice;
|
||||
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, Enums.AtaProtocol.PioIn, Enums.AtaTransferRegister.NoTransfer,
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.NoTransfer,
|
||||
ref buffer, timeout, false, out duration, out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace DiscImageChef.Devices
|
||||
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters"/> contains the error registers.</returns>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
/// <param name="statusRegisters">Status registers.</param>
|
||||
public bool AtapiIdentify(out byte[] buffer, out Structs.AtaErrorRegistersCHS statusRegisters)
|
||||
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters)
|
||||
{
|
||||
return AtapiIdentify(out buffer, out statusRegisters, Timeout);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
/// <param name="statusRegisters">Status registers.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool AtapiIdentify(out byte[] buffer, out Structs.AtaErrorRegistersCHS statusRegisters, out double duration)
|
||||
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, out double duration)
|
||||
{
|
||||
return AtapiIdentify(out buffer, out statusRegisters, Timeout, out duration);
|
||||
}
|
||||
@@ -72,7 +72,7 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
/// <param name="statusRegisters">Status registers.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
public bool AtapiIdentify(out byte[] buffer, out Structs.AtaErrorRegistersCHS statusRegisters, uint timeout)
|
||||
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, uint timeout)
|
||||
{
|
||||
double duration;
|
||||
return AtapiIdentify(out buffer, out statusRegisters, timeout, out duration);
|
||||
@@ -86,15 +86,15 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="statusRegisters">Status registers.</param>
|
||||
/// <param name="timeout">Timeout.</param>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool AtapiIdentify(out byte[] buffer, out Structs.AtaErrorRegistersCHS statusRegisters, uint timeout, out double duration)
|
||||
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersCHS statusRegisters, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[512];
|
||||
Structs.AtaRegistersCHS registers = new Structs.AtaRegistersCHS();
|
||||
AtaRegistersCHS registers = new AtaRegistersCHS();
|
||||
bool sense;
|
||||
|
||||
registers.command = (byte)Enums.AtaCommands.IdentifyPacketDevice;
|
||||
registers.command = (byte)AtaCommands.IdentifyPacketDevice;
|
||||
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, Enums.AtaProtocol.PioIn, Enums.AtaTransferRegister.NoTransfer,
|
||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.NoTransfer,
|
||||
ref buffer, timeout, false, out duration, out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="direction">SCSI command transfer direction</param>
|
||||
/// <param name="duration">Time it took to execute the command in milliseconds</param>
|
||||
/// <param name="sense"><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, Enums.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, fd, cdb, ref buffer, out senseBuffer, timeout, direction, out duration, out sense);
|
||||
}
|
||||
@@ -70,8 +70,8 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="transferBlocks">If set to <c>true</c>, transfer is indicated in blocks, otherwise, it is indicated in bytes.</param>
|
||||
/// <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(Structs.AtaRegistersCHS registers, out Structs.AtaErrorRegistersCHS errorRegisters,
|
||||
Enums.AtaProtocol protocol, Enums.AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
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)
|
||||
{
|
||||
return Command.SendAtaCommand(platformID, fd, registers, out errorRegisters, protocol, transferRegister,
|
||||
@@ -91,8 +91,8 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="transferBlocks">If set to <c>true</c>, transfer is indicated in blocks, otherwise, it is indicated in bytes.</param>
|
||||
/// <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(Structs.AtaRegistersLBA28 registers, out Structs.AtaErrorRegistersLBA28 errorRegisters,
|
||||
Enums.AtaProtocol protocol, Enums.AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
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)
|
||||
{
|
||||
return Command.SendAtaCommand(platformID, fd, registers, out errorRegisters, protocol, transferRegister,
|
||||
@@ -112,8 +112,8 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="transferBlocks">If set to <c>true</c>, transfer is indicated in blocks, otherwise, it is indicated in bytes.</param>
|
||||
/// <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(Structs.AtaRegistersLBA48 registers, out Structs.AtaErrorRegistersLBA48 errorRegisters,
|
||||
Enums.AtaProtocol protocol, Enums.AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
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)
|
||||
{
|
||||
return Command.SendAtaCommand(platformID, fd, registers, out errorRegisters, protocol, transferRegister,
|
||||
|
||||
@@ -90,10 +90,10 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
buffer = new byte[5];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = { (byte)Enums.ScsiCommands.Inquiry, 0, 0, 0, 5, 0 };
|
||||
byte[] cdb = { (byte)ScsiCommands.Inquiry, 0, 0, 0, 5, 0 };
|
||||
bool sense;
|
||||
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, Enums.ScsiDirection.In, out duration, out sense);
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
if (sense)
|
||||
@@ -101,11 +101,11 @@ namespace DiscImageChef.Devices
|
||||
|
||||
byte pagesLength = (byte)(buffer[4] + 5);
|
||||
|
||||
cdb = new byte[] { (byte)Enums.ScsiCommands.Inquiry, 0, 0, 0, pagesLength, 0 };
|
||||
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, Enums.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", "INQUIRY took {0} ms.", duration);
|
||||
@@ -165,10 +165,10 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
buffer = new byte[5];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = { (byte)Enums.ScsiCommands.Inquiry, 1, page, 0, 5, 0 };
|
||||
byte[] cdb = { (byte)ScsiCommands.Inquiry, 1, page, 0, 5, 0 };
|
||||
bool sense;
|
||||
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, Enums.ScsiDirection.In, out duration, out sense);
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense);
|
||||
error = lastError != 0;
|
||||
|
||||
if (sense)
|
||||
@@ -176,11 +176,11 @@ namespace DiscImageChef.Devices
|
||||
|
||||
byte pagesLength = (byte)(buffer[3] + 4);
|
||||
|
||||
cdb = new byte[] { (byte)Enums.ScsiCommands.Inquiry, 1, page, 0, pagesLength, 0 };
|
||||
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, Enums.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", "INQUIRY took {0} ms.", duration);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -99,50 +99,50 @@ namespace DiscImageChef.Devices.Linux
|
||||
return error;
|
||||
}
|
||||
|
||||
static ScsiIoctlDirection AtaProtocolToScsiDirection(Enums.AtaProtocol protocol)
|
||||
static ScsiIoctlDirection AtaProtocolToScsiDirection(AtaProtocol protocol)
|
||||
{
|
||||
switch (protocol)
|
||||
{
|
||||
case Enums.AtaProtocol.DeviceDiagnostic:
|
||||
case Enums.AtaProtocol.DeviceReset:
|
||||
case Enums.AtaProtocol.HardReset:
|
||||
case Enums.AtaProtocol.NonData:
|
||||
case Enums.AtaProtocol.SoftReset:
|
||||
case Enums.AtaProtocol.ReturnResponse:
|
||||
case AtaProtocol.DeviceDiagnostic:
|
||||
case AtaProtocol.DeviceReset:
|
||||
case AtaProtocol.HardReset:
|
||||
case AtaProtocol.NonData:
|
||||
case AtaProtocol.SoftReset:
|
||||
case AtaProtocol.ReturnResponse:
|
||||
return ScsiIoctlDirection.None;
|
||||
case Enums.AtaProtocol.PioIn:
|
||||
case Enums.AtaProtocol.UDmaIn:
|
||||
case AtaProtocol.PioIn:
|
||||
case AtaProtocol.UDmaIn:
|
||||
return ScsiIoctlDirection.In;
|
||||
case Enums.AtaProtocol.PioOut:
|
||||
case Enums.AtaProtocol.UDmaOut:
|
||||
case AtaProtocol.PioOut:
|
||||
case AtaProtocol.UDmaOut:
|
||||
return ScsiIoctlDirection.Out;
|
||||
default:
|
||||
return ScsiIoctlDirection.Unspecified;
|
||||
}
|
||||
}
|
||||
|
||||
internal static int SendAtaCommand(int fd, Structs.AtaRegistersCHS registers,
|
||||
out Structs.AtaErrorRegistersCHS errorRegisters, Enums.AtaProtocol protocol,
|
||||
Enums.AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
internal static int SendAtaCommand(int fd, AtaRegistersCHS registers,
|
||||
out AtaErrorRegistersCHS errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
duration = 0;
|
||||
sense = false;
|
||||
errorRegisters = new Structs.AtaErrorRegistersCHS();
|
||||
errorRegisters = new AtaErrorRegistersCHS();
|
||||
|
||||
if (buffer == null)
|
||||
return -1;
|
||||
|
||||
byte[] cdb = new byte[16];
|
||||
cdb[0] = (byte)Enums.ScsiCommands.AtaPassThrough16;
|
||||
cdb[0] = (byte)ScsiCommands.AtaPassThrough16;
|
||||
cdb[1] = (byte)(((byte)protocol << 1) & 0x1E);
|
||||
if (transferRegister != Enums.AtaTransferRegister.NoTransfer &&
|
||||
protocol != Enums.AtaProtocol.NonData)
|
||||
if (transferRegister != AtaTransferRegister.NoTransfer &&
|
||||
protocol != AtaProtocol.NonData)
|
||||
{
|
||||
switch (protocol)
|
||||
{
|
||||
case Enums.AtaProtocol.PioIn:
|
||||
case Enums.AtaProtocol.UDmaIn:
|
||||
case AtaProtocol.PioIn:
|
||||
case AtaProtocol.UDmaIn:
|
||||
cdb[2] = 0x08;
|
||||
break;
|
||||
default:
|
||||
@@ -186,28 +186,28 @@ namespace DiscImageChef.Devices.Linux
|
||||
return error;
|
||||
}
|
||||
|
||||
internal static int SendAtaCommand(int fd, Structs.AtaRegistersLBA28 registers,
|
||||
out Structs.AtaErrorRegistersLBA28 errorRegisters, Enums.AtaProtocol protocol,
|
||||
Enums.AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
internal static int SendAtaCommand(int fd, AtaRegistersLBA28 registers,
|
||||
out AtaErrorRegistersLBA28 errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
duration = 0;
|
||||
sense = false;
|
||||
errorRegisters = new Structs.AtaErrorRegistersLBA28();
|
||||
errorRegisters = new AtaErrorRegistersLBA28();
|
||||
|
||||
if (buffer == null)
|
||||
return -1;
|
||||
|
||||
byte[] cdb = new byte[16];
|
||||
cdb[0] = (byte)Enums.ScsiCommands.AtaPassThrough16;
|
||||
cdb[0] = (byte)ScsiCommands.AtaPassThrough16;
|
||||
cdb[1] = (byte)(((byte)protocol << 1) & 0x1E);
|
||||
if (transferRegister != Enums.AtaTransferRegister.NoTransfer &&
|
||||
protocol != Enums.AtaProtocol.NonData)
|
||||
if (transferRegister != AtaTransferRegister.NoTransfer &&
|
||||
protocol != AtaProtocol.NonData)
|
||||
{
|
||||
switch (protocol)
|
||||
{
|
||||
case Enums.AtaProtocol.PioIn:
|
||||
case Enums.AtaProtocol.UDmaIn:
|
||||
case AtaProtocol.PioIn:
|
||||
case AtaProtocol.UDmaIn:
|
||||
cdb[2] = 0x08;
|
||||
break;
|
||||
default:
|
||||
@@ -251,29 +251,29 @@ namespace DiscImageChef.Devices.Linux
|
||||
return error;
|
||||
}
|
||||
|
||||
internal static int SendAtaCommand(int fd, Structs.AtaRegistersLBA48 registers,
|
||||
out Structs.AtaErrorRegistersLBA48 errorRegisters, Enums.AtaProtocol protocol,
|
||||
Enums.AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
internal static int SendAtaCommand(int fd, AtaRegistersLBA48 registers,
|
||||
out AtaErrorRegistersLBA48 errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
duration = 0;
|
||||
sense = false;
|
||||
errorRegisters = new Structs.AtaErrorRegistersLBA48();
|
||||
errorRegisters = new AtaErrorRegistersLBA48();
|
||||
|
||||
if (buffer == null)
|
||||
return -1;
|
||||
|
||||
byte[] cdb = new byte[16];
|
||||
cdb[0] = (byte)Enums.ScsiCommands.AtaPassThrough16;
|
||||
cdb[0] = (byte)ScsiCommands.AtaPassThrough16;
|
||||
cdb[1] |= 0x01;
|
||||
cdb[1] = (byte)(((byte)protocol << 1) & 0x1E);
|
||||
if (transferRegister != Enums.AtaTransferRegister.NoTransfer &&
|
||||
protocol != Enums.AtaProtocol.NonData)
|
||||
if (transferRegister != AtaTransferRegister.NoTransfer &&
|
||||
protocol != AtaProtocol.NonData)
|
||||
{
|
||||
switch (protocol)
|
||||
{
|
||||
case Enums.AtaProtocol.PioIn:
|
||||
case Enums.AtaProtocol.UDmaIn:
|
||||
case AtaProtocol.PioIn:
|
||||
case AtaProtocol.UDmaIn:
|
||||
cdb[2] = 0x08;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -39,76 +39,73 @@ using System;
|
||||
|
||||
namespace DiscImageChef.Devices
|
||||
{
|
||||
public static class Structs
|
||||
public struct AtaRegistersCHS
|
||||
{
|
||||
public struct AtaRegistersCHS
|
||||
{
|
||||
public byte feature;
|
||||
public byte sectorCount;
|
||||
public byte sector;
|
||||
public byte cylinderLow;
|
||||
public byte cylinderHigh;
|
||||
public byte deviceHead;
|
||||
public byte command;
|
||||
}
|
||||
public byte feature;
|
||||
public byte sectorCount;
|
||||
public byte sector;
|
||||
public byte cylinderLow;
|
||||
public byte cylinderHigh;
|
||||
public byte deviceHead;
|
||||
public byte command;
|
||||
}
|
||||
|
||||
public struct AtaRegistersLBA28
|
||||
{
|
||||
public byte feature;
|
||||
public byte sectorCount;
|
||||
public byte lbaLow;
|
||||
public byte lbaMid;
|
||||
public byte lbaHigh;
|
||||
public byte deviceHead;
|
||||
public byte command;
|
||||
}
|
||||
public struct AtaRegistersLBA28
|
||||
{
|
||||
public byte feature;
|
||||
public byte sectorCount;
|
||||
public byte lbaLow;
|
||||
public byte lbaMid;
|
||||
public byte lbaHigh;
|
||||
public byte deviceHead;
|
||||
public byte command;
|
||||
}
|
||||
|
||||
public struct AtaRegistersLBA48
|
||||
{
|
||||
public ushort feature;
|
||||
public ushort sectorCount;
|
||||
public ushort lbaLow;
|
||||
public ushort lbaMid;
|
||||
public ushort lbaHigh;
|
||||
public byte deviceHead;
|
||||
public byte command;
|
||||
}
|
||||
public struct AtaRegistersLBA48
|
||||
{
|
||||
public ushort feature;
|
||||
public ushort sectorCount;
|
||||
public ushort lbaLow;
|
||||
public ushort lbaMid;
|
||||
public ushort lbaHigh;
|
||||
public byte deviceHead;
|
||||
public byte command;
|
||||
}
|
||||
|
||||
public struct AtaErrorRegistersCHS
|
||||
{
|
||||
public byte status;
|
||||
public byte error;
|
||||
public byte sectorCount;
|
||||
public byte sector;
|
||||
public byte cylinderLow;
|
||||
public byte cylinderHigh;
|
||||
public byte deviceHead;
|
||||
public byte command;
|
||||
}
|
||||
public struct AtaErrorRegistersCHS
|
||||
{
|
||||
public byte status;
|
||||
public byte error;
|
||||
public byte sectorCount;
|
||||
public byte sector;
|
||||
public byte cylinderLow;
|
||||
public byte cylinderHigh;
|
||||
public byte deviceHead;
|
||||
public byte command;
|
||||
}
|
||||
|
||||
public struct AtaErrorRegistersLBA28
|
||||
{
|
||||
public byte status;
|
||||
public byte error;
|
||||
public byte sectorCount;
|
||||
public byte lbaLow;
|
||||
public byte lbaMid;
|
||||
public byte lbaHigh;
|
||||
public byte deviceHead;
|
||||
public byte command;
|
||||
}
|
||||
public struct AtaErrorRegistersLBA28
|
||||
{
|
||||
public byte status;
|
||||
public byte error;
|
||||
public byte sectorCount;
|
||||
public byte lbaLow;
|
||||
public byte lbaMid;
|
||||
public byte lbaHigh;
|
||||
public byte deviceHead;
|
||||
public byte command;
|
||||
}
|
||||
|
||||
public struct AtaErrorRegistersLBA48
|
||||
{
|
||||
public byte status;
|
||||
public byte error;
|
||||
public ushort sectorCount;
|
||||
public ushort lbaLow;
|
||||
public ushort lbaMid;
|
||||
public ushort lbaHigh;
|
||||
public byte deviceHead;
|
||||
public byte command;
|
||||
}
|
||||
public struct AtaErrorRegistersLBA48
|
||||
{
|
||||
public byte status;
|
||||
public byte error;
|
||||
public ushort sectorCount;
|
||||
public ushort lbaLow;
|
||||
public ushort lbaMid;
|
||||
public ushort lbaHigh;
|
||||
public byte deviceHead;
|
||||
public byte command;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user