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