| 97 | } |
| 98 | |
| 99 | static uint8_t sha256_read(uint16_t pio, bool peek) { |
| 100 | uint16_t index = pio >> 2; |
| 101 | uint8_t bit_offset = (pio & 3) << 3; |
| 102 | |
| 103 | if (!peek) { |
| 104 | if (protected_ports_unlocked()) { |
| 105 | sha256.last = index; |
| 106 | } else { |
| 107 | index = sha256.last; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | if (index == 0x0C >> 2) { |
| 112 | return read8(sha256.state[7], bit_offset); |
| 113 | } else if (index >= 0x10 >> 2 && index < 0x50 >> 2) { |
| 114 | return read8(sha256.block[index - (0x10 >> 2)], bit_offset); |
| 115 | } else if (index >= 0x60 >> 2 && index < 0x80 >> 2) { |
| 116 | return read8(sha256.state[index - (0x60 >> 2)], bit_offset); |
| 117 | } |
| 118 | /* Return 0 if invalid */ |
| 119 | return 0; |
| 120 | } |
| 121 | |
| 122 | static void sha256_write(uint16_t pio, uint8_t byte, bool poke) { |
| 123 | uint16_t index = pio >> 2; |
nothing calls this directly
no test coverage detected