firewire.c (169117) | firewire.c (169119) |
---|---|
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 169117 2007-04-30 10:50:53Z simokawa $ | 34 * $FreeBSD: head/sys/dev/firewire/firewire.c 169119 2007-04-30 12:26: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> --- 150 unchanged lines hidden (view full) --- 193/* 194 * Async. request procedure for userland application. 195 */ 196int 197fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer) 198{ 199 int err = 0; 200 struct fw_xferq *xferq; | 35 * 36 */ 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/types.h> 41 42#include <sys/kernel.h> --- 150 unchanged lines hidden (view full) --- 193/* 194 * Async. request procedure for userland application. 195 */ 196int 197fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer) 198{ 199 int err = 0; 200 struct fw_xferq *xferq; |
201 int tl = 0, len; | 201 int tl = -1, len; |
202 struct fw_pkt *fp; 203 int tcode; 204 struct tcode_info *info; 205 206 if(xfer == NULL) return EINVAL; 207 if(xfer->hand == NULL){ 208 printf("hand == NULL\n"); 209 return EINVAL; --- 115 unchanged lines hidden (view full) --- 325 device_set_desc(dev, "IEEE1394(FireWire) bus"); 326 return (0); 327} 328 329static void 330firewire_xfer_timeout(struct firewire_comm *fc) 331{ 332 struct fw_xfer *xfer; | 202 struct fw_pkt *fp; 203 int tcode; 204 struct tcode_info *info; 205 206 if(xfer == NULL) return EINVAL; 207 if(xfer->hand == NULL){ 208 printf("hand == NULL\n"); 209 return EINVAL; --- 115 unchanged lines hidden (view full) --- 325 device_set_desc(dev, "IEEE1394(FireWire) bus"); 326 return (0); 327} 328 329static void 330firewire_xfer_timeout(struct firewire_comm *fc) 331{ 332 struct fw_xfer *xfer; |
333 struct tlabel *tl; | |
334 struct timeval tv; 335 struct timeval split_timeout; 336 int i, s; 337 338 split_timeout.tv_sec = 0; 339 split_timeout.tv_usec = 200 * 1000; /* 200 msec */ 340 341 microtime(&tv); 342 timevalsub(&tv, &split_timeout); 343 344 s = splfw(); 345 for (i = 0; i < 0x40; i ++) { | 333 struct timeval tv; 334 struct timeval split_timeout; 335 int i, s; 336 337 split_timeout.tv_sec = 0; 338 split_timeout.tv_usec = 200 * 1000; /* 200 msec */ 339 340 microtime(&tv); 341 timevalsub(&tv, &split_timeout); 342 343 s = splfw(); 344 for (i = 0; i < 0x40; i ++) { |
346 while ((tl = STAILQ_FIRST(&fc->tlabels[i])) != NULL) { 347 xfer = tl->xfer; | 345 while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) { |
348 if (timevalcmp(&xfer->tv, &tv, >)) 349 /* the rests are newer than this */ 350 break; 351 if (xfer->state == FWXF_START) 352 /* not sent yet */ 353 break; 354 device_printf(fc->bdev, 355 "split transaction timeout dst=0x%x tl=0x%x state=%d\n", --- 549 unchanged lines hidden (view full) --- 905} 906 907/* 908 * To free transaction label. 909 */ 910static void 911fw_tl_free(struct firewire_comm *fc, struct fw_xfer *xfer) 912{ | 346 if (timevalcmp(&xfer->tv, &tv, >)) 347 /* the rests are newer than this */ 348 break; 349 if (xfer->state == FWXF_START) 350 /* not sent yet */ 351 break; 352 device_printf(fc->bdev, 353 "split transaction timeout dst=0x%x tl=0x%x state=%d\n", --- 549 unchanged lines hidden (view full) --- 903} 904 905/* 906 * To free transaction label. 907 */ 908static void 909fw_tl_free(struct firewire_comm *fc, struct fw_xfer *xfer) 910{ |
913 struct tlabel *tl; 914 int s = splfw(); | 911 struct fw_xfer *txfer; 912 int s; |
915 | 913 |
916 for( tl = STAILQ_FIRST(&fc->tlabels[xfer->tl]); tl != NULL; 917 tl = STAILQ_NEXT(tl, link)){ 918 if(tl->xfer == xfer){ 919 STAILQ_REMOVE(&fc->tlabels[xfer->tl], tl, tlabel, link); 920 free(tl, M_FW); 921 splx(s); 922 return; 923 } | 914 if (xfer->tl < 0) 915 return; 916 917 s = splfw(); 918#if 1 /* make sure the label is allocated */ 919 STAILQ_FOREACH(txfer, &fc->tlabels[xfer->tl], tlabel) 920 if(txfer == xfer) 921 break; 922 if (txfer == NULL) { 923 printf("%s: the xfer is not in the tlabel(%d)\n", 924 __FUNCTION__, xfer->tl); 925 splx(s); 926 return; |
924 } | 927 } |
928#endif 929 930 STAILQ_REMOVE(&fc->tlabels[xfer->tl], xfer, fw_xfer, tlabel); |
|
925 splx(s); 926 return; 927} 928 929/* 930 * To obtain XFER structure by transaction label. 931 */ 932static struct fw_xfer * 933fw_tl2xfer(struct firewire_comm *fc, int node, int tlabel) 934{ 935 struct fw_xfer *xfer; | 931 splx(s); 932 return; 933} 934 935/* 936 * To obtain XFER structure by transaction label. 937 */ 938static struct fw_xfer * 939fw_tl2xfer(struct firewire_comm *fc, int node, int tlabel) 940{ 941 struct fw_xfer *xfer; |
936 struct tlabel *tl; | |
937 int s = splfw(); 938 | 942 int s = splfw(); 943 |
939 for( tl = STAILQ_FIRST(&fc->tlabels[tlabel]); tl != NULL; 940 tl = STAILQ_NEXT(tl, link)){ 941 if(tl->xfer->send.hdr.mode.hdr.dst == node){ 942 xfer = tl->xfer; | 944 STAILQ_FOREACH(xfer, &fc->tlabels[tlabel], tlabel) 945 if(xfer->send.hdr.mode.hdr.dst == node) { |
943 splx(s); 944 if (firewire_debug > 2) 945 printf("fw_tl2xfer: found tl=%d\n", tlabel); 946 return(xfer); 947 } | 946 splx(s); 947 if (firewire_debug > 2) 948 printf("fw_tl2xfer: found tl=%d\n", tlabel); 949 return(xfer); 950 } |
948 } | |
949 if (firewire_debug > 1) 950 printf("fw_tl2xfer: not found tl=%d\n", tlabel); 951 splx(s); 952 return(NULL); 953} 954 955/* 956 * To allocate IEEE1394 XFER structure. --- 721 unchanged lines hidden (view full) --- 1678 1679/* 1680 * To allocate unique transaction label. 1681 */ 1682static int 1683fw_get_tlabel(struct firewire_comm *fc, struct fw_xfer *xfer) 1684{ 1685 u_int i; | 951 if (firewire_debug > 1) 952 printf("fw_tl2xfer: not found tl=%d\n", tlabel); 953 splx(s); 954 return(NULL); 955} 956 957/* 958 * To allocate IEEE1394 XFER structure. --- 721 unchanged lines hidden (view full) --- 1680 1681/* 1682 * To allocate unique transaction label. 1683 */ 1684static int 1685fw_get_tlabel(struct firewire_comm *fc, struct fw_xfer *xfer) 1686{ 1687 u_int i; |
1686 struct tlabel *tl, *tmptl; | 1688 struct fw_xfer *txfer; |
1687 int s; 1688 static uint32_t label = 0; 1689 1690 s = splfw(); 1691 for( i = 0 ; i < 0x40 ; i ++){ 1692 label = (label + 1) & 0x3f; | 1689 int s; 1690 static uint32_t label = 0; 1691 1692 s = splfw(); 1693 for( i = 0 ; i < 0x40 ; i ++){ 1694 label = (label + 1) & 0x3f; |
1693 for(tmptl = STAILQ_FIRST(&fc->tlabels[label]); 1694 tmptl != NULL; tmptl = STAILQ_NEXT(tmptl, link)){ 1695 if (tmptl->xfer->send.hdr.mode.hdr.dst == | 1695 STAILQ_FOREACH(txfer, &fc->tlabels[label], tlabel) 1696 if (txfer->send.hdr.mode.hdr.dst == |
1696 xfer->send.hdr.mode.hdr.dst) 1697 break; | 1697 xfer->send.hdr.mode.hdr.dst) 1698 break; |
1698 } 1699 if(tmptl == NULL) { 1700 tl = malloc(sizeof(struct tlabel),M_FW,M_NOWAIT); 1701 if (tl == NULL) { 1702 splx(s); 1703 return (-1); 1704 } 1705 tl->xfer = xfer; 1706 STAILQ_INSERT_TAIL(&fc->tlabels[label], tl, link); | 1699 if(txfer == NULL) { 1700 STAILQ_INSERT_TAIL(&fc->tlabels[label], xfer, tlabel); |
1707 splx(s); 1708 if (firewire_debug > 1) 1709 printf("fw_get_tlabel: dst=%d tl=%d\n", 1710 xfer->send.hdr.mode.hdr.dst, label); 1711 return(label); 1712 } 1713 } 1714 splx(s); --- 546 unchanged lines hidden --- | 1701 splx(s); 1702 if (firewire_debug > 1) 1703 printf("fw_get_tlabel: dst=%d tl=%d\n", 1704 xfer->send.hdr.mode.hdr.dst, label); 1705 return(label); 1706 } 1707 } 1708 splx(s); --- 546 unchanged lines hidden --- |