REFACTOR: Fixed MOST name inconsistencies.

This commit is contained in:
2017-12-20 17:15:26 +00:00
parent 542520f5cd
commit a4650c61aa
428 changed files with 16205 additions and 16320 deletions

View File

@@ -54,9 +54,9 @@ namespace DiscImageChef.Devices
internal static int SendScsiCommand(object fd, byte[] cdb, ref byte[] buffer, out byte[] senseBuffer,
uint timeout, ScsiDirection direction, out double duration, out bool sense)
{
Interop.PlatformID ptID = DetectOS.GetRealPlatformID();
Interop.PlatformID ptId = DetectOS.GetRealPlatformID();
return SendScsiCommand(ptID, fd, cdb, ref buffer, out senseBuffer, timeout, direction, out duration,
return SendScsiCommand(ptId, fd, cdb, ref buffer, out senseBuffer, timeout, direction, out duration,
out sense);
}
@@ -64,7 +64,7 @@ namespace DiscImageChef.Devices
/// Sends a SCSI command
/// </summary>
/// <returns>0 if no error occurred, otherwise, errno</returns>
/// <param name="ptID">Platform ID for executing the command</param>
/// <param name="ptId">Platform ID for executing the command</param>
/// <param name="fd">File handle</param>
/// <param name="cdb">SCSI CDB</param>
/// <param name="buffer">Buffer for SCSI command response</param>
@@ -73,11 +73,11 @@ namespace DiscImageChef.Devices
/// <param name="direction">SCSI command transfer direction</param>
/// <param name="duration">Time it took to execute the command in milliseconds</param>
/// <param name="sense"><c>True</c> if SCSI error returned non-OK status and <paramref name="senseBuffer"/> contains SCSI sense</param>
internal static int SendScsiCommand(Interop.PlatformID ptID, object fd, byte[] cdb, ref byte[] buffer,
internal static int SendScsiCommand(Interop.PlatformID ptId, object fd, byte[] cdb, ref byte[] buffer,
out byte[] senseBuffer, uint timeout, ScsiDirection direction,
out double duration, out bool sense)
{
switch(ptID)
switch(ptId)
{
case Interop.PlatformID.Win32NT:
{
@@ -127,21 +127,21 @@ namespace DiscImageChef.Devices
}
case Interop.PlatformID.FreeBSD:
{
FreeBSD.ccb_flags flags = 0;
FreeBSD.CcbFlags flags = 0;
switch(direction)
{
case ScsiDirection.In:
flags = FreeBSD.ccb_flags.CAM_DIR_IN;
flags = FreeBSD.CcbFlags.CamDirIn;
break;
case ScsiDirection.Out:
flags = FreeBSD.ccb_flags.CAM_DIR_OUT;
flags = FreeBSD.CcbFlags.CamDirOut;
break;
case ScsiDirection.Bidirectional:
flags = FreeBSD.ccb_flags.CAM_DIR_BOTH;
flags = FreeBSD.CcbFlags.CamDirBoth;
break;
case ScsiDirection.None:
flags = FreeBSD.ccb_flags.CAM_DIR_NONE;
flags = FreeBSD.CcbFlags.CamDirNone;
break;
}
@@ -151,7 +151,7 @@ namespace DiscImageChef.Devices
: FreeBSD.Command.SendScsiCommand((IntPtr)fd, cdb, ref buffer, out senseBuffer, timeout,
flags, out duration, out sense);
}
default: throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", ptID));
default: throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", ptId));
}
}
@@ -159,18 +159,18 @@ namespace DiscImageChef.Devices
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
uint timeout, bool transferBlocks, out double duration, out bool sense)
{
Interop.PlatformID ptID = DetectOS.GetRealPlatformID();
Interop.PlatformID ptId = DetectOS.GetRealPlatformID();
return SendAtaCommand(ptID, fd, registers, out errorRegisters, protocol, transferRegister, ref buffer,
return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister, ref buffer,
timeout, transferBlocks, out duration, out sense);
}
internal static int SendAtaCommand(Interop.PlatformID ptID, object fd, AtaRegistersCHS registers,
internal static int SendAtaCommand(Interop.PlatformID ptId, object fd, AtaRegistersCHS registers,
out AtaErrorRegistersCHS errorRegisters, AtaProtocol protocol,
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{
switch(ptID)
switch(ptId)
{
case Interop.PlatformID.Win32NT:
{
@@ -200,7 +200,7 @@ namespace DiscImageChef.Devices
return FreeBSD.Command.SendAtaCommand((IntPtr)fd, registers, out errorRegisters, protocol,
ref buffer, timeout, out duration, out sense);
}
default: throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", ptID));
default: throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", ptId));
}
}
@@ -209,18 +209,18 @@ namespace DiscImageChef.Devices
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{
Interop.PlatformID ptID = DetectOS.GetRealPlatformID();
Interop.PlatformID ptId = DetectOS.GetRealPlatformID();
return SendAtaCommand(ptID, fd, registers, out errorRegisters, protocol, transferRegister, ref buffer,
return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister, ref buffer,
timeout, transferBlocks, out duration, out sense);
}
internal static int SendAtaCommand(Interop.PlatformID ptID, object fd, AtaRegistersLBA28 registers,
internal static int SendAtaCommand(Interop.PlatformID ptId, object fd, AtaRegistersLBA28 registers,
out AtaErrorRegistersLBA28 errorRegisters, AtaProtocol protocol,
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{
switch(ptID)
switch(ptId)
{
case Interop.PlatformID.Win32NT:
{
@@ -250,7 +250,7 @@ namespace DiscImageChef.Devices
return FreeBSD.Command.SendAtaCommand((IntPtr)fd, registers, out errorRegisters, protocol,
ref buffer, timeout, out duration, out sense);
}
default: throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", ptID));
default: throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", ptId));
}
}
@@ -259,18 +259,18 @@ namespace DiscImageChef.Devices
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{
Interop.PlatformID ptID = DetectOS.GetRealPlatformID();
Interop.PlatformID ptId = DetectOS.GetRealPlatformID();
return SendAtaCommand(ptID, fd, registers, out errorRegisters, protocol, transferRegister, ref buffer,
return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister, ref buffer,
timeout, transferBlocks, out duration, out sense);
}
internal static int SendAtaCommand(Interop.PlatformID ptID, object fd, AtaRegistersLBA48 registers,
internal static int SendAtaCommand(Interop.PlatformID ptId, object fd, AtaRegistersLBA48 registers,
out AtaErrorRegistersLBA48 errorRegisters, AtaProtocol protocol,
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
bool transferBlocks, out double duration, out bool sense)
{
switch(ptID)
switch(ptId)
{
case Interop.PlatformID.Win32NT:
{
@@ -289,7 +289,7 @@ namespace DiscImageChef.Devices
return FreeBSD.Command.SendAtaCommand((IntPtr)fd, registers, out errorRegisters, protocol,
ref buffer, timeout, out duration, out sense);
}
default: throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", ptID));
default: throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", ptId));
}
}
@@ -297,18 +297,18 @@ namespace DiscImageChef.Devices
uint argument, uint blockSize, uint blocks, ref byte[] buffer,
out uint[] response, out double duration, out bool sense, uint timeout = 0)
{
Interop.PlatformID ptID = DetectOS.GetRealPlatformID();
Interop.PlatformID ptId = DetectOS.GetRealPlatformID();
return SendMmcCommand(ptID, (int)fd, command, write, isApplication, flags, argument, blockSize, blocks,
return SendMmcCommand(ptId, (int)fd, command, write, isApplication, flags, argument, blockSize, blocks,
ref buffer, out response, out duration, out sense, timeout);
}
internal static int SendMmcCommand(Interop.PlatformID ptID, object fd, MmcCommands command, bool write,
internal static int SendMmcCommand(Interop.PlatformID ptId, object fd, MmcCommands command, bool write,
bool isApplication, MmcFlags flags, uint argument, uint blockSize, uint blocks,
ref byte[] buffer, out uint[] response, out double duration, out bool sense,
uint timeout = 0)
{
switch(ptID)
switch(ptId)
{
case Interop.PlatformID.Win32NT:
{
@@ -322,7 +322,7 @@ namespace DiscImageChef.Devices
blockSize, blocks, ref buffer, out response, out duration,
out sense, timeout);
}
default: throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", ptID));
default: throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", ptId));
}
}
}

View File

@@ -50,7 +50,7 @@ namespace DiscImageChef.Devices
public int SendScsiCommand(byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, uint timeout,
ScsiDirection direction, out double duration, out bool sense)
{
return Command.SendScsiCommand(platformID, fd, cdb, ref buffer, out senseBuffer, timeout, direction,
return Command.SendScsiCommand(platformId, fd, cdb, ref buffer, out senseBuffer, timeout, direction,
out duration, out sense);
}
@@ -71,7 +71,7 @@ namespace DiscImageChef.Devices
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
uint timeout, bool transferBlocks, out double duration, out bool sense)
{
return Command.SendAtaCommand(platformID, fd, registers, out errorRegisters, protocol, transferRegister,
return Command.SendAtaCommand(platformId, fd, registers, out errorRegisters, protocol, transferRegister,
ref buffer, timeout, transferBlocks, out duration, out sense);
}
@@ -92,7 +92,7 @@ namespace DiscImageChef.Devices
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
uint timeout, bool transferBlocks, out double duration, out bool sense)
{
return Command.SendAtaCommand(platformID, fd, registers, out errorRegisters, protocol, transferRegister,
return Command.SendAtaCommand(platformId, fd, registers, out errorRegisters, protocol, transferRegister,
ref buffer, timeout, transferBlocks, out duration, out sense);
}
@@ -113,7 +113,7 @@ namespace DiscImageChef.Devices
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
uint timeout, bool transferBlocks, out double duration, out bool sense)
{
return Command.SendAtaCommand(platformID, fd, registers, out errorRegisters, protocol, transferRegister,
return Command.SendAtaCommand(platformId, fd, registers, out errorRegisters, protocol, transferRegister,
ref buffer, timeout, transferBlocks, out duration, out sense);
}
@@ -137,7 +137,7 @@ namespace DiscImageChef.Devices
uint blockSize, uint blocks, ref byte[] buffer, out uint[] response,
out double duration, out bool sense, uint timeout = 0)
{
if(command == MmcCommands.SendCID && cachedCid != null)
if(command == MmcCommands.SendCid && cachedCid != null)
{
System.DateTime start = System.DateTime.Now;
buffer = new byte[cachedCid.Length];
@@ -149,7 +149,7 @@ namespace DiscImageChef.Devices
return 0;
}
if(command == MmcCommands.SendCSD && cachedCid != null)
if(command == MmcCommands.SendCsd && cachedCid != null)
{
System.DateTime start = System.DateTime.Now;
buffer = new byte[cachedCsd.Length];
@@ -161,7 +161,7 @@ namespace DiscImageChef.Devices
return 0;
}
if(command == (MmcCommands)SecureDigitalCommands.SendSCR && cachedScr != null)
if(command == (MmcCommands)SecureDigitalCommands.SendScr && cachedScr != null)
{
System.DateTime start = System.DateTime.Now;
buffer = new byte[cachedScr.Length];
@@ -186,7 +186,7 @@ namespace DiscImageChef.Devices
return 0;
}
return Command.SendMmcCommand(platformID, fd, command, write, isApplication, flags, argument, blockSize,
return Command.SendMmcCommand(platformId, fd, command, write, isApplication, flags, argument, blockSize,
blocks, ref buffer, out response, out duration, out sense, timeout);
}
}

View File

@@ -46,12 +46,12 @@ namespace DiscImageChef.Devices
/// <param name="devicePath">Device path</param>
public Device(string devicePath)
{
platformID = Interop.DetectOS.GetRealPlatformID();
platformId = Interop.DetectOS.GetRealPlatformID();
Timeout = 15;
error = false;
removable = false;
switch(platformID)
switch(platformId)
{
case Interop.PlatformID.Win32NT:
{
@@ -91,17 +91,17 @@ namespace DiscImageChef.Devices
lastError = Marshal.GetLastWin32Error();
}
FreeBSD.cam_device camDevice =
(FreeBSD.cam_device)Marshal.PtrToStructure((IntPtr)fd, typeof(FreeBSD.cam_device));
FreeBSD.CamDevice camDevice =
(FreeBSD.CamDevice)Marshal.PtrToStructure((IntPtr)fd, typeof(FreeBSD.CamDevice));
if(StringHandlers.CToString(camDevice.sim_name) == "ata")
if(StringHandlers.CToString(camDevice.SimName) == "ata")
throw new
InvalidOperationException("Parallel ATA devices are not supported on FreeBSD due to upstream bug #224250.");
break;
}
default:
throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", platformID));
throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", platformId));
}
if(error) throw new SystemException(string.Format("Error {0} opening device.", lastError));
@@ -121,7 +121,7 @@ namespace DiscImageChef.Devices
string ntDevicePath = null;
// Windows is answering SCSI INQUIRY for all device types so it needs to be detected first
if(platformID == Interop.PlatformID.Win32NT)
if(platformId == Interop.PlatformID.Win32NT)
{
Windows.StoragePropertyQuery query = new Windows.StoragePropertyQuery();
query.PropertyId = Windows.StoragePropertyId.Device;
@@ -129,39 +129,39 @@ namespace DiscImageChef.Devices
query.AdditionalParameters = new byte[1];
IntPtr descriptorPtr = Marshal.AllocHGlobal(1000);
byte[] descriptor_b = new byte[1000];
byte[] descriptorB = new byte[1000];
uint returned = 0;
int error = 0;
bool hasError = !Windows.Extern.DeviceIoControlStorageQuery((SafeFileHandle)fd,
Windows.WindowsIoctl
.IOCTL_STORAGE_QUERY_PROPERTY,
.IoctlStorageQueryProperty,
ref query, (uint)Marshal.SizeOf(query),
descriptorPtr, 1000, ref returned,
IntPtr.Zero);
if(hasError) error = Marshal.GetLastWin32Error();
Marshal.Copy(descriptorPtr, descriptor_b, 0, 1000);
Marshal.Copy(descriptorPtr, descriptorB, 0, 1000);
if(!hasError && error == 0)
{
Windows.StorageDeviceDescriptor descriptor = new Windows.StorageDeviceDescriptor();
descriptor.Version = BitConverter.ToUInt32(descriptor_b, 0);
descriptor.Size = BitConverter.ToUInt32(descriptor_b, 4);
descriptor.DeviceType = descriptor_b[8];
descriptor.DeviceTypeModifier = descriptor_b[9];
descriptor.RemovableMedia = descriptor_b[10] > 0;
descriptor.CommandQueueing = descriptor_b[11] > 0;
descriptor.VendorIdOffset = BitConverter.ToUInt32(descriptor_b, 12);
descriptor.ProductIdOffset = BitConverter.ToUInt32(descriptor_b, 16);
descriptor.ProductRevisionOffset = BitConverter.ToUInt32(descriptor_b, 20);
descriptor.SerialNumberOffset = BitConverter.ToUInt32(descriptor_b, 24);
descriptor.BusType = (Windows.StorageBusType)BitConverter.ToUInt32(descriptor_b, 28);
descriptor.RawPropertiesLength = BitConverter.ToUInt32(descriptor_b, 32);
descriptor.Version = BitConverter.ToUInt32(descriptorB, 0);
descriptor.Size = BitConverter.ToUInt32(descriptorB, 4);
descriptor.DeviceType = descriptorB[8];
descriptor.DeviceTypeModifier = descriptorB[9];
descriptor.RemovableMedia = descriptorB[10] > 0;
descriptor.CommandQueueing = descriptorB[11] > 0;
descriptor.VendorIdOffset = BitConverter.ToUInt32(descriptorB, 12);
descriptor.ProductIdOffset = BitConverter.ToUInt32(descriptorB, 16);
descriptor.ProductRevisionOffset = BitConverter.ToUInt32(descriptorB, 20);
descriptor.SerialNumberOffset = BitConverter.ToUInt32(descriptorB, 24);
descriptor.BusType = (Windows.StorageBusType)BitConverter.ToUInt32(descriptorB, 28);
descriptor.RawPropertiesLength = BitConverter.ToUInt32(descriptorB, 32);
descriptor.RawDeviceProperties = new byte[descriptor.RawPropertiesLength];
Array.Copy(descriptor_b, 36, descriptor.RawDeviceProperties, 0, descriptor.RawPropertiesLength);
Array.Copy(descriptorB, 36, descriptor.RawDeviceProperties, 0, descriptor.RawPropertiesLength);
switch(descriptor.BusType)
{
@@ -207,9 +207,9 @@ namespace DiscImageChef.Devices
if(!atapiSense)
{
type = DeviceType.ATAPI;
Identify.IdentifyDevice? ATAID = Identify.Decode(ataBuf);
Identify.IdentifyDevice? ataid = Identify.Decode(ataBuf);
if(ATAID.HasValue) scsiSense = ScsiInquiry(out inqBuf, out senseBuf);
if(ataid.HasValue) scsiSense = ScsiInquiry(out inqBuf, out senseBuf);
}
else manufacturer = "ATA";
}
@@ -224,9 +224,9 @@ namespace DiscImageChef.Devices
byte[] sdBuffer = new byte[16];
bool sense = false;
lastError = Windows.Command.SendMmcCommand((SafeFileHandle)fd, MmcCommands.SendCSD, false, false,
MmcFlags.ResponseSPI_R2 | MmcFlags.Response_R2 |
MmcFlags.CommandAC, 0, 16, 1, ref sdBuffer,
lastError = Windows.Command.SendMmcCommand((SafeFileHandle)fd, MmcCommands.SendCsd, false, false,
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 |
MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer,
out uint[] response, out double duration, out sense, 0);
if(!sense)
@@ -238,9 +238,9 @@ namespace DiscImageChef.Devices
sdBuffer = new byte[16];
sense = false;
lastError = Windows.Command.SendMmcCommand((SafeFileHandle)fd, MmcCommands.SendCID, false, false,
MmcFlags.ResponseSPI_R2 | MmcFlags.Response_R2 |
MmcFlags.CommandAC, 0, 16, 1, ref sdBuffer, out response,
lastError = Windows.Command.SendMmcCommand((SafeFileHandle)fd, MmcCommands.SendCid, false, false,
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 |
MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer, out response,
out duration, out sense, 0);
if(!sense)
@@ -253,9 +253,9 @@ namespace DiscImageChef.Devices
sense = false;
lastError = Windows.Command.SendMmcCommand((SafeFileHandle)fd,
(MmcCommands)SecureDigitalCommands.SendSCR, false, true,
MmcFlags.ResponseSPI_R1 | MmcFlags.Response_R1 |
MmcFlags.CommandADTC, 0, 8, 1, ref sdBuffer,
(MmcCommands)SecureDigitalCommands.SendScr, false, true,
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 |
MmcFlags.CommandAdtc, 0, 8, 1, ref sdBuffer,
out response, out duration, out sense, 0);
if(!sense)
@@ -272,8 +272,8 @@ namespace DiscImageChef.Devices
lastError = Windows.Command.SendMmcCommand((SafeFileHandle)fd,
(MmcCommands)SecureDigitalCommands
.SendOperatingCondition, false, true,
MmcFlags.ResponseSPI_R3 | MmcFlags.Response_R3 |
MmcFlags.CommandBCR, 0, 4, 1, ref sdBuffer,
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 |
MmcFlags.CommandBcr, 0, 4, 1, ref sdBuffer,
out response, out duration, out sense, 0);
if(!sense)
@@ -289,8 +289,8 @@ namespace DiscImageChef.Devices
lastError = Windows.Command.SendMmcCommand((SafeFileHandle)fd, MmcCommands.SendOpCond, false,
true,
MmcFlags.ResponseSPI_R3 | MmcFlags.Response_R3 |
MmcFlags.CommandBCR, 0, 4, 1, ref sdBuffer,
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 |
MmcFlags.CommandBcr, 0, 4, 1, ref sdBuffer,
out response, out duration, out sense, 0);
if(!sense)
@@ -301,7 +301,7 @@ namespace DiscImageChef.Devices
}
}
}
else if(platformID == Interop.PlatformID.Linux)
else if(platformId == Interop.PlatformID.Linux)
{
if(devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) ||
devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) ||
@@ -313,22 +313,22 @@ namespace DiscImageChef.Devices
string devPath = devicePath.Substring(5);
if(System.IO.File.Exists("/sys/block/" + devPath + "/device/csd"))
{
int len = ConvertFromHexASCII("/sys/block/" + devPath + "/device/csd", out cachedCsd);
int len = ConvertFromHexAscii("/sys/block/" + devPath + "/device/csd", out cachedCsd);
if(len == 0) cachedCsd = null;
}
if(System.IO.File.Exists("/sys/block/" + devPath + "/device/cid"))
{
int len = ConvertFromHexASCII("/sys/block/" + devPath + "/device/cid", out cachedCid);
int len = ConvertFromHexAscii("/sys/block/" + devPath + "/device/cid", out cachedCid);
if(len == 0) cachedCid = null;
}
if(System.IO.File.Exists("/sys/block/" + devPath + "/device/scr"))
{
int len = ConvertFromHexASCII("/sys/block/" + devPath + "/device/scr", out cachedScr);
int len = ConvertFromHexAscii("/sys/block/" + devPath + "/device/scr", out cachedScr);
if(len == 0) cachedScr = null;
}
if(System.IO.File.Exists("/sys/block/" + devPath + "/device/ocr"))
{
int len = ConvertFromHexASCII("/sys/block/" + devPath + "/device/ocr", out cachedOcr);
int len = ConvertFromHexAscii("/sys/block/" + devPath + "/device/ocr", out cachedOcr);
if(len == 0) cachedOcr = null;
}
}
@@ -365,7 +365,7 @@ namespace DiscImageChef.Devices
#endregion SecureDigital / MultiMediaCard
#region USB
if(platformID == Interop.PlatformID.Linux)
if(platformId == Interop.PlatformID.Linux)
{
if(devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) ||
devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) ||
@@ -439,15 +439,15 @@ namespace DiscImageChef.Devices
}
}
}
else if(platformID == Interop.PlatformID.Win32NT)
else if(platformId == Interop.PlatformID.Win32NT)
{
Windows.Usb.USBDevice usbDevice = null;
Windows.Usb.UsbDevice usbDevice = null;
// I have to search for USB disks, floppies and CD-ROMs as separate device types
foreach(string devGuid in new[]
{
Windows.Usb.GUID_DEVINTERFACE_FLOPPY, Windows.Usb.GUID_DEVINTERFACE_CDROM,
Windows.Usb.GUID_DEVINTERFACE_DISK
Windows.Usb.GuidDevinterfaceFloppy, Windows.Usb.GuidDevinterfaceCdrom,
Windows.Usb.GuidDevinterfaceDisk
})
{
usbDevice = Windows.Usb.FindDrivePath(devicePath, devGuid);
@@ -470,7 +470,7 @@ namespace DiscImageChef.Devices
#endregion USB
#region FireWire
if(platformID == Interop.PlatformID.Linux)
if(platformId == Interop.PlatformID.Linux)
{
if(devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) ||
devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) ||
@@ -539,7 +539,7 @@ namespace DiscImageChef.Devices
#endregion FireWire
#region PCMCIA
if(platformID == Interop.PlatformID.Linux)
if(platformId == Interop.PlatformID.Linux)
{
if(devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) ||
devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) ||
@@ -596,23 +596,23 @@ namespace DiscImageChef.Devices
if(!scsiSense)
{
Decoders.SCSI.Inquiry.SCSIInquiry? Inquiry = Decoders.SCSI.Inquiry.Decode(inqBuf);
Decoders.SCSI.Inquiry.SCSIInquiry? inquiry = Decoders.SCSI.Inquiry.Decode(inqBuf);
type = DeviceType.SCSI;
bool serialSense = ScsiInquiry(out inqBuf, out senseBuf, 0x80);
if(!serialSense) serial = Decoders.SCSI.EVPD.DecodePage80(inqBuf);
if(Inquiry.HasValue)
if(inquiry.HasValue)
{
string tmp = StringHandlers.CToString(Inquiry.Value.ProductRevisionLevel);
string tmp = StringHandlers.CToString(inquiry.Value.ProductRevisionLevel);
if(tmp != null) revision = tmp.Trim();
tmp = StringHandlers.CToString(Inquiry.Value.ProductIdentification);
tmp = StringHandlers.CToString(inquiry.Value.ProductIdentification);
if(tmp != null) model = tmp.Trim();
tmp = StringHandlers.CToString(Inquiry.Value.VendorIdentification);
tmp = StringHandlers.CToString(inquiry.Value.VendorIdentification);
if(tmp != null) manufacturer = tmp.Trim();
removable = Inquiry.Value.RMB;
removable = inquiry.Value.RMB;
scsiType = (Decoders.SCSI.PeripheralDeviceTypes)Inquiry.Value.PeripheralDeviceType;
scsiType = (Decoders.SCSI.PeripheralDeviceTypes)inquiry.Value.PeripheralDeviceType;
}
bool atapiSense = AtapiIdentify(out ataBuf, out errorRegisters);
@@ -620,9 +620,9 @@ namespace DiscImageChef.Devices
if(!atapiSense)
{
type = DeviceType.ATAPI;
Identify.IdentifyDevice? ATAID = Identify.Decode(ataBuf);
Identify.IdentifyDevice? ataId = Identify.Decode(ataBuf);
if(ATAID.HasValue) serial = ATAID.Value.SerialNumber;
if(ataId.HasValue) serial = ataId.Value.SerialNumber;
}
else
{
@@ -637,11 +637,11 @@ namespace DiscImageChef.Devices
if(!ataSense)
{
type = DeviceType.ATA;
Identify.IdentifyDevice? ATAID = Identify.Decode(ataBuf);
Identify.IdentifyDevice? ataid = Identify.Decode(ataBuf);
if(ATAID.HasValue)
if(ataid.HasValue)
{
string[] separated = ATAID.Value.Model.Split(' ');
string[] separated = ataid.Value.Model.Split(' ');
if(separated.Length == 1) model = separated[0];
else
@@ -650,15 +650,15 @@ namespace DiscImageChef.Devices
model = separated[separated.Length - 1];
}
revision = ATAID.Value.FirmwareRevision;
serial = ATAID.Value.SerialNumber;
revision = ataid.Value.FirmwareRevision;
serial = ataid.Value.SerialNumber;
scsiType = Decoders.SCSI.PeripheralDeviceTypes.DirectAccess;
if((ushort)ATAID.Value.GeneralConfiguration != 0x848A)
if((ushort)ataid.Value.GeneralConfiguration != 0x848A)
{
removable |=
(ATAID.Value.GeneralConfiguration & Identify.GeneralConfigurationBit.Removable) ==
(ataid.Value.GeneralConfiguration & Identify.GeneralConfigurationBit.Removable) ==
Identify.GeneralConfigurationBit.Removable;
}
else compactFlash = true;
@@ -694,7 +694,7 @@ namespace DiscImageChef.Devices
}
}
static int ConvertFromHexASCII(string file, out byte[] outBuf)
static int ConvertFromHexAscii(string file, out byte[] outBuf)
{
System.IO.StreamReader sr = new System.IO.StreamReader(file);
string ins = sr.ReadToEnd().Trim();

View File

@@ -45,7 +45,7 @@ namespace DiscImageChef.Devices
{
if(fd != null)
{
switch(platformID)
switch(platformId)
{
case Interop.PlatformID.Win32NT:
Windows.Extern.CloseHandle((SafeFileHandle)fd);

View File

@@ -36,12 +36,12 @@ namespace DiscImageChef.Devices
{
public struct DeviceInfo
{
public string path;
public string vendor;
public string model;
public string serial;
public string bus;
public bool supported;
public string Path;
public string Vendor;
public string Model;
public string Serial;
public string Bus;
public bool Supported;
}
public partial class Device

View File

@@ -36,13 +36,13 @@ namespace DiscImageChef.Devices
{
public partial class Device
{
public bool ReadCSD(out byte[] buffer, out uint[] response, uint timeout, out double duration)
public bool ReadCsd(out byte[] buffer, out uint[] response, uint timeout, out double duration)
{
buffer = new byte[16];
bool sense = false;
lastError = SendMmcCommand(MmcCommands.SendCSD, false, false,
MmcFlags.ResponseSPI_R2 | MmcFlags.Response_R2 | MmcFlags.CommandAC, 0, 16, 1,
lastError = SendMmcCommand(MmcCommands.SendCsd, false, false,
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1,
ref buffer, out response, out duration, out sense, timeout);
error = lastError != 0;
@@ -51,13 +51,13 @@ namespace DiscImageChef.Devices
return sense;
}
public bool ReadCID(out byte[] buffer, out uint[] response, uint timeout, out double duration)
public bool ReadCid(out byte[] buffer, out uint[] response, uint timeout, out double duration)
{
buffer = new byte[16];
bool sense = false;
lastError = SendMmcCommand(MmcCommands.SendCID, false, false,
MmcFlags.ResponseSPI_R2 | MmcFlags.Response_R2 | MmcFlags.CommandAC, 0, 16, 1,
lastError = SendMmcCommand(MmcCommands.SendCid, false, false,
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1,
ref buffer, out response, out duration, out sense, timeout);
error = lastError != 0;
@@ -66,13 +66,13 @@ namespace DiscImageChef.Devices
return sense;
}
public bool ReadOCR(out byte[] buffer, out uint[] response, uint timeout, out double duration)
public bool ReadOcr(out byte[] buffer, out uint[] response, uint timeout, out double duration)
{
buffer = new byte[4];
bool sense = false;
lastError = SendMmcCommand(MmcCommands.SendOpCond, false, true,
MmcFlags.ResponseSPI_R3 | MmcFlags.Response_R3 | MmcFlags.CommandBCR, 0, 4, 1,
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0, 4, 1,
ref buffer, out response, out duration, out sense, timeout);
error = lastError != 0;
@@ -81,13 +81,13 @@ namespace DiscImageChef.Devices
return sense;
}
public bool ReadExtendedCSD(out byte[] buffer, out uint[] response, uint timeout, out double duration)
public bool ReadExtendedCsd(out byte[] buffer, out uint[] response, uint timeout, out double duration)
{
buffer = new byte[512];
bool sense = false;
lastError = SendMmcCommand(MmcCommands.SendExtCSD, false, false,
MmcFlags.ResponseSPI_R1 | MmcFlags.Response_R1 | MmcFlags.CommandADTC, 0, 512, 1,
lastError = SendMmcCommand(MmcCommands.SendExtCsd, false, false,
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 512, 1,
ref buffer, out response, out duration, out sense, timeout);
error = lastError != 0;
@@ -102,7 +102,7 @@ namespace DiscImageChef.Devices
bool sense = false;
lastError = SendMmcCommand(MmcCommands.SetBlocklen, false, false,
MmcFlags.ResponseSPI_R1 | MmcFlags.Response_R1 | MmcFlags.CommandAC, length, 0,
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, length, 0,
0, ref buffer, out response, out duration, out sense, timeout);
error = lastError != 0;
@@ -125,7 +125,7 @@ namespace DiscImageChef.Devices
else command = MmcCommands.ReadSingleBlock;
lastError = SendMmcCommand(command, false, false,
MmcFlags.ResponseSPI_R1 | MmcFlags.Response_R1 | MmcFlags.CommandADTC, address,
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, address,
blockSize, transferLength, ref buffer, out response, out duration, out sense,
timeout);
error = lastError != 0;
@@ -134,7 +134,7 @@ namespace DiscImageChef.Devices
{
byte[] foo = new byte[0];
SendMmcCommand(MmcCommands.StopTransmission, false, false,
MmcFlags.Response_R1b | MmcFlags.ResponseSPI_R1b | MmcFlags.CommandAC, 0, 0, 0, ref foo,
MmcFlags.ResponseR1B | MmcFlags.ResponseSpiR1B | MmcFlags.CommandAc, 0, 0, 0, ref foo,
out uint[] responseStop, out double stopDuration, out bool stopSense, timeout);
duration += stopDuration;
DicConsole.DebugWriteLine("MMC Device", "READ_MULTIPLE_BLOCK took {0} ms.", duration);
@@ -150,7 +150,7 @@ namespace DiscImageChef.Devices
bool sense = false;
lastError = SendMmcCommand(MmcCommands.SendStatus, false, true,
MmcFlags.ResponseSPI_R1 | MmcFlags.Response_R1 | MmcFlags.CommandAC, 0, 4, 1,
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, 0, 4, 1,
ref buffer, out response, out duration, out sense, timeout);
error = lastError != 0;

View File

@@ -36,13 +36,13 @@ namespace DiscImageChef.Devices
{
public partial class Device
{
public bool ReadSDStatus(out byte[] buffer, out uint[] response, uint timeout, out double duration)
public bool ReadSdStatus(out byte[] buffer, out uint[] response, uint timeout, out double duration)
{
buffer = new byte[64];
bool sense = false;
lastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendStatus, false, true,
MmcFlags.ResponseSPI_R1 | MmcFlags.Response_R1 | MmcFlags.CommandADTC, 0, 64, 1,
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 64, 1,
ref buffer, out response, out duration, out sense, timeout);
error = lastError != 0;
@@ -51,13 +51,13 @@ namespace DiscImageChef.Devices
return sense;
}
public bool ReadSDOCR(out byte[] buffer, out uint[] response, uint timeout, out double duration)
public bool ReadSdocr(out byte[] buffer, out uint[] response, uint timeout, out double duration)
{
buffer = new byte[4];
bool sense = false;
lastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendOperatingCondition, false, true,
MmcFlags.ResponseSPI_R3 | MmcFlags.Response_R3 | MmcFlags.CommandBCR, 0, 4, 1,
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0, 4, 1,
ref buffer, out response, out duration, out sense, timeout);
error = lastError != 0;
@@ -66,13 +66,13 @@ namespace DiscImageChef.Devices
return sense;
}
public bool ReadSCR(out byte[] buffer, out uint[] response, uint timeout, out double duration)
public bool ReadScr(out byte[] buffer, out uint[] response, uint timeout, out double duration)
{
buffer = new byte[8];
bool sense = false;
lastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendSCR, false, true,
MmcFlags.ResponseSPI_R1 | MmcFlags.Response_R1 | MmcFlags.CommandADTC, 0, 8, 1,
lastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendScr, false, true,
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 8, 1,
ref buffer, out response, out duration, out sense, timeout);
error = lastError != 0;

View File

@@ -69,7 +69,7 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.Adaptec_Translate;
cdb[0] = (byte)ScsiCommands.AdaptecTranslate;
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
cdb[2] = (byte)((lba & 0xFF00) >> 8);
cdb[3] = (byte)(lba & 0xFF);
@@ -115,7 +115,7 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.Adaptec_SetErrorThreshold;
cdb[0] = (byte)ScsiCommands.AdaptecSetErrorThreshold;
if(drive1) cdb[1] += 0x20;
cdb[4] = 1;
@@ -157,7 +157,7 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.Adaptec_Translate;
cdb[0] = (byte)ScsiCommands.AdaptecTranslate;
if(drive1) cdb[1] += 0x20;
cdb[4] = (byte)buffer.Length;
@@ -187,7 +187,7 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.Adaptec_WriteBuffer;
cdb[0] = (byte)ScsiCommands.AdaptecWriteBuffer;
lastError = SendScsiCommand(cdb, ref oneKBuffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
out sense);
@@ -212,7 +212,7 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.Adaptec_ReadBuffer;
cdb[0] = (byte)ScsiCommands.AdaptecReadBuffer;
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);

View File

@@ -51,7 +51,7 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.Archive_RequestBlockAddress;
cdb[0] = (byte)ScsiCommands.ArchiveRequestBlockAddress;
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
cdb[2] = (byte)((lba & 0xFF00) >> 8);
cdb[3] = (byte)(lba & 0xFF);
@@ -94,7 +94,7 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.Archive_SeekBlock;
cdb[0] = (byte)ScsiCommands.ArchiveSeekBlock;
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
cdb[2] = (byte)((lba & 0xFF00) >> 8);
cdb[3] = (byte)(lba & 0xFF);

View File

@@ -72,7 +72,7 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.Certance_ParkUnpark;
cdb[0] = (byte)ScsiCommands.CertanceParkUnpark;
if(park) cdb[4] = 1;
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,

View File

@@ -96,7 +96,7 @@ namespace DiscImageChef.Devices
Array.Copy(firstHalfBytes, 0, buffer, 1, 8);
Array.Copy(secondHalfBytes, 0, buffer, 9, 8);
cdb[0] = (byte)ScsiCommands.Fujitsu_Display;
cdb[0] = (byte)ScsiCommands.FujitsuDisplay;
cdb[6] = (byte)buffer.Length;
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,

View File

@@ -54,7 +54,7 @@ namespace DiscImageChef.Devices
buffer = new byte[2064 * transferLength];
bool sense;
cdb[0] = (byte)ScsiCommands.HlDtSt_Vendor;
cdb[0] = (byte)ScsiCommands.HlDtStVendor;
cdb[1] = 0x48;
cdb[2] = 0x49;
cdb[3] = 0x54;

View File

@@ -48,10 +48,10 @@ namespace DiscImageChef.Devices
/// <param name="pba">If set to <c>true</c> address contain physical block address.</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool HPReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address, ushort blockBytes,
public bool HpReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address, ushort blockBytes,
bool pba, uint timeout, out double duration)
{
return HPReadLong(out buffer, out senseBuffer, relAddr, address, 0, blockBytes, pba, false, timeout,
return HpReadLong(out buffer, out senseBuffer, relAddr, address, 0, blockBytes, pba, false, timeout,
out duration);
}
@@ -69,7 +69,7 @@ namespace DiscImageChef.Devices
/// <param name="sectorCount">If set to <c>true</c> <paramref name="transferLen"/> is a count of secors to read. Otherwise it will be ignored</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool HPReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address,
public bool HpReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address,
ushort transferLen, ushort blockBytes, bool pba, bool sectorCount, uint timeout,
out double duration)
{

View File

@@ -51,7 +51,7 @@ namespace DiscImageChef.Devices
byte[] buffer = new byte[0];
bool sense;
cdb[0] = (byte)ScsiCommands.Kreon_Command;
cdb[0] = (byte)ScsiCommands.KreonCommand;
cdb[1] = 0x08;
cdb[2] = 0x01;
cdb[3] = 0x01;
@@ -116,7 +116,7 @@ namespace DiscImageChef.Devices
byte[] buffer = new byte[0];
bool sense;
cdb[0] = (byte)ScsiCommands.Kreon_Command;
cdb[0] = (byte)ScsiCommands.KreonCommand;
cdb[1] = 0x08;
cdb[2] = 0x01;
cdb[3] = 0x11;
@@ -148,7 +148,7 @@ namespace DiscImageChef.Devices
bool sense;
features = 0;
cdb[0] = (byte)ScsiCommands.Kreon_Command;
cdb[0] = (byte)ScsiCommands.KreonCommand;
cdb[1] = 0x08;
cdb[2] = 0x01;
cdb[3] = 0x10;
@@ -178,7 +178,7 @@ namespace DiscImageChef.Devices
features |= KreonFeatures.WxripperUnlock360;
break;
case 0x2001:
features |= KreonFeatures.DecryptSS360;
features |= KreonFeatures.DecryptSs360;
break;
case 0x2101:
features |= KreonFeatures.ChallengeResponse360;
@@ -190,7 +190,7 @@ namespace DiscImageChef.Devices
features |= KreonFeatures.WxripperUnlock;
break;
case 0x2002:
features |= KreonFeatures.DecryptSS;
features |= KreonFeatures.DecryptSs;
break;
case 0x2102:
features |= KreonFeatures.ChallengeResponse;
@@ -215,7 +215,7 @@ namespace DiscImageChef.Devices
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
/// <param name="buffer">The SS sector.</param>
public bool KreonExtractSS(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration,
public bool KreonExtractSs(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration,
byte requestNumber = 0x00)
{
buffer = new byte[2048];
@@ -223,7 +223,7 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.Kreon_SS_Command;
cdb[0] = (byte)ScsiCommands.KreonSsCommand;
cdb[1] = 0x00;
cdb[2] = 0xFF;
cdb[3] = 0x02;

View File

@@ -76,9 +76,9 @@ namespace DiscImageChef.Devices
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
/// <param name="startingFeatureNumber">Starting Feature number.</param>
/// <param name="RT">Return type, <see cref="MmcGetConfigurationRt"/>.</param>
/// <param name="rt">Return type, <see cref="MmcGetConfigurationRt"/>.</param>
public bool GetConfiguration(out byte[] buffer, out byte[] senseBuffer, ushort startingFeatureNumber,
MmcGetConfigurationRt RT, uint timeout, out double duration)
MmcGetConfigurationRt rt, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
@@ -86,7 +86,7 @@ namespace DiscImageChef.Devices
bool sense;
cdb[0] = (byte)ScsiCommands.GetConfiguration;
cdb[1] = (byte)((byte)RT & 0x03);
cdb[1] = (byte)((byte)rt & 0x03);
cdb[2] = (byte)((startingFeatureNumber & 0xFF00) >> 8);
cdb[3] = (byte)(startingFeatureNumber & 0xFF);
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
@@ -127,10 +127,10 @@ namespace DiscImageChef.Devices
/// <param name="layerNumber">Medium layer for requested disc structure</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="format">Which disc structure are we requesting</param>
/// <param name="AGID">AGID used in medium copy protection</param>
/// <param name="agid">AGID used in medium copy protection</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool ReadDiscStructure(out byte[] buffer, out byte[] senseBuffer, MmcDiscStructureMediaType mediaType,
uint address, byte layerNumber, MmcDiscStructureFormat format, byte AGID,
uint address, byte layerNumber, MmcDiscStructureFormat format, byte agid,
uint timeout, out double duration)
{
senseBuffer = new byte[32];
@@ -148,7 +148,7 @@ namespace DiscImageChef.Devices
cdb[7] = (byte)format;
cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[9] = (byte)(buffer.Length & 0xFF);
cdb[10] = (byte)((AGID & 0x03) << 6);
cdb[10] = (byte)((agid & 0x03) << 6);
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
@@ -193,14 +193,14 @@ namespace DiscImageChef.Devices
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
/// <param name="buffer">Buffer where the SCSI READ TOC/PMA/ATIP response will be stored</param>
/// <param name="senseBuffer">Sense buffer.</param>
/// <param name="MSF">If <c>true</c>, request data in MM:SS:FF units, otherwise, in blocks</param>
/// <param name="msf">If <c>true</c>, request data in MM:SS:FF units, otherwise, in blocks</param>
/// <param name="track">Start TOC from this track</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool ReadToc(out byte[] buffer, out byte[] senseBuffer, bool MSF, byte track, uint timeout,
public bool ReadToc(out byte[] buffer, out byte[] senseBuffer, bool msf, byte track, uint timeout,
out double duration)
{
return ReadTocPmaAtip(out buffer, out senseBuffer, MSF, 0, track, timeout, out duration);
return ReadTocPmaAtip(out buffer, out senseBuffer, msf, 0, track, timeout, out duration);
}
/// <summary>
@@ -222,13 +222,13 @@ namespace DiscImageChef.Devices
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
/// <param name="buffer">Buffer where the SCSI READ TOC/PMA/ATIP response will be stored</param>
/// <param name="senseBuffer">Sense buffer.</param>
/// <param name="MSF">If <c>true</c>, request data in MM:SS:FF units, otherwise, in blocks</param>
/// <param name="msf">If <c>true</c>, request data in MM:SS:FF units, otherwise, in blocks</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool ReadSessionInfo(out byte[] buffer, out byte[] senseBuffer, bool MSF, uint timeout,
public bool ReadSessionInfo(out byte[] buffer, out byte[] senseBuffer, bool msf, uint timeout,
out double duration)
{
return ReadTocPmaAtip(out buffer, out senseBuffer, MSF, 1, 0, timeout, out duration);
return ReadTocPmaAtip(out buffer, out senseBuffer, msf, 1, 0, timeout, out duration);
}
/// <summary>
@@ -291,12 +291,12 @@ namespace DiscImageChef.Devices
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
/// <param name="buffer">Buffer where the SCSI READ TOC/PMA/ATIP response will be stored</param>
/// <param name="senseBuffer">Sense buffer.</param>
/// <param name="MSF">If <c>true</c>, request data in MM:SS:FF units, otherwise, in blocks</param>
/// <param name="msf">If <c>true</c>, request data in MM:SS:FF units, otherwise, in blocks</param>
/// <param name="format">What structure is requested</param>
/// <param name="trackSessionNumber">Track/Session number</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool ReadTocPmaAtip(out byte[] buffer, out byte[] senseBuffer, bool MSF, byte format,
public bool ReadTocPmaAtip(out byte[] buffer, out byte[] senseBuffer, bool msf, byte format,
byte trackSessionNumber, uint timeout, out double duration)
{
senseBuffer = new byte[32];
@@ -308,7 +308,7 @@ namespace DiscImageChef.Devices
else tmpBuffer = new byte[1024];
cdb[0] = (byte)ScsiCommands.ReadTocPmaAtip;
if(MSF) cdb[1] = 0x02;
if(msf) cdb[1] = 0x02;
cdb[2] = (byte)(format & 0x0F);
cdb[6] = trackSessionNumber;
cdb[7] = (byte)((tmpBuffer.Length & 0xFF00) >> 8);
@@ -404,17 +404,17 @@ namespace DiscImageChef.Devices
/// <param name="transferLength">How many blocks to read.</param>
/// <param name="blockSize">Block size.</param>
/// <param name="expectedSectorType">Expected sector type.</param>
/// <param name="DAP">If set to <c>true</c> CD-DA should be modified by mute and interpolation</param>
/// <param name="dap">If set to <c>true</c> CD-DA should be modified by mute and interpolation</param>
/// <param name="relAddr">If set to <c>true</c> address is relative to current position.</param>
/// <param name="sync">If set to <c>true</c> we request the sync bytes for data sectors.</param>
/// <param name="headerCodes">Header codes.</param>
/// <param name="userData">If set to <c>true</c> we request the user data.</param>
/// <param name="edcEcc">If set to <c>true</c> we request the EDC/ECC fields for data sectors.</param>
/// <param name="C2Error">C2 error options.</param>
/// <param name="c2Error">C2 error options.</param>
/// <param name="subchannel">Subchannel selection.</param>
public bool ReadCd(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize, uint transferLength,
MmcSectorTypes expectedSectorType, bool DAP, bool relAddr, bool sync,
MmcHeaderCodes headerCodes, bool userData, bool edcEcc, MmcErrorField C2Error,
MmcSectorTypes expectedSectorType, bool dap, bool relAddr, bool sync,
MmcHeaderCodes headerCodes, bool userData, bool edcEcc, MmcErrorField c2Error,
MmcSubchannel subchannel, uint timeout, out double duration)
{
senseBuffer = new byte[32];
@@ -423,7 +423,7 @@ namespace DiscImageChef.Devices
cdb[0] = (byte)ScsiCommands.ReadCd;
cdb[1] = (byte)((byte)expectedSectorType << 2);
if(DAP) cdb[1] += 0x02;
if(dap) cdb[1] += 0x02;
if(relAddr) cdb[1] += 0x01;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
@@ -432,7 +432,7 @@ namespace DiscImageChef.Devices
cdb[6] = (byte)((transferLength & 0xFF0000) >> 16);
cdb[7] = (byte)((transferLength & 0xFF00) >> 8);
cdb[8] = (byte)(transferLength & 0xFF);
cdb[9] = (byte)((byte)C2Error << 1);
cdb[9] = (byte)((byte)c2Error << 1);
cdb[9] += (byte)((byte)headerCodes << 5);
if(sync) cdb[9] += 0x80;
if(userData) cdb[9] += 0x10;
@@ -462,16 +462,16 @@ namespace DiscImageChef.Devices
/// <param name="endMsf">End MM:SS:FF of read encoded as 0x00MMSSFF.</param>
/// <param name="blockSize">Block size.</param>
/// <param name="expectedSectorType">Expected sector type.</param>
/// <param name="DAP">If set to <c>true</c> CD-DA should be modified by mute and interpolation</param>
/// <param name="dap">If set to <c>true</c> CD-DA should be modified by mute and interpolation</param>
/// <param name="sync">If set to <c>true</c> we request the sync bytes for data sectors.</param>
/// <param name="headerCodes">Header codes.</param>
/// <param name="userData">If set to <c>true</c> we request the user data.</param>
/// <param name="edcEcc">If set to <c>true</c> we request the EDC/ECC fields for data sectors.</param>
/// <param name="C2Error">C2 error options.</param>
/// <param name="c2Error">C2 error options.</param>
/// <param name="subchannel">Subchannel selection.</param>
public bool ReadCdMsf(out byte[] buffer, out byte[] senseBuffer, uint startMsf, uint endMsf, uint blockSize,
MmcSectorTypes expectedSectorType, bool DAP, bool sync, MmcHeaderCodes headerCodes,
bool userData, bool edcEcc, MmcErrorField C2Error, MmcSubchannel subchannel, uint timeout,
MmcSectorTypes expectedSectorType, bool dap, bool sync, MmcHeaderCodes headerCodes,
bool userData, bool edcEcc, MmcErrorField c2Error, MmcSubchannel subchannel, uint timeout,
out double duration)
{
senseBuffer = new byte[32];
@@ -480,14 +480,14 @@ namespace DiscImageChef.Devices
cdb[0] = (byte)ScsiCommands.ReadCdMsf;
cdb[1] = (byte)((byte)expectedSectorType << 2);
if(DAP) cdb[1] += 0x02;
if(dap) cdb[1] += 0x02;
cdb[3] = (byte)((startMsf & 0xFF0000) >> 16);
cdb[4] = (byte)((startMsf & 0xFF00) >> 8);
cdb[5] = (byte)(startMsf & 0xFF);
cdb[6] = (byte)((endMsf & 0xFF0000) >> 16);
cdb[7] = (byte)((endMsf & 0xFF00) >> 8);
cdb[8] = (byte)(endMsf & 0xFF);
cdb[9] = (byte)((byte)C2Error << 1);
cdb[9] = (byte)((byte)c2Error << 1);
cdb[9] += (byte)((byte)headerCodes << 5);
if(sync) cdb[9] += 0x80;
if(userData) cdb[9] += 0x10;

View File

@@ -53,7 +53,7 @@ namespace DiscImageChef.Devices
byte[] cdb = new byte[10];
bool sense;
cdb[0] = (byte)ScsiCommands.NEC_ReadCdDa;
cdb[0] = (byte)ScsiCommands.NecReadCdDa;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);

View File

@@ -51,7 +51,7 @@ namespace DiscImageChef.Devices
public bool PlasmonReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address,
ushort blockBytes, bool pba, uint timeout, out double duration)
{
return HPReadLong(out buffer, out senseBuffer, relAddr, address, 0, blockBytes, pba, false, timeout,
return HpReadLong(out buffer, out senseBuffer, relAddr, address, 0, blockBytes, pba, false, timeout,
out duration);
}
@@ -73,7 +73,7 @@ namespace DiscImageChef.Devices
ushort transferLen, ushort blockBytes, bool pba, bool sectorCount, uint timeout,
out double duration)
{
return HPReadLong(out buffer, out senseBuffer, relAddr, address, transferLen, blockBytes, pba, sectorCount,
return HpReadLong(out buffer, out senseBuffer, relAddr, address, transferLen, blockBytes, pba, sectorCount,
timeout, out duration);
}
@@ -94,7 +94,7 @@ namespace DiscImageChef.Devices
byte[] cdb = new byte[10];
bool sense;
cdb[0] = (byte)ScsiCommands.Plasmon_ReadSectorLocation;
cdb[0] = (byte)ScsiCommands.PlasmonReadSectorLocation;
cdb[2] = (byte)((address & 0xFF000000) >> 24);
cdb[3] = (byte)((address & 0xFF0000) >> 16);
cdb[4] = (byte)((address & 0xFF00) >> 8);

View File

@@ -123,14 +123,14 @@ namespace DiscImageChef.Devices
/// <param name="senseBuffer">Sense buffer.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool PlextorReadEepromCDR(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
public bool PlextorReadEepromCdr(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
{
buffer = new byte[256];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.Plextor_ReadEeprom;
cdb[0] = (byte)ScsiCommands.PlextorReadEeprom;
cdb[8] = 1;
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -157,7 +157,7 @@ namespace DiscImageChef.Devices
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.Plextor_ReadEeprom;
cdb[0] = (byte)ScsiCommands.PlextorReadEeprom;
cdb[8] = 2;
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -187,7 +187,7 @@ namespace DiscImageChef.Devices
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.Plextor_ReadEeprom;
cdb[0] = (byte)ScsiCommands.PlextorReadEeprom;
cdb[1] = 1;
cdb[7] = block;
cdb[8] = (byte)((blockSize & 0xFF00) >> 8);
@@ -224,7 +224,7 @@ namespace DiscImageChef.Devices
max = 0;
last = 0;
cdb[0] = (byte)ScsiCommands.Plextor_PoweRec;
cdb[0] = (byte)ScsiCommands.PlextorPoweRec;
cdb[9] = (byte)buf.Length;
lastError = SendScsiCommand(cdb, ref buf, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -264,7 +264,7 @@ namespace DiscImageChef.Devices
enabled = false;
speed = 0;
cdb[0] = (byte)ScsiCommands.Plextor_Extend2;
cdb[0] = (byte)ScsiCommands.PlextorExtend2;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[9] = (byte)buf.Length;
@@ -299,7 +299,7 @@ namespace DiscImageChef.Devices
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.Plextor_Extend;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[2] = (byte)PlextorSubCommands.Silent;
cdb[3] = 4;
@@ -329,7 +329,7 @@ namespace DiscImageChef.Devices
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.Plextor_Extend;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[2] = (byte)PlextorSubCommands.GigaRec;
cdb[10] = (byte)buffer.Length;
@@ -359,7 +359,7 @@ namespace DiscImageChef.Devices
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.Plextor_Extend;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[2] = (byte)PlextorSubCommands.VariRec;
cdb[10] = (byte)buffer.Length;
@@ -391,7 +391,7 @@ namespace DiscImageChef.Devices
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.Plextor_Extend;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[2] = (byte)PlextorSubCommands.SecuRec;
cdb[10] = (byte)buffer.Length;
@@ -419,7 +419,7 @@ namespace DiscImageChef.Devices
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.Plextor_Extend;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[2] = (byte)PlextorSubCommands.SpeedRead;
cdb[10] = (byte)buffer.Length;
@@ -448,7 +448,7 @@ namespace DiscImageChef.Devices
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.Plextor_Extend;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[2] = (byte)PlextorSubCommands.SessionHide;
cdb[9] = (byte)buffer.Length;
@@ -478,12 +478,12 @@ namespace DiscImageChef.Devices
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.Plextor_Extend;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[2] = (byte)PlextorSubCommands.BitSet;
cdb[9] = (byte)buffer.Length;
if(dualLayer) cdb[3] = (byte)PlextorSubCommands.BitSetRDL;
if(dualLayer) cdb[3] = (byte)PlextorSubCommands.BitSetRdl;
else cdb[3] = (byte)PlextorSubCommands.BitSetR;
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -511,7 +511,7 @@ namespace DiscImageChef.Devices
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.Plextor_Extend;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[2] = (byte)PlextorSubCommands.TestWriteDvdPlus;
cdb[10] = (byte)buffer.Length;

View File

@@ -233,13 +233,13 @@ namespace DiscImageChef.Devices
/// <param name="senseBuffer">Sense buffer.</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
/// <param name="DBD">If set to <c>true</c> device MUST not return any block descriptor.</param>
/// <param name="dbd">If set to <c>true</c> device MUST not return any block descriptor.</param>
/// <param name="pageControl">Page control.</param>
/// <param name="pageCode">Page code.</param>
public bool ModeSense6(out byte[] buffer, out byte[] senseBuffer, bool DBD,
public bool ModeSense6(out byte[] buffer, out byte[] senseBuffer, bool dbd,
ScsiModeSensePageControl pageControl, byte pageCode, uint timeout, out double duration)
{
return ModeSense6(out buffer, out senseBuffer, DBD, pageControl, pageCode, 0, timeout, out duration);
return ModeSense6(out buffer, out senseBuffer, dbd, pageControl, pageCode, 0, timeout, out duration);
}
/// <summary>
@@ -250,11 +250,11 @@ namespace DiscImageChef.Devices
/// <param name="senseBuffer">Sense buffer.</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
/// <param name="DBD">If set to <c>true</c> device MUST not return any block descriptor.</param>
/// <param name="dbd">If set to <c>true</c> device MUST not return any block descriptor.</param>
/// <param name="pageControl">Page control.</param>
/// <param name="pageCode">Page code.</param>
/// <param name="subPageCode">Sub-page code.</param>
public bool ModeSense6(out byte[] buffer, out byte[] senseBuffer, bool DBD,
public bool ModeSense6(out byte[] buffer, out byte[] senseBuffer, bool dbd,
ScsiModeSensePageControl pageControl, byte pageCode, byte subPageCode, uint timeout,
out double duration)
{
@@ -264,7 +264,7 @@ namespace DiscImageChef.Devices
bool sense;
cdb[0] = (byte)ScsiCommands.ModeSense;
if(DBD) cdb[1] = 0x08;
if(dbd) cdb[1] = 0x08;
cdb[2] |= (byte)pageControl;
cdb[2] |= (byte)(pageCode & 0x3F);
cdb[3] = subPageCode;
@@ -299,13 +299,13 @@ namespace DiscImageChef.Devices
/// <param name="senseBuffer">Sense buffer.</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
/// <param name="DBD">If set to <c>true</c> device MUST not return any block descriptor.</param>
/// <param name="dbd">If set to <c>true</c> device MUST not return any block descriptor.</param>
/// <param name="pageControl">Page control.</param>
/// <param name="pageCode">Page code.</param>
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool DBD,
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool dbd,
ScsiModeSensePageControl pageControl, byte pageCode, uint timeout, out double duration)
{
return ModeSense10(out buffer, out senseBuffer, false, DBD, pageControl, pageCode, 0, timeout,
return ModeSense10(out buffer, out senseBuffer, false, dbd, pageControl, pageCode, 0, timeout,
out duration);
}
@@ -317,14 +317,14 @@ namespace DiscImageChef.Devices
/// <param name="senseBuffer">Sense buffer.</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
/// <param name="DBD">If set to <c>true</c> device MUST not return any block descriptor.</param>
/// <param name="dbd">If set to <c>true</c> device MUST not return any block descriptor.</param>
/// <param name="pageControl">Page control.</param>
/// <param name="pageCode">Page code.</param>
/// <param name="LLBAA">If set means 64-bit LBAs are accepted by the caller.</param>
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool LLBAA, bool DBD,
/// <param name="llbaa">If set means 64-bit LBAs are accepted by the caller.</param>
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool llbaa, bool dbd,
ScsiModeSensePageControl pageControl, byte pageCode, uint timeout, out double duration)
{
return ModeSense10(out buffer, out senseBuffer, LLBAA, DBD, pageControl, pageCode, 0, timeout,
return ModeSense10(out buffer, out senseBuffer, llbaa, dbd, pageControl, pageCode, 0, timeout,
out duration);
}
@@ -336,12 +336,12 @@ namespace DiscImageChef.Devices
/// <param name="senseBuffer">Sense buffer.</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
/// <param name="DBD">If set to <c>true</c> device MUST not return any block descriptor.</param>
/// <param name="dbd">If set to <c>true</c> device MUST not return any block descriptor.</param>
/// <param name="pageControl">Page control.</param>
/// <param name="pageCode">Page code.</param>
/// <param name="subPageCode">Sub-page code.</param>
/// <param name="LLBAA">If set means 64-bit LBAs are accepted by the caller.</param>
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool LLBAA, bool DBD,
/// <param name="llbaa">If set means 64-bit LBAs are accepted by the caller.</param>
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool llbaa, bool dbd,
ScsiModeSensePageControl pageControl, byte pageCode, byte subPageCode, uint timeout,
out double duration)
{
@@ -351,8 +351,8 @@ namespace DiscImageChef.Devices
bool sense;
cdb[0] = (byte)ScsiCommands.ModeSense10;
if(LLBAA) cdb[1] |= 0x10;
if(DBD) cdb[1] |= 0x08;
if(llbaa) cdb[1] |= 0x10;
if(dbd) cdb[1] |= 0x08;
cdb[2] |= (byte)pageControl;
cdb[2] |= (byte)(pageCode & 0x3F);
cdb[3] = subPageCode;
@@ -472,12 +472,12 @@ namespace DiscImageChef.Devices
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
/// <param name="buffer">Buffer where the SCSI READ CAPACITY response will be stored</param>
/// <param name="senseBuffer">Sense buffer.</param>
/// <param name="RelAddr">Indicates that <paramref name="address"/> is relative to current medium position</param>
/// <param name="address">Address where information is requested from, only valid if <paramref name="PMI"/> is set</param>
/// <param name="PMI">If set, it is requesting partial media capacity</param>
/// <param name="relAddr">Indicates that <paramref name="address"/> is relative to current medium position</param>
/// <param name="address">Address where information is requested from, only valid if <paramref name="pmi"/> is set</param>
/// <param name="pmi">If set, it is requesting partial media capacity</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool ReadCapacity(out byte[] buffer, out byte[] senseBuffer, bool RelAddr, uint address, bool PMI,
public bool ReadCapacity(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address, bool pmi,
uint timeout, out double duration)
{
senseBuffer = new byte[32];
@@ -487,10 +487,10 @@ namespace DiscImageChef.Devices
cdb[0] = (byte)ScsiCommands.ReadCapacity;
if(PMI)
if(pmi)
{
cdb[8] = 0x01;
if(RelAddr) cdb[1] = 0x01;
if(relAddr) cdb[1] = 0x01;
cdb[2] = (byte)((address & 0xFF000000) >> 24);
cdb[3] = (byte)((address & 0xFF0000) >> 16);
@@ -526,11 +526,11 @@ namespace DiscImageChef.Devices
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
/// <param name="buffer">Buffer where the SCSI READ CAPACITY(16) response will be stored</param>
/// <param name="senseBuffer">Sense buffer.</param>
/// <param name="address">Address where information is requested from, only valid if <paramref name="PMI"/> is set</param>
/// <param name="PMI">If set, it is requesting partial media capacity</param>
/// <param name="address">Address where information is requested from, only valid if <paramref name="pmi"/> is set</param>
/// <param name="pmi">If set, it is requesting partial media capacity</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool ReadCapacity16(out byte[] buffer, out byte[] senseBuffer, ulong address, bool PMI, uint timeout,
public bool ReadCapacity16(out byte[] buffer, out byte[] senseBuffer, ulong address, bool pmi, uint timeout,
out double duration)
{
senseBuffer = new byte[32];
@@ -541,7 +541,7 @@ namespace DiscImageChef.Devices
cdb[0] = (byte)ScsiCommands.ServiceActionIn;
cdb[1] = (byte)ScsiServiceActions.ReadCapacity16;
if(PMI)
if(pmi)
{
cdb[14] = 0x01;
byte[] temp = BitConverter.GetBytes(address);
@@ -738,10 +738,10 @@ namespace DiscImageChef.Devices
// Prevent overflows
if(buffer.Length > 255)
{
if(platformID != Interop.PlatformID.Win32NT && platformID != Interop.PlatformID.Win32S &&
platformID != Interop.PlatformID.Win32Windows && platformID != Interop.PlatformID.WinCE &&
platformID != Interop.PlatformID.WindowsPhone &&
platformID != Interop.PlatformID.Xbox) lastError = 75;
if(platformId != Interop.PlatformID.Win32NT && platformId != Interop.PlatformID.Win32S &&
platformId != Interop.PlatformID.Win32Windows && platformId != Interop.PlatformID.WinCE &&
platformId != Interop.PlatformID.WindowsPhone &&
platformId != Interop.PlatformID.Xbox) lastError = 75;
else lastError = 111;
error = true;
duration = 0;
@@ -781,10 +781,10 @@ namespace DiscImageChef.Devices
// Prevent overflows
if(buffer.Length > 65535)
{
if(platformID != Interop.PlatformID.Win32NT && platformID != Interop.PlatformID.Win32S &&
platformID != Interop.PlatformID.Win32Windows && platformID != Interop.PlatformID.WinCE &&
platformID != Interop.PlatformID.WindowsPhone &&
platformID != Interop.PlatformID.Xbox) lastError = 75;
if(platformId != Interop.PlatformID.Win32NT && platformId != Interop.PlatformID.Win32S &&
platformId != Interop.PlatformID.Win32Windows && platformId != Interop.PlatformID.WinCE &&
platformId != Interop.PlatformID.WindowsPhone &&
platformId != Interop.PlatformID.Xbox) lastError = 75;
else lastError = 111;
error = true;
duration = 0;

View File

@@ -1004,13 +1004,13 @@ namespace DiscImageChef.Devices
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
bool sense;
byte[] count_b = BitConverter.GetBytes(count);
byte[] countB = BitConverter.GetBytes(count);
cdb[0] = (byte)ScsiCommands.Space;
cdb[1] = (byte)((byte)code & 0x0F);
cdb[2] = count_b[2];
cdb[3] = count_b[1];
cdb[4] = count_b[0];
cdb[2] = countB[2];
cdb[3] = countB[1];
cdb[4] = countB[0];
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out sense);

View File

@@ -34,7 +34,7 @@ namespace DiscImageChef.Devices
{
public partial class Device
{
Interop.PlatformID platformID;
Interop.PlatformID platformId;
object fd;
bool error;
int lastError;
@@ -73,9 +73,9 @@ namespace DiscImageChef.Devices
/// Gets the Platform ID for this device
/// </summary>
/// <value>The Platform ID</value>
public Interop.PlatformID PlatformID
public Interop.PlatformID PlatformId
{
get { return platformID; }
get { return platformId; }
}
/// <summary>
@@ -160,7 +160,7 @@ namespace DiscImageChef.Devices
/// Gets the device's SCSI peripheral device type
/// </summary>
/// <value>The SCSI peripheral device type.</value>
public Decoders.SCSI.PeripheralDeviceTypes SCSIType
public Decoders.SCSI.PeripheralDeviceTypes ScsiType
{
get { return scsiType; }
}
@@ -178,7 +178,7 @@ namespace DiscImageChef.Devices
/// Gets a value indicating whether this device is attached via USB.
/// </summary>
/// <value><c>true</c> if this device is attached via USB; otherwise, <c>false</c>.</value>
public bool IsUSB
public bool IsUsb
{
get { return usb; }
}
@@ -187,7 +187,7 @@ namespace DiscImageChef.Devices
/// Gets the USB vendor ID.
/// </summary>
/// <value>The USB vendor ID.</value>
public ushort USBVendorID
public ushort UsbVendorId
{
get { return usbVendor; }
}
@@ -196,7 +196,7 @@ namespace DiscImageChef.Devices
/// Gets the USB product ID.
/// </summary>
/// <value>The USB product ID.</value>
public ushort USBProductID
public ushort UsbProductId
{
get { return usbProduct; }
}
@@ -205,7 +205,7 @@ namespace DiscImageChef.Devices
/// Gets the USB descriptors.
/// </summary>
/// <value>The USB descriptors.</value>
public byte[] USBDescriptors
public byte[] UsbDescriptors
{
get { return usbDescriptors; }
}
@@ -214,7 +214,7 @@ namespace DiscImageChef.Devices
/// Gets the USB manufacturer string.
/// </summary>
/// <value>The USB manufacturer string.</value>
public string USBManufacturerString
public string UsbManufacturerString
{
get { return usbManufacturerString; }
}
@@ -223,7 +223,7 @@ namespace DiscImageChef.Devices
/// Gets the USB product string.
/// </summary>
/// <value>The USB product string.</value>
public string USBProductString
public string UsbProductString
{
get { return usbProductString; }
}
@@ -232,7 +232,7 @@ namespace DiscImageChef.Devices
/// Gets the USB serial string.
/// </summary>
/// <value>The USB serial string.</value>
public string USBSerialString
public string UsbSerialString
{
get { return usbSerialString; }
}
@@ -250,7 +250,7 @@ namespace DiscImageChef.Devices
/// Gets the FireWire GUID
/// </summary>
/// <value>The FireWire GUID.</value>
public ulong FireWireGUID
public ulong FireWireGuid
{
get { return firewireGuid; }
}
@@ -304,7 +304,7 @@ namespace DiscImageChef.Devices
/// Gets a value indicating whether this device is a PCMCIA device.
/// </summary>
/// <value><c>true</c> if this device is a PCMCIA device; otherwise, <c>false</c>.</value>
public bool IsPCMCIA
public bool IsPcmcia
{
get { return pcmcia; }
}
@@ -312,7 +312,7 @@ namespace DiscImageChef.Devices
/// <summary>
/// Contains the PCMCIA CIS if applicable
/// </summary>
public byte[] CIS
public byte[] Cis
{
get { return cis; }
}

View File

@@ -259,7 +259,7 @@ namespace DiscImageChef.Devices
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_8x = 0x80,
Vendor_8X = 0x80,
/// <summary>
/// Unknown vendor command
/// </summary>
@@ -267,83 +267,83 @@ namespace DiscImageChef.Devices
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_C0 = 0xC0,
VendorC0 = 0xC0,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_C1 = 0xC1,
VendorC1 = 0xC1,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_C2 = 0xC2,
VendorC2 = 0xC2,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_C3 = 0xC3,
VendorC3 = 0xC3,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_F0 = 0xF0,
VendorF0 = 0xF0,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_F1 = 0xF1,
VendorF1 = 0xF1,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_F2 = 0xF2,
VendorF2 = 0xF2,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_F3 = 0xF3,
VendorF3 = 0xF3,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_F4 = 0xF4,
VendorF4 = 0xF4,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_F5 = 0xF5,
VendorF5 = 0xF5,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_F6 = 0xF6,
VendorF6 = 0xF6,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_F7 = 0xF7,
VendorF7 = 0xF7,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_F8 = 0xF8,
VendorF8 = 0xF8,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_F9 = 0xF9,
VendorF9 = 0xF9,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_FA = 0xFA,
VendorFa = 0xFA,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_FB = 0xFB,
VendorFb = 0xFB,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_FC = 0xFC,
VendorFc = 0xFC,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_FD = 0xFD,
VendorFd = 0xFD,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_FE = 0xFE,
VendorFe = 0xFE,
/// <summary>
/// Unknown vendor command
/// </summary>
Vendor_FF = 0xFF,
VendorFf = 0xFF,
#endregion Commands defined on ATA rev. 4c
#region Commands defined on ATA-2 rev. 4c
@@ -651,9 +651,9 @@ namespace DiscImageChef.Devices
#region Commands defined on ATA/ATAPI Command Set 3 (ACS-3) rev. 5
/// <summary>
/// Sends <see cref="AtaNCQQueueManagementSubcommands"/>
/// Sends <see cref="AtaNcqQueueManagementSubcommands"/>
/// </summary>
NCQQueueManagement = 0x63,
NcqQueueManagement = 0x63,
/// <summary>
/// Sets the device date and time
/// </summary>
@@ -867,13 +867,13 @@ namespace DiscImageChef.Devices
/// <summary>
/// All known ATA NCQ QUEUE MANAGEMENT sub-commands
/// </summary>
public enum AtaNCQQueueManagementSubcommands : byte
public enum AtaNcqQueueManagementSubcommands : byte
{
#region Commands defined on ATA/ATAPI Command Set 3 (ACS-3) rev. 5
/// <summary>
/// Aborts pending NCQ commands
/// </summary>
AbortNCQQueue = 0x00,
AbortNcqQueue = 0x00,
/// <summary>
/// Controls how NCQ Streaming commands are processed by the device
/// </summary>
@@ -1321,11 +1321,11 @@ namespace DiscImageChef.Devices
/// <summary>
/// SASI rev. 0a
/// </summary>
WriteECC = 0xE1,
WriteEcc = 0xE1,
/// <summary>
/// SASI rev. 0a
/// </summary>
ReadID = 0xE2,
ReadId = 0xE2,
/// <summary>
/// SASI rev. 0a
/// </summary>
@@ -1574,7 +1574,7 @@ namespace DiscImageChef.Devices
/// 4.- Write the buffer to the blocks
/// SBC-3 rev. 16
/// </summary>
ORWrite = 0x8B,
OrWrite = 0x8B,
/// <summary>
/// Transfers requested blocks to devices' cache
/// SCSI-2 X3T9.2/375R rev. 10l
@@ -1737,29 +1737,29 @@ namespace DiscImageChef.Devices
/// </summary>
WriteSame16 = 0x93,
/// <summary>
/// Requets XOR data generated by an <see cref="XDWrite"/> or <see cref="Regenerate"/> command
/// Requets XOR data generated by an <see cref="XdWrite"/> or <see cref="Regenerate"/> command
/// SBC-1 rev. 8c
/// </summary>
XDRead = 0x52,
XdRead = 0x52,
/// <summary>
/// XORs the data sent with data on the medium and stores it until an <see cref="XDRead"/> is issued
/// XORs the data sent with data on the medium and stores it until an <see cref="XdRead"/> is issued
/// SBC-1 rev. 8c
/// </summary>
XDWrite = 0x50,
XdWrite = 0x50,
/// <summary>
/// XORs the data sent with data on the medium and stores it until an <see cref="XDRead"/> is issued
/// XORs the data sent with data on the medium and stores it until an <see cref="XdRead"/> is issued
/// SBC-1 rev. 8c
/// </summary>
XDWrite16 = 0x80,
XdWrite16 = 0x80,
/// <summary>
/// Requets the target to XOR the sent data with the data on the medium and return the results
/// </summary>
XDWriteRead = 0x53,
XdWriteRead = 0x53,
/// <summary>
/// Requests the target to XOR the data transferred with the data on the medium and writes it to the medium
/// SBC-1 rev. 8c
/// </summary>
XPWrite = 0x51,
XpWrite = 0x51,
#endregion SCSI Block Commands (SBC)
#region SCSI Streaming Commands (SSC)
@@ -2361,7 +2361,7 @@ namespace DiscImageChef.Devices
/// <summary>
/// Requests the drive the status from the previous WriteCDP command.
/// </summary>
ReadCDP = 0xE4,
ReadCdp = 0xE4,
/// <summary>
/// Requests status from the drive
/// </summary>
@@ -2443,200 +2443,200 @@ namespace DiscImageChef.Devices
/// Verifies that the device can be accessed
/// Sega SPI ver. 1.30
/// </summary>
Sega_TestUnit = TestUnitReady,
SegaTestUnit = TestUnitReady,
/// <summary>
/// Gets current CD status
/// Sega SPI ver. 1.30
/// </summary>
Sega_RequestStatus = 0x10,
SegaRequestStatus = 0x10,
/// <summary>
/// Gets CD block mode info
/// Sega SPI ver. 1.30
/// </summary>
Sega_RequestMode = 0x11,
SegaRequestMode = 0x11,
/// <summary>
/// Sets CD block mode
/// Sega SPI ver. 1.30
/// </summary>
Sega_SetMode = 0x12,
SegaSetMode = 0x12,
/// <summary>
/// Requests device error info
/// Sega SPI ver. 1.30
/// </summary>
Sega_RequestError = 0x13,
SegaRequestError = 0x13,
/// <summary>
/// Gets disc TOC
/// Sega SPI ver. 1.30
/// </summary>
Sega_GetToc = 0x14,
SegaGetToc = 0x14,
/// <summary>
/// Gets specified session data
/// Sega SPI ver. 1.30
/// </summary>
Sega_RequestSession = 0x15,
SegaRequestSession = 0x15,
/// <summary>
/// Stops the drive and opens the drive tray, or, on manual trays, stays busy until it is opened
/// Sega SPI ver. 1.30
/// </summary>
Sega_OpenTray = 0x16,
SegaOpenTray = 0x16,
/// <summary>
/// Starts audio playback
/// Sega SPI ver. 1.30
/// </summary>
Sega_PlayCd = 0x20,
SegaPlayCd = 0x20,
/// <summary>
/// Moves drive pickup to specified block
/// Sega SPI ver. 1.30
/// </summary>
Sega_Seek = 0x21,
SegaSeek = 0x21,
/// <summary>
/// Fast-forwards or fast-reverses until Lead-In or Lead-Out arrive, or until another command is issued
/// Sega SPI ver. 1.30
/// </summary>
Sega_Scan = 0x22,
SegaScan = 0x22,
/// <summary>
/// Reads blocks from the disc
/// Sega SPI ver. 1.30
/// </summary>
Sega_Read = 0x30,
SegaRead = 0x30,
/// <summary>
/// Reads blocks from the disc seeking to another position at end
/// Sega SPI ver. 1.30
/// </summary>
Sega_Read2 = 0x31,
SegaRead2 = 0x31,
/// <summary>
/// Reads disc subcode
/// Sega SPI ver. 1.30
/// </summary>
Sega_GetSubcode = 0x40,
SegaGetSubcode = 0x40,
#endregion SEGA Packet Interface (all are 12-byte CDB)
/// <summary>
/// Variable sized Command Description Block
/// SPC-4 rev. 16
/// </summary>
VariableSizedCDB = 0x7F,
VariableSizedCdb = 0x7F,
#region Plextor vendor commands
/// <summary>
/// Sends extended commands (like SpeedRead) to Plextor drives
/// </summary>
Plextor_Extend = 0xE9,
PlextorExtend = 0xE9,
/// <summary>
/// Command for Plextor PoweRec
/// </summary>
Plextor_PoweRec = 0xEB,
PlextorPoweRec = 0xEB,
/// <summary>
/// Sends extended commands (like PoweRec) to Plextor drives
/// </summary>
Plextor_Extend2 = 0xED,
PlextorExtend2 = 0xED,
/// <summary>
/// Resets Plextor drives
/// </summary>
Plextor_Reset = 0xEE,
PlextorReset = 0xEE,
/// <summary>
/// Reads drive statistics from Plextor drives EEPROM
/// </summary>
Plextor_ReadEeprom = 0xF1,
PlextorReadEeprom = 0xF1,
#endregion Plextor vendor commands
#region HL-DT-ST vendor commands
/// <summary>
/// Sends debugging commands to HL-DT-ST DVD drives
/// </summary>
HlDtSt_Vendor = 0xE7,
HlDtStVendor = 0xE7,
#endregion HL-DT-ST vendor commands
#region NEC vendor commands
/// <summary>
/// Reads CD-DA data
/// </summary>
NEC_ReadCdDa = 0xD4,
NecReadCdDa = 0xD4,
#endregion NEC vendor commands
#region Adaptec vendor commands
/// <summary>
/// Translates a SCSI LBA to a drive's CHS
/// </summary>
Adaptec_Translate = 0x0F,
AdaptecTranslate = 0x0F,
/// <summary>
/// Configures Adaptec controller error threshold
/// </summary>
Adaptec_SetErrorThreshold = 0x10,
AdaptecSetErrorThreshold = 0x10,
/// <summary>
/// Reads and resets error and statistical counters
/// </summary>
Adaptec_ReadCounters = 0x11,
AdaptecReadCounters = 0x11,
/// <summary>
/// Writes to controller's RAM
/// </summary>
Adaptec_WriteBuffer = 0x13,
AdaptecWriteBuffer = 0x13,
/// <summary>
/// Reads controller's RAM
/// </summary>
Adaptec_ReadBuffer = 0x14,
AdaptecReadBuffer = 0x14,
#endregion Adaptec vendor commands
#region Archive Corp. vendor commands
/// <summary>
/// Gets current position's block address
/// </summary>
Archive_RequestBlockAddress = 0x02,
ArchiveRequestBlockAddress = 0x02,
/// <summary>
/// Seeks to specified block address
/// </summary>
Archive_SeekBlock = 0x0C,
ArchiveSeekBlock = 0x0C,
#endregion Archive Corp. vendor commands
#region Certance vendor commands
/// <summary>
/// Parks the load arm in preparation for transport
/// </summary>
Certance_ParkUnpark = 0x06,
CertanceParkUnpark = 0x06,
#endregion Certance vendor commands
#region Fujitsu vendor commands
/// <summary>
/// Used to check the controller's data and control path
/// </summary>
Fujitsu_LoopWriteToRead = 0xC1,
FujitsuLoopWriteToRead = 0xC1,
/// <summary>
/// Used to display a message on the operator panel
/// </summary>
Fujitsu_Display = 0xCF,
FujitsuDisplay = 0xCF,
#endregion Fujitsu vendor commands
#region M-Systems vendor commands
/// <summary>
/// Securely erases all flash blocks, including defective, spared and unused
/// </summary>
MSystems_SecurityErase = 0xFF,
MSystemsSecurityErase = 0xFF,
/// <summary>
/// Securely erases all flash blocks, including defective, spared and unused
/// </summary>
MSystems_SecurityEraseOld = 0xDF,
MSystemsSecurityEraseOld = 0xDF,
#endregion M-Systems vendor commands
#region Plasmon vendor commands
/// <summary>
/// Retrieves sector address
/// </summary>
Plasmon_ReadSectorLocation = 0xE6,
PlasmonReadSectorLocation = 0xE6,
/// <summary>
/// Makes a Compliant WORM block completely unreadable
/// </summary>
Plasmon_Shred = 0xEE,
PlasmonShred = 0xEE,
#endregion Plasmon vendor commands
#region Kreon vendor commands
/// <summary>
/// Most Kreon commands start with this
/// </summary>
Kreon_Command = 0xFF,
KreonCommand = 0xFF,
/// <summary>
/// Kreon extract Security Sectors command start with this
/// </summary>
Kreon_SS_Command = 0xAD
KreonSsCommand = 0xAD
#endregion Kreon vendor commands
}
#endregion SCSI Commands
@@ -2718,7 +2718,7 @@ namespace DiscImageChef.Devices
/// <summary>
/// Unknown Serial ATA
/// </summary>
FPDma = 12,
FpDma = 12,
/// <summary>
/// Requests the Extended ATA Status Return Descriptor
/// </summary>
@@ -2746,14 +2746,14 @@ namespace DiscImageChef.Devices
/// <summary>
/// The STPSIU contains the data length
/// </summary>
SPTSIU = 3
Sptsiu = 3
}
#endregion SCSI's ATA Command Pass-Through
/// <summary>
/// ZBC sub-commands, mask 0x1F
/// </summary>
public enum ZBCSubCommands : byte
public enum ZbcSubCommands : byte
{
/// <summary>
/// Returns list with zones of specified types
@@ -2842,11 +2842,11 @@ namespace DiscImageChef.Devices
/// <summary>
/// Disc Structures for DVD and HD DVD
/// </summary>
DVD = 0x00,
Dvd = 0x00,
/// <summary>
/// Disc Structures for BD
/// </summary>
BD = 0x01
Bd = 0x01
}
public enum MmcDiscStructureFormat : byte
@@ -2856,31 +2856,31 @@ namespace DiscImageChef.Devices
/// <summary>
/// AACS Volume Identifier
/// </summary>
AACSVolId = 0x80,
AacsVolId = 0x80,
/// <summary>
/// AACS Pre-recorded Media Serial Number
/// </summary>
AACSMediaSerial = 0x81,
AacsMediaSerial = 0x81,
/// <summary>
/// AACS Media Identifier
/// </summary>
AACSMediaId = 0x82,
AacsMediaId = 0x82,
/// <summary>
/// AACS Lead-in Media Key Block
/// </summary>
AACSMKB = 0x83,
Aacsmkb = 0x83,
/// <summary>
/// AACS Data Keys
/// </summary>
AACSDataKeys = 0x84,
AacsDataKeys = 0x84,
/// <summary>
/// AACS LBA extents
/// </summary>
AACSLBAExtents = 0x85,
AacslbaExtents = 0x85,
/// <summary>
/// CPRM Media Key Block specified by AACS
/// </summary>
AACSMKBCPRM = 0x86,
Aacsmkbcprm = 0x86,
/// <summary>
/// Recognized format layers
/// </summary>
@@ -2930,27 +2930,27 @@ namespace DiscImageChef.Devices
/// <summary>
/// DDS from DVD-RAM
/// </summary>
DVDRAM_DDS = 0x08,
DvdramDds = 0x08,
/// <summary>
/// DVD-RAM Medium Status
/// </summary>
DVDRAM_MediumStatus = 0x09,
DvdramMediumStatus = 0x09,
/// <summary>
/// DVD-RAM Spare Area Information
/// </summary>
DVDRAM_SpareAreaInformation = 0x0A,
DvdramSpareAreaInformation = 0x0A,
/// <summary>
/// DVD-RAM Recording Type Information
/// </summary>
DVDRAM_RecordingType = 0x0B,
DvdramRecordingType = 0x0B,
/// <summary>
/// DVD-R/-RW RMD in last Border-out
/// </summary>
LastBorderOutRMD = 0x0C,
LastBorderOutRmd = 0x0C,
/// <summary>
/// Specified RMD from last recorded Border-out
/// </summary>
SpecifiedRMD = 0x0D,
SpecifiedRmd = 0x0D,
/// <summary>
/// DVD-R/-RW Lead-in pre-recorded information
/// </summary>
@@ -2958,35 +2958,35 @@ namespace DiscImageChef.Devices
/// <summary>
/// DVD-R/-RW Media Identifier
/// </summary>
DVDR_MediaIdentifier = 0x0F,
DvdrMediaIdentifier = 0x0F,
/// <summary>
/// DVD-R/-RW Physical Format Information
/// </summary>
DVDR_PhysicalInformation = 0x10,
DvdrPhysicalInformation = 0x10,
/// <summary>
/// ADIP
/// </summary>
ADIP = 0x11,
Adip = 0x11,
/// <summary>
/// HD DVD Lead-in Copyright Protection Information
/// </summary>
HDDVD_CopyrightInformation = 0x12,
HddvdCopyrightInformation = 0x12,
/// <summary>
/// AACS Lead-in Copyright Data Section
/// </summary>
DVD_AACS = 0x15,
DvdAacs = 0x15,
/// <summary>
/// HD DVD-R Medium Status
/// </summary>
HDDVDR_MediumStatus = 0x19,
HddvdrMediumStatus = 0x19,
/// <summary>
/// HD DVD-R Last recorded RMD in the latest RMZ
/// </summary>
HDDVDR_LastRMD = 0x1A,
HddvdrLastRmd = 0x1A,
/// <summary>
/// DVD+/-R DL and DVD-Download DL layer capacity
/// </summary>
DVDR_LayerCapacity = 0x20,
DvdrLayerCapacity = 0x20,
/// <summary>
/// DVD-R DL Middle Zone start address
/// </summary>
@@ -2998,7 +2998,7 @@ namespace DiscImageChef.Devices
/// <summary>
/// DVD-R DL Start LBA of the manual layer jump
/// </summary>
ManualLayerJumpStartLBA = 0x23,
ManualLayerJumpStartLba = 0x23,
/// <summary>
/// DVD-R DL Remapping information of the specified Anchor Point
/// </summary>
@@ -3006,7 +3006,7 @@ namespace DiscImageChef.Devices
/// <summary>
/// Disc Control Block
/// </summary>
DCB = 0x30,
Dcb = 0x30,
// BD Disc Structures
/// <summary>
@@ -3016,11 +3016,11 @@ namespace DiscImageChef.Devices
/// <summary>
/// Blu-ray Burst Cutting Area
/// </summary>
BD_BurstCuttingArea = 0x03,
BdBurstCuttingArea = 0x03,
/// <summary>
/// Blu-ray DDS
/// </summary>
BD_DDS = 0x08,
BdDds = 0x08,
/// <summary>
/// Blu-ray Cartridge Status
/// </summary>
@@ -3028,15 +3028,15 @@ namespace DiscImageChef.Devices
/// <summary>
/// Blu-ray Spare Area Information
/// </summary>
BD_SpareAreaInformation = 0x0A,
BdSpareAreaInformation = 0x0A,
/// <summary>
/// Unmodified DFL
/// </summary>
RawDFL = 0x12,
RawDfl = 0x12,
/// <summary>
/// Physical Access Control
/// </summary>
PAC = 0x30
Pac = 0x30
}
public enum ScsiServiceActions : byte
@@ -3047,7 +3047,7 @@ namespace DiscImageChef.Devices
/// Requests parameter data describing provisioning status for the specified LBA
/// SBC-3 rev. 25
/// </summary>
GetLBAStatus = 0x12,
GetLbaStatus = 0x12,
/// <summary>
/// Gets device capacity
/// SBC-2 rev. 4
@@ -3086,7 +3086,7 @@ namespace DiscImageChef.Devices
/// <summary>
/// POW Resources Information
/// </summary>
POWResources = 0x02
PowResources = 0x02
}
public enum MmcSectorTypes : byte
@@ -3098,7 +3098,7 @@ namespace DiscImageChef.Devices
/// <summary>
/// Only CD-DA sectors shall be returned
/// </summary>
CDDA = 0x01,
Cdda = 0x01,
/// <summary>
/// Only Mode 1 sectors shall be returned
/// </summary>
@@ -3170,7 +3170,7 @@ namespace DiscImageChef.Devices
/// <summary>
/// De-interleaved and error-corrected R to W subchannel data shall be transferred
/// </summary>
RW = 0x04
Rw = 0x04
}
public enum PioneerSubchannel : byte
@@ -3272,7 +3272,7 @@ namespace DiscImageChef.Devices
/// <summary>
/// Book setting for DVD+R DL
/// </summary>
BitSetRDL = 0x0E,
BitSetRdl = 0x0E,
/// <summary>
/// Plextor SpeedRead
/// </summary>
@@ -3439,7 +3439,7 @@ namespace DiscImageChef.Devices
/// <summary>
/// Asks device to send their CID numbers (BCR, R2)
/// </summary>
AllSendCID = 2,
AllSendCid = 2,
/// <summary>
/// Assigns a relative address to the device (AC, R1)
/// </summary>
@@ -3447,7 +3447,7 @@ namespace DiscImageChef.Devices
/// <summary>
/// Programs the DSR of the device (BC)
/// </summary>
SetDSR = 4,
SetDsr = 4,
/// <summary>
/// Toggles the device between sleep and standby (AC, R1b)
/// </summary>
@@ -3463,15 +3463,15 @@ namespace DiscImageChef.Devices
/// <summary>
/// Asks device to send its extended card-specific data (ExtCSD) (ADTC, R1)
/// </summary>
SendExtCSD = 8,
SendExtCsd = 8,
/// <summary>
/// Asks device to send its card-specific data (CSD) (AC, R2)
/// </summary>
SendCSD = 9,
SendCsd = 9,
/// <summary>
/// Asks device to send its card identification (CID) (AC, R2)
/// </summary>
SendCID = 10,
SendCid = 10,
/// <summary>
/// Reads data stream from device, starting at given address, until a <see cref="StopTransmission"/> follows (ADTC, R1)
/// </summary>
@@ -3496,8 +3496,8 @@ namespace DiscImageChef.Devices
/// The host sends the bus testing data pattern to a device (ADTC, R1)
/// </summary>
BusTestWrite = 19,
SPIReadOCR = 58,
SPICRCOnOff = 59,
SpiReadOcr = 58,
SpicrcOnOff = 59,
#endregion Class 1 MMC Commands (Basic and read-stream)
#region Class 2 MMC Commands (Block-oriented read)
@@ -3516,7 +3516,7 @@ namespace DiscImageChef.Devices
/// <summary>
/// 128 blocks of tuning pattern is sent for HS200 optimal sampling point detection (ADTC, R1)
/// </summary>
SendTuningBlockHS200 = 21,
SendTuningBlockHs200 = 21,
#endregion Class 2 MMC Commands (Block-oriented read)
#region Class 3 MMC Commands (Stream write)
@@ -3542,11 +3542,11 @@ namespace DiscImageChef.Devices
/// <summary>
/// Programs the Card Information register (ADTC, R1)
/// </summary>
ProgramCID = 26,
ProgramCid = 26,
/// <summary>
/// Programs the programmable bits of the CSD (ADTC, R1)
/// </summary>
ProgramCSD = 27,
ProgramCsd = 27,
/// <summary>
/// Sets the real time clock according to information in block (ADTC, R1)
/// </summary>
@@ -3609,11 +3609,11 @@ namespace DiscImageChef.Devices
/// <summary>
/// Used to write and read 8 bit data field, used to access application dependent registers not defined in MMC standard (AC, R4)
/// </summary>
FastIO = 39,
FastIo = 39,
/// <summary>
/// Sets the system into interrupt mode (BCR, R5)
/// </summary>
GoIRQState = 40,
GoIrqState = 40,
#endregion Class 9 MMC Commands (I/O mode)
#region Class 10 MMC Commands (Security Protocols)
@@ -3724,7 +3724,7 @@ namespace DiscImageChef.Devices
/// <summary>
/// Reads the SD Configuration Register SCR (ADTC, R1)
/// </summary>
SendSCR = 51,
SendScr = 51,
}
[Flags]
@@ -3736,30 +3736,30 @@ namespace DiscImageChef.Devices
ResponseBusy = 1 << 3,
ResponseOpcode = 1 << 4,
CommandMask = 3 << 5,
CommandAC = 0 << 5,
CommandADTC = 1 << 5,
CommandBC = 2 << 5,
CommandBCR = 3 << 5,
ResponseSPI_S1 = 1 << 7,
ResponseSPI_S2 = 1 << 8,
ResponseSPI_B4 = 1 << 9,
ResponseSPI_Busy = 1 << 10,
CommandAc = 0 << 5,
CommandAdtc = 1 << 5,
CommandBc = 2 << 5,
CommandBcr = 3 << 5,
ResponseSpiS1 = 1 << 7,
ResponseSpiS2 = 1 << 8,
ResponseSpiB4 = 1 << 9,
ResponseSpiBusy = 1 << 10,
ResponseNone = 0,
Response_R1 = ResponsePresent | ResponseCrc | ResponseOpcode,
Response_R1b = ResponsePresent | ResponseCrc | ResponseOpcode | ResponseBusy,
Response_R2 = ResponsePresent | Response136 | ResponseCrc,
Response_R3 = ResponsePresent,
Response_R4 = ResponsePresent,
Response_R5 = ResponsePresent | ResponseCrc | ResponseOpcode,
Response_R6 = ResponsePresent | ResponseCrc | ResponseOpcode,
Response_R7 = ResponsePresent | ResponseCrc | ResponseOpcode,
ResponseSPI_R1 = ResponseSPI_S1,
ResponseSPI_R1b = ResponseSPI_S1 | ResponseSPI_Busy,
ResponseSPI_R2 = ResponseSPI_S1 | ResponseSPI_S2,
ResponseSPI_R3 = ResponseSPI_S1 | ResponseSPI_B4,
ResponseSPI_R4 = ResponseSPI_S1 | ResponseSPI_B4,
ResponseSPI_R5 = ResponseSPI_S1 | ResponseSPI_S2,
ResponseSPI_R7 = ResponseSPI_S1 | ResponseSPI_B4
ResponseR1 = ResponsePresent | ResponseCrc | ResponseOpcode,
ResponseR1B = ResponsePresent | ResponseCrc | ResponseOpcode | ResponseBusy,
ResponseR2 = ResponsePresent | Response136 | ResponseCrc,
ResponseR3 = ResponsePresent,
ResponseR4 = ResponsePresent,
ResponseR5 = ResponsePresent | ResponseCrc | ResponseOpcode,
ResponseR6 = ResponsePresent | ResponseCrc | ResponseOpcode,
ResponseR7 = ResponsePresent | ResponseCrc | ResponseOpcode,
ResponseSpiR1 = ResponseSpiS1,
ResponseSpiR1B = ResponseSpiS1 | ResponseSpiBusy,
ResponseSpiR2 = ResponseSpiS1 | ResponseSpiS2,
ResponseSpiR3 = ResponseSpiS1 | ResponseSpiB4,
ResponseSpiR4 = ResponseSpiS1 | ResponseSpiB4,
ResponseSpiR5 = ResponseSpiS1 | ResponseSpiS2,
ResponseSpiR7 = ResponseSpiS1 | ResponseSpiB4
}
[Flags]
@@ -3776,7 +3776,7 @@ namespace DiscImageChef.Devices
/// <summary>
/// Drive can read and decrypt the SS from Xbox 360 discs
/// </summary>
DecryptSS360,
DecryptSs360,
/// <summary>
/// Drive has full challenge response capabilities with Xbox 360 discs
/// </summary>
@@ -3792,7 +3792,7 @@ namespace DiscImageChef.Devices
/// <summary>
/// Drive can read and decrypt the SS from Xbox discs
/// </summary>
DecryptSS,
DecryptSs,
/// <summary>
/// Drive has full challenge response capabilities with Xbox discs
/// </summary>

View File

@@ -56,7 +56,7 @@ namespace DiscImageChef.Devices.FreeBSD
/// <param name="duration">Time it took to execute the command in milliseconds</param>
/// <param name="sense"><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, ccb_flags direction, out double duration, out bool sense)
uint timeout, CcbFlags direction, out double duration, out bool sense)
{
senseBuffer = null;
duration = 0;
@@ -73,8 +73,8 @@ namespace DiscImageChef.Devices.FreeBSD
return Marshal.GetLastWin32Error();
}
ccb_scsiio64 csio = (ccb_scsiio64)Marshal.PtrToStructure(ccbPtr, typeof(ccb_scsiio64));
csio.ccb_h.func_code = xpt_opcode.XPT_SCSI_IO;
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.retry_count = 1;
@@ -93,9 +93,9 @@ namespace DiscImageChef.Devices.FreeBSD
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 |= CcbFlags.CamCdbPointer;
}
csio.ccb_h.flags |= ccb_flags.CAM_DEV_QFRZDIS;
csio.ccb_h.flags |= CcbFlags.CamDevQfrzdis;
Marshal.Copy(buffer, 0, csio.data_ptr, buffer.Length);
Marshal.StructureToPtr(csio, ccbPtr, false);
@@ -106,28 +106,28 @@ namespace DiscImageChef.Devices.FreeBSD
if(error < 0) error = Marshal.GetLastWin32Error();
csio = (ccb_scsiio64)Marshal.PtrToStructure(ccbPtr, typeof(ccb_scsiio64));
csio = (CcbScsiio64)Marshal.PtrToStructure(ccbPtr, typeof(CcbScsiio64));
if((csio.ccb_h.status & cam_status.CAM_STATUS_MASK) != cam_status.CAM_REQ_CMP &&
(csio.ccb_h.status & cam_status.CAM_STATUS_MASK) != cam_status.CAM_SCSI_STATUS_ERROR)
if((csio.ccb_h.status & CamStatus.CamStatusMask) != CamStatus.CamReqCmp &&
(csio.ccb_h.status & CamStatus.CamStatusMask) != CamStatus.CamScsiStatusError)
{
error = Marshal.GetLastWin32Error();
DicConsole.DebugWriteLine("FreeBSD devices", "CAM status {0} error {1}", csio.ccb_h.status, error);
sense = true;
}
if((csio.ccb_h.status & cam_status.CAM_STATUS_MASK) == cam_status.CAM_SCSI_STATUS_ERROR)
if((csio.ccb_h.status & CamStatus.CamStatusMask) == CamStatus.CamScsiStatusError)
{
sense = true;
senseBuffer = new byte[1];
senseBuffer[0] = csio.scsi_status;
}
if((csio.ccb_h.status & cam_status.CAM_AUTOSNS_VALID) != 0)
if((csio.ccb_h.status & CamStatus.CamAutosnsValid) != 0)
{
if(csio.sense_len - csio.sense_resid > 0)
{
sense = (csio.ccb_h.status & cam_status.CAM_STATUS_MASK) == cam_status.CAM_SCSI_STATUS_ERROR;
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);
@@ -138,12 +138,12 @@ namespace DiscImageChef.Devices.FreeBSD
cdb = new byte[csio.cdb_len];
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(CcbFlags.CamCdbPointer))
Marshal.Copy(new IntPtr(BitConverter.ToInt64(csio.cdb_bytes, 0)), cdb, 0, cdb.Length);
else Array.Copy(csio.cdb_bytes, 0, cdb, 0, cdb.Length);
duration = (end - start).TotalMilliseconds;
if(csio.ccb_h.flags.HasFlag(ccb_flags.CAM_CDB_POINTER)) Marshal.FreeHGlobal(cdbPtr);
if(csio.ccb_h.flags.HasFlag(CcbFlags.CamCdbPointer)) Marshal.FreeHGlobal(cdbPtr);
Marshal.FreeHGlobal(csio.data_ptr);
cam_freeccb(ccbPtr);
@@ -163,7 +163,7 @@ namespace DiscImageChef.Devices.FreeBSD
/// <param name="duration">Time it took to execute the command in milliseconds</param>
/// <param name="sense"><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, ccb_flags direction, out double duration, out bool sense)
uint timeout, CcbFlags direction, out double duration, out bool sense)
{
senseBuffer = null;
duration = 0;
@@ -180,8 +180,8 @@ namespace DiscImageChef.Devices.FreeBSD
return Marshal.GetLastWin32Error();
}
ccb_scsiio csio = (ccb_scsiio)Marshal.PtrToStructure(ccbPtr, typeof(ccb_scsiio));
csio.ccb_h.func_code = xpt_opcode.XPT_SCSI_IO;
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.retry_count = 1;
@@ -200,9 +200,9 @@ namespace DiscImageChef.Devices.FreeBSD
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 |= CcbFlags.CamCdbPointer;
}
csio.ccb_h.flags |= ccb_flags.CAM_DEV_QFRZDIS;
csio.ccb_h.flags |= CcbFlags.CamDevQfrzdis;
Marshal.Copy(buffer, 0, csio.data_ptr, buffer.Length);
Marshal.StructureToPtr(csio, ccbPtr, false);
@@ -213,28 +213,28 @@ namespace DiscImageChef.Devices.FreeBSD
if(error < 0) error = Marshal.GetLastWin32Error();
csio = (ccb_scsiio)Marshal.PtrToStructure(ccbPtr, typeof(ccb_scsiio));
csio = (CcbScsiio)Marshal.PtrToStructure(ccbPtr, typeof(CcbScsiio));
if((csio.ccb_h.status & cam_status.CAM_STATUS_MASK) != cam_status.CAM_REQ_CMP &&
(csio.ccb_h.status & cam_status.CAM_STATUS_MASK) != cam_status.CAM_SCSI_STATUS_ERROR)
if((csio.ccb_h.status & CamStatus.CamStatusMask) != CamStatus.CamReqCmp &&
(csio.ccb_h.status & CamStatus.CamStatusMask) != CamStatus.CamScsiStatusError)
{
error = Marshal.GetLastWin32Error();
DicConsole.DebugWriteLine("FreeBSD devices", "CAM status {0} error {1}", csio.ccb_h.status, error);
sense = true;
}
if((csio.ccb_h.status & cam_status.CAM_STATUS_MASK) == cam_status.CAM_SCSI_STATUS_ERROR)
if((csio.ccb_h.status & CamStatus.CamStatusMask) == CamStatus.CamScsiStatusError)
{
sense = true;
senseBuffer = new byte[1];
senseBuffer[0] = csio.scsi_status;
}
if((csio.ccb_h.status & cam_status.CAM_AUTOSNS_VALID) != 0)
if((csio.ccb_h.status & CamStatus.CamAutosnsValid) != 0)
{
if(csio.sense_len - csio.sense_resid > 0)
{
sense = (csio.ccb_h.status & cam_status.CAM_STATUS_MASK) == cam_status.CAM_SCSI_STATUS_ERROR;
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);
@@ -245,19 +245,19 @@ namespace DiscImageChef.Devices.FreeBSD
cdb = new byte[csio.cdb_len];
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(CcbFlags.CamCdbPointer))
Marshal.Copy(new IntPtr(BitConverter.ToInt32(csio.cdb_bytes, 0)), cdb, 0, cdb.Length);
else Array.Copy(csio.cdb_bytes, 0, cdb, 0, cdb.Length);
duration = (end - start).TotalMilliseconds;
if(csio.ccb_h.flags.HasFlag(ccb_flags.CAM_CDB_POINTER)) Marshal.FreeHGlobal(cdbPtr);
if(csio.ccb_h.flags.HasFlag(CcbFlags.CamCdbPointer)) Marshal.FreeHGlobal(cdbPtr);
Marshal.FreeHGlobal(csio.data_ptr);
cam_freeccb(ccbPtr);
return error;
}
static ccb_flags AtaProtocolToCamFlags(AtaProtocol protocol)
static CcbFlags AtaProtocolToCamFlags(AtaProtocol protocol)
{
switch(protocol)
{
@@ -266,12 +266,12 @@ namespace DiscImageChef.Devices.FreeBSD
case AtaProtocol.HardReset:
case AtaProtocol.NonData:
case AtaProtocol.SoftReset:
case AtaProtocol.ReturnResponse: return ccb_flags.CAM_DIR_NONE;
case AtaProtocol.ReturnResponse: return CcbFlags.CamDirNone;
case AtaProtocol.PioIn:
case AtaProtocol.UDmaIn: return ccb_flags.CAM_DIR_IN;
case AtaProtocol.UDmaIn: return CcbFlags.CamDirIn;
case AtaProtocol.PioOut:
case AtaProtocol.UDmaOut: return ccb_flags.CAM_DIR_OUT;
default: return ccb_flags.CAM_DIR_NONE;
case AtaProtocol.UDmaOut: return CcbFlags.CamDirOut;
default: return CcbFlags.CamDirNone;
}
}
@@ -287,8 +287,8 @@ namespace DiscImageChef.Devices.FreeBSD
IntPtr ccbPtr = cam_getccb(dev);
ccb_ataio ataio = (ccb_ataio)Marshal.PtrToStructure(ccbPtr, typeof(ccb_ataio));
ataio.ccb_h.func_code = xpt_opcode.XPT_ATA_IO;
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;
@@ -296,7 +296,7 @@ namespace DiscImageChef.Devices.FreeBSD
ataio.ccb_h.timeout = timeout;
ataio.data_ptr = Marshal.AllocHGlobal(buffer.Length);
ataio.dxfer_len = (uint)buffer.Length;
ataio.ccb_h.flags |= ccb_flags.CAM_DEV_QFRZDIS;
ataio.ccb_h.flags |= CcbFlags.CamDevQfrzdis;
ataio.cmd.flags = CamAtaIoFlags.NeedResult;
switch(protocol)
{
@@ -304,10 +304,10 @@ namespace DiscImageChef.Devices.FreeBSD
case AtaProtocol.DmaQueued:
case AtaProtocol.UDmaIn:
case AtaProtocol.UDmaOut:
ataio.cmd.flags |= CamAtaIoFlags.DMA;
ataio.cmd.flags |= CamAtaIoFlags.Dma;
break;
case AtaProtocol.FPDma:
ataio.cmd.flags |= CamAtaIoFlags.FPDMA;
case AtaProtocol.FpDma:
ataio.cmd.flags |= CamAtaIoFlags.Fpdma;
break;
}
@@ -328,17 +328,17 @@ namespace DiscImageChef.Devices.FreeBSD
if(error < 0) error = Marshal.GetLastWin32Error();
ataio = (ccb_ataio)Marshal.PtrToStructure(ccbPtr, typeof(ccb_ataio));
ataio = (CcbAtaio)Marshal.PtrToStructure(ccbPtr, typeof(CcbAtaio));
if((ataio.ccb_h.status & cam_status.CAM_STATUS_MASK) != cam_status.CAM_REQ_CMP &&
(ataio.ccb_h.status & cam_status.CAM_STATUS_MASK) != cam_status.CAM_SCSI_STATUS_ERROR)
if((ataio.ccb_h.status & CamStatus.CamStatusMask) != CamStatus.CamReqCmp &&
(ataio.ccb_h.status & CamStatus.CamStatusMask) != CamStatus.CamScsiStatusError)
{
error = Marshal.GetLastWin32Error();
DicConsole.DebugWriteLine("FreeBSD devices", "CAM status {0} error {1}", ataio.ccb_h.status, error);
sense = true;
}
if((ataio.ccb_h.status & cam_status.CAM_STATUS_MASK) == cam_status.CAM_ATA_STATUS_ERROR) sense = true;
if((ataio.ccb_h.status & CamStatus.CamStatusMask) == CamStatus.CamAtaStatusError) sense = true;
errorRegisters.cylinderHigh = ataio.res.lba_high;
errorRegisters.cylinderLow = ataio.res.lba_mid;
@@ -373,8 +373,8 @@ namespace DiscImageChef.Devices.FreeBSD
IntPtr ccbPtr = cam_getccb(dev);
ccb_ataio ataio = (ccb_ataio)Marshal.PtrToStructure(ccbPtr, typeof(ccb_ataio));
ataio.ccb_h.func_code = xpt_opcode.XPT_ATA_IO;
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;
@@ -382,7 +382,7 @@ namespace DiscImageChef.Devices.FreeBSD
ataio.ccb_h.timeout = timeout;
ataio.data_ptr = Marshal.AllocHGlobal(buffer.Length);
ataio.dxfer_len = (uint)buffer.Length;
ataio.ccb_h.flags |= ccb_flags.CAM_DEV_QFRZDIS;
ataio.ccb_h.flags |= CcbFlags.CamDevQfrzdis;
ataio.cmd.flags = CamAtaIoFlags.NeedResult;
switch(protocol)
{
@@ -390,10 +390,10 @@ namespace DiscImageChef.Devices.FreeBSD
case AtaProtocol.DmaQueued:
case AtaProtocol.UDmaIn:
case AtaProtocol.UDmaOut:
ataio.cmd.flags |= CamAtaIoFlags.DMA;
ataio.cmd.flags |= CamAtaIoFlags.Dma;
break;
case AtaProtocol.FPDma:
ataio.cmd.flags |= CamAtaIoFlags.FPDMA;
case AtaProtocol.FpDma:
ataio.cmd.flags |= CamAtaIoFlags.Fpdma;
break;
}
@@ -414,17 +414,17 @@ namespace DiscImageChef.Devices.FreeBSD
if(error < 0) error = Marshal.GetLastWin32Error();
ataio = (ccb_ataio)Marshal.PtrToStructure(ccbPtr, typeof(ccb_ataio));
ataio = (CcbAtaio)Marshal.PtrToStructure(ccbPtr, typeof(CcbAtaio));
if((ataio.ccb_h.status & cam_status.CAM_STATUS_MASK) != cam_status.CAM_REQ_CMP &&
(ataio.ccb_h.status & cam_status.CAM_STATUS_MASK) != cam_status.CAM_SCSI_STATUS_ERROR)
if((ataio.ccb_h.status & CamStatus.CamStatusMask) != CamStatus.CamReqCmp &&
(ataio.ccb_h.status & CamStatus.CamStatusMask) != CamStatus.CamScsiStatusError)
{
error = Marshal.GetLastWin32Error();
DicConsole.DebugWriteLine("FreeBSD devices", "CAM status {0} error {1}", ataio.ccb_h.status, error);
sense = true;
}
if((ataio.ccb_h.status & cam_status.CAM_STATUS_MASK) == cam_status.CAM_ATA_STATUS_ERROR) sense = true;
if((ataio.ccb_h.status & CamStatus.CamStatusMask) == CamStatus.CamAtaStatusError) sense = true;
errorRegisters.lbaHigh = ataio.res.lba_high;
errorRegisters.lbaMid = ataio.res.lba_mid;
@@ -463,8 +463,8 @@ namespace DiscImageChef.Devices.FreeBSD
IntPtr ccbPtr = cam_getccb(dev);
ccb_ataio ataio = (ccb_ataio)Marshal.PtrToStructure(ccbPtr, typeof(ccb_ataio));
ataio.ccb_h.func_code = xpt_opcode.XPT_ATA_IO;
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;
@@ -472,7 +472,7 @@ namespace DiscImageChef.Devices.FreeBSD
ataio.ccb_h.timeout = timeout;
ataio.data_ptr = Marshal.AllocHGlobal(buffer.Length);
ataio.dxfer_len = (uint)buffer.Length;
ataio.ccb_h.flags |= ccb_flags.CAM_DEV_QFRZDIS;
ataio.ccb_h.flags |= CcbFlags.CamDevQfrzdis;
ataio.cmd.flags = CamAtaIoFlags.NeedResult | CamAtaIoFlags.ExtendedCommand;
switch(protocol)
{
@@ -480,10 +480,10 @@ namespace DiscImageChef.Devices.FreeBSD
case AtaProtocol.DmaQueued:
case AtaProtocol.UDmaIn:
case AtaProtocol.UDmaOut:
ataio.cmd.flags |= CamAtaIoFlags.DMA;
ataio.cmd.flags |= CamAtaIoFlags.Dma;
break;
case AtaProtocol.FPDma:
ataio.cmd.flags |= CamAtaIoFlags.FPDMA;
case AtaProtocol.FpDma:
ataio.cmd.flags |= CamAtaIoFlags.Fpdma;
break;
}
@@ -509,17 +509,17 @@ namespace DiscImageChef.Devices.FreeBSD
if(error < 0) error = Marshal.GetLastWin32Error();
ataio = (ccb_ataio)Marshal.PtrToStructure(ccbPtr, typeof(ccb_ataio));
ataio = (CcbAtaio)Marshal.PtrToStructure(ccbPtr, typeof(CcbAtaio));
if((ataio.ccb_h.status & cam_status.CAM_STATUS_MASK) != cam_status.CAM_REQ_CMP &&
(ataio.ccb_h.status & cam_status.CAM_STATUS_MASK) != cam_status.CAM_SCSI_STATUS_ERROR)
if((ataio.ccb_h.status & CamStatus.CamStatusMask) != CamStatus.CamReqCmp &&
(ataio.ccb_h.status & CamStatus.CamStatusMask) != CamStatus.CamScsiStatusError)
{
error = Marshal.GetLastWin32Error();
DicConsole.DebugWriteLine("FreeBSD devices", "CAM status {0} error {1}", ataio.ccb_h.status, error);
sense = true;
}
if((ataio.ccb_h.status & cam_status.CAM_STATUS_MASK) == cam_status.CAM_ATA_STATUS_ERROR) sense = true;
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);

View File

@@ -93,7 +93,7 @@ namespace DiscImageChef.Devices.FreeBSD
/// <summary>
/// O_NOCTTY
///</summary>
NoControlTTY = 0x00008000,
NoControlTty = 0x00008000,
/// <summary>
/// O_DIRECT
///</summary>
@@ -109,7 +109,7 @@ namespace DiscImageChef.Devices.FreeBSD
/// <summary>
/// O_TTY_INIT
///</summary>
InitializeTTY = 0x00080000,
InitializeTty = 0x00080000,
/// <summary>
/// O_CLOEXEC
///</summary>
@@ -126,7 +126,7 @@ namespace DiscImageChef.Devices.FreeBSD
/// <summary>
/// FPDMA command
///</summary>
FPDMA = 0x02,
Fpdma = 0x02,
/// <summary>
/// Control, not a command
///</summary>
@@ -138,595 +138,595 @@ namespace DiscImageChef.Devices.FreeBSD
/// <summary>
/// DMA command
///</summary>
DMA = 0x10
Dma = 0x10
}
/// <summary>XPT Opcodes for xpt_action</summary>
[Flags]
enum xpt_opcode
enum XptOpcode
{
// Function code flags are bits greater than 0xff
/// <summary>Non-immediate function code</summary>
XPT_FC_QUEUED = 0x100,
XPT_FC_USER_CCB = 0x200,
XptFcQueued = 0x100,
XptFcUserCcb = 0x200,
/// <summary>Only for the transport layer device</summary>
XPT_FC_XPT_ONLY = 0x400,
XptFcXptOnly = 0x400,
/// <summary>Passes through the device queues</summary>
XPT_FC_DEV_QUEUED = 0x800 | XPT_FC_QUEUED,
XptFcDevQueued = 0x800 | XptFcQueued,
// Common function commands: 0x00->0x0F
/// <summary>Execute Nothing</summary>
XPT_NOOP = 0x00,
XptNoop = 0x00,
/// <summary>Execute the requested I/O operation</summary>
XPT_SCSI_IO = 0x01 | XPT_FC_DEV_QUEUED,
XptScsiIo = 0x01 | XptFcDevQueued,
/// <summary>Get type information for specified device</summary>
XPT_GDEV_TYPE = 0x02,
XptGdevType = 0x02,
/// <summary>Get a list of peripheral devices</summary>
XPT_GDEVLIST = 0x03,
XptGdevlist = 0x03,
/// <summary>Path routing inquiry</summary>
XPT_PATH_INQ = 0x04,
XptPathInq = 0x04,
/// <summary>Release a frozen device queue</summary>
XPT_REL_SIMQ = 0x05,
XptRelSimq = 0x05,
/// <summary>Set Asynchronous Callback Parameters</summary>
XPT_SASYNC_CB = 0x06,
XptSasyncCb = 0x06,
/// <summary>Set device type information</summary>
XPT_SDEV_TYPE = 0x07,
XptSdevType = 0x07,
/// <summary>(Re)Scan the SCSI Bus</summary>
XPT_SCAN_BUS = 0x08 | XPT_FC_QUEUED | XPT_FC_USER_CCB | XPT_FC_XPT_ONLY,
XptScanBus = 0x08 | XptFcQueued | XptFcUserCcb | XptFcXptOnly,
/// <summary>Get EDT entries matching the given pattern</summary>
XPT_DEV_MATCH = 0x09 | XPT_FC_XPT_ONLY,
XptDevMatch = 0x09 | XptFcXptOnly,
/// <summary>Turn on debugging for a bus, target or lun</summary>
XPT_DEBUG = 0x0a,
XptDebug = 0x0a,
/// <summary>Path statistics (error counts, etc.)</summary>
XPT_PATH_STATS = 0x0b,
XptPathStats = 0x0b,
/// <summary>Device statistics (error counts, etc.)</summary>
XPT_GDEV_STATS = 0x0c,
XptGdevStats = 0x0c,
/// <summary>Get/Set Device advanced information</summary>
XPT_DEV_ADVINFO = 0x0e,
XptDevAdvinfo = 0x0e,
/// <summary>Asynchronous event</summary>
XPT_ASYNC = 0x0f | XPT_FC_QUEUED | XPT_FC_USER_CCB | XPT_FC_XPT_ONLY,
XptAsync = 0x0f | XptFcQueued | XptFcUserCcb | XptFcXptOnly,
/// <summary>SCSI Control Functions: 0x10->0x1F</summary>
/// <summary>Abort the specified CCB</summary>
XPT_ABORT = 0x10,
XptAbort = 0x10,
/// <summary>Reset the specified SCSI bus</summary>
XPT_RESET_BUS = 0x11 | XPT_FC_XPT_ONLY,
XptResetBus = 0x11 | XptFcXptOnly,
/// <summary>Bus Device Reset the specified SCSI device</summary>
XPT_RESET_DEV = 0x12 | XPT_FC_DEV_QUEUED,
XptResetDev = 0x12 | XptFcDevQueued,
/// <summary>Terminate the I/O process</summary>
XPT_TERM_IO = 0x13,
XptTermIo = 0x13,
/// <summary>Scan Logical Unit</summary>
XPT_SCAN_LUN = 0x14 | XPT_FC_QUEUED | XPT_FC_USER_CCB | XPT_FC_XPT_ONLY,
XptScanLun = 0x14 | XptFcQueued | XptFcUserCcb | XptFcXptOnly,
/// <summary>Get default/user transfer settings for the target</summary>
XPT_GET_TRAN_SETTINGS = 0x15,
XptGetTranSettings = 0x15,
/// <summary>Set transfer rate/width negotiation settings</summary>
XPT_SET_TRAN_SETTINGS = 0x16,
XptSetTranSettings = 0x16,
/// <summary>Calculate the geometry parameters for a device give the sector size and volume size.</summary>
XPT_CALC_GEOMETRY = 0x17,
XptCalcGeometry = 0x17,
/// <summary>Execute the requested ATA I/O operation</summary>
XPT_ATA_IO = 0x18 | XPT_FC_DEV_QUEUED,
XptAtaIo = 0x18 | XptFcDevQueued,
/// <summary>Compat only</summary>
XPT_GET_SIM_KNOB_OLD = 0x18,
XptGetSimKnobOld = 0x18,
/// <summary>Set SIM specific knob values.</summary>
XPT_SET_SIM_KNOB = 0x19,
XptSetSimKnob = 0x19,
/// <summary>Get SIM specific knob values.</summary>
XPT_GET_SIM_KNOB = 0x1a,
XptGetSimKnob = 0x1a,
/// <summary>Serial Management Protocol</summary>
XPT_SMP_IO = 0x1b | XPT_FC_DEV_QUEUED,
XptSmpIo = 0x1b | XptFcDevQueued,
/// <summary>Scan Target</summary>
XPT_SCAN_TGT = 0x1E | XPT_FC_QUEUED | XPT_FC_USER_CCB | XPT_FC_XPT_ONLY,
XptScanTgt = 0x1E | XptFcQueued | XptFcUserCcb | XptFcXptOnly,
// HBA engine commands 0x20->0x2F
/// <summary>HBA engine feature inquiry</summary>
XPT_ENG_INQ = 0x20 | XPT_FC_XPT_ONLY,
XptEngInq = 0x20 | XptFcXptOnly,
/// <summary>HBA execute engine request</summary>
XPT_ENG_EXEC = 0x21 | XPT_FC_DEV_QUEUED,
XptEngExec = 0x21 | XptFcDevQueued,
// Target mode commands: 0x30->0x3F
/// <summary>Enable LUN as a target</summary>
XPT_EN_LUN = 0x30,
XptEnLun = 0x30,
/// <summary>Execute target I/O request</summary>
XPT_TARGET_IO = 0x31 | XPT_FC_DEV_QUEUED,
XptTargetIo = 0x31 | XptFcDevQueued,
/// <summary>Accept Host Target Mode CDB</summary>
XPT_ACCEPT_TARGET_IO = 0x32 | XPT_FC_QUEUED | XPT_FC_USER_CCB,
XptAcceptTargetIo = 0x32 | XptFcQueued | XptFcUserCcb,
/// <summary>Continue Host Target I/O Connection</summary>
XPT_CONT_TARGET_IO = 0x33 | XPT_FC_DEV_QUEUED,
XptContTargetIo = 0x33 | XptFcDevQueued,
/// <summary>Notify Host Target driver of event (obsolete)</summary>
XPT_IMMED_NOTIFY = 0x34 | XPT_FC_QUEUED | XPT_FC_USER_CCB,
XptImmedNotify = 0x34 | XptFcQueued | XptFcUserCcb,
/// <summary>Acknowledgement of event (obsolete)</summary>
XPT_NOTIFY_ACK = 0x35,
XptNotifyAck = 0x35,
/// <summary>Notify Host Target driver of event</summary>
XPT_IMMEDIATE_NOTIFY = 0x36 | XPT_FC_QUEUED | XPT_FC_USER_CCB,
XptImmediateNotify = 0x36 | XptFcQueued | XptFcUserCcb,
/// <summary>Acknowledgement of event</summary>
XPT_NOTIFY_ACKNOWLEDGE = 0x37 | XPT_FC_QUEUED | XPT_FC_USER_CCB,
XptNotifyAcknowledge = 0x37 | XptFcQueued | XptFcUserCcb,
/// <summary>Vendor Unique codes: 0x80->0x8F</summary>
XPT_VUNIQUE = 0x80
XptVunique = 0x80
}
enum ccb_dev_match_status
enum CcbDevMatchStatus
{
CAM_DEV_MATCH_LAST,
CAM_DEV_MATCH_MORE,
CAM_DEV_MATCH_LIST_CHANGED,
CAM_DEV_MATCH_SIZE_ERROR,
CAM_DEV_MATCH_ERROR
CamDevMatchLast,
CamDevMatchMore,
CamDevMatchListChanged,
CamDevMatchSizeError,
CamDevMatchError
}
enum dev_match_type
enum DevMatchType
{
DEV_MATCH_PERIPH = 0,
DEV_MATCH_DEVICE,
DEV_MATCH_BUS
DevMatchPeriph = 0,
DevMatchDevice,
DevMatchBus
}
[Flags]
enum periph_pattern_flags
enum PeriphPatternFlags
{
PERIPH_MATCH_NONE = 0x000,
PERIPH_MATCH_PATH = 0x001,
PERIPH_MATCH_TARGET = 0x002,
PERIPH_MATCH_LUN = 0x004,
PERIPH_MATCH_NAME = 0x008,
PERIPH_MATCH_UNIT = 0x010,
PeriphMatchNone = 0x000,
PeriphMatchPath = 0x001,
PeriphMatchTarget = 0x002,
PeriphMatchLun = 0x004,
PeriphMatchName = 0x008,
PeriphMatchUnit = 0x010,
// PERIPH_MATCH_ANY = 0x01f
}
[Flags]
enum dev_pattern_flags
enum DevPatternFlags
{
DEV_MATCH_NONE = 0x000,
DEV_MATCH_PATH = 0x001,
DEV_MATCH_TARGET = 0x002,
DEV_MATCH_LUN = 0x004,
DEV_MATCH_INQUIRY = 0x008,
DEV_MATCH_DEVID = 0x010,
DevMatchNone = 0x000,
DevMatchPath = 0x001,
DevMatchTarget = 0x002,
DevMatchLun = 0x004,
DevMatchInquiry = 0x008,
DevMatchDevid = 0x010,
// DEV_MATCH_ANY = 0x00f
}
[Flags]
enum bus_pattern_flags
enum BusPatternFlags
{
BUS_MATCH_NONE = 0x000,
BUS_MATCH_PATH = 0x001,
BUS_MATCH_NAME = 0x002,
BUS_MATCH_UNIT = 0x004,
BUS_MATCH_BUS_ID = 0x008,
BusMatchNone = 0x000,
BusMatchPath = 0x001,
BusMatchName = 0x002,
BusMatchUnit = 0x004,
BusMatchBusId = 0x008,
// BUS_MATCH_ANY = 0x00f
}
[Flags]
enum dev_result_flags
enum DevResultFlags
{
DEV_RESULT_NOFLAG = 0x00,
DEV_RESULT_UNCONFIGURED = 0x01
DevResultNoflag = 0x00,
DevResultUnconfigured = 0x01
}
enum cam_proto
enum CamProto
{
PROTO_UNKNOWN,
PROTO_UNSPECIFIED,
ProtoUnknown,
ProtoUnspecified,
/// <summary>
/// Small Computer System Interface
/// </summary>
PROTO_SCSI,
ProtoScsi,
/// <summary>
/// AT Attachment
/// </summary>
PROTO_ATA,
ProtoAta,
/// <summary>
/// AT Attachment Packetized Interface
/// </summary>
PROTO_ATAPI,
ProtoAtapi,
/// <summary>
/// SATA Port Multiplier
/// </summary>
PROTO_SATAPM,
ProtoSatapm,
/// <summary>
/// SATA Enclosure Management Bridge
/// </summary>
PROTO_SEMB,
ProtoSemb,
/// <summary>
/// NVMe
/// </summary>
PROTO_NVME,
ProtoNvme,
/// <summary>
/// MMC, SD, SDIO
/// </summary>
PROTO_MMCSD,
ProtoMmcsd,
}
[Flags]
enum mmc_card_features
enum MmcCardFeatures
{
CARD_FEATURE_MEMORY = 0x1,
CARD_FEATURE_SDHC = 0x1 << 1,
CARD_FEATURE_SDIO = 0x1 << 2,
CARD_FEATURE_SD20 = 0x1 << 3,
CARD_FEATURE_MMC = 0x1 << 4,
CARD_FEATURE_18V = 0x1 << 5,
CardFeatureMemory = 0x1,
CardFeatureSdhc = 0x1 << 1,
CardFeatureSdio = 0x1 << 2,
CardFeatureSd20 = 0x1 << 3,
CardFeatureMmc = 0x1 << 4,
CardFeature18V = 0x1 << 5,
}
enum cam_generations : uint
enum CamGenerations : uint
{
CAM_BUS_GENERATION = 0x00,
CAM_TARGET_GENERATION = 0x01,
CAM_DEV_GENERATION = 0x02,
CAM_PERIPH_GENERATION = 0x03,
CamBusGeneration = 0x00,
CamTargetGeneration = 0x01,
CamDevGeneration = 0x02,
CamPeriphGeneration = 0x03,
}
[Flags]
enum dev_pos_type
enum DevPosType
{
CAM_DEV_POS_NONE = 0x000,
CAM_DEV_POS_BUS = 0x001,
CAM_DEV_POS_TARGET = 0x002,
CAM_DEV_POS_DEVICE = 0x004,
CAM_DEV_POS_PERIPH = 0x008,
CAM_DEV_POS_PDPTR = 0x010,
CamDevPosNone = 0x000,
CamDevPosBus = 0x001,
CamDevPosTarget = 0x002,
CamDevPosDevice = 0x004,
CamDevPosPeriph = 0x008,
CamDevPosPdptr = 0x010,
// CAM_DEV_POS_TYPEMASK = 0xf00,
CAM_DEV_POS_EDT = 0x100,
CAM_DEV_POS_PDRV = 0x200
CamDevPosEdt = 0x100,
CamDevPosPdrv = 0x200
}
enum FreebsdIoctl : uint
{
CAMIOCOMMAND = 0xC4D81802,
Camiocommand = 0xC4D81802,
}
[Flags]
enum ccb_flags : uint
enum CcbFlags : uint
{
/// <summary>
/// The CDB field is a pointer
/// </summary>
CAM_CDB_POINTER = 0x00000001,
CamCdbPointer = 0x00000001,
/// <summary>
/// SIM queue actions are enabled
/// </summary>
CAM_QUEUE_ENABLE = 0x00000002,
CamQueueEnable = 0x00000002,
/// <summary>
/// CCB contains a linked CDB
/// </summary>
CAM_CDB_LINKED = 0x00000004,
CamCdbLinked = 0x00000004,
/// <summary>
/// Perform transport negotiation with this command.
/// </summary>
CAM_NEGOTIATE = 0x00000008,
CamNegotiate = 0x00000008,
/// <summary>
/// Data type with physical addrs
/// </summary>
CAM_DATA_ISPHYS = 0x00000010,
CamDataIsphys = 0x00000010,
/// <summary>
/// Disable autosense feature
/// </summary>
CAM_DIS_AUTOSENSE = 0x00000020,
CamDisAutosense = 0x00000020,
/// <summary>
/// Data direction (00:IN/OUT)
/// </summary>
CAM_DIR_BOTH = 0x00000000,
CamDirBoth = 0x00000000,
/// <summary>
/// Data direction (01:DATA IN)
/// </summary>
CAM_DIR_IN = 0x00000040,
CamDirIn = 0x00000040,
/// <summary>
/// Data direction (10:DATA OUT)
/// </summary>
CAM_DIR_OUT = 0x00000080,
CamDirOut = 0x00000080,
/// <summary>
/// Data direction (11:no data)
/// </summary>
CAM_DIR_NONE = 0x000000C0,
CamDirNone = 0x000000C0,
/// <summary>
/// Data type (000:Virtual)
/// </summary>
CAM_DATA_VADDR = 0x00000000,
CamDataVaddr = 0x00000000,
/// <summary>
/// Data type (001:Physical)
/// </summary>
CAM_DATA_PADDR = 0x00000010,
CamDataPaddr = 0x00000010,
/// <summary>
/// Data type (010:sglist)
/// </summary>
CAM_DATA_SG = 0x00040000,
CamDataSg = 0x00040000,
/// <summary>
/// Data type (011:sglist phys)
/// </summary>
CAM_DATA_SG_PADDR = 0x00040010,
CamDataSgPaddr = 0x00040010,
/// <summary>
/// Data type (100:bio)
/// </summary>
CAM_DATA_BIO = 0x00200000,
CamDataBio = 0x00200000,
/// <summary>
/// Use Soft reset alternative
/// </summary>
CAM_SOFT_RST_OP = 0x00000100,
CamSoftRstOp = 0x00000100,
/// <summary>
/// Flush resid bytes on complete
/// </summary>
CAM_ENG_SYNC = 0x00000200,
CamEngSync = 0x00000200,
/// <summary>
/// Disable DEV Q freezing
/// </summary>
CAM_DEV_QFRZDIS = 0x00000400,
CamDevQfrzdis = 0x00000400,
/// <summary>
/// Freeze DEV Q on execution
/// </summary>
CAM_DEV_QFREEZE = 0x00000800,
CamDevQfreeze = 0x00000800,
/// <summary>
/// Command takes a lot of power
/// </summary>
CAM_HIGH_POWER = 0x00001000,
CamHighPower = 0x00001000,
/// <summary>
/// Sense data is a pointer
/// </summary>
CAM_SENSE_PTR = 0x00002000,
CamSensePtr = 0x00002000,
/// <summary>
/// Sense pointer is physical addr
/// </summary>
CAM_SENSE_PHYS = 0x00004000,
CamSensePhys = 0x00004000,
/// <summary>
/// Use the tag action in this ccb
/// </summary>
CAM_TAG_ACTION_VALID = 0x00008000,
CamTagActionValid = 0x00008000,
/// <summary>
/// Pass driver does err. recovery
/// </summary>
CAM_PASS_ERR_RECOVER = 0x00010000,
CamPassErrRecover = 0x00010000,
/// <summary>
/// Disable disconnect
/// </summary>
CAM_DIS_DISCONNECT = 0x00020000,
CamDisDisconnect = 0x00020000,
/// <summary>
/// Message buffer ptr is physical
/// </summary>
CAM_MSG_BUF_PHYS = 0x00080000,
CamMsgBufPhys = 0x00080000,
/// <summary>
/// Autosense data ptr is physical
/// </summary>
CAM_SNS_BUF_PHYS = 0x00100000,
CamSnsBufPhys = 0x00100000,
/// <summary>
/// CDB poiner is physical
/// </summary>
CAM_CDB_PHYS = 0x00400000,
CamCdbPhys = 0x00400000,
/// <summary>
/// SG list is for the HBA engine
/// </summary>
CAM_ENG_SGLIST = 0x00800000,
CamEngSglist = 0x00800000,
/* Phase cognizant mode flags */
/// <summary>
/// Disable autosave/restore ptrs
/// </summary>
CAM_DIS_AUTOSRP = 0x01000000,
CamDisAutosrp = 0x01000000,
/// <summary>
/// Disable auto disconnect
/// </summary>
CAM_DIS_AUTODISC = 0x02000000,
CamDisAutodisc = 0x02000000,
/// <summary>
/// Target CCB available
/// </summary>
CAM_TGT_CCB_AVAIL = 0x04000000,
CamTgtCcbAvail = 0x04000000,
/// <summary>
/// The SIM runs in phase mode
/// </summary>
CAM_TGT_PHASE_MODE = 0x08000000,
CamTgtPhaseMode = 0x08000000,
/// <summary>
/// Message buffer valid
/// </summary>
CAM_MSGB_VALID = 0x10000000,
CamMsgbValid = 0x10000000,
/// <summary>
/// Status buffer valid
/// </summary>
CAM_STATUS_VALID = 0x20000000,
CamStatusValid = 0x20000000,
/// <summary>
/// Data buffer valid
/// </summary>
CAM_DATAB_VALID = 0x40000000,
CamDatabValid = 0x40000000,
/* Host target Mode flags */
/// <summary>
/// Send sense data with status
/// </summary>
CAM_SEND_SENSE = 0x08000000,
CamSendSense = 0x08000000,
/// <summary>
/// Terminate I/O Message sup.
/// </summary>
CAM_TERM_IO = 0x10000000,
CamTermIo = 0x10000000,
/// <summary>
/// Disconnects are mandatory
/// </summary>
CAM_DISCONNECT = 0x20000000,
CamDisconnect = 0x20000000,
/// <summary>
/// Send status after data phase
/// </summary>
CAM_SEND_STATUS = 0x40000000,
CamSendStatus = 0x40000000,
/// <summary>
/// Call callback without lock.
/// </summary>
CAM_UNLOCKED = 0x80000000
CamUnlocked = 0x80000000
}
enum cam_status : uint
enum CamStatus : uint
{
/// <summary>CCB request is in progress</summary>
CAM_REQ_INPROG = 0x00,
CamReqInprog = 0x00,
/// <summary>CCB request completed without error</summary>
CAM_REQ_CMP = 0x01,
CamReqCmp = 0x01,
/// <summary>CCB request aborted by the host</summary>
CAM_REQ_ABORTED = 0x02,
CamReqAborted = 0x02,
/// <summary>Unable to abort CCB request</summary>
CAM_UA_ABORT = 0x03,
CamUaAbort = 0x03,
/// <summary>CCB request completed with an error</summary>
CAM_REQ_CMP_ERR = 0x04,
CamReqCmpErr = 0x04,
/// <summary>CAM subsystem is busy</summary>
CAM_BUSY = 0x05,
CamBusy = 0x05,
/// <summary>CCB request was invalid</summary>
CAM_REQ_INVALID = 0x06,
CamReqInvalid = 0x06,
/// <summary>Supplied Path ID is invalid</summary>
CAM_PATH_INVALID = 0x07,
CamPathInvalid = 0x07,
/// <summary>SCSI Device Not Installed/there</summary>
CAM_DEV_NOT_THERE = 0x08,
CamDevNotThere = 0x08,
/// <summary>Unable to terminate I/O CCB request</summary>
CAM_UA_TERMIO = 0x09,
CamUaTermio = 0x09,
/// <summary>Target Selection Timeout</summary>
CAM_SEL_TIMEOUT = 0x0a,
CamSelTimeout = 0x0a,
/// <summary>Command timeout</summary>
CAM_CMD_TIMEOUT = 0x0b,
CamCmdTimeout = 0x0b,
/// <summary>SCSI error, look at error code in CCB</summary>
CAM_SCSI_STATUS_ERROR = 0x0c,
CamScsiStatusError = 0x0c,
/// <summary>Message Reject Received</summary>
CAM_MSG_REJECT_REC = 0x0d,
CamMsgRejectRec = 0x0d,
/// <summary>SCSI Bus Reset Sent/Received</summary>
CAM_SCSI_BUS_RESET = 0x0e,
CamScsiBusReset = 0x0e,
/// <summary>Uncorrectable parity error occurred</summary>
CAM_UNCOR_PARITY = 0x0f,
CamUncorParity = 0x0f,
/// <summary>Autosense: request sense cmd fail</summary>
CAM_AUTOSENSE_FAIL = 0x10,
CamAutosenseFail = 0x10,
/// <summary>No HBA Detected error</summary>
CAM_NO_HBA = 0x11,
CamNoHba = 0x11,
/// <summary>Data Overrun error</summary>
CAM_DATA_RUN_ERR = 0x12,
CamDataRunErr = 0x12,
/// <summary>Unexpected Bus Free</summary>
CAM_UNEXP_BUSFREE = 0x13,
CamUnexpBusfree = 0x13,
/// <summary>Target Bus Phase Sequence Failure</summary>
CAM_SEQUENCE_FAIL = 0x14,
CamSequenceFail = 0x14,
/// <summary>CCB length supplied is inadequate</summary>
CAM_CCB_LEN_ERR = 0x15,
CamCcbLenErr = 0x15,
/// <summary>Unable to provide requested capability</summary>
CAM_PROVIDE_FAIL = 0x16,
CamProvideFail = 0x16,
/// <summary>A SCSI BDR msg was sent to target</summary>
CAM_BDR_SENT = 0x17,
CamBdrSent = 0x17,
/// <summary>CCB request terminated by the host</summary>
CAM_REQ_TERMIO = 0x18,
CamReqTermio = 0x18,
/// <summary>Unrecoverable Host Bus Adapter Error</summary>
CAM_UNREC_HBA_ERROR = 0x19,
CamUnrecHbaError = 0x19,
/// <summary>Request was too large for this host</summary>
CAM_REQ_TOO_BIG = 0x1a,
CamReqTooBig = 0x1a,
/// <summary>This request should be requeued to preserve transaction ordering. This typically occurs when the SIM recognizes an error that should freeze the queue and must place additional requests for the target at the sim level back into the XPT queue.</summary>
CAM_REQUEUE_REQ = 0x1b,
CamRequeueReq = 0x1b,
/// <summary>ATA error, look at error code in CCB</summary>
CAM_ATA_STATUS_ERROR = 0x1c,
CamAtaStatusError = 0x1c,
/// <summary>Initiator/Target Nexus lost.</summary>
CAM_SCSI_IT_NEXUS_LOST = 0x1d,
CamScsiItNexusLost = 0x1d,
/// <summary>SMP error, look at error code in CCB</summary>
CAM_SMP_STATUS_ERROR = 0x1e,
CamSmpStatusError = 0x1e,
/// <summary>Command completed without error but exceeded the soft timeout threshold.</summary>
CAM_REQ_SOFTTIMEOUT = 0x1f,
CamReqSofttimeout = 0x1f,
/*
* 0x20 - 0x32 are unassigned
*/
/// <summary>Initiator Detected Error</summary>
CAM_IDE = 0x33,
CamIde = 0x33,
/// <summary>Resource Unavailable</summary>
CAM_RESRC_UNAVAIL = 0x34,
CamResrcUnavail = 0x34,
/// <summary>Unacknowledged Event by Host</summary>
CAM_UNACKED_EVENT = 0x35,
CamUnackedEvent = 0x35,
/// <summary>Message Received in Host Target Mode</summary>
CAM_MESSAGE_RECV = 0x36,
CamMessageRecv = 0x36,
/// <summary>Invalid CDB received in Host Target Mode</summary>
CAM_INVALID_CDB = 0x37,
CamInvalidCdb = 0x37,
/// <summary>Lun supplied is invalid</summary>
CAM_LUN_INVALID = 0x38,
CamLunInvalid = 0x38,
/// <summary>Target ID supplied is invalid</summary>
CAM_TID_INVALID = 0x39,
CamTidInvalid = 0x39,
/// <summary>The requested function is not available</summary>
CAM_FUNC_NOTAVAIL = 0x3a,
CamFuncNotavail = 0x3a,
/// <summary>Nexus is not established</summary>
CAM_NO_NEXUS = 0x3b,
CamNoNexus = 0x3b,
/// <summary>The initiator ID is invalid</summary>
CAM_IID_INVALID = 0x3c,
CamIidInvalid = 0x3c,
/// <summary>The SCSI CDB has been received</summary>
CAM_CDB_RECVD = 0x3d,
CamCdbRecvd = 0x3d,
/// <summary>The LUN is already enabled for target mode</summary>
CAM_LUN_ALRDY_ENA = 0x3e,
CamLunAlrdyEna = 0x3e,
/// <summary>SCSI Bus Busy</summary>
CAM_SCSI_BUSY = 0x3f,
CamScsiBusy = 0x3f,
/*
* Flags
*/
/// <summary>The DEV queue is frozen w/this err</summary>
CAM_DEV_QFRZN = 0x40,
CamDevQfrzn = 0x40,
/// <summary>Autosense data valid for target</summary>
CAM_AUTOSNS_VALID = 0x80,
CamAutosnsValid = 0x80,
/// <summary>SIM ready to take more commands</summary>
CAM_RELEASE_SIMQ = 0x100,
CamReleaseSimq = 0x100,
/// <summary>SIM has this command in its queue</summary>
CAM_SIM_QUEUED = 0x200,
CamSimQueued = 0x200,
/// <summary>Quality of service data is valid</summary>
CAM_QOS_VALID = 0x400,
CamQosValid = 0x400,
/// <summary>Mask bits for just the status #</summary>
CAM_STATUS_MASK = 0x3F,
CamStatusMask = 0x3F,
/*
* Target Specific Adjunct Status
*/
/// <summary>sent sense with status</summary>
CAM_SENT_SENSE = 0x40000000
CamSentSense = 0x40000000
}
}

View File

@@ -50,15 +50,15 @@ namespace DiscImageChef.Devices.FreeBSD
{
DeviceInfo deviceInfo = new DeviceInfo();
IntPtr dev = cam_open_device(passDevice, FileFlags.ReadWrite);
cam_device camDevice = (cam_device)Marshal.PtrToStructure(dev, typeof(cam_device));
CamDevice camDevice = (CamDevice)Marshal.PtrToStructure(dev, typeof(CamDevice));
IntPtr ccbPtr = cam_getccb(dev);
if(ccbPtr.ToInt64() == 0) continue;
ccb_getdev cgd = (ccb_getdev)Marshal.PtrToStructure(ccbPtr, typeof(ccb_getdev));
CcbGetdev cgd = (CcbGetdev)Marshal.PtrToStructure(ccbPtr, typeof(CcbGetdev));
cgd.ccb_h.func_code = xpt_opcode.XPT_GDEV_TYPE;
cgd.ccb_h.func_code = XptOpcode.XptGdevType;
Marshal.StructureToPtr(cgd, ccbPtr, false);
@@ -70,22 +70,22 @@ namespace DiscImageChef.Devices.FreeBSD
continue;
}
cgd = (ccb_getdev)Marshal.PtrToStructure(ccbPtr, typeof(ccb_getdev));
cgd = (CcbGetdev)Marshal.PtrToStructure(ccbPtr, typeof(CcbGetdev));
cam_freeccb(ccbPtr);
cam_close_device(dev);
string simName = StringHandlers.CToString(camDevice.sim_name);
deviceInfo.path = passDevice;
byte[] serialNumber = new byte[camDevice.serial_num_len];
Array.Copy(camDevice.serial_num, 0, serialNumber, 0, serialNumber.Length);
deviceInfo.serial = StringHandlers.CToString(serialNumber);
string simName = StringHandlers.CToString(camDevice.SimName);
deviceInfo.Path = passDevice;
byte[] serialNumber = new byte[camDevice.SerialNumLen];
Array.Copy(camDevice.SerialNum, 0, serialNumber, 0, serialNumber.Length);
deviceInfo.Serial = StringHandlers.CToString(serialNumber);
switch(cgd.protocol)
{
case cam_proto.PROTO_ATA:
case cam_proto.PROTO_ATAPI:
case cam_proto.PROTO_SATAPM:
case CamProto.ProtoAta:
case CamProto.ProtoAtapi:
case CamProto.ProtoSatapm:
{
// Little-endian FreeBSD gives it resorted
// Big-endian FreeBSD, no idea
@@ -103,49 +103,49 @@ namespace DiscImageChef.Devices.FreeBSD
if(separated.Length == 1)
{
deviceInfo.vendor = "ATA";
deviceInfo.model = separated[0];
deviceInfo.Vendor = "ATA";
deviceInfo.Model = separated[0];
}
else
{
deviceInfo.vendor = separated[0];
deviceInfo.model = separated[separated.Length - 1];
deviceInfo.Vendor = separated[0];
deviceInfo.Model = separated[separated.Length - 1];
}
deviceInfo.serial = idt.Value.SerialNumber;
deviceInfo.bus = simName == "ahcich" ? "SATA" : "ATA";
deviceInfo.supported = simName != "ata";
deviceInfo.Serial = idt.Value.SerialNumber;
deviceInfo.Bus = simName == "ahcich" ? "SATA" : "ATA";
deviceInfo.Supported = simName != "ata";
}
if(cgd.protocol == cam_proto.PROTO_ATAPI) goto case cam_proto.PROTO_SCSI;
if(cgd.protocol == CamProto.ProtoAtapi) goto case CamProto.ProtoScsi;
break;
}
case cam_proto.PROTO_SCSI:
case CamProto.ProtoScsi:
{
Decoders.SCSI.Inquiry.SCSIInquiry? inq = Decoders.SCSI.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.supported = simName != "ata";
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 cam_proto.PROTO_NVME:
deviceInfo.bus = "NVMe";
deviceInfo.supported = false;
case CamProto.ProtoNvme:
deviceInfo.Bus = "NVMe";
deviceInfo.Supported = false;
break;
case cam_proto.PROTO_MMCSD:
deviceInfo.model = "Unknown card";
deviceInfo.bus = "MMC/SD";
deviceInfo.supported = false;
case CamProto.ProtoMmcsd:
deviceInfo.Model = "Unknown card";
deviceInfo.Bus = "MMC/SD";
deviceInfo.Supported = false;
break;
}
listDevices.Add(deviceInfo);
}
return listDevices.Count > 0 ? listDevices.OrderBy(t => t.path).ToArray() : null;
return listDevices.Count > 0 ? listDevices.OrderBy(t => t.Path).ToArray() : null;
}
}
}

View File

@@ -40,7 +40,7 @@ using target_id_t = System.UInt32;
namespace DiscImageChef.Devices.FreeBSD
{
[StructLayout(LayoutKind.Sequential)]
struct ata_cmd
struct AtaCmd
{
public CamAtaIoFlags flags;
public byte command;
@@ -59,7 +59,7 @@ namespace DiscImageChef.Devices.FreeBSD
}
[StructLayout(LayoutKind.Sequential)]
struct ata_res
struct AtaRes
{
public CamAtaIoFlags flags;
public byte status;
@@ -76,64 +76,64 @@ namespace DiscImageChef.Devices.FreeBSD
}
[StructLayout(LayoutKind.Sequential)]
struct cam_pinfo
struct CamPinfo
{
public uint priority;
public uint generation;
public int index;
}
struct LIST_ENTRY
struct ListEntry
{
/// <summary>
/// LIST_ENTRY(ccb_hdr)=le->*le_next
/// </summary>
public IntPtr le_next;
public IntPtr LeNext;
/// <summary>
/// LIST_ENTRY(ccb_hdr)=le->**le_prev
/// </summary>
public IntPtr le_prev;
public IntPtr LePrev;
}
struct SLIST_ENTRY
struct SlistEntry
{
/// <summary>
/// SLIST_ENTRY(ccb_hdr)=sle->*sle_next
/// </summary>
public IntPtr sle_next;
public IntPtr SleNext;
}
struct TAILQ_ENTRY
struct TailqEntry
{
/// <summary>
/// TAILQ_ENTRY(ccb_hdr)=tqe->*tqe_next
/// </summary>
public IntPtr tqe_next;
public IntPtr TqeNext;
/// <summary>
/// TAILQ_ENTRY(ccb_hdr)=tqe->**tqe_prev
/// </summary>
public IntPtr tqe_prev;
public IntPtr TqePrev;
}
struct STAILQ_ENTRY
struct StailqEntry
{
/// <summary>
/// STAILQ_ENTRY(ccb_hdr)=stqe->*stqe_next
/// </summary>
public IntPtr stqe_next;
public IntPtr StqeNext;
}
[StructLayout(LayoutKind.Explicit)]
struct camq_entry
struct CamqEntry
{
[FieldOffset(0)] public LIST_ENTRY le;
[FieldOffset(0)] public SLIST_ENTRY sle;
[FieldOffset(0)] public TAILQ_ENTRY tqe;
[FieldOffset(0)] public STAILQ_ENTRY stqe;
[FieldOffset(0)] public ListEntry le;
[FieldOffset(0)] public SlistEntry sle;
[FieldOffset(0)] public TailqEntry tqe;
[FieldOffset(0)] public StailqEntry stqe;
}
[StructLayout(LayoutKind.Sequential)]
struct timeval
struct Timeval
{
public long tv_sec;
/// <summary>long</summary>
@@ -141,39 +141,39 @@ namespace DiscImageChef.Devices.FreeBSD
}
[StructLayout(LayoutKind.Sequential)]
struct ccb_qos_area
struct CcbQosArea
{
public timeval etime;
public Timeval etime;
public UIntPtr sim_data;
public UIntPtr periph_data;
}
[StructLayout(LayoutKind.Sequential)]
struct ccb_hdr
struct CcbHdr
{
public cam_pinfo pinfo;
public camq_entry xpt_links;
public camq_entry sim_links;
public camq_entry periph_links;
public CamPinfo pinfo;
public CamqEntry xpt_links;
public CamqEntry sim_links;
public CamqEntry periph_links;
public uint retry_count;
public IntPtr cbfcnp;
public xpt_opcode func_code;
public cam_status status;
public XptOpcode func_code;
public CamStatus status;
public IntPtr path;
public uint path_id;
public uint target_id;
public ulong target_lun;
public ccb_flags flags;
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 ccb_qos_area qos;
public CcbQosArea qos;
public uint timeout;
public timeval softtimeout;
public Timeval softtimeout;
}
[StructLayout(LayoutKind.Sequential)]
struct scsi_sense_data
struct ScsiSenseData
{
const int SSD_FULL_SIZE = 252;
public byte error_code;
@@ -184,9 +184,9 @@ namespace DiscImageChef.Devices.FreeBSD
/// SCSI I/O Request CCB used for the XPT_SCSI_IO and XPT_CONT_TARGET_IO function codes.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
struct ccb_scsiio
struct CcbScsiio
{
public ccb_hdr ccb_h;
public CcbHdr ccb_h;
/// <summary>Ptr for next CCB for action</summary>
public IntPtr next_ccb;
/// <summary>Ptr to mapping info</summary>
@@ -196,7 +196,7 @@ namespace DiscImageChef.Devices.FreeBSD
/// <summary>Data transfer length</summary>
public uint dxfer_len;
/// <summary>Autosense storage</summary>
public scsi_sense_data sense_data;
public ScsiSenseData sense_data;
/// <summary>Number of bytes to autosense</summary>
public byte sense_len;
/// <summary>Number of bytes for the CDB</summary>
@@ -230,9 +230,9 @@ namespace DiscImageChef.Devices.FreeBSD
/// SCSI I/O Request CCB used for the XPT_SCSI_IO and XPT_CONT_TARGET_IO function codes.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
struct ccb_scsiio64
struct CcbScsiio64
{
public ccb_hdr ccb_h;
public CcbHdr ccb_h;
/// <summary>Ptr for next CCB for action</summary>
public IntPtr next_ccb;
/// <summary>Ptr to mapping info</summary>
@@ -242,7 +242,7 @@ namespace DiscImageChef.Devices.FreeBSD
/// <summary>Data transfer length</summary>
public uint dxfer_len;
/// <summary>Autosense storage</summary>
public scsi_sense_data sense_data;
public ScsiSenseData sense_data;
/// <summary>Number of bytes to autosense</summary>
public byte sense_len;
/// <summary>Number of bytes for the CDB</summary>
@@ -277,15 +277,15 @@ namespace DiscImageChef.Devices.FreeBSD
/// ATA I/O Request CCB used for the XPT_ATA_IO function code.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
struct ccb_ataio
struct CcbAtaio
{
public ccb_hdr ccb_h;
public CcbHdr ccb_h;
/// <summary>Ptr for next CCB for action</summary>
public IntPtr next_ccb;
/// <summary>ATA command register set</summary>
public ata_cmd cmd;
public AtaCmd cmd;
/// <summary>ATA result register set</summary>
public ata_res res;
public AtaRes res;
/// <summary>Ptr to the data buf/SG list</summary>
public IntPtr data_ptr;
/// <summary>Data transfer length</summary>
@@ -299,7 +299,7 @@ namespace DiscImageChef.Devices.FreeBSD
}
[StructLayout(LayoutKind.Sequential)]
struct nvme_command
struct NvmeCommand
{
private ushort opc_fuse_rsvd1;
/// <summary>
@@ -358,55 +358,55 @@ namespace DiscImageChef.Devices.FreeBSD
/// <summary>
/// opcode
/// </summary>
public byte opc => (byte)((opc_fuse_rsvd1 & 0xFF00) >> 8);
public byte Opc => (byte)((opc_fuse_rsvd1 & 0xFF00) >> 8);
/// <summary>
/// fused operation
/// </summary>
public byte fuse => (byte)((opc_fuse_rsvd1 & 0xC0) >> 6);
public byte Fuse => (byte)((opc_fuse_rsvd1 & 0xC0) >> 6);
/// <summary>
/// reserved
/// </summary>
public byte rsvd1 => (byte)(opc_fuse_rsvd1 & 0x3F);
public byte Rsvd1 => (byte)(opc_fuse_rsvd1 & 0x3F);
}
[StructLayout(LayoutKind.Sequential)]
struct nvme_status
struct NvmeStatus
{
private ushort status;
/// <summary>
/// phase tag
/// </summary>
public byte p => (byte)((status & 0x8000) >> 15);
public byte P => (byte)((status & 0x8000) >> 15);
/// <summary>
/// status code
/// </summary>
public byte sc => (byte)((status & 0x7F80) >> 7);
public byte Sc => (byte)((status & 0x7F80) >> 7);
/// <summary>
/// status code type
/// </summary>
public byte sct => (byte)((status & 0x70) >> 4);
public byte Sct => (byte)((status & 0x70) >> 4);
/// <summary>
/// reserved
/// </summary>
public byte rsvd2 => (byte)((status & 0xC) >> 15);
public byte Rsvd2 => (byte)((status & 0xC) >> 15);
/// <summary>
/// more
/// </summary>
public byte m => (byte)((status & 0x2) >> 1);
public byte M => (byte)((status & 0x2) >> 1);
/// <summary>
/// do not retry
/// </summary>
public byte dnr => (byte)(status & 0x1);
public byte Dnr => (byte)(status & 0x1);
}
[StructLayout(LayoutKind.Sequential)]
struct nvme_completion
struct NvmeCompletion
{
/// <summary>
/// command-specific
@@ -433,22 +433,22 @@ namespace DiscImageChef.Devices.FreeBSD
/// </summary>
public ushort cid;
public nvme_status status;
public NvmeStatus status;
}
/// <summary>
/// NVMe I/O Request CCB used for the XPT_NVME_IO and XPT_NVME_ADMIN function codes.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
struct ccb_nvmeio
struct CcbNvmeio
{
public ccb_hdr ccb_h;
public CcbHdr ccb_h;
/// <summary>Ptr for next CCB for action</summary>
public IntPtr next_ccb;
/// <summary>NVME command, per NVME standard</summary>
public nvme_command cmd;
public NvmeCommand cmd;
/// <summary>NVME completion, per NVME standard</summary>
public nvme_completion cpl;
public NvmeCompletion cpl;
/// <summary>Ptr to the data buf/SG list</summary>
public IntPtr data_ptr;
/// <summary>Data transfer length</summary>
@@ -460,7 +460,7 @@ namespace DiscImageChef.Devices.FreeBSD
}
[StructLayout(LayoutKind.Sequential)]
struct periph_match_pattern
struct PeriphMatchPattern
{
private const int DEV_IDLEN = 16;
@@ -469,18 +469,18 @@ namespace DiscImageChef.Devices.FreeBSD
public path_id_t path_id;
public target_id_t target_id;
public lun_id_t target_lun;
public periph_pattern_flags flags;
public PeriphPatternFlags flags;
}
[StructLayout(LayoutKind.Sequential)]
struct device_id_match_pattern
struct DeviceIdMatchPattern
{
public byte id_len;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public byte[] id;
}
[StructLayout(LayoutKind.Sequential)]
struct scsi_static_inquiry_pattern
struct ScsiStaticInquiryPattern
{
private const int SID_VENDOR_SIZE = 8;
private const int SID_PRODUCT_SIZE = 16;
@@ -493,24 +493,24 @@ namespace DiscImageChef.Devices.FreeBSD
}
[StructLayout(LayoutKind.Explicit)]
struct device_match_pattern_data
struct DeviceMatchPatternData
{
[FieldOffset(0)] public scsi_static_inquiry_pattern inq_pat;
[FieldOffset(0)] public device_id_match_pattern devid_pat;
[FieldOffset(0)] public ScsiStaticInquiryPattern inq_pat;
[FieldOffset(0)] public DeviceIdMatchPattern devid_pat;
}
[StructLayout(LayoutKind.Sequential)]
struct device_match_pattern
struct DeviceMatchPattern
{
public path_id_t path_id;
public target_id_t target_id;
public lun_id_t target_lun;
public dev_pattern_flags flags;
public device_match_pattern_data data;
public DevPatternFlags flags;
public DeviceMatchPatternData data;
}
[StructLayout(LayoutKind.Sequential)]
struct bus_match_pattern
struct BusMatchPattern
{
private const int DEV_IDLEN = 16;
@@ -518,26 +518,26 @@ namespace DiscImageChef.Devices.FreeBSD
[MarshalAs(UnmanagedType.ByValArray, SizeConst = DEV_IDLEN)] public byte[] dev_name;
public uint unit_number;
public uint bus_id;
bus_pattern_flags flags;
BusPatternFlags flags;
}
[StructLayout(LayoutKind.Explicit)]
struct match_pattern
struct MatchPattern
{
[FieldOffset(0)] public periph_match_pattern periph_pattern;
[FieldOffset(0)] public device_match_pattern device_pattern;
[FieldOffset(0)] public bus_match_pattern bus_pattern;
[FieldOffset(0)] public PeriphMatchPattern periph_pattern;
[FieldOffset(0)] public DeviceMatchPattern device_pattern;
[FieldOffset(0)] public BusMatchPattern bus_pattern;
}
[StructLayout(LayoutKind.Sequential)]
struct dev_match_pattern
struct DevMatchPattern
{
public dev_match_type type;
public match_pattern pattern;
public DevMatchType type;
public MatchPattern pattern;
}
[StructLayout(LayoutKind.Sequential)]
struct periph_match_result
struct PeriphMatchResult
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] periph_name;
public uint unit_number;
@@ -547,7 +547,7 @@ namespace DiscImageChef.Devices.FreeBSD
}
[StructLayout(LayoutKind.Sequential)]
struct mmc_cid
struct MmcCid
{
public uint mid;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] pnm;
@@ -560,7 +560,7 @@ namespace DiscImageChef.Devices.FreeBSD
}
[StructLayout(LayoutKind.Sequential)]
struct mmc_params
struct MmcParams
{
/// <summary>
/// Card model
@@ -585,7 +585,7 @@ namespace DiscImageChef.Devices.FreeBSD
/// <summary>
/// Card CID -- parsed
/// </summary>
public mmc_cid cid;
public MmcCid cid;
/// <summary>
/// Card CSD -- raw
@@ -600,26 +600,26 @@ namespace DiscImageChef.Devices.FreeBSD
/// <summary>
/// What kind of card is it
/// </summary>
public mmc_card_features card_features;
public MmcCardFeatures card_features;
public byte sdio_func_count;
}
[StructLayout(LayoutKind.Sequential)]
struct device_match_result
struct DeviceMatchResult
{
public path_id_t path_id;
public target_id_t target_id;
public lun_id_t target_lun;
public cam_proto protocol;
public CamProto protocol;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public byte[] inq_data;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)] public byte[] ident_data;
public dev_result_flags flags;
public mmc_params mmc_ident_data;
public DevResultFlags flags;
public MmcParams mmc_ident_data;
}
[StructLayout(LayoutKind.Sequential)]
struct bus_match_result
struct BusMatchResult
{
public path_id_t path_id;
private const int DEV_IDLEN = 16;
@@ -629,22 +629,22 @@ namespace DiscImageChef.Devices.FreeBSD
}
[StructLayout(LayoutKind.Explicit)]
struct match_result
struct MatchResult
{
[FieldOffset(0)] public periph_match_result periph_result;
[FieldOffset(0)] public device_match_result device_result;
[FieldOffset(0)] public bus_match_result bus_result;
[FieldOffset(0)] public PeriphMatchResult periph_result;
[FieldOffset(0)] public DeviceMatchResult device_result;
[FieldOffset(0)] public BusMatchResult bus_result;
}
[StructLayout(LayoutKind.Sequential)]
struct dev_match_result
struct DevMatchResult
{
public dev_match_type type;
public match_result result;
public DevMatchType type;
public MatchResult result;
}
[StructLayout(LayoutKind.Sequential)]
struct ccb_dm_cookie
struct CcbDmCookie
{
public IntPtr bus;
public IntPtr target;
@@ -654,18 +654,18 @@ namespace DiscImageChef.Devices.FreeBSD
}
[StructLayout(LayoutKind.Sequential)]
struct ccb_dev_position
struct CcbDevPosition
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public cam_generations[] generations;
dev_pos_type position_type;
public ccb_dm_cookie cookie;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public CamGenerations[] generations;
DevPosType position_type;
public CcbDmCookie cookie;
}
[StructLayout(LayoutKind.Sequential)]
struct ccb_dev_match
struct CcbDevMatch
{
public ccb_hdr ccb_h;
ccb_dev_match_status status;
public CcbHdr ccb_h;
CcbDevMatchStatus status;
public uint num_patterns;
public uint pattern_buf_len;
@@ -682,10 +682,10 @@ namespace DiscImageChef.Devices.FreeBSD
/// </summary>
public IntPtr matches;
public ccb_dev_position pos;
public CcbDevPosition pos;
}
struct cam_device
struct CamDevice
{
private const int MAXPATHLEN = 1024;
private const int DEV_IDLEN = 16;
@@ -693,86 +693,86 @@ namespace DiscImageChef.Devices.FreeBSD
/// <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[] device_path;
[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[] given_dev_name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = DEV_IDLEN + 1)] public byte[] GivenDevName;
/// <summary>
/// Unit number given by the user.
/// </summary>
public uint given_unit_number;
public uint GivenUnitNumber;
/// <summary>
/// Name of the device, e.g. 'pass'
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = DEV_IDLEN + 1)] public byte[] device_name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = DEV_IDLEN + 1)] public byte[] DeviceName;
/// <summary>
/// Unit number of the passthrough device associated with this particular device.
/// </summary>
public uint dev_unit_num;
public uint DevUnitNum;
/// <summary>
/// Controller name, e.g. 'ahc'
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = SIM_IDLEN + 1)] public byte[] sim_name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = SIM_IDLEN + 1)] public byte[] SimName;
/// <summary>
/// Controller unit number
/// </summary>
public uint sim_unit_number;
public uint SimUnitNumber;
/// <summary>
/// Controller bus number
/// </summary>
public uint bus_id;
public uint BusId;
/// <summary>
/// Logical Unit Number
/// </summary>
public lun_id_t target_lun;
public lun_id_t TargetLun;
/// <summary>
/// Target ID
/// </summary>
public target_id_t target_id;
public target_id_t TargetId;
/// <summary>
/// System SCSI bus number
/// </summary>
public path_id_t path_id;
public path_id_t PathId;
/// <summary>
/// type of peripheral device
/// </summary>
public ushort pd_type;
public ushort PdType;
/// <summary>
/// SCSI Inquiry data
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public byte[] inq_data;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public byte[] InqData;
/// <summary>
/// device serial number
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 252)] public byte[] serial_num;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 252)] public byte[] SerialNum;
/// <summary>
/// length of the serial number
/// </summary>
public byte serial_num_len;
public byte SerialNumLen;
/// <summary>
/// Negotiated sync period
/// </summary>
public byte sync_period;
public byte SyncPeriod;
/// <summary>
/// Negotiated sync offset
/// </summary>
public byte sync_offset;
public byte SyncOffset;
/// <summary>
/// Negotiated bus width
/// </summary>
public byte bus_width;
public byte BusWidth;
/// <summary>
/// file descriptor for device
/// </summary>
public int fd;
public int Fd;
}
[StructLayout(LayoutKind.Sequential)]
struct ccb_getdev
struct CcbGetdev
{
public ccb_hdr ccb_h;
public cam_proto protocol;
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;
/// <summary>

View File

@@ -60,42 +60,42 @@ namespace DiscImageChef.Devices.Linux
if(buffer == null) return -1;
sg_io_hdr_t io_hdr = new sg_io_hdr_t();
SgIoHdrT ioHdr = new SgIoHdrT();
senseBuffer = new byte[32];
io_hdr.interface_id = 'S';
io_hdr.cmd_len = (byte)cdb.Length;
io_hdr.mx_sb_len = (byte)senseBuffer.Length;
io_hdr.dxfer_direction = direction;
io_hdr.dxfer_len = (uint)buffer.Length;
io_hdr.dxferp = Marshal.AllocHGlobal(buffer.Length);
io_hdr.cmdp = Marshal.AllocHGlobal(cdb.Length);
io_hdr.sbp = Marshal.AllocHGlobal(senseBuffer.Length);
io_hdr.timeout = timeout * 1000;
ioHdr.interface_id = 'S';
ioHdr.cmd_len = (byte)cdb.Length;
ioHdr.mx_sb_len = (byte)senseBuffer.Length;
ioHdr.dxfer_direction = direction;
ioHdr.dxfer_len = (uint)buffer.Length;
ioHdr.dxferp = Marshal.AllocHGlobal(buffer.Length);
ioHdr.cmdp = Marshal.AllocHGlobal(cdb.Length);
ioHdr.sbp = Marshal.AllocHGlobal(senseBuffer.Length);
ioHdr.timeout = timeout * 1000;
Marshal.Copy(buffer, 0, io_hdr.dxferp, buffer.Length);
Marshal.Copy(cdb, 0, io_hdr.cmdp, cdb.Length);
Marshal.Copy(senseBuffer, 0, io_hdr.sbp, senseBuffer.Length);
Marshal.Copy(buffer, 0, ioHdr.dxferp, buffer.Length);
Marshal.Copy(cdb, 0, ioHdr.cmdp, cdb.Length);
Marshal.Copy(senseBuffer, 0, ioHdr.sbp, senseBuffer.Length);
DateTime start = DateTime.UtcNow;
int error = Extern.ioctlSg(fd, LinuxIoctl.SG_IO, ref io_hdr);
int error = Extern.ioctlSg(fd, LinuxIoctl.SgIo, ref ioHdr);
DateTime end = DateTime.UtcNow;
if(error < 0) error = Marshal.GetLastWin32Error();
Marshal.Copy(io_hdr.dxferp, buffer, 0, buffer.Length);
Marshal.Copy(io_hdr.cmdp, cdb, 0, cdb.Length);
Marshal.Copy(io_hdr.sbp, senseBuffer, 0, senseBuffer.Length);
Marshal.Copy(ioHdr.dxferp, buffer, 0, buffer.Length);
Marshal.Copy(ioHdr.cmdp, cdb, 0, cdb.Length);
Marshal.Copy(ioHdr.sbp, senseBuffer, 0, senseBuffer.Length);
sense |= (io_hdr.info & SgInfo.OkMask) != SgInfo.Ok;
sense |= (ioHdr.info & SgInfo.OkMask) != SgInfo.Ok;
if(io_hdr.duration > 0) duration = io_hdr.duration;
if(ioHdr.duration > 0) duration = ioHdr.duration;
else duration = (end - start).TotalMilliseconds;
Marshal.FreeHGlobal(io_hdr.dxferp);
Marshal.FreeHGlobal(io_hdr.cmdp);
Marshal.FreeHGlobal(io_hdr.sbp);
Marshal.FreeHGlobal(ioHdr.dxferp);
Marshal.FreeHGlobal(ioHdr.cmdp);
Marshal.FreeHGlobal(ioHdr.sbp);
return error;
}
@@ -339,28 +339,28 @@ namespace DiscImageChef.Devices.Linux
if(buffer == null) return -1;
mmc_ioc_cmd io_cmd = new mmc_ioc_cmd();
MmcIocCmd ioCmd = new MmcIocCmd();
IntPtr bufPtr = Marshal.AllocHGlobal(buffer.Length);
io_cmd.write_flag = write;
io_cmd.is_ascmd = isApplication;
io_cmd.opcode = (uint)command;
io_cmd.arg = argument;
io_cmd.flags = flags;
io_cmd.blksz = blockSize;
io_cmd.blocks = blocks;
ioCmd.write_flag = write;
ioCmd.is_ascmd = isApplication;
ioCmd.opcode = (uint)command;
ioCmd.arg = argument;
ioCmd.flags = flags;
ioCmd.blksz = blockSize;
ioCmd.blocks = blocks;
if(timeout > 0)
{
io_cmd.data_timeout_ns = timeout * 1000000000;
io_cmd.cmd_timeout_ms = timeout * 1000;
ioCmd.data_timeout_ns = timeout * 1000000000;
ioCmd.cmd_timeout_ms = timeout * 1000;
}
io_cmd.data_ptr = (ulong)bufPtr;
ioCmd.data_ptr = (ulong)bufPtr;
Marshal.Copy(buffer, 0, bufPtr, buffer.Length);
DateTime start = DateTime.UtcNow;
int error = Extern.ioctlMmc(fd, LinuxIoctl.MMC_IOC_CMD, ref io_cmd);
int error = Extern.ioctlMmc(fd, LinuxIoctl.MmcIocCmd, ref ioCmd);
DateTime end = DateTime.UtcNow;
sense |= error < 0;
@@ -369,7 +369,7 @@ namespace DiscImageChef.Devices.Linux
Marshal.Copy(bufPtr, buffer, 0, buffer.Length);
response = io_cmd.response;
response = ioCmd.response;
duration = (end - start).TotalMilliseconds;
Marshal.FreeHGlobal(bufPtr);

