|
FreeNOS
|
ARM virtual memory implementation. More...
#include <ARMPaging.h>
Public Member Functions | |
| ARMPaging (MemoryMap *map, SplitAllocator *alloc) | |
| Constructor. More... | |
| ARMPaging (MemoryMap *map, Address firstTableAddress, Address kernelBaseAddress) | |
| Secondary constructor with pre-allocated 1st page table. More... | |
| virtual | ~ARMPaging () |
| Destructor. More... | |
| virtual Result | initialize () |
| Initialize the MemoryContext. More... | |
| virtual Result | activate (bool initializeMMU=false) |
| Activate the MemoryContext. More... | |
| virtual Result | map (Address virt, Address phys, Memory::Access access) |
| Map a physical page to a virtual address. More... | |
| virtual Result | unmap (Address virt) |
| Unmap a virtual address. More... | |
| virtual Result | lookup (Address virt, Address *phys) const |
| Translate virtual address to physical address. More... | |
| virtual Result | access (Address virt, Memory::Access *access) const |
| Get Access flags for a virtual address. More... | |
| virtual Result | releaseSection (const Memory::Range &range, const bool tablesOnly=false) |
| Release memory sections. More... | |
| virtual Result | releaseRange (Memory::Range *range) |
| Release range of memory. More... | |
Public Member Functions inherited from MemoryContext | |
| MemoryContext (MemoryMap *map, SplitAllocator *alloc) | |
| Constructor. More... | |
| virtual | ~MemoryContext () |
| Destructor. More... | |
| virtual Result | mapRangeContiguous (Memory::Range *range) |
| Map a range of contiguous physical pages to virtual addresses. More... | |
| virtual Result | mapRangeSparse (Memory::Range *range) |
| Map and allocate a range of sparse (non-contiguous) physical pages to virtual addresses. More... | |
| virtual Result | unmapRange (Memory::Range *range) |
| Unmaps a range of virtual memory. More... | |
| virtual Result | release (Address virt) |
| Release a memory page mapping. More... | |
| virtual Result | findFree (Size size, MemoryMap::Region region, Address *virt) const |
| Find unused memory. More... | |
| virtual void | mapRangeSparseCallback (Address *phys) |
| Callback to provide intermediate Range object during mapRangeSparse() More... | |
Private Member Functions | |
| void | setupFirstTable (MemoryMap *map, Address firstTableAddress, Address kernelBaseAddress) |
| Installs default mappings on 1st level page table. More... | |
| Result | enableMMU () |
| Enable the MMU. More... | |
Private Attributes | |
| ARMFirstTable * | m_firstTable |
| Pointer to the first level page table. More... | |
| Address | m_firstTableAddr |
| Physical address of the first level page table. More... | |
| Address | m_kernelBaseAddr |
| Kernel base address. More... | |
| Arch::Cache | m_cache |
| Caching implementation. More... | |
Additional Inherited Members | |
Public Types inherited from MemoryContext | |
| enum | Result { Success, InvalidAddress, InvalidSize, AlreadyExists, OutOfMemory } |
| Result codes. More... | |
| typedef enum MemoryContext::Result | Result |
| Result codes. More... | |
Static Public Member Functions inherited from MemoryContext | |
| static MemoryContext * | getCurrent () |
| Get currently active MemoryContext. More... | |
Protected Attributes inherited from MemoryContext | |
| SplitAllocator * | m_alloc |
| Physical memory allocator. More... | |
| MemoryMap * | m_map |
| Virtual memory layout. More... | |
| Callback< MemoryContext, Address > | m_mapRangeSparseCallback |
| Callback object for mapRangeSparseCallback function. More... | |
| Memory::Range * | m_savedRange |
| Saved range input for use in the mapRangeSparse Callback. More... | |
| Size | m_numSparsePages |
| Number of pages allocated via mapRangeSparse Callback. More... | |
Static Protected Attributes inherited from MemoryContext | |
| static MemoryContext * | m_current = 0 |
| The currently active MemoryContext. More... | |
ARM virtual memory implementation.
Definition at line 43 of file ARMPaging.h.
| ARMPaging::ARMPaging | ( | MemoryMap * | map, |
| SplitAllocator * | alloc | ||
| ) |
Constructor.
| map | Virtual memory map. |
| alloc | Allocator pointer of the physical memory page allocations. |
Definition at line 28 of file ARMPaging.cpp.
Secondary constructor with pre-allocated 1st page table.
| map | Virtual memory map |
| firstTableAddress | Physical address of 1st page table |
| kernelBaseAddress | Physical base address of the kernel |
Definition at line 45 of file ARMPaging.cpp.
|
virtual |
Destructor.
Definition at line 36 of file ARMPaging.cpp.
References MemoryContext::m_alloc, m_firstTableAddr, PAGESIZE, and SplitAllocator::release().
|
virtual |
Get Access flags for a virtual address.
| virt | Virtual address to get Access flags for. |
| access | MemoryAccess object pointer. |
Implements MemoryContext.
Definition at line 274 of file ARMPaging.cpp.
References ARMFirstTable::access(), MemoryContext::m_alloc, and m_firstTable.
|
virtual |
Activate the MemoryContext.
This function applies this MemoryContext on the hardware MMU.
| initializeMMU | If true perform (re)initialization of the MMU |
Implements MemoryContext.
Definition at line 198 of file ARMPaging.cpp.
References ARMCacheV6::cleanInvalidate(), enableMMU(), isb(), m_cache, MemoryContext::m_current, m_firstTableAddr, mcr, MemoryContext::Success, tlb_flush_all(), ARMControl::TranslationTable0, Cache::Unified, and ARMControl::write().
Referenced by kernel_main().
|
private |
|
virtual |
Initialize the MemoryContext.
Implements MemoryContext.
Definition at line 55 of file ARMPaging.cpp.
References Memory::Range::access, Allocator::Range::address, Allocator::Range::alignment, SplitAllocator::allocate(), Memory::Device, MemoryMap::KernelData, MemoryContext::m_alloc, m_firstTable, m_firstTableAddr, m_kernelBaseAddr, MemoryContext::m_map, ARMFirstTable::mapLarge(), MegaByte, MemoryContext::OutOfMemory, Memory::Range::phys, MemoryMap::range(), Memory::Readable, MemoryBlock::set(), Memory::Range::size, Allocator::Range::size, MemoryContext::Success, Allocator::Success, ARMFirstTable::unmap(), Memory::Range::virt, and Memory::Writable.
Referenced by kernel_main().
|
virtual |
Translate virtual address to physical address.
| virt | Virtual address to lookup on input |
| phys | Contains the physical address on output. |
Implements MemoryContext.
Definition at line 269 of file ARMPaging.cpp.
References MemoryContext::m_alloc, m_firstTable, and ARMFirstTable::translate().
|
virtual |
Map a physical page to a virtual address.
| virt | Virtual address. |
| phys | Physical address. |
| access | Memory access flags. |
Implements MemoryContext.
Definition at line 237 of file ARMPaging.cpp.
References isb(), MemoryContext::m_alloc, MemoryContext::m_current, m_firstTable, ARMFirstTable::map(), and tlb_invalidate.
|
virtual |
Release range of memory.
| range | Memory range input |
Implements MemoryContext.
Definition at line 285 of file ARMPaging.cpp.
References MemoryContext::m_alloc, m_firstTable, and ARMFirstTable::releaseRange().
|
virtual |
Release memory sections.
Deallocate all associated physical memory which resides in the given memory section range.
| range | Range of memory sections to release |
| tablesOnly | True to only release associated page tables and do not release the actual mapped pages |
Implements MemoryContext.
Definition at line 279 of file ARMPaging.cpp.
References MemoryContext::m_alloc, m_firstTable, and ARMFirstTable::releaseSection().
|
private |
Installs default mappings on 1st level page table.
| map | Virtual memory map |
| firstTableAddress | Physical address of 1st level page table |
| kernelBaseAddress | Physical address of the kernel base |
|
virtual |
Unmap a virtual address.
This function removes a virtual to physical memory mapping without deallocating any physical memory.
| virt | Virtual address to unmap. |
Implements MemoryContext.
Definition at line 251 of file ARMPaging.cpp.
References ARMCacheV6::cleanInvalidateAddress(), Cache::Data, isb(), MemoryContext::m_alloc, m_cache, MemoryContext::m_current, m_firstTable, tlb_invalidate, and ARMFirstTable::unmap().
|
private |
Caching implementation.
Definition at line 184 of file ARMPaging.h.
Referenced by activate(), and unmap().
|
private |
Pointer to the first level page table.
Definition at line 175 of file ARMPaging.h.
Referenced by access(), initialize(), lookup(), map(), releaseRange(), releaseSection(), and unmap().
|
private |
Physical address of the first level page table.
Definition at line 178 of file ARMPaging.h.
Referenced by activate(), initialize(), and ~ARMPaging().
|
private |
1.8.17