//
// BwgBurn - CD-R/CD-RW/DVD-R/DVD-RW burning program for Windows XP
//
// Copyright (C) 2006 by Jack W. Griffin (butchg@comcast.net)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the
//
// Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330,
// Boston, MA 02111-1307 USA
//
using System;
using System.Collections.Generic;
using System.Text;
namespace Bwg.Scsi
{
///
/// This class describes a single SCSI feature. The data associated with the feature is
/// stored as a series of bytes that must be interpreted by the calling code.
///
public class Feature : Result
{
#region Feature Numbers
///
/// This enumerated type indicates the type of the feature.
///
public enum FeatureType : ushort
{
///
/// The ProfileList feature (see the SCSI-3 MMC specification)
///
ProfileList = 0x0000,
///
/// The Core feature (see the SCSI-3 MMC specification)
///
Core = 0x0001,
///
/// The Morphing feature (see the SCSI-3 MMC specification)
///
Morphing = 0x0002,
///
/// The RemovableMedia feature (see the SCSI-3 MMC specification)
///
RemovableMedia = 0x0003,
///
/// The WriteProtect feature (see the SCSI-3 MMC specification)
///
WriteProtect = 0x0004,
///
/// The RandomReadable feature (see the SCSI-3 MMC specification)
///
RandomReadable = 0x0010,
///
/// The MultiRead feature (see the SCSI-3 MMC specification)
///
MultiRead = 0x001d,
///
/// The CDRead feature (see the SCSI-3 MMC specification)
///
CDRead = 0x001e,
///
/// The DVDRead feature (see the SCSI-3 MMC specification)
///
DVDRead = 0x001f,
///
/// The RandomWritable feature (see the SCSI-3 MMC specification)
///
RandomWritable = 0x0020,
///
/// The IncrementalStreamWritable feature (see the SCSI-3 MMC specification)
///
IncrementalStreamWritable = 0x0021,
///
/// The SectorErasable feature (see the SCSI-3 MMC specification)
///
SectorErasable = 0x0022,
///
/// The Formattable feature (see the SCSI-3 MMC specification)
///
Formattable = 0x0023,
///
/// The HardwareDefectManagement feature (see the SCSI-3 MMC specification)
///
HardwareDefectManagement = 0x0024,
///
/// The WriteOnce feature (see the SCSI-3 MMC specification)
///
WriteOnce = 0x0025,
///
/// The RestrictedOverwrite feature (see the SCSI-3 MMC specification)
///
RestrictedOverwrite = 0x0026,
///
/// The CDRWCavWrite feature (see the SCSI-3 MMC specification)
///
CDRWCavWrite = 0x0027,
///
/// The MRW feature (see the SCSI-3 MMC specification)
///
MRW = 0x0028,
///
/// The EnhancedDefectReporting feature (see the SCSI-3 MMC specification)
///
EnhancedDefectReporting = 0x0029,
///
/// The DVDPlusRW feature (see the SCSI-3 MMC specification)
///
DVDPlusRW = 0x002a,
///
/// The DVDPlusR feature (see the SCSI-3 MMC specification)
///
DVDPlusR = 0x002b,
///
/// The RigidRestrictedOverwrite feature (see the SCSI-3 MMC specification)
///
RigidRestrictedOverwrite = 0x002c,
///
/// The CDTrackAtOnce feature (see the SCSI-3 MMC specification)
///
CDTrackAtOnce = 0x002d,
///
/// The CDSessionAtOnce feature (see the SCSI-3 MMC specification)
///
CDSessionAtOnce = 0x002e,
///
/// The DVDMinusR_DVDMinusRW feature (see the SCSI-3 MMC specification)
///
DVDMinusR_DVDMinusRW = 0x002f,
///
/// The DDCDRead feature (see the SCSI-3 MMC specification)
///
DDCDRead = 0x0030,
///
/// The DDCDMinusR feature (see the SCSI-3 MMC specification)
///
DDCDMinusR = 0x0031,
///
/// The DDCDMinusRW feature (see the SCSI-3 MMC specification)
///
DDCDMinusRW = 0x0032,
///
/// The layer jump recording feature (see the SCSI MMC-5 specification)
///
LayerJumpRecording = 0x0033,
///
/// The CDRWMediaWriteSupport feature (see the SCSI-3 MMC specification)
///
CDRWMediaWriteSupport = 0x0037,
///
///
///
BD_RPseudoOverWrite = 0x0038,
///
/// The dual layer feature for DVD+RW
///
DvdPlusRWDualLayer = 0x003a,
///
/// The dual layer featuer for DVD+R
///
DvdPlusRDualLayer = 0x003b,
///
///
///
BDRead = 0x0040,
///
///
///
BDWrite = 0x0041,
///
///
///
TSR = 0x0042,
///
///
///
HdDvdRead = 0x0050,
///
///
///
HdDvdWrite = 0x0051,
///
///
///
OldHybridDisk = 0x0052,
///
///
///
HybridDisk = 0x0080,
///
/// The PowerMangaementFeature feature (see the SCSI-3 MMC specification)
///
PowerMangaementFeature = 0x0100,
///
/// The S_M_A_R_T feature (see the SCSI-3 MMC specification)
///
S_M_A_R_T = 0x0101,
///
/// The EmbeddedChanger feature (see the SCSI-3 MMC specification)
///
EmbeddedChanger = 0x0102,
///
/// The CDAudioExternalPlay feature (see the SCSI-3 MMC specification)
///
CDAudioExternalPlay = 0x0103,
///
/// The MicrocodeUpgrade feature (see the SCSI-3 MMC specification)
///
MicrocodeUpgrade = 0x0104,
///
/// The Timeout feature (see the SCSI-3 MMC specification)
///
Timeout = 0x0105,
///
/// The DVDCSS feature (see the SCSI-3 MMC specification)
///
DVDCSS = 0x0106,
///
/// The RealTimeStreaming feature (see the SCSI-3 MMC specification)
///
RealTimeStreaming = 0x0107,
///
/// The LogicalUnitSerialNumber feature (see the SCSI-3 MMC specification)
///
LogicalUnitSerialNumber = 0x0108,
///
/// The MediaSerialNumber feature (see the SCSI-3 MMC specification)
///
MediaSerialNumber = 0x0109,
///
/// The DiskControlBlock feature (see the SCSI-3 MMC specification)
///
DiskControlBlock = 0x010A,
///
/// The DVD_CPRM feature (see the SCSI-3 MMC specification)
///
DVD_CPRM = 0x010B,
///
/// The FirmwareInformation feature (see the SCSI-3 MMC specification)
///
FirmwareInformation = 0x010C,
///
///
///
AACS = 0x010d,
///
///
///
VCPS = 0x0110
} ;
#endregion
#region private variables
///
/// The feature code for this feature
///
private FeatureType m_code;
///
/// The verion for this feature
///
private byte m_version;
///
/// If true, this feature is persistent (see SCSI MMC spec for more details)
///
private bool m_persistent;
///
/// If true, this feature is current (see SCSI MMC spec for more details)
///
private bool m_current;
///
/// The raw data assocaited with the feature. This data may be invalid if the
/// feature is invalid.
///
private byte[] m_data;
#endregion
#region constructor
///
/// This is a constructor for the SCSI feature. It takes data from a raw buffer and
/// creates the SCSI featuer object
///
/// Pointer to the start of the raw reply buffer
/// Size of the raw reply buffer
/// The offset to start parsing a SCSI feature from the reply buffer
public Feature(IntPtr buffer, int size, ref int offset) : base(buffer, size)
{
m_code = (FeatureType)Get16(offset);
offset += 2;
byte b = Get8(offset);
offset++;
if ((b & 0x01) != 0)
m_current = true;
else
m_current = false;
if ((b & 0x02) != 0)
m_persistent = true;
else
m_persistent = false;
m_version = (byte)((b >> 2) & 0x0f);
byte len = Get8(offset);
offset++;
m_data = new byte[len];
for(int i = 0 ; i < len && offset < BufferSize ; i++)
{
m_data[i] = Get8(offset);
offset++;
}
}
#endregion
#region public methods
///
/// Return a string representing a human readable form of this object.
///
/// string representing this object
public override string ToString()
{
return "Feature(type=" + m_code.ToString() + ")";
}
#endregion
#region public propreties
///
/// Return the code associated with this feature
///
public FeatureType Code { get { return m_code; } }
///
/// Return the version of the current feature
///
public byte Version { get { return m_version; } }
///
/// Return the presistence state of the feature. If true, this feature is persistant
///
public bool Persistent { get { return m_persistent; } }
///
/// Return the current flag associated with the feature. If true, this feature is currently active.
///
public bool Current { get { return m_current; } }
///
/// This item contains the data from the feature
///
public byte[] Data { get { return m_data; } }
///
/// This property returns the name of the feature.
///
public string Name
{
get
{
return m_code.ToString();
}
}
#endregion
}
}