mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Add test for MediaTek READ CACHE vendor command.
This commit is contained in:
4
.idea/.idea.Aaru/.idea/contentModel.xml
generated
4
.idea/.idea.Aaru/.idea/contentModel.xml
generated
@@ -2194,6 +2194,10 @@
|
||||
<e p="SyQuest.cs" t="Include" />
|
||||
</e>
|
||||
<e p="SCSI.cs" t="Include" />
|
||||
<e p="SCSI_MMC" t="Include">
|
||||
<e p="MediaTek.cs" t="Include" />
|
||||
<e p="SCSI_MMC.cs" t="Include" />
|
||||
</e>
|
||||
<e p="SecureDigital" t="Include">
|
||||
<e p="MultiMediaCard.cs" t="Include" />
|
||||
<e p="SecureDigital.cs" t="Include" />
|
||||
|
||||
@@ -53,6 +53,8 @@
|
||||
<Compile Include="SCSI.cs" />
|
||||
<Compile Include="ATA.cs" />
|
||||
<Compile Include="NVMe.cs" />
|
||||
<Compile Include="SCSI_MMC\MediaTek.cs" />
|
||||
<Compile Include="SCSI_MMC\SCSI_MMC.cs" />
|
||||
<Compile Include="SecureDigital.cs" />
|
||||
<Compile Include="SCSI\Adaptec.cs" />
|
||||
<Compile Include="SCSI\ArchiveCorp.cs" />
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
// Copyright © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||
using Aaru.Console;
|
||||
using Aaru.Devices;
|
||||
|
||||
@@ -44,6 +45,10 @@ namespace Aaru.Tests.Devices
|
||||
AaruConsole.WriteLine("2.- Send an ATA command.");
|
||||
AaruConsole.WriteLine("3.- Send a SecureDigital/MultiMediaCard command.");
|
||||
AaruConsole.WriteLine("4.- Send a NVMe command.");
|
||||
|
||||
if(dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice)
|
||||
AaruConsole.WriteLine("5.- Send a special sequence of commands for SCSI Multimedia devices.");
|
||||
|
||||
AaruConsole.WriteLine("0.- Return to device menu.");
|
||||
AaruConsole.Write("Choose: ");
|
||||
|
||||
@@ -79,6 +84,11 @@ namespace Aaru.Tests.Devices
|
||||
NVMe(devPath, dev);
|
||||
|
||||
continue;
|
||||
case 5 when dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice:
|
||||
ScsiMmc.Menu(devPath, dev);
|
||||
|
||||
continue;
|
||||
|
||||
default:
|
||||
AaruConsole.WriteLine("Incorrect option. Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
|
||||
162
Aaru.Tests.Devices/SCSI_MMC/MediaTek.cs
Normal file
162
Aaru.Tests.Devices/SCSI_MMC/MediaTek.cs
Normal file
@@ -0,0 +1,162 @@
|
||||
using Aaru.Console;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Devices;
|
||||
|
||||
namespace Aaru.Tests.Devices
|
||||
{
|
||||
internal static partial class ScsiMmc
|
||||
{
|
||||
static void MediaTekReadCache(string devPath, Device dev)
|
||||
{
|
||||
uint address = 0;
|
||||
string strDev;
|
||||
int item;
|
||||
|
||||
parameters:
|
||||
|
||||
while(true)
|
||||
{
|
||||
System.Console.Clear();
|
||||
AaruConsole.WriteLine("Device: {0}", devPath);
|
||||
AaruConsole.WriteLine("Parameters for MediaTek READ CACHE command:");
|
||||
AaruConsole.WriteLine("LBA: {0}", address);
|
||||
AaruConsole.WriteLine();
|
||||
AaruConsole.WriteLine("Choose what to do:");
|
||||
AaruConsole.WriteLine("1.- Change parameters.");
|
||||
AaruConsole.WriteLine("2.- Send command with these parameters.");
|
||||
AaruConsole.WriteLine("0.- Return to special SCSI MultiMedia Commands menu.");
|
||||
|
||||
strDev = System.Console.ReadLine();
|
||||
|
||||
if(!int.TryParse(strDev, out item))
|
||||
{
|
||||
AaruConsole.WriteLine("Not a number. Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
switch(item)
|
||||
{
|
||||
case 0:
|
||||
AaruConsole.WriteLine("Returning to special SCSI MultiMedia Commands menu...");
|
||||
|
||||
return;
|
||||
case 1:
|
||||
AaruConsole.Write("LBA?: ");
|
||||
strDev = System.Console.ReadLine();
|
||||
|
||||
if(!uint.TryParse(strDev, out address))
|
||||
{
|
||||
AaruConsole.WriteLine("Not a number. Press any key to continue...");
|
||||
address = 0;
|
||||
System.Console.ReadKey();
|
||||
}
|
||||
|
||||
break;
|
||||
case 2: goto start;
|
||||
}
|
||||
}
|
||||
|
||||
start:
|
||||
System.Console.Clear();
|
||||
|
||||
AaruConsole.WriteLine("Sending READ CD to the device...");
|
||||
|
||||
bool sense = dev.ReadCd(out byte[] buffer, out byte[] senseBuffer, address, 2352, 1,
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true,
|
||||
MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out double duration);
|
||||
|
||||
if(sense)
|
||||
AaruConsole.WriteLine("READ CD failed...");
|
||||
|
||||
AaruConsole.WriteLine("Sending MediaTek READ CACHE to the device...");
|
||||
sense = dev.MediaTekReadCache(out buffer, out senseBuffer, 0, 0xB00, dev.Timeout, out duration);
|
||||
|
||||
menu:
|
||||
AaruConsole.WriteLine("Device: {0}", devPath);
|
||||
AaruConsole.WriteLine("Command took {0} ms.", duration);
|
||||
AaruConsole.WriteLine("Sense is {0}.", sense);
|
||||
AaruConsole.WriteLine("System error status is {0} and error number is {1}.", dev.Error, dev.LastError);
|
||||
AaruConsole.WriteLine("Buffer is {0} bytes.", buffer?.Length.ToString() ?? "null");
|
||||
AaruConsole.WriteLine("Buffer is null or empty? {0}", ArrayHelpers.ArrayIsNullOrEmpty(buffer));
|
||||
AaruConsole.WriteLine("Sense buffer is {0} bytes.", senseBuffer?.Length.ToString() ?? "null");
|
||||
AaruConsole.WriteLine("Sense buffer is null or empty? {0}", ArrayHelpers.ArrayIsNullOrEmpty(senseBuffer));
|
||||
AaruConsole.WriteLine();
|
||||
AaruConsole.WriteLine("Choose what to do:");
|
||||
AaruConsole.WriteLine("1.- Print buffer.");
|
||||
AaruConsole.WriteLine("2.- Print sense buffer.");
|
||||
AaruConsole.WriteLine("3.- Decode sense buffer.");
|
||||
AaruConsole.WriteLine("4.- Send command again.");
|
||||
AaruConsole.WriteLine("5.- Change parameters.");
|
||||
AaruConsole.WriteLine("0.- Return to special SCSI MultiMedia Commands menu.");
|
||||
AaruConsole.Write("Choose: ");
|
||||
|
||||
strDev = System.Console.ReadLine();
|
||||
|
||||
if(!int.TryParse(strDev, out item))
|
||||
{
|
||||
AaruConsole.WriteLine("Not a number. Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
System.Console.Clear();
|
||||
|
||||
goto menu;
|
||||
}
|
||||
|
||||
switch(item)
|
||||
{
|
||||
case 0:
|
||||
AaruConsole.WriteLine("Returning to special SCSI MultiMedia Commands menu...");
|
||||
|
||||
return;
|
||||
case 1:
|
||||
System.Console.Clear();
|
||||
AaruConsole.WriteLine("Device: {0}", devPath);
|
||||
AaruConsole.WriteLine("MediaTek's READ CACHE response:");
|
||||
|
||||
if(buffer != null)
|
||||
PrintHex.PrintHexArray(buffer, 64);
|
||||
|
||||
AaruConsole.WriteLine("Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
System.Console.Clear();
|
||||
AaruConsole.WriteLine("Device: {0}", devPath);
|
||||
|
||||
goto menu;
|
||||
case 2:
|
||||
System.Console.Clear();
|
||||
AaruConsole.WriteLine("Device: {0}", devPath);
|
||||
AaruConsole.WriteLine("MediaTek's READ CACHE sense:");
|
||||
|
||||
if(senseBuffer != null)
|
||||
PrintHex.PrintHexArray(senseBuffer, 64);
|
||||
|
||||
AaruConsole.WriteLine("Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
System.Console.Clear();
|
||||
AaruConsole.WriteLine("Device: {0}", devPath);
|
||||
|
||||
goto menu;
|
||||
case 3:
|
||||
System.Console.Clear();
|
||||
AaruConsole.WriteLine("Device: {0}", devPath);
|
||||
AaruConsole.WriteLine("MediaTek's READ CACHE decoded sense:");
|
||||
AaruConsole.Write("{0}", Sense.PrettifySense(senseBuffer));
|
||||
AaruConsole.WriteLine("Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
System.Console.Clear();
|
||||
AaruConsole.WriteLine("Device: {0}", devPath);
|
||||
|
||||
goto menu;
|
||||
case 4: goto start;
|
||||
case 5: goto parameters;
|
||||
default:
|
||||
AaruConsole.WriteLine("Incorrect option. Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
System.Console.Clear();
|
||||
|
||||
goto menu;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
79
Aaru.Tests.Devices/SCSI_MMC/SCSI_MMC.cs
Normal file
79
Aaru.Tests.Devices/SCSI_MMC/SCSI_MMC.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : SCSI_MMC.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : DiscImageChef device testing.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.Console;
|
||||
using Aaru.Devices;
|
||||
|
||||
namespace Aaru.Tests.Devices
|
||||
{
|
||||
internal static partial class ScsiMmc
|
||||
{
|
||||
public static void Menu(string devPath, Device dev)
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
System.Console.Clear();
|
||||
AaruConsole.WriteLine("Device: {0}", devPath);
|
||||
AaruConsole.WriteLine("Send a special SCSI MultiMedia command to the device:");
|
||||
|
||||
AaruConsole.
|
||||
WriteLine("1.- Try to read the cache data from a device with a MediaTek chipset (F1h command 06h subcommand).");
|
||||
|
||||
AaruConsole.WriteLine("0.- Return to command class menu.");
|
||||
AaruConsole.Write("Choose: ");
|
||||
|
||||
string strDev = System.Console.ReadLine();
|
||||
|
||||
if(!int.TryParse(strDev, out int item))
|
||||
{
|
||||
AaruConsole.WriteLine("Not a number. Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
switch(item)
|
||||
{
|
||||
case 0:
|
||||
AaruConsole.WriteLine("Returning to command class menu...");
|
||||
|
||||
return;
|
||||
case 1:
|
||||
MediaTekReadCache(devPath, dev);
|
||||
|
||||
continue;
|
||||
default:
|
||||
AaruConsole.WriteLine("Incorrect option. Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user