| CMSIS-Core (Cortex-A) CMSIS-Core support for Cortex-A processor-based devices |

Loading...
Searching...
No Matches
Content | Functions
Memory Management Unit Functions
Core Peripherals

MMU Functions provide control of the Memory Management Unit using translation tables and attributes of different regions of the physical memory map.
Reference: Architecture Reference Manual Reference Manual - Armv7-A and Armv7-R edition. More...

## Content
| MMU Defines and Structs
| Defines and structures that relate to the Memory Management Unit.

## Functions
__STATIC_INLINE int | MMU_XNSection (uint32_t *descriptor_l1, mmu_execute_Type xn)
| Set section execution-never attribute.
__STATIC_INLINE int | MMU_DomainSection (uint32_t *descriptor_l1, uint8_t domain)
| Set section domain.
__STATIC_INLINE int | MMU_PSection (uint32_t *descriptor_l1, mmu_ecc_check_Type p_bit)
| Set section parity check.
__STATIC_INLINE int | MMU_APSection (uint32_t *descriptor_l1, mmu_access_Type user, mmu_access_Type priv, uint32_t afe)
| Set section access privileges.
__STATIC_INLINE int | MMU_SharedSection (uint32_t *descriptor_l1, mmu_shared_Type s_bit)
| Set section shareability.
__STATIC_INLINE int | MMU_GlobalSection (uint32_t *descriptor_l1, mmu_global_Type g_bit)
| Set section Global attribute.
__STATIC_INLINE int | MMU_SecureSection (uint32_t *descriptor_l1, mmu_secure_Type s_bit)
| Set section Security attribute.
__STATIC_INLINE int | MMU_XNPage (uint32_t *descriptor_l2, mmu_execute_Type xn, mmu_region_size_Type page)
| Set 4k/64k page execution-never attribute.
__STATIC_INLINE int | MMU_DomainPage (uint32_t *descriptor_l1, uint8_t domain)
| Set 4k/64k page domain.
__STATIC_INLINE int | MMU_PPage (uint32_t *descriptor_l1, mmu_ecc_check_Type p_bit)
| Set 4k/64k page parity check.
__STATIC_INLINE int | MMU_APPage (uint32_t *descriptor_l2, mmu_access_Type user, mmu_access_Type priv, uint32_t afe)
| Set 4k/64k page access privileges.
__STATIC_INLINE int | MMU_SharedPage (uint32_t *descriptor_l2, mmu_shared_Type s_bit)
| Set 4k/64k page shareability.
__STATIC_INLINE int | MMU_GlobalPage (uint32_t *descriptor_l2, mmu_global_Type g_bit)
| Set 4k/64k page Global attribute.
__STATIC_INLINE int | MMU_SecurePage (uint32_t *descriptor_l1, mmu_secure_Type s_bit)
| Set 4k/64k page Security attribute.
__STATIC_INLINE int | MMU_MemorySection (uint32_t *descriptor_l1, mmu_memory_Type mem, mmu_cacheability_Type outer, mmu_cacheability_Type inner)
| Set Section memory attributes.
__STATIC_INLINE int | MMU_MemoryPage (uint32_t *descriptor_l2, mmu_memory_Type mem, mmu_cacheability_Type outer, mmu_cacheability_Type inner, mmu_region_size_Type page)
| Set 4k/64k page memory attributes.
__STATIC_INLINE int | MMU_GetSectionDescriptor (uint32_t *descriptor, mmu_region_attributes_Type reg)
| Create a L1 section descriptor.
__STATIC_INLINE int | MMU_GetPageDescriptor (uint32_t *descriptor, uint32_t *descriptor2, mmu_region_attributes_Type reg)
| Create a L1 and L2 4k/64k page descriptor.
__STATIC_INLINE void | MMU_TTSection (uint32_t *ttb, uint32_t base_address, uint32_t count, uint32_t descriptor_l1)
| Create a 1MB Section.
__STATIC_INLINE void | MMU_TTPage4k (uint32_t *ttb, uint32_t base_address, uint32_t count, uint32_t descriptor_l1, uint32_t *ttb_l2, uint32_t descriptor_l2)
| Create a 4k page entry.
__STATIC_INLINE void | MMU_TTPage64k (uint32_t *ttb, uint32_t base_address, uint32_t count, uint32_t descriptor_l1, uint32_t *ttb_l2, uint32_t descriptor_l2)
| Create a 64k page entry.
__STATIC_INLINE void | MMU_Enable (void)
| Enable MMU.
__STATIC_INLINE void | MMU_Disable (void)
| Disable MMU.
__STATIC_INLINE void | MMU_InvalidateTLB (void)
| Invalidate entire unified TLB.

