2018-02-23 18:04:46 +00:00
|
|
|
/*
|
2018-02-26 13:06:10 +00:00
|
|
|
* This file is part of the TREZOR project, https://trezor.io/
|
2018-02-23 18:04:46 +00:00
|
|
|
*
|
2018-02-26 13:06:10 +00:00
|
|
|
* Copyright (c) SatoshiLabs
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2018-02-23 18:04:46 +00:00
|
|
|
*/
|
|
|
|
|
2017-04-17 16:07:34 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2017-10-27 04:01:22 +00:00
|
|
|
#include <unistd.h>
|
2017-04-17 16:07:34 +00:00
|
|
|
|
|
|
|
#include "common.h"
|
2017-12-07 14:31:23 +00:00
|
|
|
#include "display.h"
|
2019-01-25 17:33:25 +00:00
|
|
|
#include "memzero.h"
|
2017-12-07 14:31:23 +00:00
|
|
|
|
|
|
|
void __shutdown(void)
|
|
|
|
{
|
|
|
|
printf("SHUTDOWN\n");
|
|
|
|
exit(3);
|
|
|
|
}
|
2017-04-17 16:07:34 +00:00
|
|
|
|
2017-12-17 00:09:45 +00:00
|
|
|
#define COLOR_FATAL_ERROR RGB16(0x7F, 0x00, 0x00)
|
|
|
|
|
2017-10-11 22:32:46 +00:00
|
|
|
void __attribute__((noreturn)) __fatal_error(const char *expr, const char *msg, const char *file, int line, const char *func)
|
|
|
|
{
|
2017-12-07 14:31:23 +00:00
|
|
|
display_orientation(0);
|
|
|
|
display_backlight(255);
|
2017-12-17 00:09:45 +00:00
|
|
|
display_print_color(COLOR_WHITE, COLOR_FATAL_ERROR);
|
2017-12-07 14:31:23 +00:00
|
|
|
display_printf("\nFATAL ERROR:\n");
|
2017-10-11 22:32:46 +00:00
|
|
|
printf("\nFATAL ERROR:\n");
|
|
|
|
if (expr) {
|
2017-12-07 14:31:23 +00:00
|
|
|
display_printf("expr: %s\n", expr);
|
2017-10-11 22:32:46 +00:00
|
|
|
printf("expr: %s\n", expr);
|
|
|
|
}
|
|
|
|
if (msg) {
|
2017-12-07 14:31:23 +00:00
|
|
|
display_printf("msg : %s\n", msg);
|
2017-10-11 22:32:46 +00:00
|
|
|
printf("msg : %s\n", msg);
|
|
|
|
}
|
2017-04-28 13:39:22 +00:00
|
|
|
if (file) {
|
2017-12-07 14:31:23 +00:00
|
|
|
display_printf("file: %s:%d\n", file, line);
|
2017-10-11 22:32:46 +00:00
|
|
|
printf("file: %s:%d\n", file, line);
|
2017-04-28 13:39:22 +00:00
|
|
|
}
|
|
|
|
if (func) {
|
2017-12-07 14:31:23 +00:00
|
|
|
display_printf("func: %s\n", func);
|
2017-10-11 22:32:46 +00:00
|
|
|
printf("func: %s\n", func);
|
2017-04-28 13:39:22 +00:00
|
|
|
}
|
2017-10-12 14:02:40 +00:00
|
|
|
#ifdef GITREV
|
2017-12-07 14:31:23 +00:00
|
|
|
display_printf("rev : %s\n", XSTR(GITREV));
|
2017-10-12 14:02:40 +00:00
|
|
|
printf("rev : %s\n", XSTR(GITREV));
|
|
|
|
#endif
|
2017-12-07 14:31:23 +00:00
|
|
|
hal_delay(3000);
|
|
|
|
__shutdown();
|
|
|
|
for (;;);
|
2017-04-17 16:07:34 +00:00
|
|
|
}
|
2017-10-27 04:01:22 +00:00
|
|
|
|
|
|
|
void hal_delay(uint32_t ms)
|
|
|
|
{
|
|
|
|
usleep(1000 * ms);
|
|
|
|
}
|
2019-01-25 17:33:25 +00:00
|
|
|
|
|
|
|
uint8_t HW_ENTROPY_DATA[HW_ENTROPY_LEN];
|
|
|
|
|
|
|
|
void collect_hw_entropy(void)
|
|
|
|
{
|
|
|
|
memzero(HW_ENTROPY_DATA, HW_ENTROPY_LEN);
|
|
|
|
}
|