fwohci.c (110195) | fwohci.c (110269) |
---|---|
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 --- 16 unchanged lines hidden (view full) --- 25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 * | 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 --- 16 unchanged lines hidden (view full) --- 25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 * |
33 * $FreeBSD: head/sys/dev/firewire/fwohci.c 110195 2003-02-01 15:04:33Z simokawa $ | 33 * $FreeBSD: head/sys/dev/firewire/fwohci.c 110269 2003-02-03 07:33:31Z simokawa $ |
34 * 35 */ 36 37#define ATRQ_CH 0 38#define ATRS_CH 1 39#define ARRQ_CH 2 40#define ARRS_CH 3 41#define ITX_CH 4 --- 1004 unchanged lines hidden (view full) --- 1046 switch(xfer->act_type){ 1047 case FWACT_XFER: 1048 fw_xfer_done(xfer); 1049 break; 1050 default: 1051 break; 1052 } 1053 } | 34 * 35 */ 36 37#define ATRQ_CH 0 38#define ATRS_CH 1 39#define ARRQ_CH 2 40#define ARRS_CH 3 41#define ITX_CH 4 --- 1004 unchanged lines hidden (view full) --- 1046 switch(xfer->act_type){ 1047 case FWACT_XFER: 1048 fw_xfer_done(xfer); 1049 break; 1050 default: 1051 break; 1052 } 1053 } |
1054 dbch->xferq.queued --; | |
1055 } | 1054 } |
1055 dbch->xferq.queued --; |
|
1056 tr->xfer = NULL; 1057 1058 packets ++; 1059 tr = STAILQ_NEXT(tr, link); 1060 dbch->bottom = tr; 1061 } 1062out: 1063 if ((dbch->flags & FWOHCI_DBCH_FULL) && packets > 0) { 1064 printf("make free slot\n"); 1065 dbch->flags &= ~FWOHCI_DBCH_FULL; 1066 fwohci_start(sc, dbch); 1067 } 1068 splx(s); 1069} 1070 1071static void 1072fwohci_drain(struct firewire_comm *fc, struct fw_xfer *xfer, struct fwohci_dbch *dbch) 1073{ | 1056 tr->xfer = NULL; 1057 1058 packets ++; 1059 tr = STAILQ_NEXT(tr, link); 1060 dbch->bottom = tr; 1061 } 1062out: 1063 if ((dbch->flags & FWOHCI_DBCH_FULL) && packets > 0) { 1064 printf("make free slot\n"); 1065 dbch->flags &= ~FWOHCI_DBCH_FULL; 1066 fwohci_start(sc, dbch); 1067 } 1068 splx(s); 1069} 1070 1071static void 1072fwohci_drain(struct firewire_comm *fc, struct fw_xfer *xfer, struct fwohci_dbch *dbch) 1073{ |
1074 int i, s; | 1074 int i, s, found=0; |
1075 struct fwohcidb_tr *tr; 1076 1077 if(xfer->state != FWXF_START) return; 1078 1079 s = splfw(); 1080 tr = dbch->bottom; | 1075 struct fwohcidb_tr *tr; 1076 1077 if(xfer->state != FWXF_START) return; 1078 1079 s = splfw(); 1080 tr = dbch->bottom; |
1081 for( i = 0 ; i <= dbch->xferq.queued ; i ++){ | 1081 for (i = 0; i < dbch->xferq.queued; i ++) { |
1082 if(tr->xfer == xfer){ | 1082 if(tr->xfer == xfer){ |
1083 s = splfw(); | |
1084 tr->xfer = NULL; | 1083 tr->xfer = NULL; |
1084#if 0 |
|
1085 dbch->xferq.queued --; | 1085 dbch->xferq.queued --; |
1086#if 1 | |
1087 /* XXX */ 1088 if (tr == dbch->bottom) 1089 dbch->bottom = STAILQ_NEXT(tr, link); | 1086 /* XXX */ 1087 if (tr == dbch->bottom) 1088 dbch->bottom = STAILQ_NEXT(tr, link); |
1090#endif | |
1091 if (dbch->flags & FWOHCI_DBCH_FULL) { 1092 printf("fwohci_drain: make slot\n"); 1093 dbch->flags &= ~FWOHCI_DBCH_FULL; 1094 fwohci_start((struct fwohci_softc *)fc, dbch); 1095 } | 1089 if (dbch->flags & FWOHCI_DBCH_FULL) { 1090 printf("fwohci_drain: make slot\n"); 1091 dbch->flags &= ~FWOHCI_DBCH_FULL; 1092 fwohci_start((struct fwohci_softc *)fc, dbch); 1093 } |
1096 1097 splx(s); | 1094#endif 1095 found ++; |
1098 break; 1099 } 1100 tr = STAILQ_NEXT(tr, link); 1101 } 1102 splx(s); | 1096 break; 1097 } 1098 tr = STAILQ_NEXT(tr, link); 1099 } 1100 splx(s); |
1101 if (!found) 1102 device_printf(fc->dev, "fwochi_drain: xfer not found\n"); |
|
1103 return; 1104} 1105 1106static void 1107fwohci_db_free(struct fwohci_dbch *dbch) 1108{ 1109 struct fwohcidb_tr *db_tr; 1110 int idb, i; --- 670 unchanged lines hidden (view full) --- 1781 1782#endif 1783 fw_busreset(fc); 1784 1785 /* XXX need to wait DMA to stop */ 1786#ifndef ACK_ALL 1787 OWRITE(sc, FWOHCI_INTSTATCLR, OHCI_INT_PHY_BUS_R); 1788#endif | 1103 return; 1104} 1105 1106static void 1107fwohci_db_free(struct fwohci_dbch *dbch) 1108{ 1109 struct fwohcidb_tr *db_tr; 1110 int idb, i; --- 670 unchanged lines hidden (view full) --- 1781 1782#endif 1783 fw_busreset(fc); 1784 1785 /* XXX need to wait DMA to stop */ 1786#ifndef ACK_ALL 1787 OWRITE(sc, FWOHCI_INTSTATCLR, OHCI_INT_PHY_BUS_R); 1788#endif |
1789#if 1 | 1789#if 0 |
1790 /* pending all pre-bus_reset packets */ 1791 fwohci_txd(sc, &sc->atrq); 1792 fwohci_txd(sc, &sc->atrs); 1793 fwohci_arcv(sc, &sc->arrs, -1); 1794 fwohci_arcv(sc, &sc->arrq, -1); 1795#endif 1796 1797 --- 92 unchanged lines hidden (view full) --- 1890 device_printf(fc->dev, "invalid SID len = %d\n", plen); 1891 goto sidout; 1892 } 1893 plen -= 4; /* chop control info */ 1894 buf = malloc(OHCI_SIDSIZE, M_FW, M_NOWAIT); 1895 if(buf == NULL) goto sidout; 1896 bcopy((void *)(uintptr_t)(volatile void *)(fc->sid_buf + 1), 1897 buf, plen); | 1790 /* pending all pre-bus_reset packets */ 1791 fwohci_txd(sc, &sc->atrq); 1792 fwohci_txd(sc, &sc->atrs); 1793 fwohci_arcv(sc, &sc->arrs, -1); 1794 fwohci_arcv(sc, &sc->arrq, -1); 1795#endif 1796 1797 --- 92 unchanged lines hidden (view full) --- 1890 device_printf(fc->dev, "invalid SID len = %d\n", plen); 1891 goto sidout; 1892 } 1893 plen -= 4; /* chop control info */ 1894 buf = malloc(OHCI_SIDSIZE, M_FW, M_NOWAIT); 1895 if(buf == NULL) goto sidout; 1896 bcopy((void *)(uintptr_t)(volatile void *)(fc->sid_buf + 1), 1897 buf, plen); |
1898#if 1 1899 /* pending all pre-bus_reset packets */ 1900 fwohci_txd(sc, &sc->atrq); 1901 fwohci_txd(sc, &sc->atrs); 1902 fwohci_arcv(sc, &sc->arrs, -1); 1903 fwohci_arcv(sc, &sc->arrq, -1); 1904#endif |
|
1898 fw_sidrcv(fc, buf, plen, 0); 1899 } 1900sidout: 1901 if((stat & OHCI_INT_DMA_ATRQ )){ 1902#ifndef ACK_ALL 1903 OWRITE(sc, FWOHCI_INTSTATCLR, OHCI_INT_DMA_ATRQ); 1904#endif 1905 fwohci_txd(sc, &(sc->atrq)); --- 829 unchanged lines hidden (view full) --- 2735 } 2736 if( buf != NULL){ 2737/* DMA result-code will be written at the tail of packet */ 2738 stat = ((struct fwohci_trailer *)(ld - sizeof(struct fwohci_trailer)))->stat; 2739 spd = (stat >> 5) & 0x3; 2740 stat &= 0x1f; 2741 switch(stat){ 2742 case FWOHCIEV_ACKPEND: | 1905 fw_sidrcv(fc, buf, plen, 0); 1906 } 1907sidout: 1908 if((stat & OHCI_INT_DMA_ATRQ )){ 1909#ifndef ACK_ALL 1910 OWRITE(sc, FWOHCI_INTSTATCLR, OHCI_INT_DMA_ATRQ); 1911#endif 1912 fwohci_txd(sc, &(sc->atrq)); --- 829 unchanged lines hidden (view full) --- 2742 } 2743 if( buf != NULL){ 2744/* DMA result-code will be written at the tail of packet */ 2745 stat = ((struct fwohci_trailer *)(ld - sizeof(struct fwohci_trailer)))->stat; 2746 spd = (stat >> 5) & 0x3; 2747 stat &= 0x1f; 2748 switch(stat){ 2749 case FWOHCIEV_ACKPEND: |
2743#if 0 | 2750#if 1 |
2744 printf("fwohci_arcv: ack pending..\n"); 2745#endif 2746 /* fall through */ 2747 case FWOHCIEV_ACKCOMPL: 2748 if( poff != 0 ) 2749 bcopy(buf+poff, buf, plen - 4); 2750 fw_rcv(&sc->fc, buf, plen - sizeof(struct fwohci_trailer), 0, 0, spd); 2751 break; --- 37 unchanged lines hidden --- | 2751 printf("fwohci_arcv: ack pending..\n"); 2752#endif 2753 /* fall through */ 2754 case FWOHCIEV_ACKCOMPL: 2755 if( poff != 0 ) 2756 bcopy(buf+poff, buf, plen - 4); 2757 fw_rcv(&sc->fc, buf, plen - sizeof(struct fwohci_trailer), 0, 0, spd); 2758 break; --- 37 unchanged lines hidden --- |