mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Solved FreeBSD SCSI structure alignment (now works).
This commit is contained in:
@@ -65,6 +65,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
IntPtr ccbPtr = cam_getccb(dev);
|
IntPtr ccbPtr = cam_getccb(dev);
|
||||||
|
IntPtr cdbPtr = IntPtr.Zero;
|
||||||
|
|
||||||
if(ccbPtr.ToInt64() == 0)
|
if(ccbPtr.ToInt64() == 0)
|
||||||
{
|
{
|
||||||
@@ -85,17 +86,18 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
csio.cdb_len = (byte)cdb.Length;
|
csio.cdb_len = (byte)cdb.Length;
|
||||||
// TODO: Create enum?
|
// TODO: Create enum?
|
||||||
csio.tag_action = 0x20;
|
csio.tag_action = 0x20;
|
||||||
csio.cdb_io = new cdb_t64();
|
csio.cdb_bytes = new byte[CAM_MAX_CDBLEN];
|
||||||
if(cdb.Length <= CAM_MAX_CDBLEN)
|
if(cdb.Length <= CAM_MAX_CDBLEN)
|
||||||
{
|
Array.Copy(cdb, 0, csio.cdb_bytes, 0, cdb.Length);
|
||||||
csio.cdb_io.cdb_bytes = new byte[CAM_MAX_CDBLEN];
|
|
||||||
Array.Copy(cdb, 0, csio.cdb_io.cdb_bytes, 0, cdb.Length);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
csio.cdb_io.cdb_ptr = Marshal.AllocHGlobal(cdb.Length).ToInt64();
|
cdbPtr = Marshal.AllocHGlobal(cdb.Length);
|
||||||
|
byte[] cdbPtrBytes = BitConverter.GetBytes(cdbPtr.ToInt64());
|
||||||
|
Array.Copy(cdbPtrBytes, 0, csio.cdb_bytes, 0, IntPtr.Size);
|
||||||
csio.ccb_h.flags |= ccb_flags.CAM_CDB_POINTER;
|
csio.ccb_h.flags |= ccb_flags.CAM_CDB_POINTER;
|
||||||
}
|
}
|
||||||
|
csio.ccb_h.flags |= ccb_flags.CAM_DEV_QFRZDIS;
|
||||||
|
|
||||||
Marshal.Copy(buffer, 0, csio.data_ptr, buffer.Length);
|
Marshal.Copy(buffer, 0, csio.data_ptr, buffer.Length);
|
||||||
Marshal.StructureToPtr(csio, ccbPtr, false);
|
Marshal.StructureToPtr(csio, ccbPtr, false);
|
||||||
|
|
||||||
@@ -139,11 +141,13 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
|
|
||||||
Marshal.Copy(csio.data_ptr, buffer, 0, buffer.Length);
|
Marshal.Copy(csio.data_ptr, buffer, 0, buffer.Length);
|
||||||
if(csio.ccb_h.flags.HasFlag(ccb_flags.CAM_CDB_POINTER))
|
if(csio.ccb_h.flags.HasFlag(ccb_flags.CAM_CDB_POINTER))
|
||||||
Marshal.Copy(new IntPtr(csio.cdb_io.cdb_ptr), cdb, 0, cdb.Length);
|
Marshal.Copy(new IntPtr(BitConverter.ToInt64(csio.cdb_bytes, 0)), cdb, 0, cdb.Length);
|
||||||
else
|
else
|
||||||
Array.Copy(csio.cdb_io.cdb_bytes, 0, cdb, 0, cdb.Length);
|
Array.Copy(csio.cdb_bytes, 0, cdb, 0, cdb.Length);
|
||||||
duration = (end - start).TotalMilliseconds;
|
duration = (end - start).TotalMilliseconds;
|
||||||
|
|
||||||
|
if(csio.ccb_h.flags.HasFlag(ccb_flags.CAM_CDB_POINTER))
|
||||||
|
Marshal.FreeHGlobal(cdbPtr);
|
||||||
Marshal.FreeHGlobal(csio.data_ptr);
|
Marshal.FreeHGlobal(csio.data_ptr);
|
||||||
cam_freeccb(ccbPtr);
|
cam_freeccb(ccbPtr);
|
||||||
|
|
||||||
@@ -172,6 +176,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
IntPtr ccbPtr = cam_getccb(dev);
|
IntPtr ccbPtr = cam_getccb(dev);
|
||||||
|
IntPtr cdbPtr = IntPtr.Zero;
|
||||||
|
|
||||||
if(ccbPtr.ToInt32() == 0)
|
if(ccbPtr.ToInt32() == 0)
|
||||||
{
|
{
|
||||||
@@ -192,17 +197,18 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
csio.cdb_len = (byte)cdb.Length;
|
csio.cdb_len = (byte)cdb.Length;
|
||||||
// TODO: Create enum?
|
// TODO: Create enum?
|
||||||
csio.tag_action = 0x20;
|
csio.tag_action = 0x20;
|
||||||
csio.cdb_io = new cdb_t();
|
csio.cdb_bytes = new byte[CAM_MAX_CDBLEN];
|
||||||
if(cdb.Length <= CAM_MAX_CDBLEN)
|
if(cdb.Length <= CAM_MAX_CDBLEN)
|
||||||
{
|
Array.Copy(cdb, 0, csio.cdb_bytes, 0, cdb.Length);
|
||||||
csio.cdb_io.cdb_bytes = new byte[CAM_MAX_CDBLEN];
|
|
||||||
Array.Copy(cdb, 0, csio.cdb_io.cdb_bytes, 0, cdb.Length);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
csio.cdb_io.cdb_ptr = Marshal.AllocHGlobal(cdb.Length).ToInt32();
|
cdbPtr = Marshal.AllocHGlobal(cdb.Length);
|
||||||
|
byte[] cdbPtrBytes = BitConverter.GetBytes(cdbPtr.ToInt32());
|
||||||
|
Array.Copy(cdbPtrBytes, 0, csio.cdb_bytes, 0, IntPtr.Size);
|
||||||
csio.ccb_h.flags |= ccb_flags.CAM_CDB_POINTER;
|
csio.ccb_h.flags |= ccb_flags.CAM_CDB_POINTER;
|
||||||
}
|
}
|
||||||
|
csio.ccb_h.flags |= ccb_flags.CAM_DEV_QFRZDIS;
|
||||||
|
|
||||||
Marshal.Copy(buffer, 0, csio.data_ptr, buffer.Length);
|
Marshal.Copy(buffer, 0, csio.data_ptr, buffer.Length);
|
||||||
Marshal.StructureToPtr(csio, ccbPtr, false);
|
Marshal.StructureToPtr(csio, ccbPtr, false);
|
||||||
|
|
||||||
@@ -246,11 +252,13 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
|
|
||||||
Marshal.Copy(csio.data_ptr, buffer, 0, buffer.Length);
|
Marshal.Copy(csio.data_ptr, buffer, 0, buffer.Length);
|
||||||
if(csio.ccb_h.flags.HasFlag(ccb_flags.CAM_CDB_POINTER))
|
if(csio.ccb_h.flags.HasFlag(ccb_flags.CAM_CDB_POINTER))
|
||||||
Marshal.Copy(new IntPtr(csio.cdb_io.cdb_ptr), cdb, 0, cdb.Length);
|
Marshal.Copy(new IntPtr(BitConverter.ToInt32(csio.cdb_bytes, 0)), cdb, 0, cdb.Length);
|
||||||
else
|
else
|
||||||
Array.Copy(csio.cdb_io.cdb_bytes, 0, cdb, 0, cdb.Length);
|
Array.Copy(csio.cdb_bytes, 0, cdb, 0, cdb.Length);
|
||||||
duration = (end - start).TotalMilliseconds;
|
duration = (end - start).TotalMilliseconds;
|
||||||
|
|
||||||
|
if(csio.ccb_h.flags.HasFlag(ccb_flags.CAM_CDB_POINTER))
|
||||||
|
Marshal.FreeHGlobal(cdbPtr);
|
||||||
Marshal.FreeHGlobal(csio.data_ptr);
|
Marshal.FreeHGlobal(csio.data_ptr);
|
||||||
cam_freeccb(ccbPtr);
|
cam_freeccb(ccbPtr);
|
||||||
|
|
||||||
|
|||||||
@@ -182,19 +182,6 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = SSD_FULL_SIZE - 1)] public byte[] sense_buf;
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = SSD_FULL_SIZE - 1)] public byte[] sense_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cdb_t
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Pointer to the CDB bytes to send
|
|
||||||
/// </summary>
|
|
||||||
public int cdb_ptr;
|
|
||||||
/// <summary>
|
|
||||||
/// Area for the CDB send
|
|
||||||
/// </summary>
|
|
||||||
const int IOCDBLEN = 16;
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = IOCDBLEN)] public byte[] cdb_bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// SCSI I/O Request CCB used for the XPT_SCSI_IO and XPT_CONT_TARGET_IO function codes.
|
/// SCSI I/O Request CCB used for the XPT_SCSI_IO and XPT_CONT_TARGET_IO function codes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -224,8 +211,11 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
public sbyte sense_resid;
|
public sbyte sense_resid;
|
||||||
/// <summary>Transfer residual length: 2's comp</summary>
|
/// <summary>Transfer residual length: 2's comp</summary>
|
||||||
public int resid;
|
public int resid;
|
||||||
/// <summary>Union for CDB bytes/pointer</summary>
|
/// <summary>
|
||||||
public cdb_t cdb_io;
|
/// Area for the CDB send, or pointer to the CDB bytes to send
|
||||||
|
/// </summary>
|
||||||
|
const int IOCDBLEN = 16;
|
||||||
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = IOCDBLEN)] public byte[] cdb_bytes;
|
||||||
/// <summary>Pointer to the message buffer</summary>
|
/// <summary>Pointer to the message buffer</summary>
|
||||||
public IntPtr msg_ptr;
|
public IntPtr msg_ptr;
|
||||||
/// <summary>Number of bytes for the Message</summary>
|
/// <summary>Number of bytes for the Message</summary>
|
||||||
@@ -238,19 +228,6 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
public uint init_id;
|
public uint init_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cdb_t64
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Pointer to the CDB bytes to send
|
|
||||||
/// </summary>
|
|
||||||
public long cdb_ptr;
|
|
||||||
/// <summary>
|
|
||||||
/// Area for the CDB send
|
|
||||||
/// </summary>
|
|
||||||
const int IOCDBLEN = 16;
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = IOCDBLEN)] public byte[] cdb_bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// SCSI I/O Request CCB used for the XPT_SCSI_IO and XPT_CONT_TARGET_IO function codes.
|
/// SCSI I/O Request CCB used for the XPT_SCSI_IO and XPT_CONT_TARGET_IO function codes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -280,8 +257,12 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
public sbyte sense_resid;
|
public sbyte sense_resid;
|
||||||
/// <summary>Transfer residual length: 2's comp</summary>
|
/// <summary>Transfer residual length: 2's comp</summary>
|
||||||
public int resid;
|
public int resid;
|
||||||
/// <summary>Union for CDB bytes/pointer</summary>
|
public uint alignment;
|
||||||
public cdb_t64 cdb_io;
|
/// <summary>
|
||||||
|
/// Area for the CDB send, or pointer to the CDB bytes to send
|
||||||
|
/// </summary>
|
||||||
|
const int IOCDBLEN = 16;
|
||||||
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = IOCDBLEN)] public byte[] cdb_bytes;
|
||||||
/// <summary>Pointer to the message buffer</summary>
|
/// <summary>Pointer to the message buffer</summary>
|
||||||
public IntPtr msg_ptr;
|
public IntPtr msg_ptr;
|
||||||
/// <summary>Number of bytes for the Message</summary>
|
/// <summary>Number of bytes for the Message</summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user