mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Code cleanup.
This commit is contained in:
@@ -40,9 +40,12 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
buffer = new byte[16];
|
||||
|
||||
LastError = SendMmcCommand(MmcCommands.SendCsd, false, false,
|
||||
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1,
|
||||
ref buffer, out response, out duration, out bool sense, timeout);
|
||||
LastError = SendMmcCommand(MmcCommands.SendCsd, false,
|
||||
false,
|
||||
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0,
|
||||
16, 1,
|
||||
ref buffer, out response,
|
||||
out duration, out bool sense, timeout);
|
||||
Error = LastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("MMC Device", "SEND_CSD took {0} ms.", duration);
|
||||
@@ -54,9 +57,12 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
buffer = new byte[16];
|
||||
|
||||
LastError = SendMmcCommand(MmcCommands.SendCid, false, false,
|
||||
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1,
|
||||
ref buffer, out response, out duration, out bool sense, timeout);
|
||||
LastError = SendMmcCommand(MmcCommands.SendCid, false,
|
||||
false,
|
||||
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0,
|
||||
16, 1,
|
||||
ref buffer, out response,
|
||||
out duration, out bool sense, timeout);
|
||||
Error = LastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("MMC Device", "SEND_CID took {0} ms.", duration);
|
||||
@@ -68,9 +74,12 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
buffer = new byte[4];
|
||||
|
||||
LastError = SendMmcCommand(MmcCommands.SendOpCond, false, true,
|
||||
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0, 4, 1,
|
||||
ref buffer, out response, out duration, out bool sense, timeout);
|
||||
LastError = SendMmcCommand(MmcCommands.SendOpCond, false,
|
||||
true,
|
||||
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0,
|
||||
4, 1,
|
||||
ref buffer, out response,
|
||||
out duration, out bool sense, timeout);
|
||||
Error = LastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("SecureDigital Device", "SEND_OP_COND took {0} ms.", duration);
|
||||
@@ -82,9 +91,12 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
buffer = new byte[512];
|
||||
|
||||
LastError = SendMmcCommand(MmcCommands.SendExtCsd, false, false,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 512, 1,
|
||||
ref buffer, out response, out duration, out bool sense, timeout);
|
||||
LastError = SendMmcCommand(MmcCommands.SendExtCsd, false,
|
||||
false,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0,
|
||||
512, 1,
|
||||
ref buffer,
|
||||
out response, out duration, out bool sense, timeout);
|
||||
Error = LastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("MMC Device", "SEND_EXT_CSD took {0} ms.", duration);
|
||||
@@ -96,9 +108,12 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
|
||||
LastError = SendMmcCommand(MmcCommands.SetBlocklen, false, false,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, length, 0, 0,
|
||||
ref buffer, out response, out duration, out bool sense, timeout);
|
||||
LastError = SendMmcCommand(MmcCommands.SetBlocklen, false,
|
||||
false,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, length,
|
||||
0, 0,
|
||||
ref buffer, out response,
|
||||
out duration, out bool sense, timeout);
|
||||
Error = LastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("MMC Device", "SET_BLOCKLEN took {0} ms.", duration);
|
||||
@@ -106,28 +121,34 @@ namespace DiscImageChef.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool Read(out byte[] buffer, out uint[] response, uint lba, uint blockSize, uint transferLength,
|
||||
bool byteAddressed, uint timeout, out double duration)
|
||||
public bool Read(out byte[] buffer, out uint[] response, uint lba, uint blockSize,
|
||||
uint transferLength,
|
||||
bool byteAddressed, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[transferLength * blockSize];
|
||||
uint address;
|
||||
if(byteAddressed) address = lba * blockSize;
|
||||
else address = lba;
|
||||
else address = lba;
|
||||
|
||||
MmcCommands command = transferLength > 1 ? MmcCommands.ReadMultipleBlock : MmcCommands.ReadSingleBlock;
|
||||
|
||||
LastError = SendMmcCommand(command, false, false,
|
||||
LastError = SendMmcCommand(command, false,
|
||||
false,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, address,
|
||||
blockSize, transferLength, ref buffer, out response, out duration,
|
||||
blockSize,
|
||||
transferLength, ref buffer, out response, out duration,
|
||||
out bool sense, timeout);
|
||||
Error = LastError != 0;
|
||||
|
||||
if(transferLength > 1)
|
||||
{
|
||||
byte[] foo = new byte[0];
|
||||
SendMmcCommand(MmcCommands.StopTransmission, false, false,
|
||||
MmcFlags.ResponseR1B | MmcFlags.ResponseSpiR1B | MmcFlags.CommandAc, 0, 0, 0, ref foo,
|
||||
out _, out double stopDuration, out bool _, timeout);
|
||||
SendMmcCommand(MmcCommands.StopTransmission, false,
|
||||
false,
|
||||
MmcFlags.ResponseR1B | MmcFlags.ResponseSpiR1B | MmcFlags.CommandAc, 0,
|
||||
0, 0, ref foo,
|
||||
out _,
|
||||
out double stopDuration, out bool _, timeout);
|
||||
duration += stopDuration;
|
||||
DicConsole.DebugWriteLine("MMC Device", "READ_MULTIPLE_BLOCK took {0} ms.", duration);
|
||||
}
|
||||
@@ -140,9 +161,12 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
buffer = new byte[4];
|
||||
|
||||
LastError = SendMmcCommand(MmcCommands.SendStatus, false, true,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, 0, 4, 1,
|
||||
ref buffer, out response, out duration, out bool sense, timeout);
|
||||
LastError = SendMmcCommand(MmcCommands.SendStatus, false,
|
||||
true,
|
||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, 0,
|
||||
4, 1,
|
||||
ref buffer, out response,
|
||||
out duration, out bool sense, timeout);
|
||||
Error = LastError != 0;
|
||||
|
||||
DicConsole.DebugWriteLine("SecureDigital Device", "SEND_STATUS took {0} ms.", duration);
|
||||
|
||||
Reference in New Issue
Block a user