1098ca2bdSWarner Losh /*- 277ee030bSHidetoshi Shimokawa * Copyright (c) 2003 Hidetoshi Shimokawa 33c60ba66SKatsushi Kobayashi * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa 43c60ba66SKatsushi Kobayashi * All rights reserved. 53c60ba66SKatsushi Kobayashi * 63c60ba66SKatsushi Kobayashi * Redistribution and use in source and binary forms, with or without 73c60ba66SKatsushi Kobayashi * modification, are permitted provided that the following conditions 83c60ba66SKatsushi Kobayashi * are met: 93c60ba66SKatsushi Kobayashi * 1. Redistributions of source code must retain the above copyright 103c60ba66SKatsushi Kobayashi * notice, this list of conditions and the following disclaimer. 113c60ba66SKatsushi Kobayashi * 2. Redistributions in binary form must reproduce the above copyright 123c60ba66SKatsushi Kobayashi * notice, this list of conditions and the following disclaimer in the 133c60ba66SKatsushi Kobayashi * documentation and/or other materials provided with the distribution. 143c60ba66SKatsushi Kobayashi * 3. All advertising materials mentioning features or use of this software 153c60ba66SKatsushi Kobayashi * must display the acknowledgement as bellow: 163c60ba66SKatsushi Kobayashi * 173c60ba66SKatsushi Kobayashi * This product includes software developed by K. Kobayashi and H. Shimokawa 183c60ba66SKatsushi Kobayashi * 193c60ba66SKatsushi Kobayashi * 4. The name of the author may not be used to endorse or promote products 203c60ba66SKatsushi Kobayashi * derived from this software without specific prior written permission. 213c60ba66SKatsushi Kobayashi * 223c60ba66SKatsushi Kobayashi * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 233c60ba66SKatsushi Kobayashi * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 243c60ba66SKatsushi Kobayashi * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 253c60ba66SKatsushi Kobayashi * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 263c60ba66SKatsushi Kobayashi * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 273c60ba66SKatsushi Kobayashi * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 283c60ba66SKatsushi Kobayashi * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 293c60ba66SKatsushi Kobayashi * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 303c60ba66SKatsushi Kobayashi * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 313c60ba66SKatsushi Kobayashi * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 323c60ba66SKatsushi Kobayashi * POSSIBILITY OF SUCH DAMAGE. 333c60ba66SKatsushi Kobayashi * 343c60ba66SKatsushi Kobayashi * $FreeBSD$ 353c60ba66SKatsushi Kobayashi * 363c60ba66SKatsushi Kobayashi */ 373c60ba66SKatsushi Kobayashi 3810d3ed64SHidetoshi Shimokawa #ifdef __DragonFly__ 3910d3ed64SHidetoshi Shimokawa typedef d_thread_t fw_proc; 4010d3ed64SHidetoshi Shimokawa #include <sys/select.h> 4110d3ed64SHidetoshi Shimokawa #elif __FreeBSD_version >= 500000 423c60ba66SKatsushi Kobayashi typedef struct thread fw_proc; 433c60ba66SKatsushi Kobayashi #include <sys/selinfo.h> 443c60ba66SKatsushi Kobayashi #else 453c60ba66SKatsushi Kobayashi typedef struct proc fw_proc; 463c60ba66SKatsushi Kobayashi #include <sys/select.h> 473c60ba66SKatsushi Kobayashi #endif 483c60ba66SKatsushi Kobayashi 4977ee030bSHidetoshi Shimokawa #include <sys/uio.h> 5077ee030bSHidetoshi Shimokawa 513c60ba66SKatsushi Kobayashi #define splfw splimp 523c60ba66SKatsushi Kobayashi 533c60ba66SKatsushi Kobayashi struct fw_device{ 5403161bbcSDoug Rabson uint16_t dst; 553c60ba66SKatsushi Kobayashi struct fw_eui64 eui; 5603161bbcSDoug Rabson uint8_t speed; 5703161bbcSDoug Rabson uint8_t maxrec; 5803161bbcSDoug Rabson uint8_t nport; 5903161bbcSDoug Rabson uint8_t power; 603c60ba66SKatsushi Kobayashi #define CSRROMOFF 0x400 613c60ba66SKatsushi Kobayashi #define CSRROMSIZE 0x400 623c60ba66SKatsushi Kobayashi int rommax; /* offset from 0xffff f000 0000 */ 6303161bbcSDoug Rabson uint32_t csrrom[CSRROMSIZE/4]; 643c60ba66SKatsushi Kobayashi int rcnt; 65f90ce7b1SHidetoshi Shimokawa struct firewire_comm *fc; 6603161bbcSDoug Rabson uint32_t status; 673c60ba66SKatsushi Kobayashi #define FWDEVINIT 1 683c60ba66SKatsushi Kobayashi #define FWDEVATTACHED 2 693c60ba66SKatsushi Kobayashi #define FWDEVINVAL 3 700981f5f0SHidetoshi Shimokawa STAILQ_ENTRY(fw_device) link; 713c60ba66SKatsushi Kobayashi }; 7293001c72SHidetoshi Shimokawa 733c60ba66SKatsushi Kobayashi struct firewire_softc { 7410d3ed64SHidetoshi Shimokawa #if defined(__FreeBSD__) && __FreeBSD_version >= 500000 7589c9c53dSPoul-Henning Kamp struct cdev *dev; 763c60ba66SKatsushi Kobayashi #endif 773c60ba66SKatsushi Kobayashi struct firewire_comm *fc; 783c60ba66SKatsushi Kobayashi }; 7993001c72SHidetoshi Shimokawa 803c60ba66SKatsushi Kobayashi #define FW_MAX_DMACH 0x20 813c60ba66SKatsushi Kobayashi #define FW_MAX_DEVCH FW_MAX_DMACH 823c60ba66SKatsushi Kobayashi #define FW_XFERTIMEOUT 1 8393001c72SHidetoshi Shimokawa 843c60ba66SKatsushi Kobayashi struct firewire_dev_comm { 853c60ba66SKatsushi Kobayashi device_t dev; 863c60ba66SKatsushi Kobayashi struct firewire_comm *fc; 87d09a5d6fSHidetoshi Shimokawa void (*post_busreset) (void *); 88d09a5d6fSHidetoshi Shimokawa void (*post_explore) (void *); 893c60ba66SKatsushi Kobayashi }; 903c60ba66SKatsushi Kobayashi 913c60ba66SKatsushi Kobayashi struct tcode_info { 923c60ba66SKatsushi Kobayashi u_char hdr_len; /* IEEE1394 header length */ 933c60ba66SKatsushi Kobayashi u_char flag; 943c60ba66SKatsushi Kobayashi #define FWTI_REQ (1 << 0) 953c60ba66SKatsushi Kobayashi #define FWTI_RES (1 << 1) 963c60ba66SKatsushi Kobayashi #define FWTI_TLABEL (1 << 2) 973c60ba66SKatsushi Kobayashi #define FWTI_BLOCK_STR (1 << 3) 983c60ba66SKatsushi Kobayashi #define FWTI_BLOCK_ASY (1 << 4) 993c60ba66SKatsushi Kobayashi }; 1003c60ba66SKatsushi Kobayashi 1013c60ba66SKatsushi Kobayashi struct firewire_comm{ 1023c60ba66SKatsushi Kobayashi device_t dev; 1033c60ba66SKatsushi Kobayashi device_t bdev; 10403161bbcSDoug Rabson uint16_t busid:10, 1053c60ba66SKatsushi Kobayashi nodeid:6; 1063c60ba66SKatsushi Kobayashi u_int mode; 1073c60ba66SKatsushi Kobayashi u_int nport; 1083c60ba66SKatsushi Kobayashi u_int speed; 1093c60ba66SKatsushi Kobayashi u_int maxrec; 1103c60ba66SKatsushi Kobayashi u_int irm; 1113c60ba66SKatsushi Kobayashi u_int max_node; 1123c60ba66SKatsushi Kobayashi u_int max_hop; 1133c60ba66SKatsushi Kobayashi u_int max_asyretry; 1143c60ba66SKatsushi Kobayashi #define FWPHYASYST (1 << 0) 1153c60ba66SKatsushi Kobayashi u_int retry_count; 11603161bbcSDoug Rabson uint32_t ongobus:10, 1173c60ba66SKatsushi Kobayashi ongonode:6, 1183c60ba66SKatsushi Kobayashi ongoaddr:16; 1193c60ba66SKatsushi Kobayashi struct fw_device *ongodev; 1203c60ba66SKatsushi Kobayashi struct fw_eui64 ongoeui; 1213c60ba66SKatsushi Kobayashi #define FWMAXCSRDIR 16 1223c60ba66SKatsushi Kobayashi SLIST_HEAD(, csrdir) ongocsr; 1233c60ba66SKatsushi Kobayashi SLIST_HEAD(, csrdir) csrfree; 12403161bbcSDoug Rabson uint32_t status; 125630529adSHidetoshi Shimokawa #define FWBUSNOTREADY (-1) 1263c60ba66SKatsushi Kobayashi #define FWBUSRESET 0 1273c60ba66SKatsushi Kobayashi #define FWBUSINIT 1 1283c60ba66SKatsushi Kobayashi #define FWBUSCYMELECT 2 1293c60ba66SKatsushi Kobayashi #define FWBUSMGRELECT 3 1303c60ba66SKatsushi Kobayashi #define FWBUSMGRDONE 4 1313c60ba66SKatsushi Kobayashi #define FWBUSEXPLORE 5 1323c60ba66SKatsushi Kobayashi #define FWBUSPHYCONF 6 1333c60ba66SKatsushi Kobayashi #define FWBUSEXPDONE 7 1343c60ba66SKatsushi Kobayashi #define FWBUSCOMPLETION 10 1353c60ba66SKatsushi Kobayashi int nisodma; 136c547b896SHidetoshi Shimokawa struct fw_eui64 eui; 13793001c72SHidetoshi Shimokawa struct fw_xferq 13893001c72SHidetoshi Shimokawa *arq, *atq, *ars, *ats, *it[FW_MAX_DMACH],*ir[FW_MAX_DMACH]; 13993001c72SHidetoshi Shimokawa STAILQ_HEAD(, tlabel) tlabels[0x40]; 14093001c72SHidetoshi Shimokawa STAILQ_HEAD(, fw_bind) binds; 1410981f5f0SHidetoshi Shimokawa STAILQ_HEAD(, fw_device) devices; 14293001c72SHidetoshi Shimokawa u_int sid_cnt; 14393001c72SHidetoshi Shimokawa #define CSRSIZE 0x4000 14403161bbcSDoug Rabson uint32_t csr_arc[CSRSIZE/4]; 14593001c72SHidetoshi Shimokawa #define CROMSIZE 0x400 14603161bbcSDoug Rabson uint32_t *config_rom; 1470bc666e0SHidetoshi Shimokawa struct crom_src_buf *crom_src_buf; 1480bc666e0SHidetoshi Shimokawa struct crom_src *crom_src; 1490bc666e0SHidetoshi Shimokawa struct crom_chunk *crom_root; 15093001c72SHidetoshi Shimokawa struct fw_topology_map *topology_map; 15193001c72SHidetoshi Shimokawa struct fw_speed_map *speed_map; 15293001c72SHidetoshi Shimokawa struct callout busprobe_callout; 1530981f5f0SHidetoshi Shimokawa struct callout bmr_callout; 1540981f5f0SHidetoshi Shimokawa struct callout timeout_callout; 1550981f5f0SHidetoshi Shimokawa struct callout retry_probe_callout; 15603161bbcSDoug Rabson uint32_t (*cyctimer) (struct firewire_comm *); 157d09a5d6fSHidetoshi Shimokawa void (*ibr) (struct firewire_comm *); 15803161bbcSDoug Rabson uint32_t (*set_bmr) (struct firewire_comm *, uint32_t); 15989c9c53dSPoul-Henning Kamp int (*ioctl) (struct cdev *, u_long, caddr_t, int, fw_proc *); 160d09a5d6fSHidetoshi Shimokawa int (*irx_enable) (struct firewire_comm *, int); 161d09a5d6fSHidetoshi Shimokawa int (*irx_disable) (struct firewire_comm *, int); 162d09a5d6fSHidetoshi Shimokawa int (*itx_enable) (struct firewire_comm *, int); 163d09a5d6fSHidetoshi Shimokawa int (*itx_disable) (struct firewire_comm *, int); 164d09a5d6fSHidetoshi Shimokawa void (*timeout) (void *); 165d09a5d6fSHidetoshi Shimokawa void (*poll) (struct firewire_comm *, int, int); 166d09a5d6fSHidetoshi Shimokawa void (*set_intr) (struct firewire_comm *, int); 16703161bbcSDoug Rabson void (*irx_post) (struct firewire_comm *, uint32_t *); 16803161bbcSDoug Rabson void (*itx_post) (struct firewire_comm *, uint32_t *); 16993001c72SHidetoshi Shimokawa struct tcode_info *tcode; 17077ee030bSHidetoshi Shimokawa bus_dma_tag_t dmat; 17193001c72SHidetoshi Shimokawa }; 17293001c72SHidetoshi Shimokawa #define CSRARC(sc, offset) ((sc)->csr_arc[(offset)/4]) 17393001c72SHidetoshi Shimokawa 17493001c72SHidetoshi Shimokawa struct csrdir{ 17503161bbcSDoug Rabson uint32_t ongoaddr; 17603161bbcSDoug Rabson uint32_t off; 17793001c72SHidetoshi Shimokawa SLIST_ENTRY(csrdir) link; 17893001c72SHidetoshi Shimokawa }; 17993001c72SHidetoshi Shimokawa 1803c60ba66SKatsushi Kobayashi struct fw_xferq { 1813c60ba66SKatsushi Kobayashi int flag; 1823c60ba66SKatsushi Kobayashi #define FWXFERQ_CHTAGMASK 0xff 1833c60ba66SKatsushi Kobayashi #define FWXFERQ_RUNNING (1 << 8) 1843c60ba66SKatsushi Kobayashi #define FWXFERQ_STREAM (1 << 9) 1853c60ba66SKatsushi Kobayashi 1863c60ba66SKatsushi Kobayashi #define FWXFERQ_BULK (1 << 11) 1873c60ba66SKatsushi Kobayashi #define FWXFERQ_MODEMASK (7 << 10) 1883c60ba66SKatsushi Kobayashi 1893c60ba66SKatsushi Kobayashi #define FWXFERQ_EXTBUF (1 << 13) 1903c60ba66SKatsushi Kobayashi #define FWXFERQ_OPEN (1 << 14) 1913c60ba66SKatsushi Kobayashi 1923c60ba66SKatsushi Kobayashi #define FWXFERQ_HANDLER (1 << 16) 1933c60ba66SKatsushi Kobayashi #define FWXFERQ_WAKEUP (1 << 17) 194d09a5d6fSHidetoshi Shimokawa void (*start) (struct firewire_comm*); 1956cada79aSHidetoshi Shimokawa int dmach; 19677ee030bSHidetoshi Shimokawa STAILQ_HEAD(, fw_xfer) q; 1973c60ba66SKatsushi Kobayashi u_int queued; 1983c60ba66SKatsushi Kobayashi u_int maxq; 1993c60ba66SKatsushi Kobayashi u_int psize; 2003c60ba66SKatsushi Kobayashi STAILQ_HEAD(, fw_bind) binds; 20177ee030bSHidetoshi Shimokawa struct fwdma_alloc_multi *buf; 2023c60ba66SKatsushi Kobayashi u_int bnchunk; 2033c60ba66SKatsushi Kobayashi u_int bnpacket; 2043c60ba66SKatsushi Kobayashi struct fw_bulkxfer *bulkxfer; 2053c60ba66SKatsushi Kobayashi STAILQ_HEAD(, fw_bulkxfer) stvalid; 2063c60ba66SKatsushi Kobayashi STAILQ_HEAD(, fw_bulkxfer) stfree; 2075a7ba74dSHidetoshi Shimokawa STAILQ_HEAD(, fw_bulkxfer) stdma; 2083c60ba66SKatsushi Kobayashi struct fw_bulkxfer *stproc; 2093c60ba66SKatsushi Kobayashi struct selinfo rsel; 2103c60ba66SKatsushi Kobayashi caddr_t sc; 211d09a5d6fSHidetoshi Shimokawa void (*hand) (struct fw_xferq *); 2123c60ba66SKatsushi Kobayashi }; 21393001c72SHidetoshi Shimokawa 2143c60ba66SKatsushi Kobayashi struct fw_bulkxfer{ 21577ee030bSHidetoshi Shimokawa int poffset; 2162b4601d1SHidetoshi Shimokawa struct mbuf *mbuf; 2173c60ba66SKatsushi Kobayashi STAILQ_ENTRY(fw_bulkxfer) link; 2183c60ba66SKatsushi Kobayashi caddr_t start; 2193c60ba66SKatsushi Kobayashi caddr_t end; 2202b4601d1SHidetoshi Shimokawa int resp; 2213c60ba66SKatsushi Kobayashi }; 22293001c72SHidetoshi Shimokawa 2233c60ba66SKatsushi Kobayashi struct tlabel{ 2243c60ba66SKatsushi Kobayashi struct fw_xfer *xfer; 2253c60ba66SKatsushi Kobayashi STAILQ_ENTRY(tlabel) link; 2263c60ba66SKatsushi Kobayashi }; 22793001c72SHidetoshi Shimokawa 2283c60ba66SKatsushi Kobayashi struct fw_bind{ 229c4778b5dSHidetoshi Shimokawa u_int64_t start; 230c4778b5dSHidetoshi Shimokawa u_int64_t end; 23177ee030bSHidetoshi Shimokawa STAILQ_HEAD(, fw_xfer) xferlist; 2323c60ba66SKatsushi Kobayashi STAILQ_ENTRY(fw_bind) fclist; 2333c60ba66SKatsushi Kobayashi STAILQ_ENTRY(fw_bind) chlist; 23477ee030bSHidetoshi Shimokawa #define FWACT_NULL 0 23577ee030bSHidetoshi Shimokawa #define FWACT_XFER 2 23677ee030bSHidetoshi Shimokawa #define FWACT_CH 3 23703161bbcSDoug Rabson uint8_t act_type; 23803161bbcSDoug Rabson uint8_t sub; 2393c60ba66SKatsushi Kobayashi }; 2403c60ba66SKatsushi Kobayashi 2413c60ba66SKatsushi Kobayashi struct fw_xfer{ 2423c60ba66SKatsushi Kobayashi caddr_t sc; 2433c60ba66SKatsushi Kobayashi struct firewire_comm *fc; 2443c60ba66SKatsushi Kobayashi struct fw_xferq *q; 245864d7e72SHidetoshi Shimokawa struct timeval tv; 24677ee030bSHidetoshi Shimokawa int8_t resp; 2473c60ba66SKatsushi Kobayashi #define FWXF_INIT 0 2483c60ba66SKatsushi Kobayashi #define FWXF_INQ 1 2493c60ba66SKatsushi Kobayashi #define FWXF_START 2 2503c60ba66SKatsushi Kobayashi #define FWXF_SENT 3 2513c60ba66SKatsushi Kobayashi #define FWXF_SENTERR 4 2523c60ba66SKatsushi Kobayashi #define FWXF_BUSY 8 2533c60ba66SKatsushi Kobayashi #define FWXF_RCVD 10 25403161bbcSDoug Rabson uint8_t state; 25503161bbcSDoug Rabson uint8_t retry; 25603161bbcSDoug Rabson uint8_t tl; 257d09a5d6fSHidetoshi Shimokawa void (*retry_req) (struct fw_xfer *); 2583c60ba66SKatsushi Kobayashi union{ 259d09a5d6fSHidetoshi Shimokawa void (*hand) (struct fw_xfer *); 2603c60ba66SKatsushi Kobayashi } act; 2613c60ba66SKatsushi Kobayashi struct { 262c4778b5dSHidetoshi Shimokawa struct fw_pkt hdr; 26303161bbcSDoug Rabson uint32_t *payload; 26403161bbcSDoug Rabson uint16_t pay_len; 26503161bbcSDoug Rabson uint8_t spd; 2663c60ba66SKatsushi Kobayashi } send, recv; 2673c60ba66SKatsushi Kobayashi struct mbuf *mbuf; 2683c60ba66SKatsushi Kobayashi STAILQ_ENTRY(fw_xfer) link; 26948249fe0SHidetoshi Shimokawa struct malloc_type *malloc; 2703c60ba66SKatsushi Kobayashi }; 271c4778b5dSHidetoshi Shimokawa 272c4778b5dSHidetoshi Shimokawa struct fw_rcv_buf { 273c4778b5dSHidetoshi Shimokawa struct firewire_comm *fc; 274c4778b5dSHidetoshi Shimokawa struct fw_xfer *xfer; 275c4778b5dSHidetoshi Shimokawa struct iovec *vec; 276c4778b5dSHidetoshi Shimokawa u_int nvec; 27703161bbcSDoug Rabson uint8_t spd; 278c4778b5dSHidetoshi Shimokawa }; 279c4778b5dSHidetoshi Shimokawa 28003161bbcSDoug Rabson void fw_sidrcv (struct firewire_comm *, uint32_t *, u_int); 281d09a5d6fSHidetoshi Shimokawa void fw_rcv (struct fw_rcv_buf *); 282d09a5d6fSHidetoshi Shimokawa void fw_xfer_unload ( struct fw_xfer*); 283d09a5d6fSHidetoshi Shimokawa void fw_xfer_free_buf ( struct fw_xfer*); 284d09a5d6fSHidetoshi Shimokawa void fw_xfer_free ( struct fw_xfer*); 285d09a5d6fSHidetoshi Shimokawa struct fw_xfer *fw_xfer_alloc (struct malloc_type *); 286d09a5d6fSHidetoshi Shimokawa struct fw_xfer *fw_xfer_alloc_buf (struct malloc_type *, int, int); 287d09a5d6fSHidetoshi Shimokawa void fw_init (struct firewire_comm *); 288d09a5d6fSHidetoshi Shimokawa int fw_tbuf_update (struct firewire_comm *, int, int); 289d09a5d6fSHidetoshi Shimokawa int fw_rbuf_update (struct firewire_comm *, int, int); 290d09a5d6fSHidetoshi Shimokawa void fw_asybusy (struct fw_xfer *); 291d09a5d6fSHidetoshi Shimokawa int fw_bindadd (struct firewire_comm *, struct fw_bind *); 292d09a5d6fSHidetoshi Shimokawa int fw_bindremove (struct firewire_comm *, struct fw_bind *); 293d09a5d6fSHidetoshi Shimokawa int fw_asyreq (struct firewire_comm *, int, struct fw_xfer*); 294d09a5d6fSHidetoshi Shimokawa void fw_busreset (struct firewire_comm *); 29503161bbcSDoug Rabson uint16_t fw_crc16 (uint32_t *, uint32_t); 296d09a5d6fSHidetoshi Shimokawa void fw_xfer_timeout (void *); 297d09a5d6fSHidetoshi Shimokawa void fw_xfer_done (struct fw_xfer *); 298d09a5d6fSHidetoshi Shimokawa void fw_asy_callback (struct fw_xfer *); 299d09a5d6fSHidetoshi Shimokawa void fw_asy_callback_free (struct fw_xfer *); 300d09a5d6fSHidetoshi Shimokawa struct fw_device *fw_noderesolve_nodeid (struct firewire_comm *, int); 301d09a5d6fSHidetoshi Shimokawa struct fw_device *fw_noderesolve_eui64 (struct firewire_comm *, struct fw_eui64 *); 30203161bbcSDoug Rabson struct fw_bind *fw_bindlookup (struct firewire_comm *, uint16_t, uint32_t); 303d09a5d6fSHidetoshi Shimokawa void fw_drain_txq (struct firewire_comm *); 304d09a5d6fSHidetoshi Shimokawa int fwdev_makedev (struct firewire_softc *); 305d09a5d6fSHidetoshi Shimokawa int fwdev_destroydev (struct firewire_softc *); 3066a113b3dSRobert Watson void fwdev_clone (void *, struct ucred *, char *, int, struct cdev **); 3073c60ba66SKatsushi Kobayashi 3083c60ba66SKatsushi Kobayashi extern int firewire_debug; 3093c60ba66SKatsushi Kobayashi extern devclass_t firewire_devclass; 3103c60ba66SKatsushi Kobayashi 31110d3ed64SHidetoshi Shimokawa #ifdef __DragonFly__ 31210d3ed64SHidetoshi Shimokawa #define FWPRI PCATCH 31345545499SHidetoshi Shimokawa #else 31410d3ed64SHidetoshi Shimokawa #define FWPRI ((PZERO+8)|PCATCH) 31545545499SHidetoshi Shimokawa #endif 31645545499SHidetoshi Shimokawa 31710d3ed64SHidetoshi Shimokawa #if defined(__DragonFly__) || __FreeBSD_version < 500000 31810d3ed64SHidetoshi Shimokawa #define CALLOUT_INIT(x) callout_init(x) 31910d3ed64SHidetoshi Shimokawa #else 32010d3ed64SHidetoshi Shimokawa #define CALLOUT_INIT(x) callout_init(x, 0 /* mpsafe */) 32110d3ed64SHidetoshi Shimokawa #endif 32210d3ed64SHidetoshi Shimokawa 32310d3ed64SHidetoshi Shimokawa #if defined(__DragonFly__) || __FreeBSD_version < 500000 324c4778b5dSHidetoshi Shimokawa /* compatibility shim for 4.X */ 325c4778b5dSHidetoshi Shimokawa #define bio buf 326c4778b5dSHidetoshi Shimokawa #define bio_bcount b_bcount 327c4778b5dSHidetoshi Shimokawa #define bio_cmd b_flags 328c4778b5dSHidetoshi Shimokawa #define bio_count b_count 329c4778b5dSHidetoshi Shimokawa #define bio_data b_data 330c4778b5dSHidetoshi Shimokawa #define bio_dev b_dev 331c4778b5dSHidetoshi Shimokawa #define bio_error b_error 332c4778b5dSHidetoshi Shimokawa #define bio_flags b_flags 333c4778b5dSHidetoshi Shimokawa #define bio_offset b_offset 334c4778b5dSHidetoshi Shimokawa #define bio_resid b_resid 335c4778b5dSHidetoshi Shimokawa #define BIO_ERROR B_ERROR 336c4778b5dSHidetoshi Shimokawa #define BIO_READ B_READ 337c4778b5dSHidetoshi Shimokawa #define BIO_WRITE B_WRITE 338c4778b5dSHidetoshi Shimokawa #define MIN(a,b) (((a)<(b))?(a):(b)) 339b2d0deb2SHidetoshi Shimokawa #define MAX(a,b) (((a)>(b))?(a):(b)) 340c4778b5dSHidetoshi Shimokawa #endif 341c4778b5dSHidetoshi Shimokawa 3425166f1dfSHidetoshi Shimokawa MALLOC_DECLARE(M_FW); 34348249fe0SHidetoshi Shimokawa MALLOC_DECLARE(M_FWXFER); 344