2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2015-10-12 06:39:31 +01:00
|
|
|
// The Disc Image Chef
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : Structs.cs
|
2016-07-28 18:13:49 +01:00
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2015-10-12 06:39:31 +01:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Component : Linux direct device access.
|
2015-10-12 06:39:31 +01:00
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Contains structures necessary for directly interfacing devices under
|
|
|
|
|
// Linux.
|
2015-10-12 06:39:31 +01:00
|
|
|
//
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// 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
|
2015-10-12 06:39:31 +01:00
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// 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.
|
2015-10-12 06:39:31 +01:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// 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/>.
|
2015-10-12 06:39:31 +01:00
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2015-10-12 06:39:31 +01:00
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
using System;
|
2015-10-05 21:20:25 +01:00
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
namespace DiscImageChef.Devices.Linux
|
|
|
|
|
{
|
2015-10-06 21:18:02 +01:00
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
struct sg_io_hdr_t
|
2015-10-05 21:20:25 +01:00
|
|
|
{
|
2015-10-06 21:18:02 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Always 'S' for SG v3
|
|
|
|
|
/// </summary>
|
2017-12-19 20:33:03 +00:00
|
|
|
public int interface_id; /* [i] 'S' (required) */
|
|
|
|
|
public ScsiIoctlDirection dxfer_direction; /* [i] */
|
|
|
|
|
public byte cmd_len; /* [i] */
|
|
|
|
|
public byte mx_sb_len; /* [i] */
|
2015-10-06 21:18:02 +01:00
|
|
|
public ushort iovec_count; /* [i] */
|
2017-12-19 20:33:03 +00:00
|
|
|
public uint dxfer_len; /* [i] */
|
|
|
|
|
public IntPtr dxferp; /* [i], [*io] */
|
|
|
|
|
public IntPtr cmdp; /* [i], [*i] */
|
|
|
|
|
public IntPtr sbp; /* [i], [*o] */
|
|
|
|
|
public uint timeout; /* [i] unit: millisecs */
|
|
|
|
|
public uint flags; /* [i] */
|
|
|
|
|
public int pack_id; /* [i->o] */
|
|
|
|
|
public IntPtr usr_ptr; /* [i->o] */
|
|
|
|
|
public byte status; /* [o] */
|
|
|
|
|
public byte masked_status; /* [o] */
|
|
|
|
|
public byte msg_status; /* [o] */
|
|
|
|
|
public byte sb_len_wr; /* [o] */
|
2015-10-06 21:18:02 +01:00
|
|
|
public ushort host_status; /* [o] */
|
2017-12-19 20:33:03 +00:00
|
|
|
public ushort driver_status; /* [o] */
|
|
|
|
|
public int resid; /* [o] */
|
|
|
|
|
public uint duration; /* [o] */
|
|
|
|
|
public SgInfo info; /* [o] */
|
2015-10-05 21:20:25 +01:00
|
|
|
}
|
2016-10-22 22:58:01 +01:00
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
struct mmc_ioc_cmd
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Implies direction of data. true = write, false = read
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool write_flag;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Application-specific command. true = precede with CMD55
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool is_ascmd;
|
|
|
|
|
public uint opcode;
|
|
|
|
|
public uint arg;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CMD response
|
|
|
|
|
/// </summary>
|
2017-12-19 20:33:03 +00:00
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public uint[] response;
|
2016-10-22 22:58:01 +01:00
|
|
|
public MmcFlags flags;
|
|
|
|
|
public uint blksz;
|
|
|
|
|
public uint blocks;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sleep at least <see cref="postsleep_min_us"/> useconds, and at most
|
|
|
|
|
/// <see cref="postsleep_max_us"/> useconds *after* issuing command.Needed for
|
|
|
|
|
/// some read commands for which cards have no other way of indicating
|
|
|
|
|
/// they're ready for the next command (i.e. there is no equivalent of
|
|
|
|
|
/// a "busy" indicator for read operations).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint postsleep_min_us;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sleep at least <see cref="postsleep_min_us"/> useconds, and at most
|
|
|
|
|
/// <see cref="postsleep_max_us"/> useconds *after* issuing command.Needed for
|
|
|
|
|
/// some read commands for which cards have no other way of indicating
|
|
|
|
|
/// they're ready for the next command (i.e. there is no equivalent of
|
|
|
|
|
/// a "busy" indicator for read operations).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint postsleep_max_us;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Override driver-computed timeouts.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint data_timeout_ns;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Override driver-computed timeouts.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint cmd_timeout_ms;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// For 64-bit machines <see cref="data_ptr"/> , wants to
|
|
|
|
|
/// be 8-byte aligned.Make sure this struct is the same size when
|
|
|
|
|
/// built for 32-bit.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint __pad;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// DAT buffer
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ulong data_ptr;
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|