]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/include/sys/sys_mpu.h
Add target specific pinmux for TMS570_HYDCTR
[pes-rpp/rpp-lib.git] / rpp / include / sys / sys_mpu.h
1 /** @file sys_mpu.h
2 *   @brief System Mpu Header File
3 *   @date 15.Mar.2012
4 *   @version 03.01.00
5 *
6 *   This file contains:
7 *   - Mpu Interface Functions
8 *   .
9 *   which are relevant for the memory protection unit driver.
10 */
11
12 /* (c) Texas Instruments 2009-2012, All rights reserved. */
13
14 #ifndef __SYS_MPU_H__
15 #define __SYS_MPU_H__
16
17 #include "base.h"
18
19 /* USER CODE BEGIN (0) */
20 /* USER CODE END */
21
22 /** @def mpuREGION1
23 *   @brief Mpu region 1
24 *
25 *   Alias for Mpu region 1
26 */
27 #define mpuREGION1 0U
28
29 /** @def mpuREGION2
30 *   @brief Mpu region 2
31 *
32 *   Alias for Mpu region 1
33 */
34 #define mpuREGION2 1U
35
36 /** @def mpuREGION3
37 *   @brief Mpu region 3
38 *
39 *   Alias for Mpu region 3
40 */
41 #define mpuREGION3 2U
42
43 /** @def mpuREGION4
44 *   @brief Mpu region 4
45 *
46 *   Alias for Mpu region 4
47 */
48 #define mpuREGION4 3U
49
50 /** @def mpuREGION5
51 *   @brief Mpu region 5
52 *
53 *   Alias for Mpu region 5
54 */
55 #define mpuREGION5 4U
56
57 /** @def mpuREGION6
58 *   @brief Mpu region 6
59 *
60 *   Alias for Mpu region 6
61 */
62 #define mpuREGION6 5U
63
64 /** @def mpuREGION7
65 *   @brief Mpu region 7
66 *
67 *   Alias for Mpu region 7
68 */
69 #define mpuREGION7 6U
70
71 /** @def mpuREGION8
72 *   @brief Mpu region 8
73 *
74 *   Alias for Mpu region 8
75 */
76 #define mpuREGION8 7U
77
78 /** @def mpuREGION9
79 *   @brief Mpu region 9
80 *
81 *   Alias for Mpu region 9
82 */
83 #define mpuREGION9 8U
84
85 /** @def mpuREGION10
86 *   @brief Mpu region 10
87 *
88 *   Alias for Mpu region 10
89 */
90 #define mpuREGION10 9U
91
92 /** @def mpuREGION11
93 *   @brief Mpu region 11
94 *
95 *   Alias for Mpu region 11
96 */
97 #define mpuREGION11 10U
98
99 /** @def mpuREGION12
100 *   @brief Mpu region 12
101 *
102 *   Alias for Mpu region 12
103 */
104 #define mpuREGION12 11U
105
106
107
108
109 /** @enum mpuRegionAccessPermission
110 *   @brief Alias names for mpu region access permissions
111 *
112 *   This enumeration is used to provide alias names for the mpu region access permission:
113 *     - MPU_PRIV_NA_USER_NA_EXEC no access in priviledged mode, no access in user mode and execute
114 *     - MPU_PRIV_RW_USER_NA_EXEC read/write in priviledged mode, no access in user mode and execute
115 *     - MPU_PRIV_RW_USER_RO_EXEC read/write in priviledged mode, read only in user mode and execute
116 *     - MPU_PRIV_RW_USER_RW_EXEC read/write in priviledged mode, read/write in user mode and execute
117 *     - MPU_PRIV_RO_USER_NA_EXEC read only in priviledged mode, no access in user mode and execute
118 *     - MPU_PRIV_RO_USER_RO_EXEC read only in priviledged mode, read only in user mode and execute
119 *     - MPU_PRIV_NA_USER_NA_NOEXEC no access in priviledged mode, no access in user mode and no execution
120 *     - MPU_PRIV_RW_USER_NA_NOEXEC read/write in priviledged mode, no access in user mode and no execution
121 *     - MPU_PRIV_RW_USER_RO_NOEXEC read/write in priviledged mode, read only in user mode and no execution
122 *     - MPU_PRIV_RW_USER_RW_NOEXEC read/write in priviledged mode, read/write in user mode and no execution
123 *     - MPU_PRIV_RO_USER_NA_NOEXEC read only in priviledged mode, no access in user mode and no execution
124 *     - MPU_PRIV_RO_USER_RO_NOEXEC read only in priviledged mode, read only in user mode and no execution
125 *
126 */
127 enum mpuRegionAccessPermission
128 {
129     MPU_PRIV_NA_USER_NA_EXEC   = 0x0000, /**< Alias no access in priviledged mode, no access in user mode and execute */
130     MPU_PRIV_RW_USER_NA_EXEC   = 0x0100, /**< Alias no read/write in priviledged mode, no access in user mode and execute */
131     MPU_PRIV_RW_USER_RO_EXEC   = 0x0200, /**< Alias no read/write in priviledged mode, read only in user mode and execute */
132     MPU_PRIV_RW_USER_RW_EXEC   = 0x0300, /**< Alias no read/write in priviledged mode, read/write in user mode and execute */
133     MPU_PRIV_RO_USER_NA_EXEC   = 0x0500, /**< Alias no read only in priviledged mode, no access in user mode and execute */
134     MPU_PRIV_RO_USER_RO_EXEC   = 0x0600, /**< Alias no read only in priviledged mode, read only in user mode and execute */
135     MPU_PRIV_NA_USER_NA_NOEXEC = 0x1000, /**< Alias no access in priviledged mode, no access in user mode and no execution */
136     MPU_PRIV_RW_USER_NA_NOEXEC = 0x1100, /**< Alias no read/write in priviledged mode, no access in user mode and no execution */
137     MPU_PRIV_RW_USER_RO_NOEXEC = 0x1200, /**< Alias no read/write in priviledged mode, read only in user mode and no execution */
138     MPU_PRIV_RW_USER_RW_NOEXEC = 0x1300, /**< Alias no read/write in priviledged mode, read/write in user mode and no execution */
139     MPU_PRIV_RO_USER_NA_NOEXEC = 0x1500, /**< Alias no read only in priviledged mode, no access in user mode and no execution */
140     MPU_PRIV_RO_USER_RO_NOEXEC = 0x1600  /**< Alias no read only in priviledged mode, read only in user mode and no execution */
141 };
142
143 /** @enum mpuRegionType
144 *   @brief Alias names for mpu region type
145 *
146 *   This enumeration is used to provide alias names for the mpu region type:
147 *     - MPU_STRONGLYORDERED_SHAREABLE Memory type strongly ordered and shareable
148 *     - MPU_DEVICE_SHAREABLE          Memory type device and shareable
149 *     - MPU_NORMAL_OIWTNOWA_NONSHARED Memory type normal outer and inner write-through, no write allocate and non shared
150 *     - MPU_NORMAL_OIWTNOWA_SHARED    Memory type normal outer and inner write-through, no write allocate and shared
151 *     - MPU_NORMAL_OIWBNOWA_NONSHARED Memory type normal outer and inner write-back, no write allocate and non shared
152 *     - MPU_NORMAL_OIWBNOWA_SHARED    Memory type normal outer and inner write-back, no write allocate and shared
153 *     - MPU_NORMAL_OINC_NONSHARED     Memory type normal outer and inner non-cachable and non shared
154 *     - MPU_NORMAL_OINC_SHARED        Memory type normal outer and inner non-cachable and shared
155 *     - MPU_NORMAL_OIWBWA_NONSHARED   Memory type normal outer and inner write-back, write allocate and non shared
156 *     - MPU_NORMAL_OIWBWA_SHARED      Memory type normal outer and inner write-back, write allocate and shared
157 *     - MPU_DEVICE_NONSHAREABLE       Memory type device and non shareable
158 */
159 enum mpuRegionType
160 {
161     MPU_STRONGLYORDERED_SHAREABLE = 0x0000, /**< Memory type strongly ordered and shareable */
162     MPU_DEVICE_SHAREABLE          = 0x0001, /**< Memory type device and shareable */
163     MPU_NORMAL_OIWTNOWA_NONSHARED = 0x0002, /**< Memory type normal outer and inner write-through, no write allocate and non shared */
164     MPU_NORMAL_OIWBNOWA_NONSHARED = 0x0003, /**< Memory type normal outer and inner write-back, no write allocate and non shared */
165     MPU_NORMAL_OIWTNOWA_SHARED    = 0x0006, /**< Memory type normal outer and inner write-through, no write allocate and shared */
166     MPU_NORMAL_OIWBNOWA_SHARED    = 0x0007, /**< Memory type normal outer and inner write-back, no write allocate and shared */
167     MPU_NORMAL_OINC_NONSHARED     = 0x0008, /**< Memory type normal outer and inner non-cachable and non shared */
168     MPU_NORMAL_OIWBWA_NONSHARED   = 0x000B, /**< Memory type normal outer and inner write-back, write allocate and non shared */
169     MPU_NORMAL_OINC_SHARED        = 0x000C, /**< Memory type normal outer and inner non-cachable and shared */
170     MPU_NORMAL_OIWBWA_SHARED      = 0x000F, /**< Memory type normal outer and inner write-back, write allocate and shared */
171     MPU_DEVICE_NONSHAREABLE       = 0x0010  /**< Memory type device and non shareable */
172 };
173
174 /** @enum mpuRegionSize
175 *   @brief Alias names for mpu region type
176 *
177 *   This enumeration is used to provide alias names for the mpu region type:
178 *     - MPU_STRONGLYORDERED_SHAREABLE Memory type strongly ordered and shareable
179 *     - MPU_32_BYTES Memory size in bytes
180 *     - MPU_64_BYTES Memory size in bytes
181 *     - MPU_128_BYTES Memory size in bytes
182 *     - MPU_256_BYTES Memory size in bytes
183 *     - MPU_512_BYTES Memory size in bytes
184 *     - MPU_1_KB Memory size in kB
185 *     - MPU_2_KB Memory size in kB
186 *     - MPU_4_KB Memory size in kB
187 *     - MPU_8_KB Memory size in kB
188 *     - MPU_16_KB Memory size in kB
189 *     - MPU_32_KB Memory size in kB
190 *     - MPU_64_KB Memory size in kB
191 *     - MPU_128_KB Memory size in kB
192 *     - MPU_256_KB  Memory size in kB
193 *     - MPU_512_KB Memory size in kB
194 *     - MPU_1_MB Memory size in MB
195 *     - MPU_2_MB Memory size in MB
196 *     - MPU_4_MB Memory size in MB
197 *     - MPU_8_MBv Memory size in MB
198 *     - MPU_16_MB Memory size in MB
199 *     - MPU_32_MB Memory size in MB
200 *     - MPU_64_MB Memory size in MB
201 *     - MPU_128_MB Memory size in MB
202 *     - MPU_256_MB Memory size in MB
203 *     - MPU_512_MB Memory size in MB
204 *     - MPU_1_GB Memory size in GB
205 *     - MPU_2_GB Memory size in GB
206 *     - MPU_4_GB Memory size in GB
207 */
208 enum mpuRegionSize
209 {
210     MPU_32_BYTES  = 0x04, /**< Memory size in bytes */
211     MPU_64_BYTES  = 0x05, /**< Memory size in bytes */
212     MPU_128_BYTES = 0x06, /**< Memory size in bytes */
213     MPU_256_BYTES = 0x07, /**< Memory size in bytes */
214     MPU_512_BYTES = 0x08, /**< Memory size in bytes */
215     MPU_1_KB      = 0x09, /**< Memory size in kB */
216     MPU_2_KB      = 0x0A, /**< Memory size in kB */
217     MPU_4_KB      = 0x0B, /**< Memory size in kB */
218     MPU_8_KB      = 0x0C, /**< Memory size in kB */
219     MPU_16_KB     = 0x0D, /**< Memory size in kB */
220     MPU_32_KB     = 0x0E, /**< Memory size in kB */
221     MPU_64_KB     = 0x0F, /**< Memory size in kB */
222     MPU_128_KB    = 0x10, /**< Memory size in kB */
223     MPU_256_KB    = 0x11, /**< Memory size in kB */
224     MPU_512_KB    = 0x12, /**< Memory size in kB */
225     MPU_1_MB      = 0x13, /**< Memory size in MB */
226     MPU_2_MB      = 0x14, /**< Memory size in MB */
227     MPU_4_MB      = 0x15, /**< Memory size in MB */
228     MPU_8_MB      = 0x16, /**< Memory size in MB */
229     MPU_16_MB     = 0x17, /**< Memory size in MB */
230     MPU_32_MB     = 0x18, /**< Memory size in MB */
231     MPU_64_MB     = 0x19, /**< Memory size in MB */
232     MPU_128_MB    = 0x1A, /**< Memory size in MB */
233     MPU_256_MB    = 0x1B, /**< Memory size in MB */
234     MPU_512_MB    = 0x1C, /**< Memory size in MB */
235     MPU_1_GB      = 0x1D, /**< Memory size in GB */
236     MPU_2_GB      = 0x1E, /**< Memory size in GB */
237     MPU_4_GB      = 0x1F  /**< Memory size in GB */
238 };
239
240 /** @fn void _mpuInit_(void)
241 *   @brief Initialize Mpu
242 *
243 *   This function initalizes memory protection unit.
244 */
245 void _mpuInit_(void);
246
247 /** @fn void _mpuEnable_(void)
248 *   @brief Enable Mpu
249 *
250 *   This function enables memory protection unit.
251 */
252 void _mpuEnable_(void);
253
254 /** @fn void _mpuDisable_(void)
255 *   @brief Disable Mpu
256 *
257 *   This function disables memory protection unit.
258 */
259 void _mpuDisable_(void);
260
261 /** @fn void _mpuEnableBackgroundRegion_(void)
262 *   @brief Enable Mpu background region
263 *
264 *   This function enables background region of the memory protection unit.
265 */
266 void _mpuEnableBackgroundRegion_(void);
267
268 /** @fn void _mpuDisableBackgroundRegion_(void)
269 *   @brief Disable Mpu background region
270 *
271 *   This function disables background region of the memory protection unit.
272 */
273 void _mpuDisableBackgroundRegion_(void);
274
275 /** @fn uint32_t _mpuGetNumberOfRegions_(void)
276 *   @brief Returns number of implemented Mpu regions
277 *   @return Number of implemented mpu regions
278 *
279 *   This function returns the number of implemented mpu regions.
280 */
281 uint32_t _mpuGetNumberOfRegions_(void);
282
283 /** @fn uint32_t _mpuAreRegionsSeparate_(void)
284 *   @brief Returns the type of the implemented mpu regions
285 *   @return Mpu type of regions
286 *
287 *   This function returns 0 when mpu regions are of type unified atherwise regions are of type separate.
288 */
289 uint32_t _mpuAreRegionsSeparate_(void);
290
291 /** @fn void _mpuSetRegion_(uint32_t region)
292 *   @brief Set mpu region number
293 *
294 *   This function selects one of the implemented mpu regions.
295 */
296 void _mpuSetRegion_(uint32_t region);
297
298 /** @fn uint32_t _mpuGetRegion_(void)
299 *   @brief Returns the currently selected mpu region
300 *   @return Mpu region number
301 *
302 *   This function returns currently selected mpu region number.
303 */
304 uint32_t _mpuGetRegion_(void);
305
306 /** @fn void _mpuSetRegionBaseAddress_(uint32_t address)
307 *   @brief Set base address of currently selected mpu region
308 *   @note The base address must always aligned with region size
309 *
310 *   This function sets the base address of currently selected mpu region.
311 */
312 void _mpuSetRegionBaseAddress_(uint32_t address);
313
314 /** @fn uint32_t _mpuGetRegionBaseAddress_(void)
315 *   @brief Returns base address of currently selected mpu region
316 *   @return Current base address of selected mpu region
317 *
318 *   This function returns the base address of currently selected mpu region.
319 */
320 uint32_t _mpuGetRegionBaseAddress_(void);
321
322 /** @fn void _mpuSetRegionTypeAndPermission_(uint32_t type, uint32_t permission)
323 *   @brief Set type of currently selected mpu region
324 *
325 *   This function sets the type of currently selected mpu region.
326 */
327 void _mpuSetRegionTypeAndPermission_(uint32_t type, uint32_t permission);
328
329 /** @fn uint32_t _mpuGetRegionType_(void)
330 *   @brief Returns the type of currently selected mpu region
331 *   @return Current type of selected mpu region
332 *
333 *   This function returns the type of currently selected mpu region.
334 */
335 uint32_t _mpuGetRegionType_(void);
336
337 /** @fn uint32_t _mpuGetRegionPermission_(void)
338 *   @brief Returns permission of currently selected mpu region
339 *   @return Current type of selected mpu region
340 *
341 *   This function returns permission of currently selected mpu region.
342 */
343 uint32_t _mpuGetRegionPermission_(void);
344
345 /** @fn void _mpuSetRegionSizeRegister_(uint32_t value)
346 *   @brief Set mpu region size register value
347 *
348 *   This function sets mpu region size register value.
349 */
350 void _mpuSetRegionSizeRegister_(uint32_t value);
351
352 #endif