MPUEMLIB

Detailed Description

Memory Protection Unit (MPU) Peripheral API.

Deprecated:
These functions are deprecated and marked for removal in a later release. Use ARM's ARM_MPU_xxx API instead. See file platform/CMSIS/Include/mpu_armv7.h or mpu_armv8.h

This module contains functions to enable, disable, and set up MPU. MPU is used to control access attributes and permissions in the memory map. The settings that can be controlled are:

  • Executable attribute.
  • Cachable, bufferable and shareable attributes.
  • Cache policy.
  • Access permissions: Privileged or User state, read or write access, and combinations of all these.

The MPU module can be activated and deactivated with functions:

*  MPU_Enable(..);
*  MPU_Disable();

The MPU module can control 8 memory regions with individual access control settings. Section attributes and permissions are set with:

*  MPU_ConfigureRegion(..);

It is advisable to disable MPU when altering region settings.

Data Structures

struct MPU_RegionInit_TypeDef

Macros

#define MPU_CTRL_HFNMIENA MPU_CTRL_HFNMIENA_Msk
#define MPU_CTRL_PRIVDEFENA MPU_CTRL_PRIVDEFENA_Msk
#define MPU_INIT_FLASH_DEFAULT
#define MPU_INIT_PERIPHERAL_DEFAULT
#define MPU_INIT_SRAM_DEFAULT

Enumerations

enum MPU_RegionAp_TypeDef {
mpuRegionNoAccess = 0,
mpuRegionApPRw = 1,
mpuRegionApPRwURo = 2,
mpuRegionApFullAccess = 3,
mpuRegionApPRo = 5,
mpuRegionApPRo_URo = 6
}
enum MPU_RegionSize_TypeDef {
mpuRegionSize32b = 4,
mpuRegionSize64b = 5,
mpuRegionSize128b = 6,
mpuRegionSize256b = 7,
mpuRegionSize512b = 8,
mpuRegionSize1Kb = 9,
mpuRegionSize2Kb = 10,
mpuRegionSize4Kb = 11,
mpuRegionSize8Kb = 12,
mpuRegionSize16Kb = 13,
mpuRegionSize32Kb = 14,
mpuRegionSize64Kb = 15,
mpuRegionSize128Kb = 16,
mpuRegionSize256Kb = 17,
mpuRegionSize512Kb = 18,
mpuRegionSize1Mb = 19,
mpuRegionSize2Mb = 20,
mpuRegionSize4Mb = 21,
mpuRegionSize8Mb = 22,
mpuRegionSize16Mb = 23,
mpuRegionSize32Mb = 24,
mpuRegionSize64Mb = 25,
mpuRegionSize128Mb = 26,
mpuRegionSize256Mb = 27,
mpuRegionSize512Mb = 28,
mpuRegionSize1Gb = 29,
mpuRegionSize2Gb = 30,
mpuRegionSize4Gb = 31
}

Functions

void MPU_ConfigureRegion (const MPU_RegionInit_TypeDef *init)
Configure the MPU region.
__STATIC_INLINE void MPU_Disable (void)
Disable the MPU.
__STATIC_INLINE void MPU_Enable (uint32_t flags)
Enable the MPU.

Macro Definition Documentation

#define MPU_CTRL_HFNMIENA   MPU_CTRL_HFNMIENA_Msk

Argument to MPU_enable(). Enables MPU during hard fault, NMI, and FAULTMASK handlers.

Definition at line 67 of file em_mpu.h .

#define MPU_CTRL_PRIVDEFENA   MPU_CTRL_PRIVDEFENA_Msk

Argument to MPU_enable(). Enables privileged access to default memory map.

Definition at line 62 of file em_mpu.h .

#define MPU_INIT_FLASH_DEFAULT
Value:
{ \
true, /* Enable MPU region. */ \
0, /* MPU Region number. */ \
FLASH_MEM_BASE, /* Flash base address. */ \
mpuRegionSize1Mb, /* Size - Set to max. */ \
mpuRegionApFullAccess, /* Access permissions. */ \
false, /* Execution allowed. */ \
false, /* Not shareable. */ \
true, /* Cacheable. */ \
false, /* Not to be buffered. */ \
0, /* No subregions. */ \
0 /* No TEX attributes. */ \
}

Default configuration of MPU region initialization structure for flash memory.

Definition at line 140 of file em_mpu.h .

#define MPU_INIT_PERIPHERAL_DEFAULT
Value:
{ \
true, /* Enable MPU region. */ \
0, /* MPU Region number. */ \
0, /* Region base address. */ \
mpuRegionSize32b, /* Size - Set to minimum */ \
mpuRegionApFullAccess, /* Access permissions. */ \
true, /* Execution not allowed. */ \
true, /* Shareable. */ \
false, /* Not cacheable. */ \
true, /* To be buffered. */ \
0, /* No subregions. */ \
0 /* No TEX attributes. */ \
}

