Files
Aaru/Aaru.Devices/Remote/Structs.cs

871 lines
30 KiB
C#
Raw Normal View History

2020-03-11 21:56:55 +00:00
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : Structs.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Aaru Remote.
//
// --[ Description ] ----------------------------------------------------------
//
// Structures for the Aaru Remote protocol.
//
// --[ 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 <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
2020-12-31 23:08:23 +00:00
// Copyright © 2011-2021 Natalia Portillo
2020-03-11 21:56:55 +00:00
// ****************************************************************************/
using System.Runtime.InteropServices;
2020-02-27 00:33:26 +00:00
using Aaru.CommonTypes.Enums;
using Aaru.Decoders.ATA;
2021-08-17 13:56:05 +01:00
// ReSharper disable MemberCanBeInternal
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable IdentifierTypo
2020-02-27 00:33:26 +00:00
namespace Aaru.Devices.Remote
{
2021-08-17 13:56:05 +01:00
/// <summary>
/// Header for any Aaru remote packet
/// </summary>
2019-10-12 22:34:27 +01:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketHeader
{
2021-08-17 13:56:05 +01:00
/// <summary>
/// Unique Aaru packet identifier (primary)
/// </summary>
2019-10-26 15:34:00 +01:00
public uint remote_id;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Unique Aaru packet identifier (secondary)
/// </summary>
2019-10-26 15:34:00 +01:00
public uint packet_id;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Packet length
/// </summary>
2020-02-29 18:03:35 +00:00
public uint len;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Packet version
/// </summary>
2020-02-29 18:03:35 +00:00
public byte version;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Unique Aaru packet type identifier
/// </summary>
2020-02-27 22:42:21 +00:00
public AaruPacketType packetType;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Spare for expansion (or alignment)
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
2019-10-12 22:34:27 +01:00
public readonly byte[] spare;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Hello packet, identifies a remote initiator with a responder
/// </summary>
2019-10-12 22:34:27 +01:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketHello
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Application name
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string application;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Application version
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
public string version;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Maximum supported protocol version
/// </summary>
public byte maxProtocol;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Spare for expansion (or alignment)
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
2019-10-12 22:34:27 +01:00
public readonly byte[] spare;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Operating system name
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string sysname;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Operating system version / release
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string release;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Operating system machine / architecture
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string machine;
}
2019-10-12 22:34:27 +01:00
2021-08-17 13:56:05 +01:00
/// <summary>
/// Request a list of device
/// </summary>
2019-10-12 22:34:27 +01:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketCommandListDevices
2019-10-12 22:34:27 +01:00
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
2019-10-12 22:34:27 +01:00
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Returns the requested list of devices
/// </summary>
2019-10-12 22:34:27 +01:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public readonly struct AaruPacketResponseListDevices
2019-10-12 22:34:27 +01:00
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public readonly AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// How many device descriptors follows this structure in the packet
/// </summary>
2020-02-29 18:03:35 +00:00
public readonly ushort devices;
2019-10-12 22:34:27 +01:00
}
2019-10-13 20:54:10 +01:00
2021-08-17 13:56:05 +01:00
/// <summary>
/// Sends a request or returns a response that requires no intervention or further processing
/// </summary>
2019-10-13 20:54:10 +01:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketNop
2019-10-13 20:54:10 +01:00
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Reason code
/// </summary>
2020-02-29 18:03:35 +00:00
public AaruNopReason reasonCode;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Spare for expansion (or alignment)
/// </summary>
2019-10-13 20:54:10 +01:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public readonly byte[] spare;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Reason name
/// </summary>
2019-10-13 20:54:10 +01:00
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string reason;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Operating system error number
/// </summary>
2019-10-13 21:19:21 +01:00
public int errno;
2019-10-13 20:54:10 +01:00
}
2019-10-13 21:59:19 +01:00
2021-08-17 13:56:05 +01:00
/// <summary>
/// Requests to open a device
/// </summary>
2019-10-13 21:59:19 +01:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketCommandOpenDevice
2019-10-13 21:59:19 +01:00
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Device path
/// </summary>
2019-10-13 21:59:19 +01:00
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
public string device_path;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Requests remote to send a command to a SCSI device. This header is followed by the CDB and after it comes the buffer.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketCmdScsi
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Length in bytes of the CDB that follows this structure
/// </summary>
2020-02-29 18:03:35 +00:00
public uint cdb_len;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Length in bytes of the buffer that follows the CDB
/// </summary>
2020-02-29 18:03:35 +00:00
public uint buf_len;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Direction of SCSI data transfer
/// </summary>
2020-02-29 18:03:35 +00:00
public int direction;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Timeout waiting for device to respond to command
/// </summary>
2020-02-29 18:03:35 +00:00
public uint timeout;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Returns the response from a command sent to a SCSI device. This structure is followed by the buffer containing the REQUEST SENSE response and this is followed by the data buffer.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketResScsi
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Size the REQUEST SENSE buffer that follows this structure
/// </summary>
2020-02-29 18:03:35 +00:00
public uint sense_len;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Length in bytes of the data buffer that follows the sense buffer
/// </summary>
2020-02-29 18:03:35 +00:00
public uint buf_len;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Time in milliseconds it took for the device to execute the command
/// </summary>
2020-02-29 18:03:35 +00:00
public uint duration;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Set to anything different of zero if there was a SENSE returned
/// </summary>
2020-02-29 18:03:35 +00:00
public uint sense;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Set to the remote operating system error number
/// </summary>
2020-02-29 18:03:35 +00:00
public uint error_no;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Requests remote to send a command to an ATA device using the CHS command set. This header is followed by the data buffer.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketCmdAtaChs
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Length in bytes of the data buffer
/// </summary>
2020-02-29 18:03:35 +00:00
public uint buf_len;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Registers to set in the ATA device
/// </summary>
2020-02-29 18:03:35 +00:00
public AtaRegistersChs registers;
2021-08-17 13:56:05 +01:00
/// <summary>
/// ATA protocol code
/// </summary>
2020-02-29 18:03:35 +00:00
public byte protocol;
2021-08-17 13:56:05 +01:00
/// <summary>
/// ATA transfer register indicator
/// </summary>
2020-02-29 18:03:35 +00:00
public byte transferRegister;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Set to <c>true</c> to transfer blocks, <c>false</c> to transfer bytes
/// </summary>
2020-02-29 18:03:35 +00:00
[MarshalAs(UnmanagedType.U1)]
public bool transferBlocks;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Spare for expansion (or alignment)
/// </summary>
public byte spare;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Timeout waiting for device to respond to command
/// </summary>
public uint timeout;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Returns the response from a command sent to an ATA device using the CHS command set. This structure is followed by the data buffer.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketResAtaChs
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-29 18:03:35 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Length in bytes of the data buffer
/// </summary>
2020-02-29 18:03:35 +00:00
public uint buf_len;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Registers as set back by the ATA device
/// </summary>
public AtaErrorRegistersChs registers;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Time in milliseconds it took for the device to execute the command
/// </summary>
2020-02-29 18:03:35 +00:00
public uint duration;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Set to anything different of zero if the device set an error condition
/// </summary>
2020-02-29 18:03:35 +00:00
public uint sense;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Set to the remote operating system error number
/// </summary>
2020-02-29 18:03:35 +00:00
public uint error_no;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Requests remote to send a command to an ATA device using the 28-bit command set. This header is followed by the data buffer.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketCmdAtaLba28
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-29 18:03:35 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Length in bytes of the data buffer
/// </summary>
2020-02-29 18:03:35 +00:00
public uint buf_len;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Registers to set in the ATA device
/// </summary>
public AtaRegistersLba28 registers;
2021-08-17 13:56:05 +01:00
/// <summary>
/// ATA protocol code
/// </summary>
2020-02-29 18:03:35 +00:00
public byte protocol;
2021-08-17 13:56:05 +01:00
/// <summary>
/// ATA transfer register indicator
/// </summary>
2020-02-29 18:03:35 +00:00
public byte transferRegister;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Set to <c>true</c> to transfer blocks, <c>false</c> to transfer bytes
/// </summary>
2020-02-29 18:03:35 +00:00
[MarshalAs(UnmanagedType.U1)]
public bool transferBlocks;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Spare for expansion (or alignment)
/// </summary>
public byte spare;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Timeout waiting for device to respond to command
/// </summary>
public uint timeout;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Returns the response from a command sent to an ATA device using the 28-bit LBA command set. This structure is followed by the data buffer.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketResAtaLba28
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-29 18:03:35 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Length in bytes of the data buffer
/// </summary>
2020-02-29 18:03:35 +00:00
public uint buf_len;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Registers as set back by the ATA device
/// </summary>
public AtaErrorRegistersLba28 registers;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Time in milliseconds it took for the device to execute the command
/// </summary>
2020-02-29 18:03:35 +00:00
public uint duration;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Set to anything different of zero if the device set an error condition
/// </summary>
2020-02-29 18:03:35 +00:00
public uint sense;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Set to the remote operating system error number
/// </summary>
2020-02-29 18:03:35 +00:00
public uint error_no;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Requests remote to send a command to an ATA device using the 48-bit command set. This header is followed by the data buffer.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketCmdAtaLba48
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-29 18:03:35 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Length in bytes of the data buffer
/// </summary>
2020-02-29 18:03:35 +00:00
public uint buf_len;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Registers to set in the ATA device
/// </summary>
public AtaRegistersLba48 registers;
2021-08-17 13:56:05 +01:00
/// <summary>
/// ATA protocol code
/// </summary>
2020-02-29 18:03:35 +00:00
public byte protocol;
2021-08-17 13:56:05 +01:00
/// <summary>
/// ATA transfer register indicator
/// </summary>
2020-02-29 18:03:35 +00:00
public byte transferRegister;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Set to <c>true</c> to transfer blocks, <c>false</c> to transfer bytes
/// </summary>
2020-02-29 18:03:35 +00:00
[MarshalAs(UnmanagedType.U1)]
public bool transferBlocks;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Spare for expansion (or alignment)
/// </summary>
public byte spare;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Timeout waiting for device to respond to command
/// </summary>
public uint timeout;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Returns the response from a command sent to an ATA device using the 48-bit LBA command set. This structure is followed by the data buffer.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketResAtaLba48
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-29 18:03:35 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Length in bytes of the data buffer
/// </summary>
2020-02-29 18:03:35 +00:00
public uint buf_len;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Registers as set back by the ATA device
/// </summary>
public AtaErrorRegistersLba48 registers;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Time in milliseconds it took for the device to execute the command
/// </summary>
2020-02-29 18:03:35 +00:00
public uint duration;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Set to anything different of zero if the device set an error condition
/// </summary>
2020-02-29 18:03:35 +00:00
public uint sense;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Set to the remote operating system error number
/// </summary>
2020-02-29 18:03:35 +00:00
public uint error_no;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// SecureDigital or MultiMediaCard command description
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AaruCmdSdhci
{
2021-08-17 13:56:05 +01:00
/// <summary>
/// Command
/// </summary>
public MmcCommands command;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Set to <c>true</c> if the command writes to the device, <c>false</c> otherwise
/// </summary>
2020-02-29 18:03:35 +00:00
[MarshalAs(UnmanagedType.U1)]
public bool write;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Set to <c>true</c> if it is an application command, <c>false</c> otherwise
/// </summary>
2020-02-29 18:03:35 +00:00
[MarshalAs(UnmanagedType.U1)]
public bool application;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Flags
/// </summary>
public MmcFlags flags;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Argument
/// </summary>
2020-02-29 18:03:35 +00:00
public uint argument;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Block size
/// </summary>
2020-02-29 18:03:35 +00:00
public uint block_size;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Number of blocks to transfer
/// </summary>
2020-02-29 18:03:35 +00:00
public uint blocks;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Length in bytes of the data buffer
/// </summary>
2020-02-29 18:03:35 +00:00
public uint buf_len;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Timeout waiting for device to respond to command
/// </summary>
2020-02-29 18:03:35 +00:00
public uint timeout;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Requests remote to send a command to a SecureDigital or MultiMediaCard device attached using a SDHCI controller. This structure is followed by the data buffer.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AaruPacketCmdSdhci
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// SecureDigital or MultiMediaCard command description
/// </summary>
public AaruCmdSdhci command;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Returns the response from a command sent to a SecureDigital or MultiMediaCard device attached to a SDHCI controller. This structure is followed by the data buffer.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AaruResSdhci
{
2021-08-17 13:56:05 +01:00
/// <summary>
/// Length in bytes of the data buffer
/// </summary>
public uint buf_len;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Response registers
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public uint[] response;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Time in milliseconds it took for the device to execute the command
/// </summary>
public uint duration;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Set to anything different of zero if the device set an error condition
/// </summary>
public uint sense;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Set to the remote operating system error number
/// </summary>
2019-10-17 22:15:01 +01:00
public uint error_no;
}
2019-10-14 01:02:25 +01:00
2021-08-17 13:56:05 +01:00
/// <summary>
/// Returns the response from a command sent to a SecureDigital or MultiMediaCard device attached to a SDHCI controller. This structure is followed by the data buffer.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AaruPacketResSdhci
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Response
/// </summary>
public AaruResSdhci res;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Requests the Aaru device type for the opened device
/// </summary>
2019-10-14 01:02:25 +01:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketCmdGetDeviceType
2019-10-14 01:02:25 +01:00
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
2019-10-14 01:02:25 +01:00
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Returns the Aaru device type for the opened device
/// </summary>
2019-10-14 01:02:25 +01:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketResGetDeviceType
2019-10-14 01:02:25 +01:00
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Aaru's device type
/// </summary>
2020-02-29 18:03:35 +00:00
public DeviceType device_type;
2019-10-14 01:02:25 +01:00
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Requests the registers of a SecureDigital or MultiMediaCard attached to an SDHCI controller
/// </summary>
2019-10-26 17:14:58 +01:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketCmdGetSdhciRegisters
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Returns the registers of a SecureDigital or MultiMediaCard attached to an SDHCI controller
/// </summary>
2019-10-26 17:14:58 +01:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketResGetSdhciRegisters
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// <c>true</c> if the device is attached to an SDHCI controller and the rest of the fields on this packet are valid, <c>false</c> otherwise
/// </summary>
2020-02-29 18:03:35 +00:00
[MarshalAs(UnmanagedType.U1)]
public bool isSdhci;
2021-08-17 13:56:05 +01:00
/// <summary>
/// CSD registers
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] csd;
2021-08-17 13:56:05 +01:00
/// <summary>
/// CID registers
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] cid;
2021-08-17 13:56:05 +01:00
/// <summary>
/// OCR registers
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] ocr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// SCR registers
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] scr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Length of the CSD registers
/// </summary>
public uint csd_len;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Length of the CID registers
/// </summary>
public uint cid_len;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Length of the OCR registers
/// </summary>
public uint ocr_len;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Length of the SCR registers
/// </summary>
public uint scr_len;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Requests information about the USB connection of the opened device
/// </summary>
2019-10-26 17:14:58 +01:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketCmdGetUsbData
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Returns information about the USB connection of the opened device
/// </summary>
2019-10-26 17:14:58 +01:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketResGetUsbData
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// <c>true</c> if the device is attached using USB and the rest of the fields on this packet are valid, <c>false</c> otherwise
/// </summary>
2020-02-29 18:03:35 +00:00
[MarshalAs(UnmanagedType.U1)]
public bool isUsb;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Length of the descriptors
/// </summary>
public ushort descLen;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Raw USB descriptors
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 65536)]
public byte[] descriptors;
2021-08-17 13:56:05 +01:00
/// <summary>
/// USB vendor ID
/// </summary>
public ushort idVendor;
2021-08-17 13:56:05 +01:00
/// <summary>
/// USB product ID
/// </summary>
public ushort idProduct;
2021-08-17 13:56:05 +01:00
/// <summary>
/// USB manufacturer string
/// </summary>
2019-10-18 23:41:58 +01:00
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string manufacturer;
2021-08-17 13:56:05 +01:00
/// <summary>
/// USB product string
/// </summary>
2019-10-18 23:41:58 +01:00
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string product;
2021-08-17 13:56:05 +01:00
/// <summary>
/// USB serial number string
/// </summary>
2019-10-18 23:41:58 +01:00
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string serial;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Requests information about the FireWire connection of the opened device
/// </summary>
2019-10-26 17:14:58 +01:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketCmdGetFireWireData
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Returns information about the FireWire connection of the opened device
/// </summary>
2019-10-26 17:14:58 +01:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketResGetFireWireData
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// <c>true</c> if the device is attached using FireWire and the rest of the fields on this packet are valid, <c>false</c> otherwise
/// </summary>
2020-02-29 18:03:35 +00:00
[MarshalAs(UnmanagedType.U1)]
public bool isFireWire;
2021-08-17 13:56:05 +01:00
/// <summary>
/// FireWire model ID
/// </summary>
2020-02-29 18:03:35 +00:00
public uint idModel;
2021-08-17 13:56:05 +01:00
/// <summary>
/// FireWire vendor ID
/// </summary>
2020-02-29 18:03:35 +00:00
public uint idVendor;
2021-08-17 13:56:05 +01:00
/// <summary>
/// FireWire's device GUID
/// </summary>
public ulong guid;
2021-08-17 13:56:05 +01:00
/// <summary>
/// FireWire vendor string
/// </summary>
2019-10-18 23:41:58 +01:00
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string vendor;
2021-08-17 13:56:05 +01:00
/// <summary>
/// FireWire model string
/// </summary>
2019-10-18 23:41:58 +01:00
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string model;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Requests information about the PCMCIA or CardBus connection of the opened device
/// </summary>
2019-10-26 17:14:58 +01:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketCmdGetPcmciaData
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Returns information about the PCMCIA or CardBus connection of the opened device
/// </summary>
2019-10-26 17:14:58 +01:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketResGetPcmciaData
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// <c>true</c> if the device is a PCMCIA or CardBus device and the rest of the fields on this packet are valid, <c>false</c> otherwise
/// </summary>
2020-02-29 18:03:35 +00:00
[MarshalAs(UnmanagedType.U1)]
public bool isPcmcia;
2021-08-17 13:56:05 +01:00
/// <summary>
/// CIS buffer length
/// </summary>
public ushort cis_len;
2021-08-17 13:56:05 +01:00
/// <summary>
/// CIS buffer
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 65536)]
public byte[] cis;
}
2019-10-26 15:47:36 +01:00
2021-08-17 13:56:05 +01:00
/// <summary>
/// Requests to close the currently opened device
/// </summary>
2019-10-26 15:47:36 +01:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketCmdClose
2019-10-26 15:47:36 +01:00
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
2019-10-26 15:47:36 +01:00
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Requests to know if the remote is running with administrative (aka root) privileges
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketCmdAmIRoot
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Returns if the remote is running with administrative (aka root) privileges
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2020-02-27 22:42:21 +00:00
public struct AaruPacketResAmIRoot
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
2020-02-27 22:42:21 +00:00
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Set to any value different of 0 to indicate the remote is running with administrative (aka root) privileges
/// </summary>
2020-02-29 18:03:35 +00:00
public uint am_i_root;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Initiates a multiple command block with the SDHCI controller the SecureDigital or MultiMediaCard is attached
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AaruPacketMultiCmdSdhci
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// How many commands to queue
/// </summary>
public ulong cmd_count;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Closes and then re-opens the same device
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AaruPacketCmdReOpen
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
public AaruPacketHeader hdr;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Reads data using operating system buffers
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AaruPacketCmdOsRead
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Device offset where to read
/// </summary>
public ulong offset;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Number of bytes to read
/// </summary>
public uint length;
}
2021-08-17 13:56:05 +01:00
/// <summary>
/// Returns data read using operating system buffers. This structure is followed by the data buffer.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AaruPacketResOsRead
{
2021-08-17 13:56:05 +01:00
/// <summary>Packet header</summary>
public AaruPacketHeader hdr;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Set to the remote operating system error number
/// </summary>
public int errno;
2021-08-17 13:56:05 +01:00
/// <summary>
/// Time in milliseconds it took for the device to execute the command
/// </summary>
public uint duration;
}
}