|
@@ -21,13 +21,13 @@
|
|
* See the License for the specific language governing permissions and
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* limitations under the License.
|
|
*/
|
|
*/
|
|
-
|
|
|
|
|
|
+
|
|
#if defined ( __ICCARM__ )
|
|
#if defined ( __ICCARM__ )
|
|
#pragma system_include /* treat file as system include file for MISRA check */
|
|
#pragma system_include /* treat file as system include file for MISRA check */
|
|
#elif defined (__clang__)
|
|
#elif defined (__clang__)
|
|
#pragma clang system_header /* treat file as system include file */
|
|
#pragma clang system_header /* treat file as system include file */
|
|
#endif
|
|
#endif
|
|
-
|
|
|
|
|
|
+
|
|
#ifndef ARM_MPU_ARMV7_H
|
|
#ifndef ARM_MPU_ARMV7_H
|
|
#define ARM_MPU_ARMV7_H
|
|
#define ARM_MPU_ARMV7_H
|
|
|
|
|
|
@@ -79,12 +79,12 @@
|
|
|
|
|
|
/**
|
|
/**
|
|
* MPU Memory Access Attributes
|
|
* MPU Memory Access Attributes
|
|
-*
|
|
|
|
|
|
+*
|
|
* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
|
|
* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
|
|
* \param IsShareable Region is shareable between multiple bus masters.
|
|
* \param IsShareable Region is shareable between multiple bus masters.
|
|
* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache.
|
|
* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache.
|
|
* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
|
|
* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
|
|
-*/
|
|
|
|
|
|
+*/
|
|
#define ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable) \
|
|
#define ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable) \
|
|
((((TypeExtField ) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \
|
|
((((TypeExtField ) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \
|
|
(((IsShareable ) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \
|
|
(((IsShareable ) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \
|
|
@@ -93,7 +93,7 @@
|
|
|
|
|
|
/**
|
|
/**
|
|
* MPU Region Attribute and Size Register Value
|
|
* MPU Region Attribute and Size Register Value
|
|
-*
|
|
|
|
|
|
+*
|
|
* \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
|
|
* \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
|
|
* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
|
|
* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
|
|
* \param AccessAttributes Memory access attribution, see \ref ARM_MPU_ACCESS_.
|
|
* \param AccessAttributes Memory access attribution, see \ref ARM_MPU_ACCESS_.
|
|
@@ -104,10 +104,10 @@
|
|
((((DisableExec ) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \
|
|
((((DisableExec ) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \
|
|
(((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \
|
|
(((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \
|
|
(((AccessAttributes) ) & (MPU_RASR_TEX_Msk | MPU_RASR_S_Msk | MPU_RASR_C_Msk | MPU_RASR_B_Msk)))
|
|
(((AccessAttributes) ) & (MPU_RASR_TEX_Msk | MPU_RASR_S_Msk | MPU_RASR_C_Msk | MPU_RASR_B_Msk)))
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* MPU Region Attribute and Size Register Value
|
|
* MPU Region Attribute and Size Register Value
|
|
-*
|
|
|
|
|
|
+*
|
|
* \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
|
|
* \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
|
|
* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
|
|
* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
|
|
* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
|
|
* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
|
|
@@ -116,7 +116,7 @@
|
|
* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
|
|
* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
|
|
* \param SubRegionDisable Sub-region disable field.
|
|
* \param SubRegionDisable Sub-region disable field.
|
|
* \param Size Region size of the region to be configured, for example 4K, 8K.
|
|
* \param Size Region size of the region to be configured, for example 4K, 8K.
|
|
-*/
|
|
|
|
|
|
+*/
|
|
#define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \
|
|
#define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \
|
|
ARM_MPU_RASR_EX(DisableExec, AccessPermission, ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable), SubRegionDisable, Size)
|
|
ARM_MPU_RASR_EX(DisableExec, AccessPermission, ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable), SubRegionDisable, Size)
|
|
|
|
|
|
@@ -126,7 +126,7 @@
|
|
* - Shareable
|
|
* - Shareable
|
|
* - Non-cacheable
|
|
* - Non-cacheable
|
|
* - Non-bufferable
|
|
* - Non-bufferable
|
|
-*/
|
|
|
|
|
|
+*/
|
|
#define ARM_MPU_ACCESS_ORDERED ARM_MPU_ACCESS_(0U, 1U, 0U, 0U)
|
|
#define ARM_MPU_ACCESS_ORDERED ARM_MPU_ACCESS_(0U, 1U, 0U, 0U)
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -137,7 +137,7 @@
|
|
* - Bufferable (if shareable) or non-bufferable (if non-shareable)
|
|
* - Bufferable (if shareable) or non-bufferable (if non-shareable)
|
|
*
|
|
*
|
|
* \param IsShareable Configures the device memory as shareable or non-shareable.
|
|
* \param IsShareable Configures the device memory as shareable or non-shareable.
|
|
-*/
|
|
|
|
|
|
+*/
|
|
#define ARM_MPU_ACCESS_DEVICE(IsShareable) ((IsShareable) ? ARM_MPU_ACCESS_(0U, 1U, 0U, 1U) : ARM_MPU_ACCESS_(2U, 0U, 0U, 0U))
|
|
#define ARM_MPU_ACCESS_DEVICE(IsShareable) ((IsShareable) ? ARM_MPU_ACCESS_(0U, 1U, 0U, 1U) : ARM_MPU_ACCESS_(2U, 0U, 0U, 0U))
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -150,7 +150,7 @@
|
|
* \param OuterCp Configures the outer cache policy.
|
|
* \param OuterCp Configures the outer cache policy.
|
|
* \param InnerCp Configures the inner cache policy.
|
|
* \param InnerCp Configures the inner cache policy.
|
|
* \param IsShareable Configures the memory as shareable or non-shareable.
|
|
* \param IsShareable Configures the memory as shareable or non-shareable.
|
|
-*/
|
|
|
|
|
|
+*/
|
|
#define ARM_MPU_ACCESS_NORMAL(OuterCp, InnerCp, IsShareable) ARM_MPU_ACCESS_((4U | (OuterCp)), IsShareable, ((InnerCp) & 2U), ((InnerCp) & 1U))
|
|
#define ARM_MPU_ACCESS_NORMAL(OuterCp, InnerCp, IsShareable) ARM_MPU_ACCESS_((4U | (OuterCp)), IsShareable, ((InnerCp) & 2U), ((InnerCp) & 1U))
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -181,7 +181,7 @@ typedef struct {
|
|
uint32_t RBAR; //!< The region base address register value (RBAR)
|
|
uint32_t RBAR; //!< The region base address register value (RBAR)
|
|
uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR
|
|
uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR
|
|
} ARM_MPU_Region_t;
|
|
} ARM_MPU_Region_t;
|
|
-
|
|
|
|
|
|
+
|
|
/** Enable the MPU.
|
|
/** Enable the MPU.
|
|
* \param MPU_Control Default access permissions for unconfigured regions.
|
|
* \param MPU_Control Default access permissions for unconfigured regions.
|
|
*/
|
|
*/
|
|
@@ -219,7 +219,7 @@ __STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr)
|
|
/** Configure an MPU region.
|
|
/** Configure an MPU region.
|
|
* \param rbar Value for RBAR register.
|
|
* \param rbar Value for RBAR register.
|
|
* \param rsar Value for RSAR register.
|
|
* \param rsar Value for RSAR register.
|
|
-*/
|
|
|
|
|
|
+*/
|
|
__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr)
|
|
__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr)
|
|
{
|
|
{
|
|
MPU->RBAR = rbar;
|
|
MPU->RBAR = rbar;
|
|
@@ -230,7 +230,7 @@ __STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr)
|
|
* \param rnr Region number to be configured.
|
|
* \param rnr Region number to be configured.
|
|
* \param rbar Value for RBAR register.
|
|
* \param rbar Value for RBAR register.
|
|
* \param rsar Value for RSAR register.
|
|
* \param rsar Value for RSAR register.
|
|
-*/
|
|
|
|
|
|
+*/
|
|
__STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr)
|
|
__STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr)
|
|
{
|
|
{
|
|
MPU->RNR = rnr;
|
|
MPU->RNR = rnr;
|
|
@@ -246,7 +246,7 @@ __STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t r
|
|
__STATIC_INLINE void orderedCpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len)
|
|
__STATIC_INLINE void orderedCpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len)
|
|
{
|
|
{
|
|
uint32_t i;
|
|
uint32_t i;
|
|
- for (i = 0U; i < len; ++i)
|
|
|
|
|
|
+ for (i = 0U; i < len; ++i)
|
|
{
|
|
{
|
|
dst[i] = src[i];
|
|
dst[i] = src[i];
|
|
}
|
|
}
|
|
@@ -256,7 +256,7 @@ __STATIC_INLINE void orderedCpy(volatile uint32_t* dst, const uint32_t* __RESTRI
|
|
* \param table Pointer to the MPU configuration table.
|
|
* \param table Pointer to the MPU configuration table.
|
|
* \param cnt Amount of regions to be configured.
|
|
* \param cnt Amount of regions to be configured.
|
|
*/
|
|
*/
|
|
-__STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt)
|
|
|
|
|
|
+__STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt)
|
|
{
|
|
{
|
|
const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U;
|
|
const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U;
|
|
while (cnt > MPU_TYPE_RALIASES) {
|
|
while (cnt > MPU_TYPE_RALIASES) {
|