Skip to content

Commit

Permalink
refactor(core): get rid of platform.h
Browse files Browse the repository at this point in the history
[no changelog]
  • Loading branch information
cepetr committed Oct 7, 2024
1 parent b43a9f1 commit 91c5ea3
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 71 deletions.
1 change: 0 additions & 1 deletion core/embed/boardloader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "image.h"
#include "model.h"
#include "mpu.h"
#include "platform.h"
#include "pvd.h"
#include "reset_flags.h"
#include "rng.h"
Expand Down
1 change: 0 additions & 1 deletion core/embed/bootloader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
#else
#include "compiler_traits.h"
#include "mpu.h"
#include "platform.h"
#endif

#define USB_IFACE_NUM 0
Expand Down
2 changes: 1 addition & 1 deletion core/embed/kernel/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "mpu.h"
#include "optiga_commands.h"
#include "optiga_transport.h"
#include "platform.h"
#include "option_bytes.h"
#include "pvd.h"
#include "random_delays.h"
#include "rsod.h"
Expand Down
14 changes: 14 additions & 0 deletions core/embed/trezorhal/bootutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,18 @@ void __attribute__((noreturn)) reboot_and_upgrade(const uint8_t hash[32]);
// unrecoverable error state.
void __attribute__((noreturn)) secure_shutdown(void);

// Alternative memset with slightly different arguments
//
// This function writes a 32-bit value to a range of memory addresses.
// The range is defined by the start and stop pointers and must
// be aligned to 4 bytes.
void memset_reg(volatile void *start, volatile void *stop, uint32_t val);

// Jumps to the next booting stage (e.g. bootloader to firmware).
// `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);

#endif // TREZORHAL_BOOTUTILS_H
2 changes: 2 additions & 0 deletions core/embed/trezorhal/option_bytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ void flash_unlock_option_bytes(void);
uint32_t flash_set_option_bytes(void);
secbool flash_configure_option_bytes(void);

void check_oem_keys(void);

#endif // KERNEL_MODE

#endif // TREZORHAL_OPTION_BYTES_H
3 changes: 2 additions & 1 deletion core/embed/trezorhal/stm32f4/bootutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "irq.h"
#include "model.h"
#include "mpu.h"
#include "platform.h"

#ifdef KERNEL_MODE

Expand Down Expand Up @@ -160,6 +159,8 @@ reboot_with_args(boot_command_t command, const void* args, size_t args_size) {

ensure_thread_mode();

// from util.s
extern void jump_to_with_flag(uint32_t address, uint32_t reset_flag);
jump_to_with_flag(BOOTLOADER_START + IMAGE_HEADER_SIZE, g_boot_command);
for (;;)
;
Expand Down
30 changes: 0 additions & 30 deletions core/embed/trezorhal/stm32f4/platform.h

This file was deleted.

4 changes: 2 additions & 2 deletions core/embed/trezorhal/stm32f4/startup_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/

#include STM32_HAL_H
#include TREZOR_BOARD

#include "startup_init.h"
#include "platform.h"
#include "bootutils.h"
#include "rng.h"
#include "systick.h"
#include TREZOR_BOARD

#ifdef KERNEL_MODE

Expand Down
1 change: 0 additions & 1 deletion core/embed/trezorhal/stm32f4/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include "bootutils.h"
#include "mpu.h"
#include "platform.h"
#include "systask.h"
#include "system.h"
#include "systick.h"
Expand Down
32 changes: 0 additions & 32 deletions core/embed/trezorhal/stm32u5/platform.h

This file was deleted.

3 changes: 1 addition & 2 deletions core/embed/trezorhal/stm32u5/startup_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include TREZOR_BOARD
#include STM32_HAL_H

#include "platform.h"
#include "rng.h"
#include TREZOR_BOARD

#ifdef KERNEL_MODE

Expand Down

0 comments on commit 91c5ea3

Please sign in to comment.