1 #ifndef SG_LIB_DATA_H 2 #define SG_LIB_DATA_H 3 4 /* 5 * Copyright (c) 2007-2021 Douglas Gilbert. 6 * All rights reserved. 7 * Use of this source code is governed by a BSD-style 8 * license that can be found in the BSD_LICENSE file. 9 * 10 * SPDX-License-Identifier: BSD-2-Clause 11 */ 12 13 /* 14 * This header file contains some structure declarations and array name 15 * declarations which are defined in the sg_lib_data.c . 16 * Typically this header does not need to be exposed to users of the 17 * sg_lib interface declared in sg_libs.h . 18 */ 19 20 #include <stdint.h> 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 /* Operation codes with associated service actions that change or qualify 27 * the command name */ 28 #define SG_EXTENDED_COPY 0x83 /* since spc4r34 became next entry */ 29 #define SG_3PARTY_COPY_OUT 0x83 /* new in spc4r34: Third party copy out */ 30 #define SG_RECEIVE_COPY 0x84 /* since spc4r34 became next entry */ 31 #define SG_3PARTY_COPY_IN 0x84 /* new in spc4r34: Third party copy in */ 32 #define SG_MAINTENANCE_IN 0xa3 33 #define SG_MAINTENANCE_OUT 0xa4 34 #define SG_PERSISTENT_RESERVE_IN 0x5e 35 #define SG_PERSISTENT_RESERVE_OUT 0x5f 36 #define SG_READ_ATTRIBUTE 0x8c 37 #define SG_READ_BUFFER 0x3c /* now READ BUFFER(10) */ 38 #define SG_READ_BUFFER_16 0x9b 39 #define SG_READ_POSITION 0x34 /* SSC command with service actions */ 40 #define SG_SANITIZE 0x48 41 #define SG_SERVICE_ACTION_BIDI 0x9d 42 #define SG_SERVICE_ACTION_IN_12 0xab 43 #define SG_SERVICE_ACTION_IN_16 0x9e 44 #define SG_SERVICE_ACTION_OUT_12 0xa9 45 #define SG_SERVICE_ACTION_OUT_16 0x9f 46 #define SG_VARIABLE_LENGTH_CMD 0x7f 47 #define SG_WRITE_BUFFER 0x3b 48 #define SG_ZONING_OUT 0x94 49 #define SG_ZBC_OUT SG_ZONING_OUT /* as SPC calls them */ 50 #define SG_ZONING_IN 0x95 51 #define SG_ZBC_IN SG_ZONING_IN /* as SPC calls them */ 52 53 54 55 struct sg_lib_simple_value_name_t { 56 int value; 57 const char * name; 58 }; 59 60 struct sg_lib_value_name_t { 61 int value; 62 int peri_dev_type; /* 0 -> SPC and/or PDT_DISK, >0 -> PDT */ 63 const char * name; 64 }; 65 66 struct sg_value_2names_t { 67 int value; 68 const char * name; 69 const char * name2; 70 }; 71 72 struct sg_lib_asc_ascq_t { 73 uint8_t asc; /* additional sense code */ 74 uint8_t ascq; /* additional sense code qualifier */ 75 const char * text; 76 }; 77 78 struct sg_lib_asc_ascq_range_t { 79 uint8_t asc; /* additional sense code (ASC) */ 80 uint8_t ascq_min; /* ASCQ minimum in range */ 81 uint8_t ascq_max; /* ASCQ maximum in range */ 82 const char * text; 83 }; 84 85 /* First use: SCSI status, sense_key, asc, ascq tuple */ 86 struct sg_lib_4tuple_u8 { 87 uint8_t t1; 88 uint8_t t2; 89 uint8_t t3; 90 uint8_t t4; 91 }; 92 93 struct sg_cmd_response_t { 94 int din_len; 95 int dout_len; 96 int resid; 97 int resid2; 98 const uint8_t * sbp; 99 }; 100 101 102 extern const char * sg_lib_version_str; 103 104 extern struct sg_lib_value_name_t sg_lib_normal_opcodes[]; 105 extern struct sg_lib_value_name_t sg_lib_read_buff_arr[]; 106 extern struct sg_lib_value_name_t sg_lib_write_buff_arr[]; 107 extern struct sg_lib_value_name_t sg_lib_maint_in_arr[]; 108 extern struct sg_lib_value_name_t sg_lib_maint_out_arr[]; 109 extern struct sg_lib_value_name_t sg_lib_pr_in_arr[]; 110 extern struct sg_lib_value_name_t sg_lib_pr_out_arr[]; 111 extern struct sg_lib_value_name_t sg_lib_sanitize_sa_arr[]; 112 extern struct sg_lib_value_name_t sg_lib_serv_in12_arr[]; 113 extern struct sg_lib_value_name_t sg_lib_serv_out12_arr[]; 114 extern struct sg_lib_value_name_t sg_lib_serv_in16_arr[]; 115 extern struct sg_lib_value_name_t sg_lib_serv_out16_arr[]; 116 extern struct sg_lib_value_name_t sg_lib_serv_bidi_arr[]; 117 extern struct sg_lib_value_name_t sg_lib_xcopy_sa_arr[]; 118 extern struct sg_lib_value_name_t sg_lib_rec_copy_sa_arr[]; 119 extern struct sg_lib_value_name_t sg_lib_variable_length_arr[]; 120 extern struct sg_lib_value_name_t sg_lib_zoning_out_arr[]; 121 extern struct sg_lib_value_name_t sg_lib_zoning_in_arr[]; 122 extern struct sg_lib_value_name_t sg_lib_read_attr_arr[]; 123 extern struct sg_lib_value_name_t sg_lib_read_pos_arr[]; 124 extern struct sg_lib_asc_ascq_range_t sg_lib_asc_ascq_range[]; 125 extern struct sg_lib_simple_value_name_t sg_lib_sstatus_str_arr[]; 126 extern struct sg_lib_asc_ascq_t sg_lib_asc_ascq[]; 127 extern struct sg_lib_value_name_t sg_lib_scsi_feature_sets[]; 128 extern const char * sg_lib_sense_key_desc[]; 129 extern const char * sg_lib_pdt_strs[]; 130 extern const char * sg_lib_transport_proto_strs[]; 131 extern const char * sg_lib_tapealert_strs[]; 132 extern int sg_lib_pdt_decay_arr[]; 133 134 extern struct sg_lib_simple_value_name_t sg_lib_nvme_admin_cmd_arr[]; 135 extern struct sg_lib_simple_value_name_t sg_lib_nvme_nvm_cmd_arr[]; 136 extern struct sg_lib_value_name_t sg_lib_nvme_cmd_status_arr[]; 137 extern struct sg_lib_4tuple_u8 sg_lib_scsi_status_sense_arr[]; 138 139 extern struct sg_value_2names_t sg_exit_str_arr[]; 140 141 #ifdef __cplusplus 142 } 143 #endif 144 145 #endif 146