S32 SDK

Detailed Description

Memory Protection Unit Hardware Abstraction Level.

This HAL provides low-level access to all hardware features of the MPU.

Data Structures

struct  mpu_access_err_info_t
 MPU detail error access info Implements : mpu_access_err_info_t_Class. More...
 
struct  mpu_low_masters_access_rights_t
 MPU access rights for masters which have separated privilege rights for user and supervisor mode accesses (e.g. master0~2 in S32K144) Implements : mpu_low_masters_access_rights_t_Class. More...
 
struct  mpu_high_masters_access_rights_t
 MPU access rights for master which have only read and write permissions Implements : mpu_high_masters_access_rights_t_Class. More...
 

Enumerations

enum  mpu_err_access_type_t { MPU_ERR_TYPE_READ = 0U, MPU_ERR_TYPE_WRITE = 1U }
 MPU access error Implements : mpu_err_access_type_t_Class. More...
 
enum  mpu_err_attributes_t { MPU_INSTRUCTION_ACCESS_IN_USER_MODE = 0U, MPU_DATA_ACCESS_IN_USER_MODE = 1U, MPU_INSTRUCTION_ACCESS_IN_SUPERVISOR_MODE = 2U, MPU_DATA_ACCESS_IN_SUPERVISOR_MODE = 3U }
 MPU access error attributes Implements : mpu_err_attributes_t_Class. More...
 
enum  mpu_supervisor_access_rights_t { MPU_SUPERVISOR_READ_WRITE_EXECUTE = 0U, MPU_SUPERVISOR_READ_EXECUTE = 1U, MPU_SUPERVISOR_READ_WRITE = 2U, MPU_SUPERVISOR_EQUAL_TO_USERMODE = 3U }
 MPU access rights in supervisor mode Implements : mpu_supervisor_access_rights_t_Class. More...
 
enum  mpu_user_access_rights_t {
  MPU_USER_NO_ACCESS_RIGHTS = 0U, MPU_USER_EXECUTE = 1U, MPU_USER_WRITE = 2U, MPU_USER_WRITE_EXECUTE = 3U,
  MPU_USER_READ = 4U, MPU_USER_READ_EXECUTE = 5U, MPU_USER_READ_WRITE = 6U, MPU_USER_READ_WRITE_EXECUTE = 7U
}
 MPU access rights in user mode Implements : mpu_user_access_rights_t_Class. More...
 

Functions

static void MPU_HAL_Enable (MPU_Type *const base)
 Enables the MPU module. More...
 
static void MPU_HAL_Disable (MPU_Type *const base)
 Disables the MPU module. More...
 
static bool MPU_HAL_IsEnable (const MPU_Type *const base)
 Checks whether the MPU module is enabled. More...
 
static uint8_t MPU_HAL_GetHardwareRevision (const MPU_Type *const base)
 Gets MPU hardware revision level. More...
 
bool MPU_HAL_GetSlavePortErrorStatus (const MPU_Type *const base, uint8_t slaveNum)
 Gets the error status of a specified slave port. More...
 
void MPU_HAL_GetDetailErrorAccessInfo (MPU_Type *const base, uint8_t slaveNum, mpu_access_err_info_t *errInfoPtr)
 Gets MPU detail error access info. More...
 
void MPU_HAL_SetRegionAddr (MPU_Type *const base, uint8_t regionNum, uint32_t startAddr, uint32_t endAddr)
 Sets region start and end address. Please note that using this function will clear the valid bit of the region, and a further validation might be needed. More...
 
void MPU_HAL_SetLowMasterAccessRights (MPU_Type *const base, uint8_t regionNum, uint8_t masterNum, const mpu_low_masters_access_rights_t *accessRightsPtr)
 Sets access permission for master which has separated privilege rights for user and supervisor mode accesses in a specific region. Please note that using this function will clear the valid bit of the region. In order to keep the region valid, the MPU_HAL_SetAlternateLowMasterAccessRights function can be used. More...
 
void MPU_HAL_SetHighMasterAccessRights (MPU_Type *const base, uint8_t regionNum, uint8_t masterNum, const mpu_high_masters_access_rights_t *accessRightsPtr)
 Sets access permission for master which has only read and write permissions in a specific region. Please note that using this function will clear the valid bit of the region. In order to keep the region valid, the MPU_HAL_SetAlternateHighMasterAccessRights function can be used. More...
 
static void MPU_HAL_SetRegionValidCmd (MPU_Type *const base, uint8_t regionNum, bool enable)
 Sets the region valid value. When a region changed not by alternating registers should set the valid again. More...
 
static void MPU_HAL_SetProcessIdentifierMask (MPU_Type *const base, uint8_t regionNum, uint8_t processIdentifierMask)
 Sets the process identifier mask. More...
 
static void MPU_HAL_SetProcessIdentifier (MPU_Type *const base, uint8_t regionNum, uint8_t processIdentifier)
 Sets the process identifier. More...
 
