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/cam/scsi/scsi_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 /*-
    2  * Largely written by Julian Elischer (julian@tfs.com)
    3  * for TRW Financial Systems.
    4  *
    5  * TRW Financial Systems, in accordance with their agreement with Carnegie
    6  * Mellon University, makes this software available to CMU to distribute
    7  * or use in any manner that they see fit as long as this message is kept with
    8  * the software. For this reason TFS also grants any other persons or
    9  * organisations permission to use or modify this software.
   10  *
   11  * TFS supplies this software to be publicly redistributed
   12  * on the understanding that TFS is not responsible for the correct
   13  * functioning of this software in any circumstances.
   14  *
   15  * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
   16  *
   17  * $FreeBSD: releng/5.4/sys/cam/scsi/scsi_all.h 141016 2005-01-30 01:00:13Z imp $
   18  */
   19 
   20 /*
   21  * SCSI general  interface description
   22  */
   23 
   24 #ifndef _SCSI_SCSI_ALL_H
   25 #define _SCSI_SCSI_ALL_H 1
   26 
   27 #include <sys/cdefs.h>
   28 
   29 #ifdef _KERNEL
   30 /*
   31  * This is the number of seconds we wait for devices to settle after a SCSI
   32  * bus reset.
   33  */
   34 extern int scsi_delay;
   35 #endif /* _KERNEL */
   36 
   37 /*
   38  * SCSI command format
   39  */
   40 
   41 /*
   42  * Define dome bits that are in ALL (or a lot of) scsi commands
   43  */
   44 #define SCSI_CTL_LINK           0x01
   45 #define SCSI_CTL_FLAG           0x02
   46 #define SCSI_CTL_VENDOR         0xC0
   47 #define SCSI_CMD_LUN            0xA0    /* these two should not be needed */
   48 #define SCSI_CMD_LUN_SHIFT      5       /* LUN in the cmd is no longer SCSI */
   49 
   50 #define SCSI_MAX_CDBLEN         16      /* 
   51                                          * 16 byte commands are in the 
   52                                          * SCSI-3 spec 
   53                                          */
   54 #if defined(CAM_MAX_CDBLEN) && (CAM_MAX_CDBLEN < SCSI_MAX_CDBLEN)
   55 #error "CAM_MAX_CDBLEN cannot be less than SCSI_MAX_CDBLEN"
   56 #endif
   57 
   58 /* 6byte CDBs special case 0 length to be 256 */
   59 #define SCSI_CDB6_LEN(len)      ((len) == 0 ? 256 : len)
   60 
   61 /*
   62  * This type defines actions to be taken when a particular sense code is
   63  * received.  Right now, these flags are only defined to take up 16 bits,
   64  * but can be expanded in the future if necessary.
   65  */
   66 typedef enum {
   67         SS_NOP      = 0x000000, /* Do nothing */
   68         SS_RETRY    = 0x010000, /* Retry the command */
   69         SS_FAIL     = 0x020000, /* Bail out */
   70         SS_START    = 0x030000, /* Send a Start Unit command to the device,
   71                                  * then retry the original command.
   72                                  */
   73         SS_TUR      = 0x040000, /* Send a Test Unit Ready command to the
   74                                  * device, then retry the original command.
   75                                  */
   76         SS_REQSENSE = 0x050000, /* Send a RequestSense command to the
   77                                  * device, then retry the original command.
   78                                  */
   79         SS_MASK     = 0xff0000
   80 } scsi_sense_action;
   81 
   82 typedef enum {
   83         SSQ_NONE                = 0x0000,
   84         SSQ_DECREMENT_COUNT     = 0x0100,  /* Decrement the retry count */
   85         SSQ_MANY                = 0x0200,  /* send lots of recovery commands */
   86         SSQ_RANGE               = 0x0400,  /*
   87                                             * This table entry represents the
   88                                             * end of a range of ASCQs that
   89                                             * have identical error actions
   90                                             * and text.
   91                                             */
   92         SSQ_PRINT_SENSE         = 0x0800,
   93         SSQ_MASK                = 0xff00
   94 } scsi_sense_action_qualifier;
   95 
   96 /* Mask for error status values */
   97 #define SS_ERRMASK      0xff
   98 
   99 /* The default, retyable, error action */
  100 #define SS_RDEF         SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE|EIO
  101 
  102 /* The retyable, error action, with table specified error code */
  103 #define SS_RET          SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE
  104 
  105 /* Fatal error action, with table specified error code */
  106 #define SS_FATAL        SS_FAIL|SSQ_PRINT_SENSE
  107 
  108 struct scsi_generic
  109 {
  110         u_int8_t opcode;
  111         u_int8_t bytes[11];
  112 };
  113 
  114 struct scsi_request_sense
  115 {
  116         u_int8_t opcode;
  117         u_int8_t byte2;
  118         u_int8_t unused[2];
  119         u_int8_t length;
  120         u_int8_t control;
  121 };
  122 
  123 struct scsi_test_unit_ready
  124 {
  125         u_int8_t opcode;
  126         u_int8_t byte2;
  127         u_int8_t unused[3];
  128         u_int8_t control;
  129 };
  130 
  131 struct scsi_send_diag
  132 {
  133         u_int8_t opcode;
  134         u_int8_t byte2;
  135 #define SSD_UOL         0x01
  136 #define SSD_DOL         0x02
  137 #define SSD_SELFTEST    0x04
  138 #define SSD_PF          0x10
  139         u_int8_t unused[1];
  140         u_int8_t paramlen[2];
  141         u_int8_t control;
  142 };
  143 
  144 struct scsi_sense
  145 {
  146         u_int8_t opcode;
  147         u_int8_t byte2;
  148         u_int8_t unused[2];
  149         u_int8_t length;
  150         u_int8_t control;
  151 };
  152 
  153 struct scsi_inquiry
  154 {
  155         u_int8_t opcode;
  156         u_int8_t byte2;
  157 #define SI_EVPD 0x01
  158         u_int8_t page_code;
  159         u_int8_t reserved;
  160         u_int8_t length;
  161         u_int8_t control;
  162 };
  163 
  164 struct scsi_mode_sense_6
  165 {
  166         u_int8_t opcode;
  167         u_int8_t byte2;
  168 #define SMS_DBD                         0x08
  169         u_int8_t page;
  170 #define SMS_PAGE_CODE                   0x3F
  171 #define SMS_VENDOR_SPECIFIC_PAGE        0x00
  172 #define SMS_DISCONNECT_RECONNECT_PAGE   0x02
  173 #define SMS_PERIPHERAL_DEVICE_PAGE      0x09
  174 #define SMS_CONTROL_MODE_PAGE           0x0A
  175 #define SMS_ALL_PAGES_PAGE              0x3F
  176 #define SMS_PAGE_CTRL_MASK              0xC0
  177 #define SMS_PAGE_CTRL_CURRENT           0x00
  178 #define SMS_PAGE_CTRL_CHANGEABLE        0x40
  179 #define SMS_PAGE_CTRL_DEFAULT           0x80
  180 #define SMS_PAGE_CTRL_SAVED             0xC0
  181         u_int8_t unused;
  182         u_int8_t length;
  183         u_int8_t control;
  184 };
  185 
  186 struct scsi_mode_sense_10
  187 {
  188         u_int8_t opcode;
  189         u_int8_t byte2;         /* same bits as small version */
  190         u_int8_t page;          /* same bits as small version */
  191         u_int8_t unused[4];
  192         u_int8_t length[2];
  193         u_int8_t control;
  194 };
  195 
  196 struct scsi_mode_select_6
  197 {
  198         u_int8_t opcode;
  199         u_int8_t byte2;
  200 #define SMS_SP  0x01
  201 #define SMS_PF  0x10
  202         u_int8_t unused[2];
  203         u_int8_t length;
  204         u_int8_t control;
  205 };
  206 
  207 struct scsi_mode_select_10
  208 {
  209         u_int8_t opcode;
  210         u_int8_t byte2;         /* same bits as small version */
  211         u_int8_t unused[5];
  212         u_int8_t length[2];
  213         u_int8_t control;
  214 };
  215 
  216 /*
  217  * When sending a mode select to a tape drive, the medium type must be 0.
  218  */
  219 struct scsi_mode_hdr_6
  220 {
  221         u_int8_t datalen;
  222         u_int8_t medium_type;
  223         u_int8_t dev_specific;
  224         u_int8_t block_descr_len;
  225 };
  226 
  227 struct scsi_mode_hdr_10
  228 {
  229         u_int8_t datalen[2];
  230         u_int8_t medium_type;
  231         u_int8_t dev_specific;
  232         u_int8_t reserved[2];
  233         u_int8_t block_descr_len[2];
  234 };
  235 
  236 struct scsi_mode_block_descr
  237 {
  238         u_int8_t density_code;
  239         u_int8_t num_blocks[3];
  240         u_int8_t reserved;
  241         u_int8_t block_len[3];
  242 };
  243 
  244 struct scsi_log_sense
  245 {
  246         u_int8_t opcode;
  247         u_int8_t byte2;
  248 #define SLS_SP                          0x01
  249 #define SLS_PPC                         0x02
  250         u_int8_t page;
  251 #define SLS_PAGE_CODE                   0x3F
  252 #define SLS_ALL_PAGES_PAGE              0x00
  253 #define SLS_OVERRUN_PAGE                0x01
  254 #define SLS_ERROR_WRITE_PAGE            0x02
  255 #define SLS_ERROR_READ_PAGE             0x03
  256 #define SLS_ERROR_READREVERSE_PAGE      0x04
  257 #define SLS_ERROR_VERIFY_PAGE           0x05
  258 #define SLS_ERROR_NONMEDIUM_PAGE        0x06
  259 #define SLS_ERROR_LASTN_PAGE            0x07
  260 #define SLS_PAGE_CTRL_MASK              0xC0
  261 #define SLS_PAGE_CTRL_THRESHOLD         0x00
  262 #define SLS_PAGE_CTRL_CUMULATIVE        0x40
  263 #define SLS_PAGE_CTRL_THRESH_DEFAULT    0x80
  264 #define SLS_PAGE_CTRL_CUMUL_DEFAULT     0xC0
  265         u_int8_t reserved[2];
  266         u_int8_t paramptr[2];
  267         u_int8_t length[2];
  268         u_int8_t control;
  269 };
  270 
  271 struct scsi_log_select
  272 {
  273         u_int8_t opcode;
  274         u_int8_t byte2;
  275 /*      SLS_SP                          0x01 */
  276 #define SLS_PCR                         0x02
  277         u_int8_t page;
  278 /*      SLS_PAGE_CTRL_MASK              0xC0 */
  279 /*      SLS_PAGE_CTRL_THRESHOLD         0x00 */
  280 /*      SLS_PAGE_CTRL_CUMULATIVE        0x40 */
  281 /*      SLS_PAGE_CTRL_THRESH_DEFAULT    0x80 */
  282 /*      SLS_PAGE_CTRL_CUMUL_DEFAULT     0xC0 */
  283         u_int8_t reserved[4];
  284         u_int8_t length[2];
  285         u_int8_t control;
  286 };
  287 
  288 struct scsi_log_header
  289 {
  290         u_int8_t page;
  291         u_int8_t reserved;
  292         u_int8_t datalen[2];
  293 };
  294 
  295 struct scsi_log_param_header {
  296         u_int8_t param_code[2];
  297         u_int8_t param_control;
  298 #define SLP_LP                          0x01
  299 #define SLP_LBIN                        0x02
  300 #define SLP_TMC_MASK                    0x0C
  301 #define SLP_TMC_ALWAYS                  0x00
  302 #define SLP_TMC_EQUAL                   0x04
  303 #define SLP_TMC_NOTEQUAL                0x08
  304 #define SLP_TMC_GREATER                 0x0C
  305 #define SLP_ETC                         0x10
  306 #define SLP_TSD                         0x20
  307 #define SLP_DS                          0x40
  308 #define SLP_DU                          0x80
  309         u_int8_t param_len;
  310 };
  311 
  312 struct scsi_control_page {
  313         u_int8_t page_code;
  314         u_int8_t page_length;
  315         u_int8_t rlec;
  316 #define SCB_RLEC                        0x01    /*Report Log Exception Cond*/
  317         u_int8_t queue_flags;
  318 #define SCP_QUEUE_ALG_MASK              0xF0
  319 #define SCP_QUEUE_ALG_RESTRICTED        0x00
  320 #define SCP_QUEUE_ALG_UNRESTRICTED      0x10
  321 #define SCP_QUEUE_ERR                   0x02    /*Queued I/O aborted for CACs*/
  322 #define SCP_QUEUE_DQUE                  0x01    /*Queued I/O disabled*/
  323         u_int8_t eca_and_aen;
  324 #define SCP_EECA                        0x80    /*Enable Extended CA*/
  325 #define SCP_RAENP                       0x04    /*Ready AEN Permission*/
  326 #define SCP_UAAENP                      0x02    /*UA AEN Permission*/
  327 #define SCP_EAENP                       0x01    /*Error AEN Permission*/
  328         u_int8_t reserved;
  329         u_int8_t aen_holdoff_period[2];
  330 };
  331 
  332 struct scsi_reserve
  333 {
  334         u_int8_t opcode;
  335         u_int8_t byte2;
  336         u_int8_t unused[2];
  337         u_int8_t length;
  338         u_int8_t control;
  339 };
  340 
  341 struct scsi_release
  342 {
  343         u_int8_t opcode;
  344         u_int8_t byte2;
  345         u_int8_t unused[2];
  346         u_int8_t length;
  347         u_int8_t control;
  348 };
  349 
  350 struct scsi_prevent
  351 {
  352         u_int8_t opcode;
  353         u_int8_t byte2;
  354         u_int8_t unused[2];
  355         u_int8_t how;
  356         u_int8_t control;
  357 };
  358 #define PR_PREVENT 0x01
  359 #define PR_ALLOW   0x00
  360 
  361 struct scsi_sync_cache
  362 {
  363         u_int8_t opcode;
  364         u_int8_t byte2;
  365         u_int8_t begin_lba[4];
  366         u_int8_t reserved;
  367         u_int8_t lb_count[2];
  368         u_int8_t control;       
  369 };
  370 
  371 
  372 struct scsi_changedef
  373 {
  374         u_int8_t opcode;
  375         u_int8_t byte2;
  376         u_int8_t unused1;
  377         u_int8_t how;
  378         u_int8_t unused[4];
  379         u_int8_t datalen;
  380         u_int8_t control;
  381 };
  382 
  383 struct scsi_read_buffer
  384 {
  385         u_int8_t opcode;
  386         u_int8_t byte2;
  387 #define RWB_MODE                0x07
  388 #define RWB_MODE_HDR_DATA       0x00
  389 #define RWB_MODE_DATA           0x02
  390 #define RWB_MODE_DOWNLOAD       0x04
  391 #define RWB_MODE_DOWNLOAD_SAVE  0x05
  392         u_int8_t buffer_id;
  393         u_int8_t offset[3];
  394         u_int8_t length[3];
  395         u_int8_t control;
  396 };
  397 
  398 struct scsi_write_buffer
  399 {
  400         u_int8_t opcode;
  401         u_int8_t byte2;
  402         u_int8_t buffer_id;
  403         u_int8_t offset[3];
  404         u_int8_t length[3];
  405         u_int8_t control;
  406 };
  407 
  408 struct scsi_rw_6
  409 {
  410         u_int8_t opcode;
  411         u_int8_t addr[3];
  412 /* only 5 bits are valid in the MSB address byte */
  413 #define SRW_TOPADDR     0x1F
  414         u_int8_t length;
  415         u_int8_t control;
  416 };
  417 
  418 struct scsi_rw_10
  419 {
  420         u_int8_t opcode;
  421 #define SRW10_RELADDR   0x01
  422 /* EBP defined for WRITE(10) only */
  423 #define SRW10_EBP       0x04
  424 #define SRW10_FUA       0x08
  425 #define SRW10_DPO       0x10
  426         u_int8_t byte2;
  427         u_int8_t addr[4];
  428         u_int8_t reserved;
  429         u_int8_t length[2];
  430         u_int8_t control;
  431 };
  432 
  433 struct scsi_rw_12
  434 {
  435         u_int8_t opcode;
  436 #define SRW12_RELADDR   0x01
  437 #define SRW12_FUA       0x08
  438 #define SRW12_DPO       0x10
  439         u_int8_t byte2;
  440         u_int8_t addr[4];
  441         u_int8_t length[4];
  442         u_int8_t reserved;
  443         u_int8_t control;
  444 };
  445 
  446 struct scsi_rw_16
  447 {
  448         u_int8_t opcode;
  449 #define SRW16_RELADDR   0x01
  450 #define SRW16_FUA       0x08
  451 #define SRW16_DPO       0x10
  452         u_int8_t byte2;
  453         u_int8_t addr[8];
  454         u_int8_t length[4];
  455         u_int8_t reserved;
  456         u_int8_t control;
  457 };
  458 
  459 struct scsi_start_stop_unit
  460 {
  461         u_int8_t opcode;
  462         u_int8_t byte2;
  463 #define SSS_IMMED               0x01
  464         u_int8_t reserved[2];
  465         u_int8_t how;
  466 #define SSS_START               0x01
  467 #define SSS_LOEJ                0x02
  468         u_int8_t control;
  469 };
  470 
  471 #define SC_SCSI_1 0x01
  472 #define SC_SCSI_2 0x03
  473 
  474 /*
  475  * Opcodes
  476  */
  477 
  478 #define TEST_UNIT_READY         0x00
  479 #define REQUEST_SENSE           0x03
  480 #define READ_6                  0x08
  481 #define WRITE_6                 0x0a
  482 #define INQUIRY                 0x12
  483 #define MODE_SELECT_6           0x15
  484 #define MODE_SENSE_6            0x1a
  485 #define START_STOP_UNIT         0x1b
  486 #define START_STOP              0x1b
  487 #define RESERVE                 0x16
  488 #define RELEASE                 0x17
  489 #define RECEIVE_DIAGNOSTIC      0x1c
  490 #define SEND_DIAGNOSTIC         0x1d
  491 #define PREVENT_ALLOW           0x1e
  492 #define READ_CAPACITY           0x25
  493 #define READ_10                 0x28
  494 #define WRITE_10                0x2a
  495 #define POSITION_TO_ELEMENT     0x2b
  496 #define SYNCHRONIZE_CACHE       0x35
  497 #define WRITE_BUFFER            0x3b
  498 #define READ_BUFFER             0x3c
  499 #define CHANGE_DEFINITION       0x40
  500 #define LOG_SELECT              0x4c
  501 #define LOG_SENSE               0x4d
  502 #define MODE_SELECT_10          0x55
  503 #define MODE_SENSE_10           0x5A
  504 #define READ_16                 0x88
  505 #define WRITE_16                0x8a
  506 #define SERVICE_ACTION_IN       0x9e
  507 #define REPORT_LUNS             0xA0
  508 #define MOVE_MEDIUM             0xa5
  509 #define READ_12                 0xa8
  510 #define WRITE_12                0xaa
  511 #define READ_ELEMENT_STATUS     0xb8
  512 
  513 
  514 /*
  515  * Device Types
  516  */
  517 #define T_DIRECT        0x00
  518 #define T_SEQUENTIAL    0x01
  519 #define T_PRINTER       0x02
  520 #define T_PROCESSOR     0x03
  521 #define T_WORM          0x04
  522 #define T_CDROM         0x05
  523 #define T_SCANNER       0x06
  524 #define T_OPTICAL       0x07
  525 #define T_CHANGER       0x08
  526 #define T_COMM          0x09
  527 #define T_ASC0          0x0a
  528 #define T_ASC1          0x0b
  529 #define T_STORARRAY     0x0c
  530 #define T_ENCLOSURE     0x0d
  531 #define T_RBC           0x0e
  532 #define T_OCRW          0x0f
  533 #define T_NODEVICE      0x1F
  534 #define T_ANY           0xFF    /* Used in Quirk table matches */
  535 
  536 #define T_REMOV         1
  537 #define T_FIXED         0
  538 
  539 /*
  540  * This length is the initial inquiry length used by the probe code, as    
  541  * well as the legnth necessary for scsi_print_inquiry() to function 
  542  * correctly.  If either use requires a different length in the future, 
  543  * the two values should be de-coupled.
  544  */
  545 #define SHORT_INQUIRY_LENGTH    36
  546 
  547 struct scsi_inquiry_data
  548 {
  549         u_int8_t device;
  550 #define SID_TYPE(inq_data) ((inq_data)->device & 0x1f)
  551 #define SID_QUAL(inq_data) (((inq_data)->device & 0xE0) >> 5)
  552 #define SID_QUAL_LU_CONNECTED   0x00    /*
  553                                          * The specified peripheral device
  554                                          * type is currently connected to
  555                                          * logical unit.  If the target cannot
  556                                          * determine whether or not a physical
  557                                          * device is currently connected, it
  558                                          * shall also use this peripheral
  559                                          * qualifier when returning the INQUIRY
  560                                          * data.  This peripheral qualifier
  561                                          * does not mean that the device is
  562                                          * ready for access by the initiator.
  563                                          */
  564 #define SID_QUAL_LU_OFFLINE     0x01    /*
  565                                          * The target is capable of supporting
  566                                          * the specified peripheral device type
  567                                          * on this logical unit; however, the
  568                                          * physical device is not currently
  569                                          * connected to this logical unit.
  570                                          */
  571 #define SID_QUAL_RSVD           0x02
  572 #define SID_QUAL_BAD_LU         0x03    /*
  573                                          * The target is not capable of
  574                                          * supporting a physical device on
  575                                          * this logical unit. For this
  576                                          * peripheral qualifier the peripheral
  577                                          * device type shall be set to 1Fh to
  578                                          * provide compatibility with previous
  579                                          * versions of SCSI. All other
  580                                          * peripheral device type values are
  581                                          * reserved for this peripheral
  582                                          * qualifier.
  583                                          */
  584 #define SID_QUAL_IS_VENDOR_UNIQUE(inq_data) ((SID_QUAL(inq_data) & 0x08) != 0)
  585         u_int8_t dev_qual2;
  586 #define SID_QUAL2       0x7F
  587 #define SID_IS_REMOVABLE(inq_data) (((inq_data)->dev_qual2 & 0x80) != 0)
  588         u_int8_t version;
  589 #define SID_ANSI_REV(inq_data) ((inq_data)->version & 0x07)
  590 #define         SCSI_REV_0              0
  591 #define         SCSI_REV_CCS            1
  592 #define         SCSI_REV_2              2
  593 #define         SCSI_REV_SPC            3
  594 #define         SCSI_REV_SPC2           4
  595 
  596 #define SID_ECMA        0x38
  597 #define SID_ISO         0xC0
  598         u_int8_t response_format;
  599 #define SID_AENC        0x80
  600 #define SID_TrmIOP      0x40
  601         u_int8_t additional_length;
  602         u_int8_t reserved[2];
  603         u_int8_t flags;
  604 #define SID_SftRe       0x01
  605 #define SID_CmdQue      0x02
  606 #define SID_Linked      0x08
  607 #define SID_Sync        0x10
  608 #define SID_WBus16      0x20
  609 #define SID_WBus32      0x40
  610 #define SID_RelAdr      0x80
  611 #define SID_VENDOR_SIZE   8
  612         char     vendor[SID_VENDOR_SIZE];
  613 #define SID_PRODUCT_SIZE  16
  614         char     product[SID_PRODUCT_SIZE];
  615 #define SID_REVISION_SIZE 4
  616         char     revision[SID_REVISION_SIZE];
  617         /*
  618          * The following fields were taken from SCSI Primary Commands - 2
  619          * (SPC-2) Revision 14, Dated 11 November 1999
  620          */
  621 #define SID_VENDOR_SPECIFIC_0_SIZE      20
  622         u_int8_t vendor_specific0[SID_VENDOR_SPECIFIC_0_SIZE];
  623         /*
  624          * An extension of SCSI Parallel Specific Values
  625          */
  626 #define SID_SPI_IUS             0x01
  627 #define SID_SPI_QAS             0x02
  628 #define SID_SPI_CLOCK_ST        0x00
  629 #define SID_SPI_CLOCK_DT        0x04
  630 #define SID_SPI_CLOCK_DT_ST     0x0C
  631 #define SID_SPI_MASK            0x0F
  632         u_int8_t spi3data;
  633         u_int8_t reserved2;
  634         /*
  635          * Version Descriptors, stored 2 byte values.
  636          */
  637         u_int8_t version1[2];
  638         u_int8_t version2[2];
  639         u_int8_t version3[2];
  640         u_int8_t version4[2];
  641         u_int8_t version5[2];
  642         u_int8_t version6[2];
  643         u_int8_t version7[2];
  644         u_int8_t version8[2];
  645 
  646         u_int8_t reserved3[22];
  647 
  648 #define SID_VENDOR_SPECIFIC_1_SIZE      160
  649         u_int8_t vendor_specific1[SID_VENDOR_SPECIFIC_1_SIZE];
  650 };
  651 
  652 struct scsi_vpd_unit_serial_number
  653 {
  654         u_int8_t device;
  655         u_int8_t page_code;
  656 #define SVPD_UNIT_SERIAL_NUMBER 0x80
  657         u_int8_t reserved;
  658         u_int8_t length; /* serial number length */
  659 #define SVPD_SERIAL_NUM_SIZE 251
  660         u_int8_t serial_num[SVPD_SERIAL_NUM_SIZE];
  661 };
  662 
  663 struct scsi_read_capacity
  664 {
  665         u_int8_t opcode;
  666         u_int8_t byte2;
  667         u_int8_t addr[4];
  668         u_int8_t unused[3];
  669         u_int8_t control;
  670 };
  671 
  672 struct scsi_read_capacity_16
  673 {
  674         uint8_t opcode;
  675 #define SRC16_SERVICE_ACTION    0x10
  676         uint8_t service_action;
  677         uint8_t addr[8];
  678         uint8_t alloc_len[4];
  679 #define SRC16_PMI               0x01
  680 #define SRC16_RELADR            0x02
  681         uint8_t reladr;
  682         uint8_t control;
  683 };
  684 
  685 struct scsi_read_capacity_data
  686 {
  687         u_int8_t addr[4];
  688         u_int8_t length[4];
  689 };
  690 
  691 struct scsi_read_capacity_data_long
  692 {
  693         uint8_t addr[8];
  694         uint8_t length[4];
  695 };
  696 
  697 struct scsi_report_luns
  698 {
  699         u_int8_t opcode;
  700         u_int8_t byte2;
  701         u_int8_t unused[3];
  702         u_int8_t addr[4];
  703         u_int8_t control;
  704 };
  705 
  706 struct scsi_report_luns_data {
  707         u_int8_t length[4];     /* length of LUN inventory, in bytes */
  708         u_int8_t reserved[4];   /* unused */
  709         /*
  710          * LUN inventory- we only support the type zero form for now.
  711          */
  712         struct {
  713                 u_int8_t lundata[8];
  714         } luns[1];
  715 };
  716 #define RPL_LUNDATA_ATYP_MASK   0xc0    /* MBZ for type 0 lun */
  717 #define RPL_LUNDATA_T0LUN       1       /* @ lundata[1] */
  718 
  719 
  720 struct scsi_sense_data
  721 {
  722         u_int8_t error_code;
  723 #define SSD_ERRCODE                     0x7F
  724 #define         SSD_CURRENT_ERROR       0x70
  725 #define         SSD_DEFERRED_ERROR      0x71
  726 #define SSD_ERRCODE_VALID       0x80    
  727         u_int8_t segment;
  728         u_int8_t flags;
  729 #define SSD_KEY                         0x0F
  730 #define         SSD_KEY_NO_SENSE        0x00
  731 #define         SSD_KEY_RECOVERED_ERROR 0x01
  732 #define         SSD_KEY_NOT_READY       0x02
  733 #define         SSD_KEY_MEDIUM_ERROR    0x03
  734 #define         SSD_KEY_HARDWARE_ERROR  0x04
  735 #define         SSD_KEY_ILLEGAL_REQUEST 0x05
  736 #define         SSD_KEY_UNIT_ATTENTION  0x06
  737 #define         SSD_KEY_DATA_PROTECT    0x07
  738 #define         SSD_KEY_BLANK_CHECK     0x08
  739 #define         SSD_KEY_Vendor_Specific 0x09
  740 #define         SSD_KEY_COPY_ABORTED    0x0a
  741 #define         SSD_KEY_ABORTED_COMMAND 0x0b            
  742 #define         SSD_KEY_EQUAL           0x0c
  743 #define         SSD_KEY_VOLUME_OVERFLOW 0x0d
  744 #define         SSD_KEY_MISCOMPARE      0x0e
  745 #define         SSD_KEY_RESERVED        0x0f                    
  746 #define SSD_ILI         0x20
  747 #define SSD_EOM         0x40
  748 #define SSD_FILEMARK    0x80
  749         u_int8_t info[4];
  750         u_int8_t extra_len;
  751         u_int8_t cmd_spec_info[4];
  752         u_int8_t add_sense_code;
  753         u_int8_t add_sense_code_qual;
  754         u_int8_t fru;
  755         u_int8_t sense_key_spec[3];
  756 #define SSD_SCS_VALID           0x80
  757 #define SSD_FIELDPTR_CMD        0x40
  758 #define SSD_BITPTR_VALID        0x08
  759 #define SSD_BITPTR_VALUE        0x07
  760 #define SSD_MIN_SIZE 18
  761         u_int8_t extra_bytes[14];
  762 #define SSD_FULL_SIZE sizeof(struct scsi_sense_data)
  763 };
  764 
  765 struct scsi_mode_header_6
  766 {
  767         u_int8_t data_length;   /* Sense data length */
  768         u_int8_t medium_type;
  769         u_int8_t dev_spec;
  770         u_int8_t blk_desc_len;
  771 };
  772 
  773 struct scsi_mode_header_10
  774 {
  775         u_int8_t data_length[2];/* Sense data length */
  776         u_int8_t medium_type;
  777         u_int8_t dev_spec;
  778         u_int8_t unused[2];
  779         u_int8_t blk_desc_len[2];
  780 };
  781 
  782 struct scsi_mode_page_header
  783 {
  784         u_int8_t page_code;
  785         u_int8_t page_length;
  786 };
  787 
  788 struct scsi_mode_blk_desc
  789 {
  790         u_int8_t density;
  791         u_int8_t nblocks[3];
  792         u_int8_t reserved;
  793         u_int8_t blklen[3];
  794 };
  795 
  796 #define SCSI_DEFAULT_DENSITY    0x00    /* use 'default' density */
  797 #define SCSI_SAME_DENSITY       0x7f    /* use 'same' density- >= SCSI-2 only */
  798 
  799 
  800 /*
  801  * Status Byte
  802  */
  803 #define SCSI_STATUS_OK                  0x00
  804 #define SCSI_STATUS_CHECK_COND          0x02
  805 #define SCSI_STATUS_COND_MET            0x04
  806 #define SCSI_STATUS_BUSY                0x08
  807 #define SCSI_STATUS_INTERMED            0x10
  808 #define SCSI_STATUS_INTERMED_COND_MET   0x14
  809 #define SCSI_STATUS_RESERV_CONFLICT     0x18
  810 #define SCSI_STATUS_CMD_TERMINATED      0x22    /* Obsolete in SAM-2 */
  811 #define SCSI_STATUS_QUEUE_FULL          0x28
  812 #define SCSI_STATUS_ACA_ACTIVE          0x30
  813 #define SCSI_STATUS_TASK_ABORTED        0x40
  814 
  815 struct scsi_inquiry_pattern {
  816         u_int8_t   type;
  817         u_int8_t   media_type;
  818 #define SIP_MEDIA_REMOVABLE     0x01
  819 #define SIP_MEDIA_FIXED         0x02
  820         const char *vendor;
  821         const char *product;
  822         const char *revision;
  823 }; 
  824 
  825 struct scsi_static_inquiry_pattern {
  826         u_int8_t   type;
  827         u_int8_t   media_type;
  828         char       vendor[SID_VENDOR_SIZE+1];
  829         char       product[SID_PRODUCT_SIZE+1];
  830         char       revision[SID_REVISION_SIZE+1];
  831 };
  832 
  833 struct scsi_sense_quirk_entry {
  834         struct scsi_inquiry_pattern     inq_pat;
  835         int                             num_sense_keys;
  836         int                             num_ascs;
  837         struct sense_key_table_entry    *sense_key_info;
  838         struct asc_table_entry          *asc_info;
  839 };
  840 
  841 struct sense_key_table_entry {
  842         u_int8_t    sense_key;
  843         u_int32_t   action;
  844         const char *desc;
  845 };
  846 
  847 struct asc_table_entry {
  848         u_int8_t    asc;
  849         u_int8_t    ascq;
  850         u_int32_t   action;
  851         const char *desc;
  852 };
  853 
  854 struct op_table_entry {
  855         u_int8_t    opcode;
  856         u_int16_t   opmask;
  857         const char  *desc;
  858 };
  859 
  860 struct scsi_op_quirk_entry {
  861         struct scsi_inquiry_pattern     inq_pat;
  862         int                             num_ops;
  863         struct op_table_entry           *op_table;
  864 };
  865 
  866 typedef enum {
  867         SSS_FLAG_NONE           = 0x00,
  868         SSS_FLAG_PRINT_COMMAND  = 0x01
  869 } scsi_sense_string_flags;
  870 
  871 struct ccb_scsiio;
  872 struct cam_periph;
  873 union  ccb;
  874 #ifndef _KERNEL
  875 struct cam_device;
  876 #endif
  877 
  878 extern const char *scsi_sense_key_text[];
  879 
  880 struct sbuf;
  881 
  882 __BEGIN_DECLS
  883 void scsi_sense_desc(int sense_key, int asc, int ascq,
  884                      struct scsi_inquiry_data *inq_data,
  885                      const char **sense_key_desc, const char **asc_desc);
  886 scsi_sense_action scsi_error_action(struct ccb_scsiio* csio,
  887                                     struct scsi_inquiry_data *inq_data,
  888                                     u_int32_t sense_flags);
  889 const char *    scsi_status_string(struct ccb_scsiio *csio);
  890 #ifdef _KERNEL
  891 int             scsi_command_string(struct ccb_scsiio *csio, struct sbuf *sb);
  892 int             scsi_sense_sbuf(struct ccb_scsiio *csio, struct sbuf *sb,
  893                                 scsi_sense_string_flags flags);
  894 char *          scsi_sense_string(struct ccb_scsiio *csio,
  895                                   char *str, int str_len);
  896 void            scsi_sense_print(struct ccb_scsiio *csio);
  897 int             scsi_interpret_sense(union ccb *ccb, 
  898                                      u_int32_t sense_flags,
  899                                      u_int32_t *relsim_flags, 
  900                                      u_int32_t *reduction,
  901                                      u_int32_t *timeout,
  902                                      scsi_sense_action error_action);
  903 #else /* _KERNEL */
  904 int             scsi_command_string(struct cam_device *device,
  905                                     struct ccb_scsiio *csio, struct sbuf *sb);
  906 int             scsi_sense_sbuf(struct cam_device *device, 
  907                                 struct ccb_scsiio *csio, struct sbuf *sb,
  908                                 scsi_sense_string_flags flags);
  909 char *          scsi_sense_string(struct cam_device *device, 
  910                                   struct ccb_scsiio *csio,
  911                                   char *str, int str_len);
  912 void            scsi_sense_print(struct cam_device *device, 
  913                                  struct ccb_scsiio *csio, FILE *ofile);
  914 int             scsi_interpret_sense(struct cam_device *device,
  915                                      union ccb *ccb,
  916                                      u_int32_t sense_flags,
  917                                      u_int32_t *relsim_flags, 
  918                                      u_int32_t *reduction,
  919                                      u_int32_t *timeout,
  920                                      scsi_sense_action error_action);
  921 #endif /* _KERNEL */
  922 
  923 #define SF_RETRY_UA     0x01
  924 #define SF_NO_PRINT     0x02
  925 #define SF_QUIET_IR     0x04    /* Be quiet about Illegal Request reponses */
  926 #define SF_PRINT_ALWAYS 0x08
  927 
  928 
  929 const char *    scsi_op_desc(u_int16_t opcode, 
  930                              struct scsi_inquiry_data *inq_data);
  931 char *          scsi_cdb_string(u_int8_t *cdb_ptr, char *cdb_string,
  932                                 size_t len);
  933 
  934 void            scsi_print_inquiry(struct scsi_inquiry_data *inq_data);
  935 
  936 u_int           scsi_calc_syncsrate(u_int period_factor);
  937 u_int           scsi_calc_syncparam(u_int period);
  938         
  939 void            scsi_test_unit_ready(struct ccb_scsiio *csio, u_int32_t retries,
  940                                      void (*cbfcnp)(struct cam_periph *, 
  941                                                     union ccb *),
  942                                      u_int8_t tag_action, 
  943                                      u_int8_t sense_len, u_int32_t timeout);
  944 
  945 void            scsi_request_sense(struct ccb_scsiio *csio, u_int32_t retries,
  946                                    void (*cbfcnp)(struct cam_periph *, 
  947                                                   union ccb *),
  948                                    void *data_ptr, u_int8_t dxfer_len,
  949                                    u_int8_t tag_action, u_int8_t sense_len,
  950                                    u_int32_t timeout);
  951 
  952 void            scsi_inquiry(struct ccb_scsiio *csio, u_int32_t retries,
  953                              void (*cbfcnp)(struct cam_periph *, union ccb *),
  954                              u_int8_t tag_action, u_int8_t *inq_buf, 
  955                              u_int32_t inq_len, int evpd, u_int8_t page_code,
  956                              u_int8_t sense_len, u_int32_t timeout);
  957 
  958 void            scsi_mode_sense(struct ccb_scsiio *csio, u_int32_t retries,
  959                                 void (*cbfcnp)(struct cam_periph *,
  960                                                union ccb *),
  961                                 u_int8_t tag_action, int dbd,
  962                                 u_int8_t page_code, u_int8_t page,
  963                                 u_int8_t *param_buf, u_int32_t param_len,
  964                                 u_int8_t sense_len, u_int32_t timeout);
  965 
  966 void            scsi_mode_sense_len(struct ccb_scsiio *csio, u_int32_t retries,
  967                                     void (*cbfcnp)(struct cam_periph *,
  968                                                    union ccb *),
  969                                     u_int8_t tag_action, int dbd,
  970                                     u_int8_t page_code, u_int8_t page,
  971                                     u_int8_t *param_buf, u_int32_t param_len,
  972                                     int minimum_cmd_size, u_int8_t sense_len,
  973                                     u_int32_t timeout);
  974 
  975 void            scsi_mode_select(struct ccb_scsiio *csio, u_int32_t retries,
  976                                  void (*cbfcnp)(struct cam_periph *,
  977                                                 union ccb *),
  978                                  u_int8_t tag_action, int scsi_page_fmt,
  979                                  int save_pages, u_int8_t *param_buf,
  980                                  u_int32_t param_len, u_int8_t sense_len,
  981                                  u_int32_t timeout);
  982 
  983 void            scsi_mode_select_len(struct ccb_scsiio *csio, u_int32_t retries,
  984                                      void (*cbfcnp)(struct cam_periph *,
  985                                                     union ccb *),
  986                                      u_int8_t tag_action, int scsi_page_fmt,
  987                                      int save_pages, u_int8_t *param_buf,
  988                                      u_int32_t param_len, int minimum_cmd_size,
  989                                      u_int8_t sense_len, u_int32_t timeout);
  990 
  991 void            scsi_log_sense(struct ccb_scsiio *csio, u_int32_t retries,
  992                                void (*cbfcnp)(struct cam_periph *, union ccb *),
  993                                u_int8_t tag_action, u_int8_t page_code,
  994                                u_int8_t page, int save_pages, int ppc,
  995                                u_int32_t paramptr, u_int8_t *param_buf,
  996                                u_int32_t param_len, u_int8_t sense_len,
  997                                u_int32_t timeout);
  998 
  999 void            scsi_log_select(struct ccb_scsiio *csio, u_int32_t retries,
 1000                                 void (*cbfcnp)(struct cam_periph *,
 1001                                 union ccb *), u_int8_t tag_action,
 1002                                 u_int8_t page_code, int save_pages,
 1003                                 int pc_reset, u_int8_t *param_buf,
 1004                                 u_int32_t param_len, u_int8_t sense_len,
 1005                                 u_int32_t timeout);
 1006 
 1007 void            scsi_prevent(struct ccb_scsiio *csio, u_int32_t retries,
 1008                              void (*cbfcnp)(struct cam_periph *, union ccb *),
 1009                              u_int8_t tag_action, u_int8_t action,
 1010                              u_int8_t sense_len, u_int32_t timeout);
 1011 
 1012 void            scsi_read_capacity(struct ccb_scsiio *csio, u_int32_t retries,
 1013                                    void (*cbfcnp)(struct cam_periph *, 
 1014                                    union ccb *), u_int8_t tag_action, 
 1015                                    struct scsi_read_capacity_data *,
 1016                                    u_int8_t sense_len, u_int32_t timeout);
 1017 void            scsi_read_capacity_16(struct ccb_scsiio *csio, uint32_t retries,
 1018                                       void (*cbfcnp)(struct cam_periph *,
 1019                                       union ccb *), uint8_t tag_action,
 1020                                       uint64_t lba, int reladr, int pmi,
 1021                                       struct scsi_read_capacity_data_long
 1022                                       *rcap_buf, uint8_t sense_len,
 1023                                       uint32_t timeout);
 1024 
 1025 void            scsi_report_luns(struct ccb_scsiio *csio, u_int32_t retries,
 1026                                    void (*cbfcnp)(struct cam_periph *, 
 1027                                    union ccb *), u_int8_t tag_action, 
 1028                                    struct scsi_report_luns_data *,
 1029                                    u_int32_t alloc_len, u_int8_t sense_len,
 1030                                    u_int32_t timeout);
 1031 
 1032 void            scsi_synchronize_cache(struct ccb_scsiio *csio, 
 1033                                        u_int32_t retries,
 1034                                        void (*cbfcnp)(struct cam_periph *, 
 1035                                        union ccb *), u_int8_t tag_action, 
 1036                                        u_int32_t begin_lba, u_int16_t lb_count,
 1037                                        u_int8_t sense_len, u_int32_t timeout);
 1038 
 1039 void scsi_read_write(struct ccb_scsiio *csio, u_int32_t retries,
 1040                      void (*cbfcnp)(struct cam_periph *, union ccb *),
 1041                      u_int8_t tag_action, int readop, u_int8_t byte2, 
 1042                      int minimum_cmd_size, u_int64_t lba,
 1043                      u_int32_t block_count, u_int8_t *data_ptr,
 1044                      u_int32_t dxfer_len, u_int8_t sense_len,
 1045                      u_int32_t timeout);
 1046 
 1047 void scsi_start_stop(struct ccb_scsiio *csio, u_int32_t retries,
 1048                      void (*cbfcnp)(struct cam_periph *, union ccb *),
 1049                      u_int8_t tag_action, int start, int load_eject,
 1050                      int immediate, u_int8_t sense_len, u_int32_t timeout);
 1051 
 1052 int             scsi_inquiry_match(caddr_t inqbuffer, caddr_t table_entry);
 1053 int             scsi_static_inquiry_match(caddr_t inqbuffer,
 1054                                           caddr_t table_entry);
 1055 
 1056 static __inline void scsi_extract_sense(struct scsi_sense_data *sense,
 1057                                         int *error_code, int *sense_key,
 1058                                         int *asc, int *ascq);
 1059 static __inline void scsi_ulto2b(u_int32_t val, u_int8_t *bytes);
 1060 static __inline void scsi_ulto3b(u_int32_t val, u_int8_t *bytes);
 1061 static __inline void scsi_ulto4b(u_int32_t val, u_int8_t *bytes);
 1062 static __inline void scsi_u64to8b(u_int64_t val, u_int8_t *bytes);
 1063 static __inline u_int32_t scsi_2btoul(u_int8_t *bytes);
 1064 static __inline u_int32_t scsi_3btoul(u_int8_t *bytes);
 1065 static __inline int32_t scsi_3btol(u_int8_t *bytes);
 1066 static __inline u_int32_t scsi_4btoul(u_int8_t *bytes);
 1067 static __inline u_int64_t scsi_8btou64(u_int8_t *bytes);
 1068 static __inline void *find_mode_page_6(struct scsi_mode_header_6 *mode_header);
 1069 static __inline void *find_mode_page_10(struct scsi_mode_header_10 *mode_header);
 1070 
 1071 static __inline void scsi_extract_sense(struct scsi_sense_data *sense,
 1072                                         int *error_code, int *sense_key,
 1073                                         int *asc, int *ascq)
 1074 {
 1075         *error_code = sense->error_code & SSD_ERRCODE;
 1076         *sense_key = sense->flags & SSD_KEY;
 1077         *asc = (sense->extra_len >= 5) ? sense->add_sense_code : 0;
 1078         *ascq = (sense->extra_len >= 6) ? sense->add_sense_code_qual : 0;
 1079 }
 1080 
 1081 static __inline void
 1082 scsi_ulto2b(u_int32_t val, u_int8_t *bytes)
 1083 {
 1084 
 1085         bytes[0] = (val >> 8) & 0xff;
 1086         bytes[1] = val & 0xff;
 1087 }
 1088 
 1089 static __inline void
 1090 scsi_ulto3b(u_int32_t val, u_int8_t *bytes)
 1091 {
 1092 
 1093         bytes[0] = (val >> 16) & 0xff;
 1094         bytes[1] = (val >> 8) & 0xff;
 1095         bytes[2] = val & 0xff;
 1096 }
 1097 
 1098 static __inline void
 1099 scsi_ulto4b(u_int32_t val, u_int8_t *bytes)
 1100 {
 1101 
 1102         bytes[0] = (val >> 24) & 0xff;
 1103         bytes[1] = (val >> 16) & 0xff;
 1104         bytes[2] = (val >> 8) & 0xff;
 1105         bytes[3] = val & 0xff;
 1106 }
 1107 
 1108 static __inline void
 1109 scsi_u64to8b(u_int64_t val, u_int8_t *bytes)
 1110 {
 1111 
 1112         bytes[0] = (val >> 56) & 0xff;
 1113         bytes[1] = (val >> 48) & 0xff;
 1114         bytes[2] = (val >> 40) & 0xff;
 1115         bytes[3] = (val >> 32) & 0xff;
 1116         bytes[4] = (val >> 24) & 0xff;
 1117         bytes[5] = (val >> 16) & 0xff;
 1118         bytes[6] = (val >> 8) & 0xff;
 1119         bytes[7] = val & 0xff;
 1120 }
 1121 
 1122 static __inline u_int32_t
 1123 scsi_2btoul(u_int8_t *bytes)
 1124 {
 1125         u_int32_t rv;
 1126 
 1127         rv = (bytes[0] << 8) |
 1128              bytes[1];
 1129         return (rv);
 1130 }
 1131 
 1132 static __inline u_int32_t
 1133 scsi_3btoul(u_int8_t *bytes)
 1134 {
 1135         u_int32_t rv;
 1136 
 1137         rv = (bytes[0] << 16) |
 1138              (bytes[1] << 8) |
 1139              bytes[2];
 1140         return (rv);
 1141 }
 1142 
 1143 static __inline int32_t 
 1144 scsi_3btol(u_int8_t *bytes)
 1145 {
 1146         u_int32_t rc = scsi_3btoul(bytes);
 1147  
 1148         if (rc & 0x00800000)
 1149                 rc |= 0xff000000;
 1150 
 1151         return (int32_t) rc;
 1152 }
 1153 
 1154 static __inline u_int32_t
 1155 scsi_4btoul(u_int8_t *bytes)
 1156 {
 1157         u_int32_t rv;
 1158 
 1159         rv = (bytes[0] << 24) |
 1160              (bytes[1] << 16) |
 1161              (bytes[2] << 8) |
 1162              bytes[3];
 1163         return (rv);
 1164 }
 1165 
 1166 static __inline uint64_t
 1167 scsi_8btou64(uint8_t *bytes)
 1168 {
 1169         uint64_t rv;
 1170  
 1171         rv = (((uint64_t)bytes[0]) << 56) |
 1172              (((uint64_t)bytes[1]) << 48) |
 1173              (((uint64_t)bytes[2]) << 40) |
 1174              (((uint64_t)bytes[3]) << 32) |
 1175              (((uint64_t)bytes[4]) << 24) |
 1176              (((uint64_t)bytes[5]) << 16) |
 1177              (((uint64_t)bytes[6]) << 8) |
 1178              bytes[7];
 1179         return (rv);
 1180 }
 1181 
 1182 /*
 1183  * Given the pointer to a returned mode sense buffer, return a pointer to
 1184  * the start of the first mode page.
 1185  */
 1186 static __inline void *
 1187 find_mode_page_6(struct scsi_mode_header_6 *mode_header)
 1188 {
 1189         void *page_start;
 1190 
 1191         page_start = (void *)((u_int8_t *)&mode_header[1] +
 1192                               mode_header->blk_desc_len);
 1193 
 1194         return(page_start);
 1195 }
 1196 
 1197 static __inline void *
 1198 find_mode_page_10(struct scsi_mode_header_10 *mode_header)
 1199 {
 1200         void *page_start;
 1201 
 1202         page_start = (void *)((u_int8_t *)&mode_header[1] +
 1203                                scsi_2btoul(mode_header->blk_desc_len));
 1204 
 1205         return(page_start);
 1206 }
 1207 
 1208 __END_DECLS
 1209 
 1210 #endif /*_SCSI_SCSI_ALL_H*/

Cache object: e6dd752c563e014a0c8e1260b3fbb4df


[ 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.