From 4f69f31e4c40b9e854f71d3bcefc4572b4c98663 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Thu, 28 Sep 2017 19:25:24 +0000 Subject: [PATCH] If present, use cached CID, CSD and CSR registers instead of sending the command to the device. --- DiscImageChef.Devices/Device/Commands.cs | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/DiscImageChef.Devices/Device/Commands.cs b/DiscImageChef.Devices/Device/Commands.cs index f048c740..c0e18e40 100644 --- a/DiscImageChef.Devices/Device/Commands.cs +++ b/DiscImageChef.Devices/Device/Commands.cs @@ -135,6 +135,42 @@ namespace DiscImageChef.Devices uint argument, uint blockSize, uint blocks, ref byte[] buffer, out uint[] response, out double duration, out bool sense, uint timeout = 0) { + if(command == MmcCommands.SendCID && cachedCid != null) + { + System.DateTime start = System.DateTime.Now; + buffer = new byte[cachedCid.Length]; + System.Array.Copy(cachedCid, buffer, buffer.Length); + response = new uint[4]; + sense = false; + System.DateTime end = System.DateTime.Now; + duration = (end - start).TotalMilliseconds; + return 0; + } + + if(command == MmcCommands.SendCSD && cachedCid != null) + { + System.DateTime start = System.DateTime.Now; + buffer = new byte[cachedCsd.Length]; + System.Array.Copy(cachedCsd, buffer, buffer.Length); + response = new uint[4]; + sense = false; + System.DateTime end = System.DateTime.Now; + duration = (end - start).TotalMilliseconds; + return 0; + } + + if(command == (MmcCommands)SecureDigitalCommands.SendSCR && cachedScr != null) + { + System.DateTime start = System.DateTime.Now; + buffer = new byte[cachedScr.Length]; + System.Array.Copy(cachedScr, buffer, buffer.Length); + response = new uint[4]; + sense = false; + System.DateTime end = System.DateTime.Now; + duration = (end - start).TotalMilliseconds; + return 0; + } + return Command.SendMmcCommand(platformID, fd, command, write, isApplication, flags, argument, blockSize, blocks, ref buffer, out response, out duration, out sense, timeout); }