|
76 | 76 | #define S_UPLOAD 0x73 |
77 | 77 | #define WRITE 0x77 |
78 | 78 | #define RESET 0x78 |
| 79 | +#define HWINFO_WRITE 0x80 |
79 | 80 | #define S_INIT 0xAA |
80 | 81 | #define INIT 0xBB |
81 | 82 | #define EXIT 0xFF |
@@ -1019,6 +1020,27 @@ hw_ostc3_device_customtext (dc_device_t *abstract, const char *text) |
1019 | 1020 | return DC_STATUS_SUCCESS; |
1020 | 1021 | } |
1021 | 1022 |
|
| 1023 | +dc_status_t hw_ostc3_device_hwinfo_write (dc_device_t *abstract, unsigned char hwinfo[52]) |
| 1024 | +{ |
| 1025 | + hw_ostc3_device_t *device = (hw_ostc3_device_t *) abstract; |
| 1026 | + |
| 1027 | + if (!ISINSTANCE (abstract)) |
| 1028 | + return DC_STATUS_INVALIDARGS; |
| 1029 | + |
| 1030 | + dc_status_t rc = hw_ostc3_device_init (device, SERVICE); |
| 1031 | + if (rc != DC_STATUS_SUCCESS) |
| 1032 | + return rc; |
| 1033 | + |
| 1034 | + if (device->hardware == OSTC3) |
| 1035 | + return DC_STATUS_UNSUPPORTED; |
| 1036 | + |
| 1037 | + rc = hw_ostc3_transfer(device, NULL, HWINFO_WRITE, hwinfo, 52, NULL, 0, NULL, NODELAY); |
| 1038 | + if (rc != DC_STATUS_SUCCESS) |
| 1039 | + return rc; |
| 1040 | + |
| 1041 | + return DC_STATUS_SUCCESS; |
| 1042 | +} |
| 1043 | + |
1022 | 1044 | dc_status_t |
1023 | 1045 | hw_ostc3_device_config_read (dc_device_t *abstract, unsigned int config, unsigned char data[], unsigned int size) |
1024 | 1046 | { |
@@ -1641,32 +1663,45 @@ hw_ostc3_device_read (dc_device_t *abstract, unsigned int address, unsigned char |
1641 | 1663 | dc_status_t status = DC_STATUS_SUCCESS; |
1642 | 1664 | hw_ostc3_device_t *device = (hw_ostc3_device_t *) abstract; |
1643 | 1665 |
|
1644 | | - if ((address % SZ_FIRMWARE_BLOCK != 0) || |
1645 | | - (size % SZ_FIRMWARE_BLOCK != 0)) { |
1646 | | - ERROR (abstract->context, "Address or size not aligned to the page size!"); |
1647 | | - return DC_STATUS_INVALIDARGS; |
1648 | | - } |
1649 | | - |
1650 | 1666 | // Make sure the device is in service mode. |
1651 | 1667 | status = hw_ostc3_device_init (device, SERVICE); |
1652 | 1668 | if (status != DC_STATUS_SUCCESS) { |
1653 | 1669 | return status; |
1654 | 1670 | } |
1655 | 1671 |
|
1656 | | - if (device->hardware == OSTC4) { |
1657 | | - return DC_STATUS_UNSUPPORTED; |
1658 | | - } |
| 1672 | + if (device->hardware == OSTC3) { |
| 1673 | + if ((address % SZ_FIRMWARE_BLOCK != 0) || |
| 1674 | + (size % SZ_FIRMWARE_BLOCK != 0)) { |
| 1675 | + ERROR (abstract->context, "Address or size not aligned to the page size!"); |
| 1676 | + return DC_STATUS_INVALIDARGS; |
| 1677 | + } |
1659 | 1678 |
|
1660 | | - unsigned int nbytes = 0; |
1661 | | - while (nbytes < size) { |
1662 | | - // Read a memory page. |
1663 | | - status = hw_ostc3_firmware_block_read (device, address + nbytes, data + nbytes, SZ_FIRMWARE_BLOCK); |
| 1679 | + unsigned int nbytes = 0; |
| 1680 | + while (nbytes < size) { |
| 1681 | + // Read a memory page. |
| 1682 | + status = hw_ostc3_firmware_block_read (device, address + nbytes, data + nbytes, SZ_FIRMWARE_BLOCK); |
| 1683 | + if (status != DC_STATUS_SUCCESS) { |
| 1684 | + ERROR (abstract->context, "Failed to read block."); |
| 1685 | + |
| 1686 | + return status; |
| 1687 | + } |
| 1688 | + |
| 1689 | + nbytes += SZ_FIRMWARE_BLOCK; |
| 1690 | + } |
| 1691 | + } else { |
| 1692 | + if (address % 0x100 != 0) { |
| 1693 | + ERROR(abstract->context, "Address not aligned to the page size (0x100)!"); |
| 1694 | + |
| 1695 | + return DC_STATUS_INVALIDARGS; |
| 1696 | + } |
| 1697 | + |
| 1698 | + status = hw_ostc3_firmware_block_read(device, address >> 8, data, size); |
1664 | 1699 | if (status != DC_STATUS_SUCCESS) { |
1665 | | - ERROR (abstract->context, "Failed to read block."); |
| 1700 | + ERROR(abstract->context, "Failed to read block."); |
| 1701 | + |
1666 | 1702 | return status; |
1667 | 1703 | } |
1668 | 1704 |
|
1669 | | - nbytes += SZ_FIRMWARE_BLOCK; |
1670 | 1705 | } |
1671 | 1706 |
|
1672 | 1707 | return DC_STATUS_SUCCESS; |
|
0 commit comments