Skip to content

Commit

Permalink
refactor(core): rename jump_to function
Browse files Browse the repository at this point in the history
[no changelog]
  • Loading branch information
cepetr committed Jan 14, 2025
1 parent 774eff0 commit c612cd6
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/embed/projects/boardloader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,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;
}
9 changes: 6 additions & 3 deletions core/embed/projects/bootloader/emulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <io/display.h>
#include <sys/bootargs.h>
#include <sys/bootutils.h>
#include <sys/systick.h>
#include <util/flash.h>
#include <util/flash_otp.h>
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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]);

Expand Down
2 changes: 0 additions & 2 deletions core/embed/projects/bootloader/emulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@

extern uint8_t *FIRMWARE_START;

__attribute__((noreturn)) void jump_to(uint32_t address);

#endif
3 changes: 2 additions & 1 deletion core/embed/projects/bootloader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,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
Expand Down
3 changes: 2 additions & 1 deletion core/embed/projects/bootloader_ci/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 2 additions & 2 deletions core/embed/sys/startup/inc/sys/bootutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c612cd6

Please sign in to comment.