View File

@@ -61,7 +61,7 @@ namespace DiscImageChef.Devices.Linux
/// <summary>
/// O_NOCTTY
/// </summary>
NoControlTTY = 00000400,
NoControlTty = 00000400,
/// <summary>
/// O_TRUNC
/// </summary>
@@ -143,10 +143,10 @@ namespace DiscImageChef.Devices.Linux
enum LinuxIoctl : uint
{
// SCSI IOCtls
SG_GET_VERSION_NUM = 0x2282,
SG_IO = 0x2285,
SgGetVersionNum = 0x2282,
SgIo = 0x2285,
// MMC IOCtl
MMC_IOC_CMD = 0xC048B300
MmcIocCmd = 0xC048B300
}
[Flags]

View File

@@ -48,10 +48,10 @@ namespace DiscImageChef.Devices.Linux
internal static extern int ioctlInt(int fd, LinuxIoctl request, out int value);
[DllImport("libc", EntryPoint = "ioctl", SetLastError = true)]
internal static extern int ioctlSg(int fd, LinuxIoctl request, ref sg_io_hdr_t value);
internal static extern int ioctlSg(int fd, LinuxIoctl request, ref SgIoHdrT value);
[DllImport("libc", EntryPoint = "ioctl", SetLastError = true)]
internal static extern int ioctlMmc(int fd, LinuxIoctl request, ref mmc_ioc_cmd value);
internal static extern int ioctlMmc(int fd, LinuxIoctl request, ref MmcIocCmd value);
[DllImport("libc", CharSet = CharSet.Ansi, SetLastError = true)]
internal static extern int readlink(string path, System.IntPtr buf, int bufsize);
@@ -67,6 +67,6 @@ namespace DiscImageChef.Devices.Linux
IntPtr udev, string subsystem, string sysname);
[DllImport("libudev", CharSet = CharSet.Ansi, SetLastError = true)]
internal static extern string udev_device_get_property_value(IntPtr udev_device, string key);
internal static extern string udev_device_get_property_value(IntPtr udevDevice, string key);
}
}

