RTEMS 6.1-rc6
Loading...
Searching...
No Matches
Files | Data Structures | Macros | Functions | Variables

This group provides support functions to manage an Arm PMSAv8-32 (Protected Memory System Architecture) based Memory Protection Unit (MPU). More...

Files

file  aarch32-psma-init-default.c
 This source file contains the implementation of _AArch32_PMSA_Initialize_default().
 
file  aarch32-psma-init.c
 This source file contains the implementation of _AArch32_PMSA_Initialize().
 
file  aarch32-pmsa.h
 This header file provides the API to manage an Arm PMSAv8-32 based Memory Protection Unit (MPU).
 

Data Structures

struct  AArch32_PMSA_Section
 The section definition is used to initialize the Memory Protection Unit (MPU). More...
 
struct  AArch32_PMSA_Region
 The region definition is used to configure the Memory Protection Unit (MPU). More...
 

Macros

#define AARCH32_PMSA_MIN_REGION_ALIGN   64
 
#define AARCH32_PMSA_ATTR_EN   0x1U
 
#define AARCH32_PMSA_ATTR_IDX_SHIFT   1
 
#define AARCH32_PMSA_ATTR_IDX_MASK   0xeU
 
#define AARCH32_PMSA_ATTR_IDX(_idx)    ( ( _idx ) << AARCH32_PMSA_ATTR_IDX_SHIFT )
 
#define AARCH32_PMSA_ATTR_XN   0x40U
 
#define AARCH32_PMSA_ATTR_AP_SHIFT   7
 
#define AARCH32_PMSA_ATTR_AP_MASK   0x18U
 
#define AARCH32_PMSA_ATTR_AP(_ap)    ( ( _ap ) << AARCH32_PMSA_ATTR_AP_SHIFT )
 
#define AARCH32_PMSA_ATTR_AP_EL1_RW_EL0_NO   0x0U
 
#define AARCH32_PMSA_ATTR_AP_EL1_RW_EL0_RW   0x1U
 
#define AARCH32_PMSA_ATTR_AP_EL1_RO_EL0_NO   0x2U
 
#define AARCH32_PMSA_ATTR_AP_EL1_RO_EL0_RO   0x3U
 
#define AARCH32_PMSA_ATTR_SH_SHIFT   9
 
#define AARCH32_PMSA_ATTR_SH_MASK   0x600U
 
#define AARCH32_PMSA_ATTR_SH(_sh)    ( ( _sh ) << AARCH32_PMSA_ATTR_SH_SHIFT )
 
#define AARCH32_PMSA_ATTR_SH_NO   0x0U
 
#define AARCH32_PMSA_ATTR_SH_RES   0x1U
 
#define AARCH32_PMSA_ATTR_SH_OUTER   0x2U
 
#define AARCH32_PMSA_ATTR_SH_INNER   0x3U
 
#define AARCH32_PMSA_MEM_DEVICE_NG_NR_NE   0x00U
 
#define AARCH32_PMSA_MEM_DEVICE_NG_NR_E   0x04U
 
#define AARCH32_PMSA_MEM_DEVICE_NG_R_E   0x08U
 
#define AARCH32_PMSA_MEM_DEVICE_G_R_E   0x0cU
 
#define AARCH32_PMSA_MEM_OUTER_WTT   0x00U
 
#define AARCH32_PMSA_MEM_OUTER_NC   0x40U
 
#define AARCH32_PMSA_MEM_OUTER_WBT   0x40U
 
#define AARCH32_PMSA_MEM_OUTER_WTNT   0x80U
 
#define AARCH32_PMSA_MEM_OUTER_WBNT   0xc0U
 
#define AARCH32_PMSA_MEM_OUTER_RA   0x20U
 
#define AARCH32_PMSA_MEM_OUTER_WA   0x10U
 
#define AARCH32_PMSA_MEM_INNER_WTT   0x00U
 
#define AARCH32_PMSA_MEM_INNER_NC   0x04U
 
#define AARCH32_PMSA_MEM_INNER_WBT   0x04U
 
#define AARCH32_PMSA_MEM_INNER_WTNT   0x08U
 
#define AARCH32_PMSA_MEM_INNER_WBNT   0x0cU
 
#define AARCH32_PMSA_MEM_INNER_RA   0x02U
 
#define AARCH32_PMSA_MEM_INNER_WA   0x01U
 
