Deleted Added
full compact
firewire.c (129541) firewire.c (129585)
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 129541 2004-05-21 09:12:07Z dfr $
34 * $FreeBSD: head/sys/dev/firewire/firewire.c 129585 2004-05-22 16:14:17Z dfr $
35 *
36 */
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/types.h>
41
42#include <sys/kernel.h>

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

103static int fw_get_tlabel (struct firewire_comm *, struct fw_xfer *);
104static void fw_bus_probe (struct firewire_comm *);
105static void fw_bus_explore (struct firewire_comm *);
106static void fw_bus_explore_callback (struct fw_xfer *);
107static void fw_attach_dev (struct firewire_comm *);
108#ifdef FW_VMACCESS
109static void fw_vmaccess (struct fw_xfer *);
110#endif
35 *
36 */
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/types.h>
41
42#include <sys/kernel.h>

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

103static int fw_get_tlabel (struct firewire_comm *, struct fw_xfer *);
104static void fw_bus_probe (struct firewire_comm *);
105static void fw_bus_explore (struct firewire_comm *);
106static void fw_bus_explore_callback (struct fw_xfer *);
107static void fw_attach_dev (struct firewire_comm *);
108#ifdef FW_VMACCESS
109static void fw_vmaccess (struct fw_xfer *);
110#endif
111struct fw_xfer *asyreqq (struct firewire_comm *, u_int8_t, u_int8_t, u_int8_t,
112 u_int32_t, u_int32_t, void (*)(struct fw_xfer *));
111struct fw_xfer *asyreqq (struct firewire_comm *, uint8_t, uint8_t, uint8_t,
112 uint32_t, uint32_t, void (*)(struct fw_xfer *));
113static int fw_bmr (struct firewire_comm *);
114
115static device_method_t firewire_methods[] = {
116 /* Device interface */
117 DEVMETHOD(device_identify, firewire_identify),
118 DEVMETHOD(device_probe, firewire_probe),
119 DEVMETHOD(device_attach, firewire_attach),
120 DEVMETHOD(device_detach, firewire_detach),

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

681 if (fdc->post_busreset != NULL)
682 fdc->post_busreset(fdc);
683 }
684 free(devlistp, M_TEMP);
685 }
686
687 newrom = malloc(CROMSIZE, M_FW, M_NOWAIT | M_ZERO);
688 src = &fc->crom_src_buf->src;
113static int fw_bmr (struct firewire_comm *);
114
115static device_method_t firewire_methods[] = {
116 /* Device interface */
117 DEVMETHOD(device_identify, firewire_identify),
118 DEVMETHOD(device_probe, firewire_probe),
119 DEVMETHOD(device_attach, firewire_attach),
120 DEVMETHOD(device_detach, firewire_detach),

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

681 if (fdc->post_busreset != NULL)
682 fdc->post_busreset(fdc);
683 }
684 free(devlistp, M_TEMP);
685 }
686
687 newrom = malloc(CROMSIZE, M_FW, M_NOWAIT | M_ZERO);
688 src = &fc->crom_src_buf->src;
689 crom_load(src, (u_int32_t *)newrom, CROMSIZE);
689 crom_load(src, (uint32_t *)newrom, CROMSIZE);
690 if (bcmp(newrom, fc->config_rom, CROMSIZE) != 0) {
691 /* bump generation and reload */
692 src->businfo.generation ++;
693 /* generation must be between 0x2 and 0xF */
694 if (src->businfo.generation < 2)
695 src->businfo.generation ++;
690 if (bcmp(newrom, fc->config_rom, CROMSIZE) != 0) {
691 /* bump generation and reload */
692 src->businfo.generation ++;
693 /* generation must be between 0x2 and 0xF */
694 if (src->businfo.generation < 2)
695 src->businfo.generation ++;
696 crom_load(src, (u_int32_t *)newrom, CROMSIZE);
696 crom_load(src, (uint32_t *)newrom, CROMSIZE);
697 bcopy(newrom, (void *)fc->config_rom, CROMSIZE);
698 }
699 free(newrom, M_FW);
700}
701
702/* Call once after reboot */
703void fw_init(struct firewire_comm *fc)
704{

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

826
827#define BIND_CMP(addr, fwb) (((addr) < (fwb)->start)?-1:\
828 ((fwb)->end < (addr))?1:0)
829
830/*
831 * To lookup bound process from IEEE1394 address.
832 */
833struct fw_bind *
697 bcopy(newrom, (void *)fc->config_rom, CROMSIZE);
698 }
699 free(newrom, M_FW);
700}
701
702/* Call once after reboot */
703void fw_init(struct firewire_comm *fc)
704{

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

826
827#define BIND_CMP(addr, fwb) (((addr) < (fwb)->start)?-1:\
828 ((fwb)->end < (addr))?1:0)
829
830/*
831 * To lookup bound process from IEEE1394 address.
832 */
833struct fw_bind *
834fw_bindlookup(struct firewire_comm *fc, u_int16_t dest_hi, u_int32_t dest_lo)
834fw_bindlookup(struct firewire_comm *fc, uint16_t dest_hi, uint32_t dest_lo)
835{
836 u_int64_t addr;
837 struct fw_bind *tfw;
838
839 addr = ((u_int64_t)dest_hi << 32) | dest_lo;
840 STAILQ_FOREACH(tfw, &fc->binds, fclist)
841 if (tfw->act_type != FWACT_NULL && BIND_CMP(addr, tfw) == 0)
842 return(tfw);

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

1130 fw_asyreq(fc, -1, xfer);
1131}
1132
1133#if 0
1134/*
1135 * Dump self ID.
1136 */
1137static void
835{
836 u_int64_t addr;
837 struct fw_bind *tfw;
838
839 addr = ((u_int64_t)dest_hi << 32) | dest_lo;
840 STAILQ_FOREACH(tfw, &fc->binds, fclist)
841 if (tfw->act_type != FWACT_NULL && BIND_CMP(addr, tfw) == 0)
842 return(tfw);

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

1130 fw_asyreq(fc, -1, xfer);
1131}
1132
1133#if 0
1134/*
1135 * Dump self ID.
1136 */
1137static void
1138fw_print_sid(u_int32_t sid)
1138fw_print_sid(uint32_t sid)
1139{
1140 union fw_self_id *s;
1141 s = (union fw_self_id *) &sid;
1142 printf("node:%d link:%d gap:%d spd:%d del:%d con:%d pwr:%d"
1143 " p0:%d p1:%d p2:%d i:%d m:%d\n",
1144 s->p0.phy_id, s->p0.link_active, s->p0.gap_count,
1145 s->p0.phy_speed, s->p0.phy_delay, s->p0.contender,
1146 s->p0.power_class, s->p0.port0, s->p0.port1,
1147 s->p0.port2, s->p0.initiated_reset, s->p0.more_packets);
1148}
1149#endif
1150
1151/*
1152 * To receive self ID.
1153 */
1139{
1140 union fw_self_id *s;
1141 s = (union fw_self_id *) &sid;
1142 printf("node:%d link:%d gap:%d spd:%d del:%d con:%d pwr:%d"
1143 " p0:%d p1:%d p2:%d i:%d m:%d\n",
1144 s->p0.phy_id, s->p0.link_active, s->p0.gap_count,
1145 s->p0.phy_speed, s->p0.phy_delay, s->p0.contender,
1146 s->p0.power_class, s->p0.port0, s->p0.port1,
1147 s->p0.port2, s->p0.initiated_reset, s->p0.more_packets);
1148}
1149#endif
1150
1151/*
1152 * To receive self ID.
1153 */
1154void fw_sidrcv(struct firewire_comm* fc, u_int32_t *sid, u_int len)
1154void fw_sidrcv(struct firewire_comm* fc, uint32_t *sid, u_int len)
1155{
1155{
1156 u_int32_t *p;
1156 uint32_t *p;
1157 union fw_self_id *self_id;
1158 u_int i, j, node, c_port = 0, i_branch = 0;
1159
1157 union fw_self_id *self_id;
1158 u_int i, j, node, c_port = 0, i_branch = 0;
1159
1160 fc->sid_cnt = len /(sizeof(u_int32_t) * 2);
1160 fc->sid_cnt = len /(sizeof(uint32_t) * 2);
1161 fc->status = FWBUSINIT;
1162 fc->max_node = fc->nodeid & 0x3f;
1161 fc->status = FWBUSINIT;
1162 fc->max_node = fc->nodeid & 0x3f;
1163 CSRARC(fc, NODE_IDS) = ((u_int32_t)fc->nodeid) << 16;
1163 CSRARC(fc, NODE_IDS) = ((uint32_t)fc->nodeid) << 16;
1164 fc->status = FWBUSCYMELECT;
1165 fc->topology_map->crc_len = 2;
1166 fc->topology_map->generation ++;
1167 fc->topology_map->self_id_count = 0;
1168 fc->topology_map->node_count = 0;
1169 fc->speed_map->generation ++;
1170 fc->speed_map->crc_len = 1 + (64*64 + 3) / 4;
1171 self_id = &fc->topology_map->self_id[0];

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

1215 }
1216 sid += 2;
1217 self_id++;
1218 fc->topology_map->self_id_count ++;
1219 }
1220 device_printf(fc->bdev, "%d nodes", fc->max_node + 1);
1221 /* CRC */
1222 fc->topology_map->crc = fw_crc16(
1164 fc->status = FWBUSCYMELECT;
1165 fc->topology_map->crc_len = 2;
1166 fc->topology_map->generation ++;
1167 fc->topology_map->self_id_count = 0;
1168 fc->topology_map->node_count = 0;
1169 fc->speed_map->generation ++;
1170 fc->speed_map->crc_len = 1 + (64*64 + 3) / 4;
1171 self_id = &fc->topology_map->self_id[0];

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

1215 }
1216 sid += 2;
1217 self_id++;
1218 fc->topology_map->self_id_count ++;
1219 }
1220 device_printf(fc->bdev, "%d nodes", fc->max_node + 1);
1221 /* CRC */
1222 fc->topology_map->crc = fw_crc16(
1223 (u_int32_t *)&fc->topology_map->generation,
1223 (uint32_t *)&fc->topology_map->generation,
1224 fc->topology_map->crc_len * 4);
1225 fc->speed_map->crc = fw_crc16(
1224 fc->topology_map->crc_len * 4);
1225 fc->speed_map->crc = fw_crc16(
1226 (u_int32_t *)&fc->speed_map->generation,
1226 (uint32_t *)&fc->speed_map->generation,
1227 fc->speed_map->crc_len * 4);
1228 /* byteswap and copy to CSR */
1227 fc->speed_map->crc_len * 4);
1228 /* byteswap and copy to CSR */
1229 p = (u_int32_t *)fc->topology_map;
1229 p = (uint32_t *)fc->topology_map;
1230 for (i = 0; i <= fc->topology_map->crc_len; i++)
1231 CSRARC(fc, TOPO_MAP + i * 4) = htonl(*p++);
1230 for (i = 0; i <= fc->topology_map->crc_len; i++)
1231 CSRARC(fc, TOPO_MAP + i * 4) = htonl(*p++);
1232 p = (u_int32_t *)fc->speed_map;
1232 p = (uint32_t *)fc->speed_map;
1233 CSRARC(fc, SPED_MAP) = htonl(*p++);
1234 CSRARC(fc, SPED_MAP + 4) = htonl(*p++);
1233 CSRARC(fc, SPED_MAP) = htonl(*p++);
1234 CSRARC(fc, SPED_MAP + 4) = htonl(*p++);
1235 /* don't byte-swap u_int8_t array */
1235 /* don't byte-swap uint8_t array */
1236 bcopy(p, &CSRARC(fc, SPED_MAP + 8), (fc->speed_map->crc_len - 1)*4);
1237
1238 fc->max_hop = fc->max_node - i_branch;
1239 printf(", maxhop <= %d", fc->max_hop);
1240
1241 if(fc->irm == -1 ){
1242 printf(", Not found IRM capable node");
1243 }else{

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

1314/*
1315 * To collect device informations on the IEEE1394 bus.
1316 */
1317static void
1318fw_bus_explore(struct firewire_comm *fc )
1319{
1320 int err = 0;
1321 struct fw_device *fwdev, *pfwdev, *tfwdev;
1236 bcopy(p, &CSRARC(fc, SPED_MAP + 8), (fc->speed_map->crc_len - 1)*4);
1237
1238 fc->max_hop = fc->max_node - i_branch;
1239 printf(", maxhop <= %d", fc->max_hop);
1240
1241 if(fc->irm == -1 ){
1242 printf(", Not found IRM capable node");
1243 }else{

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

1314/*
1315 * To collect device informations on the IEEE1394 bus.
1316 */
1317static void
1318fw_bus_explore(struct firewire_comm *fc )
1319{
1320 int err = 0;
1321 struct fw_device *fwdev, *pfwdev, *tfwdev;
1322 u_int32_t addr;
1322 uint32_t addr;
1323 struct fw_xfer *xfer;
1324 struct fw_pkt *fp;
1325
1326 if(fc->status != FWBUSEXPLORE)
1327 return;
1328
1329loop:
1330 if(fc->ongonode == fc->nodeid) fc->ongonode++;

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

1437 printf("bus_explore done\n");
1438 fw_attach_dev(fc);
1439 return;
1440
1441}
1442
1443/* Portable Async. request read quad */
1444struct fw_xfer *
1323 struct fw_xfer *xfer;
1324 struct fw_pkt *fp;
1325
1326 if(fc->status != FWBUSEXPLORE)
1327 return;
1328
1329loop:
1330 if(fc->ongonode == fc->nodeid) fc->ongonode++;

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

1437 printf("bus_explore done\n");
1438 fw_attach_dev(fc);
1439 return;
1440
1441}
1442
1443/* Portable Async. request read quad */
1444struct fw_xfer *
1445asyreqq(struct firewire_comm *fc, u_int8_t spd, u_int8_t tl, u_int8_t rt,
1446 u_int32_t addr_hi, u_int32_t addr_lo,
1445asyreqq(struct firewire_comm *fc, uint8_t spd, uint8_t tl, uint8_t rt,
1446 uint32_t addr_hi, uint32_t addr_lo,
1447 void (*hand) (struct fw_xfer*))
1448{
1449 struct fw_xfer *xfer;
1450 struct fw_pkt *fp;
1451 int err;
1452
1453 xfer = fw_xfer_alloc(M_FWXFER);
1454 if (xfer == NULL)

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

1484static void
1485fw_bus_explore_callback(struct fw_xfer *xfer)
1486{
1487 struct firewire_comm *fc;
1488 struct fw_pkt *sfp,*rfp;
1489 struct csrhdr *chdr;
1490 struct csrdir *csrd;
1491 struct csrreg *csrreg;
1447 void (*hand) (struct fw_xfer*))
1448{
1449 struct fw_xfer *xfer;
1450 struct fw_pkt *fp;
1451 int err;
1452
1453 xfer = fw_xfer_alloc(M_FWXFER);
1454 if (xfer == NULL)

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

1484static void
1485fw_bus_explore_callback(struct fw_xfer *xfer)
1486{
1487 struct firewire_comm *fc;
1488 struct fw_pkt *sfp,*rfp;
1489 struct csrhdr *chdr;
1490 struct csrdir *csrd;
1491 struct csrreg *csrreg;
1492 u_int32_t offset;
1492 uint32_t offset;
1493
1494
1495 if(xfer == NULL) {
1496 printf("xfer == NULL\n");
1497 return;
1498 }
1499 fc = xfer->fc;
1500

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

1512 }
1513 goto errnode;
1514 }
1515
1516 sfp = &xfer->send.hdr;
1517 rfp = &xfer->recv.hdr;
1518#if 0
1519 {
1493
1494
1495 if(xfer == NULL) {
1496 printf("xfer == NULL\n");
1497 return;
1498 }
1499 fc = xfer->fc;
1500

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

1512 }
1513 goto errnode;
1514 }
1515
1516 sfp = &xfer->send.hdr;
1517 rfp = &xfer->recv.hdr;
1518#if 0
1519 {
1520 u_int32_t *qld;
1520 uint32_t *qld;
1521 int i;
1521 int i;
1522 qld = (u_int32_t *)xfer->recv.buf;
1522 qld = (uint32_t *)xfer->recv.buf;
1523 printf("len:%d\n", xfer->recv.len);
1524 for( i = 0 ; i <= xfer->recv.len && i < 32; i+= 4){
1525 printf("0x%08x ", rfp->mode.ld[i/4]);
1526 if((i % 16) == 15) printf("\n");
1527 }
1528 if((i % 16) != 15) printf("\n");
1529 }
1530#endif

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

1705 * To allocate unique transaction label.
1706 */
1707static int
1708fw_get_tlabel(struct firewire_comm *fc, struct fw_xfer *xfer)
1709{
1710 u_int i;
1711 struct tlabel *tl, *tmptl;
1712 int s;
1523 printf("len:%d\n", xfer->recv.len);
1524 for( i = 0 ; i <= xfer->recv.len && i < 32; i+= 4){
1525 printf("0x%08x ", rfp->mode.ld[i/4]);
1526 if((i % 16) == 15) printf("\n");
1527 }
1528 if((i % 16) != 15) printf("\n");
1529 }
1530#endif

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

1705 * To allocate unique transaction label.
1706 */
1707static int
1708fw_get_tlabel(struct firewire_comm *fc, struct fw_xfer *xfer)
1709{
1710 u_int i;
1711 struct tlabel *tl, *tmptl;
1712 int s;
1713 static u_int32_t label = 0;
1713 static uint32_t label = 0;
1714
1715 s = splfw();
1716 for( i = 0 ; i < 0x40 ; i ++){
1717 label = (label + 1) & 0x3f;
1718 for(tmptl = STAILQ_FIRST(&fc->tlabels[label]);
1719 tmptl != NULL; tmptl = STAILQ_NEXT(tmptl, link)){
1720 if (tmptl->xfer->send.hdr.mode.hdr.dst ==
1721 xfer->send.hdr.mode.hdr.dst)

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

1762 rb->vec->iov_len -= tinfo->hdr_len;
1763
1764 /* Copy payload */
1765 p = (u_char *)rb->xfer->recv.payload;
1766 res = rb->xfer->recv.pay_len;
1767
1768 /* special handling for RRESQ */
1769 if (pkt->mode.hdr.tcode == FWTCODE_RRESQ &&
1714
1715 s = splfw();
1716 for( i = 0 ; i < 0x40 ; i ++){
1717 label = (label + 1) & 0x3f;
1718 for(tmptl = STAILQ_FIRST(&fc->tlabels[label]);
1719 tmptl != NULL; tmptl = STAILQ_NEXT(tmptl, link)){
1720 if (tmptl->xfer->send.hdr.mode.hdr.dst ==
1721 xfer->send.hdr.mode.hdr.dst)

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

1762 rb->vec->iov_len -= tinfo->hdr_len;
1763
1764 /* Copy payload */
1765 p = (u_char *)rb->xfer->recv.payload;
1766 res = rb->xfer->recv.pay_len;
1767
1768 /* special handling for RRESQ */
1769 if (pkt->mode.hdr.tcode == FWTCODE_RRESQ &&
1770 p != NULL && res >= sizeof(u_int32_t)) {
1771 *(u_int32_t *)p = pkt->mode.rresq.data;
1772 rb->xfer->recv.pay_len = sizeof(u_int32_t);
1770 p != NULL && res >= sizeof(uint32_t)) {
1771 *(uint32_t *)p = pkt->mode.rresq.data;
1772 rb->xfer->recv.pay_len = sizeof(uint32_t);
1773 return;
1774 }
1775
1776 if ((tinfo->flag & FWTI_BLOCK_ASY) == 0)
1777 return;
1778
1779 plen = pkt->mode.rresb.len;
1780

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

1803fw_rcv(struct fw_rcv_buf *rb)
1804{
1805 struct fw_pkt *fp, *resfp;
1806 struct fw_bind *bind;
1807 int tcode, s;
1808 int i, len, oldstate;
1809#if 0
1810 {
1773 return;
1774 }
1775
1776 if ((tinfo->flag & FWTI_BLOCK_ASY) == 0)
1777 return;
1778
1779 plen = pkt->mode.rresb.len;
1780

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

1803fw_rcv(struct fw_rcv_buf *rb)
1804{
1805 struct fw_pkt *fp, *resfp;
1806 struct fw_bind *bind;
1807 int tcode, s;
1808 int i, len, oldstate;
1809#if 0
1810 {
1811 u_int32_t *qld;
1811 uint32_t *qld;
1812 int i;
1812 int i;
1813 qld = (u_int32_t *)buf;
1813 qld = (uint32_t *)buf;
1814 printf("spd %d len:%d\n", spd, len);
1815 for( i = 0 ; i <= len && i < 32; i+= 4){
1816 printf("0x%08x ", ntohl(qld[i/4]));
1817 if((i % 16) == 15) printf("\n");
1818 }
1819 if((i % 16) != 15) printf("\n");
1820 }
1821#endif

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

2103#ifdef FW_VMACCESS
2104/*
2105 * Software implementation for physical memory block access.
2106 * XXX:Too slow, usef for debug purpose only.
2107 */
2108static void
2109fw_vmaccess(struct fw_xfer *xfer){
2110 struct fw_pkt *rfp, *sfp = NULL;
1814 printf("spd %d len:%d\n", spd, len);
1815 for( i = 0 ; i <= len && i < 32; i+= 4){
1816 printf("0x%08x ", ntohl(qld[i/4]));
1817 if((i % 16) == 15) printf("\n");
1818 }
1819 if((i % 16) != 15) printf("\n");
1820 }
1821#endif

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

2103#ifdef FW_VMACCESS
2104/*
2105 * Software implementation for physical memory block access.
2106 * XXX:Too slow, usef for debug purpose only.
2107 */
2108static void
2109fw_vmaccess(struct fw_xfer *xfer){
2110 struct fw_pkt *rfp, *sfp = NULL;
2111 u_int32_t *ld = (u_int32_t *)xfer->recv.buf;
2111 uint32_t *ld = (uint32_t *)xfer->recv.buf;
2112
2113 printf("vmaccess spd:%2x len:%03x data:%08x %08x %08x %08x\n",
2114 xfer->spd, xfer->recv.len, ntohl(ld[0]), ntohl(ld[1]), ntohl(ld[2]), ntohl(ld[3]));
2115 printf("vmaccess data:%08x %08x %08x %08x\n", ntohl(ld[4]), ntohl(ld[5]), ntohl(ld[6]), ntohl(ld[7]));
2116 if(xfer->resp != 0){
2117 fw_xfer_free( xfer);
2118 return;
2119 }

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

2132 (caddr_t)ntohl(rfp->mode.wreqb.dest_lo), ntohs(rfp->mode.wreqb.len));
2133 sfp->mode.wres.tcode = FWTCODE_WRES;
2134 sfp->mode.wres.rtcode = 0;
2135 break;
2136 case FWTCODE_WREQQ:
2137 xfer->send.buf = malloc(12, M_FW, M_NOWAIT);
2138 xfer->send.len = 12;
2139 sfp->mode.wres.tcode = FWTCODE_WRES;
2112
2113 printf("vmaccess spd:%2x len:%03x data:%08x %08x %08x %08x\n",
2114 xfer->spd, xfer->recv.len, ntohl(ld[0]), ntohl(ld[1]), ntohl(ld[2]), ntohl(ld[3]));
2115 printf("vmaccess data:%08x %08x %08x %08x\n", ntohl(ld[4]), ntohl(ld[5]), ntohl(ld[6]), ntohl(ld[7]));
2116 if(xfer->resp != 0){
2117 fw_xfer_free( xfer);
2118 return;
2119 }

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

2132 (caddr_t)ntohl(rfp->mode.wreqb.dest_lo), ntohs(rfp->mode.wreqb.len));
2133 sfp->mode.wres.tcode = FWTCODE_WRES;
2134 sfp->mode.wres.rtcode = 0;
2135 break;
2136 case FWTCODE_WREQQ:
2137 xfer->send.buf = malloc(12, M_FW, M_NOWAIT);
2138 xfer->send.len = 12;
2139 sfp->mode.wres.tcode = FWTCODE_WRES;
2140 *((u_int32_t *)(ntohl(rfp->mode.wreqb.dest_lo))) = rfp->mode.wreqq.data;
2140 *((uint32_t *)(ntohl(rfp->mode.wreqb.dest_lo))) = rfp->mode.wreqq.data;
2141 sfp->mode.wres.rtcode = 0;
2142 break;
2143 case FWTCODE_RREQB:
2144 xfer->send.buf = malloc(16 + rfp->mode.rreqb.len, M_FW, M_NOWAIT);
2145 xfer->send.len = 16 + ntohs(rfp->mode.rreqb.len);
2146 sfp = (struct fw_pkt *)xfer->send.buf;
2147 bcopy((caddr_t)ntohl(rfp->mode.rreqb.dest_lo),
2141 sfp->mode.wres.rtcode = 0;
2142 break;
2143 case FWTCODE_RREQB:
2144 xfer->send.buf = malloc(16 + rfp->mode.rreqb.len, M_FW, M_NOWAIT);
2145 xfer->send.len = 16 + ntohs(rfp->mode.rreqb.len);
2146 sfp = (struct fw_pkt *)xfer->send.buf;
2147 bcopy((caddr_t)ntohl(rfp->mode.rreqb.dest_lo),
2148 sfp->mode.rresb.payload, (u_int16_t)ntohs(rfp->mode.rreqb.len));
2148 sfp->mode.rresb.payload, (uint16_t)ntohs(rfp->mode.rreqb.len));
2149 sfp->mode.rresb.tcode = FWTCODE_RRESB;
2150 sfp->mode.rresb.len = rfp->mode.rreqb.len;
2151 sfp->mode.rresb.rtcode = 0;
2152 sfp->mode.rresb.extcode = 0;
2153 break;
2154 case FWTCODE_RREQQ:
2155 xfer->send.buf = malloc(16, M_FW, M_NOWAIT);
2156 xfer->send.len = 16;
2157 sfp = (struct fw_pkt *)xfer->send.buf;
2149 sfp->mode.rresb.tcode = FWTCODE_RRESB;
2150 sfp->mode.rresb.len = rfp->mode.rreqb.len;
2151 sfp->mode.rresb.rtcode = 0;
2152 sfp->mode.rresb.extcode = 0;
2153 break;
2154 case FWTCODE_RREQQ:
2155 xfer->send.buf = malloc(16, M_FW, M_NOWAIT);
2156 xfer->send.len = 16;
2157 sfp = (struct fw_pkt *)xfer->send.buf;
2158 sfp->mode.rresq.data = *(u_int32_t *)(ntohl(rfp->mode.rreqq.dest_lo));
2158 sfp->mode.rresq.data = *(uint32_t *)(ntohl(rfp->mode.rreqq.dest_lo));
2159 sfp->mode.wres.tcode = FWTCODE_RRESQ;
2160 sfp->mode.rresb.rtcode = 0;
2161 break;
2162 default:
2163 fw_xfer_free( xfer);
2164 return;
2165 }
2166 sfp->mode.hdr.dst = rfp->mode.hdr.src;

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

2175/**/
2176 return;
2177}
2178#endif
2179
2180/*
2181 * CRC16 check-sum for IEEE1394 register blocks.
2182 */
2159 sfp->mode.wres.tcode = FWTCODE_RRESQ;
2160 sfp->mode.rresb.rtcode = 0;
2161 break;
2162 default:
2163 fw_xfer_free( xfer);
2164 return;
2165 }
2166 sfp->mode.hdr.dst = rfp->mode.hdr.src;

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

2175/**/
2176 return;
2177}
2178#endif
2179
2180/*
2181 * CRC16 check-sum for IEEE1394 register blocks.
2182 */
2183u_int16_t
2184fw_crc16(u_int32_t *ptr, u_int32_t len){
2185 u_int32_t i, sum, crc = 0;
2183uint16_t
2184fw_crc16(uint32_t *ptr, uint32_t len){
2185 uint32_t i, sum, crc = 0;
2186 int shift;
2187 len = (len + 3) & ~3;
2188 for(i = 0 ; i < len ; i+= 4){
2189 for( shift = 28 ; shift >= 0 ; shift -= 4){
2190 sum = ((crc >> 12) ^ (ptr[i/4] >> shift)) & 0xf;
2191 crc = (crc << 4) ^ ( sum << 12 ) ^ ( sum << 5) ^ sum;
2192 }
2193 crc &= 0xffff;
2194 }
2186 int shift;
2187 len = (len + 3) & ~3;
2188 for(i = 0 ; i < len ; i+= 4){
2189 for( shift = 28 ; shift >= 0 ; shift -= 4){
2190 sum = ((crc >> 12) ^ (ptr[i/4] >> shift)) & 0xf;
2191 crc = (crc << 4) ^ ( sum << 12 ) ^ ( sum << 5) ^ sum;
2192 }
2193 crc &= 0xffff;
2194 }
2195 return((u_int16_t) crc);
2195 return((uint16_t) crc);
2196}
2197
2198static int
2199fw_bmr(struct firewire_comm *fc)
2200{
2201 struct fw_device fwdev;
2202 union fw_self_id *self_id;
2203 int cmstr;
2196}
2197
2198static int
2199fw_bmr(struct firewire_comm *fc)
2200{
2201 struct fw_device fwdev;
2202 union fw_self_id *self_id;
2203 int cmstr;
2204 u_int32_t quad;
2204 uint32_t quad;
2205
2206 /* Check to see if the current root node is cycle master capable */
2207 self_id = fw_find_self_id(fc, fc->max_node);
2208 if (fc->max_node > 0) {
2209 /* XXX check cmc bit of businfo block rather than contender */
2210 if (self_id->p0.link_active && self_id->p0.contender)
2211 cmstr = fc->max_node;
2212 else {

--- 71 unchanged lines hidden ---
2205
2206 /* Check to see if the current root node is cycle master capable */
2207 self_id = fw_find_self_id(fc, fc->max_node);
2208 if (fc->max_node > 0) {
2209 /* XXX check cmc bit of businfo block rather than contender */
2210 if (self_id->p0.link_active && self_id->p0.contender)
2211 cmstr = fc->max_node;
2212 else {

--- 71 unchanged lines hidden ---