Skip to content

Commit

Permalink
refactor(core): introduce global trezor_rtl/bsp/model headers
Browse files Browse the repository at this point in the history
[no changelog]
  • Loading branch information
cepetr committed Nov 1, 2024
1 parent e2b85a5 commit df5d723
Show file tree
Hide file tree
Showing 240 changed files with 596 additions and 681 deletions.
8 changes: 3 additions & 5 deletions core/embed/boardloader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,26 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <string.h>
#include <trezor_model.h>
#include <trezor_rtl.h>

#include TREZOR_BOARD
#include "board_capabilities.h"
#include "bootutils.h"
#include "buffers.h"
#include "common.h"
#include "compiler_traits.h"
#include "display.h"
#include "display_draw.h"
#include "flash.h"
#include "flash_utils.h"
#include "image.h"
#include "model.h"
#include "mpu.h"
#include "pvd.h"
#include "reset_flags.h"
#include "rng.h"
#include "rsod.h"
#include "secret.h"
#include "system.h"
#include "systick.h"
#include "terminal.h"

#ifdef USE_SD_CARD
Expand All @@ -59,7 +58,6 @@
#endif

#include "memzero.h"
#include "model.h"
#include "monoctr.h"
#include "option_bytes.h"
#include "tamper.h"
Expand Down
4 changes: 1 addition & 3 deletions core/embed/bootloader/bootui.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <string.h>

#include TREZOR_BOARD
#include <trezor_rtl.h>

#include "bootui.h"
#include "colors.h"
Expand Down
5 changes: 2 additions & 3 deletions core/embed/bootloader/bootui.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
#ifndef __BOOTUI_H__
#define __BOOTUI_H__

#include <trezor_types.h>

#include "image.h"
#include "secbool.h"
#include "stdbool.h"
#include TREZOR_BOARD

