From 88c36610f2b79759ff7766c1fb125113a792dd91 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Fri, 5 Jun 2020 01:22:31 +0100 Subject: [PATCH] Add media tag types for MiniDisc. --- .idea/.idea.Aaru/.idea/contentModel.xml | 139 ++++++++++++-- Aaru.CommonTypes | 2 +- Aaru.Devices/Aaru.Devices.csproj | 1 + Aaru.Devices/Device/ScsiCommands/MiniDisc.cs | 179 +++++++++++++++++++ Aaru.Devices/Enums.cs | 50 +++--- 5 files changed, 332 insertions(+), 39 deletions(-) create mode 100644 Aaru.Devices/Device/ScsiCommands/MiniDisc.cs diff --git a/.idea/.idea.Aaru/.idea/contentModel.xml b/.idea/.idea.Aaru/.idea/contentModel.xml index f99f46376..4255e8c45 100644 --- a/.idea/.idea.Aaru/.idea/contentModel.xml +++ b/.idea/.idea.Aaru/.idea/contentModel.xml @@ -3,8 +3,23 @@ - + + + + + + + + + + + + + + + + @@ -95,7 +110,13 @@ - + + + + + + + @@ -180,14 +201,26 @@ - + + + + + + + - + + + + + + + @@ -195,7 +228,13 @@ - + + + + + + + @@ -303,7 +342,13 @@ - + + + + + + + @@ -383,7 +428,13 @@ - + + + + + + + @@ -535,7 +586,13 @@ - + + + + + + + @@ -568,6 +625,7 @@ + @@ -612,7 +670,13 @@ - + + + + + + + @@ -624,7 +688,13 @@ - + + + + + + + @@ -822,7 +892,13 @@ - + + + + + + + @@ -839,7 +915,13 @@ - + + + + + + + @@ -1293,6 +1375,7 @@ + @@ -1318,7 +1401,13 @@ - + + + + + + + @@ -1880,7 +1969,13 @@ - + + + + + + + @@ -1907,13 +2002,25 @@ - + + + + + + + - + + + + + + + diff --git a/Aaru.CommonTypes b/Aaru.CommonTypes index f39d20551..fbb7a2c3c 160000 --- a/Aaru.CommonTypes +++ b/Aaru.CommonTypes @@ -1 +1 @@ -Subproject commit f39d205516caa98f88031482b3d053136a07ec79 +Subproject commit fbb7a2c3c0a7dbc97584d432e86551ebb26bf8fa diff --git a/Aaru.Devices/Aaru.Devices.csproj b/Aaru.Devices/Aaru.Devices.csproj index 27fc9ba7f..16235eaea 100644 --- a/Aaru.Devices/Aaru.Devices.csproj +++ b/Aaru.Devices/Aaru.Devices.csproj @@ -49,6 +49,7 @@ + diff --git a/Aaru.Devices/Device/ScsiCommands/MiniDisc.cs b/Aaru.Devices/Device/ScsiCommands/MiniDisc.cs new file mode 100644 index 000000000..c5f70672d --- /dev/null +++ b/Aaru.Devices/Device/ScsiCommands/MiniDisc.cs @@ -0,0 +1,179 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : MiniDisc.cs +// Author(s) : Natalia Portillo +// +// Component : MiniDisc vendor commands. +// +// --[ Description ] ---------------------------------------------------------- +// +// Contains vendor commands for MiniDisc drives. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2020 Natalia Portillo +// ****************************************************************************/ + +using Aaru.Console; + +namespace Aaru.Devices +{ + public partial class Device + { + public bool MiniDiscReadDataTOC(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) + { + ushort transferLength = 2336; + senseBuffer = new byte[32]; + byte[] cdb = new byte[10]; + + cdb[0] = (byte)ScsiCommands.MiniDiscReadDTOC; + + cdb[7] = (byte)((transferLength & 0xFF00) >> 8); + cdb[8] = (byte)(transferLength & 0xFF); + + buffer = new byte[transferLength]; + + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + out bool sense); + + Error = LastError != 0; + + AaruConsole.DebugWriteLine("SCSI Device", "MINIDISC READ DTOC took {0} ms.", duration); + + return sense; + } + + public bool MiniDiscReadUserTOC(out byte[] buffer, out byte[] senseBuffer, uint sector, uint timeout, + out double duration) + { + ushort transferLength = 2336; + senseBuffer = new byte[32]; + byte[] cdb = new byte[10]; + + cdb[0] = (byte)ScsiCommands.MiniDiscReadUTOC; + + cdb[2] = (byte)((sector & 0xFF000000) >> 24); + cdb[3] = (byte)((sector & 0xFF0000) >> 16); + cdb[4] = (byte)((sector & 0xFF00) >> 8); + cdb[5] = (byte)(sector & 0xFF); + cdb[7] = (byte)((transferLength & 0xFF00) >> 8); + cdb[8] = (byte)(transferLength & 0xFF); + + buffer = new byte[transferLength]; + + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + out bool sense); + + Error = LastError != 0; + + AaruConsole.DebugWriteLine("SCSI Device", "MINIDISC READ UTOC took {0} ms.", duration); + + return sense; + } + + public bool MiniDiscD5(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) + { + ushort transferLength = 4; + senseBuffer = new byte[32]; + byte[] cdb = new byte[10]; + + cdb[0] = (byte)ScsiCommands.MiniDiscD5; + + cdb[7] = (byte)((transferLength & 0xFF00) >> 8); + cdb[8] = (byte)(transferLength & 0xFF); + + buffer = new byte[transferLength]; + + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + out bool sense); + + Error = LastError != 0; + + AaruConsole.DebugWriteLine("SCSI Device", "MINIDISC command D5h took {0} ms.", duration); + + return sense; + } + + public bool MiniDiscStopPlaying(out byte[] buffer, out byte[] senseBuffer, uint sector, uint timeout, + out double duration) + { + senseBuffer = new byte[32]; + byte[] cdb = new byte[10]; + + cdb[0] = (byte)ScsiCommands.MiniDiscStopPlay; + + buffer = new byte[0]; + + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + out bool sense); + + Error = LastError != 0; + + AaruConsole.DebugWriteLine("SCSI Device", "MINIDISC STOP PLAY took {0} ms.", duration); + + return sense; + } + + public bool MiniDiscReadPosition(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) + { + ushort transferLength = 4; + senseBuffer = new byte[32]; + byte[] cdb = new byte[10]; + + cdb[0] = (byte)ScsiCommands.MiniDiscReadPosition; + + cdb[7] = (byte)((transferLength & 0xFF00) >> 8); + cdb[8] = (byte)(transferLength & 0xFF); + + buffer = new byte[transferLength]; + + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + out bool sense); + + Error = LastError != 0; + + AaruConsole.DebugWriteLine("SCSI Device", "MINIDISC READ POSITION took {0} ms.", duration); + + return sense; + } + + public bool MiniDiscGetType(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) + { + ushort transferLength = 8; + senseBuffer = new byte[32]; + byte[] cdb = new byte[10]; + + cdb[0] = (byte)ScsiCommands.MiniDiscGetType; + + cdb[7] = (byte)((transferLength & 0xFF00) >> 8); + cdb[8] = (byte)(transferLength & 0xFF); + + buffer = new byte[transferLength]; + + LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + out bool sense); + + Error = LastError != 0; + + AaruConsole.DebugWriteLine("SCSI Device", "MINIDISC GET TYPE took {0} ms.", duration); + + return sense; + } + } +} \ No newline at end of file diff --git a/Aaru.Devices/Enums.cs b/Aaru.Devices/Enums.cs index 24fdc86b8..4df7b395d 100644 --- a/Aaru.Devices/Enums.cs +++ b/Aaru.Devices/Enums.cs @@ -1816,8 +1816,25 @@ namespace Aaru.Devices KreonCommand = 0xFF, /// Kreon extract Security Sectors command start with this - KreonSsCommand = 0xAD + KreonSsCommand = 0xAD, #endregion Kreon vendor commands + + #region MiniDisc vendor commands + /// Gets some list of pointers only present on MD-DATA discs + MiniDiscReadDTOC = 0xD1, + /// Writes some list of pointers only present on MD-DATA discs + MiniDiscWriteDTOC = 0xD2, + /// Reads UTOC + MiniDiscReadUTOC = 0xD4, + /// Unknown, returns 4 empty bytes + MiniDiscD5 = 0xD5, + /// Stops playing audio + MiniDiscStopPlay = 0xD6, + /// Gets current audio playing position + MiniDiscReadPosition = 0xD7, + /// Gets some values that are identical amongst audio discs and data discs, different between them + MiniDiscGetType = 0xD8 + #endregion } #endregion SCSI Commands @@ -2650,31 +2667,20 @@ namespace Aaru.Devices [Flags] public enum MmcFlags : uint { - ResponsePresent = 1 << 0, Response136 = 1 << 1, ResponseCrc = 1 << 2, - ResponseBusy = 1 << 3, ResponseOpcode = 1 << 4, CommandMask = 3 << 5, - CommandAc = 0 << 5, CommandAdtc = 1 << 5, CommandBc = 2 << 5, - CommandBcr = 3 << 5, ResponseSpiS1 = 1 << 7, ResponseSpiS2 = 1 << 8, + ResponsePresent = 1 << 0, Response136 = 1 << 1, ResponseCrc = 1 << 2, + ResponseBusy = 1 << 3, ResponseOpcode = 1 << 4, CommandMask = 3 << 5, + CommandAc = 0 << 5, CommandAdtc = 1 << 5, CommandBc = 2 << 5, + CommandBcr = 3 << 5, ResponseSpiS1 = 1 << 7, ResponseSpiS2 = 1 << 8, ResponseSpiB4 = 1 << 9, ResponseSpiBusy = 1 << 10, ResponseNone = 0, ResponseR1 = ResponsePresent | ResponseCrc | ResponseOpcode, ResponseR1B = ResponsePresent | ResponseCrc | ResponseOpcode | ResponseBusy, ResponseR2 = ResponsePresent | Response136 | ResponseCrc, ResponseR3 = ResponsePresent, - ResponseR4 = ResponsePresent, - ResponseR5 = ResponsePresent | ResponseCrc | ResponseOpcode, - ResponseR6 = ResponsePresent | - ResponseCrc | - ResponseOpcode, - ResponseR7 = ResponsePresent | - ResponseCrc | - ResponseOpcode, ResponseSpiR1 = ResponseSpiS1, - ResponseSpiR1B = - ResponseSpiS1 | - ResponseSpiBusy, ResponseSpiR2 = ResponseSpiS1 | ResponseSpiS2, - ResponseSpiR3 = - ResponseSpiS1 | - ResponseSpiB4, ResponseSpiR4 = ResponseSpiS1 | ResponseSpiB4, - ResponseSpiR5 = - ResponseSpiS1 | - ResponseSpiS2, ResponseSpiR7 = ResponseSpiS1 | ResponseSpiB4 + ResponseR4 = ResponsePresent, ResponseR5 = ResponsePresent | ResponseCrc | ResponseOpcode, + ResponseR6 = ResponsePresent | ResponseCrc | ResponseOpcode, + ResponseR7 = ResponsePresent | ResponseCrc | ResponseOpcode, ResponseSpiR1 = ResponseSpiS1, + ResponseSpiR1B = ResponseSpiS1 | ResponseSpiBusy, ResponseSpiR2 = ResponseSpiS1 | ResponseSpiS2, + ResponseSpiR3 = ResponseSpiS1 | ResponseSpiB4, ResponseSpiR4 = ResponseSpiS1 | ResponseSpiB4, + ResponseSpiR5 = ResponseSpiS1 | ResponseSpiS2, ResponseSpiR7 = ResponseSpiS1 | ResponseSpiB4 } [Flags]