Tiva Driver Lib
|
Functions | |
void | MPUEnable (uint32_t ui32MPUConfig) |
void | MPUDisable (void) |
uint32_t | MPURegionCountGet (void) |
void | MPURegionEnable (uint32_t ui32Region) |
void | MPURegionDisable (uint32_t ui32Region) |
void | MPURegionSet (uint32_t ui32Region, uint32_t ui32Addr, uint32_t ui32Flags) |
void | MPURegionGet (uint32_t ui32Region, uint32_t *pui32Addr, uint32_t *pui32Flags) |
void | MPUIntRegister (void(*pfnHandler)(void)) |
void | MPUIntUnregister (void) |
void MPUDisable | ( | void | ) |
Disables the MPU for use.
This function disables the Cortex-M memory protection unit. When the MPU is disabled, the default memory map is used and memory management faults are not generated.
void MPUEnable | ( | uint32_t | ui32MPUConfig | ) |
Enables and configures the MPU for use.
ui32MPUConfig | is the logical OR of the possible configurations. |
This function enables the Cortex-M memory protection unit. It also configures the default behavior when in privileged mode and while handling a hard fault or NMI. Prior to enabling the MPU, at least one region must be set by calling MPURegionSet() or else by enabling the default region for privileged mode by passing the MPU_CONFIG_PRIV_DEFAULT flag to MPUEnable(). Once the MPU is enabled, a memory management fault is generated for memory access violations.
The ui32MPUConfig parameter should be the logical OR of any of the following:
void MPUIntRegister | ( | void(*)(void) | pfnHandler | ) |
Registers an interrupt handler for the memory management fault.
pfnHandler | is a pointer to the function to be called when the memory management fault occurs. |
This function sets and enables the handler to be called when the MPU generates a memory management fault due to a protection region access violation.
void MPUIntUnregister | ( | void | ) |
Unregisters an interrupt handler for the memory management fault.
This function disables and clears the handler to be called when a memory management fault occurs.
uint32_t MPURegionCountGet | ( | void | ) |
Gets the count of regions supported by the MPU.
This function is used to get the total number of regions that are supported by the MPU, including regions that are already programmed.
void MPURegionDisable | ( | uint32_t | ui32Region | ) |
Disables a specific region.
ui32Region | is the region number to disable. |
This function is used to disable a previously enabled memory protection region. The region remains configured if it is not overwritten with another call to MPURegionSet(), and can be enabled again by calling MPURegionEnable().
void MPURegionEnable | ( | uint32_t | ui32Region | ) |
Enables a specific region.
ui32Region | is the region number to enable. |
This function is used to enable a memory protection region. The region should already be configured with the MPURegionSet() function. Once enabled, the memory protection rules of the region are applied and access violations cause a memory management fault.
void MPURegionGet | ( | uint32_t | ui32Region, |
uint32_t * | pui32Addr, | ||
uint32_t * | pui32Flags | ||
) |
Gets the current settings for a specific region.
ui32Region | is the region number to get. |
pui32Addr | points to storage for the base address of the region. |
pui32Flags | points to the attribute flags for the region. |
This function retrieves the configuration of a specific region. The meanings and format of the parameters is the same as that of the MPURegionSet() function.
This function can be used to save the configuration of a region for later use with the MPURegionSet() function. The region's enable state is preserved in the attributes that are saved.
void MPURegionSet | ( | uint32_t | ui32Region, |
uint32_t | ui32Addr, | ||
uint32_t | ui32Flags | ||
) |
Sets up the access rules for a specific region.
ui32Region | is the region number to set up. |
ui32Addr | is the base address of the region. It must be aligned according to the size of the region specified in ui32Flags. |
ui32Flags | is a set of flags to define the attributes of the region. |
This function sets up the protection rules for a region. The region has a base address and a set of attributes including the size. The base address parameter, ui32Addr, must be aligned according to the size, and the size must be a power of 2.
The ui32Flags parameter is the logical OR of all of the attributes of the region. It is a combination of choices for region size, execute permission, read/write permissions, disabled sub-regions, and a flag to determine if the region is enabled.
The size flag determines the size of a region and must be one of the following:
The execute permission flag must be one of the following:
The read/write access permissions are applied separately for the privileged and user modes. The read/write access flags must be one of the following:
The region is automatically divided into 8 equally-sized sub-regions by the MPU. Sub-regions can only be used in regions of size 256 bytes or larger. Any of these 8 sub-regions can be disabled, allowing for creation of ``holes'' in a region which can be left open, or overlaid by another region with different attributes. Any of the 8 sub-regions can be disabled with a logical OR of any of the following flags:
Finally, the region can be initially enabled or disabled with one of the following flags:
As an example, to set a region with the following attributes: size of 32 KB, execution enabled, read-only for both privileged and user, one sub-region disabled, and initially enabled; the ui32Flags parameter would have the following value:
(MPU_RGN_SIZE_32K | MPU_RGN_PERM_EXEC | MPU_RGN_PERM_PRV_RO_USR_RO | MPU_SUB_RGN_DISABLE_2 | MPU_RGN_ENABLE)