| 120 | } |
| 121 | |
| 122 | static void sha256_write(uint16_t pio, uint8_t byte, bool poke) { |
| 123 | uint16_t index = pio >> 2; |
| 124 | uint8_t bit_offset = (pio & 3) << 3; |
| 125 | |
| 126 | if (!poke) { |
| 127 | if (protected_ports_unlocked()) { |
| 128 | sha256.last = index; |
| 129 | } else { |
| 130 | return; /* writes are ignored when mmio is locked */ |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | if (!pio && flash_unlocked()) { |
| 135 | if (byte & 0x10) { |
| 136 | memset(sha256.state, 0, sizeof(sha256.state)); |
| 137 | } else { |
| 138 | if ((byte & 0xE) == 0xA) /* 0A or 0B: first block */ |
| 139 | initialize(); |
| 140 | if ((byte & 0xA) == 0xA) /* 0E or 0F: subsequent blocks */ |
| 141 | process_block(); |
| 142 | } |
| 143 | } else if (index >= 0x10 >> 2 && index < 0x50 >> 2) { |
| 144 | write8(sha256.block[index - (0x10 >> 2)], bit_offset, byte); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | static const eZ80portrange_t device = { |
| 149 | .read = sha256_read, |
nothing calls this directly
no test coverage detected