1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 06:18:07 +00:00

refactor(core): get rid of platform.h

[no changelog]
This commit is contained in:
cepetr 2024-10-04 14:28:34 +02:00 committed by cepetr
parent 5fd1f0e4c6
commit 0fa2cf70cd
13 changed files with 32 additions and 72 deletions

View File

@ -19,6 +19,7 @@
#include <string.h>
#include STM32_HAL_H
#include TREZOR_BOARD
#include "board_capabilities.h"
#include "bootutils.h"
@ -32,7 +33,6 @@
#include "image.h"
#include "model.h"
#include "mpu.h"
#include "platform.h"
#include "pvd.h"
#include "reset_flags.h"
#include "rng.h"

View File

@ -30,6 +30,7 @@
#include "flash_utils.h"
#include "image.h"
#include "messages.pb.h"
#include "mpu.h"
#include "option_bytes.h"
#include "pvd.h"
#include "random_delays.h"
@ -84,8 +85,7 @@
#include "emulator.h"
#else
#include "compiler_traits.h"
#include "mpu.h"
#include "platform.h"
#include STM32_HAL_H
#endif
#define USB_IFACE_NUM 0

View File

@ -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"

View File

@ -33,6 +33,7 @@
#include "secret.h"
#include "sha2.h"
#include STM32_HAL_H
#include TREZOR_BOARD
#ifdef STM32U5

View File

@ -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

View File

@ -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

View File

@ -17,6 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include STM32_HAL_H
#include <string.h>
#include "bootargs.h"
@ -27,7 +29,6 @@
#include "irq.h"
#include "model.h"
#include "mpu.h"
#include "platform.h"
#ifdef KERNEL_MODE
@ -160,6 +161,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 (;;)
;

View File

@ -17,6 +17,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TREZOR_EMULATOR
#include STM32_HAL_H
#endif
#include <string.h>
#include "blake2s.h"

View File

@ -1,30 +0,0 @@
/*
* This file is part of the Trezor project, https://trezor.io/
*
* Copyright (c) SatoshiLabs
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TREZORHAL_STM32_H
#define TREZORHAL_STM32_H
#include STM32_HAL_H
#include <stdint.h>
void memset_reg(volatile void *start, volatile void *stop, uint32_t val);
void jump_to(uint32_t address);
void jump_to_with_flag(uint32_t address, uint32_t register_flag);
#endif // TREZORHAL_STM32_H

View File

@ -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

View File

@ -23,7 +23,6 @@
#include "bootutils.h"
#include "mpu.h"
#include "platform.h"
#include "systask.h"
#include "system.h"
#include "systick.h"

View File

@ -1,32 +0,0 @@
/*
* This file is part of the Trezor project, https://trezor.io/
*
* Copyright (c) SatoshiLabs
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TREZORHAL_STM32_H
#define TREZORHAL_STM32_H
#include <stdint.h>
// the following functions are defined in util.s
void memset_reg(volatile void *start, volatile void *stop, uint32_t val);
void jump_to(uint32_t address);
void jump_to_with_flag(uint32_t address, uint32_t register_flag);
void check_oem_keys(void);
#endif // TREZORHAL_STM32_H

View File

@ -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