Deleted Added
full compact
firewire.c (152792) firewire.c (167630)
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 152792 2005-11-25 14:29:24Z simokawa $
34 * $FreeBSD: head/sys/dev/firewire/firewire.c 167630 2007-03-16 05:11:42Z 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>

--- 209 unchanged lines hidden (view full) ---

252 return EAGAIN;
253 fp->mode.hdr.tlrt = tl << 2;
254 }
255
256 xfer->tl = tl;
257 xfer->resp = 0;
258 xfer->fc = fc;
259 xfer->q = 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>

--- 209 unchanged lines hidden (view full) ---

252 return EAGAIN;
253 fp->mode.hdr.tlrt = tl << 2;
254 }
255
256 xfer->tl = tl;
257 xfer->resp = 0;
258 xfer->fc = fc;
259 xfer->q = xferq;
260 xfer->retry_req = fw_asybusy;
261
262 fw_asystart(xfer);
263 return err;
264}
265/*
266 * Wakeup blocked process.
267 */
268void

--- 19 unchanged lines hidden (view full) ---

288/*
289 * Async. request with given xfer structure.
290 */
291static void
292fw_asystart(struct fw_xfer *xfer)
293{
294 struct firewire_comm *fc = xfer->fc;
295 int s;
260
261 fw_asystart(xfer);
262 return err;
263}
264/*
265 * Wakeup blocked process.
266 */
267void

--- 19 unchanged lines hidden (view full) ---

