mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 23:48:12 +00:00
common: don't expose shutdown() via common.h
This commit is contained in:
parent
f88080b904
commit
38e3088325
@ -89,7 +89,7 @@ static void pin_fails_check_max(uint32_t ctr)
|
||||
break;
|
||||
}
|
||||
}
|
||||
shutdown();
|
||||
ensure(secfalse, "pin_fails_check_max");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,17 +45,16 @@ void display_init(void)
|
||||
printf("%s\n", SDL_GetError());
|
||||
ensure(secfalse, "SDL_Init error");
|
||||
}
|
||||
atexit(SDL_Quit);
|
||||
SDL_Window *win = SDL_CreateWindow("TREZOR", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, DISPLAY_RESX + 2 * DISPLAY_BORDER, DISPLAY_RESY + 2 * DISPLAY_BORDER, SDL_WINDOW_SHOWN);
|
||||
if (!win) {
|
||||
printf("%s\n", SDL_GetError());
|
||||
SDL_Quit();
|
||||
ensure(secfalse, "SDL_CreateWindow error");
|
||||
}
|
||||
RENDERER = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED);
|
||||
if (!RENDERER) {
|
||||
printf("%s\n", SDL_GetError());
|
||||
SDL_DestroyWindow(win);
|
||||
SDL_Quit();
|
||||
ensure(secfalse, "SDL_CreateRenderer error");
|
||||
}
|
||||
SDL_SetRenderDrawColor(RENDERER, DISPLAY_BACKLIGHT, DISPLAY_BACKLIGHT, DISPLAY_BACKLIGHT, 255);
|
||||
|
@ -27,7 +27,7 @@ enum { VCP_IFACE = 0x00 };
|
||||
static void vcp_intr(void)
|
||||
{
|
||||
display_clear();
|
||||
shutdown();
|
||||
ensure(secfalse, "vcp_intr");
|
||||
}
|
||||
|
||||
static void vcp_puts(const char *s, size_t len)
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include "display.h"
|
||||
#include "rng.h"
|
||||
|
||||
void shutdown(void);
|
||||
|
||||
void __attribute__((noreturn)) __fatal_error(const char *expr, const char *msg, const char *file, int line, const char *func) {
|
||||
display_orientation(0);
|
||||
display_backlight(255);
|
||||
|
@ -18,6 +18,5 @@ extern uint32_t __stack_chk_guard;
|
||||
|
||||
void memset_reg(volatile void *start, volatile void *stop, uint32_t val);
|
||||
void jump_to(uint32_t address);
|
||||
void shutdown(void);
|
||||
|
||||
#endif
|
||||
|
@ -3,36 +3,49 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "display.h"
|
||||
|
||||
void __shutdown(void)
|
||||
{
|
||||
printf("SHUTDOWN\n");
|
||||
exit(3);
|
||||
}
|
||||
|
||||
void __attribute__((noreturn)) __fatal_error(const char *expr, const char *msg, const char *file, int line, const char *func)
|
||||
{
|
||||
display_orientation(0);
|
||||
display_backlight(255);
|
||||
display_print_color(COLOR_WHITE, COLOR_RED128);
|
||||
display_printf("\nFATAL ERROR:\n");
|
||||
printf("\nFATAL ERROR:\n");
|
||||
if (expr) {
|
||||
display_printf("expr: %s\n", expr);
|
||||
printf("expr: %s\n", expr);
|
||||
}
|
||||
if (msg) {
|
||||
display_printf("msg : %s\n", msg);
|
||||
printf("msg : %s\n", msg);
|
||||
}
|
||||
if (file) {
|
||||
display_printf("file: %s:%d\n", file, line);
|
||||
printf("file: %s:%d\n", file, line);
|
||||
}
|
||||
if (func) {
|
||||
display_printf("func: %s\n", func);
|
||||
printf("func: %s\n", func);
|
||||
}
|
||||
#ifdef GITREV
|
||||
#define XSTR(s) STR(s)
|
||||
#define STR(s) #s
|
||||
display_printf("rev : %s\n", XSTR(GITREV));
|
||||
printf("rev : %s\n", XSTR(GITREV));
|
||||
#endif
|
||||
exit(1);
|
||||
hal_delay(3000);
|
||||
__shutdown();
|
||||
for (;;);
|
||||
}
|
||||
|
||||
void hal_delay(uint32_t ms)
|
||||
{
|
||||
usleep(1000 * ms);
|
||||
}
|
||||
|
||||
void shutdown(void)
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
|
@ -9,6 +9,4 @@ void __attribute__((noreturn)) __fatal_error(const char *expr, const char *msg,
|
||||
|
||||
void hal_delay(uint32_t ms);
|
||||
|
||||
void shutdown(void);
|
||||
|
||||
#endif
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include "options.h"
|
||||
#include "embed/trezorhal/touch.h"
|
||||
|
||||
void __shutdown(void);
|
||||
|
||||
uint32_t touch_read(void)
|
||||
{
|
||||
#ifndef TREZOR_NOUI
|
||||
@ -43,11 +45,11 @@ uint32_t touch_read(void)
|
||||
break;
|
||||
case SDL_KEYUP:
|
||||
if (event.key.keysym.sym == SDLK_ESCAPE) {
|
||||
exit(3);
|
||||
__shutdown();
|
||||
}
|
||||
break;
|
||||
case SDL_QUIT:
|
||||
exit(3);
|
||||
__shutdown();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user