37#ifndef _RTEMS_SCORE_AARCH32_PMSA_H
38#define _RTEMS_SCORE_AARCH32_PMSA_H
57#define AARCH32_PMSA_MIN_REGION_ALIGN 64
59#define AARCH32_PMSA_ATTR_EN 0x1U
61#define AARCH32_PMSA_ATTR_IDX_SHIFT 1
62#define AARCH32_PMSA_ATTR_IDX_MASK 0xeU
63#define AARCH32_PMSA_ATTR_IDX( _idx ) \
64 ( ( _idx ) << AARCH32_PMSA_ATTR_IDX_SHIFT )
66#define AARCH32_PMSA_ATTR_XN 0x40U
68#define AARCH32_PMSA_ATTR_AP_SHIFT 7
69#define AARCH32_PMSA_ATTR_AP_MASK 0x18U
70#define AARCH32_PMSA_ATTR_AP( _ap ) \
71 ( ( _ap ) << AARCH32_PMSA_ATTR_AP_SHIFT )
72#define AARCH32_PMSA_ATTR_AP_EL1_RW_EL0_NO 0x0U
73#define AARCH32_PMSA_ATTR_AP_EL1_RW_EL0_RW 0x1U
74#define AARCH32_PMSA_ATTR_AP_EL1_RO_EL0_NO 0x2U
75#define AARCH32_PMSA_ATTR_AP_EL1_RO_EL0_RO 0x3U
77#define AARCH32_PMSA_ATTR_SH_SHIFT 9
78#define AARCH32_PMSA_ATTR_SH_MASK 0x600U
79#define AARCH32_PMSA_ATTR_SH( _sh ) \
80 ( ( _sh ) << AARCH32_PMSA_ATTR_SH_SHIFT )
81#define AARCH32_PMSA_ATTR_SH_NO 0x0U
82#define AARCH32_PMSA_ATTR_SH_RES 0x1U
83#define AARCH32_PMSA_ATTR_SH_OUTER 0x2U
84#define AARCH32_PMSA_ATTR_SH_INNER 0x3U
86#define AARCH32_PMSA_MEM_DEVICE_NG_NR_NE 0x00U
87#define AARCH32_PMSA_MEM_DEVICE_NG_NR_E 0x04U
88#define AARCH32_PMSA_MEM_DEVICE_NG_R_E 0x08U
89#define AARCH32_PMSA_MEM_DEVICE_G_R_E 0x0cU
91#define AARCH32_PMSA_MEM_OUTER_WTT 0x00U
92#define AARCH32_PMSA_MEM_OUTER_NC 0x40U
93#define AARCH32_PMSA_MEM_OUTER_WBT 0x40U
94#define AARCH32_PMSA_MEM_OUTER_WTNT 0x80U
95#define AARCH32_PMSA_MEM_OUTER_WBNT 0xc0U
97#define AARCH32_PMSA_MEM_OUTER_RA 0x20U
98#define AARCH32_PMSA_MEM_OUTER_WA 0x10U
100#define AARCH32_PMSA_MEM_INNER_WTT 0x00U
101#define AARCH32_PMSA_MEM_INNER_NC 0x04U
102#define AARCH32_PMSA_MEM_INNER_WBT 0x04U
103#define AARCH32_PMSA_MEM_INNER_WTNT 0x08U
104#define AARCH32_PMSA_MEM_INNER_WBNT 0x0cU
106#define AARCH32_PMSA_MEM_INNER_RA 0x02U
107#define AARCH32_PMSA_MEM_INNER_WA 0x01U
109#define AARCH32_PMSA_MEM_ATTR( _ma0, _ma1, _ma2, _ma3 ) \
110 ( ( _ma0 ) | ( ( _ma1 ) << 8 ) | ( ( _ma2 ) << 16 ) | ( ( _ma3 ) << 24 ) )
112#define AARCH32_PMSA_MEM_ATTR_DEFAULT_CACHED \
113 ( AARCH32_PMSA_MEM_OUTER_WBNT | \
114 AARCH32_PMSA_MEM_OUTER_RA | \
115 AARCH32_PMSA_MEM_OUTER_WA | \
116 AARCH32_PMSA_MEM_INNER_WBNT | \
117 AARCH32_PMSA_MEM_INNER_RA | \
118 AARCH32_PMSA_MEM_INNER_WA )
120#define AARCH32_PMSA_MEM_ATTR_DEFAULT_UNCACHED \
121 ( AARCH32_PMSA_MEM_OUTER_NC | \
122 AARCH32_PMSA_MEM_INNER_NC )
124#define AARCH32_PMSA_MEM_ATTR_DEFAULT_DEVICE \
125 AARCH32_PMSA_MEM_DEVICE_NG_NR_NE
127#define AARCH32_PMSA_CODE_CACHED \
128 ( AARCH32_PMSA_ATTR_EN | \
129 AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RO_EL0_NO ) | \
130 AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
131 AARCH32_PMSA_ATTR_IDX( 0U ) )
133#define AARCH32_PMSA_CODE_UNCACHED \
134 ( AARCH32_PMSA_ATTR_EN | \
135 AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RO_EL0_NO ) | \
136 AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
137 AARCH32_PMSA_ATTR_IDX( 1U ) )
139#define AARCH32_PMSA_DATA_READ_ONLY_CACHED \
140 ( AARCH32_PMSA_ATTR_EN | \
141 AARCH32_PMSA_ATTR_XN | \
142 AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RO_EL0_NO ) | \
143 AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
144 AARCH32_PMSA_ATTR_IDX( 0U ) )
146#define AARCH32_PMSA_DATA_READ_ONLY_UNCACHED \
147 ( AARCH32_PMSA_ATTR_EN | \
148 AARCH32_PMSA_ATTR_XN | \
149 AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RO_EL0_NO ) | \
150 AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
151 AARCH32_PMSA_ATTR_IDX( 1U ) )
153#define AARCH32_PMSA_DATA_READ_WRITE_CACHED \
154 ( AARCH32_PMSA_ATTR_EN | \
155 AARCH32_PMSA_ATTR_XN | \
156 AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RW_EL0_NO ) | \
157 AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
158 AARCH32_PMSA_ATTR_IDX( 0U ) )
160#define AARCH32_PMSA_DATA_READ_WRITE_UNCACHED \
161 ( AARCH32_PMSA_ATTR_EN | \
162 AARCH32_PMSA_ATTR_XN | \
163 AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RW_EL0_NO ) | \
164 AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
165 AARCH32_PMSA_ATTR_IDX( 1U ) )
167#define AARCH32_PMSA_DATA_READ_WRITE_SHARED \
168 ( AARCH32_PMSA_ATTR_EN | \
169 AARCH32_PMSA_ATTR_XN | \
170 AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RW_EL0_NO ) | \
171 AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_OUTER ) | \
172 AARCH32_PMSA_ATTR_IDX( 1U ) )
174#define AARCH32_PMSA_DEVICE \
175 ( AARCH32_PMSA_ATTR_EN | \
176 AARCH32_PMSA_ATTR_XN | \
177 AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RW_EL0_NO ) | \
178 AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
179 AARCH32_PMSA_ATTR_IDX( 2U ) )
187#if defined(RTEMS_SMP)
188#define AARCH32_PMSA_DATA_READ_WRITE_DEFAULT \
189 AARCH32_PMSA_DATA_READ_WRITE_SHARED
191#define AARCH32_PMSA_DATA_READ_WRITE_DEFAULT \
192 AARCH32_PMSA_DATA_READ_WRITE_CACHED
202#define AARCH32_PMSA_DEFAULT_SECTIONS \
204 .begin = (uint32_t) bsp_section_fast_text_begin, \
205 .end = (uint32_t) bsp_section_fast_text_end, \
206 .attributes = AARCH32_PMSA_CODE_CACHED \
208 .begin = (uint32_t) bsp_section_fast_data_begin, \
209 .end = (uint32_t) bsp_section_fast_data_end, \
210 .attributes = AARCH32_PMSA_DATA_READ_WRITE_DEFAULT \
212 .begin = (uint32_t) bsp_section_start_begin, \
213 .end = (uint32_t) bsp_section_start_end, \
214 .attributes = AARCH32_PMSA_CODE_CACHED \
216 .begin = (uint32_t) bsp_section_vector_begin, \
217 .end = (uint32_t) bsp_section_vector_end, \
218 .attributes = AARCH32_PMSA_CODE_CACHED \
220 .begin = (uint32_t) bsp_section_text_begin, \
221 .end = (uint32_t) bsp_section_text_end, \
222 .attributes = AARCH32_PMSA_CODE_CACHED \
224 .begin = (uint32_t) bsp_section_rodata_begin, \
225 .end = (uint32_t) bsp_section_rodata_end, \
226 .attributes = AARCH32_PMSA_DATA_READ_ONLY_CACHED \
228 .begin = (uint32_t) bsp_section_data_begin, \
229 .end = (uint32_t) bsp_section_data_end, \
230 .attributes = AARCH32_PMSA_DATA_READ_WRITE_DEFAULT \
232 .begin = (uint32_t) bsp_section_bss_begin, \
233 .end = (uint32_t) bsp_section_bss_end, \
234 .attributes = AARCH32_PMSA_DATA_READ_WRITE_DEFAULT \
236 .begin = (uint32_t) bsp_section_rtemsstack_begin, \
237 .end = (uint32_t) bsp_section_rtemsstack_end, \
238 .attributes = AARCH32_PMSA_DATA_READ_WRITE_DEFAULT \
240 .begin = (uint32_t) bsp_section_work_begin, \
241 .end = (uint32_t) bsp_section_work_end, \
242 .attributes = AARCH32_PMSA_DATA_READ_WRITE_DEFAULT \
244 .begin = (uint32_t) bsp_section_stack_begin, \
245 .end = (uint32_t) bsp_section_stack_end, \
246 .attributes = AARCH32_PMSA_DATA_READ_WRITE_DEFAULT \
248 .begin = (uint32_t) bsp_section_nocache_begin, \
249 .end = (uint32_t) bsp_section_nocache_end, \
250 .attributes = AARCH32_PMSA_DATA_READ_WRITE_UNCACHED \
252 .begin = (uint32_t) bsp_section_nocachenoload_begin, \
253 .end = (uint32_t) bsp_section_nocachenoload_end, \
254 .attributes = AARCH32_PMSA_DATA_READ_WRITE_UNCACHED \
326 uint32_t memory_attributes_0,
327 uint32_t memory_attributes_1,
352 size_t section_count,
This header file provides basic definitions used by the API and the implementation.
const size_t _AArch32_PMSA_Section_count
This constant provides the count of elements in _AArch32_PMSA_Sections.
Definition: pmsa-sections.c:55
void _AArch32_PMSA_Initialize(uint32_t memory_attributes_0, uint32_t memory_attributes_1, const AArch32_PMSA_Section *sections, size_t section_count)
Initializes the Memory Protection Unit (MPU).
const AArch32_PMSA_Section _AArch32_PMSA_Sections[]
This array provides section definitions to initialize the memory protection unit (MPU).
Definition: pmsa-sections.c:46
size_t _AArch32_PMSA_Map_sections_to_regions(const AArch32_PMSA_Section *sections, size_t section_count, AArch32_PMSA_Region *regions, size_t region_max)
Maps the section definitions to region definitions.
void _AArch32_PMSA_Initialize_default(void)
Initializes the Memory Protection Unit (MPU) using the section definitions with default memory attrib...
The region definition is used to configure the Memory Protection Unit (MPU).
Definition: aarch32-pmsa.h:286
uint32_t base
This member defines the base address of the region.
Definition: aarch32-pmsa.h:292
uint32_t attributes
This member defines the attributes of the region.
Definition: aarch32-pmsa.h:304
uint32_t limit
This member defines the limit address of the region.
Definition: aarch32-pmsa.h:299
The section definition is used to initialize the Memory Protection Unit (MPU).
Definition: aarch32-pmsa.h:263
uint32_t begin
This member defines the begin address of the section.
Definition: aarch32-pmsa.h:267
uint32_t attributes
This member defines the attributes of the section.
Definition: aarch32-pmsa.h:277
uint32_t end
This member defines the end address of the section.
Definition: aarch32-pmsa.h:272