Professional Documents
Culture Documents
JW Chen
Agenda
MPU Overview MMU Overview Detail of the ARM MMU Memory Configuration of Hermon
MPU overview
Background
Some Embedded systems use a multitasking operating or control system and must ensure that a running task does not disrupt the operation of other tasks. There are two methods to control access to system resource, unprotected and protected. A protected system relies on both hardware and software to protect the system resources. ARM provides several processors equipped with hardware that actively protects system resources, either through Memory Protection Unit(MPU) or a Memory Management Unit(MMU)
Protected Region
ARM MPU use regions as the primary construct for system protection. A region is a set of attributes associated with a area of memory The Rules for regions
Regions can overlap other regions Regions are assigned a priority number that is independent of the privilege assigned to the region When regions overlap, the attributes of the region with the highest priority number take precedence over the other regions. The priority only applies over the address within the areas that overlap. A regions starting address must be a multiple of its size. A regions size can be any power of two between 4KB and 4GB Accessing an area of main memory outside of a defined region results in an abort.The MPU generate a prefetch abort if the core was fetching an instruction or a data abort if the memory request was for data.
Background regions
Background regions : A low-priority region used to assign the same attributes to a large memory area Region 0 Region 0 Region 0 Task 3 shield several dormant memory areas Can Task 3 Task 3 Region from unwanted access while another part of the background region is active under2 a Task 2 Region 3 Task 2 Task different regions control
Task 1 Region 3 Task 1 Task 1
MMU Overview
overview
The primary difference from MPU is the addition of hardware to support virtual memory In an MMU, tasks can run even if they are compiled and linked to run in regions with overlapping addresses in main memory. To permit tasks to have their own virtual memory map, the MMU hardware performs address relocation The area of virtual memory is called page, and the area of physical memory to by the translation process is called page frame
Address relocation
TLB
Text Region1
Only running task has an active set of page tables To reduce the time which it takes to perform a context switch, a writethrough cache policy can be used (in the ARM9 family).
Page tables
There is a single level 1 master page table (also known as section page table )contains two types of page table entry(PTE) Master L1 page table divides the 4GB address space into 1MB sections, hence L1 page table contain 4096 page table entries If the L1 table is acting as a directory, the PTE contains a pointer to either an L2 coarse or L2 fine page table that represent 1MB of virtual memory If the L1 master table is translating a 1MB section, then the PTE contains the base address of the 1MB page frame in physical memory A coarse L2 page table has 256 entries consuming 1KB of main memory A coarse page table support a 4KB or 64KB pages If the coarse table translates a 64KB page, an identical PTE must be repeated in the page table 16 times for each 64KB page A fine L2 page table has 1024 entries consuming 4KB of main memory A fine page table support a 1KB, 4KB or 64KB pages If the fine table translates a 4KB page,the same PTE must be repeated 4 times If the fine table translates a 64KB page,the same PTE must be repeated 64 times
1.Save the active task context and place the task in a dormant state 2.Write the awakening tasks process ID to CP15:c13:c0 3.set the current tasks domain to no access, and the awakening tasks domain to client access, by writing to CP15:c3:c0(as below) 4.Restore the context of the awakening tasks 5.Resume execution of the restored task