firewire.h revision 118293
151974Smsmith/* 265245Smsmith * Copyright (c) 2003 Hidetoshi Shimokawa 365245Smsmith * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa 451974Smsmith * All rights reserved. 551974Smsmith * 651974Smsmith * Redistribution and use in source and binary forms, with or without 751974Smsmith * modification, are permitted provided that the following conditions 851974Smsmith * are met: 951974Smsmith * 1. Redistributions of source code must retain the above copyright 1051974Smsmith * notice, this list of conditions and the following disclaimer. 1151974Smsmith * 2. Redistributions in binary form must reproduce the above copyright 1251974Smsmith * notice, this list of conditions and the following disclaimer in the 1351974Smsmith * documentation and/or other materials provided with the distribution. 1451974Smsmith * 3. All advertising materials mentioning features or use of this software 1551974Smsmith * must display the acknowledgement as bellow: 1651974Smsmith * 1751974Smsmith * This product includes software developed by K. Kobayashi and H. Shimokawa 1851974Smsmith * 1951974Smsmith * 4. The name of the author may not be used to endorse or promote products 2051974Smsmith * derived from this software without specific prior written permission. 2151974Smsmith * 2251974Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2351974Smsmith * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 2451974Smsmith * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 2551974Smsmith * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 2651974Smsmith * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27106225Semoore * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28106225Semoore * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29106225Semoore * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 30106225Semoore * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31106225Semoore * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32106225Semoore * POSSIBILITY OF SUCH DAMAGE. 33106225Semoore * 34106225Semoore * $FreeBSD: head/sys/dev/firewire/firewire.h 118293 2003-08-01 04:51:21Z simokawa $ 35106225Semoore * 36106225Semoore */ 37106225Semoore 38106225Semoore#ifndef _FIREWIRE_H 39105419Semoore#define _FIREWIRE_H 1 40106225Semoore 41105419Semoore#define DEV_DEF 0 42105419Semoore#define DEV_DV 2 43106225Semoore 44106225Semoorestruct fw_isochreq { 45106225Semoore unsigned char ch:6, 46106225Semoore tag:2; 47106225Semoore}; 48106225Semoore 49106225Semoorestruct fw_isobufreq { 50106225Semoore struct fw_bufspec { 51106225Semoore unsigned int nchunk; 52106225Semoore unsigned int npacket; 53106225Semoore unsigned int psize; 54105419Semoore } tx, rx; 55106225Semoore}; 5651974Smsmith 5751974Smsmithstruct fw_addr { 5851974Smsmith unsigned long hi; 5965245Smsmith unsigned long lo; 6065245Smsmith}; 61112946Sphk 6265245Smsmithstruct fw_asybindreq { 6351974Smsmith struct fw_addr start; 6465245Smsmith unsigned long len; 6587599Sobrien}; 6687599Sobrien 6765245Smsmithstruct fw_reg_req_t { 6865245Smsmith unsigned long addr; 6965245Smsmith unsigned long data; 7065245Smsmith}; 7187599Sobrien 7251974Smsmith#define MAXREC(x) (2 << (x)) 7351974Smsmith#define FWPMAX_S400 (2048 + 20) /* MAXREC plus space for control data */ 7451974Smsmith#define FWMAXQUEUE 64 7551974Smsmith 7651974Smsmith#define FWLOCALBUS 0xffc0 7751974Smsmith 7851974Smsmith#define FWTCODE_WREQQ 0 7951974Smsmith#define FWTCODE_WREQB 1 8051974Smsmith#define FWTCODE_WRES 2 8151974Smsmith#define FWTCODE_RREQQ 4 8251974Smsmith#define FWTCODE_RREQB 5 8351974Smsmith#define FWTCODE_RRESQ 6 8451974Smsmith#define FWTCODE_RRESB 7 8551974Smsmith#define FWTCODE_CYCS 8 8651974Smsmith#define FWTCODE_LREQ 9 8751974Smsmith#define FWTCODE_STREAM 0xa 8851974Smsmith#define FWTCODE_LRES 0xb 8951974Smsmith#define FWTCODE_PHY 0xe 9051974Smsmith 9165245Smsmith#define FWRETRY_1 0 9265245Smsmith#define FWRETRY_X 1 9365245Smsmith#define FWRETRY_A 2 9465245Smsmith#define FWRETRY_B 3 9565245Smsmith 9665245Smsmith#define FWRCODE_COMPLETE 0 9765245Smsmith#define FWRCODE_ER_CONFL 4 9865245Smsmith#define FWRCODE_ER_DATA 5 9951974Smsmith#define FWRCODE_ER_TYPE 6 10065245Smsmith#define FWRCODE_ER_ADDR 7 10165245Smsmith 10251974Smsmith#define FWSPD_S100 0 10351974Smsmith#define FWSPD_S200 1 10451974Smsmith#define FWSPD_S400 2 10551974Smsmith 10651974Smsmith#define FWP_TL_VALID (1 << 7) 10760938Sjake 10851974Smsmithstruct fw_isohdr { 10951974Smsmith u_int32_t hdr[1]; 11051974Smsmith}; 11165245Smsmith 11251974Smsmithstruct fw_asyhdr { 11351974Smsmith u_int32_t hdr[4]; 11451974Smsmith}; 11551974Smsmith 11665245Smsmith#if BYTE_ORDER == BIG_ENDIAN 11765245Smsmith#define BIT4x2(x,y) u_int8_t x:4, y:4 11865245Smsmith#define BIT16x2(x,y) u_int32_t x:16, y:16 11965245Smsmith#else 12065245Smsmith#define BIT4x2(x,y) u_int8_t y:4, x:4 12165245Smsmith#define BIT16x2(x,y) u_int32_t y:16, x:16 12251974Smsmith#endif 12365245Smsmith 12465245Smsmith 12551974Smsmith#if BYTE_ORDER == BIG_ENDIAN 12651974Smsmith#define COMMON_HDR(a,b,c,d) u_int32_t a:16,b:8,c:4,d:4 12751974Smsmith#define COMMON_RES(a,b,c,d) u_int32_t a:16,b:4,c:4,d:8 12851974Smsmith#else 12951974Smsmith#define COMMON_HDR(a,b,c,d) u_int32_t d:4,c:4,b:8,a:16 13065245Smsmith#define COMMON_RES(a,b,c,d) u_int32_t d:8,c:4,b:4,a:16 13165245Smsmith#endif 13265245Smsmith 13365245Smsmithstruct fw_pkt { 13465245Smsmith union { 13551974Smsmith u_int32_t ld[0]; 136105419Semoore struct { 13751974Smsmith COMMON_HDR(, , tcode, ); 13851974Smsmith } common; 13965245Smsmith struct { 14065245Smsmith COMMON_HDR(len, chtag, tcode, sy); 14165245Smsmith u_int32_t payload[0]; 14265245Smsmith } stream; 14365245Smsmith struct { 14465245Smsmith COMMON_HDR(dst, tlrt, tcode, pri); 14565245Smsmith BIT16x2(src, ); 14665245Smsmith } hdr; 14765245Smsmith struct { 14865245Smsmith COMMON_HDR(dst, tlrt, tcode, pri); 14965245Smsmith BIT16x2(src, dest_hi); 15065245Smsmith u_int32_t dest_lo; 15151974Smsmith } rreqq; 15251974Smsmith struct { 15351974Smsmith COMMON_HDR(dst, tlrt, tcode, pri); 15451974Smsmith COMMON_RES(src, rtcode, , ); 15551974Smsmith u_int32_t :32; 15651974Smsmith } wres; 15751974Smsmith struct { 15851974Smsmith COMMON_HDR(dst, tlrt, tcode, pri); 15951974Smsmith BIT16x2(src, dest_hi); 16051974Smsmith u_int32_t dest_lo; 16151974Smsmith BIT16x2(len, extcode); 16251974Smsmith } rreqb; 16351974Smsmith struct { 16458496Smsmith COMMON_HDR(dst, tlrt, tcode, pri); 16558496Smsmith BIT16x2(src, dest_hi); 16651974Smsmith u_int32_t dest_lo; 16751974Smsmith u_int32_t data; 16851974Smsmith } wreqq; 16951974Smsmith struct { 17051974Smsmith COMMON_HDR(dst, tlrt, tcode, pri); 17151974Smsmith BIT16x2(src, dest_hi); 17251974Smsmith u_int32_t dest_lo; 17351974Smsmith u_int32_t data; 17451974Smsmith } cyc; 17551974Smsmith struct { 17651974Smsmith COMMON_HDR(dst, tlrt, tcode, pri); 17751974Smsmith COMMON_RES(src, rtcode, , ); 17851974Smsmith u_int32_t :32; 17965245Smsmith u_int32_t data; 18051974Smsmith } rresq; 18151974Smsmith struct { 18251974Smsmith COMMON_HDR(dst, tlrt, tcode, pri); 18351974Smsmith BIT16x2(src, dest_hi); 18465245Smsmith u_int32_t dest_lo; 18551974Smsmith BIT16x2(len, extcode); 18651974Smsmith u_int32_t payload[0]; 18751974Smsmith } wreqb; 18851974Smsmith struct { 18951974Smsmith COMMON_HDR(dst, tlrt, tcode, pri); 190131394Sps BIT16x2(src, dest_hi); 19151974Smsmith u_int32_t dest_lo; 19251974Smsmith BIT16x2(len, extcode); 19365245Smsmith#define FW_LREQ_MSKSWAP 1 19465245Smsmith#define FW_LREQ_CMPSWAP 2 19551974Smsmith#define FW_LREQ_FTADD 3 19665245Smsmith#define FW_LREQ_LTADD 4 19765245Smsmith#define FW_LREQ_BDADD 5 19860938Sjake#define FW_LREQ_WRADD 6 19965245Smsmith u_int32_t payload[0]; 20051974Smsmith } lreq; 20165245Smsmith struct { 20265245Smsmith COMMON_HDR(dst, tlrt, tcode, pri); 20365245Smsmith COMMON_RES(src, rtcode, , ); 20458883Smsmith u_int32_t :32; 20565245Smsmith BIT16x2(len, extcode); 206130585Sphk u_int32_t payload[0]; 20765245Smsmith } rresb; 20851974Smsmith struct { 20951974Smsmith COMMON_HDR(dst, tlrt, tcode, pri); 21065245Smsmith COMMON_RES(src, rtcode, , ); 21165245Smsmith u_int32_t :32; 21265245Smsmith BIT16x2(len, extcode); 21365245Smsmith u_int32_t payload[0]; 21465245Smsmith } lres; 21551974Smsmith } mode; 216107756Semoore}; 217107756Semoore 21865245Smsmithstruct fw_eui64 { 21965245Smsmith u_int32_t hi, lo; 22065245Smsmith}; 22165245Smsmith#define FW_EUI64_BYTE(eui, x) \ 22265245Smsmith ((((x)<4)? \ 22365245Smsmith ((eui)->hi >> (8*(3-(x)))): \ 22465245Smsmith ((eui)->lo >> (8*(7-(x)))) \ 22551974Smsmith ) & 0xff) 22651974Smsmith#define FW_EUI64_EQUAL(x, y) \ 22751974Smsmith ((x).hi == (y).hi && (x).lo == (y).lo) 22865245Smsmith 22958883Smsmithstruct fw_asyreq { 23065245Smsmith struct fw_asyreq_t{ 23165245Smsmith unsigned char sped; 23265245Smsmith unsigned int type; 23365245Smsmith#define FWASREQNODE 0 23465245Smsmith#define FWASREQEUI 1 23558883Smsmith#define FWASRESTL 2 23658883Smsmith#define FWASREQSTREAM 3 23765245Smsmith unsigned short len; 23851974Smsmith union { 23965245Smsmith struct fw_eui64 eui; 24065245Smsmith }dst; 24151974Smsmith }req; 24251974Smsmith struct fw_pkt pkt; 24365245Smsmith u_int32_t data[512]; 24451974Smsmith}; 24565245Smsmith 24665245Smsmithstruct fw_devinfo { 24765245Smsmith struct fw_eui64 eui; 24851974Smsmith u_int16_t dst; 24951974Smsmith u_int16_t status; 25051974Smsmith}; 25151974Smsmith 25251974Smsmith#define FW_MAX_DEVLST 70 25351974Smsmithstruct fw_devlstreq { 25451974Smsmith u_int16_t n; 25551974Smsmith u_int16_t info_len; 25651974Smsmith struct fw_devinfo dev[FW_MAX_DEVLST]; 257125975Sphk}; 25851974Smsmith 25951974Smsmith#define FW_SELF_ID_PORT_CONNECTED_TO_CHILD 3 26051974Smsmith#define FW_SELF_ID_PORT_CONNECTED_TO_PARENT 2 26151974Smsmith#define FW_SELF_ID_PORT_NOT_CONNECTED 1 26251974Smsmith#define FW_SELF_ID_PORT_NOT_EXISTS 0 26351974Smsmith#if BYTE_ORDER == BIG_ENDIAN 26465245Smsmithunion fw_self_id { 265120988Sps struct { 26651974Smsmith u_int32_t id:2, 26751974Smsmith phy_id:6, 26865245Smsmith sequel:1, 26965245Smsmith link_active:1, 27065245Smsmith gap_count:6, 27165245Smsmith phy_speed:2, 27265245Smsmith phy_delay:2, 27365245Smsmith contender:1, 27465245Smsmith power_class:3, 27565245Smsmith port0:2, 27665245Smsmith port1:2, 27765245Smsmith port2:2, 27865245Smsmith initiated_reset:1, 27965245Smsmith more_packets:1; 28065245Smsmith } p0; 28165245Smsmith struct { 28265245Smsmith u_int32_t 28365245Smsmith id:2, 28465245Smsmith phy_id:6, 28565245Smsmith sequel:1, 28665245Smsmith sequence_num:3, 28765245Smsmith :2, 28865245Smsmith porta:2, 28965245Smsmith portb:2, 29065245Smsmith portc:2, 29165245Smsmith portd:2, 29265245Smsmith porte:2, 29365245Smsmith portf:2, 29465245Smsmith portg:2, 29565245Smsmith porth:2, 29665245Smsmith :1, 29765245Smsmith more_packets:1; 29865245Smsmith } p1; 29965245Smsmith}; 30065245Smsmith#else 30165245Smsmithunion fw_self_id { 30265245Smsmith struct { 30365245Smsmith u_int32_t more_packets:1, 30465245Smsmith initiated_reset:1, 30565245Smsmith port2:2, 30665245Smsmith port1:2, 30765245Smsmith port0:2, 30865245Smsmith power_class:3, 30965245Smsmith contender:1, 31065245Smsmith phy_delay:2, 31165245Smsmith phy_speed:2, 31265245Smsmith gap_count:6, 31365245Smsmith link_active:1, 31465245Smsmith sequel:1, 31565245Smsmith phy_id:6, 31665245Smsmith id:2; 31765245Smsmith } p0; 31865245Smsmith struct { 31965245Smsmith u_int32_t more_packets:1, 32065245Smsmith reserved1:1, 32165245Smsmith porth:2, 32265245Smsmith portg:2, 32365245Smsmith portf:2, 32465245Smsmith porte:2, 32565245Smsmith portd:2, 32665245Smsmith portc:2, 32765245Smsmith portb:2, 32865245Smsmith porta:2, 32965245Smsmith reserved2:2, 33065245Smsmith sequence_num:3, 33165245Smsmith sequel:1, 33265245Smsmith phy_id:6, 33365245Smsmith id:2; 33465245Smsmith } p1; 33565245Smsmith}; 33665245Smsmith#endif 33765245Smsmith 33865245Smsmith 33965245Smsmithstruct fw_topology_map { 34065245Smsmith u_int32_t crc:16, 34165245Smsmith crc_len:16; 34265245Smsmith u_int32_t generation; 34365245Smsmith u_int32_t self_id_count:16, 34465245Smsmith node_count:16; 34565245Smsmith union fw_self_id self_id[4*64]; 34665245Smsmith}; 34765245Smsmith 34865245Smsmithstruct fw_speed_map { 34965245Smsmith u_int32_t crc:16, 35065245Smsmith crc_len:16; 35165245Smsmith u_int32_t generation; 35265245Smsmith u_int8_t speed[64][64]; 35365245Smsmith}; 35465245Smsmith 35565245Smsmithstruct fw_crom_buf { 35665245Smsmith struct fw_eui64 eui; 35765245Smsmith int len; 35865245Smsmith void *ptr; 35965245Smsmith}; 36065245Smsmith 36165245Smsmith/* 36265245Smsmith * FireWire specific system requests. 36365245Smsmith */ 36465245Smsmith#define FW_SSTBUF _IOWR('S', 86, struct fw_isobufreq) 36565245Smsmith#define FW_GSTBUF _IOWR('S', 87, struct fw_isobufreq) 36665245Smsmith#define FW_SRSTREAM _IOWR('S', 88, struct fw_isochreq) 36765245Smsmith#define FW_GRSTREAM _IOWR('S', 89, struct fw_isochreq) 36865245Smsmith#define FW_STSTREAM _IOWR('S', 90, struct fw_isochreq) 36965245Smsmith#define FW_GTSTREAM _IOWR('S', 91, struct fw_isochreq) 37065245Smsmith 37165245Smsmith#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 385#define DUMPDMA _IOWR('S', 82, u_int32_t) 386 387#ifdef _KERNEL 388 389#define FWMAXNDMA 0x100 /* 8 bits DMA channel id. in device No. */ 390 391#if __FreeBSD_version < 500000 392#define dev2unit(x) ((minor(x) & 0xff) | (minor(x) >> 8)) 393#define unit2minor(x) (((x) & 0xff) | (((x) << 8) & ~0xffff)) 394#endif 395 396#define UNIT2MIN(x) (((x) & 0xff) << 8) 397#define DEV2UNIT(x) ((dev2unit(x) & 0xff00) >> 8) 398#define DEV2SUB(x) (dev2unit(x) & 0xff) 399 400#define FWMEM_FLAG 0x10000 401#define DEV_FWMEM(x) (dev2unit(x) & FWMEM_FLAG) 402#endif 403#endif 404