2024-08-30 09:12:05 +00:00
|
|
|
/*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2024-08-16 10:11:38 +00:00
|
|
|
#ifndef TREZORHAL_BOOTUTILS_H
|
|
|
|
#define TREZORHAL_BOOTUTILS_H
|
2023-10-20 12:58:32 +00:00
|
|
|
|
2024-11-01 11:55:31 +00:00
|
|
|
#include <trezor_types.h>
|
2023-10-31 11:38:11 +00:00
|
|
|
|
2024-08-30 09:12:05 +00:00
|
|
|
// Immediately resets the device and initiates the normal boot sequence.
|
2024-10-02 11:38:45 +00:00
|
|
|
void __attribute__((noreturn)) reboot_device(void);
|
2023-10-20 12:58:32 +00:00
|
|
|
|
2024-08-30 09:12:05 +00:00
|
|
|
// Resets the device and enters the bootloader,
|
|
|
|
// halting there and waiting for further user instructions.
|
2024-08-16 11:33:58 +00:00
|
|
|
void __attribute__((noreturn)) reboot_to_bootloader(void);
|
|
|
|
|
2024-08-30 09:12:05 +00:00
|
|
|
// Resets the device into the bootloader and automatically continues
|
|
|
|
// with the installation of new firmware (also known as an
|
|
|
|
// interaction-less upgrade).
|
|
|
|
//
|
|
|
|
// If the provided hash is NULL or invalid, the device will stop
|
|
|
|
// at the bootloader and will require user acknowledgment to proceed
|
|
|
|
// with the firmware installation.
|
|
|
|
void __attribute__((noreturn)) reboot_and_upgrade(const uint8_t hash[32]);
|
|
|
|
|
|
|
|
// Allows the user to see the displayed error message and then
|
|
|
|
// safely shuts down the device (clears secrets, memory, etc.).
|
|
|
|
//
|
|
|
|
// This function is called when the device enters an
|
|
|
|
// unrecoverable error state.
|
2024-08-16 11:33:58 +00:00
|
|
|
void __attribute__((noreturn)) secure_shutdown(void);
|
2024-08-08 16:26:25 +00:00
|
|
|
|
2024-10-04 12:28:34 +00:00
|
|
|
// 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);
|
|
|
|
|
2024-10-31 20:15:18 +00:00
|
|
|
// Ensure compatible hardware settings before jumping to
|
|
|
|
// the different booting stage. This function is used to
|
|
|
|
// ensure backward compatibility with older versions of
|
|
|
|
// released bootloaders and firmware.
|
|
|
|
//
|
|
|
|
// Does nothing on almost all platforms.
|
|
|
|
void ensure_compatible_settings(void);
|
|
|
|
|
2024-08-16 10:11:38 +00:00
|
|
|
#endif // TREZORHAL_BOOTUTILS_H
|