The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/scsipi/scsipi_all.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: scsipi_all.h,v 1.25 2003/10/16 17:34:43 mycroft Exp $  */
    2 
    3 /*
    4  * SCSI and SCSI-like general interface description
    5  */
    6 
    7 /*
    8  * Largely written by Julian Elischer (julian@tfs.com)
    9  * for TRW Financial Systems.
   10  *
   11  * TRW Financial Systems, in accordance with their agreement with Carnegie
   12  * Mellon University, makes this software available to CMU to distribute
   13  * or use in any manner that they see fit as long as this message is kept with
   14  * the software. For this reason TFS also grants any other persons or
   15  * organisations permission to use or modify this software.
   16  *
   17  * TFS supplies this software to be publicly redistributed
   18  * on the understanding that TFS is not responsible for the correct
   19  * functioning of this software in any circumstances.
   20  *
   21  * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
   22  */
   23 
   24 #ifndef _DEV_SCSIPI_SCSIPI_ALL_H_
   25 #define _DEV_SCSIPI_SCSIPI_ALL_H_
   26 
   27 /*
   28  * SCSI-like command format and opcode
   29  */
   30 
   31 /*
   32  * Some basic, common SCSI command group definitions.
   33  */
   34 
   35 #define CDB_GROUPID(cmd)        ((cmd >> 5) & 0x7)
   36 #define CDB_GROUPID_0   0
   37 #define CDB_GROUPID_1   1
   38 #define CDB_GROUPID_2   2
   39 #define CDB_GROUPID_3   3
   40 #define CDB_GROUPID_4   4
   41 #define CDB_GROUPID_5   5
   42 #define CDB_GROUPID_6   6
   43 #define CDB_GROUPID_7   7
   44 
   45 #define CDB_GROUP0      6       /*  6-byte cdb's */
   46 #define CDB_GROUP1      10      /* 10-byte cdb's */
   47 #define CDB_GROUP2      10      /* 10-byte cdb's */
   48 #define CDB_GROUP3      0       /* reserved */
   49 #define CDB_GROUP4      16      /* 16-byte cdb's */
   50 #define CDB_GROUP5      12      /* 12-byte cdb's */
   51 #define CDB_GROUP6      0       /* vendor specific */
   52 #define CDB_GROUP7      0       /* vendor specific */
   53 
   54 /*
   55  * Some basic, common SCSI commands
   56  */
   57 #define TEST_UNIT_READY         0x00
   58 struct scsipi_test_unit_ready {
   59         u_int8_t opcode;
   60         u_int8_t byte2;
   61         u_int8_t unused[3];
   62         u_int8_t control;
   63 };
   64 
   65 #define REQUEST_SENSE           0x03
   66 struct scsipi_sense {
   67         u_int8_t opcode;
   68         u_int8_t byte2;
   69         u_int8_t unused[2];
   70         u_int8_t length;
   71         u_int8_t control;
   72 };
   73 
   74 #define MODE_SENSE              0x1a
   75 struct scsipi_mode_sense {
   76         u_int8_t opcode;
   77         u_int8_t byte2;
   78 #define SMS_DBD                         0x08 /* disable block descriptors */
   79         u_int8_t page;
   80 #define SMS_PAGE_CODE                   0x3F
   81 #define SMS_PAGE_CTRL                   0xC0
   82 #define SMS_PAGE_CTRL_CURRENT           0x00
   83 #define SMS_PAGE_CTRL_CHANGEABLE        0x40
   84 #define SMS_PAGE_CTRL_DEFAULT           0x80
   85 #define SMS_PAGE_CTRL_SAVED             0xC0
   86         u_int8_t unused;
   87         u_int8_t length;
   88         u_int8_t control;
   89 } __attribute__((packed));
   90 
   91 #define MODE_SENSE_BIG          0x5A
   92 struct scsipi_mode_sense_big {
   93         u_int8_t opcode;
   94         u_int8_t byte2;         /* same bits as small version */
   95         u_int8_t page;          /* same bits as small version */
   96         u_int8_t unused[4];
   97         u_int8_t length[2];
   98         u_int8_t control;
   99 } __attribute__((packed));
  100 
  101 #define MODE_SELECT             0x15
  102 struct scsipi_mode_select {
  103         u_int8_t opcode;
  104         u_int8_t byte2;
  105 #define SMS_SP  0x01            /* save page */
  106 #define SMS_PF  0x10            /* page format (0 = SCSI-1, 1 = SCSI-2) */
  107         u_int8_t unused[2];
  108         u_int8_t length;
  109         u_int8_t control;
  110 } __attribute__((packed));
  111 
  112 #define MODE_SELECT_BIG         0x55
  113 struct scsipi_mode_select_big {
  114         u_int8_t opcode;
  115         u_int8_t byte2;         /* same bits as small version */
  116         u_int8_t unused[5];
  117         u_int8_t length[2];
  118         u_int8_t control;
  119 } __attribute__((packed));
  120 
  121 #define INQUIRY                 0x12
  122 struct scsipi_inquiry {
  123         u_int8_t opcode;
  124         u_int8_t byte2;
  125         u_int8_t unused[2];
  126         u_int8_t length;
  127         u_int8_t control;
  128 } __attribute__((packed));
  129 
  130 #define START_STOP              0x1b
  131 struct scsipi_start_stop {
  132         u_int8_t opcode;
  133         u_int8_t byte2;
  134         u_int8_t unused[2];
  135         u_int8_t how;
  136 #define SSS_STOP                0x00
  137 #define SSS_START               0x01
  138 #define SSS_LOEJ                0x02
  139         u_int8_t control;
  140 };
  141 
  142 #define PREVENT_ALLOW           0x1e
  143 struct scsipi_prevent {
  144         u_int8_t opcode;
  145         u_int8_t byte2;
  146         u_int8_t unused[2];
  147         u_int8_t how;
  148         u_int8_t control;
  149 } __attribute__((packed));
  150 #define PR_PREVENT 0x01
  151 #define PR_ALLOW   0x00
  152 
  153 /*
  154  * inquiry and sense data format
  155  */
  156 
  157 struct scsipi_sense_data {
  158 /* 1*/  u_int8_t error_code;
  159 #define SSD_ERRCODE     0x7F
  160 #define SSD_ERRCODE_VALID 0x80
  161 /* 2*/  u_int8_t segment;
  162 /* 3*/  u_int8_t flags;
  163 #define SSD_KEY         0x0F
  164 #define SSD_ILI         0x20
  165 #define SSD_EOM         0x40
  166 #define SSD_FILEMARK    0x80
  167 /* 7*/  u_int8_t info[4];
  168 /* 8*/  u_int8_t extra_len;
  169 /*12*/  u_int8_t cmd_spec_info[4];
  170 /*13*/  u_int8_t add_sense_code;
  171 /*14*/  u_int8_t add_sense_code_qual;
  172 /*15*/  u_int8_t fru;
  173 /*16*/  u_int8_t sense_key_spec_1;
  174 #define SSD_SCS_VALID   0x80
  175 /*17*/  u_int8_t sense_key_spec_2;
  176 /*18*/  u_int8_t sense_key_spec_3;
  177 /*32*/  u_int8_t extra_bytes[14];
  178 } __attribute__((packed));
  179 
  180 #define SKEY_NO_SENSE           0x00
  181 #define SKEY_RECOVERED_ERROR    0x01
  182 #define SKEY_NOT_READY          0x02
  183 #define SKEY_MEDIUM_ERROR       0x03
  184 #define SKEY_HARDWARE_ERROR     0x04
  185 #define SKEY_ILLEGAL_REQUEST    0x05
  186 #define SKEY_UNIT_ATTENTION     0x06
  187 #define SKEY_WRITE_PROTECT      0x07
  188 #define SKEY_BLANK_CHECK        0x08
  189 #define SKEY_VENDOR_UNIQUE      0x09
  190 #define SKEY_COPY_ABORTED       0x0A
  191 #define SKEY_ABORTED_COMMAND    0x0B
  192 #define SKEY_EQUAL              0x0C
  193 #define SKEY_VOLUME_OVERFLOW    0x0D
  194 #define SKEY_MISCOMPARE         0x0E
  195 #define SKEY_RESERVED           0x0F
  196 
  197 /*
  198  * Sense bytes described by the extra_len tag start at cmd_spec_info,
  199  * and can only continue up to the end of the structure we've defined
  200  * (which is too short for some cases).
  201  */
  202 #define ADD_BYTES_LIM(sp)       \
  203         ((((int)(sp)->extra_len) < (int) sizeof(struct scsipi_sense_data) - 8)? \
  204         ((sp)->extra_len) : (sizeof (struct scsipi_sense_data) - 8))
  205 
  206 
  207 struct scsipi_sense_data_unextended {
  208 /* 1*/  u_int8_t error_code; 
  209 /* 4*/  u_int8_t block[3];
  210 } __attribute__((packed)); 
  211 
  212 #define T_REMOV         1       /* device is removable */
  213 #define T_FIXED         0       /* device is not removable */
  214 
  215 /*
  216  * According to SPC-2r16, in order to know if a U3W device support PPR,
  217  * Inquiry Data structure should be at least 57 Bytes
  218  */
  219 
  220 struct scsipi_inquiry_data {
  221 /* 1*/  u_int8_t device;
  222 #define SID_TYPE                0x1f    /* device type mask */
  223 #define SID_QUAL                0xe0    /* device qualifier mask */
  224 #define SID_QUAL_LU_PRESENT     0x00    /* logical unit present */
  225 #define SID_QUAL_LU_NOTPRESENT  0x20    /* logical unit not present */
  226 #define SID_QUAL_reserved       0x40
  227 #define SID_QUAL_LU_NOT_SUPP    0x60    /* logical unit not supported */
  228 
  229 #define T_DIRECT                0x00    /* direct access device */
  230 #define T_SEQUENTIAL            0x01    /* sequential access device */
  231 #define T_PRINTER               0x02    /* printer device */
  232 #define T_PROCESSOR             0x03    /* processor device */
  233 #define T_WORM                  0x04    /* write once, read many device */
  234 #define T_CDROM                 0x05    /* cd-rom device */
  235 #define T_SCANNER               0x06    /* scanner device */
  236 #define T_OPTICAL               0x07    /* optical memory device */
  237 #define T_CHANGER               0x08    /* medium changer device */
  238 #define T_COMM                  0x09    /* communication device */
  239 #define T_IT8_1                 0x0a    /* Defined by ASC IT8... */
  240 #define T_IT8_2                 0x0b    /* ...(Graphic arts pre-press devices) */
  241 #define T_STORARRAY             0x0c    /* storage array device */
  242 #define T_ENCLOSURE             0x0d    /* enclosure services device */
  243 #define T_SIMPLE_DIRECT         0x0E    /* Simplified direct-access device */
  244 #define T_OPTIC_CARD_RW         0x0F    /* Optical card reader/writer device */
  245 #define T_OBJECT_STORED         0x11    /* Object-based Storage Device */
  246 #define T_NODEVICE              0x1f
  247 
  248         u_int8_t dev_qual2;
  249 #define SID_QUAL2               0x7F
  250 #define SID_REMOVABLE           0x80
  251 
  252 /* 3*/  u_int8_t version;
  253 #define SID_ANSII       0x07
  254 #define SID_ECMA        0x38
  255 #define SID_ISO         0xC0
  256 
  257 /* 4*/  u_int8_t response_format;
  258 #define SID_RespDataFmt 0x0F
  259 #define SID_FORMAT_SCSI1        0x00    /* SCSI-1 format */
  260 #define SID_FORMAT_CCS          0x01    /* SCSI CCS format */
  261 #define SID_FORMAT_ISO          0x02    /* ISO format */
  262 
  263 /* 5*/  u_int8_t additional_length;     /* n-4 */
  264 /* 6*/  u_int8_t flags1;
  265 #define SID_SCC         0x80
  266 /* 7*/  u_int8_t flags2;
  267 #define SID_Addr16      0x01
  268 #define SID_MChngr      0x08
  269 #define SID_MultiPort   0x10
  270 #define SID_EncServ     0x40
  271 #define SID_BasQue      0x80
  272 /* 8*/  u_int8_t flags3;
  273 #define SID_SftRe       0x01
  274 #define SID_CmdQue      0x02
  275 #define SID_Linked      0x08
  276 #define SID_Sync        0x10
  277 #define SID_WBus16      0x20
  278 #define SID_WBus32      0x40
  279 #define SID_RelAdr      0x80
  280 /* 9*/  char    vendor[8];
  281 /*17*/  char    product[16];
  282 /*33*/  char    revision[4];
  283 #define SCSIPI_INQUIRY_LENGTH_SCSI2     36
  284 /*37*/  u_int8_t vendor_specific[20];
  285 /*57*/  u_int8_t flags4;
  286 #define        SID_IUS         0x01
  287 #define        SID_QAS         0x02
  288 #define        SID_Clocking    0x0C
  289 #define SID_CLOCKING_ST_ONLY  0x00
  290 #define SID_CLOCKING_DT_ONLY  0x04
  291 #define SID_CLOCKING_SD_DT    0x0C
  292 /*58*/  u_int8_t reserved;
  293 /*59*/  char    version_descriptor[8][2];
  294 #define SCSIPI_INQUIRY_LENGTH_SCSI3     74
  295 } __attribute__((packed)); /* 74 Bytes */
  296 
  297 /* Data structures for mode select/mode sense */
  298 struct scsipi_mode_header {
  299         u_int8_t data_length;   /* Sense data length */
  300         u_int8_t medium_type;
  301         u_int8_t dev_spec;
  302         u_int8_t blk_desc_len;  /* unused on ATAPI */
  303 } __attribute__((packed));
  304 
  305 struct scsipi_mode_header_big {
  306         u_int8_t data_length[2];        /* Sense data length */
  307         u_int8_t medium_type;
  308         u_int8_t dev_spec;
  309         u_int8_t unused[2];             /* unused on ATAPI */
  310         u_int8_t blk_desc_len[2];       /* unused on ATAPI */
  311 } __attribute__((packed));
  312 
  313 /*
  314  * This part is common to all mode pages.
  315  */
  316 struct scsipi_mode_page_header {
  317         u_int8_t pg_code;               /* page code */
  318 #define PGCODE_MASK     0x3f            /* page code mask */
  319 #define PGCODE_PS       0x80            /* page is savable */
  320         u_int8_t pg_length;             /* page length (not including hdr) */
  321 } __attribute__((__packed__));
  322 
  323 #endif /* _DEV_SCSIPI_SCSIPI_ALL_H_ */

Cache object: ff6db5e2adbf91ca6695f453d969e61e


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.