From c30233b83231b656507c450167f2cdd2fb424b6f Mon Sep 17 00:00:00 2001 From: cepetr Date: Wed, 29 Jan 2025 21:34:20 +0100 Subject: [PATCH] refactor(core): stop using shutdown_privileged directly [no changelog] --- core/embed/sec/random_delays/stm32/random_delays.c | 7 ++----- core/embed/sys/pvd/stm32/pvd.c | 4 +--- core/embed/sys/startup/stm32f4/startup_stage_0.s | 2 +- core/embed/sys/startup/stm32f4/startup_stage_1.s | 2 +- core/embed/sys/startup/stm32f4/startup_stage_2.s | 2 +- core/embed/sys/startup/stm32f4/vectortable.S | 2 +- core/embed/sys/startup/stm32u5/startup_stage_0.s | 2 +- core/embed/sys/startup/stm32u5/startup_stage_1.s | 2 +- core/embed/sys/startup/stm32u5/startup_stage_2.s | 2 +- core/embed/sys/startup/stm32u5/vectortable.S | 2 +- core/embed/sys/task/stm32/systask.c | 2 ++ 11 files changed, 13 insertions(+), 16 deletions(-) diff --git a/core/embed/sec/random_delays/stm32/random_delays.c b/core/embed/sec/random_delays/stm32/random_delays.c index 1078a458e6..79790b7fcc 100644 --- a/core/embed/sec/random_delays/stm32/random_delays.c +++ b/core/embed/sec/random_delays/stm32/random_delays.c @@ -29,9 +29,6 @@ #ifdef KERNEL_MODE -// from util.s -extern void shutdown_privileged(void); - #define DRBG_RESEED_INTERVAL_CALLS 1000 #define DRBG_TRNG_ENTROPY_LENGTH 50 _Static_assert(CHACHA_DRBG_OPTIMAL_RESEED_LENGTH(1) == DRBG_TRNG_ENTROPY_LENGTH, @@ -192,14 +189,14 @@ void wait_random(void) { volatile int j = wait; while (i < wait) { if (i + j != wait) { - shutdown_privileged(); + error_shutdown("(glitch)"); } ++i; --j; } // Double-check loop completion. if (i != wait || j != 0) { - shutdown_privileged(); + error_shutdown("(glitch)"); } #endif } diff --git a/core/embed/sys/pvd/stm32/pvd.c b/core/embed/sys/pvd/stm32/pvd.c index cd94df5321..bc6581a88e 100644 --- a/core/embed/sys/pvd/stm32/pvd.c +++ b/core/embed/sys/pvd/stm32/pvd.c @@ -56,9 +56,7 @@ void PVD_IRQHandler(void) { // Turn off display backlight BACKLIGHT_PWM_TIM->BACKLIGHT_PWM_TIM_CCR = 0; #endif - // from util.s - extern void shutdown_privileged(void); - shutdown_privileged(); + error_shutdown("PVD IRQ"); } #endif // defined(KERNEL_MODE) && defined(USE_PVD) diff --git a/core/embed/sys/startup/stm32f4/startup_stage_0.s b/core/embed/sys/startup/stm32f4/startup_stage_0.s index cbb9e921d4..5659f009f3 100644 --- a/core/embed/sys/startup/stm32f4/startup_stage_0.s +++ b/core/embed/sys/startup/stm32f4/startup_stage_0.s @@ -56,6 +56,6 @@ reset_handler: // enter the application code bl main - b shutdown_privileged + b system_exit .end diff --git a/core/embed/sys/startup/stm32f4/startup_stage_1.s b/core/embed/sys/startup/stm32f4/startup_stage_1.s index 72a4cc8fab..fba58a7025 100644 --- a/core/embed/sys/startup/stm32f4/startup_stage_1.s +++ b/core/embed/sys/startup/stm32f4/startup_stage_1.s @@ -39,7 +39,7 @@ reset_handler: // enter the application code bl main - b shutdown_privileged + b system_exit .end diff --git a/core/embed/sys/startup/stm32f4/startup_stage_2.s b/core/embed/sys/startup/stm32f4/startup_stage_2.s index e08f0de48c..8a275704ed 100644 --- a/core/embed/sys/startup/stm32f4/startup_stage_2.s +++ b/core/embed/sys/startup/stm32f4/startup_stage_2.s @@ -34,6 +34,6 @@ reset_handler: // enter the application code bl main - b shutdown_privileged + b system_exit .end diff --git a/core/embed/sys/startup/stm32f4/vectortable.S b/core/embed/sys/startup/stm32f4/vectortable.S index 2f07d34fd1..89f5dcb7b0 100644 --- a/core/embed/sys/startup/stm32f4/vectortable.S +++ b/core/embed/sys/startup/stm32f4/vectortable.S @@ -7,7 +7,7 @@ .global default_handler .type default_handler, STT_FUNC default_handler: - b shutdown_privileged + b Default_IRQHandler .macro add_handler symbol_name:req .word \symbol_name diff --git a/core/embed/sys/startup/stm32u5/startup_stage_0.s b/core/embed/sys/startup/stm32u5/startup_stage_0.s index e237fe57e9..8473911bdc 100644 --- a/core/embed/sys/startup/stm32u5/startup_stage_0.s +++ b/core/embed/sys/startup/stm32u5/startup_stage_0.s @@ -74,6 +74,6 @@ clear_ram: // enter the application code bl main - b shutdown_privileged + b system_exit .end diff --git a/core/embed/sys/startup/stm32u5/startup_stage_1.s b/core/embed/sys/startup/stm32u5/startup_stage_1.s index 53ba794d39..b1a785a8a5 100644 --- a/core/embed/sys/startup/stm32u5/startup_stage_1.s +++ b/core/embed/sys/startup/stm32u5/startup_stage_1.s @@ -57,6 +57,6 @@ reset_handler: // enter the application code bl main - b shutdown_privileged + b system_exit .end diff --git a/core/embed/sys/startup/stm32u5/startup_stage_2.s b/core/embed/sys/startup/stm32u5/startup_stage_2.s index 7813166f8c..2130afe463 100644 --- a/core/embed/sys/startup/stm32u5/startup_stage_2.s +++ b/core/embed/sys/startup/stm32u5/startup_stage_2.s @@ -48,6 +48,6 @@ reset_handler: // enter the application code bl main - b shutdown_privileged + b system_exit .end diff --git a/core/embed/sys/startup/stm32u5/vectortable.S b/core/embed/sys/startup/stm32u5/vectortable.S index d4f79d1950..497ed72b8f 100644 --- a/core/embed/sys/startup/stm32u5/vectortable.S +++ b/core/embed/sys/startup/stm32u5/vectortable.S @@ -7,7 +7,7 @@ .global default_handler .type default_handler, STT_FUNC default_handler: - b shutdown_privileged + b Default_IRQHandler .macro add_handler symbol_name:req .word \symbol_name diff --git a/core/embed/sys/task/stm32/systask.c b/core/embed/sys/task/stm32/systask.c index a6bb7a0bf8..12d0ec699e 100644 --- a/core/embed/sys/task/stm32/systask.c +++ b/core/embed/sys/task/stm32/systask.c @@ -635,4 +635,6 @@ void NMI_Handler(void) { mpu_restore(mpu_mode); } +void Default_IRQHandler(void) { error_shutdown("Unhandled IRQ"); } + #endif // KERNEL_MODE