## Description

MMU Functions provide control of the Memory Management Unit using translation tables and attributes of different regions of the physical memory map.
Reference: Architecture Reference Manual Reference Manual - Armv7-A and Armv7-R edition.

## Function Documentation

## ◆ MMU_APPage()

__STATIC_INLINE int MMU_APPage | ( | uint32_t * | descriptor_l2,
|  | mmu_access_Type | user,
|  | mmu_access_Type | priv,
|  | uint32_t | afe
| ) |  |

Set 4k/64k page access privileges.

Parameters

  [out] | descriptor_l2 | L2 descriptor.
  [in] | user | User Level Access: NO_ACCESS, RW, READ
  [in] | priv | Privilege Level Access: NO_ACCESS, RW, READ
  [in] | afe | Access flag enable

Returns
  0

The function sets 4k/64k page access privileges

## ◆ MMU_APSection()

__STATIC_INLINE int MMU_APSection | ( | uint32_t * | descriptor_l1,
|  | mmu_access_Type | user,
|  | mmu_access_Type | priv,
|  | uint32_t | afe
| ) |  |

Set section access privileges.

Parameters

  [out] | descriptor_l1 | L1 descriptor.
  [in] | user | User Level Access: NO_ACCESS, RW, READ
  [in] | priv | Privilege Level Access: NO_ACCESS, RW, READ
  [in] | afe | Access flag enable

Returns
  0

The function sets section access privileges

## ◆ MMU_Disable()

__STATIC_INLINE void MMU_Disable | ( | void |  | ) |

Disable MMU.

## ◆ MMU_DomainPage()

__STATIC_INLINE int MMU_DomainPage | ( | uint32_t * | descriptor_l1,
|  | uint8_t | domain
| ) |  |

Set 4k/64k page domain.

Parameters

  [out] | descriptor_l1 | L1 descriptor.
  [in] | domain | Page domain

Returns
  0

The function sets 4k/64k page domain

## ◆ MMU_DomainSection()

__STATIC_INLINE int MMU_DomainSection | ( | uint32_t * | descriptor_l1,
|  | uint8_t | domain
| ) |  |

Set section domain.

Parameters

  [out] | descriptor_l1 | L1 descriptor.
  [in] | domain | Section domain

Returns
  0

The function sets section domain.

## ◆ MMU_Enable()

__STATIC_INLINE void MMU_Enable | ( | void |  | ) |

Enable MMU.

Set M bit 0 to enable the MMU Set AFE bit to enable simplified access permissions model Clear TRE bit to disable TEX remap and A bit to disable strict alignment fault checking

## ◆ MMU_GetPageDescriptor()

__STATIC_INLINE int MMU_GetPageDescriptor | ( | uint32_t * | descriptor,
|  | uint32_t * | descriptor2,
|  | mmu_region_attributes_Type | reg
| ) |  |

Create a L1 and L2 4k/64k page descriptor.

Parameters

  [out] | descriptor | L1 descriptor
  [out] | descriptor2 | L2 descriptor
  [in] | reg | 4k/64k page attributes

Returns
  0

The function creates a 4k/64k page descriptor. Assumptions:

- TEX remap disabled, so memory type and attributes are described directly by bits in the descriptor
- Functions always return 0

## ◆ MMU_GetSectionDescriptor()

__STATIC_INLINE int MMU_GetSectionDescriptor | ( | uint32_t * | descriptor,
|  | mmu_region_attributes_Type | reg
| ) |  |

Create a L1 section descriptor.

Parameters

  [out] | descriptor | L1 descriptor
  [in] | reg | Section attributes

Returns
  0

The function creates a section descriptor.

## ◆ MMU_GlobalPage()

