Add stubs for remote device commands.

This commit is contained in:
2019-10-13 23:31:56 +01:00
parent 63544feaec
commit 53a8a11408
3 changed files with 257 additions and 179 deletions

View File

@@ -40,7 +40,7 @@ using PlatformID = DiscImageChef.CommonTypes.Interop.PlatformID;
namespace DiscImageChef.Devices namespace DiscImageChef.Devices
{ {
static class Command internal static class Command
{ {
/// <summary> /// <summary>
/// Sends a SCSI command /// Sends a SCSI command
@@ -63,7 +63,7 @@ namespace DiscImageChef.Devices
uint timeout, ScsiDirection direction, out double duration, uint timeout, ScsiDirection direction, out double duration,
out bool sense) out bool sense)
{ {
PlatformID ptId = DetectOS.GetRealPlatformID(); var ptId = DetectOS.GetRealPlatformID();
return SendScsiCommand(ptId, fd, cdb, ref buffer, out senseBuffer, timeout, direction, out duration, return SendScsiCommand(ptId, fd, cdb, ref buffer, out senseBuffer, timeout, direction, out duration,
out sense); out sense);
@@ -191,7 +191,7 @@ namespace DiscImageChef.Devices
bool transferBlocks, out double duration, bool transferBlocks, out double duration,
out bool sense) out bool sense)
{ {
PlatformID ptId = DetectOS.GetRealPlatformID(); var ptId = DetectOS.GetRealPlatformID();
return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister, return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister,
ref buffer, ref buffer,
@@ -276,7 +276,7 @@ namespace DiscImageChef.Devices
bool transferBlocks, out double duration, bool transferBlocks, out double duration,
out bool sense) out bool sense)
{ {
PlatformID ptId = DetectOS.GetRealPlatformID(); var ptId = DetectOS.GetRealPlatformID();
return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister, return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister,
ref buffer, ref buffer,
@@ -361,7 +361,7 @@ namespace DiscImageChef.Devices
bool transferBlocks, out double duration, bool transferBlocks, out double duration,
out bool sense) out bool sense)
{ {
PlatformID ptId = DetectOS.GetRealPlatformID(); var ptId = DetectOS.GetRealPlatformID();
return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister, return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister,
ref buffer, ref buffer,
@@ -441,7 +441,7 @@ namespace DiscImageChef.Devices
out bool sense, out bool sense,
uint timeout = 0) uint timeout = 0)
{ {
PlatformID ptId = DetectOS.GetRealPlatformID(); var ptId = DetectOS.GetRealPlatformID();
return SendMmcCommand(ptId, (int) fd, command, write, isApplication, flags, argument, return SendMmcCommand(ptId, (int) fd, command, write, isApplication, flags, argument,
blockSize, blocks, blockSize, blocks,

View File

@@ -54,9 +54,15 @@ namespace DiscImageChef.Devices
/// SCSI sense /// SCSI sense
/// </param> /// </param>
public int SendScsiCommand(byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, uint timeout, public int SendScsiCommand(byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, uint timeout,
ScsiDirection direction, out double duration, out bool sense) => ScsiDirection direction, out double duration, out bool sense)
Command.SendScsiCommand(PlatformId, FileHandle, cdb, ref buffer, out senseBuffer, timeout, direction, {
if (!(remote is null))
return remote.SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout,
direction, out duration, out sense);
return Command.SendScsiCommand(PlatformId, FileHandle, cdb, ref buffer, out senseBuffer, timeout, direction,
out duration, out sense); out duration, out sense);
}
/// <summary> /// <summary>
/// Sends an ATA/ATAPI command to this device using CHS addressing /// Sends an ATA/ATAPI command to this device using CHS addressing
@@ -78,9 +84,14 @@ namespace DiscImageChef.Devices
AtaProtocol protocol, AtaTransferRegister transferRegister, AtaProtocol protocol, AtaTransferRegister transferRegister,
ref byte[] buffer, ref byte[] buffer,
uint timeout, bool transferBlocks, uint timeout, bool transferBlocks,
out double duration, out bool sense) => out double duration, out bool sense)
Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol, transferRegister, {
if (!(remote is null)) throw new NotImplementedException("Remote CHS ATA commands not yet implemented...");
return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol,
transferRegister,
ref buffer, timeout, transferBlocks, out duration, out sense); ref buffer, timeout, transferBlocks, out duration, out sense);
}
/// <summary> /// <summary>
/// Sends an ATA/ATAPI command to this device using 28-bit LBA addressing /// Sends an ATA/ATAPI command to this device using 28-bit LBA addressing
@@ -102,9 +113,19 @@ namespace DiscImageChef.Devices
AtaProtocol protocol, AtaTransferRegister transferRegister, AtaProtocol protocol, AtaTransferRegister transferRegister,
ref byte[] buffer, ref byte[] buffer,
uint timeout, bool transferBlocks, uint timeout, bool transferBlocks,
out double duration, out bool sense) => out double duration, out bool sense)
Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol, transferRegister, {
if (!(remote is null))
remote.SendAtaCommand(registers, out errorRegisters,
protocol, transferRegister,
ref buffer,
timeout, transferBlocks,
out duration, out sense);
return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol,
transferRegister,
ref buffer, timeout, transferBlocks, out duration, out sense); ref buffer, timeout, transferBlocks, out duration, out sense);
}
/// <summary> /// <summary>
/// Sends an ATA/ATAPI command to this device using 48-bit LBA addressing /// Sends an ATA/ATAPI command to this device using 48-bit LBA addressing
@@ -126,9 +147,19 @@ namespace DiscImageChef.Devices
AtaProtocol protocol, AtaTransferRegister transferRegister, AtaProtocol protocol, AtaTransferRegister transferRegister,
ref byte[] buffer, ref byte[] buffer,
uint timeout, bool transferBlocks, uint timeout, bool transferBlocks,
out double duration, out bool sense) => out double duration, out bool sense)
Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol, transferRegister, {
if (!(remote is null))
remote.SendAtaCommand(registers, out errorRegisters,
protocol, transferRegister,
ref buffer,
timeout, transferBlocks,
out duration, out sense);
return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol,
transferRegister,
ref buffer, timeout, transferBlocks, out duration, out sense); ref buffer, timeout, transferBlocks, out duration, out sense);
}
/// <summary> /// <summary>
/// Sends a MMC/SD command to this device /// Sends a MMC/SD command to this device
@@ -155,55 +186,60 @@ namespace DiscImageChef.Devices
{ {
case MmcCommands.SendCid when cachedCid != null: case MmcCommands.SendCid when cachedCid != null:
{ {
DateTime start = DateTime.Now; var start = DateTime.Now;
buffer = new byte[cachedCid.Length]; buffer = new byte[cachedCid.Length];
Array.Copy(cachedCid, buffer, buffer.Length); Array.Copy(cachedCid, buffer, buffer.Length);
response = new uint[4]; response = new uint[4];
sense = false; sense = false;
DateTime end = DateTime.Now; var end = DateTime.Now;
duration = (end - start).TotalMilliseconds; duration = (end - start).TotalMilliseconds;
return 0; return 0;
} }
case MmcCommands.SendCsd when cachedCid != null: case MmcCommands.SendCsd when cachedCid != null:
{ {
DateTime start = DateTime.Now; var start = DateTime.Now;
buffer = new byte[cachedCsd.Length]; buffer = new byte[cachedCsd.Length];
Array.Copy(cachedCsd, buffer, buffer.Length); Array.Copy(cachedCsd, buffer, buffer.Length);
response = new uint[4]; response = new uint[4];
sense = false; sense = false;
DateTime end = DateTime.Now; var end = DateTime.Now;
duration = (end - start).TotalMilliseconds; duration = (end - start).TotalMilliseconds;
return 0; return 0;
} }
case (MmcCommands) SecureDigitalCommands.SendScr when cachedScr != null: case (MmcCommands) SecureDigitalCommands.SendScr when cachedScr != null:
{ {
DateTime start = DateTime.Now; var start = DateTime.Now;
buffer = new byte[cachedScr.Length]; buffer = new byte[cachedScr.Length];
Array.Copy(cachedScr, buffer, buffer.Length); Array.Copy(cachedScr, buffer, buffer.Length);
response = new uint[4]; response = new uint[4];
sense = false; sense = false;
DateTime end = DateTime.Now; var end = DateTime.Now;
duration = (end - start).TotalMilliseconds; duration = (end - start).TotalMilliseconds;
return 0; return 0;
} }
} case (MmcCommands) SecureDigitalCommands.SendOperatingCondition when cachedOcr != null:
case MmcCommands.SendOpCond when cachedOcr != null:
if(command != (MmcCommands)SecureDigitalCommands.SendOperatingCondition &&
command != MmcCommands.SendOpCond || cachedOcr == null)
return Command.SendMmcCommand(PlatformId, FileHandle, command, write, isApplication, flags, argument,
blockSize, blocks, ref buffer, out response, out duration, out sense,
timeout);
{ {
DateTime start = DateTime.Now; var start = DateTime.Now;
buffer = new byte[cachedOcr.Length]; buffer = new byte[cachedOcr.Length];
Array.Copy(cachedOcr, buffer, buffer.Length); Array.Copy(cachedOcr, buffer, buffer.Length);
response = new uint[4]; response = new uint[4];
sense = false; sense = false;
DateTime end = DateTime.Now; var end = DateTime.Now;
duration = (end - start).TotalMilliseconds; duration = (end - start).TotalMilliseconds;
return 0; return 0;
} }
} }
if (!(remote is null))
remote.SendMmcCommand(command, write, isApplication, flags,
argument,
blockSize, blocks, ref buffer, out response,
out duration, out sense, timeout);
return Command.SendMmcCommand(PlatformId, FileHandle, command, write, isApplication, flags, argument,
blockSize, blocks, ref buffer, out response, out duration, out sense,
timeout);
}
} }
} }