void MPU_HAL_SetAlternateLowMasterAccessRights (MPU_Type *const base, uint8_t regionNum, uint8_t masterNum, const mpu_low_masters_access_rights_t *accessRightsPtr)
 Sets access permission for master which has separated privilege rights for user and supervisor mode accesses in a specific region by alternate register. More...
 
void MPU_HAL_SetAlternateHighMasterAccessRights (MPU_Type *const base, uint8_t regionNum, uint8_t masterNum, const mpu_high_masters_access_rights_t *accessRightsPtr)
 Sets access permission for master which has only read and write permissions in a specific region by alternate register. More...
 
void MPU_HAL_Init (MPU_Type *const base)
 Initializes the MPU module and all regions will be invalid after cleared access permission. More...
 

Enumeration Type Documentation

MPU access error Implements : mpu_err_access_type_t_Class.

Enumerator
MPU_ERR_TYPE_READ 

MPU error type: read

MPU_ERR_TYPE_WRITE 

MPU error type: write

Definition at line 47 of file mpu_hal.h.

MPU access error attributes Implements : mpu_err_attributes_t_Class.

Enumerator
MPU_INSTRUCTION_ACCESS_IN_USER_MODE 

Access instruction error in user mode

MPU_DATA_ACCESS_IN_USER_MODE 

Access data error in user mode

MPU_INSTRUCTION_ACCESS_IN_SUPERVISOR_MODE 

Access instruction error in supervisor mode

MPU_DATA_ACCESS_IN_SUPERVISOR_MODE 

Access data error in supervisor mode

Definition at line 57 of file mpu_hal.h.

MPU access rights in supervisor mode Implements : mpu_supervisor_access_rights_t_Class.

Enumerator
MPU_SUPERVISOR_READ_WRITE_EXECUTE 

Read write and execute operations are allowed in supervisor mode

MPU_SUPERVISOR_READ_EXECUTE 

Read and execute operations are allowed in supervisor mode

MPU_SUPERVISOR_READ_WRITE 

Read write operations are allowed in supervisor mode

MPU_SUPERVISOR_EQUAL_TO_USERMODE 

Access permission equal to user mode

Definition at line 69 of file mpu_hal.h.

MPU access rights in user mode Implements : mpu_user_access_rights_t_Class.

Enumerator
MPU_USER_NO_ACCESS_RIGHTS 

No access allowed in user mode

MPU_USER_EXECUTE 

Execute operation is allowed in user mode

MPU_USER_WRITE 

Write operation is allowed in user mode

MPU_USER_WRITE_EXECUTE 

Write and execute operations are allowed in user mode

MPU_USER_READ 

Read is allowed in user mode

MPU_USER_READ_EXECUTE 

Read and execute operations are allowed in user mode

MPU_USER_READ_WRITE 

Read and write operations are allowed in user mode

MPU_USER_READ_WRITE_EXECUTE 

Read write and execute operations are allowed in user mode

Definition at line 81 of file mpu_hal.h.

Function Documentation

static void MPU_HAL_Disable ( MPU_Type *const  base)
inlinestatic

Disables the MPU module.

Parameters
[in]baseThe MPU peripheral base address. Implements : MPU_HAL_Disable_Activity

Definition at line 157 of file mpu_hal.h.

static void MPU_HAL_Enable ( MPU_Type *const  base)
inlinestatic

Enables the MPU module.

Parameters
[in]baseThe MPU peripheral base address. Implements : MPU_HAL_Enable_Activity

Definition at line 146 of file mpu_hal.h.

void MPU_HAL_GetDetailErrorAccessInfo ( MPU_Type *const  base,
uint8_t  slaveNum,
mpu_access_err_info_t errInfoPtr 
)

Gets MPU detail error access info.

Parameters
[in]baseThe MPU peripheral base address.
[in]slaveNumMPU slave port number.
[out]errInfoPtrThe pointer to the MPU access error information.

Definition at line 91 of file mpu_hal.c.

static uint8_t MPU_HAL_GetHardwareRevision ( const MPU_Type *const  base)
inlinestatic

Gets MPU hardware revision level.

Parameters
[in]baseThe MPU peripheral base address.
Returns
Hardware revision level. Implements : MPU_HAL_GetHardwareRevision_Activity

Definition at line 183 of file mpu_hal.h.

bool MPU_HAL_GetSlavePortErrorStatus ( const MPU_Type *const  base,
uint8_t  slaveNum 
)

Gets the error status of a specified slave port.

Parameters
[in]baseThe MPU peripheral base address.
[in]slaveNumMPU 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.

Definition at line 65 of file mpu_hal.c.

void MPU_HAL_Init ( MPU_Type *const  base)

Initializes the MPU module and all regions will be invalid after cleared access permission.

Parameters
[in]baseThe MPU peripheral base address.

Definition at line 342 of file mpu_hal.c.