View File

@@ -60,70 +60,70 @@ namespace DiscImageChef.Devices.Linux
for(int i = 0; i < sysdevs.Length; i++)
{
devices[i] = new DeviceInfo();
devices[i].path = "/dev/" + Path.GetFileName(sysdevs[i]);
devices[i].Path = "/dev/" + Path.GetFileName(sysdevs[i]);
if(hasUdev)
{
udevDev = Extern.udev_device_new_from_subsystem_sysname(udev, "block",
Path.GetFileName(sysdevs[i]));
devices[i].vendor = Extern.udev_device_get_property_value(udevDev, "ID_VENDOR");
devices[i].model = Extern.udev_device_get_property_value(udevDev, "ID_MODEL");
if(!string.IsNullOrEmpty(devices[i].model)) devices[i].model = devices[i].model.Replace('_', ' ');
devices[i].serial = Extern.udev_device_get_property_value(udevDev, "ID_SCSI_SERIAL");
if(string.IsNullOrEmpty(devices[i].serial))
devices[i].serial = Extern.udev_device_get_property_value(udevDev, "ID_SERIAL_SHORT");
devices[i].bus = Extern.udev_device_get_property_value(udevDev, "ID_BUS");
devices[i].Vendor = Extern.udev_device_get_property_value(udevDev, "ID_VENDOR");
devices[i].Model = Extern.udev_device_get_property_value(udevDev, "ID_MODEL");
if(!string.IsNullOrEmpty(devices[i].Model)) devices[i].Model = devices[i].Model.Replace('_', ' ');
devices[i].Serial = Extern.udev_device_get_property_value(udevDev, "ID_SCSI_SERIAL");
if(string.IsNullOrEmpty(devices[i].Serial))
devices[i].Serial = Extern.udev_device_get_property_value(udevDev, "ID_SERIAL_SHORT");
devices[i].Bus = Extern.udev_device_get_property_value(udevDev, "ID_BUS");
}
if(File.Exists(Path.Combine(sysdevs[i], "device/vendor")) && string.IsNullOrEmpty(devices[i].vendor))
if(File.Exists(Path.Combine(sysdevs[i], "device/vendor")) && string.IsNullOrEmpty(devices[i].Vendor))
{
sr = new StreamReader(Path.Combine(sysdevs[i], "device/vendor"), Encoding.ASCII);
devices[i].vendor = sr.ReadLine().Trim();
devices[i].Vendor = sr.ReadLine().Trim();
}
else if(devices[i].path.StartsWith("/dev/loop", StringComparison.CurrentCulture))
devices[i].vendor = "Linux";
else if(devices[i].Path.StartsWith("/dev/loop", StringComparison.CurrentCulture))
devices[i].Vendor = "Linux";
if(File.Exists(Path.Combine(sysdevs[i], "device/model")) &&
(string.IsNullOrEmpty(devices[i].model) || devices[i].bus == "ata"))
(string.IsNullOrEmpty(devices[i].Model) || devices[i].Bus == "ata"))
{
sr = new StreamReader(Path.Combine(sysdevs[i], "device/model"), Encoding.ASCII);
devices[i].model = sr.ReadLine().Trim();
devices[i].Model = sr.ReadLine().Trim();
}
else if(devices[i].path.StartsWith("/dev/loop", StringComparison.CurrentCulture))
devices[i].model = "Linux";
else if(devices[i].Path.StartsWith("/dev/loop", StringComparison.CurrentCulture))
devices[i].Model = "Linux";
if(File.Exists(Path.Combine(sysdevs[i], "device/serial")) && string.IsNullOrEmpty(devices[i].serial))
if(File.Exists(Path.Combine(sysdevs[i], "device/serial")) && string.IsNullOrEmpty(devices[i].Serial))
{
sr = new StreamReader(Path.Combine(sysdevs[i], "device/serial"), Encoding.ASCII);
devices[i].serial = sr.ReadLine().Trim();
devices[i].Serial = sr.ReadLine().Trim();
}
if(string.IsNullOrEmpty(devices[i].vendor) || devices[i].vendor == "ATA")
if(string.IsNullOrEmpty(devices[i].Vendor) || devices[i].Vendor == "ATA")
{
if(devices[i].model != null)
if(devices[i].Model != null)
{
string[] pieces = devices[i].model.Split(' ');
string[] pieces = devices[i].Model.Split(' ');
if(pieces.Length > 1)
{
devices[i].vendor = pieces[0];
devices[i].model = devices[i].model.Substring(pieces[0].Length + 1);
devices[i].Vendor = pieces[0];
devices[i].Model = devices[i].Model.Substring(pieces[0].Length + 1);
}
}
}
// TODO: Get better device type from sysfs paths
if(string.IsNullOrEmpty(devices[i].bus))
if(string.IsNullOrEmpty(devices[i].Bus))
{
if(devices[i].path.StartsWith("/dev/loop", StringComparison.CurrentCulture))
devices[i].bus = "loop";
else if(devices[i].path.StartsWith("/dev/nvme", StringComparison.CurrentCulture))
devices[i].bus = "NVMe";
else if(devices[i].path.StartsWith("/dev/mmc", StringComparison.CurrentCulture))
devices[i].bus = "MMC/SD";
if(devices[i].Path.StartsWith("/dev/loop", StringComparison.CurrentCulture))
devices[i].Bus = "loop";
else if(devices[i].Path.StartsWith("/dev/nvme", StringComparison.CurrentCulture))
devices[i].Bus = "NVMe";
else if(devices[i].Path.StartsWith("/dev/mmc", StringComparison.CurrentCulture))
devices[i].Bus = "MMC/SD";
}
else devices[i].bus = devices[i].bus.ToUpper();
else devices[i].Bus = devices[i].Bus.ToUpper();
switch(devices[i].bus)
switch(devices[i].Bus)
{
case "ATA":
case "ATAPI":
@@ -132,7 +132,7 @@ namespace DiscImageChef.Devices.Linux
case "PCMCIA":
case "FireWire":
case "MMC/SD":
devices[i].supported = true;
devices[i].Supported = true;
break;
}
}

