59 #if defined(MPU_OVER_MPU)
76 #if FEATURE_MPU_HAS_PROCESS_IDENTIFIER
91 uint8_t masterIdx = 0U;
110 & (1UL << masterPrivilegeRight.
masterNum))
118 #if FEATURE_MPU_HAS_PROCESS_IDENTIFIER
124 #elif defined(MPU_OVER_SMPU)
131 static void MPU_ConvertSmpuErrorConfig(
const smpu_access_err_info_t * smpuErrPtr,
135 errResult->
master = smpuErrPtr->master;
136 errResult->
overrun = smpuErrPtr->Overrun;
139 errResult->
accessCtr = smpuErrPtr->accessCtr;
140 errResult->
addr = smpuErrPtr->addr;
141 #if FEATURE_SMPU_HAS_PROCESS_IDENTIFIER
142 errResult->
processId = smpuErrPtr->processorIdentification;
153 smpu_master_access_right_t * masterAccessRight,
154 smpu_user_config_t * configResult)
156 uint8_t masterIdx = 0U;
160 configResult->startAddr = regionConfig->
startAddr;
161 configResult->endAddr = regionConfig->
endAddr;
164 for (masterIdx = 0U; masterIdx < FEATURE_SMPU_MASTER_COUNT; masterIdx++)
171 masterAccessRight[masterIdx].accessRight = (smpu_access_rights_t)masterPrivilegeRight.
accessRight;
175 configResult->masterAccRight = masterAccessRight;
177 #if FEATURE_SMPU_HAS_PROCESS_IDENTIFIER
186 #if (FEATURE_SMPU_HAS_SPECIFIC_ACCESS_RIGHT_COUNT != 0U)
187 configResult->specAccessEnable = ((mpu_extension_smpu_region_t *)regionConfig->
extension)->specAccessEnable;
188 configResult->specAccessSet = (smpu_specific_access_rights_t *)((mpu_extension_smpu_region_t *)regionConfig->
extension)->specAccessSet;
190 configResult->cacheInhibitEnable = ((mpu_extension_smpu_region_t *)regionConfig->
extension)->cacheInhibitEnable;
191 configResult->lockConfig = (smpu_lock_t)((mpu_extension_smpu_region_t *)regionConfig->
extension)->lockConfig;
195 #if (FEATURE_SMPU_HAS_SPECIFIC_ACCESS_RIGHT_COUNT != 0U)
196 configResult->specAccessEnable =
false;
197 configResult->specAccessSet = NULL;
199 configResult->cacheInhibitEnable =
true;
200 configResult->lockConfig = SMPU_UNLOCK;
225 uint8_t regionIdx = 0U;
227 #if defined(MPU_OVER_MPU)
236 for (regionIdx = 0U; regionIdx < regionCnt; regionIdx++)
238 MPU_ConvertMpuRegionConfig(&configPtr[regionIdx],
240 &mpuConfig[regionIdx]);
247 #if defined(MPU_OVER_SMPU)
248 if (instance->
instType == MPU_INST_TYPE_SMPU)
252 smpu_user_config_t smpuConfig[SMPU_RGD_COUNT];
253 smpu_master_access_right_t smpuMasterConfig[SMPU_RGD_COUNT * FEATURE_SMPU_MASTER_COUNT];
256 for (regionIdx = 0U; regionIdx < regionCnt; regionIdx++)
258 MPU_ConvertSmpuRegionConfig(&configPtr[regionIdx],
259 &smpuMasterConfig[regionIdx * FEATURE_SMPU_MASTER_COUNT],
260 &smpuConfig[regionIdx]);
263 status = SMPU_DRV_Init(instance->
instIdx, regionCnt, smpuConfig);
285 #if defined(MPU_OVER_MPU)
294 #if defined(MPU_OVER_SMPU)
295 if (instance->
instType == MPU_INST_TYPE_SMPU)
298 status = SMPU_DRV_Deinit(instance->
instIdx);
322 uint8_t masterIdx = 0U;
324 #if defined(MPU_OVER_MPU)
332 masterAccRight[masterIdx].
masterNum = mpuMasterNum[masterIdx];
347 #if defined(MPU_OVER_SMPU)
348 if (instance->
instType == MPU_INST_TYPE_SMPU)
350 uint8_t smpuMasterNum[FEATURE_SMPU_MASTER_COUNT] = FEATURE_SMPU_MASTER;
353 for (masterIdx = 0U; masterIdx < FEATURE_SMPU_MASTER_COUNT; masterIdx++)
355 masterAccRight[masterIdx].
masterNum = smpuMasterNum[masterIdx];
356 masterAccRight[masterIdx].
accessRight = MPU_RW_OR_SET_3;
365 regionConfig->
endAddr = 0xFFFFFFFFU;
392 #if defined(MPU_OVER_MPU)
399 MPU_ConvertMpuRegionConfig(configPtr, mpuMasterConfig, &mpuConfig);
405 #if defined(MPU_OVER_SMPU)
406 if (instance->
instType == MPU_INST_TYPE_SMPU)
408 smpu_user_config_t smpuConfig;
409 smpu_master_access_right_t smpuMasterConfig[FEATURE_SMPU_MASTER_COUNT];
412 MPU_ConvertSmpuRegionConfig(configPtr, smpuMasterConfig, &smpuConfig);
414 status = SMPU_DRV_SetRegionConfig(instance->
instIdx, regionNum, &smpuConfig);
436 #if defined(MPU_OVER_MPU)
446 #if defined(MPU_OVER_SMPU)
447 if (instance->
instType == MPU_INST_TYPE_SMPU)
450 status = SMPU_DRV_EnableRegion(instance->
instIdx, regionNum, enable);
474 #if defined(MPU_OVER_MPU)
484 MPU_ConvertMpuErrorConfig(&mpuErrPtr, errPtr);
489 #if defined(MPU_OVER_SMPU)
490 if (instance->
instType == MPU_INST_TYPE_SMPU)
492 smpu_access_err_info_t smpuErrPtr;
495 status = SMPU_DRV_GetDetailErrorInfo(instance->
instIdx, channel, &smpuErrPtr);
499 MPU_ConvertSmpuErrorConfig(&smpuErrPtr, errPtr);
507 #if defined(MPU_OVER_SMPU)
517 mpu_lock_t lockConfig)
523 if (instance->
instType == MPU_INST_TYPE_SMPU)
526 status = SMPU_DRV_SetRegionLockConfig(instance->
instIdx, regionNum, (smpu_lock_t)lockConfig);
541 mpu_region_lock_t * regionLock)
548 if (instance->
instType == MPU_INST_TYPE_SMPU)
550 smpu_region_lock_t smpuRegionLock;
553 smpuRegionLock = SMPU_DRV_GetRegionLockInfo(instance->
instIdx, regionNum);
556 regionLock->regionNum = smpuRegionLock.regionNum;
557 #if FEATURE_SMPU_HAS_OWNER_LOCK
558 regionLock->masterOwner = smpuRegionLock.masterOwner;
560 regionLock->lockConfig = (mpu_lock_t)smpuRegionLock.lockConfig;
uint8_t processIdentifier
MPU master access rights. Implements : mpu_master_access_right_t_Class.
MPU master access permission. Implements : mpu_master_access_permission_t_Class.
Structure storing PAL instance information.
const mpu_master_access_right_t * masterAccRight
mpu_access_permission_t accessRight
void MPU_DRV_Deinit(uint32_t instance)
De-initializes the MPU region by resetting and disabling MPU module.
mpu_err_access_type_t accessType
status_t MPU_Init(const mpu_instance_t *const instance, uint8_t regionCnt, const mpu_region_config_t *configPtr)
Initializes memory protection unit by allocating regions and granting access rights for masters...
bool MPU_DRV_GetDetailErrorAccessInfo(uint32_t instance, uint8_t slavePortNum, mpu_access_err_info_t *errInfoPtr)
Checks and gets the MPU access error detail information for a slave port.
status_t MPU_Deinit(const mpu_instance_t *const instance)
De-initializes memory protection unit by reseting all regions and masters to default and disable modu...
mpu_access_rights_t
MPU access rights. Code Supervisor User Description MPU_SUPERVISOR_RWX_USER_NONE r w x - - - Allow R...
status_t MPU_DRV_Init(uint32_t instance, uint8_t regionCnt, const mpu_user_config_t *userConfigArr)
The function sets the MPU regions according to user input and then enables the MPU. Please note that access rights for region 0 will always be configured and regionCnt takes values between 1 and the maximum region count supported by the hardware. e.g. In S32K144 the number of supported regions is 8. The user must make sure that the clock is enabled.
uint8_t processorIdentification
uint8_t processIdentifier
status_t MPU_UpdateRegion(const mpu_instance_t *const instance, uint8_t regionNum, const mpu_region_config_t *configPtr)
Updates region configuration.
status_t
Status return codes. Common error codes will be a unified enumeration (C enum) that will contain all ...
status_t MPU_GetDefautRegionConfig(const mpu_instance_t *const instance, mpu_master_access_permission_t *masterAccRight, mpu_region_config_t *regionConfig)
Gets default region configuration. Grants all access rights for masters; disable PID and cache; unloc...
MPU detail error access info Implements : mpu_error_info_t_Class.
MPU user region configuration structure. This structure is used when calling the MPU_DRV_Init functio...
#define FEATURE_MPU_HAS_PROCESS_IDENTIFIER
mpu_err_attributes_t attributes
MPU detail error access info Implements : mpu_access_err_info_t_Class.
mpu_access_rights_t accessRight
status_t MPU_DRV_SetRegionConfig(uint32_t instance, uint8_t regionNum, const mpu_user_config_t *userConfigPtr)
Sets the region configuration.
mpu_error_access_type_t
MPU access error Implements : mpu_error_access_type_t_Class.
mpu_error_attributes_t attributes
mpu_error_access_type_t accessType
#define FEATURE_MPU_MASTER
bool processIdentifierEnable
const mpu_master_access_permission_t * masterAccRight
status_t MPU_EnableRegion(const mpu_instance_t *const instance, uint8_t regionNum, bool enable)
Enables or disables an exist region configuration.
void MPU_DRV_EnableRegion(uint32_t instance, uint8_t regionNum, bool enable)
Enables/Disables region descriptor. Please note that region 0 should not be disabled.
#define FEATURE_MPU_MAX_LOW_MASTER_NUMBER
mpu_error_attributes_t
MPU access error attributes Implements : mpu_error_attributes_t_Class.
#define FEATURE_MPU_MASTER_COUNT
MPU region configuration structure. Implements : mpu_region_config_t_Class.
bool MPU_GetError(const mpu_instance_t *const instance, uint8_t channel, mpu_error_info_t *errPtr)
Checks and gets the access error detail information then clear error flag if the error caused by a ma...