287/*
288 * Async. request with given xfer structure.
289 */
290static void
291fw_asystart(struct fw_xfer *xfer)
292{
293 struct firewire_comm *fc = xfer->fc;
294 int s;
296 if(xfer->retry++ >= fc->max_asyretry){
297 device_printf(fc->bdev, "max_asyretry exceeded\n");
298 xfer->resp = EBUSY;
299 xfer->state = FWXF_BUSY;
300 xfer->act.hand(xfer);
301 return;
302 }
303#if 0 /* XXX allow bus explore packets only after bus rest */
304 if (fc->status < FWBUSEXPLORE) {
305 xfer->resp = EAGAIN;
306 xfer->state = FWXF_BUSY;
307 if (xfer->act.hand != NULL)
308 xfer->act.hand(xfer);
309 return;
310 }

--- 100 unchanged lines hidden (view full) ---

411
412 unit = device_get_unit(dev);
413 if( fc->nisodma > FWMAXNDMA) fc->nisodma = FWMAXNDMA;
414
415 fwdev_makedev(sc);
416
417 CALLOUT_INIT(&sc->fc->timeout_callout);
418 CALLOUT_INIT(&sc->fc->bmr_callout);
295#if 0 /* XXX allow bus explore packets only after bus rest */
296 if (fc->status < FWBUSEXPLORE) {
297 xfer->resp = EAGAIN;
298 xfer->state = FWXF_BUSY;
299 if (xfer->act.hand != NULL)
300 xfer->act.hand(xfer);
301 return;
302 }

--- 100 unchanged lines hidden (view full) ---

403
404 unit = device_get_unit(dev);
405 if( fc->nisodma > FWMAXNDMA) fc->nisodma = FWMAXNDMA;
406
407 fwdev_makedev(sc);
408
409 CALLOUT_INIT(&sc->fc->timeout_callout);
410 CALLOUT_INIT(&sc->fc->bmr_callout);
419 CALLOUT_INIT(&sc->fc->retry_probe_callout);
420 CALLOUT_INIT(&sc->fc->busprobe_callout);
421
422 callout_reset(&sc->fc->timeout_callout, hz,
423 (void *)firewire_watchdog, (void *)sc->fc);
424
425 /* Locate our children */
426 bus_generic_probe(dev);
427

--- 54 unchanged lines hidden (view full) ---

482 if ((err = fwdev_destroydev(sc)) != 0)
483 return err;
484
485 if ((err = bus_generic_detach(dev)) != 0)
486 return err;
487
488 callout_stop(&sc->fc->timeout_callout);
489 callout_stop(&sc->fc->bmr_callout);
411 CALLOUT_INIT(&sc->fc->busprobe_callout);
412
413 callout_reset(&sc->fc->timeout_callout, hz,
414 (void *)firewire_watchdog, (void *)sc->fc);
415
416 /* Locate our children */
417 bus_generic_probe(dev);
418

--- 54 unchanged lines hidden (view full) ---

473 if ((err = fwdev_destroydev(sc)) != 0)
474 return err;
475
476 if ((err = bus_generic_detach(dev)) != 0)
477 return err;
478
479 callout_stop(&sc->fc->timeout_callout);
480 callout_stop(&sc->fc->bmr_callout);
490 callout_stop(&sc->fc->retry_probe_callout);
491 callout_stop(&sc->fc->busprobe_callout);
492
493 /* XXX xfree_free and untimeout on all xfers */
494 for (fwdev = STAILQ_FIRST(&sc->fc->devices); fwdev != NULL;
495 fwdev = fwdev_next) {
496 fwdev_next = STAILQ_NEXT(fwdev, link);
497 free(fwdev, M_FW);
498 }

--- 206 unchanged lines hidden (view full) ---

705{
706 int i;
707 struct csrdir *csrd;
708#ifdef FW_VMACCESS
709 struct fw_xfer *xfer;
710 struct fw_bind *fwb;
711#endif
712
481 callout_stop(&sc->fc->busprobe_callout);
482
483 /* XXX xfree_free and untimeout on all xfers */
484 for (fwdev = STAILQ_FIRST(&sc->fc->devices); fwdev != NULL;
485 fwdev = fwdev_next) {
486 fwdev_next = STAILQ_NEXT(fwdev, link);
487 free(fwdev, M_FW);
488 }

--- 206 unchanged lines hidden (view full) ---

695{
696 int i;
697 struct csrdir *csrd;
698#ifdef FW_VMACCESS
699 struct fw_xfer *xfer;
700 struct fw_bind *fwb;
701#endif
702
713 fc->max_asyretry = FW_MAXASYRTY;
714
715 fc->arq->queued = 0;
716 fc->ars->queued = 0;
717 fc->atq->queued = 0;
718 fc->ats->queued = 0;
719
720 fc->arq->buf = NULL;
721 fc->ars->buf = NULL;
722 fc->atq->buf = NULL;

--- 327 unchanged lines hidden (view full) ---

1050 * 2. firewire_watch() is called.
1051 */
1052 printf("fw_xfer_free FWXF_START\n");
1053#endif
1054 fw_tl_free(xfer->fc, xfer);
1055 }
1056 xfer->state = FWXF_INIT;
1057 xfer->resp = 0;
703 fc->arq->queued = 0;
704 fc->ars->queued = 0;
705 fc->atq->queued = 0;
706 fc->ats->queued = 0;
707
708 fc->arq->buf = NULL;
709 fc->ars->buf = NULL;
710 fc->atq->buf = NULL;

--- 327 unchanged lines hidden (view full) ---

1038 * 2. firewire_watch() is called.
1039 */
1040 printf("fw_xfer_free FWXF_START\n");
1041#endif
1042 fw_tl_free(xfer->fc, xfer);
1043 }
1044 xfer->state = FWXF_INIT;
1045 xfer->resp = 0;
1058 xfer->retry = 0;
1059}
1060/*
1061 * To free IEEE1394 XFER structure.
1062 */
1063void
1064fw_xfer_free_buf( struct fw_xfer* xfer)
1065{
1066 if (xfer == NULL) {

--- 41 unchanged lines hidden (view full) ---

1108 struct fw_pkt *fp;
1109
1110 fc->status = FWBUSPHYCONF;
1111
1112 xfer = fw_xfer_alloc(M_FWXFER);
1113 if (xfer == NULL)
1114 return;
1115 xfer->fc = fc;
1046}
1047/*
1048 * To free IEEE1394 XFER structure.
1049 */
1050void
1051fw_xfer_free_buf( struct fw_xfer* xfer)
1052{
1053 if (xfer == NULL) {

--- 41 unchanged lines hidden (view full) ---

1095 struct fw_pkt *fp;
1096
1097 fc->status = FWBUSPHYCONF;
1098
1099 xfer = fw_xfer_alloc(M_FWXFER);
1100 if (xfer == NULL)
1101 return;
1102 xfer->fc = fc;
1116 xfer->retry_req = fw_asybusy;
1117 xfer->act.hand = fw_asy_callback_free;
1118
1119 fp = &xfer->send.hdr;
1120 fp->mode.ld[1] = 0;
1121 if (root_node >= 0)
1122 fp->mode.ld[1] |= (root_node & 0x3f) << 24 | 1 << 23;
1123 if (gap_count >= 0)
1124 fp->mode.ld[1] |= 1 << 22 | (gap_count & 0x3f) << 16;

--- 147 unchanged lines hidden (view full) ---

1272static void
1273fw_bus_probe(struct firewire_comm *fc)
1274{
1275 int s;
1276 struct fw_device *fwdev;
1277
1278 s = splfw();
1279 fc->status = FWBUSEXPLORE;
1103 xfer->act.hand = fw_asy_callback_free;
1104
1105 fp = &xfer->send.hdr;
1106 fp->mode.ld[1] = 0;
1107 if (root_node >= 0)
1108 fp->mode.ld[1] |= (root_node & 0x3f) << 24 | 1 << 23;
1109 if (gap_count >= 0)
1110 fp->mode.ld[1] |= 1 << 22 | (gap_count & 0x3f) << 16;

--- 147 unchanged lines hidden (view full) ---

1258static void
1259fw_bus_probe(struct firewire_comm *fc)
1260{
1261 int s;
1262 struct fw_device *fwdev;
1263
1264 s = splfw();
1265 fc->status = FWBUSEXPLORE;
1280 fc->retry_count = 0;
1281
1282 /* Invalidate all devices, just after bus reset. */
1283 STAILQ_FOREACH(fwdev, &fc->devices, link)
1284 if (fwdev->status != FWDEVINVAL) {
1285 fwdev->status = FWDEVINVAL;
1286 fwdev->rcnt = 0;
1287 }
1288

--- 214 unchanged lines hidden (view full) ---

1503 fc = xfer->fc;
1504
1505 if (firewire_debug)
1506 printf("node%d: callback addr=0x%x\n",
1507 fc->ongonode, fc->ongoaddr);
1508
1509 if(xfer->resp != 0){
1510 device_printf(fc->bdev,
1266
1267 /* Invalidate all devices, just after bus reset. */
1268 STAILQ_FOREACH(fwdev, &fc->devices, link)
1269 if (fwdev->status != FWDEVINVAL) {
1270 fwdev->status = FWDEVINVAL;
1271 fwdev->rcnt = 0;
1272 }
1273

--- 214 unchanged lines hidden (view full) ---

1488 fc = xfer->fc;
1489
1490 if (firewire_debug)
1491 printf("node%d: callback addr=0x%x\n",
1492 fc->ongonode, fc->ongoaddr);
1493
1494 if(xfer->resp != 0){
1495 device_printf(fc->bdev,
1511 "bus_explore node=%d addr=0x%x resp=%d retry=%d\n",
1512 fc->ongonode, fc->ongoaddr, xfer->resp, xfer->retry);
1513 if (xfer->retry < fc->max_asyretry) {
1514 fw_asystart(xfer);
1515 return;
1516 }
1496 "bus_explore node=%d addr=0x%x resp=%d\n",
1497 fc->ongonode, fc->ongoaddr, xfer->resp);
1517 goto errnode;
1518 }
1519
1520 sfp = &xfer->send.hdr;
1521 rfp = &xfer->recv.hdr;
1522#if 0
1523 {
1524 uint32_t *qld;

--- 164 unchanged lines hidden (view full) ---

1689 if (device_get_state(devlistp[i]) >= DS_ATTACHED) {
1690 fdc = device_get_softc(devlistp[i]);
1691 if (fdc->post_explore != NULL)
1692 fdc->post_explore(fdc);
1693 }
1694 }
1695 free(devlistp, M_TEMP);
1696
1498 goto errnode;
1499 }
1500
1501 sfp = &xfer->send.hdr;
1502 rfp = &xfer->recv.hdr;
1503#if 0
1504 {
1505 uint32_t *qld;

--- 164 unchanged lines hidden (view full) ---

1670 if (device_get_state(devlistp[i]) >= DS_ATTACHED) {
1671 fdc = device_get_softc(devlistp[i]);
1672 if (fdc->post_explore != NULL)
1673 fdc->post_explore(fdc);
1674 }
1675 }
1676 free(devlistp, M_TEMP);
1677
1697 if (fc->retry_count > 0) {
1698 device_printf(fc->bdev, "bus_explore failed for %d nodes\n",
1699 fc->retry_count);
1700#if 0
1701 callout_reset(&fc->retry_probe_callout, hz*2,
1702 (void *)fc->ibr, (void *)fc);
1703#endif
1704 }
1705 return;
1706}
1707
1708/*
1709 * To allocate unique transaction label.
1710 */
1711static int
1712fw_get_tlabel(struct firewire_comm *fc, struct fw_xfer *xfer)

--- 453 unchanged lines hidden (view full) ---

2166 break;
2167 default:
2168 fw_xfer_free( xfer);
2169 return;
2170 }
2171 sfp->mode.hdr.dst = rfp->mode.hdr.src;
2172 xfer->dst = ntohs(rfp->mode.hdr.src);
2173 xfer->act.hand = fw_xfer_free;
1678 return;
1679}
1680
1681/*
1682 * To allocate unique transaction label.
1683 */
1684static int
1685fw_get_tlabel(struct firewire_comm *fc, struct fw_xfer *xfer)

--- 453 unchanged lines hidden (view full) ---

2139 break;
2140 default:
2141 fw_xfer_free( xfer);
2142 return;
2143 }
2144 sfp->mode.hdr.dst = rfp->mode.hdr.src;
2145 xfer->dst = ntohs(rfp->mode.hdr.src);
2146 xfer->act.hand = fw_xfer_free;
2174 xfer->retry_req = fw_asybusy;
2175
2176 sfp->mode.hdr.tlrt = rfp->mode.hdr.tlrt;
2177 sfp->mode.hdr.pri = 0;
2178
2179 fw_asyreq(xfer->fc, -1, xfer);
2180/**/
2181 return;
2182}

--- 108 unchanged lines hidden ---
2147
2148 sfp->mode.hdr.tlrt = rfp->mode.hdr.tlrt;
2149 sfp->mode.hdr.pri = 0;
2150
2151 fw_asyreq(xfer->fc, -1, xfer);
2152/**/
2153 return;
2154}

--- 108 unchanged lines hidden ---