mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Corrected byte addressing for MMC/SD.
This commit is contained in:
@@ -94,6 +94,7 @@ namespace DiscImageChef.Core.Devices.Dumping
|
|||||||
byte[] scr = null;
|
byte[] scr = null;
|
||||||
uint[] response;
|
uint[] response;
|
||||||
int physicalBlockSize = 0;
|
int physicalBlockSize = 0;
|
||||||
|
bool byteAddressed = true;
|
||||||
|
|
||||||
if(dev.Type == DeviceType.MMC)
|
if(dev.Type == DeviceType.MMC)
|
||||||
{
|
{
|
||||||
@@ -111,6 +112,8 @@ namespace DiscImageChef.Core.Devices.Dumping
|
|||||||
physicalBlockSize = 512;
|
physicalBlockSize = 512;
|
||||||
else if(ecsdDecoded.NativeSectorSize == 1)
|
else if(ecsdDecoded.NativeSectorSize == 1)
|
||||||
physicalBlockSize = 4096;
|
physicalBlockSize = 4096;
|
||||||
|
// Supposing it's high-capacity MMC if it has Extended CSD...
|
||||||
|
byteAddressed = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ecsd = null;
|
ecsd = null;
|
||||||
@@ -142,6 +145,8 @@ namespace DiscImageChef.Core.Devices.Dumping
|
|||||||
csdDecoded = Decoders.SecureDigital.Decoders.DecodeCSD(csd);
|
csdDecoded = Decoders.SecureDigital.Decoders.DecodeCSD(csd);
|
||||||
blocks = (ulong)(csdDecoded.Structure == 0 ? (csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2) : (csdDecoded.Size + 1) * 1024);
|
blocks = (ulong)(csdDecoded.Structure == 0 ? (csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2) : (csdDecoded.Size + 1) * 1024);
|
||||||
blockSize = (uint)Math.Pow(2, csdDecoded.ReadBlockLength);
|
blockSize = (uint)Math.Pow(2, csdDecoded.ReadBlockLength);
|
||||||
|
// Structure >=1 for SDHC/SDXC, so that's block addressed
|
||||||
|
byteAddressed = csdDecoded.Structure == 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
csd = null;
|
csd = null;
|
||||||
@@ -243,7 +248,7 @@ namespace DiscImageChef.Core.Devices.Dumping
|
|||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
error = dev.Read(out cmdBuf, out response, 0, blockSize, blocksToRead, false, timeout, out duration);
|
error = dev.Read(out cmdBuf, out response, 0, blockSize, blocksToRead, byteAddressed, timeout, out duration);
|
||||||
|
|
||||||
if(error)
|
if(error)
|
||||||
blocksToRead /= 2;
|
blocksToRead /= 2;
|
||||||
@@ -295,7 +300,7 @@ namespace DiscImageChef.Core.Devices.Dumping
|
|||||||
|
|
||||||
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, blocks, currentSpeed);
|
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, blocks, currentSpeed);
|
||||||
|
|
||||||
error = dev.Read(out cmdBuf, out response, (uint)i, blockSize, blocksToRead, false, timeout, out duration);
|
error = dev.Read(out cmdBuf, out response, (uint)i, blockSize, blocksToRead, byteAddressed, timeout, out duration);
|
||||||
|
|
||||||
if(!error)
|
if(!error)
|
||||||
{
|
{
|
||||||
@@ -350,7 +355,7 @@ namespace DiscImageChef.Core.Devices.Dumping
|
|||||||
|
|
||||||
DicConsole.Write("\rRetrying sector {0}, pass {1}, {3}{2}", badSector, pass + 1, forward ? "forward" : "reverse", runningPersistent ? "recovering partial data, " : "");
|
DicConsole.Write("\rRetrying sector {0}, pass {1}, {3}{2}", badSector, pass + 1, forward ? "forward" : "reverse", runningPersistent ? "recovering partial data, " : "");
|
||||||
|
|
||||||
error = dev.Read(out cmdBuf, out response, (uint)badSector, blockSize, 1, false, timeout, out duration);
|
error = dev.Read(out cmdBuf, out response, (uint)badSector, blockSize, 1, byteAddressed, timeout, out duration);
|
||||||
|
|
||||||
totalDuration += duration;
|
totalDuration += duration;
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
|||||||
ushort currentProfile = 0x0001;
|
ushort currentProfile = 0x0001;
|
||||||
uint blocksToRead = 1;
|
uint blocksToRead = 1;
|
||||||
uint blockSize = 512;
|
uint blockSize = 512;
|
||||||
|
bool byteAddressed = true;
|
||||||
|
|
||||||
if(dev.Type == DeviceType.MMC)
|
if(dev.Type == DeviceType.MMC)
|
||||||
{
|
{
|
||||||
@@ -74,6 +75,8 @@ namespace DiscImageChef.Core.Devices.Scanning
|
|||||||
blocksToRead = ecsd.OptimalReadSize;
|
blocksToRead = ecsd.OptimalReadSize;
|
||||||
results.blocks = ecsd.SectorCount;
|
results.blocks = ecsd.SectorCount;
|
||||||
blockSize = (uint)(ecsd.SectorSize == 1 ? 4096 : 512);
|
blockSize = (uint)(ecsd.SectorSize == 1 ? 4096 : 512);
|
||||||
|
// Supposing it's high-capacity MMC if it has Extended CSD...
|
||||||
|
byteAddressed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sense || results.blocks == 0)
|
if(sense || results.blocks == 0)
|
||||||
@@ -97,6 +100,8 @@ namespace DiscImageChef.Core.Devices.Scanning
|
|||||||
csd = Decoders.SecureDigital.Decoders.DecodeCSD(cmdBuf);
|
csd = Decoders.SecureDigital.Decoders.DecodeCSD(cmdBuf);
|
||||||
results.blocks = (ulong)(csd.Structure == 0 ? (csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2) : (csd.Size + 1) * 1024);
|
results.blocks = (ulong)(csd.Structure == 0 ? (csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2) : (csd.Size + 1) * 1024);
|
||||||
blockSize = (uint)Math.Pow(2, csd.ReadBlockLength);
|
blockSize = (uint)Math.Pow(2, csd.ReadBlockLength);
|
||||||
|
// Structure >=1 for SDHC/SDXC, so that's block addressed
|
||||||
|
byteAddressed = csd.Structure == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +115,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
|||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
sense = dev.Read(out cmdBuf, out response, 0, blockSize, blocksToRead, false, timeout, out duration);
|
sense = dev.Read(out cmdBuf, out response, 0, blockSize, blocksToRead, byteAddressed, timeout, out duration);
|
||||||
|
|
||||||
if(sense)
|
if(sense)
|
||||||
blocksToRead /= 2;
|
blocksToRead /= 2;
|
||||||
@@ -180,7 +185,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
|||||||
|
|
||||||
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, results.blocks, currentSpeed);
|
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, results.blocks, currentSpeed);
|
||||||
|
|
||||||
bool error = dev.Read(out cmdBuf, out response, (uint)i, blockSize, blocksToRead, false, timeout, out duration);
|
bool error = dev.Read(out cmdBuf, out response, (uint)i, blockSize, blocksToRead, byteAddressed, timeout, out duration);
|
||||||
|
|
||||||
if(!error)
|
if(!error)
|
||||||
{
|
{
|
||||||
@@ -246,7 +251,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
|||||||
|
|
||||||
DicConsole.Write("\rSeeking to sector {0}...\t\t", seekPos);
|
DicConsole.Write("\rSeeking to sector {0}...\t\t", seekPos);
|
||||||
|
|
||||||
dev.Read(out cmdBuf, out response, (uint)seekPos, blockSize, blocksToRead, false, timeout, out seekCur);
|
dev.Read(out cmdBuf, out response, (uint)seekPos, blockSize, blocksToRead, byteAddressed, timeout, out seekCur);
|
||||||
|
|
||||||
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
|
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
|
||||||
if(seekCur > results.seekMax && seekCur != 0)
|
if(seekCur > results.seekMax && seekCur != 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user