| 1641 | Device::readRegFL (fb_nodeaddr_t offset, fb_quadlet_t *result) { |
---|
| 1642 | debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08"PRIX64"\n", offset); |
---|
| 1643 | |
---|
| 1644 | if(offset >= DICE_INVALID_OFFSET) { |
---|
| 1645 | debugError("invalid offset: 0x%016"PRIX64"\n", offset); |
---|
| 1646 | return false; |
---|
| 1647 | } |
---|
| 1648 | |
---|
| 1649 | fb_nodeid_t nodeId = getNodeId() | 0xFFC0; |
---|
| 1650 | |
---|
| 1651 | if(!get1394Service().read_quadlet(nodeId, offset, result)) { |
---|
| 1652 | debugError("Could not read from node 0x%04X addr 0x%12"PRIX64"\n", nodeId, offset); |
---|
| 1653 | return false; |
---|
| 1654 | } |
---|
| 1655 | |
---|
| 1656 | *result = CondSwapFromBus32(*result); |
---|
| 1657 | |
---|
| 1658 | debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08"PRIX32"\n", *result); |
---|
| 1659 | |
---|
| 1660 | return true; |
---|
| 1661 | } |
---|
| 1662 | |
---|
| 1663 | bool |
---|
| 1678 | return false; |
---|
| 1679 | } |
---|
| 1680 | return true; |
---|
| 1681 | } |
---|
| 1682 | |
---|
| 1683 | bool |
---|
| 1684 | Device::writeRegFL(fb_nodeaddr_t offset, fb_quadlet_t data) { |
---|
| 1685 | debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08"PRIX64", data: 0x%08"PRIX32"\n", |
---|
| 1686 | offset, data); |
---|
| 1687 | |
---|
| 1688 | if(offset >= DICE_INVALID_OFFSET) { |
---|
| 1689 | debugError("invalid offset: 0x%012"PRIX64"\n", offset); |
---|
| 1690 | return false; |
---|
| 1691 | } |
---|
| 1692 | |
---|
| 1693 | fb_nodeid_t nodeId = getNodeId() | 0xFFC0; |
---|
| 1694 | |
---|
| 1695 | if(!get1394Service().write_quadlet( nodeId, offset, CondSwapToBus32(data) ) ) { |
---|
| 1696 | debugError("Could not write to node 0x%04X addr 0x%12"PRIX64"\n", nodeId, offset); |
---|
| 1747 | Device::readRegBlockFL(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { |
---|
| 1748 | debugOutput(DEBUG_LEVEL_VERBOSE, |
---|
| 1749 | "Reading base register offset 0x%08"PRIX64", length %zd, to %p\n", |
---|
| 1750 | offset, length, data); |
---|
| 1751 | const int blocksize_quads = 512/4; |
---|
| 1752 | |
---|
| 1753 | if(offset >= DICE_INVALID_OFFSET) { |
---|
| 1754 | debugError("invalid offset: 0x%012"PRIX64"\n", offset); |
---|
| 1755 | return false; |
---|
| 1756 | } |
---|
| 1757 | |
---|
| 1758 | fb_nodeid_t nodeId = getNodeId() | 0xFFC0; |
---|
| 1759 | int quads_done = 0; |
---|
| 1760 | int length_quads = (length+3)/4; // round to next full quadlet |
---|
| 1761 | while(quads_done < length_quads) { |
---|
| 1762 | fb_nodeaddr_t curr_addr = offset + quads_done*4; |
---|
| 1763 | fb_quadlet_t *curr_data = data + quads_done; |
---|
| 1764 | int quads_todo = length_quads - quads_done; |
---|
| 1765 | debugOutput(DEBUG_LEVEL_VERBOSE, "reading addr: 0x%012"PRIX64", %d quads to %p\n", curr_addr, quads_todo, curr_data); |
---|
| 1766 | |
---|
| 1767 | if (quads_todo > blocksize_quads) { |
---|
| 1768 | debugOutput(DEBUG_LEVEL_VERBOSE, "Truncating read from %d to %d quadlets\n", quads_todo, blocksize_quads); |
---|
| 1769 | quads_todo = blocksize_quads; |
---|
| 1770 | } |
---|
| 1771 | #ifdef DEBUG |
---|
| 1772 | if (quads_todo < 0) { |
---|
| 1773 | debugError("BUG: quads_todo < 0: %d\n", quads_todo); |
---|
| 1774 | } |
---|
| 1775 | #endif |
---|
| 1776 | |
---|
| 1777 | if(!get1394Service().read( nodeId, curr_addr, quads_todo, curr_data ) ) { |
---|
| 1778 | debugError("Could not read %d quadlets from node 0x%04X addr 0x%012"PRIX64"\n", quads_todo, nodeId, curr_addr); |
---|
| 1779 | return false; |
---|
| 1780 | } |
---|
| 1781 | quads_done += quads_todo; |
---|
| 1782 | } |
---|
| 1783 | |
---|
| 1784 | byteSwapFromBus(data, length/4); |
---|
| 1785 | return true; |
---|
| 1786 | } |
---|
| 1787 | |
---|
| 1788 | bool |
---|
| 1832 | Device::writeRegBlockFL(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { |
---|
| 1833 | debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08"PRIX64", length: %zd\n", |
---|
| 1834 | offset, length); |
---|
| 1835 | const int blocksize_quads = 512/4; |
---|
| 1836 | |
---|
| 1837 | if(offset >= DICE_INVALID_OFFSET) { |
---|
| 1838 | debugError("invalid offset: 0x%012"PRIX64"\n", offset); |
---|
| 1839 | return false; |
---|
| 1840 | } |
---|
| 1841 | |
---|
| 1842 | fb_quadlet_t data_out[length/4]; |
---|
| 1843 | memcpy(data_out, data, length); |
---|
| 1844 | byteSwapToBus(data_out, length/4); |
---|
| 1845 | |
---|
| 1846 | fb_nodeid_t nodeId = getNodeId() | 0xFFC0; |
---|
| 1847 | int quads_done = 0; |
---|
| 1848 | int length_quads = (length+3)/4; |
---|
| 1849 | while(quads_done < length_quads) { |
---|
| 1850 | fb_nodeaddr_t curr_addr = offset + quads_done*4; |
---|
| 1851 | fb_quadlet_t *curr_data = data_out + quads_done; |
---|
| 1852 | int quads_todo = length_quads - quads_done; |
---|
| 1853 | if (quads_todo > blocksize_quads) { |
---|
| 1854 | debugOutput(DEBUG_LEVEL_VERBOSE, "Truncating write from %d to %d quadlets\n", quads_todo, blocksize_quads); |
---|
| 1855 | quads_todo = blocksize_quads; |
---|
| 1856 | } |
---|
| 1857 | #ifdef DEBUG |
---|
| 1858 | if (quads_todo < 0) { |
---|
| 1859 | debugError("BUG: quads_todo < 0: %d\n", quads_todo); |
---|
| 1860 | } |
---|
| 1861 | #endif |
---|
| 1862 | |
---|
| 1863 | if(!get1394Service().write( nodeId, curr_addr, quads_todo, curr_data ) ) { |
---|
| 1864 | debugError("Could not write %d quadlets to node 0x%04X addr 0x%012"PRIX64"\n", quads_todo, nodeId, curr_addr); |
---|
| 1865 | return false; |
---|
| 1866 | } |
---|
| 1867 | quads_done += quads_todo; |
---|
| 1868 | } |
---|
| 1869 | |
---|
| 1870 | return true; |
---|
| 1871 | } |
---|
| 1872 | |
---|
| 1873 | bool |
---|