1 | /* $NetBSD: sbp.h,v 1.6 2010/08/29 21:14:16 cegger 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: src/sys/dev/firewire/sbp.h,v 1.6 2009/04/07 02:33:46 sbruno Exp $ |
36 | * |
37 | */ |
38 | #ifndef _SBP_H_ |
39 | #define _SBP_H_ |
40 | |
41 | #define ORB_NOTIFY (1 << 31) |
42 | #define ORB_FMT_STD (0 << 29) |
43 | #define ORB_FMT_VED (2 << 29) |
44 | #define ORB_FMT_NOP (3 << 29) |
45 | #define ORB_FMT_MSK (3 << 29) |
46 | #define ORB_EXV (1 << 28) |
47 | /* */ |
48 | #define ORB_CMD_IN (1 << 27) |
49 | /* */ |
50 | #define ORB_CMD_SPD(x) ((x) << 24) |
51 | #define ORB_CMD_MAXP(x) ((x) << 20) |
52 | #define ORB_RCN_TMO(x) ((x) << 20) |
53 | #define ORB_CMD_PTBL (1 << 19) |
54 | #define ORB_CMD_PSZ(x) ((x) << 16) |
55 | |
56 | #define ORB_FUN_LGI (0 << 16) |
57 | #define ORB_FUN_QLG (1 << 16) |
58 | #define ORB_FUN_RCN (3 << 16) |
59 | #define ORB_FUN_LGO (7 << 16) |
60 | #define ORB_FUN_ATA (0xb << 16) |
61 | #define ORB_FUN_ATS (0xc << 16) |
62 | #define ORB_FUN_LUR (0xe << 16) |
63 | #define ORB_FUN_RST (0xf << 16) |
64 | #define ORB_FUN_MSK (0xf << 16) |
65 | #define ORB_FUN_RUNQUEUE 0xffff |
66 | |
67 | #define SBP_DEBUG(x) if (debug > x) { |
68 | #define END_DEBUG } |
69 | |
70 | struct ind_ptr { |
71 | uint32_t hi,lo; |
72 | }; |
73 | |
74 | |
75 | #define SBP_RECV_LEN 32 |
76 | |
77 | struct sbp_login_res{ |
78 | uint16_t len; |
79 | uint16_t id; |
80 | uint16_t res0; |
81 | uint16_t cmd_hi; |
82 | uint32_t cmd_lo; |
83 | uint16_t res1; |
84 | uint16_t recon_hold; |
85 | }; |
86 | |
87 | struct sbp_status{ |
88 | #if BYTE_ORDER == BIG_ENDIAN |
89 | uint8_t src:2, |
90 | resp:2, |
91 | dead:1, |
92 | len:3; |
93 | #else |
94 | uint8_t len:3, |
95 | dead:1, |
96 | resp:2, |
97 | src:2; |
98 | #endif |
99 | uint8_t status; |
100 | uint16_t orb_hi; |
101 | uint32_t orb_lo; |
102 | uint32_t data[6]; |
103 | }; |
104 | /* src */ |
105 | #define SRC_NEXT_EXISTS 0 |
106 | #define SRC_NO_NEXT 1 |
107 | #define SRC_UNSOL 2 |
108 | |
109 | /* resp */ |
110 | #define SBP_REQ_CMP 0 /* request complete */ |
111 | #define SBP_TRANS_FAIL 1 /* transport failure */ |
112 | #define SBP_ILLE_REQ 2 /* illegal request */ |
113 | #define SBP_VEND_DEP 3 /* vendor dependent */ |
114 | |
115 | /* status (resp == 0) */ |
116 | /* 0: No additional Information to report */ |
117 | /* 1: Request Type not supported */ |
118 | /* 2: Speed not supported */ |
119 | /* 3: Page size not supported */ |
120 | /* 4: Access denied */ |
121 | #define STATUS_ACCESS_DENY 4 |
122 | #define STATUS_LUR 5 |
123 | /* 6: Maximum payload too small */ |
124 | /* 7: Reserved for future standardization */ |
125 | /* 8: Resource unavailabe */ |
126 | #define STATUS_RES_UNAVAIL 8 |
127 | /* 9: Function Rejected */ |
128 | /* 10: Login ID not recognized */ |
129 | /* 11: Dummy ORB completed */ |
130 | /* 12: Request aborted */ |
131 | /* 255: Unspecified error */ |
132 | |
133 | /* status (resp == 1) */ |
134 | /* Referenced object */ |
135 | #define OBJ_ORB (0 << 6) /* 0: ORB */ |
136 | #define OBJ_DATA (1 << 6) /* 1: Data buffer */ |
137 | #define OBJ_PT (2 << 6) /* 2: Page table */ |
138 | #define OBJ_UNSPEC (3 << 6) /* 3: Unable to specify */ |
139 | /* Serial bus error */ |
140 | /* 0: Missing acknowledge */ |
141 | /* 1: Reserved; not to be used */ |
142 | /* 2: Time-out error */ |
143 | #define SBE_TIMEOUT 2 |
144 | /* 3: Reserved; not to be used */ |
145 | /* 4: Busy retry limit exceeded: ack_busy_X */ |
146 | /* 5: Busy retry limit exceeded: ack_busy_A */ |
147 | /* 6: Busy retry limit exceeded: ack_busy_B */ |
148 | /* 7-A: Reserved for future standardization */ |
149 | /* B: Tardy retry limit exceeded */ |
150 | /* C: Conflict error */ |
151 | /* D: Data error */ |
152 | /* E: Type error */ |
153 | /* F: Address error */ |
154 | |
155 | |
156 | struct sbp_cmd_status{ |
157 | #define SBP_SFMT_CURR 0 |
158 | #define SBP_SFMT_DEFER 1 |
159 | #if BYTE_ORDER == BIG_ENDIAN |
160 | uint8_t sfmt:2, |
161 | status:6; |
162 | uint8_t valid:1, |
163 | mark:1, |
164 | eom:1, |
165 | ill_len:1, |
166 | s_key:4; |
167 | #else |
168 | uint8_t status:6, |
169 | sfmt:2; |
170 | uint8_t s_key:4, |
171 | ill_len:1, |
172 | eom:1, |
173 | mark:1, |
174 | valid:1; |
175 | #endif |
176 | uint8_t s_code; |
177 | uint8_t s_qlfr; |
178 | uint32_t info; |
179 | uint32_t cdb; |
180 | uint8_t fru; |
181 | uint8_t s_keydep[3]; |
182 | uint32_t vend[2]; |
183 | }; |
184 | |
185 | #define ORB_FUN_NAMES \ |
186 | /* 0 */ "LOGIN", \ |
187 | /* 1 */ "QUERY LOGINS", \ |
188 | /* 2 */ "Reserved", \ |
189 | /* 3 */ "RECONNECT", \ |
190 | /* 4 */ "SET PASSWORD", \ |
191 | /* 5 */ "Reserved", \ |
192 | /* 6 */ "Reserved", \ |
193 | /* 7 */ "LOGOUT", \ |
194 | /* 8 */ "Reserved", \ |
195 | /* 9 */ "Reserved", \ |
196 | /* A */ "Reserved", \ |
197 | /* B */ "ABORT TASK", \ |
198 | /* C */ "ABORT TASK SET", \ |
199 | /* D */ "Reserved", \ |
200 | /* E */ "LOGICAL UNIT RESET", \ |
201 | /* F */ "TARGET RESET" |
202 | |
203 | #endif /* _SBP_H_ */ |
204 | |