1 /* $NetBSD: sbp.h,v 1.3 2006/02/25 02:28:58 wiz Exp $ */ 2 /*- 3 * Copyright (c) 2003 Hidetoshi Shimokawa 4 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the acknowledgement as bellow: 17 * 18 * This product includes software developed by K. Kobayashi and H. Shimokawa 19 * 20 * 4. The name of the author may not be used to endorse or promote products 21 * derived from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * POSSIBILITY OF SUCH DAMAGE. 34 * 35 * $FreeBSD: /repoman/r/ncvs/src/sys/dev/firewire/sbp.h,v 1.5 2005/01/06 01:42:41 imp Exp $ 36 * 37 */ 38 39 #define ORB_NOTIFY (1 << 31) 40 #define ORB_FMT_STD (0 << 29) 41 #define ORB_FMT_VED (2 << 29) 42 #define ORB_FMT_NOP (3 << 29) 43 #define ORB_FMT_MSK (3 << 29) 44 #define ORB_EXV (1 << 28) 45 /* */ 46 #define ORB_CMD_IN (1 << 27) 47 /* */ 48 #define ORB_CMD_SPD(x) ((x) << 24) 49 #define ORB_CMD_MAXP(x) ((x) << 20) 50 #define ORB_RCN_TMO(x) ((x) << 20) 51 #define ORB_CMD_PTBL (1 << 19) 52 #define ORB_CMD_PSZ(x) ((x) << 16) 53 54 #define ORB_FUN_LGI (0 << 16) 55 #define ORB_FUN_QLG (1 << 16) 56 #define ORB_FUN_RCN (3 << 16) 57 #define ORB_FUN_LGO (7 << 16) 58 #define ORB_FUN_ATA (0xb << 16) 59 #define ORB_FUN_ATS (0xc << 16) 60 #define ORB_FUN_LUR (0xe << 16) 61 #define ORB_FUN_RST (0xf << 16) 62 #define ORB_FUN_MSK (0xf << 16) 63 #define ORB_FUN_RUNQUEUE 0xffff 64 65 #define SBP_DEBUG(x) if (debug > x) { 66 #define END_DEBUG } 67 68 struct ind_ptr { 69 uint32_t hi,lo; 70 }; 71 72 73 #define SBP_RECV_LEN 32 74 75 struct sbp_login_res{ 76 uint16_t len; 77 uint16_t id; 78 uint16_t res0; 79 uint16_t cmd_hi; 80 uint32_t cmd_lo; 81 uint16_t res1; 82 uint16_t recon_hold; 83 }; 84 85 struct sbp_status{ 86 #if BYTE_ORDER == BIG_ENDIAN 87 uint8_t src:2, 88 resp:2, 89 dead:1, 90 len:3; 91 #else 92 uint8_t len:3, 93 dead:1, 94 resp:2, 95 src:2; 96 #endif 97 uint8_t status; 98 uint16_t orb_hi; 99 uint32_t orb_lo; 100 uint32_t data[6]; 101 }; 102 /* src */ 103 #define SRC_NEXT_EXISTS 0 104 #define SRC_NO_NEXT 1 105 #define SRC_UNSOL 2 106 107 /* resp */ 108 #define SBP_REQ_CMP 0 /* request complete */ 109 #define SBP_TRANS_FAIL 1 /* transport failure */ 110 #define SBP_ILLE_REQ 2 /* illegal request */ 111 #define SBP_VEND_DEP 3 /* vendor dependent */ 112 113 /* status (resp == 0) */ 114 /* 0: No additional Information to report */ 115 /* 1: Request Type not supported */ 116 /* 2: Speed not supported */ 117 /* 3: Page size not supported */ 118 /* 4: Access denied */ 119 #define STATUS_ACCESS_DENY 4 120 /* 5: Logical unit not supported */ 121 /* 6: Maximum payload too small */ 122 /* 7: Reserved for future standardization */ 123 /* 8: Resource unavailabe */ 124 #define STATUS_RES_UNAVAIL 8 125 /* 9: Function Rejected */ 126 /* 10: Login ID not recognized */ 127 /* 11: Dummy ORB completed */ 128 /* 12: Request aborted */ 129 /* 255: Unspecified error */ 130 131 /* status (resp == 1) */ 132 /* Referenced object */ 133 #define OBJ_ORB (0 << 6) /* 0: ORB */ 134 #define OBJ_DATA (1 << 6) /* 1: Data buffer */ 135 #define OBJ_PT (2 << 6) /* 2: Page table */ 136 #define OBJ_UNSPEC (3 << 6) /* 3: Unable to specify */ 137 /* Serial bus error */ 138 /* 0: Missing acknowledge */ 139 /* 1: Reserved; not to be used */ 140 /* 2: Time-out error */ 141 #define SBE_TIMEOUT 2 142 /* 3: Reserved; not to be used */ 143 /* 4: Busy retry limit exceeded: ack_busy_X */ 144 /* 5: Busy retry limit exceeded: ack_busy_A */ 145 /* 6: Busy retry limit exceeded: ack_busy_B */ 146 /* 7-A: Reserved for future standardization */ 147 /* B: Tardy retry limit exceeded */ 148 /* C: Confilict error */ 149 /* D: Data error */ 150 /* E: Type error */ 151 /* F: Address error */ 152 153 154 struct sbp_cmd_status{ 155 #define SBP_SFMT_CURR 0 156 #define SBP_SFMT_DEFER 1 157 #if BYTE_ORDER == BIG_ENDIAN 158 uint8_t sfmt:2, 159 status:6; 160 uint8_t valid:1, 161 mark:1, 162 eom:1, 163 ill_len:1, 164 s_key:4; 165 #else 166 uint8_t status:6, 167 sfmt:2; 168 uint8_t s_key:4, 169 ill_len:1, 170 eom:1, 171 mark:1, 172 valid:1; 173 #endif 174 uint8_t s_code; 175 uint8_t s_qlfr; 176 uint32_t info; 177 uint32_t cdb; 178 uint8_t fru; 179 uint8_t s_keydep[3]; 180 uint32_t vend[2]; 181 }; 182 183 #define ORB_FUN_NAMES \ 184 /* 0 */ "LOGIN", \ 185 /* 1 */ "QUERY LOGINS", \ 186 /* 2 */ "Reserved", \ 187 /* 3 */ "RECONNECT", \ 188 /* 4 */ "SET PASSWORD", \ 189 /* 5 */ "Reserved", \ 190 /* 6 */ "Reserved", \ 191 /* 7 */ "LOGOUT", \ 192 /* 8 */ "Reserved", \ 193 /* 9 */ "Reserved", \ 194 /* A */ "Reserved", \ 195 /* B */ "ABORT TASK", \ 196 /* C */ "ABORT TASK SET", \ 197 /* D */ "Reserved", \ 198 /* E */ "LOGICAL UNIT RESET", \ 199 /* F */ "TARGET RESET" 200 201 202 struct scsi3_inquiry_data { 203 uint8_t device; 204 uint8_t reserved0; 205 uint8_t version; 206 uint8_t rdf; /* Response data format */ 207 uint8_t additional_length; 208 uint8_t reserved1; 209 uint8_t flags[2]; 210 char vendor[8]; 211 char product[16]; 212 char revision[4]; 213 u_int8_t vendor_specific[20]; 214 }; 215 typedef struct scsi3_inquiry_data *scsi3_inquiry_data_t; 216 217 struct scsi3_sense_data { 218 uint8_t response_code; 219 #define SSD_RESPONSE_CODE_VALID 0x80 220 uint8_t segment_number; 221 uint8_t flags; 222 uint8_t information[4]; 223 uint8_t asl; /* Additional sense length */ 224 uint8_t csi[4]; /* Command-specific information */ 225 uint8_t asc; /* Additional sense code */ 226 uint8_t ascq; /* Additional sense code qualifier */ 227 uint8_t fruc; /* Field replaceable unit code */ 228 uint8_t sks[3]; /* Sense-key specific */ 229 uint8_t asb[14]; /* Additional sense bytes */ 230 }; 231 typedef struct scsi3_sense_data *scsi3_sense_data_t; 232