21 #if defined(HAVE_BOLOS)
22 #include "bolos_privileged_ux.h"
25 #include "bolos_target.h"
30 #include "os_screen.h"
34 #define COMPLIANCE_UX_160
35 #define HAVE_UX_LEGACY
41 #if defined(HAVE_INDEXED_STRINGS)
43 #include "bolos_ux_loc_strings.h"
60 #if defined(HAVE_INDEXED_STRINGS)
73 #if !defined(HAVE_INDEXED_STRINGS)
74 #define STATIC_IF_NOT_INDEXED static
76 #define STATIC_IF_NOT_INDEXED
82 unsigned short element_count,
85 unsigned char event_kind);
87 unsigned short element_count,
90 unsigned char event_kind,
107 const bagl_icon_details_t *
icon;
111 #if defined(HAVE_INDEXED_STRINGS)
115 const bagl_icon_details_t *get_glyphs_icon(
unsigned char id);
116 const char *get_string_buffer(
unsigned char id);
119 #if defined(HAVE_LANGUAGE_PACK)
120 void bolos_ux_select_language(
uint16_t language);
121 void bolos_ux_refresh_language(
void);
123 typedef struct ux_loc_language_pack_infos {
124 unsigned char available;
126 } UX_LOC_LANGUAGE_PACK_INFO;
129 SYSCALL PERMISSION(APPLICATION_FLAG_BOLOS_UX)
void list_language_packs(
130 UX_LOC_LANGUAGE_PACK_INFO *packs PLENGTH(NB_LANG *
sizeof(UX_LOC_LANGUAGE_PACK_INFO)));
131 SYSCALL PERMISSION(APPLICATION_FLAG_BOLOS_UX)
const LANGUAGE_PACK *get_language_pack(
132 unsigned int language);
135 #ifndef BUTTON_FAST_THRESHOLD_CS
136 #define BUTTON_FAST_THRESHOLD_CS 8
138 #ifndef BUTTON_FAST_ACTION_CS
139 #define BUTTON_FAST_ACTION_CS 3
143 unsigned int button_mask_counter);
144 #define BUTTON_LEFT 1
145 #define BUTTON_RIGHT 2
147 #define BUTTON_EVT_FAST 0x40000000UL
148 #define BUTTON_EVT_RELEASED 0x80000000UL
150 unsigned int new_button_mask);
157 unsigned int average_char_width);
160 unsigned int average_char_width);
165 #ifndef UX_STACK_SLOT_COUNT
166 #define UX_STACK_SLOT_COUNT 1
169 #ifndef UX_STACK_SLOT_ARRAY_COUNT
170 #define UX_STACK_SLOT_ARRAY_COUNT 1
212 #ifdef HAVE_SE_SCREEN
216 #ifdef HAVE_UX_LEGACY
234 const bagl_icon_details_t *
icon;
257 const bagl_icon_details_t *
icon;
287 #if defined(HAVE_UX_FLOW)
309 ux_layout_paging_state_t layout_paging;
316 #if defined(HAVE_UX_FLOW)
330 unsigned int menulist_current;
332 list_item_value_t menulist_getter;
333 list_item_select_t menulist_selector;
336 #ifdef COMPLIANCE_UX_160
343 #ifdef COMPLIANCE_UX_160
346 #define G_ux_params ux.params
347 #define callback_interval_ms stack[0].ticker_interval
349 memset(&G_ux, 0, sizeof(G_ux)); \
363 #define UX_INIT() memset(&G_ux, 0, sizeof(G_ux));
373 #ifdef HAVE_SE_SCREEN
374 #define UX_DISPLAY_NEXT_ELEMENT() \
375 if (G_ux.stack[0].element_arrays[0].element_array \
376 && G_ux.stack[0].element_index < G_ux.stack[0].element_arrays[0].element_array_count \
377 && (os_perso_isonboarded() != BOLOS_UX_OK \
378 || os_global_pin_is_validated() == BOLOS_UX_OK)) { \
379 while (G_ux.stack[0].element_index \
380 < G_ux.stack[0].element_arrays[0].element_array_count) { \
381 const bagl_element_t *element \
382 = &G_ux.stack[0].element_arrays[0].element_array[G_ux.stack[0].element_index]; \
383 if (!G_ux.stack[0].screen_before_element_display_callback \
384 || (element = G_ux.stack[0].screen_before_element_display_callback(element))) { \
385 if ((unsigned int) element \
387 element = &G_ux.stack[0] \
389 .element_array[G_ux.stack[0].element_index]; \
391 io_seproxyhal_display(element); \
393 G_ux.stack[0].element_index++; \
395 if (G_ux.stack[0].element_index == G_ux.stack[0].element_arrays[0].element_array_count) { \
400 #define UX_DISPLAY_NEXT_ELEMENT() \
401 while (G_ux.stack[0].element_arrays[0].element_array \
402 && G_ux.stack[0].element_index < G_ux.stack[0].element_arrays[0].element_array_count \
403 && !io_seproxyhal_spi_is_status_sent() \
404 && (os_perso_isonboarded() != BOLOS_UX_OK \
405 || os_global_pin_is_validated() == BOLOS_UX_OK)) { \
406 const bagl_element_t *element \
407 = &G_ux.stack[0].element_arrays[0].element_array[G_ux.stack[0].element_index]; \
408 if (!G_ux.stack[0].screen_before_element_display_callback \
409 || (element = G_ux.stack[0].screen_before_element_display_callback(element))) { \
410 if ((unsigned int) element \
413 = &G_ux.stack[0].element_arrays[0].element_array[G_ux.stack[0].element_index]; \
415 io_seproxyhal_display(element); \
417 G_ux.stack[0].element_index++; \
426 #define UX_FORWARD_EVENT_REDRAWCB(bypasspincheck, \
430 os_sched_last_status, \
433 ignoring_app_if_ux_busy) \
434 G_ux_params.ux_id = BOLOS_UX_EVENT; \
435 G_ux_params.len = 0; \
436 os_ux(&G_ux_params); \
437 G_ux_params.len = os_sched_last_status(TASK_BOLOS_UX); \
438 if (G_ux.asynchmodal_end_callback \
439 && os_ux_get_status(BOLOS_UX_ASYNCHMODAL_PAIRING_REQUEST) != 0) { \
440 asynchmodal_end_callback_t cb = G_ux.asynchmodal_end_callback; \
441 G_ux.asynchmodal_end_callback = NULL; \
442 cb(os_ux_get_status(BOLOS_UX_ASYNCHMODAL_PAIRING_REQUEST)); \
443 G_ux_params.len = BOLOS_UX_REDRAW; \
445 if (G_ux_params.len == BOLOS_UX_REDRAW) { \
448 else if (!ignoring_app_if_ux_busy \
449 || (G_ux_params.len != BOLOS_UX_IGNORE && G_ux_params.len != BOLOS_UX_CONTINUE)) { \
459 #define UX_FORWARD_EVENT_REDRAWCB(bypasspincheck, \
463 os_sched_last_status, \
466 ignoring_app_if_ux_busy) \
467 G_ux_params.ux_id = BOLOS_UX_EVENT; \
468 G_ux_params.len = 0; \
469 os_ux(&G_ux_params); \
470 G_ux_params.len = os_sched_last_status(TASK_BOLOS_UX); \
471 if (G_ux_params.len == BOLOS_UX_REDRAW) { \
474 else if (!ignoring_app_if_ux_busy \
475 || (G_ux_params.len != BOLOS_UX_IGNORE && G_ux_params.len != BOLOS_UX_CONTINUE)) { \
485 #define UX_WAKE_UP() \
486 G_ux_params.ux_id = BOLOS_UX_WAKE_UP; \
487 G_ux_params.len = 0; \
488 os_ux(&G_ux_params); \
489 G_ux_params.len = os_sched_last_status(TASK_BOLOS_UX);
494 #define UX_REDISPLAY_REQUEST() \
495 io_seproxyhal_init_ux(); \
496 io_seproxyhal_init_button(); \
497 G_ux.stack[0].element_index = 0;
502 #define UX_REDISPLAY_IDX(index) \
503 io_seproxyhal_init_ux(); \
504 io_seproxyhal_init_button();
506 G_ux.stack[0].element_index = index; \
508 G_ux_params.len = os_sched_last_status(TASK_BOLOS_UX); \
509 if (G_ux_params.len != BOLOS_UX_IGNORE && G_ux_params.len != BOLOS_UX_CONTINUE) { \
510 UX_DISPLAY_NEXT_ELEMENT(); \
516 #define UX_REDISPLAY() UX_REDISPLAY_IDX(0)
518 #define UX_DISPLAY(elements_array, preprocessor) \
519 G_ux.stack[0].element_arrays[0].element_array = elements_array; \
520 G_ux.stack[0].element_arrays[0].element_array_count \
521 = sizeof(elements_array) / sizeof(elements_array[0]); \
522 G_ux.stack[0].button_push_callback = elements_array##_button; \
523 G_ux.stack[0].screen_before_element_display_callback = preprocessor; \
531 #define UX_DISPLAY_REQUEST(elements_array, preprocessor) \
532 G_ux.stack[0].element_arrays[0].element_array = elements_array; \
533 G_ux.stack[0].element_arrays[0].element_array_count \
534 = sizeof(elements_array) / sizeof(elements_array[0]); \
535 G_ux.stack[0].button_push_callback = elements_array##_button; \
536 G_ux.stack[0].screen_before_element_display_callback = preprocessor; \
543 #define UX_CALLBACK_SET_INTERVAL(ms) G_ux.stack[0].ticker_value = ms;
549 #define UX_FORWARD_EVENT(callback, ignoring_app_if_ux_busy) \
550 UX_FORWARD_EVENT_REDRAWCB(0, \
552 G_io_asynch_ux_callback, \
554 os_sched_last_status, \
557 ignoring_app_if_ux_busy);
559 #define UX_CONTINUE_DISPLAY_APP(displayed_callback) \
560 UX_DISPLAY_NEXT_ELEMENT(); \
562 if (G_ux.stack[0].element_index >= G_ux.stack[0].element_arrays[0].element_array_count \
563 && !io_seproxyhal_spi_is_status_sent()) { \
570 #define UX_DISPLAYED_EVENT(displayed_callback) \
571 UX_FORWARD_EVENT({ UX_CONTINUE_DISPLAY_APP(displayed_callback); }, 1)
576 #define UX_DISPLAYED() \
577 (G_ux.stack[0].element_index >= G_ux.stack[0].element_arrays[0].element_array_count)
583 #ifdef HAVE_SE_SCREEN
584 #define UX_WAIT_DISPLAYED() \
585 while (!UX_DISPLAYED()) { \
586 UX_DISPLAY_NEXT_ELEMENT(); \
589 #define UX_WAIT_DISPLAYED() \
590 while (!UX_DISPLAYED()) { \
592 io_seproxyhal_spi_recv(G_io_seproxyhal_spi_buffer, sizeof(G_io_seproxyhal_spi_buffer), 0); \
593 io_seproxyhal_handle_event(); \
594 UX_DISPLAY_NEXT_ELEMENT(); \
596 io_seproxyhal_spi_recv(G_io_seproxyhal_spi_buffer, sizeof(G_io_seproxyhal_spi_buffer), 0); \
597 io_seproxyhal_handle_event(); \
600 io_seproxyhal_general_status(); \
602 io_seproxyhal_spi_recv(G_io_seproxyhal_spi_buffer, sizeof(G_io_seproxyhal_spi_buffer), 0);
609 #define UX_BUTTON_PUSH_EVENT(seph_packet) \
612 if (G_ux.stack[0].button_push_callback) { \
613 io_seproxyhal_button_push(G_ux.stack[0].button_push_callback, \
614 seph_packet[3] >> 1); \
616 UX_CONTINUE_DISPLAY_APP({}); \
620 #define UX_FINGER_EVENT(seph_packet)
625 #define UX_TICKER_EVENT(seph_packet, callback) \
628 unsigned int UX_ALLOWED \
629 = (G_ux_params.len != BOLOS_UX_IGNORE && G_ux_params.len != BOLOS_UX_CONTINUE); \
630 if (G_ux.stack[0].ticker_value) { \
631 G_ux.stack[0].ticker_value -= MIN(G_ux.stack[0].ticker_value, 100); \
632 if (!G_ux.stack[0].ticker_value) { \
633 if (!G_ux.stack[0].ticker_callback) { \
637 G_ux.stack[0].ticker_value = G_ux.stack[0].ticker_interval; \
638 G_ux.stack[0].ticker_callback(0); \
643 UX_CONTINUE_DISPLAY_APP({}); \
652 #define UX_DEFAULT_EVENT() UX_FORWARD_EVENT({ UX_CONTINUE_DISPLAY_APP({}); }, 0);
658 #define UX_DISPLAY_KEYBOARD(callback) \
659 G_ux_params.ux_id = BOLOS_UX_KEYBOARD; \
660 G_ux_params.len = 0; \
661 os_ux(&G_ux_params); \
662 G_ux_params.len = os_sched_last_status(TASK_BOLOS_UX);
680 unsigned int *color_index,
681 unsigned int bit_per_pixel,
682 unsigned char *bitmap);
697 const bagl_icon_details_t *icon_details);
703 const bagl_icon_details_t *icon_details,
704 unsigned int *icon_len);
712 unsigned int ux_status;
718 #ifdef HAVE_UX_LEGACY
719 #define UX_MENU_END \
721 NULL, NULL, 0, NULL, NULL, NULL, 0, 0 \
724 #define UX_MENU_INIT() memset(&ux_menu, 0, sizeof(ux_menu));
726 #define UX_MENU_DISPLAY(current_entry, menu_entries, menu_entry_preprocessor) \
727 ux_menu_display(current_entry, menu_entries, menu_entry_preprocessor);
730 #define UX_MENU_UNCHANGED_ENTRY (-1UL)
738 #define UX_TURNER_INIT() memset(&ux_turner, 0, sizeof(ux_turner));
740 #define UX_TURNER_DISPLAY(current_step, steps, steps_count, button_push_callback) \
741 ux_turner_display(current_step, steps, steps_count, button_push_callback);
744 #define UX_TURNER_UNCHANGED_ENTRY (-1UL)
747 unsigned int steps_count,
755 #ifdef HAVE_UX_LEGACY
760 #error HAVE_UX_LEGACY must be removed in the release
762 #warning Refactor UX plz
Key pair generation based on elliptic curves.
const char * get_ux_loc_string(uint32_t index)
bagl_component_t component
const bagl_icon_details_t * icon
unsigned int button_same_mask_counter
unsigned char element_arrays_count
button_push_callback_t button_push_callback
struct ux_stack_slot_s::@45 element_arrays[UX_STACK_SLOT_ARRAY_COUNT]
unsigned int ticker_interval
bolos_task_status_t exit_code_after_elements_displayed
unsigned short element_index
callback_int_t ticker_callback
bagl_element_callback_t screen_before_element_display_callback
unsigned int ticker_value
const bagl_element_t * element_array
unsigned char element_array_count
unsigned char stack_count
ux_stack_slot_t stack[UX_STACK_SLOT_COUNT]
asynchmodal_end_callback_t asynchmodal_end_callback
bagl_element_t tmp_element
bolos_task_status_t exit_code
unsigned int current_step
const ux_turner_step_t * steps
button_push_callback_t button_callback
const bagl_icon_details_t * icon
unsigned int next_step_ms
void io_seproxyhal_button_push(button_push_callback_t button_push_callback, unsigned int new_button_mask)
void(* ux_menu_callback_t)(unsigned int userid)
unsigned int ux_stack_push(void)
const bagl_element_t *(* ux_menu_preprocessor_t)(const ux_menu_entry_t *, bagl_element_t *element)
void io_seproxyhal_setup_ticker(unsigned int interval_ms)
const ux_menu_entry_t *(* ux_menu_iterator_t)(unsigned int entry_idx)
const bagl_element_t * ux_stack_display_element_callback(const bagl_element_t *element)
unsigned int ux_stack_is_element_array_present(const bagl_element_t *element_array)
const bagl_element_t * ux_layout_strings_prepro(const bagl_element_t *element)
void io_seproxyhal_touch_callback(const bagl_element_t *element, unsigned char event)
void(* asynchmodal_end_callback_t)(unsigned int ux_status)
void io_seproxyhal_display_bitmap(int x, int y, unsigned int w, unsigned int h, unsigned int *color_index, unsigned int bit_per_pixel, unsigned char *bitmap)
struct ux_turner_state_s ux_turner_state_t
struct ux_seph_s ux_seph_os_and_app_t
struct ux_menu_state_s ux_menu_state_t
const bagl_element_t * ux_menu_element_preprocessor(const bagl_element_t *element)
#define UX_STACK_SLOT_COUNT
void ux_turner_display(unsigned int current_step, const ux_turner_step_t *steps, unsigned int steps_count, button_push_callback_t button_callback)
void io_seproxyhal_disable_io(void)
void io_seproxyhal_backlight(unsigned int flags, unsigned int backlight_percentage)
const bagl_element_t *(* bagl_element_callback_t)(const bagl_element_t *element)
void io_seproxyhal_power_off(bool criticalBattery)
void ux_turner_ticker(unsigned int elpased_ms)
struct ux_layout_icon_strings_params_s ux_layout_icon_strings_params_t
void ux_stack_display(unsigned int stack_slot)
void(* ux_turner_callback_t)(void)
void io_seproxyhal_se_reset(void)
void io_seproxyhal_display(const bagl_element_t *element)
void io_seproxyhal_touch_element_callback(const bagl_element_t *elements, unsigned short element_count, unsigned short x, unsigned short y, unsigned char event_kind, bagl_element_callback_t before_display)
void ux_stack_remove(unsigned int stack_slot)
void io_seproxyhal_display_default(const bagl_element_t *element)
struct ux_turner_step_s ux_turner_step_t
void ux_stack_al_display_next_element(unsigned int stack_slot)
void ux_stack_insert(unsigned int stack_slot)
void io_seproxyhal_touch(const bagl_element_t *elements, unsigned short element_count, unsigned short x, unsigned short y, unsigned char event_kind)
ux_turner_state_t ux_turner
ux_seph_os_and_app_t G_ux_os
void ux_stack_init(unsigned int stack_slot)
void io_seproxyhal_display_icon(const bagl_component_t *icon_component, const bagl_icon_details_t *icon_details)
unsigned int(* button_push_callback_t)(unsigned int button_mask, unsigned int button_mask_counter)
unsigned int io_seproxyhal_display_icon_header_and_colors(const bagl_component_t *icon_component, const bagl_icon_details_t *icon_details, unsigned int *icon_len)
#define UX_STACK_SLOT_ARRAY_COUNT
void ux_menu_display(unsigned int current_entry, const ux_menu_entry_t *menu_entries, ux_menu_preprocessor_t menu_entry_preprocessor)
struct ux_layout_strings_params_s ux_layout_strings_params_t
void ux_stack_redisplay(void)
unsigned int bagl_label_roundtrip_duration_ms(const bagl_element_t *e, unsigned int average_char_width)
unsigned int bagl_label_roundtrip_duration_ms_buf(const bagl_element_t *e, const char *str, unsigned int average_char_width)
unsigned int ux_menu_elements_button(unsigned int button_mask, unsigned int button_mask_counter)
void io_seproxyhal_request_mcu_status(void)
unsigned int(* callback_int_t)(unsigned int)
unsigned int ux_stack_pop(void)
BOLOS_UX_LOC_STRINGS UX_LOC_STRINGS_INDEX