mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 22:38:08 +00:00
refactor(core/embed): replace ensure(secfalse,... with error_shutdown
[no changelog]
This commit is contained in:
parent
0f1cac9695
commit
ba56ff8483
@ -136,9 +136,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorutils_memcpy_obj, 4, 5,
|
|||||||
STATIC mp_obj_t mod_trezorutils_halt(size_t n_args, const mp_obj_t *args) {
|
STATIC mp_obj_t mod_trezorutils_halt(size_t n_args, const mp_obj_t *args) {
|
||||||
mp_buffer_info_t msg = {0};
|
mp_buffer_info_t msg = {0};
|
||||||
if (n_args > 0 && mp_get_buffer(args[0], &msg, MP_BUFFER_READ)) {
|
if (n_args > 0 && mp_get_buffer(args[0], &msg, MP_BUFFER_READ)) {
|
||||||
ensure(secfalse, msg.buf);
|
error_shutdown(msg.buf);
|
||||||
} else {
|
} else {
|
||||||
ensure(secfalse, "halt");
|
error_shutdown("halt");
|
||||||
}
|
}
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ void check_and_replace_bootloader(void) {
|
|||||||
(new_bld_hdr->hw_model != 0)) {
|
(new_bld_hdr->hw_model != 0)) {
|
||||||
// reject non-model T bootloader
|
// reject non-model T bootloader
|
||||||
// 0 represents pre-model check bootloader
|
// 0 represents pre-model check bootloader
|
||||||
ensure(secfalse, "Incompatible embedded bootloader");
|
error_shutdown("Incompatible embedded bootloader");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// at this point, due to the previous check_image_model call, we know that the
|
// at this point, due to the previous check_image_model call, we know that the
|
||||||
@ -213,7 +213,7 @@ void check_and_replace_bootloader(void) {
|
|||||||
// against the firmware hw_model.
|
// against the firmware hw_model.
|
||||||
else if (board_name != HW_MODEL) {
|
else if (board_name != HW_MODEL) {
|
||||||
// reject incompatible bootloader
|
// reject incompatible bootloader
|
||||||
ensure(secfalse, "Incompatible embedded bootloader");
|
error_shutdown("Incompatible embedded bootloader");
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure(flash_area_erase(&BOOTLOADER_AREA, NULL), NULL);
|
ensure(flash_area_erase(&BOOTLOADER_AREA, NULL), NULL);
|
||||||
|
@ -79,7 +79,7 @@ static secbool startswith(const char *s, const char *prefix) {
|
|||||||
|
|
||||||
static void vcp_intr(void) {
|
static void vcp_intr(void) {
|
||||||
display_clear();
|
display_clear();
|
||||||
ensure(secfalse, "vcp_intr");
|
error_shutdown("vcp_intr");
|
||||||
}
|
}
|
||||||
|
|
||||||
static char vcp_getchar(void) {
|
static char vcp_getchar(void) {
|
||||||
|
@ -74,7 +74,7 @@ void i2c_init_instance(uint16_t idx, i2c_instance_t *instance) {
|
|||||||
i2c_handle[idx].Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
i2c_handle[idx].Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
||||||
|
|
||||||
if (HAL_OK != HAL_I2C_Init(&i2c_handle[idx])) {
|
if (HAL_OK != HAL_I2C_Init(&i2c_handle[idx])) {
|
||||||
ensure(secfalse, "I2C was not loaded properly.");
|
error_shutdown("I2C was not loaded properly.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ void i2c_init_instance(uint16_t idx, i2c_instance_t *instance) {
|
|||||||
i2c_handle[idx].Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
i2c_handle[idx].Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
||||||
|
|
||||||
if (HAL_OK != HAL_I2C_Init(&i2c_handle[idx])) {
|
if (HAL_OK != HAL_I2C_Init(&i2c_handle[idx])) {
|
||||||
ensure(secfalse, "I2C was not loaded properly.");
|
error_shutdown("I2C was not loaded properly.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ void display_deinit(void) {
|
|||||||
void display_init(void) {
|
void display_init(void) {
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||||
printf("%s\n", SDL_GetError());
|
printf("%s\n", SDL_GetError());
|
||||||
ensure(secfalse, "SDL_Init error");
|
error_shutdown("SDL_Init error");
|
||||||
}
|
}
|
||||||
atexit(display_deinit);
|
atexit(display_deinit);
|
||||||
|
|
||||||
@ -143,13 +143,13 @@ void display_init(void) {
|
|||||||
free(window_title_alloc);
|
free(window_title_alloc);
|
||||||
if (!WINDOW) {
|
if (!WINDOW) {
|
||||||
printf("%s\n", SDL_GetError());
|
printf("%s\n", SDL_GetError());
|
||||||
ensure(secfalse, "SDL_CreateWindow error");
|
error_shutdown("SDL_CreateWindow error");
|
||||||
}
|
}
|
||||||
RENDERER = SDL_CreateRenderer(WINDOW, -1, SDL_RENDERER_SOFTWARE);
|
RENDERER = SDL_CreateRenderer(WINDOW, -1, SDL_RENDERER_SOFTWARE);
|
||||||
if (!RENDERER) {
|
if (!RENDERER) {
|
||||||
printf("%s\n", SDL_GetError());
|
printf("%s\n", SDL_GetError());
|
||||||
SDL_DestroyWindow(WINDOW);
|
SDL_DestroyWindow(WINDOW);
|
||||||
ensure(secfalse, "SDL_CreateRenderer error");
|
error_shutdown("SDL_CreateRenderer error");
|
||||||
}
|
}
|
||||||
SDL_SetRenderDrawColor(RENDERER, 0, 0, 0, 255);
|
SDL_SetRenderDrawColor(RENDERER, 0, 0, 0, 255);
|
||||||
SDL_RenderClear(RENDERER);
|
SDL_RenderClear(RENDERER);
|
||||||
|
@ -83,7 +83,7 @@ void display_init(void) {
|
|||||||
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||||
printf("%s\n", SDL_GetError());
|
printf("%s\n", SDL_GetError());
|
||||||
ensure(secfalse, "SDL_Init error");
|
error_shutdown("SDL_Init error");
|
||||||
}
|
}
|
||||||
atexit(display_deinit);
|
atexit(display_deinit);
|
||||||
|
|
||||||
@ -108,13 +108,13 @@ void display_init(void) {
|
|||||||
free(window_title_alloc);
|
free(window_title_alloc);
|
||||||
if (!drv->window) {
|
if (!drv->window) {
|
||||||
printf("%s\n", SDL_GetError());
|
printf("%s\n", SDL_GetError());
|
||||||
ensure(secfalse, "SDL_CreateWindow error");
|
error_shutdown("SDL_CreateWindow error");
|
||||||
}
|
}
|
||||||
drv->renderer = SDL_CreateRenderer(drv->window, -1, SDL_RENDERER_SOFTWARE);
|
drv->renderer = SDL_CreateRenderer(drv->window, -1, SDL_RENDERER_SOFTWARE);
|
||||||
if (!drv->renderer) {
|
if (!drv->renderer) {
|
||||||
printf("%s\n", SDL_GetError());
|
printf("%s\n", SDL_GetError());
|
||||||
SDL_DestroyWindow(drv->window);
|
SDL_DestroyWindow(drv->window);
|
||||||
ensure(secfalse, "SDL_CreateRenderer error");
|
error_shutdown("SDL_CreateRenderer error");
|
||||||
}
|
}
|
||||||
SDL_SetRenderDrawColor(drv->renderer, 0, 0, 0, 255);
|
SDL_SetRenderDrawColor(drv->renderer, 0, 0, 0, 255);
|
||||||
SDL_RenderClear(drv->renderer);
|
SDL_RenderClear(drv->renderer);
|
||||||
|
Loading…
Reference in New Issue
Block a user