mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-05-27 11:18:51 +00:00
refactor(core): prevent incomplete mpu driver build
[no changelog]
This commit is contained in:
parent
8a9de0ebec
commit
adf9872988
@ -96,7 +96,7 @@ static inline void mpu_enable(void) {
|
|||||||
static void mpu_init_fixed_regions(void) {
|
static void mpu_init_fixed_regions(void) {
|
||||||
// Regions #0 to #4 are fixed for all targets
|
// Regions #0 to #4 are fixed for all targets
|
||||||
|
|
||||||
#ifdef BOARDLOADER
|
#if defined(BOARDLOADER)
|
||||||
// clang-format off
|
// clang-format off
|
||||||
// Code in the Flash Bank #1 (Unprivileged, Read-Only, Executable)
|
// Code in the Flash Bank #1 (Unprivileged, Read-Only, Executable)
|
||||||
// Subregion: 48KB = 64KB except 2/8 at end
|
// Subregion: 48KB = 64KB except 2/8 at end
|
||||||
@ -113,8 +113,7 @@ static void mpu_init_fixed_regions(void) {
|
|||||||
// Subregion: 192KB = 256KB except 2/8 at end
|
// Subregion: 192KB = 256KB except 2/8 at end
|
||||||
SET_REGION( 4, SRAM_BASE, SIZE_256KB, 0xC0, SRAM, FULL_ACCESS );
|
SET_REGION( 4, SRAM_BASE, SIZE_256KB, 0xC0, SRAM, FULL_ACCESS );
|
||||||
// clang-format on
|
// clang-format on
|
||||||
#endif
|
#elif defined(BOOTLOADER)
|
||||||
#ifdef BOOTLOADER
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
// Bootloader code in the Flash Bank #1 (Unprivileged, Read-Only, Executable)
|
// Bootloader code in the Flash Bank #1 (Unprivileged, Read-Only, Executable)
|
||||||
// Subregion: 128KB = 1024KB except 2/8 at start
|
// Subregion: 128KB = 1024KB except 2/8 at start
|
||||||
@ -131,8 +130,7 @@ static void mpu_init_fixed_regions(void) {
|
|||||||
// Subregion: 192KB = 256KB except 2/8 at end
|
// Subregion: 192KB = 256KB except 2/8 at end
|
||||||
SET_REGION( 4, SRAM_BASE, SIZE_256KB, 0xC0, SRAM, FULL_ACCESS );
|
SET_REGION( 4, SRAM_BASE, SIZE_256KB, 0xC0, SRAM, FULL_ACCESS );
|
||||||
// clang-format on
|
// clang-format on
|
||||||
#endif
|
#elif defined(KERNEL)
|
||||||
#ifdef KERNEL
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
// Code in the Flash Bank #1 (Unprivileged, Read-Only, Executable)
|
// Code in the Flash Bank #1 (Unprivileged, Read-Only, Executable)
|
||||||
// Subregion: 768KB = 1024KB except 2/8 at start
|
// Subregion: 768KB = 1024KB except 2/8 at start
|
||||||
@ -149,8 +147,7 @@ static void mpu_init_fixed_regions(void) {
|
|||||||
// SubRegion: 8KB at the beginning + 16KB at the end of 64KB CCMRAM
|
// SubRegion: 8KB at the beginning + 16KB at the end of 64KB CCMRAM
|
||||||
SET_REGION( 4, CCMDATARAM_BASE, SIZE_64KB, 0x3E, SRAM, PRIV_RW );
|
SET_REGION( 4, CCMDATARAM_BASE, SIZE_64KB, 0x3E, SRAM, PRIV_RW );
|
||||||
// clang-format on
|
// clang-format on
|
||||||
#endif
|
#elif defined(FIRMWARE)
|
||||||
#ifdef FIRMWARE
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
// Code in the Flash Bank #1 (Unprivileged, Read-Only, Executable)
|
// Code in the Flash Bank #1 (Unprivileged, Read-Only, Executable)
|
||||||
// Subregion: 768KB = 1024KB except 2/8 at start
|
// Subregion: 768KB = 1024KB except 2/8 at start
|
||||||
@ -165,8 +162,7 @@ static void mpu_init_fixed_regions(void) {
|
|||||||
SET_REGION( 3, SRAM_BASE, SIZE_256KB, 0xC0, SRAM, FULL_ACCESS );
|
SET_REGION( 3, SRAM_BASE, SIZE_256KB, 0xC0, SRAM, FULL_ACCESS );
|
||||||
DIS_REGION( 4 );
|
DIS_REGION( 4 );
|
||||||
// clang-format on
|
// clang-format on
|
||||||
#endif
|
#elif defined(TREZOR_PRODTEST)
|
||||||
#ifdef TREZOR_PRODTEST
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
// Code in the Flash Bank #1 (Unprivileged, Read-Only, Executable)
|
// Code in the Flash Bank #1 (Unprivileged, Read-Only, Executable)
|
||||||
// Subregion: 768KB = 1024KB except 2/8 at start
|
// Subregion: 768KB = 1024KB except 2/8 at start
|
||||||
@ -183,6 +179,8 @@ static void mpu_init_fixed_regions(void) {
|
|||||||
// (used in production test to invalidate the firmware)
|
// (used in production test to invalidate the firmware)
|
||||||
SET_REGION( 4, FIRMWARE_START, SIZE_1KB, 0x00, FLASH_DATA, PRIV_RW_URO );
|
SET_REGION( 4, FIRMWARE_START, SIZE_1KB, 0x00, FLASH_DATA, PRIV_RW_URO );
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
#else
|
||||||
|
#error "Unknown build target"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Regions #5 to #7 are banked
|
// Regions #5 to #7 are banked
|
||||||
|
@ -203,16 +203,14 @@ static void mpu_init_fixed_regions(void) {
|
|||||||
SET_REGION( 2, BOOTLOADER_START, BOOTLOADER_MAXSIZE, FLASH_DATA, YES, NO );
|
SET_REGION( 2, BOOTLOADER_START, BOOTLOADER_MAXSIZE, FLASH_DATA, YES, NO );
|
||||||
SET_REGION( 3, FIRMWARE_START, FIRMWARE_MAXSIZE, FLASH_DATA, YES, NO );
|
SET_REGION( 3, FIRMWARE_START, FIRMWARE_MAXSIZE, FLASH_DATA, YES, NO );
|
||||||
SET_REGION( 4, AUX1_RAM_START, AUX1_RAM_SIZE, SRAM, YES, NO );
|
SET_REGION( 4, AUX1_RAM_START, AUX1_RAM_SIZE, SRAM, YES, NO );
|
||||||
#endif
|
#elif defined(BOOTLOADER)
|
||||||
#if defined(BOOTLOADER)
|
|
||||||
// REGION ADDRESS SIZE TYPE WRITE UNPRIV
|
// REGION ADDRESS SIZE TYPE WRITE UNPRIV
|
||||||
SET_REGION( 0, BOOTLOADER_START, BOOTLOADER_MAXSIZE, FLASH_CODE, NO, NO );
|
SET_REGION( 0, BOOTLOADER_START, BOOTLOADER_MAXSIZE, FLASH_CODE, NO, NO );
|
||||||
SET_REGION( 1, MAIN_RAM_START, MAIN_RAM_SIZE, SRAM, YES, NO );
|
SET_REGION( 1, MAIN_RAM_START, MAIN_RAM_SIZE, SRAM, YES, NO );
|
||||||
SET_REGION( 2, FIRMWARE_START, FIRMWARE_MAXSIZE, FLASH_DATA, YES, NO );
|
SET_REGION( 2, FIRMWARE_START, FIRMWARE_MAXSIZE, FLASH_DATA, YES, NO );
|
||||||
DIS_REGION( 3 );
|
DIS_REGION( 3 );
|
||||||
SET_REGION( 4, AUX1_RAM_START, AUX1_RAM_SIZE , SRAM, YES, NO );
|
SET_REGION( 4, AUX1_RAM_START, AUX1_RAM_SIZE , SRAM, YES, NO );
|
||||||
#endif
|
#elif defined(KERNEL)
|
||||||
#if defined(KERNEL)
|
|
||||||
// REGION ADDRESS SIZE TYPE WRITE UNPRIV
|
// REGION ADDRESS SIZE TYPE WRITE UNPRIV
|
||||||
SET_REGRUN( 0, KERNEL_FLASH_START, KERNEL_FLASH_SIZE, FLASH_CODE, NO, NO ); // Kernel Code
|
SET_REGRUN( 0, KERNEL_FLASH_START, KERNEL_FLASH_SIZE, FLASH_CODE, NO, NO ); // Kernel Code
|
||||||
SET_REGION( 1, MAIN_RAM_START, MAIN_RAM_SIZE, SRAM, YES, NO ); // Kernel RAM
|
SET_REGION( 1, MAIN_RAM_START, MAIN_RAM_SIZE, SRAM, YES, NO ); // Kernel RAM
|
||||||
@ -223,21 +221,22 @@ static void mpu_init_fixed_regions(void) {
|
|||||||
#else
|
#else
|
||||||
DIS_REGION( 4 );
|
DIS_REGION( 4 );
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#if defined(FIRMWARE)
|
#elif defined(FIRMWARE)
|
||||||
// REGION ADDRESS SIZE TYPE WRITE UNPRIV
|
// REGION ADDRESS SIZE TYPE WRITE UNPRIV
|
||||||
SET_REGION( 0, FIRMWARE_START, FIRMWARE_MAXSIZE, FLASH_CODE, NO, NO );
|
SET_REGION( 0, FIRMWARE_START, FIRMWARE_MAXSIZE, FLASH_CODE, NO, NO );
|
||||||
SET_REGION( 1, MAIN_RAM_START, MAIN_RAM_SIZE, SRAM, YES, NO );
|
SET_REGION( 1, MAIN_RAM_START, MAIN_RAM_SIZE, SRAM, YES, NO );
|
||||||
DIS_REGION( 2 );
|
DIS_REGION( 2 );
|
||||||
DIS_REGION( 3 );
|
DIS_REGION( 3 );
|
||||||
SET_REGION( 4, AUX1_RAM_START, AUX1_RAM_SIZE, SRAM, YES, NO );
|
SET_REGION( 4, AUX1_RAM_START, AUX1_RAM_SIZE, SRAM, YES, NO );
|
||||||
#endif
|
#elif defined(TREZOR_PRODTEST)
|
||||||
#if defined(TREZOR_PRODTEST)
|
|
||||||
SET_REGION( 0, FIRMWARE_START, 1024, FLASH_DATA, YES, NO );
|
SET_REGION( 0, FIRMWARE_START, 1024, FLASH_DATA, YES, NO );
|
||||||
SET_REGION( 1, FIRMWARE_START + 1024, FIRMWARE_MAXSIZE - 1024, FLASH_CODE, NO, NO );
|
SET_REGION( 1, FIRMWARE_START + 1024, FIRMWARE_MAXSIZE - 1024, FLASH_CODE, NO, NO );
|
||||||
SET_REGION( 2, MAIN_RAM_START, MAIN_RAM_SIZE, SRAM, YES, NO );
|
SET_REGION( 2, MAIN_RAM_START, MAIN_RAM_SIZE, SRAM, YES, NO );
|
||||||
DIS_REGION( 3 );
|
DIS_REGION( 3 );
|
||||||
SET_REGION( 4, AUX1_RAM_START, AUX1_RAM_SIZE, SRAM, YES, NO );
|
SET_REGION( 4, AUX1_RAM_START, AUX1_RAM_SIZE, SRAM, YES, NO );
|
||||||
|
#else
|
||||||
|
#error "Unknown build target"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Regions #5 to #7 are banked
|
// Regions #5 to #7 are banked
|
||||||
|
Loading…
Reference in New Issue
Block a user