View File

@@ -7,6 +7,7 @@ using System.Net.Sockets;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using DiscImageChef.CommonTypes.Interop; using DiscImageChef.CommonTypes.Interop;
using DiscImageChef.Console; using DiscImageChef.Console;
using DiscImageChef.Decoders.ATA;
using Marshal = DiscImageChef.Helpers.Marshal; using Marshal = DiscImageChef.Helpers.Marshal;
using Version = DiscImageChef.CommonTypes.Interop.Version; using Version = DiscImageChef.CommonTypes.Interop.Version;
@@ -325,5 +326,46 @@ namespace DiscImageChef.Devices.Remote
LastError = nop.errno; LastError = nop.errno;
return false; return false;
} }
public int SendScsiCommand(byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, uint timeout,
ScsiDirection direction, out double duration, out bool sense)
{
throw new NotImplementedException("Remote SCSI commands not yet implemented...");
}
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)
{
throw new NotImplementedException("Remote CHS ATA commands not yet implemented...");
}
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)
{
throw new NotImplementedException("Remote 28-bit ATA commands not yet implemented...");
}
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)
{
throw new NotImplementedException("Remote 48-bit ATA commands not yet implemented...");
}
public int SendMmcCommand(MmcCommands command, bool write, bool isApplication, MmcFlags flags,
uint argument,
uint blockSize, uint blocks, ref byte[] buffer, out uint[] response,
out double duration, out bool sense, uint timeout = 0)
{
throw new NotImplementedException("Remote SDHCI commands not yet implemented...");
}
} }
} }