Memory protection support internals for ARM architecture.
More...
|
struct | MPU_Registers |
| Convenience structure which groups RBAR and RASR register for one MPU region together. More...
|
|
|
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) |
|
Memory protection support internals for ARM architecture.
◆ 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) |
◆ MPU_State
Type handling MPU state as remembered by CMRX thread switcher.
◆ __mpu_expand_class()
uint32_t __mpu_expand_class |
( |
uint8_t |
class | ) |
|
◆ hard_fault_handler()
void hard_fault_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
-
region | ID 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()
static void mpu_disable |
( |
| ) |
|
|
inlinestatic |
Disable memory protection.
This routine will disable memory protection even for unprivileged code.
◆ mpu_enable()
static void mpu_enable |
( |
| ) |
|
|
inlinestatic |
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()
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
-
hosted_state | MPU state buffer for the current host process |
parent_state | MPU state buffer for the parent process |
◆ 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
-
region | ID of region being activated (0-7) |
base | base address of region |
size | size of region (256B and more) |
cls | region access class, see __MPU_flags for available access classes |
- Returns
- E_OK if region was configured, otherwise error code is returned
◆ mpu_store()
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
-
hosted_state | MPU state buffer for the current host process |
parent_state | MPU state buffer for the parent process |
◆ __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 MPU_Flags for meaning of individual indices.