View File

@@ -37,7 +37,7 @@ using System.Runtime.InteropServices;
namespace DiscImageChef.Devices.Linux
{
[StructLayout(LayoutKind.Sequential)]
struct sg_io_hdr_t
struct SgIoHdrT
{
/// <summary>
/// Always 'S' for SG v3
@@ -67,7 +67,7 @@ namespace DiscImageChef.Devices.Linux
}
[StructLayout(LayoutKind.Sequential)]
struct mmc_ioc_cmd
struct MmcIocCmd
{
/// <summary>
/// Implies direction of data. true = write, false = read

View File

@@ -63,43 +63,43 @@ namespace DiscImageChef.Devices.Windows
if(buffer == null) return -1;
ScsiPassThroughDirectAndSenseBuffer sptd_sb = new ScsiPassThroughDirectAndSenseBuffer();
sptd_sb.sptd = new ScsiPassThroughDirect();
sptd_sb.SenseBuf = new byte[32];
sptd_sb.sptd.Cdb = new byte[16];
Array.Copy(cdb, sptd_sb.sptd.Cdb, cdb.Length);
sptd_sb.sptd.Length = (ushort)Marshal.SizeOf(sptd_sb.sptd);
sptd_sb.sptd.CdbLength = (byte)cdb.Length;
sptd_sb.sptd.SenseInfoLength = (byte)sptd_sb.SenseBuf.Length;
sptd_sb.sptd.DataIn = direction;
sptd_sb.sptd.DataTransferLength = (uint)buffer.Length;
sptd_sb.sptd.TimeOutValue = timeout;
sptd_sb.sptd.DataBuffer = Marshal.AllocHGlobal(buffer.Length);
sptd_sb.sptd.SenseInfoOffset = (uint)Marshal.SizeOf(sptd_sb.sptd);
ScsiPassThroughDirectAndSenseBuffer sptdSb = new ScsiPassThroughDirectAndSenseBuffer();
sptdSb.sptd = new ScsiPassThroughDirect();
sptdSb.SenseBuf = new byte[32];
sptdSb.sptd.Cdb = new byte[16];
Array.Copy(cdb, sptdSb.sptd.Cdb, cdb.Length);
sptdSb.sptd.Length = (ushort)Marshal.SizeOf(sptdSb.sptd);
sptdSb.sptd.CdbLength = (byte)cdb.Length;
sptdSb.sptd.SenseInfoLength = (byte)sptdSb.SenseBuf.Length;
sptdSb.sptd.DataIn = direction;
sptdSb.sptd.DataTransferLength = (uint)buffer.Length;
sptdSb.sptd.TimeOutValue = timeout;
sptdSb.sptd.DataBuffer = Marshal.AllocHGlobal(buffer.Length);
sptdSb.sptd.SenseInfoOffset = (uint)Marshal.SizeOf(sptdSb.sptd);
uint k = 0;
int error = 0;
Marshal.Copy(buffer, 0, sptd_sb.sptd.DataBuffer, buffer.Length);
Marshal.Copy(buffer, 0, sptdSb.sptd.DataBuffer, buffer.Length);
DateTime start = DateTime.Now;
bool hasError = !Extern.DeviceIoControlScsi(fd, WindowsIoctl.IOCTL_SCSI_PASS_THROUGH_DIRECT, ref sptd_sb,
(uint)Marshal.SizeOf(sptd_sb), ref sptd_sb,
(uint)Marshal.SizeOf(sptd_sb), ref k, IntPtr.Zero);
bool hasError = !Extern.DeviceIoControlScsi(fd, WindowsIoctl.IoctlScsiPassThroughDirect, ref sptdSb,
(uint)Marshal.SizeOf(sptdSb), ref sptdSb,
(uint)Marshal.SizeOf(sptdSb), ref k, IntPtr.Zero);
DateTime end = DateTime.Now;
if(hasError) error = Marshal.GetLastWin32Error();
Marshal.Copy(sptd_sb.sptd.DataBuffer, buffer, 0, buffer.Length);
Marshal.Copy(sptdSb.sptd.DataBuffer, buffer, 0, buffer.Length);
sense |= sptd_sb.sptd.ScsiStatus != 0;
sense |= sptdSb.sptd.ScsiStatus != 0;
senseBuffer = new byte[32];
Array.Copy(sptd_sb.SenseBuf, senseBuffer, 32);
Array.Copy(sptdSb.SenseBuf, senseBuffer, 32);
duration = (end - start).TotalMilliseconds;
Marshal.FreeHGlobal(sptd_sb.sptd.DataBuffer);
Marshal.FreeHGlobal(sptdSb.sptd.DataBuffer);
return error;
}
@@ -116,7 +116,7 @@ namespace DiscImageChef.Devices.Windows
uint offsetForBuffer = (uint)(Marshal.SizeOf(typeof(AtaPassThroughDirect)) + Marshal.SizeOf(typeof(uint)));
AtaPassThroughDirectWithBuffer aptd_buf = new AtaPassThroughDirectWithBuffer
AtaPassThroughDirectWithBuffer aptdBuf = new AtaPassThroughDirectWithBuffer
{
aptd = new AtaPassThroughDirect
{
@@ -140,49 +140,49 @@ namespace DiscImageChef.Devices.Windows
};
if(protocol == AtaProtocol.PioIn || protocol == AtaProtocol.UDmaIn || protocol == AtaProtocol.Dma)
aptd_buf.aptd.AtaFlags = AtaFlags.DataIn;
aptdBuf.aptd.AtaFlags = AtaFlags.DataIn;
else if(protocol == AtaProtocol.PioOut || protocol == AtaProtocol.UDmaOut)
aptd_buf.aptd.AtaFlags = AtaFlags.DataOut;
aptdBuf.aptd.AtaFlags = AtaFlags.DataOut;
switch(protocol)
{
case AtaProtocol.Dma:
case AtaProtocol.DmaQueued:
case AtaProtocol.FPDma:
case AtaProtocol.FpDma:
case AtaProtocol.UDmaIn:
case AtaProtocol.UDmaOut:
aptd_buf.aptd.AtaFlags |= AtaFlags.DMA;
aptdBuf.aptd.AtaFlags |= AtaFlags.Dma;
break;
}
// Unknown if needed
aptd_buf.aptd.AtaFlags |= AtaFlags.DrdyRequired;
aptdBuf.aptd.AtaFlags |= AtaFlags.DrdyRequired;
uint k = 0;
int error = 0;
Array.Copy(buffer, 0, aptd_buf.dataBuffer, 0, buffer.Length);
Array.Copy(buffer, 0, aptdBuf.dataBuffer, 0, buffer.Length);
DateTime start = DateTime.Now;
sense = !Extern.DeviceIoControlAta(fd, WindowsIoctl.IOCTL_ATA_PASS_THROUGH, ref aptd_buf,
(uint)Marshal.SizeOf(aptd_buf), ref aptd_buf,
(uint)Marshal.SizeOf(aptd_buf), ref k, IntPtr.Zero);
sense = !Extern.DeviceIoControlAta(fd, WindowsIoctl.IoctlAtaPassThrough, ref aptdBuf,
(uint)Marshal.SizeOf(aptdBuf), ref aptdBuf,
(uint)Marshal.SizeOf(aptdBuf), ref k, IntPtr.Zero);
DateTime end = DateTime.Now;
if(sense) error = Marshal.GetLastWin32Error();
Array.Copy(aptd_buf.dataBuffer, 0, buffer, 0, buffer.Length);
Array.Copy(aptdBuf.dataBuffer, 0, buffer, 0, buffer.Length);
duration = (end - start).TotalMilliseconds;
errorRegisters.command = aptd_buf.aptd.CurrentTaskFile.Command;
errorRegisters.cylinderHigh = aptd_buf.aptd.CurrentTaskFile.CylinderHigh;
errorRegisters.cylinderLow = aptd_buf.aptd.CurrentTaskFile.CylinderLow;
errorRegisters.deviceHead = aptd_buf.aptd.CurrentTaskFile.DeviceHead;
errorRegisters.error = aptd_buf.aptd.CurrentTaskFile.Error;
errorRegisters.sector = aptd_buf.aptd.CurrentTaskFile.SectorNumber;
errorRegisters.sectorCount = aptd_buf.aptd.CurrentTaskFile.SectorCount;
errorRegisters.status = aptd_buf.aptd.CurrentTaskFile.Status;
errorRegisters.command = aptdBuf.aptd.CurrentTaskFile.Command;
errorRegisters.cylinderHigh = aptdBuf.aptd.CurrentTaskFile.CylinderHigh;
errorRegisters.cylinderLow = aptdBuf.aptd.CurrentTaskFile.CylinderLow;
errorRegisters.deviceHead = aptdBuf.aptd.CurrentTaskFile.DeviceHead;
errorRegisters.error = aptdBuf.aptd.CurrentTaskFile.Error;
errorRegisters.sector = aptdBuf.aptd.CurrentTaskFile.SectorNumber;
errorRegisters.sectorCount = aptdBuf.aptd.CurrentTaskFile.SectorCount;
errorRegisters.status = aptdBuf.aptd.CurrentTaskFile.Status;
sense = errorRegisters.error != 0 || (errorRegisters.status & 0xA5) != 0;
@@ -201,7 +201,7 @@ namespace DiscImageChef.Devices.Windows
uint offsetForBuffer = (uint)(Marshal.SizeOf(typeof(AtaPassThroughDirect)) + Marshal.SizeOf(typeof(uint)));
AtaPassThroughDirectWithBuffer aptd_buf = new AtaPassThroughDirectWithBuffer
AtaPassThroughDirectWithBuffer aptdBuf = new AtaPassThroughDirectWithBuffer
{
aptd = new AtaPassThroughDirect
{
@@ -225,49 +225,49 @@ namespace DiscImageChef.Devices.Windows
};
if(protocol == AtaProtocol.PioIn || protocol == AtaProtocol.UDmaIn || protocol == AtaProtocol.Dma)
aptd_buf.aptd.AtaFlags = AtaFlags.DataIn;
aptdBuf.aptd.AtaFlags = AtaFlags.DataIn;
else if(protocol == AtaProtocol.PioOut || protocol == AtaProtocol.UDmaOut)
aptd_buf.aptd.AtaFlags = AtaFlags.DataOut;
aptdBuf.aptd.AtaFlags = AtaFlags.DataOut;
switch(protocol)
{
case AtaProtocol.Dma:
case AtaProtocol.DmaQueued:
case AtaProtocol.FPDma:
case AtaProtocol.FpDma:
case AtaProtocol.UDmaIn:
case AtaProtocol.UDmaOut:
aptd_buf.aptd.AtaFlags |= AtaFlags.DMA;
aptdBuf.aptd.AtaFlags |= AtaFlags.Dma;
break;
}
// Unknown if needed
aptd_buf.aptd.AtaFlags |= AtaFlags.DrdyRequired;
aptdBuf.aptd.AtaFlags |= AtaFlags.DrdyRequired;
uint k = 0;
int error = 0;
Array.Copy(buffer, 0, aptd_buf.dataBuffer, 0, buffer.Length);
Array.Copy(buffer, 0, aptdBuf.dataBuffer, 0, buffer.Length);
DateTime start = DateTime.Now;
sense = !Extern.DeviceIoControlAta(fd, WindowsIoctl.IOCTL_ATA_PASS_THROUGH, ref aptd_buf,
(uint)Marshal.SizeOf(aptd_buf), ref aptd_buf,
(uint)Marshal.SizeOf(aptd_buf), ref k, IntPtr.Zero);
sense = !Extern.DeviceIoControlAta(fd, WindowsIoctl.IoctlAtaPassThrough, ref aptdBuf,
(uint)Marshal.SizeOf(aptdBuf), ref aptdBuf,
(uint)Marshal.SizeOf(aptdBuf), ref k, IntPtr.Zero);
DateTime end = DateTime.Now;
if(sense) error = Marshal.GetLastWin32Error();
Array.Copy(aptd_buf.dataBuffer, 0, buffer, 0, buffer.Length);
Array.Copy(aptdBuf.dataBuffer, 0, buffer, 0, buffer.Length);
duration = (end - start).TotalMilliseconds;
errorRegisters.command = aptd_buf.aptd.CurrentTaskFile.Command;
errorRegisters.lbaHigh = aptd_buf.aptd.CurrentTaskFile.CylinderHigh;
errorRegisters.lbaMid = aptd_buf.aptd.CurrentTaskFile.CylinderLow;
errorRegisters.deviceHead = aptd_buf.aptd.CurrentTaskFile.DeviceHead;
errorRegisters.error = aptd_buf.aptd.CurrentTaskFile.Error;
errorRegisters.lbaLow = aptd_buf.aptd.CurrentTaskFile.SectorNumber;
errorRegisters.sectorCount = aptd_buf.aptd.CurrentTaskFile.SectorCount;
errorRegisters.status = aptd_buf.aptd.CurrentTaskFile.Status;
errorRegisters.command = aptdBuf.aptd.CurrentTaskFile.Command;
errorRegisters.lbaHigh = aptdBuf.aptd.CurrentTaskFile.CylinderHigh;
errorRegisters.lbaMid = aptdBuf.aptd.CurrentTaskFile.CylinderLow;
errorRegisters.deviceHead = aptdBuf.aptd.CurrentTaskFile.DeviceHead;
errorRegisters.error = aptdBuf.aptd.CurrentTaskFile.Error;
errorRegisters.lbaLow = aptdBuf.aptd.CurrentTaskFile.SectorNumber;
errorRegisters.sectorCount = aptdBuf.aptd.CurrentTaskFile.SectorCount;
errorRegisters.status = aptdBuf.aptd.CurrentTaskFile.Status;
sense = errorRegisters.error != 0 || (errorRegisters.status & 0xA5) != 0;
@@ -286,7 +286,7 @@ namespace DiscImageChef.Devices.Windows
uint offsetForBuffer = (uint)(Marshal.SizeOf(typeof(AtaPassThroughDirect)) + Marshal.SizeOf(typeof(uint)));
AtaPassThroughDirectWithBuffer aptd_buf = new AtaPassThroughDirectWithBuffer
AtaPassThroughDirectWithBuffer aptdBuf = new AtaPassThroughDirectWithBuffer
{
aptd = new AtaPassThroughDirect
{
@@ -318,53 +318,53 @@ namespace DiscImageChef.Devices.Windows
};
if(protocol == AtaProtocol.PioIn || protocol == AtaProtocol.UDmaIn || protocol == AtaProtocol.Dma)
aptd_buf.aptd.AtaFlags = AtaFlags.DataIn;
aptdBuf.aptd.AtaFlags = AtaFlags.DataIn;
else if(protocol == AtaProtocol.PioOut || protocol == AtaProtocol.UDmaOut)
aptd_buf.aptd.AtaFlags = AtaFlags.DataOut;
aptdBuf.aptd.AtaFlags = AtaFlags.DataOut;
switch(protocol)
{
case AtaProtocol.Dma:
case AtaProtocol.DmaQueued:
case AtaProtocol.FPDma:
case AtaProtocol.FpDma:
case AtaProtocol.UDmaIn:
case AtaProtocol.UDmaOut:
aptd_buf.aptd.AtaFlags |= AtaFlags.DMA;
aptdBuf.aptd.AtaFlags |= AtaFlags.Dma;
break;
}
// Unknown if needed
aptd_buf.aptd.AtaFlags |= AtaFlags.DrdyRequired;
aptdBuf.aptd.AtaFlags |= AtaFlags.DrdyRequired;
uint k = 0;
int error = 0;
Array.Copy(buffer, 0, aptd_buf.dataBuffer, 0, buffer.Length);
Array.Copy(buffer, 0, aptdBuf.dataBuffer, 0, buffer.Length);
DateTime start = DateTime.Now;
sense = !Extern.DeviceIoControlAta(fd, WindowsIoctl.IOCTL_ATA_PASS_THROUGH, ref aptd_buf,
(uint)Marshal.SizeOf(aptd_buf), ref aptd_buf,
(uint)Marshal.SizeOf(aptd_buf), ref k, IntPtr.Zero);
sense = !Extern.DeviceIoControlAta(fd, WindowsIoctl.IoctlAtaPassThrough, ref aptdBuf,
(uint)Marshal.SizeOf(aptdBuf), ref aptdBuf,
(uint)Marshal.SizeOf(aptdBuf), ref k, IntPtr.Zero);
DateTime end = DateTime.Now;
if(sense) error = Marshal.GetLastWin32Error();
Array.Copy(aptd_buf.dataBuffer, 0, buffer, 0, buffer.Length);
Array.Copy(aptdBuf.dataBuffer, 0, buffer, 0, buffer.Length);
duration = (end - start).TotalMilliseconds;
errorRegisters.sectorCount = (ushort)((aptd_buf.aptd.PreviousTaskFile.SectorCount << 8) +
aptd_buf.aptd.CurrentTaskFile.SectorCount);
errorRegisters.lbaLow = (ushort)((aptd_buf.aptd.PreviousTaskFile.SectorNumber << 8) +
aptd_buf.aptd.CurrentTaskFile.SectorNumber);
errorRegisters.lbaMid = (ushort)((aptd_buf.aptd.PreviousTaskFile.CylinderLow << 8) +
aptd_buf.aptd.CurrentTaskFile.CylinderLow);
errorRegisters.lbaHigh = (ushort)((aptd_buf.aptd.PreviousTaskFile.CylinderHigh << 8) +
aptd_buf.aptd.CurrentTaskFile.CylinderHigh);
errorRegisters.command = aptd_buf.aptd.CurrentTaskFile.Command;
errorRegisters.deviceHead = aptd_buf.aptd.CurrentTaskFile.DeviceHead;
errorRegisters.error = aptd_buf.aptd.CurrentTaskFile.Error;
errorRegisters.status = aptd_buf.aptd.CurrentTaskFile.Status;
errorRegisters.sectorCount = (ushort)((aptdBuf.aptd.PreviousTaskFile.SectorCount << 8) +
aptdBuf.aptd.CurrentTaskFile.SectorCount);
errorRegisters.lbaLow = (ushort)((aptdBuf.aptd.PreviousTaskFile.SectorNumber << 8) +
aptdBuf.aptd.CurrentTaskFile.SectorNumber);
errorRegisters.lbaMid = (ushort)((aptdBuf.aptd.PreviousTaskFile.CylinderLow << 8) +
aptdBuf.aptd.CurrentTaskFile.CylinderLow);
errorRegisters.lbaHigh = (ushort)((aptdBuf.aptd.PreviousTaskFile.CylinderHigh << 8) +
aptdBuf.aptd.CurrentTaskFile.CylinderHigh);
errorRegisters.command = aptdBuf.aptd.CurrentTaskFile.Command;
errorRegisters.deviceHead = aptdBuf.aptd.CurrentTaskFile.DeviceHead;
errorRegisters.error = aptdBuf.aptd.CurrentTaskFile.Error;
errorRegisters.status = aptdBuf.aptd.CurrentTaskFile.Status;
sense = errorRegisters.error != 0 || (errorRegisters.status & 0xA5) != 0;
@@ -403,7 +403,7 @@ namespace DiscImageChef.Devices.Windows
Array.Copy(buffer, 0, iptd.DataBuffer, 0, buffer.Length);
DateTime start = DateTime.Now;
sense = !Extern.DeviceIoControlIde(fd, WindowsIoctl.IOCTL_IDE_PASS_THROUGH, ref iptd,
sense = !Extern.DeviceIoControlIde(fd, WindowsIoctl.IoctlIdePassThrough, ref iptd,
(uint)Marshal.SizeOf(iptd), ref iptd, (uint)Marshal.SizeOf(iptd), ref k,
IntPtr.Zero);
DateTime end = DateTime.Now;
@@ -463,7 +463,7 @@ namespace DiscImageChef.Devices.Windows
Array.Copy(buffer, 0, iptd.DataBuffer, 0, buffer.Length);
DateTime start = DateTime.Now;
sense = !Extern.DeviceIoControlIde(fd, WindowsIoctl.IOCTL_IDE_PASS_THROUGH, ref iptd,
sense = !Extern.DeviceIoControlIde(fd, WindowsIoctl.IoctlIdePassThrough, ref iptd,
(uint)Marshal.SizeOf(iptd), ref iptd, (uint)Marshal.SizeOf(iptd), ref k,
IntPtr.Zero);
DateTime end = DateTime.Now;
@@ -494,7 +494,7 @@ namespace DiscImageChef.Devices.Windows
StorageDeviceNumber sdn = new StorageDeviceNumber();
sdn.deviceNumber = -1;
uint k = 0;
if(!Extern.DeviceIoControlGetDeviceNumber(deviceHandle, WindowsIoctl.IOCTL_STORAGE_GET_DEVICE_NUMBER,
if(!Extern.DeviceIoControlGetDeviceNumber(deviceHandle, WindowsIoctl.IoctlStorageGetDeviceNumber,
IntPtr.Zero, 0, ref sdn, (uint)Marshal.SizeOf(sdn), ref k,
IntPtr.Zero)) { return uint.MaxValue; }
@@ -507,7 +507,7 @@ namespace DiscImageChef.Devices.Windows
if(devNumber == uint.MaxValue) return null;
SafeFileHandle hDevInfo = Extern.SetupDiGetClassDevs(ref Consts.GUID_DEVINTERFACE_DISK, IntPtr.Zero,
SafeFileHandle hDevInfo = Extern.SetupDiGetClassDevs(ref Consts.GuidDevinterfaceDisk, IntPtr.Zero,
IntPtr.Zero,
DeviceGetClassFlags.Present |
DeviceGetClassFlags.DeviceInterface);
@@ -524,7 +524,7 @@ namespace DiscImageChef.Devices.Windows
{
buffer = new byte[2048];
if(!Extern.SetupDiEnumDeviceInterfaces(hDevInfo, IntPtr.Zero, ref Consts.GUID_DEVINTERFACE_DISK, index,
if(!Extern.SetupDiEnumDeviceInterfaces(hDevInfo, IntPtr.Zero, ref Consts.GuidDevinterfaceDisk, index,
ref spdid)) break;
uint size = 0;
@@ -581,9 +581,9 @@ namespace DiscImageChef.Devices.Windows
SffdiskQueryDeviceProtocolData queryData1 = new SffdiskQueryDeviceProtocolData();
queryData1.size = (ushort)Marshal.SizeOf(queryData1);
uint bytesReturned;
Extern.DeviceIoControl(fd, WindowsIoctl.IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL, IntPtr.Zero, 0, ref queryData1,
Extern.DeviceIoControl(fd, WindowsIoctl.IoctlSffdiskQueryDeviceProtocol, IntPtr.Zero, 0, ref queryData1,
queryData1.size, out bytesReturned, IntPtr.Zero);
return queryData1.protocolGuid.Equals(Consts.GUID_SFF_PROTOCOL_SD);
return queryData1.protocolGuid.Equals(Consts.GuidSffProtocolSd);
}
/// <summary>
@@ -617,46 +617,46 @@ namespace DiscImageChef.Devices.Windows
commandDescriptor.commandCode = (byte)command;
commandDescriptor.cmdClass = isApplication ? SdCommandClass.AppCmd : SdCommandClass.Standard;
commandDescriptor.transferDirection = write ? SdTransferDirection.Write : SdTransferDirection.Read;
commandDescriptor.transferType = flags.HasFlag(MmcFlags.CommandADTC)
commandDescriptor.transferType = flags.HasFlag(MmcFlags.CommandAdtc)
? SdTransferType.SingleBlock
: SdTransferType.CmdOnly;
commandDescriptor.responseType = 0;
if(flags.HasFlag(MmcFlags.Response_R1) || flags.HasFlag(MmcFlags.ResponseSPI_R1))
if(flags.HasFlag(MmcFlags.ResponseR1) || flags.HasFlag(MmcFlags.ResponseSpiR1))
commandDescriptor.responseType = SdResponseType.R1;
if(flags.HasFlag(MmcFlags.Response_R1b) || flags.HasFlag(MmcFlags.ResponseSPI_R1b))
if(flags.HasFlag(MmcFlags.ResponseR1B) || flags.HasFlag(MmcFlags.ResponseSpiR1B))
commandDescriptor.responseType = SdResponseType.R1b;
if(flags.HasFlag(MmcFlags.Response_R2) || flags.HasFlag(MmcFlags.ResponseSPI_R2))
if(flags.HasFlag(MmcFlags.ResponseR2) || flags.HasFlag(MmcFlags.ResponseSpiR2))
commandDescriptor.responseType = SdResponseType.R2;
if(flags.HasFlag(MmcFlags.Response_R3) || flags.HasFlag(MmcFlags.ResponseSPI_R3))
if(flags.HasFlag(MmcFlags.ResponseR3) || flags.HasFlag(MmcFlags.ResponseSpiR3))
commandDescriptor.responseType = SdResponseType.R3;
if(flags.HasFlag(MmcFlags.Response_R4) || flags.HasFlag(MmcFlags.ResponseSPI_R4))
if(flags.HasFlag(MmcFlags.ResponseR4) || flags.HasFlag(MmcFlags.ResponseSpiR4))
commandDescriptor.responseType = SdResponseType.R4;
if(flags.HasFlag(MmcFlags.Response_R5) || flags.HasFlag(MmcFlags.ResponseSPI_R5))
if(flags.HasFlag(MmcFlags.ResponseR5) || flags.HasFlag(MmcFlags.ResponseSpiR5))
commandDescriptor.responseType = SdResponseType.R5;
if(flags.HasFlag(MmcFlags.Response_R6)) commandDescriptor.responseType = SdResponseType.R6;
if(flags.HasFlag(MmcFlags.ResponseR6)) commandDescriptor.responseType = SdResponseType.R6;
byte[] command_b = new byte[commandData.size + commandData.protocolArgumentSize +
byte[] commandB = new byte[commandData.size + commandData.protocolArgumentSize +
commandData.deviceDataBufferSize];
IntPtr hBuf = Marshal.AllocHGlobal(command_b.Length);
IntPtr hBuf = Marshal.AllocHGlobal(commandB.Length);
Marshal.StructureToPtr(commandData, hBuf, true);
IntPtr descriptorOffset = new IntPtr(hBuf.ToInt32() + commandData.size);
Marshal.StructureToPtr(commandDescriptor, descriptorOffset, true);
Marshal.Copy(hBuf, command_b, 0, command_b.Length);
Marshal.Copy(hBuf, commandB, 0, commandB.Length);
Marshal.FreeHGlobal(hBuf);
uint bytesReturned;
int error = 0;
DateTime start = DateTime.Now;
sense = !Extern.DeviceIoControl(fd, WindowsIoctl.IOCTL_SFFDISK_DEVICE_COMMAND, command_b,
(uint)command_b.Length, command_b, (uint)command_b.Length,
sense = !Extern.DeviceIoControl(fd, WindowsIoctl.IoctlSffdiskDeviceCommand, commandB,
(uint)commandB.Length, commandB, (uint)commandB.Length,
out bytesReturned, IntPtr.Zero);
DateTime end = DateTime.Now;
if(sense) error = Marshal.GetLastWin32Error();
buffer = new byte[blockSize * blocks];
Buffer.BlockCopy(command_b, command_b.Length - buffer.Length, buffer, 0, buffer.Length);
Buffer.BlockCopy(commandB, commandB.Length - buffer.Length, buffer, 0, buffer.Length);
response = new uint[4];
duration = (end - start).TotalMilliseconds;

View File

@@ -213,11 +213,11 @@ namespace DiscImageChef.Devices.Windows
/// <summary>
/// FILE_READ_EA
/// </summary>
ReadEA = 0x0008,
ReadEa = 0x0008,
/// <summary>
/// FILE_WRITE_EA
/// </summary>
WriteEA = 0x0010,
WriteEa = 0x0010,
/// <summary>
/// FILE_EXECUTE
/// </summary>
@@ -326,25 +326,25 @@ namespace DiscImageChef.Devices.Windows
enum WindowsIoctl : uint
{
IOCTL_ATA_PASS_THROUGH = 0x4D02C,
IOCTL_ATA_PASS_THROUGH_DIRECT = 0x4D030,
IoctlAtaPassThrough = 0x4D02C,
IoctlAtaPassThroughDirect = 0x4D030,
/// <summary>
/// ScsiPassThrough
/// </summary>
IOCTL_SCSI_PASS_THROUGH = 0x4D004,
IoctlScsiPassThrough = 0x4D004,
/// <summary>
/// ScsiPassThroughDirect
/// </summary>
IOCTL_SCSI_PASS_THROUGH_DIRECT = 0x4D014,
IoctlScsiPassThroughDirect = 0x4D014,
/// <summary>
/// ScsiGetAddress
/// </summary>
IOCTL_SCSI_GET_ADDRESS = 0x41018,
IOCTL_STORAGE_QUERY_PROPERTY = 0x2D1400,
IOCTL_IDE_PASS_THROUGH = 0x4D028,
IOCTL_STORAGE_GET_DEVICE_NUMBER = 0x2D1080,
IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL = 0x71E80,
IOCTL_SFFDISK_DEVICE_COMMAND = 0x79E84,
IoctlScsiGetAddress = 0x41018,
IoctlStorageQueryProperty = 0x2D1400,
IoctlIdePassThrough = 0x4D028,
IoctlStorageGetDeviceNumber = 0x2D1080,
IoctlSffdiskQueryDeviceProtocol = 0x71E80,
IoctlSffdiskDeviceCommand = 0x79E84,
}
[Flags]
@@ -369,7 +369,7 @@ namespace DiscImageChef.Devices.Windows
/// <summary>
/// ATA_FLAGS_USE_DMA
/// </summary>
DMA = 0x10,
Dma = 0x10,
/// <summary>
/// ATA_FLAGS_NO_MULTIPLE
/// </summary>
@@ -389,7 +389,7 @@ namespace DiscImageChef.Devices.Windows
Trim = 8,
WriteAggregation = 9,
Telemetry = 10,
LBProvisioning = 11,
LbProvisioning = 11,
Power = 12,
Copyoffload = 13,
Resiliency = 14
@@ -495,8 +495,8 @@ namespace DiscImageChef.Devices.Windows
static class Consts
{
public static Guid GUID_SFF_PROTOCOL_SD = new Guid("AD7536A8-D055-4C40-AA4D-96312DDB6B38");
public static Guid GUID_DEVINTERFACE_DISK =
public static Guid GuidSffProtocolSd = new Guid("AD7536A8-D055-4C40-AA4D-96312DDB6B38");
public static Guid GuidDevinterfaceDisk =
new Guid(0x53F56307, 0xB6BF, 0x11D0, 0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B);
}
}

View File

@@ -49,51 +49,51 @@ namespace DiscImageChef.Devices.Windows
FileAttributes flagsAndAttributes, IntPtr templateFile);
[DllImport("Kernel32.dll", SetLastError = true, EntryPoint = "DeviceIoControl", CharSet = CharSet.Auto)]
internal static extern bool DeviceIoControlScsi(SafeFileHandle hDevice, WindowsIoctl IoControlCode,
ref ScsiPassThroughDirectAndSenseBuffer InBuffer,
internal static extern bool DeviceIoControlScsi(SafeFileHandle hDevice, WindowsIoctl ioControlCode,
ref ScsiPassThroughDirectAndSenseBuffer inBuffer,
uint nInBufferSize,
ref ScsiPassThroughDirectAndSenseBuffer OutBuffer,
ref ScsiPassThroughDirectAndSenseBuffer outBuffer,
uint nOutBufferSize, ref uint pBytesReturned,
IntPtr Overlapped);
IntPtr overlapped);
[DllImport("Kernel32.dll", SetLastError = true, EntryPoint = "DeviceIoControl", CharSet = CharSet.Auto)]
internal static extern bool DeviceIoControlAta(SafeFileHandle hDevice, WindowsIoctl IoControlCode,
ref AtaPassThroughDirectWithBuffer InBuffer, uint nInBufferSize,
ref AtaPassThroughDirectWithBuffer OutBuffer,
uint nOutBufferSize, ref uint pBytesReturned, IntPtr Overlapped);
internal static extern bool DeviceIoControlAta(SafeFileHandle hDevice, WindowsIoctl ioControlCode,
ref AtaPassThroughDirectWithBuffer inBuffer, uint nInBufferSize,
ref AtaPassThroughDirectWithBuffer outBuffer,
uint nOutBufferSize, ref uint pBytesReturned, IntPtr overlapped);
[DllImport("Kernel32.dll", SetLastError = true, EntryPoint = "DeviceIoControl", CharSet = CharSet.Auto)]
internal static extern bool DeviceIoControlStorageQuery(SafeFileHandle hDevice, WindowsIoctl IoControlCode,
ref StoragePropertyQuery InBuffer, uint nInBufferSize,
IntPtr OutBuffer, uint nOutBufferSize,
ref uint pBytesReturned, IntPtr Overlapped);
internal static extern bool DeviceIoControlStorageQuery(SafeFileHandle hDevice, WindowsIoctl ioControlCode,
ref StoragePropertyQuery inBuffer, uint nInBufferSize,
IntPtr outBuffer, uint nOutBufferSize,
ref uint pBytesReturned, IntPtr overlapped);
[DllImport("Kernel32.dll", SetLastError = true, EntryPoint = "DeviceIoControl", CharSet = CharSet.Auto)]
internal static extern bool DeviceIoControlIde(SafeFileHandle hDevice, WindowsIoctl IoControlCode,
ref IdePassThroughDirect InBuffer, uint nInBufferSize,
ref IdePassThroughDirect OutBuffer, uint nOutBufferSize,
ref uint pBytesReturned, IntPtr Overlapped);
internal static extern bool DeviceIoControlIde(SafeFileHandle hDevice, WindowsIoctl ioControlCode,
ref IdePassThroughDirect inBuffer, uint nInBufferSize,
ref IdePassThroughDirect outBuffer, uint nOutBufferSize,
ref uint pBytesReturned, IntPtr overlapped);
[DllImport("Kernel32.dll", SetLastError = true, EntryPoint = "DeviceIoControl", CharSet = CharSet.Auto)]
internal static extern bool DeviceIoControlGetDeviceNumber(SafeFileHandle hDevice, WindowsIoctl IoControlCode,
IntPtr InBuffer, uint nInBufferSize,
ref StorageDeviceNumber OutBuffer,
internal static extern bool DeviceIoControlGetDeviceNumber(SafeFileHandle hDevice, WindowsIoctl ioControlCode,
IntPtr inBuffer, uint nInBufferSize,
ref StorageDeviceNumber outBuffer,
uint nOutBufferSize, ref uint pBytesReturned,
IntPtr Overlapped);
IntPtr overlapped);
[DllImport("Kernel32.dll", SetLastError = true, EntryPoint = "DeviceIoControl", CharSet = CharSet.Auto)]
internal static extern bool DeviceIoControl(SafeFileHandle hDevice, WindowsIoctl IoControlCode, IntPtr InBuffer,
uint nInBufferSize, ref SffdiskQueryDeviceProtocolData OutBuffer,
uint nOutBufferSize, out uint pBytesReturned, IntPtr Overlapped);
internal static extern bool DeviceIoControl(SafeFileHandle hDevice, WindowsIoctl ioControlCode, IntPtr inBuffer,
uint nInBufferSize, ref SffdiskQueryDeviceProtocolData outBuffer,
uint nOutBufferSize, out uint pBytesReturned, IntPtr overlapped);
[DllImport("Kernel32.dll", SetLastError = true, EntryPoint = "DeviceIoControl", CharSet = CharSet.Auto)]
internal static extern bool DeviceIoControl(SafeFileHandle hDevice, WindowsIoctl IoControlCode, byte[] InBuffer,
uint nInBufferSize, byte[] OutBuffer, uint nOutBufferSize,
out uint pBytesReturned, IntPtr Overlapped);
internal static extern bool DeviceIoControl(SafeFileHandle hDevice, WindowsIoctl ioControlCode, byte[] inBuffer,
uint nInBufferSize, byte[] outBuffer, uint nOutBufferSize,
out uint pBytesReturned, IntPtr overlapped);
[DllImport("setupapi.dll", CharSet = CharSet.Auto)]
internal static extern SafeFileHandle SetupDiGetClassDevs(ref Guid ClassGuid, IntPtr Enumerator,
IntPtr hwndParent, DeviceGetClassFlags Flags);
internal static extern SafeFileHandle SetupDiGetClassDevs(ref Guid classGuid, IntPtr enumerator,
IntPtr hwndParent, DeviceGetClassFlags flags);
[DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool SetupDiEnumDeviceInterfaces(SafeFileHandle hDevInfo, IntPtr devInfo,

View File

@@ -43,7 +43,7 @@ namespace DiscImageChef.Devices.Windows
{
internal static DeviceInfo[] GetList()
{
List<string> DeviceIDs = new List<string>();
List<string> deviceIDs = new List<string>();
try
{
@@ -51,17 +51,17 @@ namespace DiscImageChef.Devices.Windows
new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
ManagementObjectCollection objCol = mgmtObjSearcher.Get();
foreach(ManagementObject drive in objCol) DeviceIDs.Add((string)drive["DeviceID"]);
foreach(ManagementObject drive in objCol) deviceIDs.Add((string)drive["DeviceID"]);
mgmtObjSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_TapeDrive");
objCol = mgmtObjSearcher.Get();
foreach(ManagementObject drive in objCol) DeviceIDs.Add((string)drive["DeviceID"]);
foreach(ManagementObject drive in objCol) deviceIDs.Add((string)drive["DeviceID"]);
mgmtObjSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_CDROMDrive");
objCol = mgmtObjSearcher.Get();
foreach(ManagementObject drive in objCol) DeviceIDs.Add((string)drive["Drive"]);
foreach(ManagementObject drive in objCol) deviceIDs.Add((string)drive["Drive"]);
}
catch(Exception ex)
{
@@ -72,9 +72,9 @@ namespace DiscImageChef.Devices.Windows
#endif
}
List<DeviceInfo> dev_list = new List<DeviceInfo>();
List<DeviceInfo> devList = new List<DeviceInfo>();
foreach(string devId in DeviceIDs)
foreach(string devId in deviceIDs)
{
string physId = devId;
// TODO: This can be done better
@@ -92,56 +92,56 @@ namespace DiscImageChef.Devices.Windows
//descriptor.RawDeviceProperties = new byte[16384];
IntPtr descriptorPtr = Marshal.AllocHGlobal(1000);
byte[] descriptor_b = new byte[1000];
byte[] descriptorB = new byte[1000];
uint returned = 0;
int error = 0;
bool hasError = !Extern.DeviceIoControlStorageQuery(fd, WindowsIoctl.IOCTL_STORAGE_QUERY_PROPERTY,
bool hasError = !Extern.DeviceIoControlStorageQuery(fd, WindowsIoctl.IoctlStorageQueryProperty,
ref query, (uint)Marshal.SizeOf(query),
descriptorPtr, 1000, ref returned, IntPtr.Zero);
if(hasError) error = Marshal.GetLastWin32Error();
Marshal.Copy(descriptorPtr, descriptor_b, 0, 1000);
Marshal.Copy(descriptorPtr, descriptorB, 0, 1000);
if(hasError && error != 0) continue;
StorageDeviceDescriptor descriptor = new StorageDeviceDescriptor();
descriptor.Version = BitConverter.ToUInt32(descriptor_b, 0);
descriptor.Size = BitConverter.ToUInt32(descriptor_b, 4);
descriptor.DeviceType = descriptor_b[8];
descriptor.DeviceTypeModifier = descriptor_b[9];
descriptor.RemovableMedia = BitConverter.ToBoolean(descriptor_b, 10);
descriptor.CommandQueueing = BitConverter.ToBoolean(descriptor_b, 11);
descriptor.VendorIdOffset = BitConverter.ToUInt32(descriptor_b, 12);
descriptor.ProductIdOffset = BitConverter.ToUInt32(descriptor_b, 16);
descriptor.ProductRevisionOffset = BitConverter.ToUInt32(descriptor_b, 20);
descriptor.SerialNumberOffset = BitConverter.ToUInt32(descriptor_b, 24);
descriptor.BusType = (StorageBusType)BitConverter.ToUInt32(descriptor_b, 28);
descriptor.RawPropertiesLength = BitConverter.ToUInt32(descriptor_b, 32);
descriptor.Version = BitConverter.ToUInt32(descriptorB, 0);
descriptor.Size = BitConverter.ToUInt32(descriptorB, 4);
descriptor.DeviceType = descriptorB[8];
descriptor.DeviceTypeModifier = descriptorB[9];
descriptor.RemovableMedia = BitConverter.ToBoolean(descriptorB, 10);
descriptor.CommandQueueing = BitConverter.ToBoolean(descriptorB, 11);
descriptor.VendorIdOffset = BitConverter.ToUInt32(descriptorB, 12);
descriptor.ProductIdOffset = BitConverter.ToUInt32(descriptorB, 16);
descriptor.ProductRevisionOffset = BitConverter.ToUInt32(descriptorB, 20);
descriptor.SerialNumberOffset = BitConverter.ToUInt32(descriptorB, 24);
descriptor.BusType = (StorageBusType)BitConverter.ToUInt32(descriptorB, 28);
descriptor.RawPropertiesLength = BitConverter.ToUInt32(descriptorB, 32);
DeviceInfo info = new DeviceInfo {path = physId, bus = descriptor.BusType.ToString()};
DeviceInfo info = new DeviceInfo {Path = physId, Bus = descriptor.BusType.ToString()};
if(descriptor.VendorIdOffset > 0)
info.vendor =
StringHandlers.CToString(descriptor_b, Encoding.ASCII, start: (int)descriptor.VendorIdOffset);
info.Vendor =
StringHandlers.CToString(descriptorB, Encoding.ASCII, start: (int)descriptor.VendorIdOffset);
if(descriptor.ProductIdOffset > 0)
info.model =
StringHandlers.CToString(descriptor_b, Encoding.ASCII, start: (int)descriptor.ProductIdOffset);
info.Model =
StringHandlers.CToString(descriptorB, Encoding.ASCII, start: (int)descriptor.ProductIdOffset);
// TODO: Get serial number of SCSI and USB devices, probably also FireWire (untested)
if(descriptor.SerialNumberOffset > 0)
info.serial =
StringHandlers.CToString(descriptor_b, Encoding.ASCII,
info.Serial =
StringHandlers.CToString(descriptorB, Encoding.ASCII,
start: (int)descriptor.SerialNumberOffset);
if(string.IsNullOrEmpty(info.vendor) || info.vendor == "ATA")
if(string.IsNullOrEmpty(info.Vendor) || info.Vendor == "ATA")
{
string[] pieces = info.model.Split(' ');
string[] pieces = info.Model.Split(' ');
if(pieces.Length > 1)
{
info.vendor = pieces[0];
info.model = info.model.Substring(pieces[0].Length + 1);
info.Vendor = pieces[0];
info.Model = info.Model.Substring(pieces[0].Length + 1);
}
}
@@ -157,15 +157,15 @@ namespace DiscImageChef.Devices.Windows
case StorageBusType.iSCSI:
case StorageBusType.SAS:
case StorageBusType.SATA:
info.supported = true;
info.Supported = true;
break;
}
Marshal.FreeHGlobal(descriptorPtr);
dev_list.Add(info);
devList.Add(info);
}
DeviceInfo[] devices = dev_list.ToArray();
DeviceInfo[] devices = devList.ToArray();
return devices;
}

View File

@@ -219,7 +219,7 @@ namespace DiscImageChef.Devices.Windows
}
[StructLayout(LayoutKind.Sequential)]
struct USB_SETUP_PACKET
struct UsbSetupPacket
{
public byte bmRequest;
public byte bRequest;
@@ -229,10 +229,10 @@ namespace DiscImageChef.Devices.Windows
}
[StructLayout(LayoutKind.Sequential)]
struct USB_DESCRIPTOR_REQUEST
struct UsbDescriptorRequest
{
public int ConnectionIndex;
public USB_SETUP_PACKET SetupPacket;
public UsbSetupPacket SetupPacket;
//public byte[] Data;
}

File diff suppressed because it is too large Load Diff

View File

@@ -46,63 +46,63 @@ namespace DiscImageChef.Devices.Windows
//
// Get a list of all connected devices
//
static internal List<USBDevice> GetConnectedDevices()
static internal List<UsbDevice> GetConnectedDevices()
{
List<USBDevice> DevList = new List<USBDevice>();
List<UsbDevice> devList = new List<UsbDevice>();
foreach(USBController Controller in GetHostControllers()) { ListHub(Controller.GetRootHub(), DevList); }
foreach(UsbController controller in GetHostControllers()) { ListHub(controller.GetRootHub(), devList); }
return DevList;
return devList;
}
// private routine for enumerating a hub
static void ListHub(USBHub Hub, List<USBDevice> DevList)
static void ListHub(UsbHub hub, List<UsbDevice> devList)
{
foreach(USBPort Port in Hub.GetPorts())
foreach(UsbPort port in hub.GetPorts())
{
if(Port.IsHub)
if(port.IsHub)
{
// recursive
ListHub(Port.GetHub(), DevList);
ListHub(port.GetHub(), devList);
}
else { if(Port.IsDeviceConnected) { DevList.Add(Port.GetDevice()); } }
else { if(port.IsDeviceConnected) { devList.Add(port.GetDevice()); } }
}
}
//
// Find a device based upon it's DriverKeyName
//
static internal USBDevice FindDeviceByDriverKeyName(string DriverKeyName)
static internal UsbDevice FindDeviceByDriverKeyName(string driverKeyName)
{
USBDevice FoundDevice = null;
UsbDevice foundDevice = null;
foreach(USBController Controller in GetHostControllers())
foreach(UsbController controller in GetHostControllers())
{
SearchHubDriverKeyName(Controller.GetRootHub(), ref FoundDevice, DriverKeyName);
if(FoundDevice != null) break;
SearchHubDriverKeyName(controller.GetRootHub(), ref foundDevice, driverKeyName);
if(foundDevice != null) break;
}
return FoundDevice;
return foundDevice;
}
// private routine for enumerating a hub
static void SearchHubDriverKeyName(USBHub Hub, ref USBDevice FoundDevice, string DriverKeyName)
static void SearchHubDriverKeyName(UsbHub hub, ref UsbDevice foundDevice, string driverKeyName)
{
foreach(USBPort Port in Hub.GetPorts())
foreach(UsbPort port in hub.GetPorts())
{
if(Port.IsHub)
if(port.IsHub)
{
// recursive
SearchHubDriverKeyName(Port.GetHub(), ref FoundDevice, DriverKeyName);
SearchHubDriverKeyName(port.GetHub(), ref foundDevice, driverKeyName);
}
else
{
if(Port.IsDeviceConnected)
if(port.IsDeviceConnected)
{
USBDevice Device = Port.GetDevice();
if(Device.DeviceDriverKey == DriverKeyName)
UsbDevice device = port.GetDevice();
if(device.DeviceDriverKey == driverKeyName)
{
FoundDevice = Device;
foundDevice = device;
break;
}
}
@@ -113,37 +113,37 @@ namespace DiscImageChef.Devices.Windows
//
// Find a device based upon it's Instance ID
//
static internal USBDevice FindDeviceByInstanceID(string InstanceID)
static internal UsbDevice FindDeviceByInstanceId(string instanceId)
{
USBDevice FoundDevice = null;
UsbDevice foundDevice = null;
foreach(USBController Controller in GetHostControllers())
foreach(UsbController controller in GetHostControllers())
{
SearchHubInstanceID(Controller.GetRootHub(), ref FoundDevice, InstanceID);
if(FoundDevice != null) break;
SearchHubInstanceId(controller.GetRootHub(), ref foundDevice, instanceId);
if(foundDevice != null) break;
}
return FoundDevice;
return foundDevice;
}
// private routine for enumerating a hub
static void SearchHubInstanceID(USBHub Hub, ref USBDevice FoundDevice, string InstanceID)
static void SearchHubInstanceId(UsbHub hub, ref UsbDevice foundDevice, string instanceId)
{
foreach(USBPort Port in Hub.GetPorts())
foreach(UsbPort port in hub.GetPorts())
{
if(Port.IsHub)
if(port.IsHub)
{
// recursive
SearchHubInstanceID(Port.GetHub(), ref FoundDevice, InstanceID);
SearchHubInstanceId(port.GetHub(), ref foundDevice, instanceId);
}
else
{
if(Port.IsDeviceConnected)
if(port.IsDeviceConnected)
{
USBDevice Device = Port.GetDevice();
if(Device.InstanceID == InstanceID)
UsbDevice device = port.GetDevice();
if(device.InstanceId == instanceId)
{
FoundDevice = Device;
foundDevice = device;
break;
}
}
@@ -152,9 +152,9 @@ namespace DiscImageChef.Devices.Windows
}
const int IOCTL_STORAGE_GET_DEVICE_NUMBER = 0x2D1080;
internal const string GUID_DEVINTERFACE_DISK = "53f56307-b6bf-11d0-94f2-00a0c91efb8b";
internal const string GUID_DEVINTERFACE_CDROM = "53f56308-b6bf-11d0-94f2-00a0c91efb8b";
internal const string GUID_DEVINTERFACE_FLOPPY = "53f56311-b6bf-11d0-94f2-00a0c91efb8b";
internal const string GuidDevinterfaceDisk = "53f56307-b6bf-11d0-94f2-00a0c91efb8b";
internal const string GuidDevinterfaceCdrom = "53f56308-b6bf-11d0-94f2-00a0c91efb8b";
internal const string GuidDevinterfaceFloppy = "53f56311-b6bf-11d0-94f2-00a0c91efb8b";
//typedef struct _STORAGE_DEVICE_NUMBER {
// DEVICE_TYPE DeviceType;
@@ -162,7 +162,7 @@ namespace DiscImageChef.Devices.Windows
// ULONG PartitionNumber;
//} STORAGE_DEVICE_NUMBER, *PSTORAGE_DEVICE_NUMBER;
[StructLayout(LayoutKind.Sequential)]
struct STORAGE_DEVICE_NUMBER
struct StorageDeviceNumber
{
internal int DeviceType;
internal int DeviceNumber;
@@ -184,72 +184,72 @@ namespace DiscImageChef.Devices.Windows
// IN ULONG ulFlags
//);
[DllImport("setupapi.dll", CharSet = CharSet.Auto)]
static extern int CM_Get_Device_ID(IntPtr dnDevInst, IntPtr Buffer, int BufferLen, int ulFlags);
static extern int CM_Get_Device_ID(IntPtr dnDevInst, IntPtr buffer, int bufferLen, int ulFlags);
//
// Find a device based upon a Drive Letter
//
static internal USBDevice FindDriveLetter(string DriveLetter, string deviceGuid)
static internal UsbDevice FindDriveLetter(string driveLetter, string deviceGuid)
{
USBDevice FoundDevice = null;
string InstanceID = "";
UsbDevice foundDevice = null;
string instanceId = "";
// We start by getting the unique DeviceNumber of the given
// DriveLetter. We'll use this later to find a matching
// DevicePath "symbolic name"
int DevNum = GetDeviceNumber(@"\\.\" + DriveLetter.TrimEnd('\\'));
if(DevNum < 0) { return null; }
int devNum = GetDeviceNumber(@"\\.\" + driveLetter.TrimEnd('\\'));
if(devNum < 0) { return null; }
return FindDeviceNumber(DevNum, deviceGuid);
return FindDeviceNumber(devNum, deviceGuid);
}
static internal USBDevice FindDrivePath(string DrivePath, string deviceGuid)
static internal UsbDevice FindDrivePath(string drivePath, string deviceGuid)
{
USBDevice FoundDevice = null;
string InstanceID = "";
UsbDevice foundDevice = null;
string instanceId = "";
// We start by getting the unique DeviceNumber of the given
// DriveLetter. We'll use this later to find a matching
// DevicePath "symbolic name"
int DevNum = GetDeviceNumber(DrivePath);
if(DevNum < 0) { return null; }
int devNum = GetDeviceNumber(drivePath);
if(devNum < 0) { return null; }
return FindDeviceNumber(DevNum, deviceGuid);
return FindDeviceNumber(devNum, deviceGuid);
}
//
// Find a device based upon a Drive Letter
//
static internal USBDevice FindDeviceNumber(int DevNum, string deviceGuid)
static internal UsbDevice FindDeviceNumber(int devNum, string deviceGuid)
{
USBDevice FoundDevice = null;
string InstanceID = "";
UsbDevice foundDevice = null;
string instanceId = "";
Guid DiskGUID = new Guid(deviceGuid);
Guid diskGuid = new Guid(deviceGuid);
// We start at the "root" of the device tree and look for all
// devices that match the interface GUID of a disk
IntPtr h = SetupDiGetClassDevs(ref DiskGUID, 0, IntPtr.Zero, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
IntPtr h = SetupDiGetClassDevs(ref diskGuid, 0, IntPtr.Zero, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if(h.ToInt32() != INVALID_HANDLE_VALUE)
{
bool Success = true;
bool success = true;
int i = 0;
do
{
// create a Device Interface Data structure
SP_DEVICE_INTERFACE_DATA dia = new SP_DEVICE_INTERFACE_DATA();
SpDeviceInterfaceData dia = new SpDeviceInterfaceData();
dia.cbSize = Marshal.SizeOf(dia);
// start the enumeration
Success = SetupDiEnumDeviceInterfaces(h, IntPtr.Zero, ref DiskGUID, i, ref dia);
if(Success)
success = SetupDiEnumDeviceInterfaces(h, IntPtr.Zero, ref diskGuid, i, ref dia);
if(success)
{
// build a DevInfo Data structure
SP_DEVINFO_DATA da = new SP_DEVINFO_DATA();
SpDevinfoData da = new SpDevinfoData();
da.cbSize = Marshal.SizeOf(da);
// build a Device Interface Detail Data structure
SP_DEVICE_INTERFACE_DETAIL_DATA didd = new SP_DEVICE_INTERFACE_DETAIL_DATA();
SpDeviceInterfaceDetailData didd = new SpDeviceInterfaceDetailData();
didd.cbSize = 4 + Marshal.SystemDefaultCharSize; // trust me :)
// now we can get some more detailed information
@@ -260,7 +260,7 @@ namespace DiscImageChef.Devices.Windows
// Now that we have a DevicePath... we can use it to
// generate another DeviceNumber to see if it matches
// the one we're looking for.
if(GetDeviceNumber(didd.DevicePath) == DevNum)
if(GetDeviceNumber(didd.DevicePath) == devNum)
{
// current InstanceID is at the "USBSTOR" level, so we
// need up "move up" one level to get to the "USB" level
@@ -270,46 +270,46 @@ namespace DiscImageChef.Devices.Windows
// Now we get the InstanceID of the USB level device
IntPtr ptrInstanceBuf = Marshal.AllocHGlobal(nBytes);
CM_Get_Device_ID(ptrPrevious, ptrInstanceBuf, nBytes, 0);
InstanceID = Marshal.PtrToStringAuto(ptrInstanceBuf);
instanceId = Marshal.PtrToStringAuto(ptrInstanceBuf);
Marshal.FreeHGlobal(ptrInstanceBuf);
System.Console.WriteLine("InstanceId: {0}", InstanceID);
System.Console.WriteLine("InstanceId: {0}", instanceId);
//break;
}
}
}
i++;
}
while(Success);
while(success);
SetupDiDestroyDeviceInfoList(h);
}
// Did we find an InterfaceID of a USB device?
if(InstanceID.StartsWith("USB\\")) { FoundDevice = FindDeviceByInstanceID(InstanceID); }
return FoundDevice;
if(instanceId.StartsWith("USB\\")) { foundDevice = FindDeviceByInstanceId(instanceId); }
return foundDevice;
}
// return a unique device number for the given device path
private static int GetDeviceNumber(string DevicePath)
private static int GetDeviceNumber(string devicePath)
{
int ans = -1;
IntPtr h = CreateFile(DevicePath.TrimEnd('\\'), 0, 0, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero);
IntPtr h = CreateFile(devicePath.TrimEnd('\\'), 0, 0, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero);
if(h.ToInt32() != INVALID_HANDLE_VALUE)
{
int requiredSize;
STORAGE_DEVICE_NUMBER Sdn = new STORAGE_DEVICE_NUMBER();
int nBytes = Marshal.SizeOf(Sdn);
StorageDeviceNumber sdn = new StorageDeviceNumber();
int nBytes = Marshal.SizeOf(sdn);
IntPtr ptrSdn = Marshal.AllocHGlobal(nBytes);
if(DeviceIoControl(h, IOCTL_STORAGE_GET_DEVICE_NUMBER, IntPtr.Zero, 0, ptrSdn, nBytes, out requiredSize,
IntPtr.Zero))
{
Sdn = (STORAGE_DEVICE_NUMBER)Marshal.PtrToStructure(ptrSdn, typeof(STORAGE_DEVICE_NUMBER));
sdn = (StorageDeviceNumber)Marshal.PtrToStructure(ptrSdn, typeof(StorageDeviceNumber));
// just my way of combining the relevant parts of the
// STORAGE_DEVICE_NUMBER into a single number
ans = (Sdn.DeviceType << 8) + Sdn.DeviceNumber;
ans = (sdn.DeviceType << 8) + sdn.DeviceNumber;
}
Marshal.FreeHGlobal(ptrSdn);
CloseHandle(h);