mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Code cleanup.
This commit is contained in:
@@ -60,12 +60,13 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
/// <c>True</c> if SCSI error returned non-OK status and <paramref name="senseBuffer" /> contains SCSI
|
||||
/// sense
|
||||
/// </param>
|
||||
internal static int SendScsiCommand64(IntPtr dev, byte[] cdb, ref byte[] buffer, out byte[] senseBuffer,
|
||||
uint timeout, CcbFlags direction, out double duration, out bool sense)
|
||||
internal static int SendScsiCommand64(IntPtr dev, byte[] cdb, ref byte[] buffer,
|
||||
out byte[] senseBuffer,
|
||||
uint timeout, CcbFlags direction, out double duration, out bool sense)
|
||||
{
|
||||
senseBuffer = null;
|
||||
duration = 0;
|
||||
sense = false;
|
||||
duration = 0;
|
||||
sense = false;
|
||||
|
||||
if(buffer == null) return -1;
|
||||
|
||||
@@ -79,19 +80,19 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
}
|
||||
|
||||
CcbScsiio64 csio = (CcbScsiio64)Marshal.PtrToStructure(ccbPtr, typeof(CcbScsiio64));
|
||||
csio.ccb_h.func_code = XptOpcode.XptScsiIo;
|
||||
csio.ccb_h.flags = direction;
|
||||
csio.ccb_h.xflags = 0;
|
||||
csio.ccb_h.func_code = XptOpcode.XptScsiIo;
|
||||
csio.ccb_h.flags = direction;
|
||||
csio.ccb_h.xflags = 0;
|
||||
csio.ccb_h.retry_count = 1;
|
||||
csio.ccb_h.cbfcnp = IntPtr.Zero;
|
||||
csio.ccb_h.timeout = timeout;
|
||||
csio.data_ptr = Marshal.AllocHGlobal(buffer.Length);
|
||||
csio.dxfer_len = (uint)buffer.Length;
|
||||
csio.sense_len = 32;
|
||||
csio.cdb_len = (byte)cdb.Length;
|
||||
csio.ccb_h.cbfcnp = IntPtr.Zero;
|
||||
csio.ccb_h.timeout = timeout;
|
||||
csio.data_ptr = Marshal.AllocHGlobal(buffer.Length);
|
||||
csio.dxfer_len = (uint)buffer.Length;
|
||||
csio.sense_len = 32;
|
||||
csio.cdb_len = (byte)cdb.Length;
|
||||
// TODO: Create enum?
|
||||
csio.tag_action = 0x20;
|
||||
csio.cdb_bytes = new byte[CAM_MAX_CDBLEN];
|
||||
csio.cdb_bytes = new byte[CAM_MAX_CDBLEN];
|
||||
if(cdb.Length <= CAM_MAX_CDBLEN) Array.Copy(cdb, 0, csio.cdb_bytes, 0, cdb.Length);
|
||||
else
|
||||
{
|
||||
@@ -100,14 +101,15 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
Array.Copy(cdbPtrBytes, 0, csio.cdb_bytes, 0, IntPtr.Size);
|
||||
csio.ccb_h.flags |= CcbFlags.CamCdbPointer;
|
||||
}
|
||||
|
||||
csio.ccb_h.flags |= CcbFlags.CamDevQfrzdis;
|
||||
|
||||
Marshal.Copy(buffer, 0, csio.data_ptr, buffer.Length);
|
||||
Marshal.StructureToPtr(csio, ccbPtr, false);
|
||||
|
||||
DateTime start = DateTime.UtcNow;
|
||||
int error = cam_send_ccb(dev, ccbPtr);
|
||||
DateTime end = DateTime.UtcNow;
|
||||
int error = cam_send_ccb(dev, ccbPtr);
|
||||
DateTime end = DateTime.UtcNow;
|
||||
|
||||
if(error < 0) error = Marshal.GetLastWin32Error();
|
||||
|
||||
@@ -123,22 +125,22 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
|
||||
if((csio.ccb_h.status & CamStatus.CamStatusMask) == CamStatus.CamScsiStatusError)
|
||||
{
|
||||
sense = true;
|
||||
senseBuffer = new byte[1];
|
||||
sense = true;
|
||||
senseBuffer = new byte[1];
|
||||
senseBuffer[0] = csio.scsi_status;
|
||||
}
|
||||
|
||||
if((csio.ccb_h.status & CamStatus.CamAutosnsValid) != 0)
|
||||
if(csio.sense_len - csio.sense_resid > 0)
|
||||
{
|
||||
sense = (csio.ccb_h.status & CamStatus.CamStatusMask) == CamStatus.CamScsiStatusError;
|
||||
senseBuffer = new byte[csio.sense_len - csio.sense_resid];
|
||||
sense = (csio.ccb_h.status & CamStatus.CamStatusMask) == CamStatus.CamScsiStatusError;
|
||||
senseBuffer = new byte[csio.sense_len - csio.sense_resid];
|
||||
senseBuffer[0] = csio.sense_data.error_code;
|
||||
Array.Copy(csio.sense_data.sense_buf, 0, senseBuffer, 1, senseBuffer.Length - 1);
|
||||
}
|
||||
|
||||
buffer = new byte[csio.dxfer_len];
|
||||
cdb = new byte[csio.cdb_len];
|
||||
cdb = new byte[csio.cdb_len];
|
||||
|
||||
Marshal.Copy(csio.data_ptr, buffer, 0, buffer.Length);
|
||||
if(csio.ccb_h.flags.HasFlag(CcbFlags.CamCdbPointer))
|
||||
@@ -168,12 +170,13 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
/// <c>True</c> if SCSI error returned non-OK status and <paramref name="senseBuffer" /> contains SCSI
|
||||
/// sense
|
||||
/// </param>
|
||||
internal static int SendScsiCommand(IntPtr dev, byte[] cdb, ref byte[] buffer, out byte[] senseBuffer,
|
||||
uint timeout, CcbFlags direction, out double duration, out bool sense)
|
||||
internal static int SendScsiCommand(IntPtr dev, byte[] cdb, ref byte[] buffer,
|
||||
out byte[] senseBuffer,
|
||||
uint timeout, CcbFlags direction, out double duration, out bool sense)
|
||||
{
|
||||
senseBuffer = null;
|
||||
duration = 0;
|
||||
sense = false;
|
||||
duration = 0;
|
||||
sense = false;
|
||||
|
||||
if(buffer == null) return -1;
|
||||
|
||||
@@ -187,19 +190,19 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
}
|
||||
|
||||
CcbScsiio csio = (CcbScsiio)Marshal.PtrToStructure(ccbPtr, typeof(CcbScsiio));
|
||||
csio.ccb_h.func_code = XptOpcode.XptScsiIo;
|
||||
csio.ccb_h.flags = direction;
|
||||
csio.ccb_h.xflags = 0;
|
||||
csio.ccb_h.func_code = XptOpcode.XptScsiIo;
|
||||
csio.ccb_h.flags = direction;
|
||||
csio.ccb_h.xflags = 0;
|
||||
csio.ccb_h.retry_count = 1;
|
||||
csio.ccb_h.cbfcnp = IntPtr.Zero;
|
||||
csio.ccb_h.timeout = timeout;
|
||||
csio.data_ptr = Marshal.AllocHGlobal(buffer.Length);
|
||||
csio.dxfer_len = (uint)buffer.Length;
|
||||
csio.sense_len = 32;
|
||||
csio.cdb_len = (byte)cdb.Length;
|
||||
csio.ccb_h.cbfcnp = IntPtr.Zero;
|
||||
csio.ccb_h.timeout = timeout;
|
||||
csio.data_ptr = Marshal.AllocHGlobal(buffer.Length);
|
||||
csio.dxfer_len = (uint)buffer.Length;
|
||||
csio.sense_len = 32;
|
||||
csio.cdb_len = (byte)cdb.Length;
|
||||
// TODO: Create enum?
|
||||
csio.tag_action = 0x20;
|
||||
csio.cdb_bytes = new byte[CAM_MAX_CDBLEN];
|
||||
csio.cdb_bytes = new byte[CAM_MAX_CDBLEN];
|
||||
if(cdb.Length <= CAM_MAX_CDBLEN) Array.Copy(cdb, 0, csio.cdb_bytes, 0, cdb.Length);
|
||||
else
|
||||
{
|
||||
@@ -208,14 +211,15 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
Array.Copy(cdbPtrBytes, 0, csio.cdb_bytes, 0, IntPtr.Size);
|
||||
csio.ccb_h.flags |= CcbFlags.CamCdbPointer;
|
||||
}
|
||||
|
||||
csio.ccb_h.flags |= CcbFlags.CamDevQfrzdis;
|
||||
|
||||
Marshal.Copy(buffer, 0, csio.data_ptr, buffer.Length);
|
||||
Marshal.StructureToPtr(csio, ccbPtr, false);
|
||||
|
||||
DateTime start = DateTime.UtcNow;
|
||||
int error = cam_send_ccb(dev, ccbPtr);
|
||||
DateTime end = DateTime.UtcNow;
|
||||
int error = cam_send_ccb(dev, ccbPtr);
|
||||
DateTime end = DateTime.UtcNow;
|
||||
|
||||
if(error < 0) error = Marshal.GetLastWin32Error();
|
||||
|
||||
@@ -231,22 +235,22 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
|
||||
if((csio.ccb_h.status & CamStatus.CamStatusMask) == CamStatus.CamScsiStatusError)
|
||||
{
|
||||
sense = true;
|
||||
senseBuffer = new byte[1];
|
||||
sense = true;
|
||||
senseBuffer = new byte[1];
|
||||
senseBuffer[0] = csio.scsi_status;
|
||||
}
|
||||
|
||||
if((csio.ccb_h.status & CamStatus.CamAutosnsValid) != 0)
|
||||
if(csio.sense_len - csio.sense_resid > 0)
|
||||
{
|
||||
sense = (csio.ccb_h.status & CamStatus.CamStatusMask) == CamStatus.CamScsiStatusError;
|
||||
senseBuffer = new byte[csio.sense_len - csio.sense_resid];
|
||||
sense = (csio.ccb_h.status & CamStatus.CamStatusMask) == CamStatus.CamScsiStatusError;
|
||||
senseBuffer = new byte[csio.sense_len - csio.sense_resid];
|
||||
senseBuffer[0] = csio.sense_data.error_code;
|
||||
Array.Copy(csio.sense_data.sense_buf, 0, senseBuffer, 1, senseBuffer.Length - 1);
|
||||
}
|
||||
|
||||
buffer = new byte[csio.dxfer_len];
|
||||
cdb = new byte[csio.cdb_len];
|
||||
cdb = new byte[csio.cdb_len];
|
||||
|
||||
Marshal.Copy(csio.data_ptr, buffer, 0, buffer.Length);
|
||||
if(csio.ccb_h.flags.HasFlag(CcbFlags.CamCdbPointer))
|
||||
@@ -296,12 +300,13 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
/// <param name="registers">Registers to send to drive</param>
|
||||
/// <param name="errorRegisters">Registers returned by drive</param>
|
||||
/// <param name="protocol">ATA protocol to use</param>
|
||||
internal static int SendAtaCommand(IntPtr dev, AtaRegistersChs registers,
|
||||
out AtaErrorRegistersChs errorRegisters, AtaProtocol protocol,
|
||||
ref byte[] buffer, uint timeout, out double duration, out bool sense)
|
||||
internal static int SendAtaCommand(IntPtr dev, AtaRegistersChs registers,
|
||||
out AtaErrorRegistersChs errorRegisters, AtaProtocol protocol,
|
||||
ref byte[] buffer, uint timeout,
|
||||
out double duration, out bool sense)
|
||||
{
|
||||
duration = 0;
|
||||
sense = false;
|
||||
duration = 0;
|
||||
sense = false;
|
||||
errorRegisters = new AtaErrorRegistersChs();
|
||||
|
||||
if(buffer == null) return -1;
|
||||
@@ -309,16 +314,16 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
IntPtr ccbPtr = cam_getccb(dev);
|
||||
|
||||
CcbAtaio ataio = (CcbAtaio)Marshal.PtrToStructure(ccbPtr, typeof(CcbAtaio));
|
||||
ataio.ccb_h.func_code = XptOpcode.XptAtaIo;
|
||||
ataio.ccb_h.flags = AtaProtocolToCamFlags(protocol);
|
||||
ataio.ccb_h.xflags = 0;
|
||||
ataio.ccb_h.retry_count = 1;
|
||||
ataio.ccb_h.cbfcnp = IntPtr.Zero;
|
||||
ataio.ccb_h.timeout = timeout;
|
||||
ataio.data_ptr = Marshal.AllocHGlobal(buffer.Length);
|
||||
ataio.dxfer_len = (uint)buffer.Length;
|
||||
ataio.ccb_h.flags |= CcbFlags.CamDevQfrzdis;
|
||||
ataio.cmd.flags = CamAtaIoFlags.NeedResult;
|
||||
ataio.ccb_h.func_code = XptOpcode.XptAtaIo;
|
||||
ataio.ccb_h.flags = AtaProtocolToCamFlags(protocol);
|
||||
ataio.ccb_h.xflags = 0;
|
||||
ataio.ccb_h.retry_count = 1;
|
||||
ataio.ccb_h.cbfcnp = IntPtr.Zero;
|
||||
ataio.ccb_h.timeout = timeout;
|
||||
ataio.data_ptr = Marshal.AllocHGlobal(buffer.Length);
|
||||
ataio.dxfer_len = (uint)buffer.Length;
|
||||
ataio.ccb_h.flags |= CcbFlags.CamDevQfrzdis;
|
||||
ataio.cmd.flags = CamAtaIoFlags.NeedResult;
|
||||
switch(protocol)
|
||||
{
|
||||
case AtaProtocol.Dma:
|
||||
@@ -332,20 +337,20 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
break;
|
||||
}
|
||||
|
||||
ataio.cmd.command = registers.Command;
|
||||
ataio.cmd.lba_high = registers.CylinderHigh;
|
||||
ataio.cmd.lba_mid = registers.CylinderLow;
|
||||
ataio.cmd.device = (byte)(0x40 | registers.DeviceHead);
|
||||
ataio.cmd.features = registers.Feature;
|
||||
ataio.cmd.command = registers.Command;
|
||||
ataio.cmd.lba_high = registers.CylinderHigh;
|
||||
ataio.cmd.lba_mid = registers.CylinderLow;
|
||||
ataio.cmd.device = (byte)(0x40 | registers.DeviceHead);
|
||||
ataio.cmd.features = registers.Feature;
|
||||
ataio.cmd.sector_count = registers.SectorCount;
|
||||
ataio.cmd.lba_low = registers.Sector;
|
||||
ataio.cmd.lba_low = registers.Sector;
|
||||
|
||||
Marshal.Copy(buffer, 0, ataio.data_ptr, buffer.Length);
|
||||
Marshal.StructureToPtr(ataio, ccbPtr, false);
|
||||
|
||||
DateTime start = DateTime.UtcNow;
|
||||
int error = cam_send_ccb(dev, ccbPtr);
|
||||
DateTime end = DateTime.UtcNow;
|
||||
int error = cam_send_ccb(dev, ccbPtr);
|
||||
DateTime end = DateTime.UtcNow;
|
||||
|
||||
if(error < 0) error = Marshal.GetLastWin32Error();
|
||||
|
||||
@@ -362,12 +367,12 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
if((ataio.ccb_h.status & CamStatus.CamStatusMask) == CamStatus.CamAtaStatusError) sense = true;
|
||||
|
||||
errorRegisters.CylinderHigh = ataio.res.lba_high;
|
||||
errorRegisters.CylinderLow = ataio.res.lba_mid;
|
||||
errorRegisters.DeviceHead = ataio.res.device;
|
||||
errorRegisters.Error = ataio.res.error;
|
||||
errorRegisters.Sector = ataio.res.lba_low;
|
||||
errorRegisters.SectorCount = ataio.res.sector_count;
|
||||
errorRegisters.Status = ataio.res.status;
|
||||
errorRegisters.CylinderLow = ataio.res.lba_mid;
|
||||
errorRegisters.DeviceHead = ataio.res.device;
|
||||
errorRegisters.Error = ataio.res.error;
|
||||
errorRegisters.Sector = ataio.res.lba_low;
|
||||
errorRegisters.SectorCount = ataio.res.sector_count;
|
||||
errorRegisters.Status = ataio.res.status;
|
||||
|
||||
buffer = new byte[ataio.dxfer_len];
|
||||
|
||||
@@ -394,12 +399,13 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
/// <param name="registers">Registers to send to drive</param>
|
||||
/// <param name="errorRegisters">Registers returned by drive</param>
|
||||
/// <param name="protocol">ATA protocol to use</param>
|
||||
internal static int SendAtaCommand(IntPtr dev, AtaRegistersLba28 registers,
|
||||
out AtaErrorRegistersLba28 errorRegisters, AtaProtocol protocol,
|
||||
ref byte[] buffer, uint timeout, out double duration, out bool sense)
|
||||
internal static int SendAtaCommand(IntPtr dev, AtaRegistersLba28 registers,
|
||||
out AtaErrorRegistersLba28 errorRegisters, AtaProtocol protocol,
|
||||
ref byte[] buffer, uint timeout,
|
||||
out double duration, out bool sense)
|
||||
{
|
||||
duration = 0;
|
||||
sense = false;
|
||||
duration = 0;
|
||||
sense = false;
|
||||
errorRegisters = new AtaErrorRegistersLba28();
|
||||
|
||||
if(buffer == null) return -1;
|
||||
@@ -407,16 +413,16 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
IntPtr ccbPtr = cam_getccb(dev);
|
||||
|
||||
CcbAtaio ataio = (CcbAtaio)Marshal.PtrToStructure(ccbPtr, typeof(CcbAtaio));
|
||||
ataio.ccb_h.func_code = XptOpcode.XptAtaIo;
|
||||
ataio.ccb_h.flags = AtaProtocolToCamFlags(protocol);
|
||||
ataio.ccb_h.xflags = 0;
|
||||
ataio.ccb_h.retry_count = 1;
|
||||
ataio.ccb_h.cbfcnp = IntPtr.Zero;
|
||||
ataio.ccb_h.timeout = timeout;
|
||||
ataio.data_ptr = Marshal.AllocHGlobal(buffer.Length);
|
||||
ataio.dxfer_len = (uint)buffer.Length;
|
||||
ataio.ccb_h.flags |= CcbFlags.CamDevQfrzdis;
|
||||
ataio.cmd.flags = CamAtaIoFlags.NeedResult;
|
||||
ataio.ccb_h.func_code = XptOpcode.XptAtaIo;
|
||||
ataio.ccb_h.flags = AtaProtocolToCamFlags(protocol);
|
||||
ataio.ccb_h.xflags = 0;
|
||||
ataio.ccb_h.retry_count = 1;
|
||||
ataio.ccb_h.cbfcnp = IntPtr.Zero;
|
||||
ataio.ccb_h.timeout = timeout;
|
||||
ataio.data_ptr = Marshal.AllocHGlobal(buffer.Length);
|
||||
ataio.dxfer_len = (uint)buffer.Length;
|
||||
ataio.ccb_h.flags |= CcbFlags.CamDevQfrzdis;
|
||||
ataio.cmd.flags = CamAtaIoFlags.NeedResult;
|
||||
switch(protocol)
|
||||
{
|
||||
case AtaProtocol.Dma:
|
||||
@@ -430,20 +436,20 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
break;
|
||||
}
|
||||
|
||||
ataio.cmd.command = registers.Command;
|
||||
ataio.cmd.lba_high = registers.LbaHigh;
|
||||
ataio.cmd.lba_mid = registers.LbaMid;
|
||||
ataio.cmd.device = (byte)(0x40 | registers.DeviceHead);
|
||||
ataio.cmd.features = registers.Feature;
|
||||
ataio.cmd.command = registers.Command;
|
||||
ataio.cmd.lba_high = registers.LbaHigh;
|
||||
ataio.cmd.lba_mid = registers.LbaMid;
|
||||
ataio.cmd.device = (byte)(0x40 | registers.DeviceHead);
|
||||
ataio.cmd.features = registers.Feature;
|
||||
ataio.cmd.sector_count = registers.SectorCount;
|
||||
ataio.cmd.lba_low = registers.LbaLow;
|
||||
ataio.cmd.lba_low = registers.LbaLow;
|
||||
|
||||
Marshal.Copy(buffer, 0, ataio.data_ptr, buffer.Length);
|
||||
Marshal.StructureToPtr(ataio, ccbPtr, false);
|
||||
|
||||
DateTime start = DateTime.UtcNow;
|
||||
int error = cam_send_ccb(dev, ccbPtr);
|
||||
DateTime end = DateTime.UtcNow;
|
||||
int error = cam_send_ccb(dev, ccbPtr);
|
||||
DateTime end = DateTime.UtcNow;
|
||||
|
||||
if(error < 0) error = Marshal.GetLastWin32Error();
|
||||
|
||||
@@ -459,13 +465,13 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
|
||||
if((ataio.ccb_h.status & CamStatus.CamStatusMask) == CamStatus.CamAtaStatusError) sense = true;
|
||||
|
||||
errorRegisters.LbaHigh = ataio.res.lba_high;
|
||||
errorRegisters.LbaMid = ataio.res.lba_mid;
|
||||
errorRegisters.DeviceHead = ataio.res.device;
|
||||
errorRegisters.Error = ataio.res.error;
|
||||
errorRegisters.LbaLow = ataio.res.lba_low;
|
||||
errorRegisters.LbaHigh = ataio.res.lba_high;
|
||||
errorRegisters.LbaMid = ataio.res.lba_mid;
|
||||
errorRegisters.DeviceHead = ataio.res.device;
|
||||
errorRegisters.Error = ataio.res.error;
|
||||
errorRegisters.LbaLow = ataio.res.lba_low;
|
||||
errorRegisters.SectorCount = ataio.res.sector_count;
|
||||
errorRegisters.Status = ataio.res.status;
|
||||
errorRegisters.Status = ataio.res.status;
|
||||
|
||||
buffer = new byte[ataio.dxfer_len];
|
||||
|
||||
@@ -492,12 +498,13 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
/// <param name="registers">Registers to send to drive</param>
|
||||
/// <param name="errorRegisters">Registers returned by drive</param>
|
||||
/// <param name="protocol">ATA protocol to use</param>
|
||||
internal static int SendAtaCommand(IntPtr dev, AtaRegistersLba48 registers,
|
||||
out AtaErrorRegistersLba48 errorRegisters, AtaProtocol protocol,
|
||||
ref byte[] buffer, uint timeout, out double duration, out bool sense)
|
||||
internal static int SendAtaCommand(IntPtr dev, AtaRegistersLba48 registers,
|
||||
out AtaErrorRegistersLba48 errorRegisters, AtaProtocol protocol,
|
||||
ref byte[] buffer, uint timeout,
|
||||
out double duration, out bool sense)
|
||||
{
|
||||
duration = 0;
|
||||
sense = false;
|
||||
duration = 0;
|
||||
sense = false;
|
||||
errorRegisters = new AtaErrorRegistersLba48();
|
||||
|
||||
// 48-bit ATA CAM commands can crash FreeBSD < 9.2-RELEASE
|
||||
@@ -509,16 +516,16 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
IntPtr ccbPtr = cam_getccb(dev);
|
||||
|
||||
CcbAtaio ataio = (CcbAtaio)Marshal.PtrToStructure(ccbPtr, typeof(CcbAtaio));
|
||||
ataio.ccb_h.func_code = XptOpcode.XptAtaIo;
|
||||
ataio.ccb_h.flags = AtaProtocolToCamFlags(protocol);
|
||||
ataio.ccb_h.xflags = 0;
|
||||
ataio.ccb_h.retry_count = 1;
|
||||
ataio.ccb_h.cbfcnp = IntPtr.Zero;
|
||||
ataio.ccb_h.timeout = timeout;
|
||||
ataio.data_ptr = Marshal.AllocHGlobal(buffer.Length);
|
||||
ataio.dxfer_len = (uint)buffer.Length;
|
||||
ataio.ccb_h.flags |= CcbFlags.CamDevQfrzdis;
|
||||
ataio.cmd.flags = CamAtaIoFlags.NeedResult | CamAtaIoFlags.ExtendedCommand;
|
||||
ataio.ccb_h.func_code = XptOpcode.XptAtaIo;
|
||||
ataio.ccb_h.flags = AtaProtocolToCamFlags(protocol);
|
||||
ataio.ccb_h.xflags = 0;
|
||||
ataio.ccb_h.retry_count = 1;
|
||||
ataio.ccb_h.cbfcnp = IntPtr.Zero;
|
||||
ataio.ccb_h.timeout = timeout;
|
||||
ataio.data_ptr = Marshal.AllocHGlobal(buffer.Length);
|
||||
ataio.dxfer_len = (uint)buffer.Length;
|
||||
ataio.ccb_h.flags |= CcbFlags.CamDevQfrzdis;
|
||||
ataio.cmd.flags = CamAtaIoFlags.NeedResult | CamAtaIoFlags.ExtendedCommand;
|
||||
switch(protocol)
|
||||
{
|
||||
case AtaProtocol.Dma:
|
||||
@@ -532,25 +539,25 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
break;
|
||||
}
|
||||
|
||||
ataio.cmd.lba_high_exp = (byte)((registers.LbaHigh & 0xFF00) >> 8);
|
||||
ataio.cmd.lba_mid_exp = (byte)((registers.LbaMid & 0xFF00) >> 8);
|
||||
ataio.cmd.features_exp = (byte)((registers.Feature & 0xFF00) >> 8);
|
||||
ataio.cmd.lba_high_exp = (byte)((registers.LbaHigh & 0xFF00) >> 8);
|
||||
ataio.cmd.lba_mid_exp = (byte)((registers.LbaMid & 0xFF00) >> 8);
|
||||
ataio.cmd.features_exp = (byte)((registers.Feature & 0xFF00) >> 8);
|
||||
ataio.cmd.sector_count_exp = (byte)((registers.SectorCount & 0xFF00) >> 8);
|
||||
ataio.cmd.lba_low_exp = (byte)((registers.LbaLow & 0xFF00) >> 8);
|
||||
ataio.cmd.lba_high = (byte)(registers.LbaHigh & 0xFF);
|
||||
ataio.cmd.lba_mid = (byte)(registers.LbaMid & 0xFF);
|
||||
ataio.cmd.features = (byte)(registers.Feature & 0xFF);
|
||||
ataio.cmd.sector_count = (byte)(registers.SectorCount & 0xFF);
|
||||
ataio.cmd.lba_low = (byte)(registers.LbaLow & 0xFF);
|
||||
ataio.cmd.command = registers.Command;
|
||||
ataio.cmd.device = (byte)(0x40 | registers.DeviceHead);
|
||||
ataio.cmd.lba_low_exp = (byte)((registers.LbaLow & 0xFF00) >> 8);
|
||||
ataio.cmd.lba_high = (byte)(registers.LbaHigh & 0xFF);
|
||||
ataio.cmd.lba_mid = (byte)(registers.LbaMid & 0xFF);
|
||||
ataio.cmd.features = (byte)(registers.Feature & 0xFF);
|
||||
ataio.cmd.sector_count = (byte)(registers.SectorCount & 0xFF);
|
||||
ataio.cmd.lba_low = (byte)(registers.LbaLow & 0xFF);
|
||||
ataio.cmd.command = registers.Command;
|
||||
ataio.cmd.device = (byte)(0x40 | registers.DeviceHead);
|
||||
|
||||
Marshal.Copy(buffer, 0, ataio.data_ptr, buffer.Length);
|
||||
Marshal.StructureToPtr(ataio, ccbPtr, false);
|
||||
|
||||
DateTime start = DateTime.UtcNow;
|
||||
int error = cam_send_ccb(dev, ccbPtr);
|
||||
DateTime end = DateTime.UtcNow;
|
||||
int error = cam_send_ccb(dev, ccbPtr);
|
||||
DateTime end = DateTime.UtcNow;
|
||||
|
||||
if(error < 0) error = Marshal.GetLastWin32Error();
|
||||
|
||||
@@ -567,12 +574,12 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
if((ataio.ccb_h.status & CamStatus.CamStatusMask) == CamStatus.CamAtaStatusError) sense = true;
|
||||
|
||||
errorRegisters.SectorCount = (ushort)((ataio.res.sector_count_exp << 8) + ataio.res.sector_count);
|
||||
errorRegisters.LbaLow = (ushort)((ataio.res.lba_low_exp << 8) + ataio.res.lba_low);
|
||||
errorRegisters.LbaMid = (ushort)((ataio.res.lba_mid_exp << 8) + ataio.res.lba_mid);
|
||||
errorRegisters.LbaHigh = (ushort)((ataio.res.lba_high_exp << 8) + ataio.res.lba_high);
|
||||
errorRegisters.DeviceHead = ataio.res.device;
|
||||
errorRegisters.Error = ataio.res.error;
|
||||
errorRegisters.Status = ataio.res.status;
|
||||
errorRegisters.LbaLow = (ushort)((ataio.res.lba_low_exp << 8) + ataio.res.lba_low);
|
||||
errorRegisters.LbaMid = (ushort)((ataio.res.lba_mid_exp << 8) + ataio.res.lba_mid);
|
||||
errorRegisters.LbaHigh = (ushort)((ataio.res.lba_high_exp << 8) + ataio.res.lba_high);
|
||||
errorRegisters.DeviceHead = ataio.res.device;
|
||||
errorRegisters.Error = ataio.res.error;
|
||||
errorRegisters.Status = ataio.res.status;
|
||||
|
||||
buffer = new byte[ataio.dxfer_len];
|
||||
|
||||
|
||||
@@ -269,34 +269,34 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
[Flags]
|
||||
enum PeriphPatternFlags
|
||||
{
|
||||
PeriphMatchNone = 0x000,
|
||||
PeriphMatchPath = 0x001,
|
||||
PeriphMatchNone = 0x000,
|
||||
PeriphMatchPath = 0x001,
|
||||
PeriphMatchTarget = 0x002,
|
||||
PeriphMatchLun = 0x004,
|
||||
PeriphMatchName = 0x008,
|
||||
PeriphMatchUnit = 0x010
|
||||
PeriphMatchLun = 0x004,
|
||||
PeriphMatchName = 0x008,
|
||||
PeriphMatchUnit = 0x010
|
||||
// PERIPH_MATCH_ANY = 0x01f
|
||||
}
|
||||
|
||||
[Flags]
|
||||
enum DevPatternFlags
|
||||
{
|
||||
DevMatchNone = 0x000,
|
||||
DevMatchPath = 0x001,
|
||||
DevMatchTarget = 0x002,
|
||||
DevMatchLun = 0x004,
|
||||
DevMatchNone = 0x000,
|
||||
DevMatchPath = 0x001,
|
||||
DevMatchTarget = 0x002,
|
||||
DevMatchLun = 0x004,
|
||||
DevMatchInquiry = 0x008,
|
||||
DevMatchDevid = 0x010
|
||||
DevMatchDevid = 0x010
|
||||
// DEV_MATCH_ANY = 0x00f
|
||||
}
|
||||
|
||||
[Flags]
|
||||
enum BusPatternFlags
|
||||
{
|
||||
BusMatchNone = 0x000,
|
||||
BusMatchPath = 0x001,
|
||||
BusMatchName = 0x002,
|
||||
BusMatchUnit = 0x004,
|
||||
BusMatchNone = 0x000,
|
||||
BusMatchPath = 0x001,
|
||||
BusMatchName = 0x002,
|
||||
BusMatchUnit = 0x004,
|
||||
BusMatchBusId = 0x008
|
||||
// BUS_MATCH_ANY = 0x00f
|
||||
}
|
||||
@@ -304,7 +304,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
[Flags]
|
||||
enum DevResultFlags
|
||||
{
|
||||
DevResultNoflag = 0x00,
|
||||
DevResultNoflag = 0x00,
|
||||
DevResultUnconfigured = 0x01
|
||||
}
|
||||
|
||||
@@ -353,32 +353,32 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
enum MmcCardFeatures
|
||||
{
|
||||
CardFeatureMemory = 0x1,
|
||||
CardFeatureSdhc = 0x1 << 1,
|
||||
CardFeatureSdio = 0x1 << 2,
|
||||
CardFeatureSd20 = 0x1 << 3,
|
||||
CardFeatureMmc = 0x1 << 4,
|
||||
CardFeature18V = 0x1 << 5
|
||||
CardFeatureSdhc = 0x1 << 1,
|
||||
CardFeatureSdio = 0x1 << 2,
|
||||
CardFeatureSd20 = 0x1 << 3,
|
||||
CardFeatureMmc = 0x1 << 4,
|
||||
CardFeature18V = 0x1 << 5
|
||||
}
|
||||
|
||||
enum CamGenerations : uint
|
||||
{
|
||||
CamBusGeneration = 0x00,
|
||||
CamBusGeneration = 0x00,
|
||||
CamTargetGeneration = 0x01,
|
||||
CamDevGeneration = 0x02,
|
||||
CamDevGeneration = 0x02,
|
||||
CamPeriphGeneration = 0x03
|
||||
}
|
||||
|
||||
[Flags]
|
||||
enum DevPosType
|
||||
{
|
||||
CamDevPosNone = 0x000,
|
||||
CamDevPosBus = 0x001,
|
||||
CamDevPosNone = 0x000,
|
||||
CamDevPosBus = 0x001,
|
||||
CamDevPosTarget = 0x002,
|
||||
CamDevPosDevice = 0x004,
|
||||
CamDevPosPeriph = 0x008,
|
||||
CamDevPosPdptr = 0x010,
|
||||
CamDevPosPdptr = 0x010,
|
||||
// CAM_DEV_POS_TYPEMASK = 0xf00,
|
||||
CamDevPosEdt = 0x100,
|
||||
CamDevPosEdt = 0x100,
|
||||
CamDevPosPdrv = 0x200
|
||||
}
|
||||
|
||||
|
||||
@@ -49,14 +49,14 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
/// <returns>List of devices</returns>
|
||||
internal static DeviceInfo[] GetList()
|
||||
{
|
||||
string[] passDevices = Directory.GetFiles("/dev/", "pass*", SearchOption.TopDirectoryOnly);
|
||||
string[] passDevices = Directory.GetFiles("/dev/", "pass*", SearchOption.TopDirectoryOnly);
|
||||
List<DeviceInfo> listDevices = new List<DeviceInfo>();
|
||||
|
||||
foreach(string passDevice in passDevices)
|
||||
{
|
||||
DeviceInfo deviceInfo = new DeviceInfo();
|
||||
IntPtr dev = cam_open_device(passDevice, FileFlags.ReadWrite);
|
||||
CamDevice camDevice = (CamDevice)Marshal.PtrToStructure(dev, typeof(CamDevice));
|
||||
IntPtr dev = cam_open_device(passDevice, FileFlags.ReadWrite);
|
||||
CamDevice camDevice = (CamDevice)Marshal.PtrToStructure(dev, typeof(CamDevice));
|
||||
|
||||
IntPtr ccbPtr = cam_getccb(dev);
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
for(int aIndex = 0; aIndex < 512; aIndex += 2)
|
||||
{
|
||||
atadTneid[aIndex] = cgd.ident_data[aIndex + 1];
|
||||
atadTneid[aIndex + 1] = cgd.ident_data[aIndex];
|
||||
atadTneid[aIndex + 1] = cgd.ident_data[aIndex];
|
||||
}
|
||||
|
||||
Identify.IdentifyDevice? idt = Identify.Decode(atadTneid);
|
||||
@@ -110,18 +110,19 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
if(separated.Length == 1)
|
||||
{
|
||||
deviceInfo.Vendor = "ATA";
|
||||
deviceInfo.Model = separated[0];
|
||||
deviceInfo.Model = separated[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
deviceInfo.Vendor = separated[0];
|
||||
deviceInfo.Model = separated[separated.Length - 1];
|
||||
deviceInfo.Model = separated[separated.Length - 1];
|
||||
}
|
||||
|
||||
deviceInfo.Serial = idt.Value.SerialNumber;
|
||||
deviceInfo.Bus = simName == "ahcich" ? "SATA" : "ATA";
|
||||
deviceInfo.Serial = idt.Value.SerialNumber;
|
||||
deviceInfo.Bus = simName == "ahcich" ? "SATA" : "ATA";
|
||||
deviceInfo.Supported = simName != "ata";
|
||||
}
|
||||
|
||||
if(cgd.protocol == CamProto.ProtoAtapi) goto case CamProto.ProtoScsi;
|
||||
break;
|
||||
}
|
||||
@@ -130,20 +131,21 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
Inquiry.SCSIInquiry? inq = Inquiry.Decode(cgd.inq_data);
|
||||
if(inq.HasValue)
|
||||
{
|
||||
deviceInfo.Vendor = StringHandlers.CToString(inq.Value.VendorIdentification).Trim();
|
||||
deviceInfo.Model = StringHandlers.CToString(inq.Value.ProductIdentification).Trim();
|
||||
deviceInfo.Bus = simName == "ata" || simName == "ahcich" ? "ATAPI" : "SCSI";
|
||||
deviceInfo.Vendor = StringHandlers.CToString(inq.Value.VendorIdentification).Trim();
|
||||
deviceInfo.Model = StringHandlers.CToString(inq.Value.ProductIdentification).Trim();
|
||||
deviceInfo.Bus = simName == "ata" || simName == "ahcich" ? "ATAPI" : "SCSI";
|
||||
deviceInfo.Supported = simName != "ata";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case CamProto.ProtoNvme:
|
||||
deviceInfo.Bus = "NVMe";
|
||||
deviceInfo.Bus = "NVMe";
|
||||
deviceInfo.Supported = false;
|
||||
break;
|
||||
case CamProto.ProtoMmcsd:
|
||||
deviceInfo.Model = "Unknown card";
|
||||
deviceInfo.Bus = "MMC/SD";
|
||||
deviceInfo.Model = "Unknown card";
|
||||
deviceInfo.Bus = "MMC/SD";
|
||||
deviceInfo.Supported = false;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -50,19 +50,19 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
struct AtaCmd
|
||||
{
|
||||
public CamAtaIoFlags flags;
|
||||
public byte command;
|
||||
public byte features;
|
||||
public byte lba_low;
|
||||
public byte lba_mid;
|
||||
public byte lba_high;
|
||||
public byte device;
|
||||
public byte lba_low_exp;
|
||||
public byte lba_mid_exp;
|
||||
public byte lba_high_exp;
|
||||
public byte features_exp;
|
||||
public byte sector_count;
|
||||
public byte sector_count_exp;
|
||||
public byte control;
|
||||
public byte command;
|
||||
public byte features;
|
||||
public byte lba_low;
|
||||
public byte lba_mid;
|
||||
public byte lba_high;
|
||||
public byte device;
|
||||
public byte lba_low_exp;
|
||||
public byte lba_mid_exp;
|
||||
public byte lba_high_exp;
|
||||
public byte features_exp;
|
||||
public byte sector_count;
|
||||
public byte sector_count_exp;
|
||||
public byte control;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
@@ -70,17 +70,17 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
struct AtaRes
|
||||
{
|
||||
public CamAtaIoFlags flags;
|
||||
public byte status;
|
||||
public byte error;
|
||||
public byte lba_low;
|
||||
public byte lba_mid;
|
||||
public byte lba_high;
|
||||
public byte device;
|
||||
public byte lba_low_exp;
|
||||
public byte lba_mid_exp;
|
||||
public byte lba_high_exp;
|
||||
public byte sector_count;
|
||||
public byte sector_count_exp;
|
||||
public byte status;
|
||||
public byte error;
|
||||
public byte lba_low;
|
||||
public byte lba_mid;
|
||||
public byte lba_high;
|
||||
public byte device;
|
||||
public byte lba_low_exp;
|
||||
public byte lba_mid_exp;
|
||||
public byte lba_high_exp;
|
||||
public byte sector_count;
|
||||
public byte sector_count_exp;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
@@ -89,7 +89,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
{
|
||||
public uint priority;
|
||||
public uint generation;
|
||||
public int index;
|
||||
public int index;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
@@ -140,9 +140,9 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
struct CamqEntry
|
||||
{
|
||||
[FieldOffset(0)] public ListEntry le;
|
||||
[FieldOffset(0)] public SlistEntry sle;
|
||||
[FieldOffset(0)] public TailqEntry tqe;
|
||||
[FieldOffset(0)] public ListEntry le;
|
||||
[FieldOffset(0)] public SlistEntry sle;
|
||||
[FieldOffset(0)] public TailqEntry tqe;
|
||||
[FieldOffset(0)] public StailqEntry stqe;
|
||||
}
|
||||
|
||||
@@ -168,34 +168,37 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
struct CcbHdr
|
||||
{
|
||||
public CamPinfo pinfo;
|
||||
public CamPinfo pinfo;
|
||||
public CamqEntry xpt_links;
|
||||
public CamqEntry sim_links;
|
||||
public CamqEntry periph_links;
|
||||
public uint retry_count;
|
||||
public IntPtr cbfcnp;
|
||||
public uint retry_count;
|
||||
public IntPtr cbfcnp;
|
||||
public XptOpcode func_code;
|
||||
public CamStatus status;
|
||||
public IntPtr path;
|
||||
public uint path_id;
|
||||
public uint target_id;
|
||||
public ulong target_lun;
|
||||
public CcbFlags flags;
|
||||
public uint xflags;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public IntPtr[] periph_priv;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public IntPtr[] sim_priv;
|
||||
public IntPtr path;
|
||||
public uint path_id;
|
||||
public uint target_id;
|
||||
public ulong target_lun;
|
||||
public CcbFlags flags;
|
||||
public uint xflags;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public IntPtr[] periph_priv;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public IntPtr[] sim_priv;
|
||||
public CcbQosArea qos;
|
||||
public uint timeout;
|
||||
public Timeval softtimeout;
|
||||
public uint timeout;
|
||||
public Timeval softtimeout;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
struct ScsiSenseData
|
||||
{
|
||||
const int SSD_FULL_SIZE = 252;
|
||||
const int SSD_FULL_SIZE = 252;
|
||||
public byte error_code;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = SSD_FULL_SIZE - 1)] public byte[] sense_buf;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = SSD_FULL_SIZE - 1)]
|
||||
public byte[] sense_buf;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -232,7 +235,8 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
/// 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;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = IOCDBLEN)]
|
||||
public byte[] cdb_bytes;
|
||||
/// <summary>Pointer to the message buffer</summary>
|
||||
public IntPtr msg_ptr;
|
||||
/// <summary>Number of bytes for the Message</summary>
|
||||
@@ -283,7 +287,8 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
/// 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;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = IOCDBLEN)]
|
||||
public byte[] cdb_bytes;
|
||||
/// <summary>Pointer to the message buffer</summary>
|
||||
public IntPtr msg_ptr;
|
||||
/// <summary>Number of bytes for the Message</summary>
|
||||
@@ -496,11 +501,12 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
{
|
||||
const int DEV_IDLEN = 16;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = DEV_IDLEN)] public byte[] periph_name;
|
||||
public uint unit_number;
|
||||
public path_id_t path_id;
|
||||
public target_id_t target_id;
|
||||
public lun_id_t target_lun;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = DEV_IDLEN)]
|
||||
public byte[] periph_name;
|
||||
public uint unit_number;
|
||||
public path_id_t path_id;
|
||||
public target_id_t target_id;
|
||||
public lun_id_t target_lun;
|
||||
public PeriphPatternFlags flags;
|
||||
}
|
||||
|
||||
@@ -509,21 +515,25 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
struct DeviceIdMatchPattern
|
||||
{
|
||||
public byte id_len;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public byte[] id;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
|
||||
public byte[] id;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
struct ScsiStaticInquiryPattern
|
||||
{
|
||||
const int SID_VENDOR_SIZE = 8;
|
||||
const int SID_PRODUCT_SIZE = 16;
|
||||
const int SID_REVISION_SIZE = 4;
|
||||
const int SID_VENDOR_SIZE = 8;
|
||||
const int SID_PRODUCT_SIZE = 16;
|
||||
const int SID_REVISION_SIZE = 4;
|
||||
public byte type;
|
||||
public byte media_type;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = SID_VENDOR_SIZE + 1)] public byte[] vendor;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = SID_PRODUCT_SIZE + 1)] public byte[] product;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = SID_REVISION_SIZE + 1)] public byte[] revision;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = SID_VENDOR_SIZE + 1)]
|
||||
public byte[] vendor;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = SID_PRODUCT_SIZE + 1)]
|
||||
public byte[] product;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = SID_REVISION_SIZE + 1)]
|
||||
public byte[] revision;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
@@ -531,17 +541,17 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
struct DeviceMatchPatternData
|
||||
{
|
||||
[FieldOffset(0)] public ScsiStaticInquiryPattern inq_pat;
|
||||
[FieldOffset(0)] public DeviceIdMatchPattern devid_pat;
|
||||
[FieldOffset(0)] public DeviceIdMatchPattern devid_pat;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
struct DeviceMatchPattern
|
||||
{
|
||||
public uint path_id;
|
||||
public uint target_id;
|
||||
public uint target_lun;
|
||||
public DevPatternFlags flags;
|
||||
public uint path_id;
|
||||
public uint target_id;
|
||||
public uint target_lun;
|
||||
public DevPatternFlags flags;
|
||||
public DeviceMatchPatternData data;
|
||||
}
|
||||
|
||||
@@ -552,9 +562,10 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
const int DEV_IDLEN = 16;
|
||||
|
||||
public path_id_t path_id;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = DEV_IDLEN)] public byte[] dev_name;
|
||||
public uint unit_number;
|
||||
public uint bus_id;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = DEV_IDLEN)]
|
||||
public byte[] dev_name;
|
||||
public uint unit_number;
|
||||
public uint bus_id;
|
||||
BusPatternFlags flags;
|
||||
}
|
||||
|
||||
@@ -564,7 +575,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
{
|
||||
[FieldOffset(0)] public PeriphMatchPattern periph_pattern;
|
||||
[FieldOffset(0)] public DeviceMatchPattern device_pattern;
|
||||
[FieldOffset(0)] public BusMatchPattern bus_pattern;
|
||||
[FieldOffset(0)] public BusMatchPattern bus_pattern;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
@@ -579,11 +590,12 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
struct PeriphMatchResult
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] periph_name;
|
||||
public uint unit_number;
|
||||
public path_id_t path_id;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
public byte[] periph_name;
|
||||
public uint unit_number;
|
||||
public path_id_t path_id;
|
||||
public target_id_t target_id;
|
||||
public lun_id_t target_lun;
|
||||
public lun_id_t target_lun;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
@@ -591,13 +603,14 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
struct MmcCid
|
||||
{
|
||||
public uint mid;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] pnm;
|
||||
public uint psn;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public byte[] pnm;
|
||||
public uint psn;
|
||||
public ushort oid;
|
||||
public ushort mdt_year;
|
||||
public byte mdt_month;
|
||||
public byte prv;
|
||||
public byte fwrev;
|
||||
public byte mdt_month;
|
||||
public byte prv;
|
||||
public byte fwrev;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
@@ -607,7 +620,8 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
/// <summary>
|
||||
/// Card model
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 40)] public byte[] model;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 40)]
|
||||
public byte[] model;
|
||||
|
||||
/// <summary>
|
||||
/// Card OCR
|
||||
@@ -622,7 +636,8 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
/// <summary>
|
||||
/// Card CID -- raw
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public uint[] card_cid;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public uint[] card_cid;
|
||||
|
||||
/// <summary>
|
||||
/// Card CID -- parsed
|
||||
@@ -632,7 +647,8 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
/// <summary>
|
||||
/// Card CSD -- raw
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public uint[] card_csd;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public uint[] card_csd;
|
||||
|
||||
/// <summary>
|
||||
/// Card RCA
|
||||
@@ -651,14 +667,16 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
struct DeviceMatchResult
|
||||
{
|
||||
public path_id_t path_id;
|
||||
public path_id_t path_id;
|
||||
public target_id_t target_id;
|
||||
public lun_id_t target_lun;
|
||||
public CamProto protocol;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public byte[] inq_data;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)] public byte[] ident_data;
|
||||
public lun_id_t target_lun;
|
||||
public CamProto protocol;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
|
||||
public byte[] inq_data;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)]
|
||||
public byte[] ident_data;
|
||||
public DevResultFlags flags;
|
||||
public MmcParams mmc_ident_data;
|
||||
public MmcParams mmc_ident_data;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
@@ -666,8 +684,9 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
struct BusMatchResult
|
||||
{
|
||||
public path_id_t path_id;
|
||||
const int DEV_IDLEN = 16;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = DEV_IDLEN)] public byte[] dev_name;
|
||||
const int DEV_IDLEN = 16;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = DEV_IDLEN)]
|
||||
public byte[] dev_name;
|
||||
public uint unit_number;
|
||||
public uint bus_id;
|
||||
}
|
||||
@@ -678,7 +697,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
{
|
||||
[FieldOffset(0)] public PeriphMatchResult periph_result;
|
||||
[FieldOffset(0)] public DeviceMatchResult device_result;
|
||||
[FieldOffset(0)] public BusMatchResult bus_result;
|
||||
[FieldOffset(0)] public BusMatchResult bus_result;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
@@ -686,7 +705,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
struct DevMatchResult
|
||||
{
|
||||
public DevMatchType type;
|
||||
public MatchResult result;
|
||||
public MatchResult result;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
@@ -704,8 +723,9 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
struct CcbDevPosition
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public CamGenerations[] generations;
|
||||
DevPosType position_type;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public CamGenerations[] generations;
|
||||
DevPosType position_type;
|
||||
public CcbDmCookie cookie;
|
||||
}
|
||||
|
||||
@@ -713,10 +733,10 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
struct CcbDevMatch
|
||||
{
|
||||
public CcbHdr ccb_h;
|
||||
public CcbHdr ccb_h;
|
||||
CcbDevMatchStatus status;
|
||||
public uint num_patterns;
|
||||
public uint pattern_buf_len;
|
||||
public uint num_patterns;
|
||||
public uint pattern_buf_len;
|
||||
|
||||
/// <summary>
|
||||
/// dev_match_pattern*
|
||||
@@ -738,17 +758,19 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
struct CamDevice
|
||||
{
|
||||
const int MAXPATHLEN = 1024;
|
||||
const int DEV_IDLEN = 16;
|
||||
const int SIM_IDLEN = 16;
|
||||
const int DEV_IDLEN = 16;
|
||||
const int SIM_IDLEN = 16;
|
||||
/// <summary>
|
||||
/// Pathname of the device given by the user. This may be null if the user states the device name and unit number
|
||||
/// separately.
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAXPATHLEN)] public byte[] DevicePath;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAXPATHLEN)]
|
||||
public byte[] DevicePath;
|
||||
/// <summary>
|
||||
/// Device name given by the user.
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = DEV_IDLEN + 1)] public byte[] GivenDevName;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = DEV_IDLEN + 1)]
|
||||
public byte[] GivenDevName;
|
||||
/// <summary>
|
||||
/// Unit number given by the user.
|
||||
/// </summary>
|
||||
@@ -756,7 +778,8 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
/// <summary>
|
||||
/// Name of the device, e.g. 'pass'
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = DEV_IDLEN + 1)] public byte[] DeviceName;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = DEV_IDLEN + 1)]
|
||||
public byte[] DeviceName;
|
||||
/// <summary>
|
||||
/// Unit number of the passthrough device associated with this particular device.
|
||||
/// </summary>
|
||||
@@ -764,7 +787,8 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
/// <summary>
|
||||
/// Controller name, e.g. 'ahc'
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = SIM_IDLEN + 1)] public byte[] SimName;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = SIM_IDLEN + 1)]
|
||||
public byte[] SimName;
|
||||
/// <summary>
|
||||
/// Controller unit number
|
||||
/// </summary>
|
||||
@@ -792,11 +816,13 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
/// <summary>
|
||||
/// SCSI Inquiry data
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public byte[] InqData;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
|
||||
public byte[] InqData;
|
||||
/// <summary>
|
||||
/// device serial number
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 252)] public byte[] SerialNum;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 252)]
|
||||
public byte[] SerialNum;
|
||||
/// <summary>
|
||||
/// length of the serial number
|
||||
/// </summary>
|
||||
@@ -823,19 +849,23 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
struct CcbGetdev
|
||||
{
|
||||
public CcbHdr ccb_h;
|
||||
public CcbHdr ccb_h;
|
||||
public CamProto protocol;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public byte[] inq_data;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)] public byte[] ident_data;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
|
||||
public byte[] inq_data;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)]
|
||||
public byte[] ident_data;
|
||||
/// <summary>
|
||||
/// device serial number
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 252)] public byte[] serial_num;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 252)]
|
||||
public byte[] serial_num;
|
||||
public byte inq_flags;
|
||||
/// <summary>
|
||||
/// length of the serial number
|
||||
/// </summary>
|
||||
public byte serial_num_len;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public IntPtr[] padding;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public IntPtr[] padding;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user