C Microkernel Realtime eXecutive
Realtime Operating System for Cortex-M based microcontrollers
 
Loading...
Searching...
No Matches

Description

Memory protection support internals for ARM architecture.

Modules

 ARM MPU CTRL fields
 
 ARM MPU RASR fields
 
 ARM MPU RBAR fields
 
 ARM MPU register aliases
 
 MPU region names
 Names of ARM MPU regions as being used by CMRX.
 

Macros

#define MPU_RNR_REGION   (MPU_RNR_REGION_Msk)
 
#define MPU_RNR_REGION_LSB   (MPU_RNR_REGION_Pos)
 
#define MPU_AP_MASK   0b0111
 
#define MPU_EXECUTE_SHIFT   3
 

Functions

int mpu_set_region (uint8_t region, const void *base, uint32_t size, uint8_t cls)
 Configure and activate MPU region.
 
int mpu_clear_region (uint8_t region)
 Disable MPU region.
 
int mpu_load (const MPU_State *state, uint8_t base, uint8_t count)
 
static const uint32_t __MPU_flags []
 MPU region access rights.
 
int mpu_configure_region (uint8_t region, const void *base, uint32_t size, uint8_t flags, uint32_t *RBAR, uint32_t *RASR)
 Create configuration for MPU region.
 
void hard_fault_handler (void)
 Handler for hard fault.
 
void mem_manage_handler (void)
 
static uint8_t log_2 (uint32_t num)
 
void mpu_enable ()
 Enable memory protection.
 
void mpu_disable ()
 Disable memory protection.
 
int mpu_store (MPU_State *hosted_state, MPU_State *parent_state)
 Store MPU settings.
 
int mpu_restore (const MPU_State *hosted_state, const MPU_State *parent_state)
 Load MPU settings.
 
uint32_t __mpu_expand_class (uint8_t class)
 

Macro Definition Documentation

◆ MPU_AP_MASK

#define MPU_AP_MASK   0b0111

◆ MPU_EXECUTE_SHIFT

#define MPU_EXECUTE_SHIFT   3

◆ MPU_RNR_REGION

#define MPU_RNR_REGION   (MPU_RNR_REGION_Msk)

◆ MPU_RNR_REGION_LSB

#define MPU_RNR_REGION_LSB   (MPU_RNR_REGION_Pos)

Function Documentation

◆ __mpu_expand_class()

uint32_t __mpu_expand_class ( uint8_t  class)

◆ hard_fault_handler()

void hard_fault_handler ( void  )

Handler for hard fault.

◆ log_2()

static uint8_t log_2 ( uint32_t  num)
inlinestatic

◆ mem_manage_handler()

void mem_manage_handler ( void  )

◆ mpu_clear_region()

int mpu_clear_region ( uint8_t  region)

Disable MPU region.

This function will disable use of MPU region. Address and size will remain configured, but region is not marked as enabled anymore.

Parameters
regionID of region being deactivated (0 - 7)
Returns
E_OK if region was deactivated

◆ mpu_configure_region()

int mpu_configure_region ( uint8_t  region,
const void *  base,
uint32_t  size,
uint8_t  flags,
uint32_t *  RBAR,
uint32_t *  RASR 
)

Create configuration for MPU region.

@TODO

◆ mpu_disable()

void mpu_disable ( )

Disable memory protection.

This routine will disable memory protection even for unprivileged code.

◆ mpu_enable()

void mpu_enable ( )

Enable memory protection.

This routine enables memory protection with standard memory setup for kernel purposes. This means that any privileged code has full access to memory as if no memory protection was turned on.

Note
It is safe to call this routine in kernel context even if no memory regions are set.

◆ mpu_load()

int mpu_load ( const MPU_State *  state,
uint8_t  base,
uint8_t  count 
)

◆ mpu_restore()

int mpu_restore ( const MPU_State *  hosted_state,
const MPU_State *  parent_state 
)

Load MPU settings.

Loads MPU settings for default amount of regions from off-CPU buffer. This is suitable for store-resume during task switching.

Parameters
stateMPU state buffer

◆ mpu_set_region()

int mpu_set_region ( uint8_t  region,
const void *  base,
uint32_t  size,
uint8_t  cls 
)

Configure and activate MPU region.

Activate given memory region with new base address and size. For now, caller is responsible for providing base address, which is aligned to size of block. If region is already activated, then its base address, size and flags are being overwritten.

Parameters
regionID of region being activated (0-7)
basebase address of region
sizesize of region (256B and more)
clsregion access class, see MPU_class for available access classes
Returns
E_OK if region was configured, otherwise error code is returned

◆ mpu_store()

int mpu_store ( MPU_State *  hosted_state,
MPU_State *  parent_state 
)

Store MPU settings.

Stores MPU settings for default amount of regions into off-CPU buffer. This is suitable for store-resume during task switching.

Parameters
stateMPU state buffer

Variable Documentation

◆ __MPU_flags

const uint32_t __MPU_flags[]
static
Initial value:
= {
0,
}
#define MPU_RASR_ATTR_AP_PRW_URW
Definition: mpu_priv.h:53
#define MPU_RASR_ATTR_AP_PRW_URO
Definition: mpu_priv.h:52
#define MPU_RASR_ATTR_XN
Definition: mpu_priv.h:50

MPU region access rights.

This array maps CMRX access modes to ARM access modes See enum MPU_Flags for meaning of individual indices.