Memory Management Unit (MMU)
Introduction
The Memory Management Unit (MMU) is a component provided by the Arm Cortex-A series MCU that maps virtual addresses to physical addresses to achieve memory protection. The main functions of the MMU include:
Address translation: Converts virtual addresses to physical addresses, mainly using long descriptor format in the SDK.
Permission checking: Checks access permissions to ensure that only authorized processes can access specific memory areas.
Memory isolation: Ensures memory isolation between different processes by dividing the virtual address space.
Cache management: Controls the behavior of the cache to improve memory access performance.
Usage
The MMU is initialized in the setupMMUTable()
function in ameba_xlat_table.c
during system boot.
The following code configures the non-cacheable data buffer as a non-cacheable data buffer.
mmap_add_region((uint64_t)((int)__ram_nocache_start__), (uintptr_t)__ram_nocache_start__, (size_t)__ram_nocache_end__ - (size_t)__ram_nocache_start__, \
MT_NON_CACHEABLE | MT_RW | MT_NS);
To leverage the read-only attributes of the MMU region for analysis, the following code can be added in setupMMUTable()
:
mmap_add_region((uint64_t)(StartAddr_PA, (uintptr_t)StartAddr_VA, (size_t)size_bytes, MT_MEMORY | MT_RO | MT_NS);
Since the SDK implements a direct virtual-to-physical address mapping, StartAddr_PA and StartAddr_VA share identical numerical values.
Note
Both StartAddr_PA and size_bytes must be multiples of 4KB.
All regions added in
setupMMUTable()
are allowed to have region A completely cover region B, but not allowed to have other forms of overlap between region A and region B.