AM263x MCU+ SDK  08.02.00
MPU for ARMv7 (ARM R5, ARM M4)

Features Supported

  • APIs to setup MPU regions, including region address, size, attributes like access permissions, cache properties
  • APIs to enable, disable MPU
  • API to check if MPU is enabled

Features NOT Supported

NA

Important Usage Guidelines

  • Refer to ARMv7-R or ARMv7-M architecture manual for more details
  • The number of MPU entries varies based on the ARM R5, ARM M4 instantiated in a given DEVICE, refer DEVICE datasheet for more details.
  • In R5 for this DEVICE, there are 16 MPU regions
  • In M4 for this DEVICE, there are 16 MPU regions
  • MPU regions can overlap each other, with higher numbered regions taking more precedence in case of address overlaps.

Example Usage

Include the below file to access the APIs,

Example to setup MPU regions and enable MPU is shown below,

#define MAX_REGIONS (16u) /* Max regions on a R5F */
MpuP_RegionAttrs regionParams;
uint32_t regionId = 0;
/* recommend to disable Cache and MPU before setting up MPU regions */
/* make all 4G as strongly ordered, non-cacheable */
MpuP_RegionAttrs_init(&regionParams);
regionParams.isEnable = 1;
regionParams.isCacheable = 0;
regionParams.isBufferable = 0;
regionParams.isSharable = 1;
regionParams.isExecuteNever = 1; /* dont allow code execution */
regionParams.tex = 0;
regionParams.accessPerm = MpuP_AP_S_RW;
MpuP_setRegion(regionId, (void*)0x00000000, MpuP_RegionSize_4G, &regionParams);
regionId++;
/* make ATCM as cacheable */
MpuP_RegionAttrs_init(&regionParams);
regionParams.isEnable = 1;
regionParams.isCacheable = 1;
regionParams.isBufferable = 1;
regionParams.isSharable = 0;
regionParams.isExecuteNever = 0; /* allow code execution */
regionParams.tex = 1;
regionParams.accessPerm = MpuP_AP_S_RW;
MpuP_setRegion(regionId, (void*)0x00000000, MpuP_RegionSize_32K, &regionParams);
regionId++;
/* make memory region as strongly ordered, non-cacheable */
MpuP_RegionAttrs_init(&regionParams);
regionParams.isEnable = 1;
regionParams.isCacheable = 0;
regionParams.isBufferable = 0;
regionParams.isSharable = 1;
regionParams.isExecuteNever = 1; /* dont allow code execution */
regionParams.tex = 0;
regionParams.accessPerm = MpuP_AP_S_RW;
MpuP_setRegion(regionId, (void*)0x02000000, MpuP_RegionSize_32K, &regionParams);
regionId++;
if(regionId >= MAX_REGIONS)
{
while(1) { ; }
/* Typically MPU setup happens very early in the boot sequence,
* at this point DebugP_assert(), DebugP_log() are not available
*/
}
/* enable Cache and MPU after setting up MPU regions */

API

APIs for MPU for ARMv7 (ARM R5, ARM M4)

CacheP_enable
void CacheP_enable(uint32_t type)
Cache enable.
MpuP_RegionAttrs::tex
uint8_t tex
Definition: MpuP_armv7.h:114
MpuP_RegionAttrs_init
void MpuP_RegionAttrs_init(MpuP_RegionAttrs *region)
Set default values to MpuP_RegionAttrs.
CacheP_disable
void CacheP_disable(uint32_t type)
Cache disable.
MpuP_RegionSize_4G
@ MpuP_RegionSize_4G
Definition: MpuP_armv7.h:96
MpuP_enable
void MpuP_enable()
Enable MPU sub-system using the region that are setup using MpuP_setRegion.
MpuP_disable
void MpuP_disable()
Disable MPU sub-system.
MpuP_RegionAttrs::isCacheable
uint8_t isCacheable
Definition: MpuP_armv7.h:110
MpuP_RegionAttrs::isExecuteNever
uint8_t isExecuteNever
Definition: MpuP_armv7.h:113
MpuP_RegionAttrs::isSharable
uint8_t isSharable
Definition: MpuP_armv7.h:112
CacheP.h
MpuP_RegionAttrs::isEnable
uint8_t isEnable
Definition: MpuP_armv7.h:109
CacheP_TYPE_ALL
@ CacheP_TYPE_ALL
Definition: CacheP.h:74
MpuP_armv7.h
MpuP_RegionAttrs::accessPerm
uint8_t accessPerm
Definition: MpuP_armv7.h:115
MpuP_RegionAttrs
Attribute's to apply for a MPU region.
Definition: MpuP_armv7.h:107
MpuP_RegionSize_32K
@ MpuP_RegionSize_32K
Definition: MpuP_armv7.h:79
MpuP_AP_S_RW
@ MpuP_AP_S_RW
Definition: MpuP_armv7.h:58
MpuP_setRegion
void MpuP_setRegion(uint32_t regionNum, void *addr, uint32_t size, MpuP_RegionAttrs *attrs)
Setup a region in the MPU.
MpuP_RegionAttrs::isBufferable
uint8_t isBufferable
Definition: MpuP_armv7.h:111