static bool MPU_HAL_IsEnable ( const MPU_Type *const  base)
inlinestatic

Checks whether the MPU module is enabled.

Parameters
[in]baseThe MPU peripheral base address.
Returns
State of the module
  • true: MPU module is enabled.
  • false: MPU module is disabled. Implements : MPU_HAL_IsEnable_Activity

Definition at line 171 of file mpu_hal.h.

void MPU_HAL_SetAlternateHighMasterAccessRights ( MPU_Type *const  base,
uint8_t  regionNum,
uint8_t  masterNum,
const mpu_high_masters_access_rights_t accessRightsPtr 
)

Sets access permission for master which has only read and write permissions in a specific region by alternate register.

Parameters
[in]baseThe MPU peripheral base address.
[in]regionNumMPU region number.
[in]masterNumMPU master number.
[in]accessRightsPtrThe pointer of master access rights see mpu_high_masters_access_rights_t.

Definition at line 305 of file mpu_hal.c.

void MPU_HAL_SetAlternateLowMasterAccessRights ( MPU_Type *const  base,
uint8_t  regionNum,
uint8_t  masterNum,
const mpu_low_masters_access_rights_t accessRightsPtr 
)

Sets access permission for master which has separated privilege rights for user and supervisor mode accesses in a specific region by alternate register.

Parameters
[in]baseThe MPU peripheral base address.
[in]regionNumMPU region number.
[in]masterNumMPU master number.
[in]accessRightsPtrThe pointer of master access rights see mpu_low_masters_access_rights_t.

Definition at line 258 of file mpu_hal.c.

void MPU_HAL_SetHighMasterAccessRights ( MPU_Type *const  base,
uint8_t  regionNum,
uint8_t  masterNum,
const mpu_high_masters_access_rights_t accessRightsPtr 
)

Sets access permission for master which has only read and write permissions in a specific region. Please note that using this function will clear the valid bit of the region. In order to keep the region valid, the MPU_HAL_SetAlternateHighMasterAccessRights function can be used.

Parameters
[in]baseThe MPU peripheral base address.
[in]regionNumMPU region number.
[in]masterNumMPU master number.
[in]accessRightsPtrThe pointer of master access rights see mpu_high_masters_access_rights_t.

Definition at line 220 of file mpu_hal.c.

void MPU_HAL_SetLowMasterAccessRights ( MPU_Type *const  base,
uint8_t  regionNum,
uint8_t  masterNum,
const mpu_low_masters_access_rights_t accessRightsPtr 
)

Sets access permission for master which has separated privilege rights for user and supervisor mode accesses in a specific region. Please note that using this function will clear the valid bit of the region. In order to keep the region valid, the MPU_HAL_SetAlternateLowMasterAccessRights function can be used.

Parameters
[in]baseThe MPU peripheral base address.
[in]regionNumMPU region number.
[in]masterNumMPU master number.
[in]accessRightsPtrThe pointer of master access rights see mpu_low_masters_access_rights_t.

Definition at line 170 of file mpu_hal.c.

static void MPU_HAL_SetProcessIdentifier ( MPU_Type *const  base,
uint8_t  regionNum,
uint8_t  processIdentifier 
)
inlinestatic

Sets the process identifier.

Parameters
[in]baseThe MPU peripheral base address.
[in]regionNumMPU region number.
[in]processIdentifierProcess identifier value. Implements : MPU_HAL_SetProcessIdentifier_Activity

Definition at line 308 of file mpu_hal.h.

static void MPU_HAL_SetProcessIdentifierMask ( MPU_Type *const  base,
uint8_t  regionNum,
uint8_t  processIdentifierMask 
)
inlinestatic

Sets the process identifier mask.

Parameters
[in]baseThe MPU peripheral base address.
[in]regionNumMPU region number.
[in]processIdentifierMaskProcess identifier mask value. Implements : MPU_HAL_SetProcessIdentifierMask_Activity

Definition at line 286 of file mpu_hal.h.

void MPU_HAL_SetRegionAddr ( MPU_Type *const  base,
uint8_t  regionNum,
uint32_t  startAddr,
uint32_t  endAddr 
)

Sets region start and end address. Please note that using this function will clear the valid bit of the region, and a further validation might be needed.

Parameters
[in]baseThe MPU peripheral base address.
[in]regionNumMPU region number.
[in]startAddrRegion start address.
[in]endAddrRegion end address.

Definition at line 144 of file mpu_hal.c.

static void MPU_HAL_SetRegionValidCmd ( MPU_Type *const  base,
uint8_t  regionNum,
bool  enable 
)
inlinestatic

Sets the region valid value. When a region changed not by alternating registers should set the valid again.

Parameters
[in]baseThe MPU peripheral base address.
[in]regionNumMPU region number.
[in]enableEnables or disables region. Implements : MPU_HAL_SetRegionValidCmd_Activity

Definition at line 268 of file mpu_hal.h.