// /*************************************************************************** // The Disc Image Chef // ---------------------------------------------------------------------------- // // Filename : Enums.cs // Author(s) : Natalia Portillo // // Component : FreeBSD direct device access. // // --[ Description ] ---------------------------------------------------------- // // Contains enumerations necessary for directly interfacing devices under // FreeBSD. // // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; either version 2.1 of the // License, or (at your option) any later version. // // This library 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 // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, see . // // ---------------------------------------------------------------------------- // Copyright © 2011-2018 Natalia Portillo // ****************************************************************************/ using System; namespace DiscImageChef.Devices.FreeBSD { [Flags] enum FileFlags { /// /// O_RDONLY /// ReadOnly = 0x00000000, /// /// O_WRONLY /// WriteOnly = 0x00000001, /// /// O_RDWR /// ReadWrite = 0x00000002, /// /// O_NONBLOCK /// NonBlocking = 0x00000004, /// /// O_APPEND /// Append = 0x00000008, /// /// O_SHLOCK /// SharedLock = 0x00000010, /// /// O_EXLOCK /// ExclusiveLock = 0x00000020, /// /// O_ASYNC /// Async = 0x00000040, /// /// O_FSYNC /// SyncWrites = 0x00000080, /// /// O_NOFOLLOW /// NoFollowSymlink = 0x00000100, /// /// O_CREAT /// OpenOrCreate = 0x00000200, /// /// O_TRUNC /// Truncate = 0x00000400, /// /// O_EXCL /// CreateNew = 0x00000800, /// /// O_NOCTTY /// NoControlTty = 0x00008000, /// /// O_DIRECT /// Direct = 0x00010000, /// /// O_DIRECTORY /// Directory = 0x00020000, /// /// O_EXEC /// Execute = 0x00040000, /// /// O_TTY_INIT /// InitializeTty = 0x00080000, /// /// O_CLOEXEC /// CloseOnExec = 0x00100000 } [Flags] enum CamAtaIoFlags : byte { /// /// 48-bit command /// ExtendedCommand = 0x01, /// /// FPDMA command /// Fpdma = 0x02, /// /// Control, not a command /// Control = 0x04, /// /// Needs result /// NeedResult = 0x08, /// /// DMA command /// Dma = 0x10 } /// XPT Opcodes for xpt_action [Flags] enum XptOpcode { // Function code flags are bits greater than 0xff /// Non-immediate function code XptFcQueued = 0x100, XptFcUserCcb = 0x200, /// Only for the transport layer device XptFcXptOnly = 0x400, /// Passes through the device queues XptFcDevQueued = 0x800 | XptFcQueued, // Common function commands: 0x00->0x0F /// Execute Nothing XptNoop = 0x00, /// Execute the requested I/O operation XptScsiIo = 0x01 | XptFcDevQueued, /// Get type information for specified device XptGdevType = 0x02, /// Get a list of peripheral devices XptGdevlist = 0x03, /// Path routing inquiry XptPathInq = 0x04, /// Release a frozen device queue XptRelSimq = 0x05, /// Set Asynchronous Callback Parameters XptSasyncCb = 0x06, /// Set device type information XptSdevType = 0x07, /// (Re)Scan the SCSI Bus XptScanBus = 0x08 | XptFcQueued | XptFcUserCcb | XptFcXptOnly, /// Get EDT entries matching the given pattern XptDevMatch = 0x09 | XptFcXptOnly, /// Turn on debugging for a bus, target or lun XptDebug = 0x0a, /// Path statistics (error counts, etc.) XptPathStats = 0x0b, /// Device statistics (error counts, etc.) XptGdevStats = 0x0c, /// Get/Set Device advanced information XptDevAdvinfo = 0x0e, /// Asynchronous event XptAsync = 0x0f | XptFcQueued | XptFcUserCcb | XptFcXptOnly, /// SCSI Control Functions: 0x10->0x1F /// Abort the specified CCB XptAbort = 0x10, /// Reset the specified SCSI bus XptResetBus = 0x11 | XptFcXptOnly, /// Bus Device Reset the specified SCSI device XptResetDev = 0x12 | XptFcDevQueued, /// Terminate the I/O process XptTermIo = 0x13, /// Scan Logical Unit XptScanLun = 0x14 | XptFcQueued | XptFcUserCcb | XptFcXptOnly, /// Get default/user transfer settings for the target XptGetTranSettings = 0x15, /// Set transfer rate/width negotiation settings XptSetTranSettings = 0x16, /// Calculate the geometry parameters for a device give the sector size and volume size. XptCalcGeometry = 0x17, /// Execute the requested ATA I/O operation XptAtaIo = 0x18 | XptFcDevQueued, /// Compat only XptGetSimKnobOld = 0x18, /// Set SIM specific knob values. XptSetSimKnob = 0x19, /// Get SIM specific knob values. XptGetSimKnob = 0x1a, /// Serial Management Protocol XptSmpIo = 0x1b | XptFcDevQueued, /// Scan Target XptScanTgt = 0x1E | XptFcQueued | XptFcUserCcb | XptFcXptOnly, // HBA engine commands 0x20->0x2F /// HBA engine feature inquiry XptEngInq = 0x20 | XptFcXptOnly, /// HBA execute engine request XptEngExec = 0x21 | XptFcDevQueued, // Target mode commands: 0x30->0x3F /// Enable LUN as a target XptEnLun = 0x30, /// Execute target I/O request XptTargetIo = 0x31 | XptFcDevQueued, /// Accept Host Target Mode CDB XptAcceptTargetIo = 0x32 | XptFcQueued | XptFcUserCcb, /// Continue Host Target I/O Connection XptContTargetIo = 0x33 | XptFcDevQueued, /// Notify Host Target driver of event (obsolete) XptImmedNotify = 0x34 | XptFcQueued | XptFcUserCcb, /// Acknowledgement of event (obsolete) XptNotifyAck = 0x35, /// Notify Host Target driver of event XptImmediateNotify = 0x36 | XptFcQueued | XptFcUserCcb, /// Acknowledgement of event XptNotifyAcknowledge = 0x37 | XptFcQueued | XptFcUserCcb, /// Vendor Unique codes: 0x80->0x8F XptVunique = 0x80 } enum CcbDevMatchStatus { CamDevMatchLast, CamDevMatchMore, CamDevMatchListChanged, CamDevMatchSizeError, CamDevMatchError } enum DevMatchType { DevMatchPeriph = 0, DevMatchDevice, DevMatchBus } [Flags] enum PeriphPatternFlags { PeriphMatchNone = 0x000, PeriphMatchPath = 0x001, PeriphMatchTarget = 0x002, PeriphMatchLun = 0x004, PeriphMatchName = 0x008, PeriphMatchUnit = 0x010 // PERIPH_MATCH_ANY = 0x01f } [Flags] enum DevPatternFlags { DevMatchNone = 0x000, DevMatchPath = 0x001, DevMatchTarget = 0x002, DevMatchLun = 0x004, DevMatchInquiry = 0x008, DevMatchDevid = 0x010 // DEV_MATCH_ANY = 0x00f } [Flags] enum BusPatternFlags { BusMatchNone = 0x000, BusMatchPath = 0x001, BusMatchName = 0x002, BusMatchUnit = 0x004, BusMatchBusId = 0x008 // BUS_MATCH_ANY = 0x00f } [Flags] enum DevResultFlags { DevResultNoflag = 0x00, DevResultUnconfigured = 0x01 } enum CamProto { ProtoUnknown, ProtoUnspecified, /// /// Small Computer System Interface /// ProtoScsi, /// /// AT Attachment /// ProtoAta, /// /// AT Attachment Packetized Interface /// ProtoAtapi, /// /// SATA Port Multiplier /// ProtoSatapm, /// /// SATA Enclosure Management Bridge /// ProtoSemb, /// /// NVMe /// ProtoNvme, /// /// MMC, SD, SDIO /// ProtoMmcsd } [Flags] enum MmcCardFeatures { CardFeatureMemory = 0x1, CardFeatureSdhc = 0x1 << 1, CardFeatureSdio = 0x1 << 2, CardFeatureSd20 = 0x1 << 3, CardFeatureMmc = 0x1 << 4, CardFeature18V = 0x1 << 5 } enum CamGenerations : uint { CamBusGeneration = 0x00, CamTargetGeneration = 0x01, CamDevGeneration = 0x02, CamPeriphGeneration = 0x03 } [Flags] enum DevPosType { CamDevPosNone = 0x000, CamDevPosBus = 0x001, CamDevPosTarget = 0x002, CamDevPosDevice = 0x004, CamDevPosPeriph = 0x008, CamDevPosPdptr = 0x010, // CAM_DEV_POS_TYPEMASK = 0xf00, CamDevPosEdt = 0x100, CamDevPosPdrv = 0x200 } enum FreebsdIoctl : uint { Camiocommand = 0xC4D81802 } [Flags] enum CcbFlags : uint { /// /// The CDB field is a pointer /// CamCdbPointer = 0x00000001, /// /// SIM queue actions are enabled /// CamQueueEnable = 0x00000002, /// /// CCB contains a linked CDB /// CamCdbLinked = 0x00000004, /// /// Perform transport negotiation with this command. /// CamNegotiate = 0x00000008, /// /// Data type with physical addrs /// CamDataIsphys = 0x00000010, /// /// Disable autosense feature /// CamDisAutosense = 0x00000020, /// /// Data direction (00:IN/OUT) /// CamDirBoth = 0x00000000, /// /// Data direction (01:DATA IN) /// CamDirIn = 0x00000040, /// /// Data direction (10:DATA OUT) /// CamDirOut = 0x00000080, /// /// Data direction (11:no data) /// CamDirNone = 0x000000C0, /// /// Data type (000:Virtual) /// CamDataVaddr = 0x00000000, /// /// Data type (001:Physical) /// CamDataPaddr = 0x00000010, /// /// Data type (010:sglist) /// CamDataSg = 0x00040000, /// /// Data type (011:sglist phys) /// CamDataSgPaddr = 0x00040010, /// /// Data type (100:bio) /// CamDataBio = 0x00200000, /// /// Use Soft reset alternative /// CamSoftRstOp = 0x00000100, /// /// Flush resid bytes on complete /// CamEngSync = 0x00000200, /// /// Disable DEV Q freezing /// CamDevQfrzdis = 0x00000400, /// /// Freeze DEV Q on execution /// CamDevQfreeze = 0x00000800, /// /// Command takes a lot of power /// CamHighPower = 0x00001000, /// /// Sense data is a pointer /// CamSensePtr = 0x00002000, /// /// Sense pointer is physical addr /// CamSensePhys = 0x00004000, /// /// Use the tag action in this ccb /// CamTagActionValid = 0x00008000, /// /// Pass driver does err. recovery /// CamPassErrRecover = 0x00010000, /// /// Disable disconnect /// CamDisDisconnect = 0x00020000, /// /// Message buffer ptr is physical /// CamMsgBufPhys = 0x00080000, /// /// Autosense data ptr is physical /// CamSnsBufPhys = 0x00100000, /// /// CDB poiner is physical /// CamCdbPhys = 0x00400000, /// /// SG list is for the HBA engine /// CamEngSglist = 0x00800000, /* Phase cognizant mode flags */ /// /// Disable autosave/restore ptrs /// CamDisAutosrp = 0x01000000, /// /// Disable auto disconnect /// CamDisAutodisc = 0x02000000, /// /// Target CCB available /// CamTgtCcbAvail = 0x04000000, /// /// The SIM runs in phase mode /// CamTgtPhaseMode = 0x08000000, /// /// Message buffer valid /// CamMsgbValid = 0x10000000, /// /// Status buffer valid /// CamStatusValid = 0x20000000, /// /// Data buffer valid /// CamDatabValid = 0x40000000, /* Host target Mode flags */ /// /// Send sense data with status /// CamSendSense = 0x08000000, /// /// Terminate I/O Message sup. /// CamTermIo = 0x10000000, /// /// Disconnects are mandatory /// CamDisconnect = 0x20000000, /// /// Send status after data phase /// CamSendStatus = 0x40000000, /// /// Call callback without lock. /// CamUnlocked = 0x80000000 } enum CamStatus : uint { /// CCB request is in progress CamReqInprog = 0x00, /// CCB request completed without error CamReqCmp = 0x01, /// CCB request aborted by the host CamReqAborted = 0x02, /// Unable to abort CCB request CamUaAbort = 0x03, /// CCB request completed with an error CamReqCmpErr = 0x04, /// CAM subsystem is busy CamBusy = 0x05, /// CCB request was invalid CamReqInvalid = 0x06, /// Supplied Path ID is invalid CamPathInvalid = 0x07, /// SCSI Device Not Installed/there CamDevNotThere = 0x08, /// Unable to terminate I/O CCB request CamUaTermio = 0x09, /// Target Selection Timeout CamSelTimeout = 0x0a, /// Command timeout CamCmdTimeout = 0x0b, /// SCSI error, look at error code in CCB CamScsiStatusError = 0x0c, /// Message Reject Received CamMsgRejectRec = 0x0d, /// SCSI Bus Reset Sent/Received CamScsiBusReset = 0x0e, /// Uncorrectable parity error occurred CamUncorParity = 0x0f, /// Autosense: request sense cmd fail CamAutosenseFail = 0x10, /// No HBA Detected error CamNoHba = 0x11, /// Data Overrun error CamDataRunErr = 0x12, /// Unexpected Bus Free CamUnexpBusfree = 0x13, /// Target Bus Phase Sequence Failure CamSequenceFail = 0x14, /// CCB length supplied is inadequate CamCcbLenErr = 0x15, /// Unable to provide requested capability CamProvideFail = 0x16, /// A SCSI BDR msg was sent to target CamBdrSent = 0x17, /// CCB request terminated by the host CamReqTermio = 0x18, /// Unrecoverable Host Bus Adapter Error CamUnrecHbaError = 0x19, /// Request was too large for this host CamReqTooBig = 0x1a, /// 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. CamRequeueReq = 0x1b, /// ATA error, look at error code in CCB CamAtaStatusError = 0x1c, /// Initiator/Target Nexus lost. CamScsiItNexusLost = 0x1d, /// SMP error, look at error code in CCB CamSmpStatusError = 0x1e, /// Command completed without error but exceeded the soft timeout threshold. CamReqSofttimeout = 0x1f, /* * 0x20 - 0x32 are unassigned */ /// Initiator Detected Error CamIde = 0x33, /// Resource Unavailable CamResrcUnavail = 0x34, /// Unacknowledged Event by Host CamUnackedEvent = 0x35, /// Message Received in Host Target Mode CamMessageRecv = 0x36, /// Invalid CDB received in Host Target Mode CamInvalidCdb = 0x37, /// Lun supplied is invalid CamLunInvalid = 0x38, /// Target ID supplied is invalid CamTidInvalid = 0x39, /// The requested function is not available CamFuncNotavail = 0x3a, /// Nexus is not established CamNoNexus = 0x3b, /// The initiator ID is invalid CamIidInvalid = 0x3c, /// The SCSI CDB has been received CamCdbRecvd = 0x3d, /// The LUN is already enabled for target mode CamLunAlrdyEna = 0x3e, /// SCSI Bus Busy CamScsiBusy = 0x3f, /* * Flags */ /// The DEV queue is frozen w/this err CamDevQfrzn = 0x40, /// Autosense data valid for target CamAutosnsValid = 0x80, /// SIM ready to take more commands CamReleaseSimq = 0x100, /// SIM has this command in its queue CamSimQueued = 0x200, /// Quality of service data is valid CamQosValid = 0x400, /// Mask bits for just the status # CamStatusMask = 0x3F, /* * Target Specific Adjunct Status */ /// sent sense with status CamSentSense = 0x40000000 } }