mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-21 21:00:58 +00:00
trezor.utils: add halt function
This commit is contained in:
parent
f615e5f97f
commit
533aebdf6d
@ -8,6 +8,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "py/nlr.h"
|
#include "py/nlr.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
@ -55,9 +56,28 @@ STATIC mp_obj_t mod_TrezorUtils_memcpy(size_t n_args, const mp_obj_t *args) {
|
|||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUtils_memcpy_obj, 5, 5, mod_TrezorUtils_memcpy);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUtils_memcpy_obj, 5, 5, mod_TrezorUtils_memcpy);
|
||||||
|
|
||||||
|
/// def trezor.utils.halt(msg: str=None) -> None:
|
||||||
|
/// '''
|
||||||
|
/// Halts execution
|
||||||
|
/// '''
|
||||||
|
STATIC mp_obj_t mod_TrezorUtils_halt(size_t n_args, const mp_obj_t *args) {
|
||||||
|
// TODO: is this the best we can do?
|
||||||
|
#if defined STM32_HAL_H
|
||||||
|
// loop forever
|
||||||
|
for (;;) {}
|
||||||
|
#elif defined UNIX
|
||||||
|
exit(1);
|
||||||
|
#else
|
||||||
|
#error Unsupported port. Only STMHAL and UNIX ports are supported.
|
||||||
|
#endif
|
||||||
|
return mp_const_none;
|
||||||
|
}
|
||||||
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUtils_halt_obj, 0, 1, mod_TrezorUtils_halt);
|
||||||
|
|
||||||
STATIC const mp_rom_map_elem_t mp_module_TrezorUtils_globals_table[] = {
|
STATIC const mp_rom_map_elem_t mp_module_TrezorUtils_globals_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_TrezorUtils) },
|
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_TrezorUtils) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_memcpy), MP_ROM_PTR(&mod_TrezorUtils_memcpy_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_memcpy), MP_ROM_PTR(&mod_TrezorUtils_memcpy_obj) },
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_halt), MP_ROM_PTR(&mod_TrezorUtils_halt_obj) },
|
||||||
};
|
};
|
||||||
|
|
||||||
STATIC MP_DEFINE_CONST_DICT(mp_module_TrezorUtils_globals, mp_module_TrezorUtils_globals_table);
|
STATIC MP_DEFINE_CONST_DICT(mp_module_TrezorUtils_globals, mp_module_TrezorUtils_globals_table);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import sys
|
import sys
|
||||||
import gc
|
import gc
|
||||||
|
|
||||||
from TrezorUtils import memcpy
|
from TrezorUtils import halt, memcpy
|
||||||
from trezor import log
|
from trezor import log
|
||||||
|
|
||||||
type_gen = type((lambda: (yield))())
|
type_gen = type((lambda: (yield))())
|
||||||
|
Loading…
Reference in New Issue
Block a user