mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-07 13:12:41 +00:00
refactor(core): rename jump_to function
[no changelog]
This commit is contained in:
parent
2ecf335349
commit
bdb3d486e3
@ -323,7 +323,7 @@ int main(void) {
|
|||||||
system_deinit();
|
system_deinit();
|
||||||
|
|
||||||
// g_boot_command is preserved on STM32U5
|
// 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <io/display.h>
|
#include <io/display.h>
|
||||||
#include <sys/bootargs.h>
|
#include <sys/bootargs.h>
|
||||||
|
#include <sys/bootutils.h>
|
||||||
#include <sys/systick.h>
|
#include <sys/systick.h>
|
||||||
#include <util/flash.h>
|
#include <util/flash.h>
|
||||||
#include <util/flash_otp.h>
|
#include <util/flash_otp.h>
|
||||||
@ -111,7 +112,7 @@ static int sdl_event_filter(void *userdata, SDL_Event *event) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((noreturn)) int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
SDL_SetEventFilter(sdl_event_filter, NULL);
|
SDL_SetEventFilter(sdl_event_filter, NULL);
|
||||||
|
|
||||||
display_init(DISPLAY_RESET_CONTENT);
|
display_init(DISPLAY_RESET_CONTENT);
|
||||||
@ -189,10 +190,12 @@ __attribute__((noreturn)) int main(int argc, char **argv) {
|
|||||||
|
|
||||||
bootloader_main();
|
bootloader_main();
|
||||||
hal_delay(3000);
|
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 =
|
bool storage_is_erased =
|
||||||
storage_empty(&STORAGE_AREAS[0]) && storage_empty(&STORAGE_AREAS[1]);
|
storage_empty(&STORAGE_AREAS[0]) && storage_empty(&STORAGE_AREAS[1]);
|
||||||
|
|
||||||
|
@ -7,6 +7,4 @@
|
|||||||
|
|
||||||
extern uint8_t *FIRMWARE_START;
|
extern uint8_t *FIRMWARE_START;
|
||||||
|
|
||||||
__attribute__((noreturn)) void jump_to(uint32_t address);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -382,7 +382,8 @@ void real_jump_to_firmware(void) {
|
|||||||
|
|
||||||
system_deinit();
|
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
|
#ifdef USE_RESET_TO_BOOT
|
||||||
|
@ -276,7 +276,8 @@ int main(void) {
|
|||||||
|
|
||||||
system_deinit();
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -46,11 +46,11 @@ void __attribute__((noreturn)) reboot_and_upgrade(const uint8_t hash[32]);
|
|||||||
void __attribute__((noreturn)) secure_shutdown(void);
|
void __attribute__((noreturn)) secure_shutdown(void);
|
||||||
|
|
||||||
// Jumps to the next booting stage (e.g. bootloader to firmware).
|
// 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
|
// Before jumping, the function disables all interrupts and clears the
|
||||||
// memory and registers that could contain sensitive information.
|
// 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
|
// Ensure compatible hardware settings before jumping to
|
||||||
// the different booting stage. This function is used to
|
// the different booting stage. This function is used to
|
||||||
|
@ -19,9 +19,9 @@ memset_reg:
|
|||||||
.L_loop_end:
|
.L_loop_end:
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global jump_to
|
.global jump_to_next_stage
|
||||||
.type jump_to, STT_FUNC
|
.type jump_to_next_stage, STT_FUNC
|
||||||
jump_to:
|
jump_to_next_stage:
|
||||||
mov r4, r0 // save input argument r0 (the address of the next stage's vector table) (r4 is callee save)
|
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
|
// this subroutine re-points the exception handlers before the C code
|
||||||
// that comprises them has been given a good environment to run.
|
// that comprises them has been given a good environment to run.
|
||||||
|
@ -23,9 +23,9 @@ memset_reg:
|
|||||||
|
|
||||||
// Jump to address given in first argument R0 that points to next's stage's VTOR
|
// Jump to address given in first argument R0 that points to next's stage's VTOR
|
||||||
// Clear memory and all registers before jump
|
// Clear memory and all registers before jump
|
||||||
.global jump_to
|
.global jump_to_next_stage
|
||||||
.type jump_to, STT_FUNC
|
.type jump_to_next_stage, STT_FUNC
|
||||||
jump_to:
|
jump_to_next_stage:
|
||||||
ldr r1, =0
|
ldr r1, =0
|
||||||
bl jump_to_with_flag
|
bl jump_to_with_flag
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ memset_reg:
|
|||||||
|
|
||||||
// Jump to address given in first argument R0 that points to next's stage's VTOR
|
// Jump to address given in first argument R0 that points to next's stage's VTOR
|
||||||
// Clear memory and all registers before jump
|
// Clear memory and all registers before jump
|
||||||
.global jump_to
|
.global jump_to_next_stage
|
||||||
.type jump_to, STT_FUNC
|
.type jump_to_next_stage, STT_FUNC
|
||||||
jump_to:
|
jump_to_next_stage:
|
||||||
mov r4, r0 // save input argument r0 (the address of the next stage's vector table) (r4 is callee save)
|
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
|
// this subroutine re-points the exception handlers before the C code
|
||||||
// that comprises them has been given a good environment to run.
|
// that comprises them has been given a good environment to run.
|
||||||
|
@ -23,9 +23,9 @@ memset_reg:
|
|||||||
|
|
||||||
// Jump to address given in first argument R0 that points to next's stage's VTOR
|
// Jump to address given in first argument R0 that points to next's stage's VTOR
|
||||||
// Clear memory and all registers before jump
|
// Clear memory and all registers before jump
|
||||||
.global jump_to
|
.global jump_to_next_stage
|
||||||
.type jump_to, STT_FUNC
|
.type jump_to_next_stage, STT_FUNC
|
||||||
jump_to:
|
jump_to_next_stage:
|
||||||
mov r4, r0 // save input argument r0 (the address of the next stage's vector table) (r4 is callee save)
|
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
|
// this subroutine re-points the exception handlers before the C code
|
||||||
// that comprises them has been given a good environment to run.
|
// that comprises them has been given a good environment to run.
|
||||||
|
Loading…
Reference in New Issue
Block a user