// /*************************************************************************** // 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 xpt_opcode { // Function code flags are bits greater than 0xff /// Non-immediate function code XPT_FC_QUEUED = 0x100, XPT_FC_USER_CCB = 0x200, /// Only for the transport layer device XPT_FC_XPT_ONLY = 0x400, /// Passes through the device queues XPT_FC_DEV_QUEUED = 0x800 | XPT_FC_QUEUED, // Common function commands: 0x00->0x0F /// Execute Nothing XPT_NOOP = 0x00, /// Execute the requested I/O operation XPT_SCSI_IO = 0x01 | XPT_FC_DEV_QUEUED, /// Get type information for specified device XPT_GDEV_TYPE = 0x02, /// Get a list of peripheral devices XPT_GDEVLIST = 0x03, /// Path routing inquiry XPT_PATH_INQ = 0x04, /// Release a frozen device queue XPT_REL_SIMQ = 0x05, /// Set Asynchronous Callback Parameters XPT_SASYNC_CB = 0x06, /// Set device type information XPT_SDEV_TYPE = 0x07, /// (Re)Scan the SCSI Bus XPT_SCAN_BUS = 0x08 | XPT_FC_QUEUED | XPT_FC_USER_CCB | XPT_FC_XPT_ONLY, /// Get EDT entries matching the given pattern XPT_DEV_MATCH = 0x09 | XPT_FC_XPT_ONLY, /// Turn on debugging for a bus, target or lun XPT_DEBUG = 0x0a, /// Path statistics (error counts, etc.) XPT_PATH_STATS = 0x0b, /// Device statistics (error counts, etc.) XPT_GDEV_STATS = 0x0c, /// Get/Set Device advanced information XPT_DEV_ADVINFO = 0x0e, /// Asynchronous event XPT_ASYNC = 0x0f | XPT_FC_QUEUED | XPT_FC_USER_CCB | XPT_FC_XPT_ONLY, /// SCSI Control Functions: 0x10->0x1F /// Abort the specified CCB XPT_ABORT = 0x10, /// Reset the specified SCSI bus XPT_RESET_BUS = 0x11 | XPT_FC_XPT_ONLY, /// Bus Device Reset the specified SCSI device XPT_RESET_DEV = 0x12 | XPT_FC_DEV_QUEUED, /// Terminate the I/O process XPT_TERM_IO = 0x13, /// Scan Logical Unit XPT_SCAN_LUN = 0x14 | XPT_FC_QUEUED | XPT_FC_USER_CCB | XPT_FC_XPT_ONLY, /// Get default/user transfer settings for the target XPT_GET_TRAN_SETTINGS = 0x15, /// Set transfer rate/width negotiation settings XPT_SET_TRAN_SETTINGS = 0x16, /// Calculate the geometry parameters for a device give the sector size and volume size. XPT_CALC_GEOMETRY = 0x17, /// Execute the requested ATA I/O operation XPT_ATA_IO = 0x18 | XPT_FC_DEV_QUEUED, /// Compat only XPT_GET_SIM_KNOB_OLD = 0x18, /// Set SIM specific knob values. XPT_SET_SIM_KNOB = 0x19, /// Get SIM specific knob values. XPT_GET_SIM_KNOB = 0x1a, /// Serial Management Protocol XPT_SMP_IO = 0x1b | XPT_FC_DEV_QUEUED, /// Scan Target XPT_SCAN_TGT = 0x1E | XPT_FC_QUEUED | XPT_FC_USER_CCB | XPT_FC_XPT_ONLY, // HBA engine commands 0x20->0x2F /// HBA engine feature inquiry XPT_ENG_INQ = 0x20 | XPT_FC_XPT_ONLY, /// HBA execute engine request XPT_ENG_EXEC = 0x21 | XPT_FC_DEV_QUEUED, // Target mode commands: 0x30->0x3F /// Enable LUN as a target XPT_EN_LUN = 0x30, /// Execute target I/O request XPT_TARGET_IO = 0x31 | XPT_FC_DEV_QUEUED, /// Accept Host Target Mode CDB XPT_ACCEPT_TARGET_IO = 0x32 | XPT_FC_QUEUED | XPT_FC_USER_CCB, /// Continue Host Target I/O Connection XPT_CONT_TARGET_IO = 0x33 | XPT_FC_DEV_QUEUED, /// Notify Host Target driver of event (obsolete) XPT_IMMED_NOTIFY = 0x34 | XPT_FC_QUEUED | XPT_FC_USER_CCB, /// Acknowledgement of event (obsolete) XPT_NOTIFY_ACK = 0x35, /// Notify Host Target driver of event XPT_IMMEDIATE_NOTIFY = 0x36 | XPT_FC_QUEUED | XPT_FC_USER_CCB, /// Acknowledgement of event XPT_NOTIFY_ACKNOWLEDGE = 0x37 | XPT_FC_QUEUED | XPT_FC_USER_CCB, /// Vendor Unique codes: 0x80->0x8F XPT_VUNIQUE = 0x80 } enum ccb_dev_match_status { CAM_DEV_MATCH_LAST, CAM_DEV_MATCH_MORE, CAM_DEV_MATCH_LIST_CHANGED, CAM_DEV_MATCH_SIZE_ERROR, CAM_DEV_MATCH_ERROR } enum dev_match_type { DEV_MATCH_PERIPH = 0, DEV_MATCH_DEVICE, DEV_MATCH_BUS } [Flags] enum periph_pattern_flags { PERIPH_MATCH_NONE = 0x000, PERIPH_MATCH_PATH = 0x001, PERIPH_MATCH_TARGET = 0x002, PERIPH_MATCH_LUN = 0x004, PERIPH_MATCH_NAME = 0x008, PERIPH_MATCH_UNIT = 0x010, // PERIPH_MATCH_ANY = 0x01f } [Flags] enum dev_pattern_flags { DEV_MATCH_NONE = 0x000, DEV_MATCH_PATH = 0x001, DEV_MATCH_TARGET = 0x002, DEV_MATCH_LUN = 0x004, DEV_MATCH_INQUIRY = 0x008, DEV_MATCH_DEVID = 0x010, // DEV_MATCH_ANY = 0x00f } [Flags] enum bus_pattern_flags { BUS_MATCH_NONE = 0x000, BUS_MATCH_PATH = 0x001, BUS_MATCH_NAME = 0x002, BUS_MATCH_UNIT = 0x004, BUS_MATCH_BUS_ID = 0x008, // BUS_MATCH_ANY = 0x00f } [Flags] enum dev_result_flags { DEV_RESULT_NOFLAG = 0x00, DEV_RESULT_UNCONFIGURED = 0x01 } enum cam_proto { PROTO_UNKNOWN, PROTO_UNSPECIFIED, /// /// Small Computer System Interface /// PROTO_SCSI, /// /// AT Attachment /// PROTO_ATA, /// /// AT Attachment Packetized Interface /// PROTO_ATAPI, /// /// SATA Port Multiplier /// PROTO_SATAPM, /// /// SATA Enclosure Management Bridge /// PROTO_SEMB, /// /// NVMe /// PROTO_NVME, /// /// MMC, SD, SDIO /// PROTO_MMCSD, } [Flags] enum mmc_card_features { 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, } enum cam_generations : uint { CAM_BUS_GENERATION = 0x00, CAM_TARGET_GENERATION = 0x01, CAM_DEV_GENERATION = 0x02, CAM_PERIPH_GENERATION = 0x03, } [Flags] enum dev_pos_type { 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, // CAM_DEV_POS_TYPEMASK = 0xf00, CAM_DEV_POS_EDT = 0x100, CAM_DEV_POS_PDRV = 0x200 } enum FreebsdIoctl : uint { CAMIOCOMMAND = 0xC4D81802, } [Flags] enum ccb_flags : uint { /// /// The CDB field is a pointer /// CAM_CDB_POINTER = 0x00000001, /// /// SIM queue actions are enabled /// CAM_QUEUE_ENABLE = 0x00000002, /// /// CCB contains a linked CDB /// CAM_CDB_LINKED = 0x00000004, /// /// Perform transport negotiation with this command. /// CAM_NEGOTIATE = 0x00000008, /// /// Data type with physical addrs /// CAM_DATA_ISPHYS = 0x00000010, /// /// Disable autosense feature /// CAM_DIS_AUTOSENSE = 0x00000020, /// /// Data direction (00:IN/OUT) /// CAM_DIR_BOTH = 0x00000000, /// /// Data direction (01:DATA IN) /// CAM_DIR_IN = 0x00000040, /// /// Data direction (10:DATA OUT) /// CAM_DIR_OUT = 0x00000080, /// /// Data direction (11:no data) /// CAM_DIR_NONE = 0x000000C0, /// /// Data type (000:Virtual) /// CAM_DATA_VADDR = 0x00000000, /// /// Data type (001:Physical) /// CAM_DATA_PADDR = 0x00000010, /// /// Data type (010:sglist) /// CAM_DATA_SG = 0x00040000, /// /// Data type (011:sglist phys) /// CAM_DATA_SG_PADDR = 0x00040010, /// /// Data type (100:bio) /// CAM_DATA_BIO = 0x00200000, /// /// Use Soft reset alternative /// CAM_SOFT_RST_OP = 0x00000100, /// /// Flush resid bytes on complete /// CAM_ENG_SYNC = 0x00000200, /// /// Disable DEV Q freezing /// CAM_DEV_QFRZDIS = 0x00000400, /// /// Freeze DEV Q on execution /// CAM_DEV_QFREEZE = 0x00000800, /// /// Command takes a lot of power /// CAM_HIGH_POWER = 0x00001000, /// /// Sense data is a pointer /// CAM_SENSE_PTR = 0x00002000, /// /// Sense pointer is physical addr /// CAM_SENSE_PHYS = 0x00004000, /// /// Use the tag action in this ccb /// CAM_TAG_ACTION_VALID = 0x00008000, /// /// Pass driver does err. recovery /// CAM_PASS_ERR_RECOVER = 0x00010000, /// /// Disable disconnect /// CAM_DIS_DISCONNECT = 0x00020000, /// /// Message buffer ptr is physical /// CAM_MSG_BUF_PHYS = 0x00080000, /// /// Autosense data ptr is physical /// CAM_SNS_BUF_PHYS = 0x00100000, /// /// CDB poiner is physical /// CAM_CDB_PHYS = 0x00400000, /// /// SG list is for the HBA engine /// CAM_ENG_SGLIST = 0x00800000, /* Phase cognizant mode flags */ /// /// Disable autosave/restore ptrs /// CAM_DIS_AUTOSRP = 0x01000000, /// /// Disable auto disconnect /// CAM_DIS_AUTODISC = 0x02000000, /// /// Target CCB available /// CAM_TGT_CCB_AVAIL = 0x04000000, /// /// The SIM runs in phase mode /// CAM_TGT_PHASE_MODE = 0x08000000, /// /// Message buffer valid /// CAM_MSGB_VALID = 0x10000000, /// /// Status buffer valid /// CAM_STATUS_VALID = 0x20000000, /// /// Data buffer valid /// CAM_DATAB_VALID = 0x40000000, /* Host target Mode flags */ /// /// Send sense data with status /// CAM_SEND_SENSE = 0x08000000, /// /// Terminate I/O Message sup. /// CAM_TERM_IO = 0x10000000, /// /// Disconnects are mandatory /// CAM_DISCONNECT = 0x20000000, /// /// Send status after data phase /// CAM_SEND_STATUS = 0x40000000, /// /// Call callback without lock. /// CAM_UNLOCKED = 0x80000000 } enum cam_status : uint { /// CCB request is in progress CAM_REQ_INPROG = 0x00, /// CCB request completed without error CAM_REQ_CMP = 0x01, /// CCB request aborted by the host CAM_REQ_ABORTED = 0x02, /// Unable to abort CCB request CAM_UA_ABORT = 0x03, /// CCB request completed with an error CAM_REQ_CMP_ERR = 0x04, /// CAM subsystem is busy CAM_BUSY = 0x05, /// CCB request was invalid CAM_REQ_INVALID = 0x06, /// Supplied Path ID is invalid CAM_PATH_INVALID = 0x07, /// SCSI Device Not Installed/there CAM_DEV_NOT_THERE = 0x08, /// Unable to terminate I/O CCB request CAM_UA_TERMIO = 0x09, /// Target Selection Timeout CAM_SEL_TIMEOUT = 0x0a, /// Command timeout CAM_CMD_TIMEOUT = 0x0b, /// SCSI error, look at error code in CCB CAM_SCSI_STATUS_ERROR = 0x0c, /// Message Reject Received CAM_MSG_REJECT_REC = 0x0d, /// SCSI Bus Reset Sent/Received CAM_SCSI_BUS_RESET = 0x0e, /// Uncorrectable parity error occurred CAM_UNCOR_PARITY = 0x0f, /// Autosense: request sense cmd fail CAM_AUTOSENSE_FAIL = 0x10, /// No HBA Detected error CAM_NO_HBA = 0x11, /// Data Overrun error CAM_DATA_RUN_ERR = 0x12, /// Unexpected Bus Free CAM_UNEXP_BUSFREE = 0x13, /// Target Bus Phase Sequence Failure CAM_SEQUENCE_FAIL = 0x14, /// CCB length supplied is inadequate CAM_CCB_LEN_ERR = 0x15, /// Unable to provide requested capability CAM_PROVIDE_FAIL = 0x16, /// A SCSI BDR msg was sent to target CAM_BDR_SENT = 0x17, /// CCB request terminated by the host CAM_REQ_TERMIO = 0x18, /// Unrecoverable Host Bus Adapter Error CAM_UNREC_HBA_ERROR = 0x19, /// Request was too large for this host CAM_REQ_TOO_BIG = 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. CAM_REQUEUE_REQ = 0x1b, /// ATA error, look at error code in CCB CAM_ATA_STATUS_ERROR = 0x1c, /// Initiator/Target Nexus lost. CAM_SCSI_IT_NEXUS_LOST = 0x1d, /// SMP error, look at error code in CCB CAM_SMP_STATUS_ERROR = 0x1e, /// Command completed without error but exceeded the soft timeout threshold. CAM_REQ_SOFTTIMEOUT = 0x1f, /* * 0x20 - 0x32 are unassigned */ /// Initiator Detected Error CAM_IDE = 0x33, /// Resource Unavailable CAM_RESRC_UNAVAIL = 0x34, /// Unacknowledged Event by Host CAM_UNACKED_EVENT = 0x35, /// Message Received in Host Target Mode CAM_MESSAGE_RECV = 0x36, /// Invalid CDB received in Host Target Mode CAM_INVALID_CDB = 0x37, /// Lun supplied is invalid CAM_LUN_INVALID = 0x38, /// Target ID supplied is invalid CAM_TID_INVALID = 0x39, /// The requested function is not available CAM_FUNC_NOTAVAIL = 0x3a, /// Nexus is not established CAM_NO_NEXUS = 0x3b, /// The initiator ID is invalid CAM_IID_INVALID = 0x3c, /// The SCSI CDB has been received CAM_CDB_RECVD = 0x3d, /// The LUN is already enabled for target mode CAM_LUN_ALRDY_ENA = 0x3e, /// SCSI Bus Busy CAM_SCSI_BUSY = 0x3f, /* * Flags */ /// The DEV queue is frozen w/this err CAM_DEV_QFRZN = 0x40, /// Autosense data valid for target CAM_AUTOSNS_VALID = 0x80, /// SIM ready to take more commands CAM_RELEASE_SIMQ = 0x100, /// SIM has this command in its queue CAM_SIM_QUEUED = 0x200, /// Quality of service data is valid CAM_QOS_VALID = 0x400, /// Mask bits for just the status # CAM_STATUS_MASK = 0x3F, /* * Target Specific Adjunct Status */ /// sent sense with status CAM_SENT_SENSE = 0x40000000 } }