1 /* $NetBSD: sbp2var.h,v 1.6 2005/02/27 00:27:17 perry Exp $ */
2
3 /*
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by James Chacon.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #ifndef _DEV_IEEE1394_SBP2VAR_H
40 #define _DEV_IEEE1394_SBP2VAR_H
41
42 #include <dev/std/ieee1212var.h>
43 struct sbp2_orb;
44
45 struct sbp2_mapping {
46 void *laddr;
47 u_int64_t fwaddr;
48 u_int32_t size;
49 u_int8_t rw;
50 struct sbp2_orb *orb;
51 };
52
53 /* Need a top level map per bus. */
54
55 struct sbp2_map {
56 unsigned char datamap[SBP_DATA_SIZE / SBP_DATA_BLOCK_SIZE / CHAR_BIT];
57 unsigned int next_data;
58
59 /*
60 * Divide by 4 because this is allocated in quad chunks and divide by
61 * 8 to make it a bitmap.
62 */
63 unsigned char addrmap[SBP_ADDR_SIZE / SBP_ADDR_BLOCK_SIZE / CHAR_BIT];
64 unsigned int next_addr;
65
66 u_int64_t fifo;
67 struct ieee1394_softc *sc_bus; /* fw controller softc */
68 int refcnt;
69 struct simplelock maplock;
70 TAILQ_ENTRY(sbp2_map) map_list;
71 };
72
73 struct sbp2;
74 struct sbp2_lun;
75
76 struct sbp2_status {
77 u_int8_t resp;
78 u_int8_t sbp_status;
79 u_int8_t object;
80 u_int8_t bus_error;
81 u_int32_t *data;
82 u_int16_t datalen;
83 };
84
85 struct sbp2_pagetable {
86 struct ieee1394_abuf pt_ent;
87 struct ieee1394_abuf pt_resp;
88 struct sbp2_mapping pt_map;
89
90 u_int16_t pt_cnt;
91 struct ieee1394_abuf *pt_data; /* cbarg == data_mapping */
92 };
93
94 struct sbp2_orb {
95 struct sbp2_mapping data_map;
96
97 struct ieee1394_abuf cmd;
98 struct ieee1394_abuf data;
99 struct ieee1394_abuf resp;
100
101 struct sbp2_pagetable *pt;
102
103 struct sbp2_status status;
104 u_int8_t status_rec;
105 u_int8_t ack;
106 u_int8_t db;
107 u_int8_t dback;
108
109 int state;
110 struct sbp2 *sbp2;
111 struct sbp2_lun *lun;
112
113 void (*cb)(struct sbp2_status *, void *);
114 void *cb_arg;
115
116 struct simplelock orb_lock;
117 CIRCLEQ_ENTRY(sbp2_orb) orb_list;
118 };
119
120 struct sbp2_lun {
121
122 u_int8_t ordered;
123 u_int8_t dev_type;
124 u_int16_t lun;
125
126 u_int32_t cmd_spec_id;
127 u_int32_t cmd_set;
128 u_int32_t cmd_set_rev;
129
130 u_int16_t loginid;
131 u_int16_t reconnect;
132 u_int64_t cmdreg;
133
134 int login_flag;
135 int state;
136
137 struct ieee1394_abuf command;
138 struct ieee1394_abuf doorbell;
139 struct ieee1394_abuf status;
140 TAILQ_ENTRY(sbp2_lun) lun_list;
141 };
142
143 struct sbp2 {
144 struct ieee1394_softc *sc; /* node softc */
145
146 u_int8_t speed;
147 u_int32_t maxpayload;
148
149 u_int8_t orb_size;
150 u_int8_t orb_timeout;
151
152 u_int16_t max_reconnect;
153
154 u_int32_t cmd_spec_id;
155 u_int32_t cmd_set;
156 u_int32_t cmd_set_rev;
157 u_int32_t firmware_rev;
158
159 u_int64_t uniq_id;
160 u_int64_t mgmtreg;
161
162 u_int16_t luncnt;
163
164 struct sbp2_map *map;
165 struct simplelock orblist_lock;
166
167 TAILQ_HEAD(, sbp2_lun) luns;
168 CIRCLEQ_HEAD(, sbp2_orb) orbs;
169 };
170
171 struct sbp2_cmd {
172 u_int8_t cmd[SBP2_MAX_ORB];
173 int cmdlen;
174 u_char *data;
175 int datalen;
176 u_int16_t lun;
177 int rw;
178 void (*cb)(struct sbp2_status *, void *);
179 void *cb_arg;
180 };
181
182 int sbp2_match(struct p1212_dir *);
183 struct sbp2 *sbp2_init(struct ieee1394_softc *, struct p1212_dir *);
184 void sbp2_free(struct sbp2 *);
185 void *sbp2_runcmd(struct sbp2 *, struct sbp2_cmd *);
186 void *sbp2_abort(void *);
187 void sbp2_reset_lun(struct sbp2 *, u_int16_t);
188
189 #endif /* _DEV_IEEE1394_SBP2VAR_H */
Cache object: b106253cad1762150d36a495aa020497
|