__STATIC_INLINE int MMU_GlobalPage | ( | uint32_t * | descriptor_l2,
|  | mmu_global_Type | g_bit
| ) |  |

Set 4k/64k page Global attribute.

Parameters

  [out] | descriptor_l2 | L2 descriptor.
  [in] | g_bit | 4k/64k page attribute: GLOBAL, NON_GLOBAL

Returns
  0

The function sets 4k/64k page Global attribute

## ◆ MMU_GlobalSection()

__STATIC_INLINE int MMU_GlobalSection | ( | uint32_t * | descriptor_l1,
|  | mmu_global_Type | g_bit
| ) |  |

Set section Global attribute.

Parameters

  [out] | descriptor_l1 | L1 descriptor.
  [in] | g_bit | Section attribute: GLOBAL, NON_GLOBAL

Returns
  0

The function sets section Global attribute

## ◆ MMU_InvalidateTLB()

__STATIC_INLINE void MMU_InvalidateTLB | ( | void |  | ) |

Invalidate entire unified TLB.

## ◆ MMU_MemoryPage()

__STATIC_INLINE int MMU_MemoryPage | ( | uint32_t * | descriptor_l2,
|  | mmu_memory_Type | mem,
|  | mmu_cacheability_Type | outer,
|  | mmu_cacheability_Type | inner,
|  | mmu_region_size_Type | page
| ) |  |

Set 4k/64k page memory attributes.

Parameters

  [out] | descriptor_l2 | L2 descriptor.
  [in] | mem | 4k/64k page memory type: NORMAL, DEVICE, SHARED_DEVICE, NON_SHARED_DEVICE, STRONGLY_ORDERED
  [in] | outer | Outer cacheability: NON_CACHEABLE, WB_WA, WT, WB_NO_WA,
  [in] | inner | Inner cacheability: NON_CACHEABLE, WB_WA, WT, WB_NO_WA,
  [in] | page | Page size

Returns
  0

The function sets 4k/64k page memory attributes

## ◆ MMU_MemorySection()

__STATIC_INLINE int MMU_MemorySection | ( | uint32_t * | descriptor_l1,
|  | mmu_memory_Type | mem,
|  | mmu_cacheability_Type | outer,
|  | mmu_cacheability_Type | inner
| ) |  |

Set Section memory attributes.

Parameters

  [out] | descriptor_l1 | L1 descriptor.
  [in] | mem | Section memory type: NORMAL, DEVICE, SHARED_DEVICE, NON_SHARED_DEVICE, STRONGLY_ORDERED
  [in] | outer | Outer cacheability: NON_CACHEABLE, WB_WA, WT, WB_NO_WA,
  [in] | inner | Inner cacheability: NON_CACHEABLE, WB_WA, WT, WB_NO_WA,

Returns
  0

The function sets section memory attributes

## ◆ MMU_PPage()

__STATIC_INLINE int MMU_PPage | ( | uint32_t * | descriptor_l1,
|  | mmu_ecc_check_Type | p_bit
| ) |  |

Set 4k/64k page parity check.

Parameters

  [out] | descriptor_l1 | L1 descriptor.
  [in] | p_bit | Parity check: ECC_DISABLED, ECC_ENABLED

Returns
  0

The function sets 4k/64k page parity check

## ◆ MMU_PSection()

__STATIC_INLINE int MMU_PSection | ( | uint32_t * | descriptor_l1,
|  | mmu_ecc_check_Type | p_bit
| ) |  |

Set section parity check.

Parameters

  [out] | descriptor_l1 | L1 descriptor.
  [in] | p_bit | Parity check: ECC_DISABLED, ECC_ENABLED

Returns
  0

The function sets section parity check

## ◆ MMU_SecurePage()

__STATIC_INLINE int MMU_SecurePage | ( | uint32_t * | descriptor_l1,
|  | mmu_secure_Type | s_bit
| ) |  |

Set 4k/64k page Security attribute.

Parameters

  [out] | descriptor_l1 | L1 descriptor.
  [in] | s_bit | 4k/64k page Security attribute: SECURE, NON_SECURE

Returns
  0

The function sets 4k/64k page Global attribute

