From bdb3d486e34131d1964b24bdead40122f63b3e88 Mon Sep 17 00:00:00 2001 From: cepetr Date: Wed, 29 Jan 2025 21:34:20 +0100 Subject: [PATCH] refactor(core): rename jump_to function [no changelog] --- core/embed/projects/boardloader/main.c | 2 +- core/embed/projects/bootloader/emulator.c | 9 ++++++--- core/embed/projects/bootloader/emulator.h | 2 -- core/embed/projects/bootloader/main.c | 3 ++- core/embed/projects/bootloader_ci/main.c | 3 ++- core/embed/sys/startup/inc/sys/bootutils.h | 4 ++-- core/embed/sys/startup/stm32f4/limited_util.S | 6 +++--- core/embed/sys/startup/stm32f4/util.S | 6 +++--- core/embed/sys/startup/stm32u5/limited_util.S | 6 +++--- core/embed/sys/startup/stm32u5/util.S | 6 +++--- 10 files changed, 25 insertions(+), 22 deletions(-) diff --git a/core/embed/projects/boardloader/main.c b/core/embed/projects/boardloader/main.c index 2eab5d052f..38c8750950 100644 --- a/core/embed/projects/boardloader/main.c +++ b/core/embed/projects/boardloader/main.c @@ -323,7 +323,7 @@ int main(void) { system_deinit(); // g_boot_command is preserved on STM32U5 - jump_to(IMAGE_CODE_ALIGN(BOOTLOADER_START + IMAGE_HEADER_SIZE)); + jump_to_next_stage(IMAGE_CODE_ALIGN(BOOTLOADER_START + IMAGE_HEADER_SIZE)); return 0; } diff --git a/core/embed/projects/bootloader/emulator.c b/core/embed/projects/bootloader/emulator.c index b2bd30a452..8f46770f5a 100644 --- a/core/embed/projects/bootloader/emulator.c +++ b/core/embed/projects/bootloader/emulator.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -111,7 +112,7 @@ static int sdl_event_filter(void *userdata, SDL_Event *event) { return 1; } -__attribute__((noreturn)) int main(int argc, char **argv) { +int main(int argc, char **argv) { SDL_SetEventFilter(sdl_event_filter, NULL); display_init(DISPLAY_RESET_CONTENT); @@ -189,10 +190,12 @@ __attribute__((noreturn)) int main(int argc, char **argv) { bootloader_main(); hal_delay(3000); - jump_to(0); + jump_to_next_stage(0); + + return 0; } -void jump_to(uint32_t address) { +void jump_to_next_stage(uint32_t address) { bool storage_is_erased = storage_empty(&STORAGE_AREAS[0]) && storage_empty(&STORAGE_AREAS[1]); diff --git a/core/embed/projects/bootloader/emulator.h b/core/embed/projects/bootloader/emulator.h index aa90a93f82..721490e912 100644 --- a/core/embed/projects/bootloader/emulator.h +++ b/core/embed/projects/bootloader/emulator.h @@ -7,6 +7,4 @@ extern uint8_t *FIRMWARE_START; -__attribute__((noreturn)) void jump_to(uint32_t address); - #endif diff --git a/core/embed/projects/bootloader/main.c b/core/embed/projects/bootloader/main.c index 6878e926c4..9c6eb465b5 100644 --- a/core/embed/projects/bootloader/main.c +++ b/core/embed/projects/bootloader/main.c @@ -382,7 +382,8 @@ void real_jump_to_firmware(void) { system_deinit(); - jump_to(IMAGE_CODE_ALIGN(FIRMWARE_START + vhdr.hdrlen + IMAGE_HEADER_SIZE)); + jump_to_next_stage( + IMAGE_CODE_ALIGN(FIRMWARE_START + vhdr.hdrlen + IMAGE_HEADER_SIZE)); } #ifdef USE_RESET_TO_BOOT diff --git a/core/embed/projects/bootloader_ci/main.c b/core/embed/projects/bootloader_ci/main.c index cc790e4ff3..634ee0864a 100644 --- a/core/embed/projects/bootloader_ci/main.c +++ b/core/embed/projects/bootloader_ci/main.c @@ -276,7 +276,8 @@ int main(void) { system_deinit(); - jump_to(IMAGE_CODE_ALIGN(FIRMWARE_START + vhdr.hdrlen + IMAGE_HEADER_SIZE)); + jump_to_next_stage( + IMAGE_CODE_ALIGN(FIRMWARE_START + vhdr.hdrlen + IMAGE_HEADER_SIZE)); return 0; } diff --git a/core/embed/sys/startup/inc/sys/bootutils.h b/core/embed/sys/startup/inc/sys/bootutils.h index 25cde30bae..53409dfc87 100644 --- a/core/embed/sys/startup/inc/sys/bootutils.h +++ b/core/embed/sys/startup/inc/sys/bootutils.h @@ -46,11 +46,11 @@ void __attribute__((noreturn)) reboot_and_upgrade(const uint8_t hash[32]); void __attribute__((noreturn)) secure_shutdown(void); // Jumps to the next booting stage (e.g. bootloader to firmware). -// `address` points to the flash at the vector table of the next stage. +// `vectbl_address` points to the flash at the vector table of the next stage. // // Before jumping, the function disables all interrupts and clears the // memory and registers that could contain sensitive information. -void jump_to(uint32_t address); +void jump_to_next_stage(uint32_t vectbl_address); // Ensure compatible hardware settings before jumping to // the different booting stage. This function is used to diff --git a/core/embed/sys/startup/stm32f4/limited_util.S b/core/embed/sys/startup/stm32f4/limited_util.S index ba510710b0..ef599f1a7d 100644 --- a/core/embed/sys/startup/stm32f4/limited_util.S +++ b/core/embed/sys/startup/stm32f4/limited_util.S @@ -19,9 +19,9 @@ memset_reg: .L_loop_end: bx lr - .global jump_to - .type jump_to, STT_FUNC -jump_to: + .global jump_to_next_stage + .type jump_to_next_stage, STT_FUNC +jump_to_next_stage: mov r4, r0 // save input argument r0 (the address of the next stage's vector table) (r4 is callee save) // this subroutine re-points the exception handlers before the C code // that comprises them has been given a good environment to run. diff --git a/core/embed/sys/startup/stm32f4/util.S b/core/embed/sys/startup/stm32f4/util.S index b01f5ee1a0..893e949238 100644 --- a/core/embed/sys/startup/stm32f4/util.S +++ b/core/embed/sys/startup/stm32f4/util.S @@ -23,9 +23,9 @@ memset_reg: // Jump to address given in first argument R0 that points to next's stage's VTOR // Clear memory and all registers before jump - .global jump_to - .type jump_to, STT_FUNC -jump_to: + .global jump_to_next_stage + .type jump_to_next_stage, STT_FUNC +jump_to_next_stage: ldr r1, =0 bl jump_to_with_flag diff --git a/core/embed/sys/startup/stm32u5/limited_util.S b/core/embed/sys/startup/stm32u5/limited_util.S index 0c7cc3c2ef..7e7e218cf5 100644 --- a/core/embed/sys/startup/stm32u5/limited_util.S +++ b/core/embed/sys/startup/stm32u5/limited_util.S @@ -21,9 +21,9 @@ memset_reg: // Jump to address given in first argument R0 that points to next's stage's VTOR // Clear memory and all registers before jump - .global jump_to - .type jump_to, STT_FUNC -jump_to: + .global jump_to_next_stage + .type jump_to_next_stage, STT_FUNC +jump_to_next_stage: mov r4, r0 // save input argument r0 (the address of the next stage's vector table) (r4 is callee save) // this subroutine re-points the exception handlers before the C code // that comprises them has been given a good environment to run. diff --git a/core/embed/sys/startup/stm32u5/util.S b/core/embed/sys/startup/stm32u5/util.S index 65fe4f94d0..b76c86430f 100644 --- a/core/embed/sys/startup/stm32u5/util.S +++ b/core/embed/sys/startup/stm32u5/util.S @@ -23,9 +23,9 @@ memset_reg: // Jump to address given in first argument R0 that points to next's stage's VTOR // Clear memory and all registers before jump - .global jump_to - .type jump_to, STT_FUNC -jump_to: + .global jump_to_next_stage + .type jump_to_next_stage, STT_FUNC +jump_to_next_stage: mov r4, r0 // save input argument r0 (the address of the next stage's vector table) (r4 is callee save) // this subroutine re-points the exception handlers before the C code // that comprises them has been given a good environment to run.