AM261x MCU+ SDK: MpuP_armv7.h Source File

| AM261x MCU+ SDK 26.00.00 |

MpuP_armv7.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2018-2023 Texas Instruments Incorporated
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #ifndef MPUP_ARM_V7_H
34 #define MPUP_ARM_V7_H
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 #include <stdint.h>
41 #include <kernel/dpl/SystemP.h>
42
55 typedef enum MpuP_AccessPerm_
56 {
57 MpuP_AP_ALL_BLOCK = (0x0u),
58 MpuP_AP_S_RW = (0x1u),
59 MpuP_AP_S_RW_U_R = (0x2u),
60 MpuP_AP_ALL_RW = (0x3u),
61 MpuP_AP_S_R = (0x5u),
62 MpuP_AP_ALL_R = (0x6u)
63 } MpuP_AccessPerm;
64
68 typedef enum MpuP_RegionPerm_ {
69 MpuP_RP_R = 1U,
70 MpuP_RP_RW = 2U
71 } MpuP_RegionPerm;
72
76 typedef enum MpuP_RegionSize_ {
77 MpuP_RegionSize_32 = 0x4,
78 MpuP_RegionSize_64,
79 MpuP_RegionSize_128,
80 MpuP_RegionSize_256,
81 MpuP_RegionSize_512,
82 MpuP_RegionSize_1K,
83 MpuP_RegionSize_2K,
84 MpuP_RegionSize_4K,
85 MpuP_RegionSize_8K,
86 MpuP_RegionSize_16K,
87 MpuP_RegionSize_32K,
88 MpuP_RegionSize_64K,
89 MpuP_RegionSize_128K,
90 MpuP_RegionSize_256K,
91 MpuP_RegionSize_512K,
92 MpuP_RegionSize_1M,
93 MpuP_RegionSize_2M,
94 MpuP_RegionSize_4M,
95 MpuP_RegionSize_8M,
96 MpuP_RegionSize_16M,
97 MpuP_RegionSize_32M,
98 MpuP_RegionSize_64M,
99 MpuP_RegionSize_128M,
100 MpuP_RegionSize_256M,
101 MpuP_RegionSize_512M,
102 MpuP_RegionSize_1G,
103 MpuP_RegionSize_2G,
104 MpuP_RegionSize_4G
105 } MpuP_RegionSize;
106
115 typedef struct MpuP_RegionAttrs_ {
116
117 uint8_t isEnable;
118 uint8_t isCacheable;
119 uint8_t isBufferable;
120 uint8_t isSharable;
121 uint8_t isExecuteNever;
122 uint8_t tex;
123 uint8_t accessPerm;
124 uint8_t subregionDisableMask;
125 } MpuP_RegionAttrs;
126
130 typedef struct MpuP_RegionConfig_ {
131
132 uint32_t baseAddr;
133 uint32_t size;
134 MpuP_RegionAttrs attrs;
136 } MpuP_RegionConfig;
137
141 typedef struct MpuP_Config_ {
142
143 uint32_t numRegions;
144 uint32_t enableBackgroundRegion;
145 uint32_t enableMpu;
147 } MpuP_Config;
148
156 void MpuP_RegionAttrs_init(MpuP_RegionAttrs *region);
157
169 void MpuP_setRegion(uint32_t regionNum, void * addr, uint32_t size, MpuP_RegionAttrs *attrs);
170
174 void MpuP_enable(void);
175
179 void MpuP_disable(void);
180
186 uint32_t MpuP_isEnable(void);
187
192 void MpuP_init(void);
193
203 uint32_t MpuP_isUserAuthorizedToAccessMemory(uint32_t memAddr, uint32_t memLength, MpuP_RegionPerm perm);
204
207 #ifdef __cplusplus
208 }
209 #endif
210
211 #endif /* MPUP_ARM_V7_H */
MpuP_RegionSize_2M
@ MpuP_RegionSize_2M
Definition: MpuP_armv7.h:93
MpuP_RegionAttrs::tex
uint8_t tex
Definition: MpuP_armv7.h:122
MpuP_RP_R
@ MpuP_RP_R
Definition: MpuP_armv7.h:69
MpuP_RegionAttrs_init
void MpuP_RegionAttrs_init(MpuP_RegionAttrs *region)
Set default values to MpuP_RegionAttrs.
MpuP_RegionConfig::size
uint32_t size
Definition: MpuP_armv7.h:133
MpuP_RegionSize_8K
@ MpuP_RegionSize_8K
Definition: MpuP_armv7.h:85
MpuP_Config::enableMpu
uint32_t enableMpu
Definition: MpuP_armv7.h:145
MpuP_RegionSize_4G
@ MpuP_RegionSize_4G
Definition: MpuP_armv7.h:104
MpuP_RegionSize_32
@ MpuP_RegionSize_32
Definition: MpuP_armv7.h:77
SystemP.h
MpuP_RegionAttrs::subregionDisableMask
uint8_t subregionDisableMask
Definition: MpuP_armv7.h:124
MpuP_RegionSize_512
@ MpuP_RegionSize_512
Definition: MpuP_armv7.h:81
MpuP_RegionSize_256K
@ MpuP_RegionSize_256K
Definition: MpuP_armv7.h:90
MpuP_RegionSize_64
@ MpuP_RegionSize_64
Definition: MpuP_armv7.h:78
MpuP_RegionSize_16M
@ MpuP_RegionSize_16M
Definition: MpuP_armv7.h:96
MpuP_RegionAttrs::isCacheable
uint8_t isCacheable
Definition: MpuP_armv7.h:118
MpuP_AP_ALL_R
@ MpuP_AP_ALL_R
Definition: MpuP_armv7.h:62
MpuP_RegionAttrs::isExecuteNever
uint8_t isExecuteNever
Definition: MpuP_armv7.h:121
MpuP_disable
void MpuP_disable(void)
Disable MPU sub-system.
MpuP_RegionAttrs::isSharable
uint8_t isSharable
Definition: MpuP_armv7.h:120
MpuP_RegionSize
MpuP_RegionSize
Enum's to represent different possible MPU region size.
Definition: MpuP_armv7.h:76
MpuP_RegionAttrs::isEnable
uint8_t isEnable
Definition: MpuP_armv7.h:117
MpuP_Config::numRegions
uint32_t numRegions
Definition: MpuP_armv7.h:143
MpuP_RegionSize_256
@ MpuP_RegionSize_256
Definition: MpuP_armv7.h:80
MpuP_AP_S_R
@ MpuP_AP_S_R
Definition: MpuP_armv7.h:61
MpuP_RegionSize_2K
@ MpuP_RegionSize_2K
Definition: MpuP_armv7.h:83
MpuP_RegionPerm
MpuP_RegionPerm
Enum's to authorize access requests for a given MPU region.
Definition: MpuP_armv7.h:68
MpuP_RegionSize_32M
@ MpuP_RegionSize_32M
Definition: MpuP_armv7.h:97
MpuP_RegionSize_4K
@ MpuP_RegionSize_4K
Definition: MpuP_armv7.h:84
MpuP_RegionSize_64K
@ MpuP_RegionSize_64K
Definition: MpuP_armv7.h:88
MpuP_RegionSize_128K
@ MpuP_RegionSize_128K
Definition: MpuP_armv7.h:89
MpuP_RegionSize_1K
@ MpuP_RegionSize_1K
Definition: MpuP_armv7.h:82
MpuP_RegionSize_4M
@ MpuP_RegionSize_4M
Definition: MpuP_armv7.h:94
MpuP_RegionAttrs::accessPerm
uint8_t accessPerm
Definition: MpuP_armv7.h:123
MpuP_isUserAuthorizedToAccessMemory
uint32_t MpuP_isUserAuthorizedToAccessMemory(uint32_t memAddr, uint32_t memLength, MpuP_RegionPerm perm)
Check if the user is authorized to access a specific memory.
MpuP_Config
MPU config structure, this used by SysConfig and not to be used by end-users directly.
Definition: MpuP_armv7.h:141
MpuP_RegionSize_16K
@ MpuP_RegionSize_16K
Definition: MpuP_armv7.h:86
MpuP_RP_RW
@ MpuP_RP_RW
Definition: MpuP_armv7.h:70
MpuP_AP_ALL_RW
@ MpuP_AP_ALL_RW
Definition: MpuP_armv7.h:60
MpuP_AccessPerm
MpuP_AccessPerm
Enum's to represent different types of access permissions that are possible for a given MPU region.
Definition: MpuP_armv7.h:56
MpuP_AP_S_RW_U_R
@ MpuP_AP_S_RW_U_R
Definition: MpuP_armv7.h:59
MpuP_init
void MpuP_init(void)
Initialize MPU sub-system, called by SysConfig, not to be called by end users.
MpuP_AP_ALL_BLOCK
@ MpuP_AP_ALL_BLOCK
Definition: MpuP_armv7.h:57
MpuP_RegionConfig::attrs
MpuP_RegionAttrs attrs
Definition: MpuP_armv7.h:134
MpuP_RegionConfig
Region config structure, this used by SysConfig and not to be used by end-users directly.
Definition: MpuP_armv7.h:130
MpuP_RegionSize_8M
@ MpuP_RegionSize_8M
Definition: MpuP_armv7.h:95
MpuP_RegionSize_1M
@ MpuP_RegionSize_1M
Definition: MpuP_armv7.h:92
MpuP_RegionSize_128
@ MpuP_RegionSize_128
Definition: MpuP_armv7.h:79
MpuP_Config::enableBackgroundRegion
uint32_t enableBackgroundRegion
Definition: MpuP_armv7.h:144
MpuP_RegionAttrs
Attribute's to apply for a MPU region.
Definition: MpuP_armv7.h:115
MpuP_RegionSize_64M
@ MpuP_RegionSize_64M
Definition: MpuP_armv7.h:98
MpuP_RegionSize_256M
@ MpuP_RegionSize_256M
Definition: MpuP_armv7.h:100
MpuP_RegionSize_1G
@ MpuP_RegionSize_1G
Definition: MpuP_armv7.h:102
MpuP_RegionSize_512K
@ MpuP_RegionSize_512K
Definition: MpuP_armv7.h:91
MpuP_RegionSize_2G
@ MpuP_RegionSize_2G
Definition: MpuP_armv7.h:103
MpuP_RegionSize_32K
@ MpuP_RegionSize_32K
Definition: MpuP_armv7.h:87
MpuP_RegionSize_128M
@ MpuP_RegionSize_128M
Definition: MpuP_armv7.h:99
MpuP_RegionConfig::baseAddr
uint32_t baseAddr
Definition: MpuP_armv7.h:132
MpuP_AP_S_RW
@ MpuP_AP_S_RW
Definition: MpuP_armv7.h:58
MpuP_setRegion
void MpuP_setRegion(uint32_t regionNum, void *addr, uint32_t size, MpuP_RegionAttrs *attrs)
Setup a region in the MPU.
MpuP_isEnable
uint32_t MpuP_isEnable(void)
Check if MPU sub-system is enabled.
MpuP_RegionSize_512M
@ MpuP_RegionSize_512M
Definition: MpuP_armv7.h:101
MpuP_enable
void MpuP_enable(void)
Enable MPU sub-system using the region that are setup using MpuP_setRegion.
MpuP_RegionAttrs::isBufferable
uint8_t isBufferable
Definition: MpuP_armv7.h:119