typedef enum {
SCREEN_INTRO = 0,
Expand Down
8 changes: 4 additions & 4 deletions core/embed/bootloader/emulator.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#include <stdio.h>
#include <trezor_model.h>
#include <trezor_rtl.h>

#include <unistd.h>

#include <SDL.h>

#include TREZOR_BOARD
#include "bootargs.h"
#include "bootui.h"
#include "common.h"
#include "display.h"
#include "flash.h"
#include "flash_otp.h"
#include "model.h"
#include "rust_ui.h"
#ifdef USE_OPTIGA
#include "secret.h"
#endif
#include "systick.h"

#include "emulator.h"

Expand Down
5 changes: 2 additions & 3 deletions core/embed/bootloader/emulator.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#ifndef __EMULATOR_H__
#define __EMULATOR_H__

#undef FIRMWARE_START
#include <trezor_types.h>

#include <stdint.h>
#include <stdio.h>
#undef FIRMWARE_START

extern uint8_t *FIRMWARE_START;

Expand Down
9 changes: 5 additions & 4 deletions core/embed/bootloader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <string.h>
#include <trezor_bsp.h>
#include <trezor_model.h>
#include <trezor_rtl.h>

#include <sys/types.h>

#include "bootargs.h"
#include "bootutils.h"
#include "common.h"
#include "display.h"
#include "display_utils.h"
#include "flash.h"
Expand All @@ -35,9 +37,9 @@
#include "pvd.h"
#include "random_delays.h"
#include "rsod.h"
#include "secbool.h"
#include "secret.h"
#include "system.h"
#include "systick.h"
#include "systimer.h"

#ifdef USE_DMA2D
Expand Down Expand Up @@ -66,7 +68,6 @@
#include "hash_processor.h"
#endif

#include "model.h"
#include "usb.h"
#include "version.h"

Expand Down
6 changes: 2 additions & 4 deletions core/embed/bootloader/messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <string.h>
#include <trezor_model.h>
#include <trezor_rtl.h>

#include <pb.h>
#include <pb_decode.h>
#include <pb_encode.h>
#include "messages.pb.h"

#include "bootargs.h"
#include "common.h"
#include "flash.h"
#include "flash_utils.h"
#include "image.h"
#include "secbool.h"
#include "secret.h"
#include "unit_properties.h"
#include "usb.h"
Expand All @@ -41,7 +40,6 @@
#include "version_check.h"

#include "memzero.h"
#include "model.h"

#ifdef TREZOR_EMULATOR
#include "emulator.h"
Expand Down
5 changes: 2 additions & 3 deletions core/embed/bootloader/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
#ifndef __MESSAGES_H__
#define __MESSAGES_H__

#include <stdint.h>
#include <trezor_types.h>

#include "image.h"
#include "secbool.h"
#include TREZOR_BOARD

#define USB_TIMEOUT 500
#define USB_PACKET_SIZE 64
Expand Down
6 changes: 2 additions & 4 deletions core/embed/bootloader/version_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <string.h>
#include <trezor_rtl.h>

#include "version_check.h"

#include "error_handling.h"
#include "model_version.h"
#include "monoctr.h"
#include "version_check.h"

void ensure_bootloader_min_version(void) {
monoctr_write(MONOCTR_BOOTLOADER_VERSION, BOOTLOADER_MONOTONIC_VERSION);
Expand Down
3 changes: 1 addition & 2 deletions core/embed/bootloader/version_check.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

#pragma once

#include <stdint.h>
#include "secbool.h"
#include <trezor_types.h>

// Protection against bootloader downgrade

Expand Down
2 changes: 1 addition & 1 deletion core/embed/bootloader_ci/bootui.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <string.h>
#include <trezor_rtl.h>

#include "bootui.h"
#include "display.h"
Expand Down
2 changes: 1 addition & 1 deletion core/embed/bootloader_ci/bootui.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef __BOOTUI_H__
#define __BOOTUI_H__

#include "secbool.h"
#include <trezor_types.h>

void ui_screen_welcome_third(void);

Expand Down
8 changes: 3 additions & 5 deletions core/embed/bootloader_ci/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <string.h>
#include <sys/types.h>
#include <trezor_model.h>
#include <trezor_rtl.h>

#include <sys/types.h>
#include "bootutils.h"
#include "common.h"
#include "display.h"
#include "display_draw.h"
#include "flash.h"
Expand All @@ -32,7 +32,6 @@
#include "random_delays.h"
#include "rng.h"
#include "rsod.h"
#include "secbool.h"
#include "system.h"
#ifdef USE_TOUCH
#include "touch.h"
Expand All @@ -42,7 +41,6 @@

#include "bootui.h"
#include "messages.h"
#include "model.h"
#include "version_check.h"

#ifdef USE_HASH_PROCESSOR
Expand Down
6 changes: 2 additions & 4 deletions core/embed/bootloader_ci/messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <string.h>
#include <trezor_model.h>
#include <trezor_rtl.h>

#include <pb.h>
#include <pb_decode.h>
#include <pb_encode.h>
#include "messages.pb.h"

#include "common.h"
#include "flash.h"
#include "flash_utils.h"
#include "image.h"
#include "model.h"
#include "secbool.h"
#include "usb.h"
#include "version.h"

Expand Down
4 changes: 2 additions & 2 deletions core/embed/bootloader_ci/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#ifndef __MESSAGES_H__
#define __MESSAGES_H__

#include <stdint.h>
#include <trezor_types.h>

#include "image.h"
#include "secbool.h"

#define USB_TIMEOUT 500
#define USB_PACKET_SIZE 64
Expand Down
3 changes: 1 addition & 2 deletions core/embed/extmod/modtrezorconfig/modtrezorconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <string.h>
#include <trezor_rtl.h>

#include "py/mphal.h"
#include "py/objstr.h"
Expand All @@ -27,7 +27,6 @@

#include "embed/extmod/trezorobj.h"

#include "common.h"
#include "entropy.h"
#include "memzero.h"
#include "storage.h"
Expand Down
5 changes: 3 additions & 2 deletions core/embed/extmod/modtrezorconfig/norcow_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
#ifndef __NORCOW_CONFIG_H__
#define __NORCOW_CONFIG_H__

#include TREZOR_BOARD
#include <trezor_model.h>
#include <trezor_types.h>

#include "flash.h"
#include "model.h"

#define NORCOW_HEADER_LEN 0
#define NORCOW_SECTOR_COUNT 2
Expand Down
2 changes: 1 addition & 1 deletion core/embed/extmod/modtrezorcrypto/crc.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef __CRC_H__
#define __CRC_H__

#include <stdint.h>
#include <trezor_types.h>

uint32_t checksum_crc32(const uint8_t *data, uint32_t length, uint32_t crc);

Expand Down
8 changes: 1 addition & 7 deletions core/embed/extmod/modtrezorcrypto/modtrezorcrypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdint.h>
#include <stdio.h>
#include <string.h>

#include "common.h"
#include <trezor_rtl.h>

#include "py/runtime.h"

#include TREZOR_BOARD

#if MICROPY_PY_TREZORCRYPTO

static mp_obj_t ui_wait_callback = mp_const_none;
Expand Down
3 changes: 2 additions & 1 deletion core/embed/extmod/modtrezorio/ff.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
/----------------------------------------------------------------------------*/


#include <string.h>
#include <trezor_rtl.h>

#include "ff.h" /* Declarations of FatFs API */
#include "diskio.h" /* Declarations of device I/O functions */

Expand Down
5 changes: 3 additions & 2 deletions core/embed/extmod/modtrezorio/modtrezorio-poll.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <string.h>
#include <trezor_types.h>

#include "button.h"
#include "common.h"
#include "display.h"
#include "systick.h"

#include "embed/extmod/trezorobj.h"

#ifdef TREZOR_EMULATOR
Expand Down
7 changes: 3 additions & 4 deletions core/embed/extmod/modtrezorio/modtrezorio.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <string.h>
#include <trezor_rtl.h>

#include <unistd.h>

#include "py/mphal.h"
#include "py/objstr.h"
#include "py/runtime.h"

#if MICROPY_PY_TREZORIO

#include <unistd.h>

#include TREZOR_BOARD
#include "button.h"
#include "touch.h"
#include "usb.h"
Expand Down
Loading

0 comments on commit df5d723

Please sign in to comment.