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