📄 scsi.h
字号:
#define SCSI_CORRECTABLE_ERROR 0x18#define SCSI_FILE_MARK 0x1c#define SCSI_INVALID_COMMAND 0x20#define SCSI_UNIT_ATTENTION 0x30#define SCSI_END_OF_MEDIA 0x34/* * The standard "extended" sense data returned by SCSI devices. This * has an error field of 0x70, for a "class 7" error. */typedef struct ScsiClass7Sense {#if BYTE_ORDER == BIG_ENDIAN u_char valid :1; /* Sense data is valid */ u_char error7 :7; /* == 0x70 */ u_char pad1; /* Also "segment number" for copy */ u_char fileMark :1; /* File mark on device */ u_char endOfMedia :1; /* End of media reached */ u_char badBlockLen :1; /* Block length mis-match (Exabyte) */ u_char pad2 :1; u_char key :4; /* Sense keys defined below */ u_char info1; /* Information byte 1 */ u_char info2; /* Information byte 2 */ u_char info3; /* Information byte 3 */ u_char info4; /* Information byte 4 */ u_char length; /* Number of additional info bytes */#else u_char error7 :7; /* == 0x70 */ u_char valid :1; /* Sense data is valid */ u_char pad1; /* Also "segment number" for copy */ u_char key :4; /* Sense keys defined below */ u_char pad2 :1; u_char badBlockLen :1; /* Block length mis-match (Exabyte) */ u_char endOfMedia :1; /* End of media reached */ u_char fileMark :1; /* File mark on device */ u_char info1; /* Information byte 1 */ u_char info2; /* Information byte 2 */ u_char info3; /* Information byte 3 */ u_char info4; /* Information byte 4 */ u_char length; /* Number of additional info bytes */#endif} ScsiClass7Sense; /* 8 Bytes *//* * Key values for standardized sense class 7. */#define SCSI_CLASS7_NO_SENSE 0#define SCSI_CLASS7_RECOVERABLE 1#define SCSI_CLASS7_NOT_READY 2#define SCSI_CLASS7_MEDIA_ERROR 3#define SCSI_CLASS7_HARDWARE_ERROR 4#define SCSI_CLASS7_ILLEGAL_REQUEST 5/* * These seem to have different meanings to different vendors.... */#define SCSI_CLASS7_MEDIA_CHANGE 6#define SCSI_CLASS7_UNIT_ATTN 6#define SCSI_CLASS7_WRITE_PROTECT 7#define SCSI_CLASS7_BLANK_CHECK 8#define SCSI_CLASS7_VENDOR 9#define SCSI_CLASS7_POWER_UP_FAILURE 10#define SCSI_CLASS7_ABORT 11#define SCSI_CLASS7_EQUAL 12#define SCSI_CLASS7_OVERFLOW 13#define SCSI_CLASS7_RESERVED_14 14#define SCSI_CLASS7_RESERVED_15 15/* * Data return by the SCSI inquiry command. */typedef struct ScsiInquiryData {#if BYTE_ORDER == BIG_ENDIAN u_char type; /* Peripheral Device type. See below. */ u_char rmb:1; /* Removable Medium bit. */ u_char qualifier:7; /* Device type qualifier. */ u_char version; /* Version info. */ u_char reserved:4; /* reserved. */ u_char format:4; /* Response format. */ u_char length; /* length of data returned. */ u_char reserved2[2]; /* Reserved */ u_char flags; /* SCSI II flags (see below) */ u_char vendorID[8]; /* Vendor ID (ASCII) */ u_char productID[16]; /* Product ID (ASCII) */ u_char revLevel[4]; /* Revision level (ASCII) */ u_char revData[8]; /* Revision data (ASCII) */#else u_char type; /* Peripheral Device type. See below. */ u_char qualifier:7; /* Device type qualifier. */ u_char rmb:1; /* Removable Medium bit. */ u_char version; /* Version info. */ u_char format:4; /* Response format. */ u_char reserved:4; /* reserved. */ u_char length; /* length of data returned. */ u_char reserved2[2]; /* Reserved */ u_char flags; /* SCSI II flags (see below) */ u_char vendorID[8]; /* Vendor ID (ASCII) */ u_char productID[16]; /* Product ID (ASCII) */ u_char revLevel[4]; /* Revision level (ASCII) */ u_char revData[8]; /* Revision data (ASCII) */#endif} ScsiInquiryData;/* * The SCSI Peripheral type ID codes as return by the SCSI_INQUIRY command. * * SCSI_DISK_TYPE - Direct Access Device. * SCSI_TAPE_TYPE - Sequential Access Device. * SCSI_PRINTER_TYPE - Printer Device. * SCSI_HOST_TYPE - Processor Device. * SCSI_WORM_TYPE - Write-Once Read-Multiple Device. * SCSI_ROM_TYPE - Read-Only Direct Access Device. * SCSI_SCANNER_TYPE - Scanner device. * SCSI_OPTICAL_MEM_TYPE - Optical memory device. * SCSI_MEDIUM_CHANGER_TYPE - Medium changer device. * SCSI_COMMUNICATIONS_TYPE - Communications device. * SCSI_NODEVICE_TYPE - Logical Unit not present or implemented. * * Note that codes 0xa-0x7e are reserved and 0x80-0xff are vendor unique. */#define SCSI_DISK_TYPE 0#define SCSI_TAPE_TYPE 1#define SCSI_PRINTER_TYPE 2#define SCSI_HOST_TYPE 3#define SCSI_WORM_TYPE 4#define SCSI_ROM_TYPE 5#define SCSI_SCANNER_TYPE 6#define SCSI_OPTICAL_MEM_TYPE 7#define SCSI_MEDIUM_CHANGER_TYPE 8#define SCSI_COMMUNICATIONS_TYPE 9#define SCSI_NODEVICE_TYPE 0x7f/* * The SCSI I & II inquiry flags. * * SCSI_REL_ADR - Relative addressing supported. * SCSI_WIDE_32 - 32 bit wide SCSI bus transfers supported. * SCSI_WIDE_16 - 16 bit wide SCSI bus transfers supported. * SCSI_SYNC - Synchronous data transfers supported. * SCSI_LINKED - Linked commands supported. * SCSI_CMD_QUEUE - Tagged command queuing supported. * SCSI_SOFT_RESET - Soft RESET alternative suported. */#define SCSI_REL_ADR 0x80#define SCSI_WIDE_32 0x40#define SCSI_WIDE_16 0x20#define SCSI_SYNC 0x10#define SCSI_LINKED 0x08#define SCSI_CMD_QUEUE 0x02#define SCSI_SOFT_RESET 0x01/* * Standard header for SCSI_MODE_SENSE and SCSI_MODE_SELECT commands for tapes. */typedef struct ScsiTapeModeSelectHdr { u_char len; /* length */ u_char media; /* media type */#if BYTE_ORDER == BIG_ENDIAN u_char writeprot:1; /* Write protected media */ u_char bufferedMode:3; /* Type of buffer to be done. */ u_char speed:4; /* Drive speed. */#else u_char speed:4; /* Drive speed. */ u_char bufferedMode:3; /* Type of buffer to be done. */ u_char writeprot:1; /* Write protected media */#endif u_char length; /* Block descriptor length. */ u_char density; /* tape density code */ u_char blocks_2; /* number of blocks (MSB) */ u_char blocks_1; /* number of blocks */ u_char blocks_0; /* number of blocks (LSB) */ u_char reserved; /* */ u_char block_size2; /* Tape block size (MSB) */ u_char block_size1; /* Tape block size */ u_char block_size0; /* Tape block size (LSB) */ u_char vendor[6]; /* vendor specific data */} ScsiTapeModeSelectHdr;/* * Definitions of SCSI messages. * * SCSI_COMMAND_COMPLETE - After a command has completed, successfully * or not, this is returned to the host from the target. * * SCSI_EXTENDED_MSG - Indicates that a multi-byte message is being sent. * * The following messages are used with connect/disconnect: * SCSI_SAVE_DATA_POINTER - Sent from target to host to request saving * of current DMA address and count. Indicates a pending dis-connect. * SCSI_RESTORE_POINTER - Sent from the target to the host to request * restoring pointers saved before a disconnect * SCSI_DISCONNECT - Sent from the target to the host to disconnect. * SCSI_ABORT - Sent from the host to the target to abort current request. * SCSI_MESSAGE_REJECT - Indicates receipt, by either host or target, of * an unimplemented message. * SCSI_NO_OP - Sent from host to target if it has no real message to send. * SCSI_MESSAGE_PARITY_ERROR - Sent from host to target on message parity error * SCSI_BUS_RESET - Sent from host to target to reset all current I/O * * SCSI_IDENTIFY - The low order two bits of this message type indicate * the Logical Unit of the Target which is requesting a reconnect. * SCSI_DIS_REC_IDENTIFY - Sent from the host to a target to indicate * is supports connect/dis-connect * */#define SCSI_COMMAND_COMPLETE 0x00#define SCSI_EXTENDED_MSG 0x01#define SCSI_SAVE_DATA_POINTER 0x02#define SCSI_RESTORE_POINTERS 0x03#define SCSI_DISCONNECT 0x04#define SCSI_ABORT 0x06#define SCSI_MESSAGE_REJECT 0x07#define SCSI_NO_OP 0x08#define SCSI_MESSAGE_PARITY_ERROR 0x09#define SCSI_LINKED_CMD_COMPLETE 0x0A#define SCSI_LINKED_FLAGED_CMD_COMPLETE 0x0B#define SCSI_BUS_RESET 0x0C#define SCSI_IDENTIFY 0x80#define SCSI_DIS_REC_IDENTIFY 0xc0/* * Extended message types (2nd byte of SCSI_EXTENDED_MSG). */#define SCSI_MODIFY_DATA_PTR 0x00#define SCSI_SYNCHRONOUS_XFER 0x01#define SCSI_EXTENDED_IDENTIFY 0x02 /* only in SCSI I */#define SCSI_WIDE_XFER 0x03/* * Driver ioctl's for various scsi operations. */#ifndef _IOCTL_#include <sys/ioctl.h>#endif/* * Control for SCSI "format" mode. * * "Format" mode allows a privileged process to issue direct SCSI * commands to a drive (it is intended primarily to allow on-line * formatting). SDIOCSFORMAT with a non-zero arg will put the drive * into format mode; a zero arg will take it out. When in format * mode, only the process that issued the SDIOCFORMAT can read or * write the drive. * * In format mode, process is expected to * - do SDIOCSCSICOMMAND to supply cdb for next SCSI op * - do read or write as appropriate for cdb * - if i/o error, optionally do SDIOCSENSE to get completion * status and sense data from last scsi operation. */struct scsi_fmt_cdb { int len; /* cdb length (in bytes) */ u_char cdb[28]; /* cdb to use on next read/write */};struct scsi_fmt_sense { u_int status; /* completion status of last op */ u_char sense[32]; /* sense data (if any) from last op */};#define SDIOCSFORMAT _IOW('S', 0x1, int)#define SDIOCGFORMAT _IOR('S', 0x2, int)#define SDIOCSCSICOMMAND _IOW('S', 0x3, struct scsi_fmt_cdb)#define SDIOCSENSE _IOR('S', 0x4, struct scsi_fmt_sense)#ifdef KERNEL/* * Routines. */extern void scsiGroup0Cmd();extern void scsiGroup1Cmd();#endif /* KERNEL */#endif /* _SCSI_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -