The SYSMPU driver provides hardware access control for all memory references generated in the device. Use the SYSMPU driver to program the region descriptors that define memory spaces and their access rights. After initialization, the SYSMPU concurrently monitors the system bus transactions and evaluates their appropriateness.
Initialization and Deinitialization
To initialize the SYSMPU module, call the SYSMPU_Init() function and provide the user configuration data structure. This function sets the configuration of the SYSMPU module automatically and enables the SYSMPU module.
Note that the configuration start address, end address, the region valid value, and the debugger's access permission for the SYSMPU region 0 cannot be changed.
This is an example code to configure the SYSMPU driver.
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/sysmpu
Basic Control Operations
SYSMPU can be enabled/disabled for the entire memory protection region by calling the SYSMPU_Enable() function. To save the power for any unused special regions when the entire memory protection region is disabled, call the SYSMPU_RegionEnable().
After SYSMPU initialization, the SYSMPU_SetRegionLowMasterAccessRights() and SYSMPU_SetRegionHighMasterAccessRights() can be used to change the access rights for special master ports and for special region numbers. The SYSMPU_SetRegionConfig can be used to set the whole region with the start/end address with access rights.
The SYSMPU_GetHardwareInfo() API is provided to get the hardware information for the device. The SYSMPU_GetSlavePortErrorStatus() API is provided to get the error status of a special slave port. When an error happens in this port, the SYSMPU_GetDetailErrorAccessInfo() API is provided to get the detailed error information.
|
enum | sysmpu_region_total_num_t {
kSYSMPU_8Regions = 0x0U,
kSYSMPU_12Regions = 0x1U,
kSYSMPU_16Regions = 0x2U
} |
| Describes the number of SYSMPU regions. More...
|
|
enum | sysmpu_slave_t {
kSYSMPU_Slave0 = 0U,
kSYSMPU_Slave1 = 1U,
kSYSMPU_Slave2 = 2U,
kSYSMPU_Slave3 = 3U,
kSYSMPU_Slave4 = 4U
} |
| SYSMPU slave port number. More...
|
|
enum | sysmpu_err_access_control_t {
kSYSMPU_NoRegionHit = 0U,
kSYSMPU_NoneOverlappRegion = 1U,
kSYSMPU_OverlappRegion = 2U
} |
| SYSMPU error access control detail. More...
|
|
enum | sysmpu_err_access_type_t {
kSYSMPU_ErrTypeRead = 0U,
kSYSMPU_ErrTypeWrite = 1U
} |
| SYSMPU error access type. More...
|
|
enum | sysmpu_err_attributes_t {
kSYSMPU_InstructionAccessInUserMode = 0U,
kSYSMPU_DataAccessInUserMode = 1U,
kSYSMPU_InstructionAccessInSupervisorMode = 2U,
kSYSMPU_DataAccessInSupervisorMode = 3U
} |
| SYSMPU access error attributes. More...
|
|
enum | sysmpu_supervisor_access_rights_t {
kSYSMPU_SupervisorReadWriteExecute = 0U,
kSYSMPU_SupervisorReadExecute = 1U,
kSYSMPU_SupervisorReadWrite = 2U,
kSYSMPU_SupervisorEqualToUsermode = 3U
} |
| SYSMPU access rights in supervisor mode for bus master 0 ~ 3. More...
|
|
enum | sysmpu_user_access_rights_t {
kSYSMPU_UserNoAccessRights = 0U,
kSYSMPU_UserExecute = 1U,
kSYSMPU_UserWrite = 2U,
kSYSMPU_UserWriteExecute = 3U,
kSYSMPU_UserRead = 4U,
kSYSMPU_UserReadExecute = 5U,
kSYSMPU_UserReadWrite = 6U,
kSYSMPU_UserReadWriteExecute = 7U
} |
| SYSMPU access rights in user mode for bus master 0 ~ 3. More...
|
|
|
static void | SYSMPU_Enable (SYSMPU_Type *base, bool enable) |
| Enables/disables the SYSMPU globally. More...
|
|
static void | SYSMPU_RegionEnable (SYSMPU_Type *base, uint32_t number, bool enable) |
| Enables/disables the SYSMPU for a special region. More...
|
|
void | SYSMPU_GetHardwareInfo (SYSMPU_Type *base, sysmpu_hardware_info_t *hardwareInform) |
| Gets the SYSMPU basic hardware information. More...
|
|
void | SYSMPU_SetRegionConfig (SYSMPU_Type *base, const sysmpu_region_config_t *regionConfig) |
| Sets the SYSMPU region. More...
|
|
void | SYSMPU_SetRegionAddr (SYSMPU_Type *base, uint32_t regionNum, uint32_t startAddr, uint32_t endAddr) |
| Sets the region start and end address. More...
|
|
void | SYSMPU_SetRegionRwxMasterAccessRights (SYSMPU_Type *base, uint32_t regionNum, uint32_t masterNum, const sysmpu_rwxrights_master_access_control_t *accessRights) |
| Sets the SYSMPU region access rights for masters with read, write, and execute rights. More...
|
|
void | SYSMPU_SetRegionRwMasterAccessRights (SYSMPU_Type *base, uint32_t regionNum, uint32_t masterNum, const sysmpu_rwrights_master_access_control_t *accessRights) |
| Sets the SYSMPU region access rights for masters with read and write rights. More...
|
|
bool | SYSMPU_GetSlavePortErrorStatus (SYSMPU_Type *base, sysmpu_slave_t slaveNum) |
| Gets the numbers of slave ports where errors occur. More...
|
|
void | SYSMPU_GetDetailErrorAccessInfo (SYSMPU_Type *base, sysmpu_slave_t slaveNum, sysmpu_access_err_info_t *errInform) |
| Gets the SYSMPU detailed error access information. More...
|
|
struct sysmpu_hardware_info_t |
uint8_t sysmpu_hardware_info_t::hardwareRevisionLevel |
uint8_t sysmpu_hardware_info_t::slavePortsNumbers |
struct sysmpu_access_err_info_t |
uint32_t sysmpu_access_err_info_t::master |
uint32_t sysmpu_access_err_info_t::address |
uint8_t sysmpu_access_err_info_t::processorIdentification |
struct sysmpu_rwxrights_master_access_control_t |
bool sysmpu_rwxrights_master_access_control_t::processIdentifierEnable |
struct sysmpu_rwrights_master_access_control_t |
bool sysmpu_rwrights_master_access_control_t::writeEnable |
bool sysmpu_rwrights_master_access_control_t::readEnable |
struct sysmpu_region_config_t |
This structure is used to configure the regionNum region. The accessRights1[0] ~ accessRights1[3] are used to configure the bus master 0 ~ 3 with the privilege rights setting. The accessRights2[0] ~ accessRights2[3] are used to configure the high master 4 ~ 7 with the normal read write permission. The master port assignment is the chip configuration. Normally, the core is the master 0, debugger is the master 1. Note that the SYSMPU assigns a priority scheme where the debugger is treated as the highest priority master followed by the core and then all the remaining masters. SYSMPU protection does not allow writes from the core to affect the "regionNum 0" start and end address nor the permissions associated with the debugger. It can only write the permission fields associated with the other masters. This protection guarantees that the debugger always has access to the entire address space and those rights can't be changed by the core or any other bus master. Prepare the region configuration when regionNum is 0.
uint32_t sysmpu_region_config_t::regionNum |
uint32_t sysmpu_region_config_t::startAddress |
Note: bit0 ~ bit4 always be marked as 0 by SYSMPU. The actual start address is 0-modulo-32 byte address.
uint32_t sysmpu_region_config_t::endAddress |
Note: bit0 ~ bit4 always be marked as 1 by SYSMPU. The actual end address is 31-modulo-32 byte address.
uint8_t sysmpu_region_config_t::processIdentifier |
uint8_t sysmpu_region_config_t::processIdMask |
The setting bit will ignore the same bit in process identifier.
This structure is used when calling the SYSMPU_Init function.
struct _sysmpu_config* sysmpu_config_t::next |
#define SYSMPU_MASTER_RWATTRIBUTE_START_PORT (4U) |
#define SYSMPU_REGION_RWXRIGHTS_MASTER_SHIFT |
( |
|
n | ) |
((n)*6U) |
#define SYSMPU_REGION_RWXRIGHTS_MASTER_MASK |
( |
|
n | ) |
(0x1FUL << SYSMPU_REGION_RWXRIGHTS_MASTER_SHIFT(n)) |
#define SYSMPU_REGION_RWXRIGHTS_MASTER_WIDTH 5U |
#define SYSMPU_REGION_RWXRIGHTS_MASTER_PE_SHIFT |
( |
|
n | ) |
((n)*6U + SYSMPU_REGION_RWXRIGHTS_MASTER_WIDTH) |
#define SYSMPU_REGION_RWXRIGHTS_MASTER_PE_MASK |
( |
|
n | ) |
(0x1UL << SYSMPU_REGION_RWXRIGHTS_MASTER_PE_SHIFT(n)) |
#define SYSMPU_REGION_RWXRIGHTS_MASTER_PE |
( |
|
n, |
|
|
|
x |
|
) |
| |
Value:
#define SYSMPU_REGION_RWXRIGHTS_MASTER_PE_MASK(n)
SYSMPU masters with read, write and execute rights process enable bit mask.
Definition: fsl_sysmpu.h:49
#define SYSMPU_REGION_RWXRIGHTS_MASTER_PE_SHIFT(n)
SYSMPU masters with read, write and execute rights process enable bit shift.
Definition: fsl_sysmpu.h:46
#define SYSMPU_REGION_RWRIGHTS_MASTER_MASK |
( |
|
n | ) |
(0x3UL << SYSMPU_REGION_RWRIGHTS_MASTER_SHIFT(n)) |
Enumerator |
---|
kSYSMPU_8Regions |
SYSMPU supports 8 regions.
|
kSYSMPU_12Regions |
SYSMPU supports 12 regions.
|
kSYSMPU_16Regions |
SYSMPU supports 16 regions.
|
Enumerator |
---|
kSYSMPU_Slave0 |
SYSMPU slave port 0.
|
kSYSMPU_Slave1 |
SYSMPU slave port 1.
|
kSYSMPU_Slave2 |
SYSMPU slave port 2.
|
kSYSMPU_Slave3 |
SYSMPU slave port 3.
|
kSYSMPU_Slave4 |
SYSMPU slave port 4.
|
Enumerator |
---|
kSYSMPU_NoRegionHit |
No region hit error.
|
kSYSMPU_NoneOverlappRegion |
Access single region error.
|
kSYSMPU_OverlappRegion |
Access overlapping region error.
|
Enumerator |
---|
kSYSMPU_ErrTypeRead |
SYSMPU error access type — read.
|
kSYSMPU_ErrTypeWrite |
SYSMPU error access type — write.
|
Enumerator |
---|
kSYSMPU_InstructionAccessInUserMode |
Access instruction error in user mode.
|
kSYSMPU_DataAccessInUserMode |
Access data error in user mode.
|
kSYSMPU_InstructionAccessInSupervisorMode |
Access instruction error in supervisor mode.
|
kSYSMPU_DataAccessInSupervisorMode |
Access data error in supervisor mode.
|
Enumerator |
---|
kSYSMPU_SupervisorReadWriteExecute |
Read write and execute operations are allowed in supervisor mode.
|
kSYSMPU_SupervisorReadExecute |
Read and execute operations are allowed in supervisor mode.
|
kSYSMPU_SupervisorReadWrite |
Read write operations are allowed in supervisor mode.
|
kSYSMPU_SupervisorEqualToUsermode |
Access permission equal to user mode.
|
Enumerator |
---|
kSYSMPU_UserNoAccessRights |
No access allowed in user mode.
|
kSYSMPU_UserExecute |
Execute operation is allowed in user mode.
|
kSYSMPU_UserWrite |
Write operation is allowed in user mode.
|
kSYSMPU_UserWriteExecute |
Write and execute operations are allowed in user mode.
|
kSYSMPU_UserRead |
Read is allowed in user mode.
|
kSYSMPU_UserReadExecute |
Read and execute operations are allowed in user mode.
|
kSYSMPU_UserReadWrite |
Read and write operations are allowed in user mode.
|
kSYSMPU_UserReadWriteExecute |
Read write and execute operations are allowed in user mode.
|
This function configures the SYSMPU module with the user-defined configuration.
- Parameters
-
base | SYSMPU peripheral base address. |
config | The pointer to the configuration structure. |
void SYSMPU_Deinit |
( |
SYSMPU_Type * |
base | ) |
|
- Parameters
-
base | SYSMPU peripheral base address. |
static void SYSMPU_Enable |
( |
SYSMPU_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
Call this API to enable or disable the SYSMPU module.
- Parameters
-
base | SYSMPU peripheral base address. |
enable | True enable SYSMPU, false disable SYSMPU. |
static void SYSMPU_RegionEnable |
( |
SYSMPU_Type * |
base, |
|
|
uint32_t |
number, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
When SYSMPU is enabled, call this API to disable an unused region of an enabled SYSMPU. Call this API to minimize the power dissipation.
- Parameters
-
base | SYSMPU peripheral base address. |
number | SYSMPU region number. |
enable | True enable the special region SYSMPU, false disable the special region SYSMPU. |
- Parameters
-
base | SYSMPU peripheral base address. |
hardwareInform | The pointer to the SYSMPU hardware information structure. See "sysmpu_hardware_info_t". |
Note: Due to the SYSMPU protection, the region number 0 does not allow writes from core to affect the start and end address nor the permissions associated with the debugger. It can only write the permission fields associated with the other masters.
- Parameters
-
base | SYSMPU peripheral base address. |
regionConfig | The pointer to the SYSMPU user configuration structure. See "sysmpu_region_config_t". |
void SYSMPU_SetRegionAddr |
( |
SYSMPU_Type * |
base, |
|
|
uint32_t |
regionNum, |
|
|
uint32_t |
startAddr, |
|
|
uint32_t |
endAddr |
|
) |
| |
Memory region start address. Note: bit0 ~ bit4 is always marked as 0 by SYSMPU. The actual start address by SYSMPU is 0-modulo-32 byte address. Memory region end address. Note: bit0 ~ bit4 always be marked as 1 by SYSMPU. The end address used by the SYSMPU is 31-modulo-32 byte address. Note: Due to the SYSMPU protection, the startAddr and endAddr can't be changed by the core when regionNum is 0.
- Parameters
-
base | SYSMPU peripheral base address. |
regionNum | SYSMPU region number. The range is from 0 to FSL_FEATURE_SYSMPU_DESCRIPTOR_COUNT - 1. |
startAddr | Region start address. |
endAddr | Region end address. |
The SYSMPU access rights depend on two board classifications of bus masters. The privilege rights masters and the normal rights masters. The privilege rights masters have the read, write, and execute access rights. Except the normal read and write rights, the execute rights are also allowed for these masters. The privilege rights masters normally range from bus masters 0 - 3. However, the maximum master number is device-specific. See the "SYSMPU_PRIVILEGED_RIGHTS_MASTER_MAX_INDEX". The normal rights masters access rights control see "SYSMPU_SetRegionRwMasterAccessRights()".
- Parameters
-
base | SYSMPU peripheral base address. |
regionNum | SYSMPU region number. Should range from 0 to FSL_FEATURE_SYSMPU_DESCRIPTOR_COUNT - 1. |
masterNum | SYSMPU bus master number. Should range from 0 to SYSMPU_PRIVILEGED_RIGHTS_MASTER_MAX_INDEX. |
accessRights | The pointer to the SYSMPU access rights configuration. See "sysmpu_rwxrights_master_access_control_t". |
The SYSMPU access rights depend on two board classifications of bus masters. The privilege rights masters and the normal rights masters. The normal rights masters only have the read and write access permissions. The privilege rights access control see "SYSMPU_SetRegionRwxMasterAccessRights".
- Parameters
-
base | SYSMPU peripheral base address. |
regionNum | SYSMPU region number. The range is from 0 to FSL_FEATURE_SYSMPU_DESCRIPTOR_COUNT - 1. |
masterNum | SYSMPU bus master number. Should range from SYSMPU_MASTER_RWATTRIBUTE_START_PORT to ~ FSL_FEATURE_SYSMPU_MASTER_COUNT - 1. |
accessRights | The pointer to the SYSMPU access rights configuration. See "sysmpu_rwrights_master_access_control_t". |
bool SYSMPU_GetSlavePortErrorStatus |
( |
SYSMPU_Type * |
base, |
|
|
sysmpu_slave_t |
slaveNum |
|
) |
| |
- Parameters
-
base | SYSMPU peripheral base address. |
slaveNum | SYSMPU slave port number. |
- Returns
- The slave ports error status. true - error happens in this slave port. false - error didn't happen in this slave port.
- Parameters
-
base | SYSMPU peripheral base address. |
slaveNum | SYSMPU slave port number. |
errInform | The pointer to the SYSMPU access error information. See "sysmpu_access_err_info_t". |