2 * Largely written by Julian Elischer (julian@tfs.com)
3 * for TRW Financial Systems.
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.
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.
15 * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
21 * SCSI general interface description
24 #ifndef _SCSI_SCSI_ALL_H
25 #define _SCSI_SCSI_ALL_H 1
27 #include <sys/cdefs.h>
31 * This is the number of seconds we wait for devices to settle after a SCSI
34 extern int scsi_delay;
42 * Define dome bits that are in ALL (or a lot of) scsi commands
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 */
50 #define SCSI_MAX_CDBLEN 16 /*
51 * 16 byte commands are in the
54 #if defined(CAM_MAX_CDBLEN) && (CAM_MAX_CDBLEN < SCSI_MAX_CDBLEN)
55 #error "CAM_MAX_CDBLEN cannot be less than SCSI_MAX_CDBLEN"
58 /* 6byte CDBs special case 0 length to be 256 */
59 #define SCSI_CDB6_LEN(len) ((len) == 0 ? 256 : len)
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.
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.
73 SS_TUR = 0x040000, /* Send a Test Unit Ready command to the
74 * device, then retry the original command.
76 SS_REQSENSE = 0x050000, /* Send a RequestSense command to the
77 * device, then retry the original command.
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
92 SSQ_PRINT_SENSE = 0x0800,
94 } scsi_sense_action_qualifier;
96 /* Mask for error status values */
97 #define SS_ERRMASK 0xff
99 /* The default, retyable, error action */
100 #define SS_RDEF SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE|EIO
102 /* The retyable, error action, with table specified error code */
103 #define SS_RET SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE
105 /* Fatal error action, with table specified error code */
106 #define SS_FATAL SS_FAIL|SSQ_PRINT_SENSE
114 struct scsi_request_sense
118 #define SRS_DESC 0x01
124 struct scsi_test_unit_ready
132 struct scsi_receive_diag {
141 struct scsi_send_diag {
144 #define SSD_UNITOFFL 0x01
145 #define SSD_DEVOFFL 0x02
146 #define SSD_SELFTEST 0x04
148 #define SSD_SELF_TEST_CODE_MASK 0xE0
149 #define SSD_SELF_TEST_CODE_SHIFT 5
150 #define SSD_SELF_TEST_CODE_NONE 0x00
151 #define SSD_SELF_TEST_CODE_BG_SHORT 0x01
152 #define SSD_SELF_TEST_CODE_BG_EXTENDED 0x02
153 #define SSD_SELF_TEST_CODE_BG_ABORT 0x04
154 #define SSD_SELF_TEST_CODE_FG_SHORT 0x05
155 #define SSD_SELF_TEST_CODE_FG_EXTENDED 0x06
181 struct scsi_mode_sense_6
187 #define SMS_PAGE_CODE 0x3F
188 #define SMS_VENDOR_SPECIFIC_PAGE 0x00
189 #define SMS_DISCONNECT_RECONNECT_PAGE 0x02
190 #define SMS_FORMAT_DEVICE_PAGE 0x03
191 #define SMS_GEOMETRY_PAGE 0x04
192 #define SMS_CACHE_PAGE 0x08
193 #define SMS_PERIPHERAL_DEVICE_PAGE 0x09
194 #define SMS_CONTROL_MODE_PAGE 0x0A
195 #define SMS_PROTO_SPECIFIC_PAGE 0x19
196 #define SMS_INFO_EXCEPTIONS_PAGE 0x1C
197 #define SMS_ALL_PAGES_PAGE 0x3F
198 #define SMS_PAGE_CTRL_MASK 0xC0
199 #define SMS_PAGE_CTRL_CURRENT 0x00
200 #define SMS_PAGE_CTRL_CHANGEABLE 0x40
201 #define SMS_PAGE_CTRL_DEFAULT 0x80
202 #define SMS_PAGE_CTRL_SAVED 0xC0
208 struct scsi_mode_sense_10
211 u_int8_t byte2; /* same bits as small version */
212 u_int8_t page; /* same bits as small version */
218 struct scsi_mode_select_6
229 struct scsi_mode_select_10
232 u_int8_t byte2; /* same bits as small version */
239 * When sending a mode select to a tape drive, the medium type must be 0.
241 struct scsi_mode_hdr_6
244 u_int8_t medium_type;
245 u_int8_t dev_specific;
246 u_int8_t block_descr_len;
249 struct scsi_mode_hdr_10
252 u_int8_t medium_type;
253 u_int8_t dev_specific;
254 u_int8_t reserved[2];
255 u_int8_t block_descr_len[2];
258 struct scsi_mode_block_descr
260 u_int8_t density_code;
261 u_int8_t num_blocks[3];
263 u_int8_t block_len[3];
266 struct scsi_log_sense
273 #define SLS_PAGE_CODE 0x3F
274 #define SLS_ALL_PAGES_PAGE 0x00
275 #define SLS_OVERRUN_PAGE 0x01
276 #define SLS_ERROR_WRITE_PAGE 0x02
277 #define SLS_ERROR_READ_PAGE 0x03
278 #define SLS_ERROR_READREVERSE_PAGE 0x04
279 #define SLS_ERROR_VERIFY_PAGE 0x05
280 #define SLS_ERROR_NONMEDIUM_PAGE 0x06
281 #define SLS_ERROR_LASTN_PAGE 0x07
282 #define SLS_SELF_TEST_PAGE 0x10
283 #define SLS_IE_PAGE 0x2f
284 #define SLS_PAGE_CTRL_MASK 0xC0
285 #define SLS_PAGE_CTRL_THRESHOLD 0x00
286 #define SLS_PAGE_CTRL_CUMULATIVE 0x40
287 #define SLS_PAGE_CTRL_THRESH_DEFAULT 0x80
288 #define SLS_PAGE_CTRL_CUMUL_DEFAULT 0xC0
289 u_int8_t reserved[2];
290 u_int8_t paramptr[2];
295 struct scsi_log_select
302 /* SLS_PAGE_CTRL_MASK 0xC0 */
303 /* SLS_PAGE_CTRL_THRESHOLD 0x00 */
304 /* SLS_PAGE_CTRL_CUMULATIVE 0x40 */
305 /* SLS_PAGE_CTRL_THRESH_DEFAULT 0x80 */
306 /* SLS_PAGE_CTRL_CUMUL_DEFAULT 0xC0 */
307 u_int8_t reserved[4];
312 struct scsi_log_header
319 struct scsi_log_param_header {
320 u_int8_t param_code[2];
321 u_int8_t param_control;
323 #define SLP_LBIN 0x02
324 #define SLP_TMC_MASK 0x0C
325 #define SLP_TMC_ALWAYS 0x00
326 #define SLP_TMC_EQUAL 0x04
327 #define SLP_TMC_NOTEQUAL 0x08
328 #define SLP_TMC_GREATER 0x0C
336 struct scsi_control_page {
338 u_int8_t page_length;
340 #define SCB_RLEC 0x01 /*Report Log Exception Cond*/
341 u_int8_t queue_flags;
342 #define SCP_QUEUE_ALG_MASK 0xF0
343 #define SCP_QUEUE_ALG_RESTRICTED 0x00
344 #define SCP_QUEUE_ALG_UNRESTRICTED 0x10
345 #define SCP_QUEUE_ERR 0x02 /*Queued I/O aborted for CACs*/
346 #define SCP_QUEUE_DQUE 0x01 /*Queued I/O disabled*/
347 u_int8_t eca_and_aen;
348 #define SCP_EECA 0x80 /*Enable Extended CA*/
349 #define SCP_RAENP 0x04 /*Ready AEN Permission*/
350 #define SCP_UAAENP 0x02 /*UA AEN Permission*/
351 #define SCP_EAENP 0x01 /*Error AEN Permission*/
353 u_int8_t aen_holdoff_period[2];
356 struct scsi_cache_page {
358 #define SCHP_PAGE_SAVABLE 0x80 /* Page is savable */
359 u_int8_t page_length;
360 u_int8_t cache_flags;
361 #define SCHP_FLAGS_WCE 0x04 /* Write Cache Enable */
362 #define SCHP_FLAGS_MF 0x02 /* Multiplication factor */
363 #define SCHP_FLAGS_RCD 0x01 /* Read Cache Disable */
364 u_int8_t rw_cache_policy;
365 u_int8_t dis_prefetch[2];
366 u_int8_t min_prefetch[2];
367 u_int8_t max_prefetch[2];
368 u_int8_t max_prefetch_ceil[2];
371 struct scsi_info_exceptions_page {
373 #define SIEP_PAGE_SAVABLE 0x80 /* Page is savable */
374 u_int8_t page_length;
376 #define SIEP_FLAGS_PERF 0x80
377 #define SIEP_FLAGS_EBF 0x20
378 #define SIEP_FLAGS_EWASC 0x10
379 #define SIEP_FLAGS_DEXCPT 0x08
380 #define SIEP_FLAGS_TEST 0x04
381 #define SIEP_FLAGS_EBACKERR 0x02
382 #define SIEP_FLAGS_LOGERR 0x01
384 u_int8_t interval_timer[4];
385 u_int8_t report_count[4];
388 struct scsi_proto_specific_page {
390 #define SPSP_PAGE_SAVABLE 0x80 /* Page is savable */
391 u_int8_t page_length;
393 #define SPSP_PROTO_FC 0x00
394 #define SPSP_PROTO_SPI 0x01
395 #define SPSP_PROTO_SSA 0x02
396 #define SPSP_PROTO_1394 0x03
397 #define SPSP_PROTO_RDMA 0x04
398 #define SPSP_PROTO_ISCSI 0x05
399 #define SPSP_PROTO_SAS 0x06
400 #define SPSP_PROTO_ADT 0x07
401 #define SPSP_PROTO_ATA 0x08
402 #define SPSP_PROTO_NONE 0x0f
431 #define PR_PREVENT 0x01
432 #define PR_ALLOW 0x00
434 struct scsi_sync_cache
438 u_int8_t begin_lba[4];
440 u_int8_t lb_count[2];
445 struct scsi_changedef
456 struct scsi_read_buffer
460 #define RWB_MODE 0x07
461 #define RWB_MODE_HDR_DATA 0x00
462 #define RWB_MODE_DATA 0x02
463 #define RWB_MODE_DOWNLOAD 0x04
464 #define RWB_MODE_DOWNLOAD_SAVE 0x05
471 struct scsi_write_buffer
485 /* only 5 bits are valid in the MSB address byte */
486 #define SRW_TOPADDR 0x1F
494 #define SRW10_RELADDR 0x01
495 /* EBP defined for WRITE(10) only */
496 #define SRW10_EBP 0x04
497 #define SRW10_FUA 0x08
498 #define SRW10_DPO 0x10
509 #define SRW12_RELADDR 0x01
510 #define SRW12_FUA 0x08
511 #define SRW12_DPO 0x10
522 #define SRW16_RELADDR 0x01
523 #define SRW16_FUA 0x08
524 #define SRW16_DPO 0x10
532 struct scsi_start_stop_unit
536 #define SSS_IMMED 0x01
537 u_int8_t reserved[2];
539 #define SSS_START 0x01
540 #define SSS_LOEJ 0x02
547 #define AP_MULTI 0xe0
549 #define AP_T_LEN 0x03
551 #define AP_T_DIR 0x08
552 #define AP_CK_COND 0x20
553 #define AP_OFFLINE 0x60
555 u_int8_t sector_count;
568 #define AP_EXTEND 0x01
570 u_int8_t features_ext;
572 u_int8_t sector_count_ext;
573 u_int8_t sector_count;
574 u_int8_t lba_low_ext;
576 u_int8_t lba_mid_ext;
578 u_int8_t lba_high_ext;
585 #define SC_SCSI_1 0x01
586 #define SC_SCSI_2 0x03
592 #define TEST_UNIT_READY 0x00
593 #define REQUEST_SENSE 0x03
597 #define MODE_SELECT_6 0x15
598 #define MODE_SENSE_6 0x1A
599 #define START_STOP_UNIT 0x1B
600 #define START_STOP 0x1B
603 #define RECEIVE_DIAGNOSTIC 0x1C
604 #define SEND_DIAGNOSTIC 0x1D
605 #define PREVENT_ALLOW 0x1E
606 #define READ_CAPACITY 0x25
608 #define WRITE_10 0x2A
609 #define POSITION_TO_ELEMENT 0x2B
610 #define SYNCHRONIZE_CACHE 0x35
611 #define READ_DEFECT_DATA_10 0x37
612 #define WRITE_BUFFER 0x3B
613 #define READ_BUFFER 0x3C
614 #define CHANGE_DEFINITION 0x40
615 #define LOG_SELECT 0x4C
616 #define LOG_SENSE 0x4D
617 #define MODE_SELECT_10 0x55
618 #define MODE_SENSE_10 0x5A
619 #define ATA_PASS_16 0x85
621 #define WRITE_16 0x8A
622 #define SERVICE_ACTION_IN 0x9E
623 #define REPORT_LUNS 0xA0
624 #define ATA_PASS_12 0xA1
625 #define MAINTENANCE_IN 0xA3
626 #define MAINTENANCE_OUT 0xA4
627 #define MOVE_MEDIUM 0xA5
629 #define WRITE_12 0xAA
630 #define READ_ELEMENT_STATUS 0xB8
632 /* Maintenance In Service Action Codes */
633 #define REPORT_IDENTIFYING_INFRMATION 0x05
634 #define REPORT_TARGET_PORT_GROUPS 0x0A
635 #define REPORT_ALIASES 0x0B
636 #define REPORT_SUPPORTED_OPERATION_CODES 0x0C
637 #define REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS 0x0D
638 #define REPORT_PRIORITY 0x0E
639 #define REPORT_TIMESTAMP 0x0F
640 #define MANAGEMENT_PROTOCOL_IN 0x10
641 /* Maintenance Out Service Action Codes */
642 #define SET_IDENTIFY_INFORMATION 0x06
643 #define SET_TARGET_PORT_GROUPS 0x0A
644 #define CHANGE_ALIASES 0x0B
645 #define SET_PRIORITY 0x0E
646 #define SET_TIMESTAMP 0x0F
647 #define MANGAEMENT_PROTOCOL_OUT 0x10
652 #define T_DIRECT 0x00
653 #define T_SEQUENTIAL 0x01
654 #define T_PRINTER 0x02
655 #define T_PROCESSOR 0x03
658 #define T_SCANNER 0x06
659 #define T_OPTICAL 0x07
660 #define T_CHANGER 0x08
664 #define T_STORARRAY 0x0c
665 #define T_ENCLOSURE 0x0d
670 #define T_NODEVICE 0x1f
671 #define T_ANY 0xff /* Used in Quirk table matches */
677 * This length is the initial inquiry length used by the probe code, as
678 * well as the legnth necessary for scsi_print_inquiry() to function
679 * correctly. If either use requires a different length in the future,
680 * the two values should be de-coupled.
682 #define SHORT_INQUIRY_LENGTH 36
684 struct scsi_inquiry_data
687 #define SID_TYPE(inq_data) ((inq_data)->device & 0x1f)
688 #define SID_QUAL(inq_data) (((inq_data)->device & 0xE0) >> 5)
689 #define SID_QUAL_LU_CONNECTED 0x00 /*
690 * The specified peripheral device
691 * type is currently connected to
692 * logical unit. If the target cannot
693 * determine whether or not a physical
694 * device is currently connected, it
695 * shall also use this peripheral
696 * qualifier when returning the INQUIRY
697 * data. This peripheral qualifier
698 * does not mean that the device is
699 * ready for access by the initiator.
701 #define SID_QUAL_LU_OFFLINE 0x01 /*
702 * The target is capable of supporting
703 * the specified peripheral device type
704 * on this logical unit; however, the
705 * physical device is not currently
706 * connected to this logical unit.
708 #define SID_QUAL_RSVD 0x02
709 #define SID_QUAL_BAD_LU 0x03 /*
710 * The target is not capable of
711 * supporting a physical device on
712 * this logical unit. For this
713 * peripheral qualifier the peripheral
714 * device type shall be set to 1Fh to
715 * provide compatibility with previous
716 * versions of SCSI. All other
717 * peripheral device type values are
718 * reserved for this peripheral
721 #define SID_QUAL_IS_VENDOR_UNIQUE(inq_data) ((SID_QUAL(inq_data) & 0x08) != 0)
723 #define SID_QUAL2 0x7F
724 #define SID_IS_REMOVABLE(inq_data) (((inq_data)->dev_qual2 & 0x80) != 0)
726 #define SID_ANSI_REV(inq_data) ((inq_data)->version & 0x07)
728 #define SCSI_REV_CCS 1
730 #define SCSI_REV_SPC 3
731 #define SCSI_REV_SPC2 4
732 #define SCSI_REV_SPC3 5
733 #define SCSI_REV_SPC4 6
735 #define SID_ECMA 0x38
737 u_int8_t response_format;
738 #define SID_AENC 0x80
739 #define SID_TrmIOP 0x40
740 u_int8_t additional_length;
741 #define SID_ADDITIONAL_LENGTH(iqd) \
742 ((iqd)->additional_length + \
743 offsetof(struct scsi_inquiry_data, additional_length) + 1)
745 #define SPC3_SID_PROTECT 0x01
746 #define SPC3_SID_3PC 0x08
747 #define SPC3_SID_TPGS_MASK 0x30
748 #define SPC3_SID_TPGS_IMPLICIT 0x10
749 #define SPC3_SID_TPGS_EXPLICIT 0x20
750 #define SPC3_SID_ACC 0x40
751 #define SPC3_SID_SCCS 0x80
753 #define SPC2_SID_MChngr 0x08
754 #define SPC2_SID_MultiP 0x10
755 #define SPC2_SID_EncServ 0x40
756 #define SPC2_SID_BQueue 0x80
758 #define INQ_DATA_TQ_ENABLED(iqd) \
759 ((SID_ANSI_REV(iqd) < SCSI_REV_SPC2)? ((iqd)->flags & SID_CmdQue) : \
760 (((iqd)->flags & SID_CmdQue) && !((iqd)->spc2_flags & SPC2_SID_BQueue)) || \
761 (!((iqd)->flags & SID_CmdQue) && ((iqd)->spc2_flags & SPC2_SID_BQueue)))
764 #define SID_SftRe 0x01
765 #define SID_CmdQue 0x02
766 #define SID_Linked 0x08
767 #define SID_Sync 0x10
768 #define SID_WBus16 0x20
769 #define SID_WBus32 0x40
770 #define SID_RelAdr 0x80
771 #define SID_VENDOR_SIZE 8
772 char vendor[SID_VENDOR_SIZE];
773 #define SID_PRODUCT_SIZE 16
774 char product[SID_PRODUCT_SIZE];
775 #define SID_REVISION_SIZE 4
776 char revision[SID_REVISION_SIZE];
778 * The following fields were taken from SCSI Primary Commands - 2
779 * (SPC-2) Revision 14, Dated 11 November 1999
781 #define SID_VENDOR_SPECIFIC_0_SIZE 20
782 u_int8_t vendor_specific0[SID_VENDOR_SPECIFIC_0_SIZE];
784 * An extension of SCSI Parallel Specific Values
786 #define SID_SPI_IUS 0x01
787 #define SID_SPI_QAS 0x02
788 #define SID_SPI_CLOCK_ST 0x00
789 #define SID_SPI_CLOCK_DT 0x04
790 #define SID_SPI_CLOCK_DT_ST 0x0C
791 #define SID_SPI_MASK 0x0F
795 * Version Descriptors, stored 2 byte values.
797 u_int8_t version1[2];
798 u_int8_t version2[2];
799 u_int8_t version3[2];
800 u_int8_t version4[2];
801 u_int8_t version5[2];
802 u_int8_t version6[2];
803 u_int8_t version7[2];
804 u_int8_t version8[2];
806 u_int8_t reserved3[22];
808 #define SID_VENDOR_SPECIFIC_1_SIZE 160
809 u_int8_t vendor_specific1[SID_VENDOR_SPECIFIC_1_SIZE];
812 struct scsi_vpd_supported_page_list
816 #define SVPD_SUPPORTED_PAGE_LIST 0x00
817 #define SVPD_SUPPORTED_PAGES_HDR_LEN 4
819 u_int8_t length; /* number of VPD entries */
820 #define SVPD_SUPPORTED_PAGES_SIZE 251
821 u_int8_t list[SVPD_SUPPORTED_PAGES_SIZE];
825 * This structure is more suited to target operation, because the
826 * number of supported pages is left to the user to allocate.
828 struct scsi_vpd_supported_pages
833 #define SVPD_SUPPORTED_PAGES 0x00
835 u_int8_t page_list[0];
839 struct scsi_vpd_unit_serial_number
843 #define SVPD_UNIT_SERIAL_NUMBER 0x80
845 u_int8_t length; /* serial number length */
846 #define SVPD_SERIAL_NUM_SIZE 251
847 u_int8_t serial_num[SVPD_SERIAL_NUM_SIZE];
850 struct scsi_vpd_device_id
854 #define SVPD_DEVICE_ID 0x83
855 #define SVPD_DEVICE_ID_MAX_SIZE 0xffff
856 #define SVPD_DEVICE_ID_HDR_LEN 4
857 #define SVPD_DEVICE_ID_DESC_HDR_LEN 4
859 u_int8_t desc_list[0];
862 struct scsi_vpd_id_descriptor
864 u_int8_t proto_codeset;
865 #define SCSI_PROTO_FC 0x00
866 #define SCSI_PROTO_SPI 0x01
867 #define SCSI_PROTO_SSA 0x02
868 #define SCSI_PROTO_1394 0x03
869 #define SCSI_PROTO_RDMA 0x04
870 #define SCSI_PROTO_iSCSI 0x05
871 #define SCSI_PROTO_SAS 0x06
872 #define SVPD_ID_PROTO_SHIFT 4
873 #define SVPD_ID_CODESET_BINARY 0x01
874 #define SVPD_ID_CODESET_ASCII 0x02
876 #define SVPD_ID_PIV 0x80
877 #define SVPD_ID_ASSOC_LUN 0x00
878 #define SVPD_ID_ASSOC_PORT 0x10
879 #define SVPD_ID_ASSOC_TARGET 0x20
880 #define SVPD_ID_TYPE_VENDOR 0x00
881 #define SVPD_ID_TYPE_T10 0x01
882 #define SVPD_ID_TYPE_EUI64 0x02
883 #define SVPD_ID_TYPE_NAA 0x03
884 #define SVPD_ID_TYPE_RELTARG 0x04
885 #define SVPD_ID_TYPE_TPORTGRP 0x05
886 #define SVPD_ID_TYPE_LUNGRP 0x06
887 #define SVPD_ID_TYPE_MD5_LUN_ID 0x07
888 #define SVPD_ID_TYPE_SCSI_NAME 0x08
889 #define SVPD_ID_TYPE_MASK 0x0f
892 u_int8_t identifier[0];
895 struct scsi_vpd_id_t10
898 u_int8_t vendor_spec_id[0];
901 struct scsi_vpd_id_eui64
903 u_int8_t ieee_company_id[3];
904 u_int8_t extension_id[5];
907 struct scsi_vpd_id_naa_basic
910 /* big endian, packed:
912 uint8_t naa_desig : 4;
914 #define SVPD_ID_NAA_NAA_SHIFT 4
915 #define SVPD_ID_NAA_IEEE_EXT 0x02
916 #define SVPD_ID_NAA_LOCAL_REG 0x03
917 #define SVPD_ID_NAA_IEEE_REG 0x05
918 #define SVPD_ID_NAA_IEEE_REG_EXT 0x06
922 struct scsi_vpd_id_naa_ieee_extended_id
925 uint8_t vendor_specific_id_a;
926 uint8_t ieee_company_id[3];
927 uint8_t vendor_specific_id_b[4];
930 struct scsi_vpd_id_naa_local_reg
933 uint8_t local_value[7];
936 struct scsi_vpd_id_naa_ieee_reg
939 uint8_t reg_value[7];
940 /* big endian, packed:
941 uint8_t naa_basic : 4;
942 uint8_t ieee_company_id_0 : 4;
943 uint8_t ieee_company_id_1[2];
944 uint8_t ieee_company_id_2 : 4;
945 uint8_t vendor_specific_id_0 : 4;
946 uint8_t vendor_specific_id_1[4];
950 struct scsi_vpd_id_naa_ieee_reg_extended
953 uint8_t reg_value[15];
954 /* big endian, packed:
955 uint8_t naa_basic : 4;
956 uint8_t ieee_company_id_0 : 4;
957 uint8_t ieee_company_id_1[2];
958 uint8_t ieee_company_id_2 : 4;
959 uint8_t vendor_specific_id_0 : 4;
960 uint8_t vendor_specific_id_1[4];
961 uint8_t vendor_specific_id_ext[8];
965 struct scsi_vpd_id_rel_trgt_port_id
968 uint8_t rel_trgt_port_id[2];
971 struct scsi_vpd_id_trgt_port_grp_id
974 uint8_t trgt_port_grp[2];
977 struct scsi_vpd_id_lun_grp_id
980 uint8_t log_unit_grp[2];
983 struct scsi_vpd_id_md5_lun_id
988 struct scsi_vpd_id_scsi_name
990 uint8_t name_string[256];
993 struct scsi_read_capacity
1002 struct scsi_read_capacity_16
1005 #define SRC16_SERVICE_ACTION 0x10
1006 uint8_t service_action;
1008 uint8_t alloc_len[4];
1009 #define SRC16_PMI 0x01
1010 #define SRC16_RELADR 0x02
1015 struct scsi_read_capacity_data
1021 struct scsi_read_capacity_data_long
1027 struct scsi_report_luns
1031 #define RPL_REPORT_DEFAULT 0x00
1032 #define RPL_REPORT_WELLKNOWN 0x01
1033 #define RPL_REPORT_ALL 0x02
1034 uint8_t select_report;
1035 uint8_t reserved2[3];
1041 struct scsi_report_luns_data {
1042 u_int8_t length[4]; /* length of LUN inventory, in bytes */
1043 u_int8_t reserved[4]; /* unused */
1045 * LUN inventory- we only support the type zero form for now.
1048 u_int8_t lundata[8];
1051 #define RPL_LUNDATA_PERIPH_BUS_MASK 0x3f
1052 #define RPL_LUNDATA_FLAT_LUN_MASK 0x3f
1053 #define RPL_LUNDATA_LUN_TARG_MASK 0x3f
1054 #define RPL_LUNDATA_LUN_BUS_MASK 0xe0
1055 #define RPL_LUNDATA_LUN_LUN_MASK 0x1f
1056 #define RPL_LUNDATA_EXT_LEN_MASK 0x30
1057 #define RPL_LUNDATA_EXT_EAM_MASK 0x0f
1058 #define RPL_LUNDATA_EXT_EAM_WK 0x01
1059 #define RPL_LUNDATA_EXT_EAM_NOT_SPEC 0x0f
1060 #define RPL_LUNDATA_ATYP_MASK 0xc0 /* MBZ for type 0 lun */
1061 #define RPL_LUNDATA_ATYP_PERIPH 0x00
1062 #define RPL_LUNDATA_ATYP_FLAT 0x40
1063 #define RPL_LUNDATA_ATYP_LUN 0x80
1064 #define RPL_LUNDATA_ATYP_EXTLUN 0xc0
1066 struct scsi_target_group
1069 uint8_t service_action;
1070 #define STG_PDF_LENGTH 0x00
1071 #define RPL_PDF_EXTENDED 0x20
1072 uint8_t reserved1[4];
1078 struct scsi_target_port_descriptor {
1079 uint8_t reserved[2];
1080 uint8_t relative_target_port_identifier[2];
1081 uint8_t desc_list[];
1084 struct scsi_target_port_group_descriptor {
1086 #define TPG_PRIMARY 0x80
1087 #define TPG_ASYMMETRIC_ACCESS_STATE_MASK 0xf
1088 #define TPG_ASYMMETRIC_ACCESS_OPTIMIZED 0x0
1089 #define TPG_ASYMMETRIC_ACCESS_NONOPTIMIZED 0x1
1090 #define TPG_ASYMMETRIC_ACCESS_STANDBY 0x2
1091 #define TPG_ASYMMETRIC_ACCESS_UNAVAILABLE 0x3
1092 #define TPG_ASYMMETRIC_ACCESS_LBA_DEPENDENT 0x4
1093 #define TPG_ASYMMETRIC_ACCESS_OFFLINE 0xE
1094 #define TPG_ASYMMETRIC_ACCESS_TRANSITIONING 0xF
1096 #define TPG_AO_SUP 0x01
1097 #define TPG_AN_SUP 0x02
1098 #define TPG_S_SUP 0x04
1099 #define TPG_U_SUP 0x08
1100 #define TPG_LBD_SUP 0x10
1101 #define TPG_O_SUP 0x40
1102 #define TPG_T_SUP 0x80
1103 uint8_t target_port_group[2];
1106 uint8_t vendor_specific;
1107 uint8_t target_port_count;
1108 struct scsi_target_port_descriptor descriptors[];
1111 struct scsi_target_group_data {
1112 uint8_t length[4]; /* length of returned data, in bytes */
1113 struct scsi_target_port_group_descriptor groups[];
1116 struct scsi_target_group_data_extended {
1117 uint8_t length[4]; /* length of returned data, in bytes */
1118 uint8_t format_type; /* STG_PDF_LENGTH or RPL_PDF_EXTENDED */
1119 uint8_t implicit_transition_time;
1120 uint8_t reserved[2];
1121 struct scsi_target_port_group_descriptor groups[];
1125 struct scsi_sense_data
1127 u_int8_t error_code;
1128 #define SSD_ERRCODE 0x7F
1129 #define SSD_CURRENT_ERROR 0x70
1130 #define SSD_DEFERRED_ERROR 0x71
1131 #define SSD_ERRCODE_VALID 0x80
1134 #define SSD_KEY 0x0F
1135 #define SSD_KEY_NO_SENSE 0x00
1136 #define SSD_KEY_RECOVERED_ERROR 0x01
1137 #define SSD_KEY_NOT_READY 0x02
1138 #define SSD_KEY_MEDIUM_ERROR 0x03
1139 #define SSD_KEY_HARDWARE_ERROR 0x04
1140 #define SSD_KEY_ILLEGAL_REQUEST 0x05
1141 #define SSD_KEY_UNIT_ATTENTION 0x06
1142 #define SSD_KEY_DATA_PROTECT 0x07
1143 #define SSD_KEY_BLANK_CHECK 0x08
1144 #define SSD_KEY_Vendor_Specific 0x09
1145 #define SSD_KEY_COPY_ABORTED 0x0a
1146 #define SSD_KEY_ABORTED_COMMAND 0x0b
1147 #define SSD_KEY_EQUAL 0x0c
1148 #define SSD_KEY_VOLUME_OVERFLOW 0x0d
1149 #define SSD_KEY_MISCOMPARE 0x0e
1150 #define SSD_KEY_RESERVED 0x0f
1151 #define SSD_ILI 0x20
1152 #define SSD_EOM 0x40
1153 #define SSD_FILEMARK 0x80
1156 u_int8_t cmd_spec_info[4];
1157 u_int8_t add_sense_code;
1158 u_int8_t add_sense_code_qual;
1160 u_int8_t sense_key_spec[3];
1161 #define SSD_SCS_VALID 0x80
1162 #define SSD_FIELDPTR_CMD 0x40
1163 #define SSD_BITPTR_VALID 0x08
1164 #define SSD_BITPTR_VALUE 0x07
1165 #define SSD_MIN_SIZE 18
1166 u_int8_t extra_bytes[14];
1167 #define SSD_FULL_SIZE sizeof(struct scsi_sense_data)
1170 struct scsi_mode_header_6
1172 u_int8_t data_length; /* Sense data length */
1173 u_int8_t medium_type;
1175 u_int8_t blk_desc_len;
1178 struct scsi_mode_header_10
1180 u_int8_t data_length[2];/* Sense data length */
1181 u_int8_t medium_type;
1184 u_int8_t blk_desc_len[2];
1187 struct scsi_mode_page_header
1190 u_int8_t page_length;
1193 struct scsi_mode_blk_desc
1196 u_int8_t nblocks[3];
1201 #define SCSI_DEFAULT_DENSITY 0x00 /* use 'default' density */
1202 #define SCSI_SAME_DENSITY 0x7f /* use 'same' density- >= SCSI-2 only */
1208 #define SCSI_STATUS_OK 0x00
1209 #define SCSI_STATUS_CHECK_COND 0x02
1210 #define SCSI_STATUS_COND_MET 0x04
1211 #define SCSI_STATUS_BUSY 0x08
1212 #define SCSI_STATUS_INTERMED 0x10
1213 #define SCSI_STATUS_INTERMED_COND_MET 0x14
1214 #define SCSI_STATUS_RESERV_CONFLICT 0x18
1215 #define SCSI_STATUS_CMD_TERMINATED 0x22 /* Obsolete in SAM-2 */
1216 #define SCSI_STATUS_QUEUE_FULL 0x28
1217 #define SCSI_STATUS_ACA_ACTIVE 0x30
1218 #define SCSI_STATUS_TASK_ABORTED 0x40
1220 struct scsi_inquiry_pattern {
1222 u_int8_t media_type;
1223 #define SIP_MEDIA_REMOVABLE 0x01
1224 #define SIP_MEDIA_FIXED 0x02
1226 const char *product;
1227 const char *revision;
1230 struct scsi_static_inquiry_pattern {
1232 u_int8_t media_type;
1233 char vendor[SID_VENDOR_SIZE+1];
1234 char product[SID_PRODUCT_SIZE+1];
1235 char revision[SID_REVISION_SIZE+1];
1238 struct scsi_sense_quirk_entry {
1239 struct scsi_inquiry_pattern inq_pat;
1242 struct sense_key_table_entry *sense_key_info;
1243 struct asc_table_entry *asc_info;
1246 struct sense_key_table_entry {
1252 struct asc_table_entry {
1259 struct op_table_entry {
1265 struct scsi_op_quirk_entry {
1266 struct scsi_inquiry_pattern inq_pat;
1268 struct op_table_entry *op_table;
1272 SSS_FLAG_NONE = 0x00,
1273 SSS_FLAG_PRINT_COMMAND = 0x01
1274 } scsi_sense_string_flags;
1283 extern const char *scsi_sense_key_text[];
1288 void scsi_sense_desc(int sense_key, int asc, int ascq,
1289 struct scsi_inquiry_data *inq_data,
1290 const char **sense_key_desc, const char **asc_desc);
1291 scsi_sense_action scsi_error_action(struct ccb_scsiio* csio,
1292 struct scsi_inquiry_data *inq_data,
1293 u_int32_t sense_flags);
1294 const char * scsi_status_string(struct ccb_scsiio *csio);
1296 int scsi_command_string(struct ccb_scsiio *csio, struct sbuf *sb);
1297 int scsi_sense_sbuf(struct ccb_scsiio *csio, struct sbuf *sb,
1298 scsi_sense_string_flags flags);
1299 char * scsi_sense_string(struct ccb_scsiio *csio,
1300 char *str, int str_len);
1301 void scsi_sense_print(struct ccb_scsiio *csio);
1302 int scsi_interpret_sense(union ccb *ccb,
1303 u_int32_t sense_flags,
1304 u_int32_t *relsim_flags,
1305 u_int32_t *reduction,
1307 scsi_sense_action error_action);
1309 int scsi_command_string(struct cam_device *device,
1310 struct ccb_scsiio *csio, struct sbuf *sb);
1311 int scsi_sense_sbuf(struct cam_device *device,
1312 struct ccb_scsiio *csio, struct sbuf *sb,
1313 scsi_sense_string_flags flags);
1314 char * scsi_sense_string(struct cam_device *device,
1315 struct ccb_scsiio *csio,
1316 char *str, int str_len);
1317 void scsi_sense_print(struct cam_device *device,
1318 struct ccb_scsiio *csio, FILE *ofile);
1319 int scsi_interpret_sense(struct cam_device *device,
1321 u_int32_t sense_flags,
1322 u_int32_t *relsim_flags,
1323 u_int32_t *reduction,
1325 scsi_sense_action error_action);
1326 #endif /* _KERNEL */
1328 #define SF_RETRY_UA 0x01
1329 #define SF_NO_PRINT 0x02
1330 #define SF_QUIET_IR 0x04 /* Be quiet about Illegal Request reponses */
1331 #define SF_PRINT_ALWAYS 0x08
1334 const char * scsi_op_desc(u_int16_t opcode,
1335 struct scsi_inquiry_data *inq_data);
1336 char * scsi_cdb_string(u_int8_t *cdb_ptr, char *cdb_string,
1339 void scsi_print_inquiry(struct scsi_inquiry_data *inq_data);
1341 u_int scsi_calc_syncsrate(u_int period_factor);
1342 u_int scsi_calc_syncparam(u_int period);
1344 typedef int (*scsi_devid_checkfn_t)(uint8_t *);
1345 int scsi_devid_is_naa_ieee_reg(uint8_t *bufp);
1346 int scsi_devid_is_sas_target(uint8_t *bufp);
1347 uint8_t * scsi_get_devid(struct scsi_vpd_device_id *id, uint32_t len,
1348 scsi_devid_checkfn_t ck_fn);
1350 void scsi_test_unit_ready(struct ccb_scsiio *csio, u_int32_t retries,
1351 void (*cbfcnp)(struct cam_periph *,
1353 u_int8_t tag_action,
1354 u_int8_t sense_len, u_int32_t timeout);
1356 void scsi_request_sense(struct ccb_scsiio *csio, u_int32_t retries,
1357 void (*cbfcnp)(struct cam_periph *,
1359 void *data_ptr, u_int8_t dxfer_len,
1360 u_int8_t tag_action, u_int8_t sense_len,
1363 void scsi_inquiry(struct ccb_scsiio *csio, u_int32_t retries,
1364 void (*cbfcnp)(struct cam_periph *, union ccb *),
1365 u_int8_t tag_action, u_int8_t *inq_buf,
1366 u_int32_t inq_len, int evpd, u_int8_t page_code,
1367 u_int8_t sense_len, u_int32_t timeout);
1369 void scsi_mode_sense(struct ccb_scsiio *csio, u_int32_t retries,
1370 void (*cbfcnp)(struct cam_periph *,
1372 u_int8_t tag_action, int dbd,
1373 u_int8_t page_code, u_int8_t page,
1374 u_int8_t *param_buf, u_int32_t param_len,
1375 u_int8_t sense_len, u_int32_t timeout);
1377 void scsi_mode_sense_len(struct ccb_scsiio *csio, u_int32_t retries,
1378 void (*cbfcnp)(struct cam_periph *,
1380 u_int8_t tag_action, int dbd,
1381 u_int8_t page_code, u_int8_t page,
1382 u_int8_t *param_buf, u_int32_t param_len,
1383 int minimum_cmd_size, u_int8_t sense_len,
1386 void scsi_mode_select(struct ccb_scsiio *csio, u_int32_t retries,
1387 void (*cbfcnp)(struct cam_periph *,
1389 u_int8_t tag_action, int scsi_page_fmt,
1390 int save_pages, u_int8_t *param_buf,
1391 u_int32_t param_len, u_int8_t sense_len,
1394 void scsi_mode_select_len(struct ccb_scsiio *csio, u_int32_t retries,
1395 void (*cbfcnp)(struct cam_periph *,
1397 u_int8_t tag_action, int scsi_page_fmt,
1398 int save_pages, u_int8_t *param_buf,
1399 u_int32_t param_len, int minimum_cmd_size,
1400 u_int8_t sense_len, u_int32_t timeout);
1402 void scsi_log_sense(struct ccb_scsiio *csio, u_int32_t retries,
1403 void (*cbfcnp)(struct cam_periph *, union ccb *),
1404 u_int8_t tag_action, u_int8_t page_code,
1405 u_int8_t page, int save_pages, int ppc,
1406 u_int32_t paramptr, u_int8_t *param_buf,
1407 u_int32_t param_len, u_int8_t sense_len,
1410 void scsi_log_select(struct ccb_scsiio *csio, u_int32_t retries,
1411 void (*cbfcnp)(struct cam_periph *,
1412 union ccb *), u_int8_t tag_action,
1413 u_int8_t page_code, int save_pages,
1414 int pc_reset, u_int8_t *param_buf,
1415 u_int32_t param_len, u_int8_t sense_len,
1418 void scsi_prevent(struct ccb_scsiio *csio, u_int32_t retries,
1419 void (*cbfcnp)(struct cam_periph *, union ccb *),
1420 u_int8_t tag_action, u_int8_t action,
1421 u_int8_t sense_len, u_int32_t timeout);
1423 void scsi_read_capacity(struct ccb_scsiio *csio, u_int32_t retries,
1424 void (*cbfcnp)(struct cam_periph *,
1425 union ccb *), u_int8_t tag_action,
1426 struct scsi_read_capacity_data *,
1427 u_int8_t sense_len, u_int32_t timeout);
1428 void scsi_read_capacity_16(struct ccb_scsiio *csio, uint32_t retries,
1429 void (*cbfcnp)(struct cam_periph *,
1430 union ccb *), uint8_t tag_action,
1431 uint64_t lba, int reladr, int pmi,
1432 struct scsi_read_capacity_data_long
1433 *rcap_buf, uint8_t sense_len,
1436 void scsi_report_luns(struct ccb_scsiio *csio, u_int32_t retries,
1437 void (*cbfcnp)(struct cam_periph *,
1438 union ccb *), u_int8_t tag_action,
1439 u_int8_t select_report,
1440 struct scsi_report_luns_data *rpl_buf,
1441 u_int32_t alloc_len, u_int8_t sense_len,
1444 void scsi_report_target_group(struct ccb_scsiio *csio, u_int32_t retries,
1445 void (*cbfcnp)(struct cam_periph *,
1446 union ccb *), u_int8_t tag_action,
1449 u_int32_t alloc_len, u_int8_t sense_len,
1452 void scsi_set_target_group(struct ccb_scsiio *csio, u_int32_t retries,
1453 void (*cbfcnp)(struct cam_periph *,
1454 union ccb *), u_int8_t tag_action, void *buf,
1455 u_int32_t alloc_len, u_int8_t sense_len,
1458 void scsi_synchronize_cache(struct ccb_scsiio *csio,
1460 void (*cbfcnp)(struct cam_periph *,
1461 union ccb *), u_int8_t tag_action,
1462 u_int32_t begin_lba, u_int16_t lb_count,
1463 u_int8_t sense_len, u_int32_t timeout);
1465 void scsi_receive_diagnostic_results(struct ccb_scsiio *csio, u_int32_t retries,
1466 void (*cbfcnp)(struct cam_periph *,
1468 uint8_t tag_action, int pcv,
1469 uint8_t page_code, uint8_t *data_ptr,
1470 uint16_t allocation_length,
1471 uint8_t sense_len, uint32_t timeout);
1473 void scsi_send_diagnostic(struct ccb_scsiio *csio, u_int32_t retries,
1474 void (*cbfcnp)(struct cam_periph *, union ccb *),
1475 uint8_t tag_action, int unit_offline,
1476 int device_offline, int self_test, int page_format,
1477 int self_test_code, uint8_t *data_ptr,
1478 uint16_t param_list_length, uint8_t sense_len,
1481 void scsi_read_write(struct ccb_scsiio *csio, u_int32_t retries,
1482 void (*cbfcnp)(struct cam_periph *, union ccb *),
1483 u_int8_t tag_action, int readop, u_int8_t byte2,
1484 int minimum_cmd_size, u_int64_t lba,
1485 u_int32_t block_count, u_int8_t *data_ptr,
1486 u_int32_t dxfer_len, u_int8_t sense_len,
1489 void scsi_start_stop(struct ccb_scsiio *csio, u_int32_t retries,
1490 void (*cbfcnp)(struct cam_periph *, union ccb *),
1491 u_int8_t tag_action, int start, int load_eject,
1492 int immediate, u_int8_t sense_len, u_int32_t timeout);
1494 int scsi_inquiry_match(caddr_t inqbuffer, caddr_t table_entry);
1495 int scsi_static_inquiry_match(caddr_t inqbuffer,
1496 caddr_t table_entry);
1497 int scsi_devid_match(uint8_t *rhs, size_t rhs_len,
1498 uint8_t *lhs, size_t lhs_len);
1500 static __inline void scsi_extract_sense(struct scsi_sense_data *sense,
1501 int *error_code, int *sense_key,
1502 int *asc, int *ascq);
1503 static __inline void scsi_ulto2b(u_int32_t val, u_int8_t *bytes);
1504 static __inline void scsi_ulto3b(u_int32_t val, u_int8_t *bytes);
1505 static __inline void scsi_ulto4b(u_int32_t val, u_int8_t *bytes);
1506 static __inline void scsi_u64to8b(u_int64_t val, u_int8_t *bytes);
1507 static __inline u_int32_t scsi_2btoul(u_int8_t *bytes);
1508 static __inline u_int32_t scsi_3btoul(u_int8_t *bytes);
1509 static __inline int32_t scsi_3btol(u_int8_t *bytes);
1510 static __inline u_int32_t scsi_4btoul(u_int8_t *bytes);
1511 static __inline u_int64_t scsi_8btou64(u_int8_t *bytes);
1512 static __inline void *find_mode_page_6(struct scsi_mode_header_6 *mode_header);
1513 static __inline void *find_mode_page_10(struct scsi_mode_header_10 *mode_header);
1515 static __inline void scsi_extract_sense(struct scsi_sense_data *sense,
1516 int *error_code, int *sense_key,
1517 int *asc, int *ascq)
1519 *error_code = sense->error_code & SSD_ERRCODE;
1520 *sense_key = sense->flags & SSD_KEY;
1521 *asc = (sense->extra_len >= 5) ? sense->add_sense_code : 0;
1522 *ascq = (sense->extra_len >= 6) ? sense->add_sense_code_qual : 0;
1525 static __inline void
1526 scsi_ulto2b(u_int32_t val, u_int8_t *bytes)
1529 bytes[0] = (val >> 8) & 0xff;
1530 bytes[1] = val & 0xff;
1533 static __inline void
1534 scsi_ulto3b(u_int32_t val, u_int8_t *bytes)
1537 bytes[0] = (val >> 16) & 0xff;
1538 bytes[1] = (val >> 8) & 0xff;
1539 bytes[2] = val & 0xff;
1542 static __inline void
1543 scsi_ulto4b(u_int32_t val, u_int8_t *bytes)
1546 bytes[0] = (val >> 24) & 0xff;
1547 bytes[1] = (val >> 16) & 0xff;
1548 bytes[2] = (val >> 8) & 0xff;
1549 bytes[3] = val & 0xff;
1552 static __inline void
1553 scsi_u64to8b(u_int64_t val, u_int8_t *bytes)
1556 bytes[0] = (val >> 56) & 0xff;
1557 bytes[1] = (val >> 48) & 0xff;
1558 bytes[2] = (val >> 40) & 0xff;
1559 bytes[3] = (val >> 32) & 0xff;
1560 bytes[4] = (val >> 24) & 0xff;
1561 bytes[5] = (val >> 16) & 0xff;
1562 bytes[6] = (val >> 8) & 0xff;
1563 bytes[7] = val & 0xff;
1566 static __inline u_int32_t
1567 scsi_2btoul(u_int8_t *bytes)
1571 rv = (bytes[0] << 8) |
1576 static __inline u_int32_t
1577 scsi_3btoul(u_int8_t *bytes)
1581 rv = (bytes[0] << 16) |
1587 static __inline int32_t
1588 scsi_3btol(u_int8_t *bytes)
1590 u_int32_t rc = scsi_3btoul(bytes);
1592 if (rc & 0x00800000)
1595 return (int32_t) rc;
1598 static __inline u_int32_t
1599 scsi_4btoul(u_int8_t *bytes)
1603 rv = (bytes[0] << 24) |
1610 static __inline uint64_t
1611 scsi_8btou64(uint8_t *bytes)
1615 rv = (((uint64_t)bytes[0]) << 56) |
1616 (((uint64_t)bytes[1]) << 48) |
1617 (((uint64_t)bytes[2]) << 40) |
1618 (((uint64_t)bytes[3]) << 32) |
1619 (((uint64_t)bytes[4]) << 24) |
1620 (((uint64_t)bytes[5]) << 16) |
1621 (((uint64_t)bytes[6]) << 8) |
1627 * Given the pointer to a returned mode sense buffer, return a pointer to
1628 * the start of the first mode page.
1630 static __inline void *
1631 find_mode_page_6(struct scsi_mode_header_6 *mode_header)
1635 page_start = (void *)((u_int8_t *)&mode_header[1] +
1636 mode_header->blk_desc_len);
1641 static __inline void *
1642 find_mode_page_10(struct scsi_mode_header_10 *mode_header)
1646 page_start = (void *)((u_int8_t *)&mode_header[1] +
1647 scsi_2btoul(mode_header->blk_desc_len));
1654 #endif /*_SCSI_SCSI_ALL_H*/