31 #define SW_WRONG_RESPONSE_LENGTH 0xB000
38 static uint32_t G_output_len = 0;
60 case SEPROXYHAL_TAG_BUTTON_PUSH_EVENT:
63 case SEPROXYHAL_TAG_STATUS_EVENT:
64 if (G_io_apdu_media == IO_APDU_MEDIA_USB_HID &&
66 SEPROXYHAL_TAG_STATUS_EVENT_FLAG_USB_POWERED)) {
67 THROW(EXCEPTION_IO_RESET);
70 case SEPROXYHAL_TAG_DISPLAY_PROCESSED_EVENT:
79 case SEPROXYHAL_TAG_FINGER_EVENT:
83 case SEPROXYHAL_TAG_TICKER_EVENT:
92 if (!io_seproxyhal_spi_is_status_sent()) {
93 io_seproxyhal_general_status();
101 switch (channel & ~(IO_FLAGS)) {
102 case CHANNEL_KEYBOARD:
106 io_seproxyhal_spi_send(G_io_apdu_buffer, tx_len);
108 if (channel & IO_RESET_AFTER_REPLIED) {
115 return io_seproxyhal_spi_recv(G_io_apdu_buffer,
sizeof(G_io_apdu_buffer), 0);
118 THROW(INVALID_PARAMETER);
135 switch (G_io_state) {
137 ret = io_exchange(CHANNEL_APDU | IO_CONTINUE_RX, G_output_len);
142 ret = io_exchange(CHANNEL_APDU | IO_ASYNCH_REPLY, G_output_len);
159 if (rdatalist && count > 0) {
160 for (
size_t i = 0; i < count; i++) {
161 const buffer_t *rdata = &rdatalist[i];
164 G_io_apdu_buffer + G_output_len,
165 sizeof(G_io_apdu_buffer) - G_output_len - 2)) {
170 PRINTF(
"<= FRAG (%u/%u) RData=%.*H\n", i + 1, count, rdata->
size, rdata->
ptr);
173 PRINTF(
"<= SW=%04X | RData=%.*H\n", sw, G_output_len, G_io_apdu_buffer);
176 PRINTF(
"<= SW=%04X | RData=\n", sw);
185 PRINTF(
"Swap answer is processed. Send it\n");
186 if (io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, G_output_len) == 0) {
187 swap_finalize_exchange_sign_transaction(sw ==
SW_OK);
190 PRINTF(
"Unrecoverable\n");
196 switch (G_io_state) {
201 #ifdef STANDARD_APP_SYNC_RAPDU
213 ret = io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, G_output_len);
222 #ifdef STANDARD_APP_SYNC_RAPDU
223 WEAK bool io_recv_and_process_event(
void)
225 int apdu_state = G_io_app.apdu_state;
227 os_io_seph_recv_and_process(0);
231 if (apdu_state == APDU_IDLE && G_io_app.apdu_state != APDU_IDLE) {
bool buffer_copy(const buffer_t *buffer, uint8_t *out, size_t out_len)
uint8_t G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B]
WEAK uint16_t io_exchange_al(uint8_t channel, uint16_t tx_len)
#define SW_WRONG_RESPONSE_LENGTH
WEAK int io_send_response_buffers(const buffer_t *rdatalist, size_t count, uint16_t sw)
WEAK uint8_t io_event(uint8_t channel)
WEAK int io_recv_command()
WEAK void app_ticker_event_callback(void)
@ RECEIVED
ready for new event
__attribute__((section("._nbgl_fonts_"))) const
return the non-unicode font corresponding to the given font ID
size_t size
Pointer to byte buffer.
size_t offset
Size of byte buffer.
volatile bool G_called_from_swap
volatile bool G_swap_response_ready
#define UX_TICKER_EVENT(seph_packet, callback)
#define UX_FINGER_EVENT(seph_packet)
void io_seproxyhal_display(const bagl_element_t *element)
void io_seproxyhal_display_default(const bagl_element_t *element)
#define UX_DEFAULT_EVENT()
#define UX_BUTTON_PUSH_EVENT(seph_packet)
#define UX_DISPLAYED_EVENT(displayed_callback)
void write_u16_be(uint8_t *ptr, size_t offset, uint16_t value)