Merge pull request #9742 from mikeller/fix_spi_transaction_support
[betaflight.git] / src / main / drivers / memprot_stm32h7xx.c
blob8e4fe23341b0560d07f93d18abfd0e117915b616
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #include "platform.h"
23 #include "memprot.h"
25 // Defined in linker script
26 extern uint8_t dmaram_start;
27 extern uint8_t dmaram_end;
29 extern uint8_t dmarwaxi_start;
30 extern uint8_t dmarwaxi_end;
32 mpuRegion_t mpuRegions[] = {
33 #ifdef USE_ITCM_RAM
35 // Mark ITCM-RAM as read-only
36 // "For Cortex®-M7, TCMs memories always behave as Non-cacheable, Non-shared normal memories, irrespectiveof the memory type attributes defined in the MPU for a memory region containing addresses held in the TCM"
37 // See AN4838
38 .start = 0x00000000,
39 .end = 0, // Size defined by "size"
40 .size = MPU_REGION_SIZE_64KB,
41 .perm = MPU_REGION_PRIV_RO_URO,
42 .exec = MPU_INSTRUCTION_ACCESS_ENABLE,
43 .shareable = MPU_ACCESS_NOT_SHAREABLE,
44 .cacheable = MPU_ACCESS_NOT_CACHEABLE,
45 .bufferable = MPU_ACCESS_BUFFERABLE,
47 #endif
49 // DMA transmit buffer in D2 SRAM1
50 // Reading needs cache coherence operation
51 .start = (uint32_t)&dmaram_start,
52 .end = (uint32_t)&dmaram_end,
53 .size = 0, // Size determined by ".end"
54 .perm = MPU_REGION_FULL_ACCESS,
55 .exec = MPU_INSTRUCTION_ACCESS_ENABLE,
56 .shareable = MPU_ACCESS_SHAREABLE,
57 .cacheable = MPU_ACCESS_CACHEABLE,
58 .bufferable = MPU_ACCESS_NOT_BUFFERABLE,
60 #ifdef USE_SDCARD_SDIO
62 // A region in AXI RAM accessible from SDIO internal DMA
63 .start = (uint32_t)&dmarwaxi_start,
64 .end = (uint32_t)&dmarwaxi_end,
65 .size = 0, // Size determined by ".end"
66 .perm = MPU_REGION_FULL_ACCESS,
67 .exec = MPU_INSTRUCTION_ACCESS_ENABLE,
68 .shareable = MPU_ACCESS_NOT_SHAREABLE,
69 .cacheable = MPU_ACCESS_CACHEABLE,
70 .bufferable = MPU_ACCESS_NOT_BUFFERABLE,
72 #endif
75 unsigned mpuRegionCount = ARRAYLEN(mpuRegions);
77 STATIC_ASSERT(ARRAYLEN(mpuRegions) <= MAX_MPU_REGIONS, MPU_region_count_exceeds_limit);