1 /*
2 * Copyright (C) 2018-2021 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 */
33 /**
34 * \file SafeRTOS_MPU.c
35 *
36 **/
37 #ifndef SAFERTOS_MPU_H
38 #define SAFERTOS_MPU_H
39 /* ========================================================================== */
40 /* Include Files */
41 /* ========================================================================== */
42 /* Generic headers */
43 #include <stdlib.h>
44 #include <stdint.h>
45 #include <string.h>
46 #include <ti/csl/csl_types.h>
48 /* SafeRTOS includes */
49 #include "SafeRTOS_API.h"
51 #define CSL_ARM_R5F_MPU_REGIONS_MAX ((uint32_t) 16U)
52 #define CSL_ARM_R5_MPU_REGION_SIZE_32BYTE ((uint32_t) 32U)
53 /** \brief Full access to privileged and user modes */
54 #define CSL_ARM_R5_ACC_PERM_PRIV_USR_RD_WR ((uint32_t) 0x3U)
55 /** \brief Cache Policy: Non-cacheable */
56 #define CSL_ARM_R5_CACHE_POLICY_NON_CACHEABLE ((uint32_t) 0x0U)
57 /** \brief Cache Policy: Write-back, write-allocate */
58 #define CSL_ARM_R5_CACHE_POLICY_WB_WA ((uint32_t) 0x1U)
59 /** \brief This should be passed to configuration. */
60 #define CSL_ARM_R5_MEM_ATTR_MAX ((uint32_t) 0x7U)
61 #define CSL_ARM_R5_MPU_REGION_AC_XN_SHIFT (0x0000000CU)
62 #define CSL_ARM_R5_MPU_REGION_AC_AP_SHIFT (0x00000008U)
63 #define CSL_ARM_R5_MPU_REGION_AC_S_SHIFT (0x00000002U)
64 #define CSL_ARM_R5_MPU_REGION_AC_TEX_SHIFT (0x00000003U)
65 #define CSL_ARM_R5_MPU_REGION_AC_CB_SHIFT (0x00000000U)
66 #define CSL_ARM_R5_MPU_REGION_AC_B_SHIFT (0x00000000U)
67 #define CSL_ARM_R5_MPU_REGION_AC_C_SHIFT (0x00000001U)
70 /* The structure passed to xMPUConfigureGlobalRegion() to configure the kernel
71 * with MPU global region id. */
72 typedef struct MPU_CONFIG_ACCESS
73 {
74 portUInt32Type ulexeNeverControl;
75 portUInt32Type ulaccessPermission;
76 portUInt32Type ulshareable;
77 portUInt32Type ulcacheable;
78 portUInt32Type ulcachePolicy;
79 portUInt32Type ulmemAttr;
80 }xMPU_CONFIG_ACCESS;
82 /* The structure passed to xMPUConfigureGlobalRegion() to configure the kernel
83 * with MPU global region id. */
84 typedef struct MPU_CONFIG_PARAMETERS
85 {
86 /**< Region number to configure.
87 * Range: 1 to (portmpuGLOBAL_CONFIGURABLE_REGION_LAST) */
88 portUInt32Type ulRegionNumber;
89 /**< Region base address: 32 bytes aligned. */
90 portUInt32Type ulRegionBeginAddress;
91 xMPU_CONFIG_ACCESS xRegionAccess;
92 portUInt32Type ulRegionSize;
93 portUInt32Type ulSubRegionDisable;
94 }xMPU_CONFIG_PARAMETERS;
96 #endif /* SAFERTOS_MPU_H */