2 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the acknowledgement as bellow:
16 * This product includes software developed by K. Kobayashi and H. Shimokawa
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
37 #if __FreeBSD_version >= 500000
38 typedef struct thread fw_proc;
39 #include <sys/selinfo.h>
41 typedef struct proc fw_proc;
42 #include <sys/select.h>
56 #define CSRROMOFF 0x400
57 #define CSRROMSIZE 0x400
58 int rommax; /* offset from 0xffff f000 0000 */
59 u_int32_t csrrom[CSRROMSIZE/4];
61 struct firewire_comm *fc;
64 #define FWDEVATTACHED 2
66 TAILQ_ENTRY(fw_device) link;
68 LIST_HEAD(, fw_xfer) txqueue;
69 LIST_HEAD(, fw_xfer) rxqueue;
72 struct firewire_softc {
73 #if __FreeBSD_version >= 500000
76 dev_t dev[FWMAXNDMA+1];
78 struct firewire_comm *fc;
80 #define FW_MAX_DMACH 0x20
81 #define FW_MAX_DEVCH FW_MAX_DMACH
82 #define FW_XFERTIMEOUT 1
83 struct firewire_dev_comm {
85 struct firewire_comm *fc;
86 void (*post_explore) __P((void *));
90 u_char hdr_len; /* IEEE1394 header length */
92 #define FWTI_REQ (1 << 0)
93 #define FWTI_RES (1 << 1)
94 #define FWTI_TLABEL (1 << 2)
95 #define FWTI_BLOCK_STR (1 << 3)
96 #define FWTI_BLOCK_ASY (1 << 4)
112 #define FWPHYASYST (1 << 0)
114 u_int32_t ongobus:10,
117 struct fw_device *ongodev;
118 struct fw_eui64 ongoeui;
119 #define FWMAXCSRDIR 16
120 SLIST_HEAD(, csrdir) ongocsr;
121 SLIST_HEAD(, csrdir) csrfree;
125 SLIST_ENTRY(csrdir) link;
130 #define FWBUSCYMELECT 2
131 #define FWBUSMGRELECT 3
132 #define FWBUSMGRDONE 4
133 #define FWBUSEXPLORE 5
134 #define FWBUSPHYCONF 6
135 #define FWBUSEXPDONE 7
136 #define FWBUSCOMPLETION 10
139 STAILQ_HEAD(fw_queue, fw_xfer);
142 #define FWXFERQ_CHTAGMASK 0xff
143 #define FWXFERQ_RUNNING (1 << 8)
144 #define FWXFERQ_STREAM (1 << 9)
146 #define FWXFERQ_PACKET (1 << 10)
147 #define FWXFERQ_BULK (1 << 11)
148 #define FWXFERQ_DV (1 << 12)
149 #define FWXFERQ_MODEMASK (7 << 10)
151 #define FWXFERQ_EXTBUF (1 << 13)
152 #define FWXFERQ_OPEN (1 << 14)
154 #define FWXFERQ_HANDLER (1 << 16)
155 #define FWXFERQ_WAKEUP (1 << 17)
157 void (*start) __P((struct firewire_comm*));
158 void (*drain) __P((struct firewire_comm*, struct fw_xfer*));
165 STAILQ_HEAD(, fw_bind) binds;
170 struct fw_bulkxfer *bulkxfer;
171 STAILQ_HEAD(, fw_bulkxfer) stvalid;
172 STAILQ_HEAD(, fw_bulkxfer) stfree;
173 struct fw_bulkxfer *stdma;
174 struct fw_bulkxfer *stdma2;
175 struct fw_bulkxfer *stproc;
177 int dvdbc, dvdiff, dvsync;
178 struct fw_dvbuf *dvbuf;
179 STAILQ_HEAD(, fw_dvbuf) dvvalid;
180 STAILQ_HEAD(, fw_dvbuf) dvfree;
181 struct fw_dvbuf *dvdma;
182 struct fw_dvbuf *dvproc;
188 void (*hand) __P((struct fw_xferq *));
191 *arq, *atq, *ars, *ats, *it[FW_MAX_DMACH],*ir[FW_MAX_DMACH];
195 STAILQ_ENTRY(fw_bulkxfer) link;
202 STAILQ_ENTRY(fw_dvbuf) link;
205 struct fw_xfer *xfer;
206 STAILQ_ENTRY(tlabel) link;
208 STAILQ_HEAD(, tlabel) tlabels[0x40];
210 u_int32_t start_hi, start_lo, addrlen;
211 struct fw_xfer* xfer;
212 STAILQ_ENTRY(fw_bind) fclist;
213 STAILQ_ENTRY(fw_bind) chlist;
215 STAILQ_HEAD(, fw_bind) binds;
216 TAILQ_HEAD(, fw_device) devices;
217 STAILQ_HEAD(, fw_xfer) pending;
218 volatile u_int32_t *sid_buf;
220 #define CSRSIZE 0x4000
221 u_int32_t csr_arc[CSRSIZE/4];
222 #define CROMSIZE 0x400
223 u_int32_t *config_rom;
224 struct fw_topology_map *topology_map;
225 struct fw_speed_map *speed_map;
226 struct callout_handle tlhandle;
227 struct callout_handle bmrhandle;
228 struct callout_handle timeouthandle;
229 struct callout_handle retry_probe_handle;
230 u_int32_t (*cyctimer) __P((struct firewire_comm *));
231 void (*ibr) __P((struct firewire_comm *));
232 u_int32_t (*set_bmr) __P((struct firewire_comm *, u_int32_t));
233 int (*ioctl) __P((dev_t, u_long, caddr_t, int, fw_proc *));
234 int (*irx_enable) __P((struct firewire_comm *, int));
235 int (*irx_disable) __P((struct firewire_comm *, int));
236 int (*itx_enable) __P((struct firewire_comm *, int));
237 int (*itx_disable) __P((struct firewire_comm *, int));
238 void (*timeout) __P((void *));
239 void (*poll) __P((struct firewire_comm *, int, int));
240 void (*set_intr) __P((struct firewire_comm *, int));
241 void (*irx_post) __P((struct firewire_comm *, u_int32_t *));
242 void (*itx_post) __P((struct firewire_comm *, u_int32_t *));
243 struct tcode_info *tcode;
245 #define CSRARC(sc, offset) ((sc)->csr_arc[(offset)/4])
250 struct firewire_comm *fc;
252 struct callout_handle ch;
254 struct fw_tlabel *tlabel;
262 #define FWXF_SENTERR 4
274 void (*retry_req) __P((struct fw_xfer *));
276 void (*hand) __P((struct fw_xfer *));
281 struct fw_device *device;
284 struct stch *channel;
292 STAILQ_ENTRY(fw_xfer) link;
294 void fw_sidrcv __P((struct firewire_comm *, caddr_t, u_int, u_int));
295 void fw_rcv __P((struct firewire_comm *, caddr_t, u_int, u_int, u_int, u_int));
296 void fw_xfer_free __P(( struct fw_xfer*));
297 struct fw_xfer *fw_xfer_alloc __P((void));
298 void fw_init __P((struct firewire_comm *));
299 int fw_tbuf_update __P((struct firewire_comm *, int, int));
300 int fw_rbuf_update __P((struct firewire_comm *, int, int));
301 int fw_readreqq __P((struct firewire_comm *, u_int32_t, u_int32_t, u_int32_t *));
302 int fw_writereqb __P((struct firewire_comm *, u_int32_t, u_int32_t, u_int32_t, u_int32_t *));
303 int fw_readresb __P((struct firewire_comm *, u_int32_t, u_int32_t, u_int32_t, u_int32_t*));
304 int fw_writeres __P((struct firewire_comm *, u_int32_t, u_int32_t));
305 u_int32_t getcsrdata __P((struct fw_device *, u_int8_t));
306 void fw_asybusy __P((struct fw_xfer *));
307 int fw_bindadd __P((struct firewire_comm *, struct fw_bind *));
308 int fw_bindremove __P((struct firewire_comm *, struct fw_bind *));
309 int fw_asyreq __P((struct firewire_comm *, int, struct fw_xfer*));
310 void fw_busreset __P((struct firewire_comm *));
311 u_int16_t fw_crc16 __P((u_int32_t *, u_int32_t));
312 void fw_xfer_timeout __P((void *));
313 void fw_xfer_done __P((struct fw_xfer *));
314 void fw_asy_callback __P((struct fw_xfer *));
315 struct fw_device *fw_noderesolve __P((struct firewire_comm *, struct fw_eui64));
316 struct fw_bind *fw_bindlookup __P((struct firewire_comm *, u_int32_t, u_int32_t));
319 extern int firewire_debug;
320 extern devclass_t firewire_devclass;
322 #define DV_BROADCAST_ON (1<<30)
323 #define IP_CHANNELS 0x0234
325 #define STATE_CLEAR 0x0000
326 #define STATE_SET 0x0004
327 #define NODE_IDS 0x0008
328 #define RESET_START 0x000c
329 #define SPLIT_TIMEOUT_HI 0x0018
330 #define SPLIT_TIMEOUT_LO 0x001c
331 #define CYCLE_TIME 0x0200
332 #define BUS_TIME 0x0210
333 #define BUS_MGR_ID 0x021c
334 #define BANDWIDTH_AV 0x0220
335 #define CHANNELS_AV_HI 0x0224
336 #define CHANNELS_AV_LO 0x0228
338 #define CONF_ROM 0x0400
340 #define TOPO_MAP 0x1000
341 #define SPED_MAP 0x2000
349 #define FWPRI ((PZERO+8)|PCATCH)
353 #define vtophys(va) alpha_XXX_dmamap((vm_offset_t)(va))
354 #endif /* __alpha__ */