2 * Copyright (c) 2003 Hidetoshi Shimokawa
3 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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:
17 * This product includes software developed by K. Kobayashi and H. Shimokawa
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.
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.
34 * $FreeBSD: src/sys/dev/firewire/firewirereg.h,v 1.1.2.14 2003/05/01 06:24:37 simokawa Exp $
38 #if __FreeBSD_version >= 500000
39 typedef struct thread fw_proc;
40 #include <sys/selinfo.h>
42 typedef struct proc fw_proc;
43 #include <sys/select.h>
57 #define CSRROMOFF 0x400
58 #define CSRROMSIZE 0x400
59 int rommax; /* offset from 0xffff f000 0000 */
60 u_int32_t csrrom[CSRROMSIZE/4];
62 struct firewire_comm *fc;
65 #define FWDEVATTACHED 2
67 STAILQ_ENTRY(fw_device) link;
70 struct firewire_softc {
71 #if __FreeBSD_version >= 500000
74 dev_t dev[FWMAXNDMA+1];
76 struct firewire_comm *fc;
79 #define FW_MAX_DMACH 0x20
80 #define FW_MAX_DEVCH FW_MAX_DMACH
81 #define FW_XFERTIMEOUT 1
83 struct firewire_dev_comm {
85 struct firewire_comm *fc;
86 void (*post_busreset) __P((void *));
87 void (*post_explore) __P((void *));
91 u_char hdr_len; /* IEEE1394 header length */
93 #define FWTI_REQ (1 << 0)
94 #define FWTI_RES (1 << 1)
95 #define FWTI_TLABEL (1 << 2)
96 #define FWTI_BLOCK_STR (1 << 3)
97 #define FWTI_BLOCK_ASY (1 << 4)
100 struct firewire_comm{
113 #define FWPHYASYST (1 << 0)
115 u_int32_t ongobus:10,
118 struct fw_device *ongodev;
119 struct fw_eui64 ongoeui;
120 #define FWMAXCSRDIR 16
121 SLIST_HEAD(, csrdir) ongocsr;
122 SLIST_HEAD(, csrdir) csrfree;
126 #define FWBUSCYMELECT 2
127 #define FWBUSMGRELECT 3
128 #define FWBUSMGRDONE 4
129 #define FWBUSEXPLORE 5
130 #define FWBUSPHYCONF 6
131 #define FWBUSEXPDONE 7
132 #define FWBUSCOMPLETION 10
136 *arq, *atq, *ars, *ats, *it[FW_MAX_DMACH],*ir[FW_MAX_DMACH];
137 STAILQ_HEAD(, tlabel) tlabels[0x40];
138 STAILQ_HEAD(, fw_bind) binds;
139 STAILQ_HEAD(, fw_device) devices;
140 STAILQ_HEAD(, fw_xfer) pending;
142 #define CSRSIZE 0x4000
143 u_int32_t csr_arc[CSRSIZE/4];
144 #define CROMSIZE 0x400
145 u_int32_t *config_rom;
146 struct fw_topology_map *topology_map;
147 struct fw_speed_map *speed_map;
148 struct callout busprobe_callout;
149 struct callout bmr_callout;
150 struct callout timeout_callout;
151 struct callout retry_probe_callout;
152 u_int32_t (*cyctimer) __P((struct firewire_comm *));
153 void (*ibr) __P((struct firewire_comm *));
154 u_int32_t (*set_bmr) __P((struct firewire_comm *, u_int32_t));
155 int (*ioctl) __P((dev_t, u_long, caddr_t, int, fw_proc *));
156 int (*irx_enable) __P((struct firewire_comm *, int));
157 int (*irx_disable) __P((struct firewire_comm *, int));
158 int (*itx_enable) __P((struct firewire_comm *, int));
159 int (*itx_disable) __P((struct firewire_comm *, int));
160 void (*timeout) __P((void *));
161 void (*poll) __P((struct firewire_comm *, int, int));
162 void (*set_intr) __P((struct firewire_comm *, int));
163 void (*irx_post) __P((struct firewire_comm *, u_int32_t *));
164 void (*itx_post) __P((struct firewire_comm *, u_int32_t *));
165 struct tcode_info *tcode;
168 #define CSRARC(sc, offset) ((sc)->csr_arc[(offset)/4])
173 SLIST_ENTRY(csrdir) link;
178 #define FWXFERQ_CHTAGMASK 0xff
179 #define FWXFERQ_RUNNING (1 << 8)
180 #define FWXFERQ_STREAM (1 << 9)
182 #define FWXFERQ_BULK (1 << 11)
183 #define FWXFERQ_MODEMASK (7 << 10)
185 #define FWXFERQ_EXTBUF (1 << 13)
186 #define FWXFERQ_OPEN (1 << 14)
188 #define FWXFERQ_HANDLER (1 << 16)
189 #define FWXFERQ_WAKEUP (1 << 17)
191 void (*start) __P((struct firewire_comm*));
192 STAILQ_HEAD(, fw_xfer) q;
196 STAILQ_HEAD(, fw_bind) binds;
197 struct fwdma_alloc_multi *buf;
200 struct fw_bulkxfer *bulkxfer;
201 STAILQ_HEAD(, fw_bulkxfer) stvalid;
202 STAILQ_HEAD(, fw_bulkxfer) stfree;
203 STAILQ_HEAD(, fw_bulkxfer) stdma;
204 struct fw_bulkxfer *stproc;
207 void (*hand) __P((struct fw_xferq *));
213 STAILQ_ENTRY(fw_bulkxfer) link;
220 struct fw_xfer *xfer;
221 STAILQ_ENTRY(tlabel) link;
225 u_int32_t start_hi, start_lo, addrlen;
226 STAILQ_HEAD(, fw_xfer) xferlist;
227 STAILQ_ENTRY(fw_bind) fclist;
228 STAILQ_ENTRY(fw_bind) chlist;
238 struct firewire_comm *fc;
241 /* XXX should be removed */
242 u_int32_t dst; /* XXX for if_fwe */
249 #define FWXF_SENTERR 4
255 void (*retry_req) __P((struct fw_xfer *));
257 void (*hand) __P((struct fw_xfer *));
264 STAILQ_ENTRY(fw_xfer) link;
265 struct malloc_type *malloc;
267 void fw_sidrcv __P((struct firewire_comm *, u_int32_t *, u_int));
268 void fw_rcv __P((struct firewire_comm *, struct iovec *, int, u_int, u_int));
269 void fw_xfer_unload __P(( struct fw_xfer*));
270 void fw_xfer_free __P(( struct fw_xfer*));
271 struct fw_xfer *fw_xfer_alloc __P((struct malloc_type *));
272 struct fw_xfer *fw_xfer_alloc_buf __P((struct malloc_type *, int, int));
273 void fw_init __P((struct firewire_comm *));
274 int fw_tbuf_update __P((struct firewire_comm *, int, int));
275 int fw_rbuf_update __P((struct firewire_comm *, int, int));
276 void fw_asybusy __P((struct fw_xfer *));
277 int fw_bindadd __P((struct firewire_comm *, struct fw_bind *));
278 int fw_bindremove __P((struct firewire_comm *, struct fw_bind *));
279 int fw_asyreq __P((struct firewire_comm *, int, struct fw_xfer*));
280 void fw_busreset __P((struct firewire_comm *));
281 u_int16_t fw_crc16 __P((u_int32_t *, u_int32_t));
282 void fw_xfer_timeout __P((void *));
283 void fw_xfer_done __P((struct fw_xfer *));
284 void fw_asy_callback __P((struct fw_xfer *));
285 struct fw_device *fw_noderesolve_nodeid __P((struct firewire_comm *, int));
286 struct fw_device *fw_noderesolve_eui64 __P((struct firewire_comm *, struct fw_eui64 *));
287 struct fw_bind *fw_bindlookup __P((struct firewire_comm *, u_int32_t, u_int32_t));
288 void fw_drain_txq __P((struct firewire_comm *));
291 extern int firewire_debug;
292 extern devclass_t firewire_devclass;
294 #define FWPRI ((PZERO+8)|PCATCH)
296 #if __FreeBSD_version >= 500000
297 #define CALLOUT_INIT(x) callout_init(x, 0 /* mpsafe */)
299 #define CALLOUT_INIT(x) callout_init(x)
302 MALLOC_DECLARE(M_FW);
303 MALLOC_DECLARE(M_FWXFER);