public NVMeInfo GetInfo(StorageInfo infoToMatch, int logicalDriveNumber, bool force) { if (handle.IsClosed) { throw new ObjectDisposedException("WindowsNVMeSmart"); } try { byte[] rawData; // This doesn't work with SCSI devices. Otherwise, that would be unique // var deviceNumber = WindowsStorage.QueryDeviceNumber(handle); NVMeIdentifyControllerData data = ReadPassThrough <NVMeIdentifyControllerData>(NVMePassThroughOpcode.AdminIdentify, 0x0, 0x000000001, out rawData); if (data.nn == 1) { byte[] rawDataNamespace; NVMeIdentifyNamespaceData nspace = ReadPassThrough <NVMeIdentifyNamespaceData>(NVMePassThroughOpcode.AdminIdentify, 0x000000001, 0x00000000, out rawDataNamespace); return(new NVMeInfoImpl(driveNumber, logicalDriveNumber, data, rawData, nspace, rawDataNamespace)); } return(new NVMeInfoImpl(driveNumber, logicalDriveNumber, data, rawData)); } catch (Win32Exception x) { Logging.LogError(x, "Unable to query NVMe controller info"); } // Construct the object anyway (or the counting will probably be off) // Also, the device will probably support some NVMe commands anyway if (force) { return(new NVMeInfoImpl(driveNumber, logicalDriveNumber, infoToMatch)); } return(null); }
public NVMeInfoImpl(int index, NVMeIdentifyControllerData data, byte[] rawData) { Index = index; VID = data.vid; SSVID = data.ssvid; Serial = GetString(data.sn); Model = GetString(data.mn); Revision = GetString(data.fr); IEEE = data.ieee; TotalCapacity = BitConverter.ToUInt64(data.tnvmcap, 0); // 128bit little endian UnallocatedCapacity = BitConverter.ToUInt64(data.unvmcap, 0); ControllerId = data.cntlid; NumberNamespaces = data.nn; RawData = rawData; }
public NVMeInfo GetInfo() { if (handle.IsClosed) { throw new ObjectDisposedException("WindowsNVMeSmart"); } try { byte[] rawData; NVMeIdentifyControllerData data = ReadPassThrough <NVMeIdentifyControllerData>(NVMePassThroughOpcode.AdminIdentify, 0x00000000, 0x000000001, out rawData); if (data.nn == 1) { byte[] rawDataNamespace; NVMeIdentifyNamespaceData nspace = ReadPassThrough <NVMeIdentifyNamespaceData>(NVMePassThroughOpcode.AdminIdentify, 0x000000001, 0x00000000, out rawDataNamespace); return(new NVMeInfoImpl(driveNumber, data, rawData, nspace, rawDataNamespace)); } return(new NVMeInfoImpl(driveNumber, data, rawData)); } catch (Win32Exception) { } return(null); }
public NVMeInfoImpl(int index, NVMeIdentifyControllerData data, byte[] rawData, NVMeIdentifyNamespaceData namespaceData, byte[] namespaceRawData) : this(index, data, rawData) { Namespace1 = new NVMeNamespaceInfoImpl(namespaceData, namespaceRawData); }