#define AARCH32_PMSA_MEM_ATTR(_ma0, _ma1, _ma2, _ma3)    ( ( _ma0 ) | ( ( _ma1 ) << 8 ) | ( ( _ma2 ) << 16 ) | ( ( _ma3 ) << 24 ) )
 
#define AARCH32_PMSA_MEM_ATTR_DEFAULT_CACHED
 
#define AARCH32_PMSA_MEM_ATTR_DEFAULT_UNCACHED
 
#define AARCH32_PMSA_MEM_ATTR_DEFAULT_DEVICE    AARCH32_PMSA_MEM_DEVICE_NG_NR_NE
 
#define AARCH32_PMSA_CODE_CACHED
 
#define AARCH32_PMSA_CODE_UNCACHED
 
#define AARCH32_PMSA_DATA_READ_ONLY_CACHED
 
#define AARCH32_PMSA_DATA_READ_ONLY_UNCACHED
 
#define AARCH32_PMSA_DATA_READ_WRITE_CACHED
 
#define AARCH32_PMSA_DATA_READ_WRITE_UNCACHED
 
#define AARCH32_PMSA_DATA_READ_WRITE_SHARED
 
#define AARCH32_PMSA_DEVICE
 
#define AARCH32_PMSA_DATA_READ_WRITE_DEFAULT    AARCH32_PMSA_DATA_READ_WRITE_CACHED
 
#define AARCH32_PMSA_DEFAULT_SECTIONS
 The default section definitions shall be used by the BSP to define _AArch32_PMSA_Sections.
 

Functions

void _AArch32_PMSA_Initialize (uint32_t memory_attributes_0, uint32_t memory_attributes_1, const AArch32_PMSA_Section *sections, size_t section_count)
 Initializes the Memory Protection Unit (MPU).
 
size_t _AArch32_PMSA_Map_sections_to_regions (const AArch32_PMSA_Section *sections, size_t section_count, AArch32_PMSA_Region *regions, size_t region_max)
 Maps the section definitions to region definitions.
 
void _AArch32_PMSA_Initialize_default (void)
 Initializes the Memory Protection Unit (MPU) using the section definitions with default memory attributes.
 

Variables

const AArch32_PMSA_Section _AArch32_PMSA_Sections []
 This array provides section definitions to initialize the memory protection unit (MPU).
 
const size_t _AArch32_PMSA_Section_count
 This constant provides the count of elements in _AArch32_PMSA_Sections.
 

Detailed Description

This group provides support functions to manage an Arm PMSAv8-32 (Protected Memory System Architecture) based Memory Protection Unit (MPU).

Macro Definition Documentation

◆ AARCH32_PMSA_CODE_CACHED

#define AARCH32_PMSA_CODE_CACHED
Value:
( AARCH32_PMSA_ATTR_EN | \
AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RO_EL0_NO ) | \
AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
AARCH32_PMSA_ATTR_IDX( 0U ) )

◆ AARCH32_PMSA_CODE_UNCACHED

#define AARCH32_PMSA_CODE_UNCACHED
Value:
( AARCH32_PMSA_ATTR_EN | \
AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RO_EL0_NO ) | \
AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
AARCH32_PMSA_ATTR_IDX( 1U ) )

◆ AARCH32_PMSA_DATA_READ_ONLY_CACHED

#define AARCH32_PMSA_DATA_READ_ONLY_CACHED
Value:
( AARCH32_PMSA_ATTR_EN | \
AARCH32_PMSA_ATTR_XN | \
AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RO_EL0_NO ) | \
AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
AARCH32_PMSA_ATTR_IDX( 0U ) )

◆ AARCH32_PMSA_DATA_READ_ONLY_UNCACHED

#define AARCH32_PMSA_DATA_READ_ONLY_UNCACHED
Value:
( AARCH32_PMSA_ATTR_EN | \
AARCH32_PMSA_ATTR_XN | \
AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RO_EL0_NO ) | \
AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
AARCH32_PMSA_ATTR_IDX( 1U ) )

◆ AARCH32_PMSA_DATA_READ_WRITE_CACHED

#define AARCH32_PMSA_DATA_READ_WRITE_CACHED
Value:
( AARCH32_PMSA_ATTR_EN | \
AARCH32_PMSA_ATTR_XN | \
AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RW_EL0_NO ) | \
AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
AARCH32_PMSA_ATTR_IDX( 0U ) )

◆ AARCH32_PMSA_DATA_READ_WRITE_SHARED

