firewire.c (171302) | firewire.c (171457) |
---|---|
1/*- 2 * Copyright (c) 2003 Hidetoshi Shimokawa 3 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 17 unchanged lines hidden (view full) --- 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. 33 * | 1/*- 2 * Copyright (c) 2003 Hidetoshi Shimokawa 3 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 17 unchanged lines hidden (view full) --- 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. 33 * |
34 * $FreeBSD: head/sys/dev/firewire/firewire.c 171302 2007-07-08 11:47:52Z simokawa $ | 34 * $FreeBSD: head/sys/dev/firewire/firewire.c 171457 2007-07-15 13:00:29Z simokawa $ |
35 * 36 */ 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/types.h> 41 42#include <sys/kernel.h> --- 1663 unchanged lines hidden (view full) --- 1706} 1707 1708/* 1709 * To allocate unique transaction label. 1710 */ 1711static int 1712fw_get_tlabel(struct firewire_comm *fc, struct fw_xfer *xfer) 1713{ | 35 * 36 */ 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/types.h> 41 42#include <sys/kernel.h> --- 1663 unchanged lines hidden (view full) --- 1706} 1707 1708/* 1709 * To allocate unique transaction label. 1710 */ 1711static int 1712fw_get_tlabel(struct firewire_comm *fc, struct fw_xfer *xfer) 1713{ |
1714 u_int i; | 1714 u_int dst, new_tlabel; |
1715 struct fw_xfer *txfer; 1716 int s; | 1715 struct fw_xfer *txfer; 1716 int s; |
1717 static uint32_t label = 0; | |
1718 | 1717 |
1718 dst = xfer->send.hdr.mode.hdr.dst & 0x3f; |
|
1719 s = splfw(); 1720 FW_GLOCK(fc); | 1719 s = splfw(); 1720 FW_GLOCK(fc); |
1721 for( i = 0 ; i < 0x40 ; i ++){ 1722 label = (label + 1) & 0x3f; 1723 STAILQ_FOREACH(txfer, &fc->tlabels[label], tlabel) 1724 if (txfer->send.hdr.mode.hdr.dst == 1725 xfer->send.hdr.mode.hdr.dst) | 1721 new_tlabel = (fc->last_tlabel[dst] + 1) & 0x3f; 1722 STAILQ_FOREACH(txfer, &fc->tlabels[new_tlabel], tlabel) 1723 if ((txfer->send.hdr.mode.hdr.dst & 0x3f) == dst) |
1726 break; | 1724 break; |
1727 if(txfer == NULL) { 1728 xfer->tl = label; 1729 xfer->send.hdr.mode.hdr.tlrt = label << 2; 1730 STAILQ_INSERT_TAIL(&fc->tlabels[label], xfer, tlabel); 1731 FW_GUNLOCK(fc); 1732 splx(s); 1733 if (firewire_debug > 1) 1734 printf("fw_get_tlabel: dst=%d tl=%d\n", 1735 xfer->send.hdr.mode.hdr.dst, label); 1736 /* note: label may be incremanted after unlock */ 1737 return(xfer->tl); 1738 } | 1725 if(txfer == NULL) { 1726 fc->last_tlabel[dst] = new_tlabel; 1727 STAILQ_INSERT_TAIL(&fc->tlabels[new_tlabel], xfer, tlabel); 1728 FW_GUNLOCK(fc); 1729 splx(s); 1730 xfer->tl = new_tlabel; 1731 xfer->send.hdr.mode.hdr.tlrt = new_tlabel << 2; 1732 if (firewire_debug > 1) 1733 printf("fw_get_tlabel: dst=%d tl=%d\n", dst, new_tlabel); 1734 return (new_tlabel); |
1739 } 1740 FW_GUNLOCK(fc); 1741 splx(s); 1742 1743 if (firewire_debug > 1) 1744 printf("fw_get_tlabel: no free tlabel\n"); | 1735 } 1736 FW_GUNLOCK(fc); 1737 splx(s); 1738 1739 if (firewire_debug > 1) 1740 printf("fw_get_tlabel: no free tlabel\n"); |
1745 return(-1); | 1741 return (-1); |
1746} 1747 1748static void 1749fw_rcv_copy(struct fw_rcv_buf *rb) 1750{ 1751 struct fw_pkt *pkt; 1752 u_char *p; 1753 struct tcode_info *tinfo; --- 528 unchanged lines hidden --- | 1742} 1743 1744static void 1745fw_rcv_copy(struct fw_rcv_buf *rb) 1746{ 1747 struct fw_pkt *pkt; 1748 u_char *p; 1749 struct tcode_info *tinfo; --- 528 unchanged lines hidden --- |