firewire.c (5166f1df3910b29cd99efa1f3d43a5bf92dba70a) | firewire.c (48249fe0c8fa01065bd10c670795af4db458846c) |
---|---|
1/* 2 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 52 unchanged lines hidden (view full) --- 61int firewire_debug=0, try_bmr=1; 62SYSCTL_INT(_debug, OID_AUTO, firewire_debug, CTLFLAG_RW, &firewire_debug, 0, 63 "FireWire driver debug flag"); 64SYSCTL_NODE(_hw, OID_AUTO, firewire, CTLFLAG_RD, 0, "FireWire Subsystem"); 65SYSCTL_INT(_hw_firewire, OID_AUTO, try_bmr, CTLFLAG_RW, &try_bmr, 0, 66 "Try to be a bus manager"); 67 68MALLOC_DEFINE(M_FW, "firewire", "FireWire"); | 1/* 2 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 52 unchanged lines hidden (view full) --- 61int firewire_debug=0, try_bmr=1; 62SYSCTL_INT(_debug, OID_AUTO, firewire_debug, CTLFLAG_RW, &firewire_debug, 0, 63 "FireWire driver debug flag"); 64SYSCTL_NODE(_hw, OID_AUTO, firewire, CTLFLAG_RD, 0, "FireWire Subsystem"); 65SYSCTL_INT(_hw_firewire, OID_AUTO, try_bmr, CTLFLAG_RW, &try_bmr, 0, 66 "Try to be a bus manager"); 67 68MALLOC_DEFINE(M_FW, "firewire", "FireWire"); |
69MALLOC_DEFINE(M_FWXFER, "fw_xfer", "XFER/FireWire"); |
|
69 70#define FW_MAXASYRTY 4 71#define FW_MAXDEVRCNT 4 72 73#define XFER_TIMEOUT 0 74 75devclass_t firewire_devclass; 76 --- 727 unchanged lines hidden (view full) --- 804 splx(s); 805 return(NULL); 806} 807 808/* 809 * To allocate IEEE1394 XFER structure. 810 */ 811struct fw_xfer * | 70 71#define FW_MAXASYRTY 4 72#define FW_MAXDEVRCNT 4 73 74#define XFER_TIMEOUT 0 75 76devclass_t firewire_devclass; 77 --- 727 unchanged lines hidden (view full) --- 805 splx(s); 806 return(NULL); 807} 808 809/* 810 * To allocate IEEE1394 XFER structure. 811 */ 812struct fw_xfer * |
812fw_xfer_alloc() | 813fw_xfer_alloc(struct malloc_type *type) |
813{ 814 struct fw_xfer *xfer; 815 | 814{ 815 struct fw_xfer *xfer; 816 |
816 xfer = malloc(sizeof(struct fw_xfer), M_FW, M_NOWAIT | M_ZERO); | 817 xfer = malloc(sizeof(struct fw_xfer), type, M_NOWAIT | M_ZERO); |
817 if (xfer == NULL) 818 return xfer; 819 820 xfer->time = time_second; 821 xfer->sub = -1; | 818 if (xfer == NULL) 819 return xfer; 820 821 xfer->time = time_second; 822 xfer->sub = -1; |
823 xfer->malloc = type; |
|
822 823 return xfer; 824} 825 826/* 827 * IEEE1394 XFER post process. 828 */ 829void --- 46 unchanged lines hidden (view full) --- 876 free(xfer->send.buf, M_FW); 877 } 878 if(xfer->recv.buf != NULL){ 879 free(xfer->recv.buf, M_FW); 880 } 881 if(xfer->fc != NULL){ 882 fw_tl_free(xfer->fc, xfer); 883 } | 824 825 return xfer; 826} 827 828/* 829 * IEEE1394 XFER post process. 830 */ 831void --- 46 unchanged lines hidden (view full) --- 878 free(xfer->send.buf, M_FW); 879 } 880 if(xfer->recv.buf != NULL){ 881 free(xfer->recv.buf, M_FW); 882 } 883 if(xfer->fc != NULL){ 884 fw_tl_free(xfer->fc, xfer); 885 } |
884 free(xfer, M_FW); | 886 free(xfer, xfer->malloc); |
885} 886 887static void 888fw_asy_callback_free(struct fw_xfer *xfer) 889{ 890#if 0 891 printf("asyreq done state=%d resp=%d\n", 892 xfer->state, xfer->resp); --- 10 unchanged lines hidden (view full) --- 903 struct fw_xfer *xfer; 904 struct fw_pkt *fp; 905 906 fc->status = FWBUSPHYCONF; 907 908#if 0 909 DELAY(100000); 910#endif | 887} 888 889static void 890fw_asy_callback_free(struct fw_xfer *xfer) 891{ 892#if 0 893 printf("asyreq done state=%d resp=%d\n", 894 xfer->state, xfer->resp); --- 10 unchanged lines hidden (view full) --- 905 struct fw_xfer *xfer; 906 struct fw_pkt *fp; 907 908 fc->status = FWBUSPHYCONF; 909 910#if 0 911 DELAY(100000); 912#endif |
911 xfer = fw_xfer_alloc(); | 913 xfer = fw_xfer_alloc(M_FWXFER); |
912 xfer->send.len = 12; 913 xfer->send.off = 0; 914 xfer->fc = fc; 915 xfer->retry_req = fw_asybusy; 916 xfer->act.hand = fw_asy_callback_free; 917 918 xfer->send.buf = malloc(sizeof(u_int32_t), 919 M_FW, M_NOWAIT | M_ZERO); --- 286 unchanged lines hidden (view full) --- 1206 addr = 0xf0000000 | fc->ongoaddr; 1207 } 1208#if 0 1209 xfer = asyreqq(fc, FWSPD_S100, 0, 0, 1210 ((FWLOCALBUS | fc->ongonode) << 16) | 0xffff , addr, 1211 fw_bus_explore_callback); 1212 if(xfer == NULL) goto done; 1213#else | 914 xfer->send.len = 12; 915 xfer->send.off = 0; 916 xfer->fc = fc; 917 xfer->retry_req = fw_asybusy; 918 xfer->act.hand = fw_asy_callback_free; 919 920 xfer->send.buf = malloc(sizeof(u_int32_t), 921 M_FW, M_NOWAIT | M_ZERO); --- 286 unchanged lines hidden (view full) --- 1208 addr = 0xf0000000 | fc->ongoaddr; 1209 } 1210#if 0 1211 xfer = asyreqq(fc, FWSPD_S100, 0, 0, 1212 ((FWLOCALBUS | fc->ongonode) << 16) | 0xffff , addr, 1213 fw_bus_explore_callback); 1214 if(xfer == NULL) goto done; 1215#else |
1214 xfer = fw_xfer_alloc(); | 1216 xfer = fw_xfer_alloc(M_FWXFER); |
1215 if(xfer == NULL){ 1216 goto done; 1217 } 1218 xfer->send.len = 16; 1219 xfer->spd = 0; 1220 xfer->send.buf = malloc(16, M_FW, M_NOWAIT); 1221 if(xfer->send.buf == NULL){ 1222 fw_xfer_free( xfer); --- 34 unchanged lines hidden (view full) --- 1257asyreqq(struct firewire_comm *fc, u_int8_t spd, u_int8_t tl, u_int8_t rt, 1258 u_int32_t addr_hi, u_int32_t addr_lo, 1259 void (*hand) __P((struct fw_xfer*))) 1260{ 1261 struct fw_xfer *xfer; 1262 struct fw_pkt *fp; 1263 int err; 1264 | 1217 if(xfer == NULL){ 1218 goto done; 1219 } 1220 xfer->send.len = 16; 1221 xfer->spd = 0; 1222 xfer->send.buf = malloc(16, M_FW, M_NOWAIT); 1223 if(xfer->send.buf == NULL){ 1224 fw_xfer_free( xfer); --- 34 unchanged lines hidden (view full) --- 1259asyreqq(struct firewire_comm *fc, u_int8_t spd, u_int8_t tl, u_int8_t rt, 1260 u_int32_t addr_hi, u_int32_t addr_lo, 1261 void (*hand) __P((struct fw_xfer*))) 1262{ 1263 struct fw_xfer *xfer; 1264 struct fw_pkt *fp; 1265 int err; 1266 |
1265 xfer = fw_xfer_alloc(); | 1267 xfer = fw_xfer_alloc(M_FWXFER); |
1266 if(xfer == NULL){ 1267 return NULL; 1268 } 1269 xfer->send.len = 16; 1270 xfer->spd = spd; /* XXX:min(spd, fc->spd) */ 1271 xfer->send.buf = malloc(16, M_FW, M_NOWAIT); 1272 if(xfer->send.buf == NULL){ 1273 fw_xfer_free( xfer); --- 428 unchanged lines hidden (view full) --- 1702#endif 1703 ntohs(fp->mode.rreqq.dest_hi), 1704 ntohl(fp->mode.rreqq.dest_lo), 1705 fp->mode.common.tcode); 1706 if (fc->status == FWBUSRESET) { 1707 printf("fw_rcv: cannot response(bus reset)!\n"); 1708 goto err; 1709 } | 1268 if(xfer == NULL){ 1269 return NULL; 1270 } 1271 xfer->send.len = 16; 1272 xfer->spd = spd; /* XXX:min(spd, fc->spd) */ 1273 xfer->send.buf = malloc(16, M_FW, M_NOWAIT); 1274 if(xfer->send.buf == NULL){ 1275 fw_xfer_free( xfer); --- 428 unchanged lines hidden (view full) --- 1704#endif 1705 ntohs(fp->mode.rreqq.dest_hi), 1706 ntohl(fp->mode.rreqq.dest_lo), 1707 fp->mode.common.tcode); 1708 if (fc->status == FWBUSRESET) { 1709 printf("fw_rcv: cannot response(bus reset)!\n"); 1710 goto err; 1711 } |
1710 xfer = fw_xfer_alloc(); | 1712 xfer = fw_xfer_alloc(M_FWXFER); |
1711 if(xfer == NULL){ 1712 return; 1713 } 1714 xfer->spd = spd; 1715 xfer->send.buf = malloc(16, M_FW, M_NOWAIT); 1716 resfp = (struct fw_pkt *)xfer->send.buf; 1717 switch(fp->mode.common.tcode){ 1718 case FWTCODE_WREQQ: --- 27 unchanged lines hidden (view full) --- 1746 if(fw_asyreq(fc, -1, xfer)){ 1747 fw_xfer_free( xfer); 1748 return; 1749 } 1750 goto err; 1751 } 1752 switch(bind->xfer->act_type){ 1753 case FWACT_XFER: | 1713 if(xfer == NULL){ 1714 return; 1715 } 1716 xfer->spd = spd; 1717 xfer->send.buf = malloc(16, M_FW, M_NOWAIT); 1718 resfp = (struct fw_pkt *)xfer->send.buf; 1719 switch(fp->mode.common.tcode){ 1720 case FWTCODE_WREQQ: --- 27 unchanged lines hidden (view full) --- 1748 if(fw_asyreq(fc, -1, xfer)){ 1749 fw_xfer_free( xfer); 1750 return; 1751 } 1752 goto err; 1753 } 1754 switch(bind->xfer->act_type){ 1755 case FWACT_XFER: |
1754 xfer = fw_xfer_alloc(); | 1756 xfer = fw_xfer_alloc(M_FWXFER); |
1755 if(xfer == NULL) goto err; 1756 xfer->fc = bind->xfer->fc; 1757 xfer->sc = bind->xfer->sc; 1758 xfer->recv.buf = buf; 1759 xfer->recv.len = len; 1760 xfer->recv.off = off; 1761 xfer->spd = spd; 1762 xfer->act.hand = bind->xfer->act.hand; --- 7 unchanged lines hidden (view full) --- 1770 if(fc->ir[bind->xfer->sub]->queued >= 1771 fc->ir[bind->xfer->sub]->maxq){ 1772 device_printf(fc->bdev, 1773 "Discard a packet %x %d\n", 1774 bind->xfer->sub, 1775 fc->ir[bind->xfer->sub]->queued); 1776 goto err; 1777 } | 1757 if(xfer == NULL) goto err; 1758 xfer->fc = bind->xfer->fc; 1759 xfer->sc = bind->xfer->sc; 1760 xfer->recv.buf = buf; 1761 xfer->recv.len = len; 1762 xfer->recv.off = off; 1763 xfer->spd = spd; 1764 xfer->act.hand = bind->xfer->act.hand; --- 7 unchanged lines hidden (view full) --- 1772 if(fc->ir[bind->xfer->sub]->queued >= 1773 fc->ir[bind->xfer->sub]->maxq){ 1774 device_printf(fc->bdev, 1775 "Discard a packet %x %d\n", 1776 bind->xfer->sub, 1777 fc->ir[bind->xfer->sub]->queued); 1778 goto err; 1779 } |
1778 xfer = fw_xfer_alloc(); | 1780 xfer = fw_xfer_alloc(M_FWXFER); |
1779 if(xfer == NULL) goto err; 1780 xfer->recv.buf = buf; 1781 xfer->recv.len = len; 1782 xfer->recv.off = off; 1783 xfer->spd = spd; 1784 s = splfw(); 1785 fc->ir[bind->xfer->sub]->queued++; 1786 STAILQ_INSERT_TAIL(&fc->ir[bind->xfer->sub]->q, xfer, link); --- 16 unchanged lines hidden (view full) --- 1803#if 0 1804 printf("stream rcv dma %d len %d off %d spd %d\n", 1805 sub, len, off, spd); 1806#endif 1807 if(xferq->queued >= xferq->maxq) { 1808 printf("receive queue is full\n"); 1809 goto err; 1810 } | 1781 if(xfer == NULL) goto err; 1782 xfer->recv.buf = buf; 1783 xfer->recv.len = len; 1784 xfer->recv.off = off; 1785 xfer->spd = spd; 1786 s = splfw(); 1787 fc->ir[bind->xfer->sub]->queued++; 1788 STAILQ_INSERT_TAIL(&fc->ir[bind->xfer->sub]->q, xfer, link); --- 16 unchanged lines hidden (view full) --- 1805#if 0 1806 printf("stream rcv dma %d len %d off %d spd %d\n", 1807 sub, len, off, spd); 1808#endif 1809 if(xferq->queued >= xferq->maxq) { 1810 printf("receive queue is full\n"); 1811 goto err; 1812 } |
1811 xfer = fw_xfer_alloc(); | 1813 xfer = fw_xfer_alloc(M_FWXFER); |
1812 if(xfer == NULL) goto err; 1813 xfer->recv.buf = buf; 1814 xfer->recv.len = len; 1815 xfer->recv.off = off; 1816 xfer->spd = spd; 1817 s = splfw(); 1818 xferq->queued++; 1819 STAILQ_INSERT_TAIL(&xferq->q, xfer, link); --- 69 unchanged lines hidden (view full) --- 1889void 1890fw_try_bmr(void *arg) 1891{ 1892 struct fw_xfer *xfer; 1893 struct firewire_comm *fc = (struct firewire_comm *)arg; 1894 struct fw_pkt *fp; 1895 int err = 0; 1896 | 1814 if(xfer == NULL) goto err; 1815 xfer->recv.buf = buf; 1816 xfer->recv.len = len; 1817 xfer->recv.off = off; 1818 xfer->spd = spd; 1819 s = splfw(); 1820 xferq->queued++; 1821 STAILQ_INSERT_TAIL(&xferq->q, xfer, link); --- 69 unchanged lines hidden (view full) --- 1891void 1892fw_try_bmr(void *arg) 1893{ 1894 struct fw_xfer *xfer; 1895 struct firewire_comm *fc = (struct firewire_comm *)arg; 1896 struct fw_pkt *fp; 1897 int err = 0; 1898 |
1897 xfer = fw_xfer_alloc(); | 1899 xfer = fw_xfer_alloc(M_FWXFER); |
1898 if(xfer == NULL){ 1899 return; 1900 } 1901 xfer->send.len = 24; 1902 xfer->spd = 0; 1903 xfer->send.buf = malloc(24, M_FW, M_NOWAIT); 1904 if(xfer->send.buf == NULL){ 1905 fw_xfer_free( xfer); --- 159 unchanged lines hidden --- | 1900 if(xfer == NULL){ 1901 return; 1902 } 1903 xfer->send.len = 24; 1904 xfer->spd = 0; 1905 xfer->send.buf = malloc(24, M_FW, M_NOWAIT); 1906 if(xfer->send.buf == NULL){ 1907 fw_xfer_free( xfer); --- 159 unchanged lines hidden --- |