mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-03 08:46:05 +00:00
fix(core): root ui callback for trezorconfig mod (#1412)
Co-authored-by: Pavol Rusnak <pavol@rusnak.io>
This commit is contained in:
parent
b8ffcadf94
commit
f3a64435f1
@ -31,16 +31,15 @@
|
|||||||
#include "memzero.h"
|
#include "memzero.h"
|
||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
|
|
||||||
STATIC mp_obj_t ui_wait_callback = mp_const_none;
|
|
||||||
|
|
||||||
STATIC secbool wrapped_ui_wait_callback(uint32_t wait, uint32_t progress,
|
STATIC secbool wrapped_ui_wait_callback(uint32_t wait, uint32_t progress,
|
||||||
const char *message) {
|
const char *message) {
|
||||||
if (mp_obj_is_callable(ui_wait_callback)) {
|
if (mp_obj_is_callable(MP_STATE_VM(trezorconfig_ui_wait_callback))) {
|
||||||
mp_obj_t args[3] = {0};
|
mp_obj_t args[3] = {0};
|
||||||
args[0] = mp_obj_new_int(wait);
|
args[0] = mp_obj_new_int(wait);
|
||||||
args[1] = mp_obj_new_int(progress);
|
args[1] = mp_obj_new_int(progress);
|
||||||
args[2] = mp_obj_new_str(message, strlen(message));
|
args[2] = mp_obj_new_str(message, strlen(message));
|
||||||
if (mp_call_function_n_kw(ui_wait_callback, 3, 0, args) == mp_const_true) {
|
if (mp_call_function_n_kw(MP_STATE_VM(trezorconfig_ui_wait_callback), 3, 0,
|
||||||
|
args) == mp_const_true) {
|
||||||
return sectrue;
|
return sectrue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,7 +55,7 @@ STATIC secbool wrapped_ui_wait_callback(uint32_t wait, uint32_t progress,
|
|||||||
/// """
|
/// """
|
||||||
STATIC mp_obj_t mod_trezorconfig_init(size_t n_args, const mp_obj_t *args) {
|
STATIC mp_obj_t mod_trezorconfig_init(size_t n_args, const mp_obj_t *args) {
|
||||||
if (n_args > 0) {
|
if (n_args > 0) {
|
||||||
ui_wait_callback = args[0];
|
MP_STATE_VM(trezorconfig_ui_wait_callback) = args[0];
|
||||||
storage_init(wrapped_ui_wait_callback, HW_ENTROPY_DATA, HW_ENTROPY_LEN);
|
storage_init(wrapped_ui_wait_callback, HW_ENTROPY_DATA, HW_ENTROPY_LEN);
|
||||||
} else {
|
} else {
|
||||||
storage_init(NULL, HW_ENTROPY_DATA, HW_ENTROPY_LEN);
|
storage_init(NULL, HW_ENTROPY_DATA, HW_ENTROPY_LEN);
|
||||||
|
@ -191,6 +191,9 @@ typedef long mp_off_t;
|
|||||||
#define free(p) m_free(p)
|
#define free(p) m_free(p)
|
||||||
#define realloc(p, n) m_realloc(p, n)
|
#define realloc(p, n) m_realloc(p, n)
|
||||||
|
|
||||||
|
#define MICROPY_PORT_ROOT_POINTERS \
|
||||||
|
mp_obj_t trezorconfig_ui_wait_callback; \
|
||||||
|
|
||||||
// We need to provide a declaration/definition of alloca()
|
// We need to provide a declaration/definition of alloca()
|
||||||
#include <alloca.h>
|
#include <alloca.h>
|
||||||
|
|
||||||
|
@ -258,6 +258,7 @@ void mp_unix_mark_exec(void);
|
|||||||
#define MICROPY_PORT_ROOT_POINTERS \
|
#define MICROPY_PORT_ROOT_POINTERS \
|
||||||
const char *readline_hist[50]; \
|
const char *readline_hist[50]; \
|
||||||
void *mmap_region_head; \
|
void *mmap_region_head; \
|
||||||
|
mp_obj_t trezorconfig_ui_wait_callback; \
|
||||||
|
|
||||||
// We need to provide a declaration/definition of alloca()
|
// We need to provide a declaration/definition of alloca()
|
||||||
// unless support for it is disabled.
|
// unless support for it is disabled.
|
||||||
|
Loading…
Reference in New Issue
Block a user