#define AARCH32_PMSA_DATA_READ_WRITE_SHARED
Value:
( AARCH32_PMSA_ATTR_EN | \
AARCH32_PMSA_ATTR_XN | \
AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RW_EL0_NO ) | \
AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_OUTER ) | \
AARCH32_PMSA_ATTR_IDX( 1U ) )

◆ AARCH32_PMSA_DATA_READ_WRITE_UNCACHED

#define AARCH32_PMSA_DATA_READ_WRITE_UNCACHED
Value:
( AARCH32_PMSA_ATTR_EN | \
AARCH32_PMSA_ATTR_XN | \
AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RW_EL0_NO ) | \
AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
AARCH32_PMSA_ATTR_IDX( 1U ) )

◆ AARCH32_PMSA_DEFAULT_SECTIONS

#define AARCH32_PMSA_DEFAULT_SECTIONS

The default section definitions shall be used by the BSP to define _AArch32_PMSA_Sections.

In addition to the default section definitions, the BSP should provide section definitions for the memory-mapped devices and other memory areas.

◆ AARCH32_PMSA_DEVICE

#define AARCH32_PMSA_DEVICE
Value:
( AARCH32_PMSA_ATTR_EN | \
AARCH32_PMSA_ATTR_XN | \
AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RW_EL0_NO ) | \
AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
AARCH32_PMSA_ATTR_IDX( 2U ) )

◆ AARCH32_PMSA_MEM_ATTR_DEFAULT_CACHED

#define AARCH32_PMSA_MEM_ATTR_DEFAULT_CACHED
Value:
( AARCH32_PMSA_MEM_OUTER_WBNT | \
AARCH32_PMSA_MEM_OUTER_RA | \
AARCH32_PMSA_MEM_OUTER_WA | \
AARCH32_PMSA_MEM_INNER_WBNT | \
AARCH32_PMSA_MEM_INNER_RA | \
AARCH32_PMSA_MEM_INNER_WA )

◆ AARCH32_PMSA_MEM_ATTR_DEFAULT_UNCACHED

#define AARCH32_PMSA_MEM_ATTR_DEFAULT_UNCACHED
Value:
( AARCH32_PMSA_MEM_OUTER_NC | \
AARCH32_PMSA_MEM_INNER_NC )

Function Documentation

◆ _AArch32_PMSA_Initialize()

void _AArch32_PMSA_Initialize ( uint32_t  memory_attributes_0,
uint32_t  memory_attributes_1,
const AArch32_PMSA_Section sections,
size_t  section_count 
)

Initializes the Memory Protection Unit (MPU).

The section definitions are used to define the regions of the MPU. Sections are merged if possible to reduce the count of used regions. If too many regions are used, then the MPU is not enabled. Overlapping section definitions result in undefined system behaviour.

The function shall be called while the MPU is disabled.

Parameters
memory_attributes_0are the memory attributes for MAIR0.
memory_attributes_1are the memory attributes for MAIR1.
sectionsis the array with section definitions.
section_countis the count of section definitions.

◆ _AArch32_PMSA_Initialize_default()

void _AArch32_PMSA_Initialize_default ( void  )

Initializes the Memory Protection Unit (MPU) using the section definitions with default memory attributes.

Calls _AArch32_PMSA_Initialize() using _AArch32_PMSA_Sections and _AArch32_PMSA_Section_count and the default memory attributes.

◆ _AArch32_PMSA_Map_sections_to_regions()

size_t _AArch32_PMSA_Map_sections_to_regions ( const AArch32_PMSA_Section sections,
size_t  section_count,
AArch32_PMSA_Region regions,
size_t  region_max 
)

Maps the section definitions to region definitions.

The section definitions are used to define the regions of the MPU. Sections are merged if possible to reduce the count of used regions. If too many regions are used, then zero is returned. Overlapping section definitions result in undefined system behaviour.

Parameters
sectionsis the array with section definitions to map to regions.
section_countis the count of section definitions.
regionsis the array with usable region definitions.
region_maxis the count of usable region definitions.
Returns
Returns the count of actually used regions.

Variable Documentation

◆ _AArch32_PMSA_Sections

const AArch32_PMSA_Section _AArch32_PMSA_Sections[]
extern

This array provides section definitions to initialize the memory protection unit (MPU).

The BSP shall provide the section definitions with the help of AARCH32_PMSA_DEFAULT_SECTIONS. The section count is provided by _AArch32_PMSA_Section_count.