firewire.h revision 119118
11573Srgrimes/* 223661Speter * Copyright (c) 2003 Hidetoshi Shimokawa 31573Srgrimes * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa 41573Srgrimes * All rights reserved. 51573Srgrimes * 61573Srgrimes * Redistribution and use in source and binary forms, with or without 71573Srgrimes * modification, are permitted provided that the following conditions 81573Srgrimes * are met: 91573Srgrimes * 1. Redistributions of source code must retain the above copyright 101573Srgrimes * notice, this list of conditions and the following disclaimer. 111573Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 121573Srgrimes * notice, this list of conditions and the following disclaimer in the 131573Srgrimes * documentation and/or other materials provided with the distribution. 141573Srgrimes * 3. All advertising materials mentioning features or use of this software 151573Srgrimes * must display the acknowledgement as bellow: 161573Srgrimes * 171573Srgrimes * This product includes software developed by K. Kobayashi and H. Shimokawa 181573Srgrimes * 191573Srgrimes * 4. The name of the author may not be used to endorse or promote products 201573Srgrimes * derived from this software without specific prior written permission. 211573Srgrimes * 221573Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 231573Srgrimes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 241573Srgrimes * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 251573Srgrimes * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 261573Srgrimes * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 271573Srgrimes * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 281573Srgrimes * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 291573Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 301573Srgrimes * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 311573Srgrimes * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 321573Srgrimes * POSSIBILITY OF SUCH DAMAGE. 331573Srgrimes * 341573Srgrimes * $FreeBSD: head/sys/dev/firewire/firewire.h 119118 2003-08-19 08:47:49Z simokawa $ 3523661Speter * 361573Srgrimes */ 3790041Sobrien 3890041Sobrien#ifndef _FIREWIRE_H 391573Srgrimes#define _FIREWIRE_H 1 4071579Sdeischen 411573Srgrimes#define DEV_DEF 0 421573Srgrimes#define DEV_DV 2 431573Srgrimes 4423661Speterstruct fw_isochreq { 451573Srgrimes unsigned char ch:6, 4623661Speter tag:2; 471573Srgrimes}; 481573Srgrimes 491573Srgrimesstruct fw_isobufreq { 501573Srgrimes struct fw_bufspec { 5171579Sdeischen unsigned int nchunk; 521573Srgrimes unsigned int npacket; 531573Srgrimes unsigned int psize; 541573Srgrimes } tx, rx; 5517141Sjkh}; 561573Srgrimes 57109039Stjrstruct fw_addr { 58109039Stjr unsigned long hi; 591573Srgrimes unsigned long lo; 601573Srgrimes}; 611573Srgrimes 621573Srgrimesstruct fw_asybindreq { 631573Srgrimes struct fw_addr start; 6490041Sobrien unsigned long len; 6590041Sobrien}; 6690041Sobrien 6790041Sobrienstruct fw_reg_req_t { 6890041Sobrien unsigned long addr; 6990041Sobrien unsigned long data; 701573Srgrimes}; 711573Srgrimes 721573Srgrimes#define MAXREC(x) (2 << (x)) 736227Sdg#define FWPMAX_S400 (2048 + 20) /* MAXREC plus space for control data */ 741573Srgrimes#define FWMAXQUEUE 64 7529462Sphk 761573Srgrimes#define FWLOCALBUS 0xffc0 771573Srgrimes 781573Srgrimes#define FWTCODE_WREQQ 0 791573Srgrimes#define FWTCODE_WREQB 1 801573Srgrimes#define FWTCODE_WRES 2 811573Srgrimes#define FWTCODE_RREQQ 4 821573Srgrimes#define FWTCODE_RREQB 5 831573Srgrimes#define FWTCODE_RRESQ 6 841573Srgrimes#define FWTCODE_RRESB 7 851573Srgrimes#define FWTCODE_CYCS 8 861573Srgrimes#define FWTCODE_LREQ 9 871573Srgrimes#define FWTCODE_STREAM 0xa 885072Sbde#define FWTCODE_LRES 0xb 895072Sbde#define FWTCODE_PHY 0xe 905072Sbde 915072Sbde#define FWRETRY_1 0 921573Srgrimes#define FWRETRY_X 1 931573Srgrimes#define FWRETRY_A 2 94150172Sache#define FWRETRY_B 3 951573Srgrimes 961573Srgrimes#define FWRCODE_COMPLETE 0 971573Srgrimes#define FWRCODE_ER_CONFL 4 9865468Speter#define FWRCODE_ER_DATA 5 9965468Speter#define FWRCODE_ER_TYPE 6 10065468Speter#define FWRCODE_ER_ADDR 7 10165468Speter 10265468Speter#define FWSPD_S100 0 10365468Speter#define FWSPD_S200 1 10465468Speter#define FWSPD_S400 2 10565468Speter 10629476Sphk#define FWP_TL_VALID (1 << 7) 10729392Sphk 10865468Speterstruct fw_isohdr { 10929392Sphk u_int32_t hdr[1]; 1101573Srgrimes}; 1111573Srgrimes 1121573Srgrimesstruct fw_asyhdr { 1131573Srgrimes u_int32_t hdr[4]; 114150172Sache}; 115150172Sache 11623661Speter#if BYTE_ORDER == BIG_ENDIAN 1171573Srgrimes#define BIT4x2(x,y) u_int8_t x:4, y:4 118150172Sache#define BIT16x2(x,y) u_int32_t x:16, y:16 1191573Srgrimes#else 120150138Sache#define BIT4x2(x,y) u_int8_t y:4, x:4 1211573Srgrimes#define BIT16x2(x,y) u_int32_t y:16, x:16 1221573Srgrimes#endif 1231573Srgrimes 1241573Srgrimes 1251573Srgrimes#if BYTE_ORDER == BIG_ENDIAN 1261573Srgrimes#define COMMON_HDR(a,b,c,d) u_int32_t a:16,b:8,c:4,d:4 1271573Srgrimes#define COMMON_RES(a,b,c,d) u_int32_t a:16,b:4,c:4,d:8 1281573Srgrimes#else 1291573Srgrimes#define COMMON_HDR(a,b,c,d) u_int32_t d:4,c:4,b:8,a:16 1301573Srgrimes#define COMMON_RES(a,b,c,d) u_int32_t d:8,c:4,b:4,a:16 1311573Srgrimes#endif 1321573Srgrimes 1331573Srgrimesstruct fw_pkt { 1341573Srgrimes union { 1351573Srgrimes u_int32_t ld[0]; 1361573Srgrimes struct { 1371573Srgrimes COMMON_HDR(, , tcode, ); 1381573Srgrimes } common; 1391573Srgrimes struct { 1401573Srgrimes COMMON_HDR(len, chtag, tcode, sy); 1411573Srgrimes u_int32_t payload[0]; 1421573Srgrimes } stream; 1431573Srgrimes struct { 1441573Srgrimes COMMON_HDR(dst, tlrt, tcode, pri); 1451573Srgrimes BIT16x2(src, ); 1461573Srgrimes } hdr; 1471573Srgrimes struct { 1481573Srgrimes COMMON_HDR(dst, tlrt, tcode, pri); 1491573Srgrimes BIT16x2(src, dest_hi); 1509272Shsu u_int32_t dest_lo; 1511573Srgrimes } rreqq; 1521573Srgrimes struct { 1531573Srgrimes COMMON_HDR(dst, tlrt, tcode, pri); 1541573Srgrimes COMMON_RES(src, rtcode, , ); 1551573Srgrimes u_int32_t :32; 1561573Srgrimes } wres; 1571573Srgrimes struct { 158102117Sjmallett COMMON_HDR(dst, tlrt, tcode, pri); 1591573Srgrimes BIT16x2(src, dest_hi); 1601573Srgrimes u_int32_t dest_lo; 16139327Simp BIT16x2(len, extcode); 1621573Srgrimes } rreqb; 1631573Srgrimes struct { 1641573Srgrimes COMMON_HDR(dst, tlrt, tcode, pri); 1651573Srgrimes BIT16x2(src, dest_hi); 1661573Srgrimes u_int32_t dest_lo; 1671573Srgrimes u_int32_t data; 1681573Srgrimes } wreqq; 1691573Srgrimes struct { 1701573Srgrimes COMMON_HDR(dst, tlrt, tcode, pri); 17171579Sdeischen BIT16x2(src, dest_hi); 1721573Srgrimes u_int32_t dest_lo; 1731573Srgrimes u_int32_t data; 1741573Srgrimes } cyc; 1751573Srgrimes struct { 17618971Speter COMMON_HDR(dst, tlrt, tcode, pri); 1771573Srgrimes COMMON_RES(src, rtcode, , ); 1781573Srgrimes u_int32_t :32; 1791573Srgrimes u_int32_t data; 1801573Srgrimes } rresq; 1811573Srgrimes struct { 1821573Srgrimes COMMON_HDR(dst, tlrt, tcode, pri); 1831573Srgrimes BIT16x2(src, dest_hi); 1841573Srgrimes u_int32_t dest_lo; 1851573Srgrimes BIT16x2(len, extcode); 1861573Srgrimes u_int32_t payload[0]; 1871573Srgrimes } wreqb; 1881573Srgrimes struct { 1891573Srgrimes COMMON_HDR(dst, tlrt, tcode, pri); 1901573Srgrimes BIT16x2(src, dest_hi); 1911573Srgrimes u_int32_t dest_lo; 1921573Srgrimes BIT16x2(len, extcode); 1931573Srgrimes#define FW_LREQ_MSKSWAP 1 1941573Srgrimes#define FW_LREQ_CMPSWAP 2 1951573Srgrimes#define FW_LREQ_FTADD 3 1961573Srgrimes#define FW_LREQ_LTADD 4 1971573Srgrimes#define FW_LREQ_BDADD 5 1981573Srgrimes#define FW_LREQ_WRADD 6 1991573Srgrimes u_int32_t payload[0]; 2001573Srgrimes } lreq; 2011573Srgrimes struct { 2021573Srgrimes COMMON_HDR(dst, tlrt, tcode, pri); 2031573Srgrimes COMMON_RES(src, rtcode, , ); 2041573Srgrimes u_int32_t :32; 2051573Srgrimes BIT16x2(len, extcode); 2061573Srgrimes u_int32_t payload[0]; 2071573Srgrimes } rresb; 2081573Srgrimes struct { 2091573Srgrimes COMMON_HDR(dst, tlrt, tcode, pri); 2101573Srgrimes COMMON_RES(src, rtcode, , ); 2111573Srgrimes u_int32_t :32; 2121573Srgrimes BIT16x2(len, extcode); 2131573Srgrimes u_int32_t payload[0]; 2145072Sbde } lres; 2151573Srgrimes } mode; 2161573Srgrimes}; 2171573Srgrimes 2181573Srgrimesstruct fw_eui64 { 2191573Srgrimes u_int32_t hi, lo; 2201573Srgrimes}; 2211573Srgrimes#define FW_EUI64_BYTE(eui, x) \ 2221573Srgrimes ((((x)<4)? \ 223109040Stjr ((eui)->hi >> (8*(3-(x)))): \ 2241573Srgrimes ((eui)->lo >> (8*(7-(x)))) \ 2251573Srgrimes ) & 0xff) 2261573Srgrimes#define FW_EUI64_EQUAL(x, y) \ 2279272Shsu ((x).hi == (y).hi && (x).lo == (y).lo) 2281573Srgrimes 2291573Srgrimesstruct fw_asyreq { 2301573Srgrimes struct fw_asyreq_t{ 2311573Srgrimes unsigned char sped; 2321573Srgrimes unsigned int type; 2331573Srgrimes#define FWASREQNODE 0 23428235Sdg#define FWASREQEUI 1 23528235Sdg#define FWASRESTL 2 2361573Srgrimes#define FWASREQSTREAM 3 2371573Srgrimes unsigned short len; 2381573Srgrimes union { 2391573Srgrimes struct fw_eui64 eui; 2401573Srgrimes }dst; 2411573Srgrimes }req; 2421573Srgrimes struct fw_pkt pkt; 2431573Srgrimes u_int32_t data[512]; 2441573Srgrimes}; 2451573Srgrimes 2461573Srgrimesstruct fw_devinfo { 2471573Srgrimes struct fw_eui64 eui; 2481573Srgrimes u_int16_t dst; 2491573Srgrimes u_int16_t status; 2501573Srgrimes}; 25132530Smckay 25232530Smckay#define FW_MAX_DEVLST 70 2531573Srgrimesstruct fw_devlstreq { 2541573Srgrimes u_int16_t n; 25528235Sdg u_int16_t info_len; 25628235Sdg struct fw_devinfo dev[FW_MAX_DEVLST]; 2571573Srgrimes}; 25832530Smckay 25932530Smckay#define FW_SELF_ID_PORT_CONNECTED_TO_CHILD 3 2601573Srgrimes#define FW_SELF_ID_PORT_CONNECTED_TO_PARENT 2 2611573Srgrimes#define FW_SELF_ID_PORT_NOT_CONNECTED 1 262#define FW_SELF_ID_PORT_NOT_EXISTS 0 263#if BYTE_ORDER == BIG_ENDIAN 264union fw_self_id { 265 struct { 266 u_int32_t id:2, 267 phy_id:6, 268 sequel:1, 269 link_active:1, 270 gap_count:6, 271 phy_speed:2, 272 phy_delay:2, 273 contender:1, 274 power_class:3, 275 port0:2, 276 port1:2, 277 port2:2, 278 initiated_reset:1, 279 more_packets:1; 280 } p0; 281 struct { 282 u_int32_t 283 id:2, 284 phy_id:6, 285 sequel:1, 286 sequence_num:3, 287 :2, 288 porta:2, 289 portb:2, 290 portc:2, 291 portd:2, 292 porte:2, 293 portf:2, 294 portg:2, 295 porth:2, 296 :1, 297 more_packets:1; 298 } p1; 299}; 300#else 301union fw_self_id { 302 struct { 303 u_int32_t more_packets:1, 304 initiated_reset:1, 305 port2:2, 306 port1:2, 307 port0:2, 308 power_class:3, 309 contender:1, 310 phy_delay:2, 311 phy_speed:2, 312 gap_count:6, 313 link_active:1, 314 sequel:1, 315 phy_id:6, 316 id:2; 317 } p0; 318 struct { 319 u_int32_t more_packets:1, 320 reserved1:1, 321 porth:2, 322 portg:2, 323 portf:2, 324 porte:2, 325 portd:2, 326 portc:2, 327 portb:2, 328 porta:2, 329 reserved2:2, 330 sequence_num:3, 331 sequel:1, 332 phy_id:6, 333 id:2; 334 } p1; 335}; 336#endif 337 338 339struct fw_topology_map { 340 u_int32_t crc:16, 341 crc_len:16; 342 u_int32_t generation; 343 u_int32_t self_id_count:16, 344 node_count:16; 345 union fw_self_id self_id[4*64]; 346}; 347 348struct fw_speed_map { 349 u_int32_t crc:16, 350 crc_len:16; 351 u_int32_t generation; 352 u_int8_t speed[64][64]; 353}; 354 355struct fw_crom_buf { 356 struct fw_eui64 eui; 357 int len; 358 void *ptr; 359}; 360 361/* 362 * FireWire specific system requests. 363 */ 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) 370 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) 378 379#define FW_SDEUI64 _IOW('S', 20, struct fw_eui64) 380#define FW_GDEUI64 _IOR('S', 21, struct fw_eui64) 381 382#define FWOHCI_RDREG _IOWR('S', 80, struct fw_reg_req_t) 383#define FWOHCI_WRREG _IOWR('S', 81, struct fw_reg_req_t) 384#define FWOHCI_RDPHYREG _IOWR('S', 82, struct fw_reg_req_t) 385#define FWOHCI_WRPHYREG _IOWR('S', 83, struct fw_reg_req_t) 386 387#define DUMPDMA _IOWR('S', 82, u_int32_t) 388 389#ifdef _KERNEL 390 391#define FWMAXNDMA 0x100 /* 8 bits DMA channel id. in device No. */ 392 393#if __FreeBSD_version < 500000 394#define dev2unit(x) ((minor(x) & 0xff) | (minor(x) >> 8)) 395#define unit2minor(x) (((x) & 0xff) | (((x) << 8) & ~0xffff)) 396#endif 397 398#define MAKEMINOR(f, u, s) \ 399 unit2minor((f) | (((u) & 0xff) << 8) | (s & 0xff)) 400#define DEV2UNIT(x) ((dev2unit(x) & 0xff00) >> 8) 401#define DEV2SUB(x) (dev2unit(x) & 0xff) 402 403#define FWMEM_FLAG 0x10000 404#define DEV_FWMEM(x) (dev2unit(x) & FWMEM_FLAG) 405#endif 406#endif 407