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/firewire.h,v 1.2.2.8 2003/04/28 03:29:18 simokawa Exp $
62 struct fw_asybindreq {
72 #define MAXREC(x) (2 << (x))
73 #define FWPMAX_S400 (2048 + 20) /* MAXREC plus space for control data */
76 #define FWLOCALBUS 0xffc0
78 #define FWTCODE_WREQQ 0
79 #define FWTCODE_WREQB 1
80 #define FWTCODE_WRES 2
81 #define FWTCODE_RREQQ 4
82 #define FWTCODE_RREQB 5
83 #define FWTCODE_RRESQ 6
84 #define FWTCODE_RRESB 7
85 #define FWTCODE_CYCS 8
86 #define FWTCODE_LREQ 9
87 #define FWTCODE_STREAM 0xa
88 #define FWTCODE_LRES 0xb
89 #define FWTCODE_PHY 0xe
96 #define FWRCODE_COMPLETE 0
97 #define FWRCODE_ER_CONFL 4
98 #define FWRCODE_ER_DATA 5
99 #define FWRCODE_ER_TYPE 6
100 #define FWRCODE_ER_ADDR 7
106 #define FWP_TL_VALID (1 << 7)
116 #if BYTE_ORDER == BIG_ENDIAN
117 #define BIT4x2(x,y) u_int8_t x:4, y:4
118 #define BIT16x2(x,y) u_int32_t x:16, y:16
120 #define BIT4x2(x,y) u_int8_t y:4, x:4
121 #define BIT16x2(x,y) u_int32_t y:16, x:16
125 #if BYTE_ORDER == BIG_ENDIAN
126 #define COMMON_HDR(a,b,c,d) u_int32_t a:16,b:8,c:4,d:4
127 #define COMMON_RES(a,b,c,d) u_int32_t a:16,b:4,c:4,d:8
129 #define COMMON_HDR(a,b,c,d) u_int32_t d:4,c:4,b:8,a:16
130 #define COMMON_RES(a,b,c,d) u_int32_t d:8,c:4,b:4,a:16
137 COMMON_HDR(, , tcode, );
140 COMMON_HDR(len, chtag, tcode, sy);
141 u_int32_t payload[0];
144 COMMON_HDR(dst, tlrt, tcode, pri);
148 COMMON_HDR(dst, tlrt, tcode, pri);
149 BIT16x2(src, dest_hi);
153 COMMON_HDR(dst, tlrt, tcode, pri);
154 COMMON_RES(src, rtcode, , );
158 COMMON_HDR(dst, tlrt, tcode, pri);
159 BIT16x2(src, dest_hi);
161 BIT16x2(len, extcode);
164 COMMON_HDR(dst, tlrt, tcode, pri);
165 BIT16x2(src, dest_hi);
170 COMMON_HDR(dst, tlrt, tcode, pri);
171 BIT16x2(src, dest_hi);
176 COMMON_HDR(dst, tlrt, tcode, pri);
177 COMMON_RES(src, rtcode, , );
182 COMMON_HDR(dst, tlrt, tcode, pri);
183 BIT16x2(src, dest_hi);
185 BIT16x2(len, extcode);
186 u_int32_t payload[0];
189 COMMON_HDR(dst, tlrt, tcode, pri);
190 BIT16x2(src, dest_hi);
192 BIT16x2(len, extcode);
193 #define FW_LREQ_MSKSWAP 1
194 #define FW_LREQ_CMPSWAP 2
195 #define FW_LREQ_FTADD 3
196 #define FW_LREQ_LTADD 4
197 #define FW_LREQ_BDADD 5
198 #define FW_LREQ_WRADD 6
199 u_int32_t payload[0];
202 COMMON_HDR(dst, tlrt, tcode, pri);
203 COMMON_RES(src, rtcode, , );
205 BIT16x2(len, extcode);
206 u_int32_t payload[0];
209 COMMON_HDR(dst, tlrt, tcode, pri);
210 COMMON_RES(src, rtcode, , );
212 BIT16x2(len, extcode);
213 u_int32_t payload[0];
221 #define FW_EUI64_BYTE(eui, x) \
223 ((eui)->hi >> (8*(3-(x)))): \
224 ((eui)->lo >> (8*(7-(x)))) \
226 #define FW_EUI64_EQUAL(x, y) \
227 ((x).hi == (y).hi && (x).lo == (y).lo)
233 #define FWASREQNODE 0
236 #define FWASREQSTREAM 3
252 #define FW_MAX_DEVLST 70
253 struct fw_devlstreq {
256 struct fw_devinfo dev[FW_MAX_DEVLST];
259 #define FW_SELF_ID_PORT_CONNECTED_TO_CHILD 3
260 #define FW_SELF_ID_PORT_CONNECTED_TO_PARENT 2
261 #define FW_SELF_ID_PORT_NOT_CONNECTED 1
262 #define FW_SELF_ID_PORT_NOT_EXISTS 0
263 #if BYTE_ORDER == BIG_ENDIAN
303 u_int32_t more_packets:1,
319 u_int32_t more_packets:1,
339 struct fw_topology_map {
342 u_int32_t generation;
343 u_int32_t self_id_count:16,
345 union fw_self_id self_id[4*64];
348 struct fw_speed_map {
351 u_int32_t generation;
352 u_int8_t speed[64][64];
362 * FireWire specific system requests.
364 #define FW_SSTBUF _IOWR('S', 86, struct fw_isobufreq)
365 #define FW_GSTBUF _IOWR('S', 87, struct fw_isobufreq)
366 #define FW_SRSTREAM _IOWR('S', 88, struct fw_isochreq)
367 #define FW_GRSTREAM _IOWR('S', 89, struct fw_isochreq)
368 #define FW_STSTREAM _IOWR('S', 90, struct fw_isochreq)
369 #define FW_GTSTREAM _IOWR('S', 91, struct fw_isochreq)
371 #define FW_ASYREQ _IOWR('S', 92, struct fw_asyreq)
372 #define FW_IBUSRST _IOR('S', 1, unsigned int)
373 #define FW_GDEVLST _IOWR('S', 2, struct fw_devlstreq)
374 #define FW_SBINDADDR _IOWR('S', 3, struct fw_asybindreq)
375 #define FW_CBINDADDR _IOWR('S', 4, struct fw_asybindreq)
376 #define FW_GTPMAP _IOR('S', 5, struct fw_topology_map)
377 #define FW_GCROM _IOWR('S', 7, struct fw_crom_buf)
379 #define FW_SDEUI64 _IOW('S', 20, struct fw_eui64)
380 #define FW_GDEUI64 _IOR('S', 21, struct fw_eui64)
382 #define FWOHCI_RDREG _IOWR('S', 80, struct fw_reg_req_t)
383 #define FWOHCI_WRREG _IOWR('S', 81, struct fw_reg_req_t)
385 #define DUMPDMA _IOWR('S', 82, u_int32_t)
389 #define FWMAXNDMA 0x100 /* 8 bits DMA channel id. in device No. */
391 #if __FreeBSD_version < 500000
392 #define dev2unit(x) ((minor(x) & 0xff) | (minor(x) >> 8))
393 #define unit2minor(x) (((x) & 0xff) | (((x) << 8) & ~0xffff))
396 #define UNIT2MIN(x) (((x) & 0xff) << 8)
397 #define DEV2UNIT(x) ((dev2unit(x) & 0xff00) >> 8)
398 #define DEV2DMACH(x) (dev2unit(x) & 0xff)
400 #define FWMEM_FLAG 0x10000
401 #define DEV_FWMEM(x) (dev2unit(x) & FWMEM_FLAG)