CMSIS-Core (Cortex-A): Memory Management Unit Functions

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

- Main Page
- Usage and Description
- Reference

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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. More...
__STATIC_INLINE int | MMU_DomainSection (uint32_t *descriptor_l1, uint8_t domain)
| Set section domain. More...
__STATIC_INLINE int | MMU_PSection (uint32_t *descriptor_l1, mmu_ecc_check_Type p_bit)
| Set section parity check. More...
__STATIC_INLINE int | MMU_APSection (uint32_t *descriptor_l1, mmu_access_Type user, mmu_access_Type priv, uint32_t afe)
| Set section access privileges. More...
__STATIC_INLINE int | MMU_SharedSection (uint32_t *descriptor_l1, mmu_shared_Type s_bit)
| Set section shareability. More...
__STATIC_INLINE int | MMU_GlobalSection (uint32_t *descriptor_l1, mmu_global_Type g_bit)
| Set section Global attribute. More...
__STATIC_INLINE int | MMU_SecureSection (uint32_t *descriptor_l1, mmu_secure_Type s_bit)
| Set section Security attribute. More...
__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. More...
__STATIC_INLINE int | MMU_DomainPage (uint32_t *descriptor_l1, uint8_t domain)
| Set 4k/64k page domain. More...
__STATIC_INLINE int | MMU_PPage (uint32_t *descriptor_l1, mmu_ecc_check_Type p_bit)
| Set 4k/64k page parity check. More...
__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. More...
__STATIC_INLINE int | MMU_SharedPage (uint32_t *descriptor_l2, mmu_shared_Type s_bit)
| Set 4k/64k page shareability. More...
__STATIC_INLINE int | MMU_GlobalPage (uint32_t *descriptor_l2, mmu_global_Type g_bit)
| Set 4k/64k page Global attribute. More...
__STATIC_INLINE int | MMU_SecurePage (uint32_t *descriptor_l1, mmu_secure_Type s_bit)
| Set 4k/64k page Security attribute. More...
__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. More...
__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. More...
__STATIC_INLINE int | MMU_GetSectionDescriptor (uint32_t *descriptor, mmu_region_attributes_Type reg)
| Create a L1 section descriptor. More...
__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. More...
__STATIC_INLINE void | MMU_TTSection (uint32_t *ttb, uint32_t base_address, uint32_t count, uint32_t descriptor_l1)
| Create a 1MB Section. More...
__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. More...
__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. More...
__STATIC_INLINE void | MMU_Enable (void)
| Enable MMU. More...
__STATIC_INLINE void | MMU_Disable (void)
| Disable MMU. More...
__STATIC_INLINE void | MMU_InvalidateTLB (void)
| Invalidate entire unified TLB. More...

## Description

## Function Documentation

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

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

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

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

__STATIC_INLINE void MMU_Disable | ( | void |  | ) |

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

Parameters

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

Returns
  0

The function sets 4k/64k page domain

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

Parameters

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

Returns
  0

The function sets section domain.

__STATIC_INLINE void MMU_Enable | ( | void |  | ) |

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

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

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

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

Parameters

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

Returns
  0

The function creates a section descriptor.

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

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

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

Parameters

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

Returns
  0

The function sets section Global attribute

__STATIC_INLINE void MMU_InvalidateTLB | ( | void |  | ) |

__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
| ) |  |

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

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

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

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

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

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

Parameters

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

Returns
  0

The function sets section parity check

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

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

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

Parameters

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

Returns
  0

The function sets section Global attribute

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

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

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

Parameters

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

Returns
  0

The function sets section shareability

__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
| ) |  |

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)

__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
| ) |  |

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)

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

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)

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

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

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

Parameters

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

Returns
  0

The function sets section execution-never attribute