kgdb(1): Add missing "
[dragonfly.git] / sys / bus / firewire / firewirereg.h
blobc03f5c5631056e0990698f24e146619208813d0a
1 /*
2 * Copyright (c) 2003 Hidetoshi Shimokawa
3 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
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.33 2004/01/06 14:30:46 simokawa Exp $
37 typedef struct thread fw_proc;
39 #include <sys/uio.h>
40 #include <sys/event.h>
42 struct dev_ioctl_args;
44 struct fw_device{
45 u_int16_t dst;
46 struct fw_eui64 eui;
47 u_int8_t speed;
48 u_int8_t maxrec;
49 u_int8_t nport;
50 u_int8_t power;
51 #define CSRROMOFF 0x400
52 #define CSRROMSIZE 0x400
53 int rommax; /* offset from 0xffff f000 0000 */
54 u_int32_t csrrom[CSRROMSIZE/4];
55 int rcnt;
56 struct firewire_comm *fc;
57 u_int32_t status;
58 #define FWDEVINIT 1
59 #define FWDEVATTACHED 2
60 #define FWDEVINVAL 3
61 STAILQ_ENTRY(fw_device) link;
64 struct firewire_softc {
65 #if defined(__FreeBSD__) && __FreeBSD_version >= 500000
66 cdev_t dev;
67 #endif
68 struct firewire_comm *fc;
71 #define FW_MAX_DMACH 0x20
72 #define FW_MAX_DEVCH FW_MAX_DMACH
73 #define FW_XFERTIMEOUT 1
75 struct firewire_dev_comm {
76 device_t dev;
77 struct firewire_comm *fc;
78 void (*post_busreset) (void *);
79 void (*post_explore) (void *);
82 struct tcode_info {
83 u_char hdr_len; /* IEEE1394 header length */
84 u_char flag;
85 #define FWTI_REQ (1 << 0)
86 #define FWTI_RES (1 << 1)
87 #define FWTI_TLABEL (1 << 2)
88 #define FWTI_BLOCK_STR (1 << 3)
89 #define FWTI_BLOCK_ASY (1 << 4)
92 struct firewire_comm{
93 device_t dev;
94 device_t bdev;
95 u_int16_t busid:10,
96 nodeid:6;
97 u_int mode;
98 u_int nport;
99 u_int speed;
100 u_int maxrec;
101 u_int irm;
102 u_int max_node;
103 u_int max_hop;
104 u_int max_asyretry;
105 #define FWPHYASYST (1 << 0)
106 u_int retry_count;
107 u_int32_t ongobus:10,
108 ongonode:6,
109 ongoaddr:16;
110 struct fw_device *ongodev;
111 struct fw_eui64 ongoeui;
112 #define FWMAXCSRDIR 16
113 SLIST_HEAD(, csrdir) ongocsr;
114 SLIST_HEAD(, csrdir) csrfree;
115 u_int32_t status;
116 #define FWBUSNOTREADY (-1)
117 #define FWBUSRESET 0
118 #define FWBUSINIT 1
119 #define FWBUSCYMELECT 2
120 #define FWBUSMGRELECT 3
121 #define FWBUSMGRDONE 4
122 #define FWBUSEXPLORE 5
123 #define FWBUSPHYCONF 6
124 #define FWBUSEXPDONE 7
125 #define FWBUSCOMPLETION 10
126 int nisodma;
127 struct fw_eui64 eui;
128 struct fw_xferq
129 *arq, *atq, *ars, *ats, *it[FW_MAX_DMACH],*ir[FW_MAX_DMACH];
130 STAILQ_HEAD(, tlabel) tlabels[0x40];
131 STAILQ_HEAD(, fw_bind) binds;
132 STAILQ_HEAD(, fw_device) devices;
133 u_int sid_cnt;
134 #define CSRSIZE 0x4000
135 u_int32_t csr_arc[CSRSIZE/4];
136 #define CROMSIZE 0x400
137 u_int32_t *config_rom;
138 struct crom_src_buf *crom_src_buf;
139 struct crom_src *crom_src;
140 struct crom_chunk *crom_root;
141 struct fw_topology_map *topology_map;
142 struct fw_speed_map *speed_map;
143 struct callout busprobe_callout;
144 struct callout bmr_callout;
145 struct callout timeout_callout;
146 struct callout retry_probe_callout;
147 u_int32_t (*cyctimer) (struct firewire_comm *);
148 void (*ibr) (struct firewire_comm *);
149 u_int32_t (*set_bmr) (struct firewire_comm *, u_int32_t);
150 int (*ioctl) (struct dev_ioctl_args *);
151 int (*irx_enable) (struct firewire_comm *, int);
152 int (*irx_disable) (struct firewire_comm *, int);
153 int (*itx_enable) (struct firewire_comm *, int);
154 int (*itx_disable) (struct firewire_comm *, int);
155 void (*timeout) (void *);
156 void (*poll) (struct firewire_comm *, int, int);
157 void (*set_intr) (struct firewire_comm *, int);
158 void (*irx_post) (struct firewire_comm *, u_int32_t *);
159 void (*itx_post) (struct firewire_comm *, u_int32_t *);
160 struct tcode_info *tcode;
161 bus_dma_tag_t dmat;
163 #define CSRARC(sc, offset) ((sc)->csr_arc[(offset)/4])
165 struct csrdir{
166 u_int32_t ongoaddr;
167 u_int32_t off;
168 SLIST_ENTRY(csrdir) link;
171 struct fw_xferq {
172 int flag;
173 #define FWXFERQ_CHTAGMASK 0xff
174 #define FWXFERQ_RUNNING (1 << 8)
175 #define FWXFERQ_STREAM (1 << 9)
177 #define FWXFERQ_BULK (1 << 11)
178 #define FWXFERQ_MODEMASK (7 << 10)
180 #define FWXFERQ_EXTBUF (1 << 13)
181 #define FWXFERQ_OPEN (1 << 14)
183 #define FWXFERQ_HANDLER (1 << 16)
184 #define FWXFERQ_WAKEUP (1 << 17)
185 void (*start) (struct firewire_comm*);
186 int dmach;
187 STAILQ_HEAD(, fw_xfer) q;
188 u_int queued;
189 u_int maxq;
190 u_int psize;
191 STAILQ_HEAD(, fw_bind) binds;
192 struct fwdma_alloc_multi *buf;
193 u_int bnchunk;
194 u_int bnpacket;
195 struct fw_bulkxfer *bulkxfer;
196 STAILQ_HEAD(, fw_bulkxfer) stvalid;
197 STAILQ_HEAD(, fw_bulkxfer) stfree;
198 STAILQ_HEAD(, fw_bulkxfer) stdma;
199 struct fw_bulkxfer *stproc;
200 struct kqinfo rkq;
201 caddr_t sc;
202 void (*hand) (struct fw_xferq *);
205 struct fw_bulkxfer{
206 int poffset;
207 struct mbuf *mbuf;
208 STAILQ_ENTRY(fw_bulkxfer) link;
209 caddr_t start;
210 caddr_t end;
211 int resp;
214 struct tlabel{
215 struct fw_xfer *xfer;
216 STAILQ_ENTRY(tlabel) link;
219 struct fw_bind{
220 u_int64_t start;
221 u_int64_t end;
222 STAILQ_HEAD(, fw_xfer) xferlist;
223 STAILQ_ENTRY(fw_bind) fclist;
224 STAILQ_ENTRY(fw_bind) chlist;
225 #define FWACT_NULL 0
226 #define FWACT_XFER 2
227 #define FWACT_CH 3
228 u_int8_t act_type;
229 u_int8_t sub;
232 struct fw_xfer{
233 caddr_t sc;
234 struct firewire_comm *fc;
235 struct fw_xferq *q;
236 struct timeval tv;
237 int8_t resp;
238 #define FWXF_INIT 0
239 #define FWXF_INQ 1
240 #define FWXF_START 2
241 #define FWXF_SENT 3
242 #define FWXF_SENTERR 4
243 #define FWXF_BUSY 8
244 #define FWXF_RCVD 10
245 u_int8_t state;
246 u_int8_t retry;
247 u_int8_t tl;
248 void (*retry_req) (struct fw_xfer *);
249 union{
250 void (*hand) (struct fw_xfer *);
251 } act;
252 struct {
253 struct fw_pkt hdr;
254 u_int32_t *payload;
255 u_int16_t pay_len;
256 u_int8_t spd;
257 } send, recv;
258 struct mbuf *mbuf;
259 STAILQ_ENTRY(fw_xfer) link;
260 struct malloc_type *malloc;
263 struct fw_rcv_buf {
264 struct firewire_comm *fc;
265 struct fw_xfer *xfer;
266 struct iovec *vec;
267 u_int nvec;
268 u_int8_t spd;
271 void fw_sidrcv (struct firewire_comm *, u_int32_t *, u_int);
272 void fw_rcv (struct fw_rcv_buf *);
273 void fw_xfer_unload ( struct fw_xfer*);
274 void fw_xfer_free_buf ( struct fw_xfer*);
275 void fw_xfer_free ( struct fw_xfer*);
276 struct fw_xfer *fw_xfer_alloc (struct malloc_type *);
277 struct fw_xfer *fw_xfer_alloc_buf (struct malloc_type *, int, int);
278 void fw_init (struct firewire_comm *);
279 int fw_tbuf_update (struct firewire_comm *, int, int);
280 int fw_rbuf_update (struct firewire_comm *, int, int);
281 void fw_asybusy (struct fw_xfer *);
282 int fw_bindadd (struct firewire_comm *, struct fw_bind *);
283 int fw_bindremove (struct firewire_comm *, struct fw_bind *);
284 int fw_asyreq (struct firewire_comm *, int, struct fw_xfer*);
285 void fw_busreset (struct firewire_comm *);
286 u_int16_t fw_crc16 (u_int32_t *, u_int32_t);
287 void fw_xfer_timeout (void *);
288 void fw_xfer_done (struct fw_xfer *);
289 void fw_asy_callback (struct fw_xfer *);
290 void fw_asy_callback_free (struct fw_xfer *);
291 struct fw_device *fw_noderesolve_nodeid (struct firewire_comm *, int);
292 struct fw_device *fw_noderesolve_eui64 (struct firewire_comm *, struct fw_eui64 *);
293 struct fw_bind *fw_bindlookup (struct firewire_comm *, u_int16_t, u_int32_t);
294 void fw_drain_txq (struct firewire_comm *);
295 int fwdev_makedev (struct firewire_softc *);
296 int fwdev_destroydev (struct firewire_softc *);
297 void fwdev_clone (void *, char *, int, cdev_t *);
299 extern int firewire_debug;
300 extern devclass_t firewire_devclass;
302 #define FWPRI PCATCH
304 #define CALLOUT_INIT(x) callout_init(x)
306 MALLOC_DECLARE(M_FW);
307 MALLOC_DECLARE(M_FWXFER);