1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 22:38:08 +00:00

util: use shutdown from trezor-core instead of system_halt

This commit is contained in:
Pavol Rusnak 2018-03-19 15:44:41 +01:00
parent 9588e8f273
commit 95dd254094
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
5 changed files with 27 additions and 10 deletions

View File

@ -46,7 +46,7 @@ void layoutFirmwareHash(const uint8_t *hash)
void show_halt(void) void show_halt(void)
{ {
layoutDialog(&bmp_icon_error, NULL, NULL, NULL, "Unofficial firmware", "aborted.", NULL, "Unplug your TREZOR", "contact our support.", NULL); layoutDialog(&bmp_icon_error, NULL, NULL, NULL, "Unofficial firmware", "aborted.", NULL, "Unplug your TREZOR", "contact our support.", NULL);
system_halt(); shutdown();
} }
void show_unofficial_warning(const uint8_t *hash) void show_unofficial_warning(const uint8_t *hash)

View File

@ -130,7 +130,7 @@ static char CONFIDENTIAL sessionPassphrase[51];
void storage_show_error(void) void storage_show_error(void)
{ {
layoutDialog(&bmp_icon_error, NULL, NULL, NULL, _("Storage failure"), _("detected."), NULL, _("Please unplug"), _("the device."), NULL); layoutDialog(&bmp_icon_error, NULL, NULL, NULL, _("Storage failure"), _("detected."), NULL, _("Please unplug"), _("the device."), NULL);
system_halt(); shutdown();
} }
void storage_check_flash_errors(void) void storage_check_flash_errors(void)

View File

@ -36,4 +36,28 @@ reset_handler:
// loop forever if the application code returns // loop forever if the application code returns
b . b .
.global shutdown
.type shutdown, STT_FUNC
shutdown:
cpsid f
ldr r0, =0
mov r1, r0
mov r2, r0
mov r3, r0
mov r4, r0
mov r5, r0
mov r6, r0
mov r7, r0
mov r8, r0
mov r9, r0
mov r10, r0
mov r11, r0
mov r12, r0
ldr lr, =0xffffffff
ldr r0, =_ram_start
ldr r1, =_ram_end
// set to value in r2
bl memset_reg
b . // loop forever
.end .end

5
util.c
View File

@ -66,8 +66,3 @@ uint32_t readprotobufint(uint8_t **ptr)
(*ptr)++; (*ptr)++;
return result; return result;
} }
void __attribute__((noreturn)) system_halt(void)
{
for (;;) {} // loop forever
}

4
util.h
View File

@ -43,15 +43,13 @@ void data2hex(const void *data, uint32_t len, char *str);
// read protobuf integer and advance pointer // read protobuf integer and advance pointer
uint32_t readprotobufint(uint8_t **ptr); uint32_t readprotobufint(uint8_t **ptr);
// halt execution (or do an endless loop)
void __attribute__((noreturn)) system_halt(void);
#if !EMULATOR #if !EMULATOR
// defined in memory.ld // defined in memory.ld
extern uint8_t _ram_start[], _ram_end[]; extern uint8_t _ram_start[], _ram_end[];
// defined in startup.s // defined in startup.s
extern void memset_reg(void *start, void *stop, uint32_t val); extern void memset_reg(void *start, void *stop, uint32_t val);
extern void __attribute__((noreturn)) shutdown(void);
#define FW_SIGNED 0x5A3CA5C3 #define FW_SIGNED 0x5A3CA5C3
#define FW_UNTRUSTED 0x00000000 #define FW_UNTRUSTED 0x00000000