## ◆ MMU_SecureSection()

__STATIC_INLINE int MMU_SecureSection | ( | uint32_t * | descriptor_l1,
|  | mmu_secure_Type | s_bit
| ) |  |

Set section Security attribute.

Parameters

  [out] | descriptor_l1 | L1 descriptor.
  [in] | s_bit | Section Security attribute: SECURE, NON_SECURE

Returns
  0

The function sets section Global attribute

## ◆ MMU_SharedPage()

__STATIC_INLINE int MMU_SharedPage | ( | uint32_t * | descriptor_l2,
|  | mmu_shared_Type | s_bit
| ) |  |

Set 4k/64k page shareability.

Parameters

  [out] | descriptor_l2 | L2 descriptor.
  [in] | s_bit | 4k/64k page shareability: NON_SHARED, SHARED

Returns
  0

The function sets 4k/64k page shareability

## ◆ MMU_SharedSection()

__STATIC_INLINE int MMU_SharedSection | ( | uint32_t * | descriptor_l1,
|  | mmu_shared_Type | s_bit
| ) |  |

Set section shareability.

Parameters

  [out] | descriptor_l1 | L1 descriptor.
  [in] | s_bit | Section shareability: NON_SHARED, SHARED

Returns
  0

The function sets section shareability

## ◆ MMU_TTPage4k()

__STATIC_INLINE void MMU_TTPage4k | ( | uint32_t * | ttb,
|  | uint32_t | base_address,
|  | uint32_t | count,
|  | uint32_t | descriptor_l1,
|  | uint32_t * | ttb_l2,
|  | uint32_t | descriptor_l2
| ) |  |

Create a 4k page entry.

Parameters

  [in] | ttb | L1 table base address
  [in] | base_address | 4k base address
  [in] | count | Number of 4k pages to create
  [in] | descriptor_l1 | L1 descriptor (region attributes)
  [in] | ttb_l2 | L2 table base address
  [in] | descriptor_l2 | L2 descriptor (region attributes)

## ◆ MMU_TTPage64k()

__STATIC_INLINE void MMU_TTPage64k | ( | uint32_t * | ttb,
|  | uint32_t | base_address,
|  | uint32_t | count,
|  | uint32_t | descriptor_l1,
|  | uint32_t * | ttb_l2,
|  | uint32_t | descriptor_l2
| ) |  |

Create a 64k page entry.

Parameters

  [in] | ttb | L1 table base address
  [in] | base_address | 64k base address
  [in] | count | Number of 64k pages to create
  [in] | descriptor_l1 | L1 descriptor (region attributes)
  [in] | ttb_l2 | L2 table base address
  [in] | descriptor_l2 | L2 descriptor (region attributes)

## ◆ MMU_TTSection()

__STATIC_INLINE void MMU_TTSection | ( | uint32_t * | ttb,
|  | uint32_t | base_address,
|  | uint32_t | count,
|  | uint32_t | descriptor_l1
| ) |  |

Create a 1MB Section.

Parameters

  [in] | ttb | Translation table base address
  [in] | base_address | Section base address
  [in] | count | Number of sections to create
  [in] | descriptor_l1 | L1 descriptor (region attributes)

## ◆ MMU_XNPage()

__STATIC_INLINE int MMU_XNPage | ( | uint32_t * | descriptor_l2,
|  | mmu_execute_Type | xn,
|  | mmu_region_size_Type | page
| ) |  |

Set 4k/64k page execution-never attribute.

Parameters

  [out] | descriptor_l2 | L2 descriptor.
  [in] | xn | Page execution-never attribute : EXECUTE , NON_EXECUTE.
  [in] | page | Page size: PAGE_4k, PAGE_64k,

Returns
  0

The function sets 4k/64k page execution-never attribute

## ◆ MMU_XNSection()

__STATIC_INLINE int MMU_XNSection | ( | uint32_t * | descriptor_l1,
|  | mmu_execute_Type | xn
| ) |  |

Set section execution-never attribute.

Parameters

  [out] | descriptor_l1 | L1 descriptor.
  [in] | xn | Section execution-never attribute : EXECUTE , NON_EXECUTE.

Returns
  0

The function sets section execution-never attribute