Default configuration of MPU region initialization structure for on-chip peripherals.

Definition at line 174 of file em_mpu.h .

#define MPU_INIT_SRAM_DEFAULT
Value:
{ \
true, /* Enable MPU region. */ \
1, /* MPU Region number. */ \
RAM_MEM_BASE, /* SRAM base address. */ \
mpuRegionSize128Kb, /* Size - Set to max. */ \
mpuRegionApFullAccess, /* Access permissions. */ \
false, /* Execution allowed. */ \
true, /* Shareable. */ \
true, /* Cacheable. */ \
false, /* Not to be buffered. */ \
0, /* No subregions. */ \
0 /* No TEX attributes. */ \
}

Default configuration of MPU region initialization structure for static random access memory (SRAM).

Definition at line 157 of file em_mpu.h .

Enumeration Type Documentation

MPU region access permission attributes.

Enumerator
mpuRegionNoAccess

No access at all.

mpuRegionApPRw

Privileged state R/W only.

mpuRegionApPRwURo

Privileged state R/W, User state R only.

mpuRegionApFullAccess

R/W in Privileged and User state.

mpuRegionApPRo

Privileged R only.

mpuRegionApPRo_URo

R only in Privileged and User state.

Definition at line 110 of file em_mpu.h .

Size of an MPU region.

Enumerator
mpuRegionSize32b

32 byte region size.

mpuRegionSize64b

64 byte region size.

mpuRegionSize128b

128 byte region size.

mpuRegionSize256b

256 byte region size.

mpuRegionSize512b

512 byte region size.

mpuRegionSize1Kb

1K byte region size.

mpuRegionSize2Kb

2K byte region size.

mpuRegionSize4Kb

4K byte region size.

mpuRegionSize8Kb

8K byte region size.

mpuRegionSize16Kb

16K byte region size.

mpuRegionSize32Kb

32K byte region size.

mpuRegionSize64Kb

64K byte region size.

mpuRegionSize128Kb

128K byte region size.

mpuRegionSize256Kb

256K byte region size.

mpuRegionSize512Kb

512K byte region size.

mpuRegionSize1Mb

1M byte region size.

mpuRegionSize2Mb

2M byte region size.

mpuRegionSize4Mb

4M byte region size.

mpuRegionSize8Mb

8M byte region size.

mpuRegionSize16Mb

16M byte region size.

mpuRegionSize32Mb

32M byte region size.

mpuRegionSize64Mb

64M byte region size.

mpuRegionSize128Mb

128M byte region size.

mpuRegionSize256Mb

256M byte region size.

mpuRegionSize512Mb

512M byte region size.

mpuRegionSize1Gb

1G byte region size.

mpuRegionSize2Gb

2G byte region size.

mpuRegionSize4Gb

4G byte region size.

Definition at line 76 of file em_mpu.h .

Function Documentation

void MPU_ConfigureRegion ( const MPU_RegionInit_TypeDef * init )

Configure the MPU region.

Deprecated:
Deprecated and marked for removal in a later release. Use ARM's ARM_MPU_SetRegion(), ARM_MPU_SetRegionEx(), ARM_MPU_Load() or similar instead.

Writes to MPU RBAR and RASR registers. See Cortex-M3 Reference Manual, MPU chapter for more details. To disable a region, set init->regionNo to the desired value and init->regionEnable = false.

Parameters
[in] init A pointer to the structure containing the MPU region initialization information.

Definition at line 98 of file em_mpu.c .

References MPU_RegionInit_TypeDef::accessPermission , MPU_RegionInit_TypeDef::baseAddress , MPU_RegionInit_TypeDef::bufferable , MPU_RegionInit_TypeDef::cacheable , MPU_RegionInit_TypeDef::disableExec , MPU_RegionInit_TypeDef::regionEnable , MPU_RegionInit_TypeDef::regionNo , MPU_RegionInit_TypeDef::shareable , MPU_RegionInit_TypeDef::size , MPU_RegionInit_TypeDef::srd , and MPU_RegionInit_TypeDef::tex .

__STATIC_INLINE void MPU_Disable ( void )

Disable the MPU.

Deprecated:
Deprecated and marked for removal in a later release. Use ARM's ARM_MPU_Disable() instead.

Disable MPU and MPU fault exceptions.

Definition at line 204 of file em_mpu.h .

__STATIC_INLINE void MPU_Enable ( uint32_t flags )

Enable the MPU.

Deprecated:
Deprecated and marked for removal in a later release. Use ARM's ARM_MPU_Enable() instead.

Enable MPU and MPU fault exceptions.

Parameters
[in] flags Use a logical OR of MPU_CTRL_PRIVDEFENA and MPU_CTRL_HFNMIENA as needed.

Definition at line 224 of file em_mpu.h .