|
FreeNOS
|
ARM64 first level page table. More...
#include <ARM64FirstTable.h>
Public Member Functions | |
| MemoryContext::Result | map (Address virt, Address phys, Memory::Access access, SplitAllocator *alloc) |
| Map a virtual address to a physical address. | |
| MemoryContext::Result | mapLarge (Memory::Range range, SplitAllocator *alloc) |
| Map a contigous range of virtual memory to physical memory. | |
| MemoryContext::Result | unmap (Address virt, SplitAllocator *alloc) |
| Remove virtual address mapping. | |
| MemoryContext::Result | translate (Address virt, Address *phys, SplitAllocator *alloc) const |
| Translate virtual address to physical address. | |
| MemoryContext::Result | access (Address virt, Memory::Access *access, SplitAllocator *alloc) const |
| Get Access flags for a virtual address. | |
| MemoryContext::Result | releaseSection (const Memory::Range range, SplitAllocator *alloc, const bool tablesOnly) |
| Release memory sections. | |
| MemoryContext::Result | releaseRange (const Memory::Range range, SplitAllocator *alloc) |
| Release range of memory. | |
Static Public Member Functions | |
| static void | initialize (ARM64FirstTable *firstTable) |
Private Member Functions | |
| void | releasePhysical (SplitAllocator *alloc, const Address phys) |
| Release a single physical page. | |
| ARM64SecondTable * | getSecondTable (Address virt, SplitAllocator *alloc) const |
| Retrieve second level page table. | |
| u32 | flags (Memory::Access access) const |
| Convert Memory::Access to first level page table flags. | |
| u64 | get_l2_entry (Address virt, SplitAllocator *alloc, u64 **tbl_l2, unsigned int *l2_idx) const |
| Get entry of Level 2 table. | |
Private Attributes | |
| u64 | m_tables_l1 [512] |
| Array of page table entries. | |
| u64 | m_tables_l2 [4][512] |
ARM64 first level page table.
Definition at line 44 of file ARM64FirstTable.h.
| MemoryContext::Result ARM64FirstTable::access | ( | Address | virt, |
| Memory::Access * | access, | ||
| SplitAllocator * | alloc | ||
| ) | const |
Get Access flags for a virtual address.
| virt | Virtual address to get Access flags for. |
| access | MemoryAccess object pointer. |
| alloc | Physical memory allocator |
Definition at line 188 of file ARM64FirstTable.cpp.
References ARM64SecondTable::access(), access(), getSecondTable(), and MemoryContext::InvalidAddress.
Referenced by ARM64Paging::access(), access(), flags(), and map().
|
private |
Convert Memory::Access to first level page table flags.
| access | Memory access flags to convert |
Definition at line 199 of file ARM64FirstTable.cpp.
References access(), Memory::Device, Memory::Executable, PT_AF, PT_DEV, PT_ISH, PT_KERNEL, PT_NC, PT_NX, PT_OSH, PT_RO, PT_USER, Memory::User, and Memory::Writable.
|
private |
Get entry of Level 2 table.
| virt | Virtual address to fetch page table for |
| alloc | Physical memory allocator |
| tbl_l2[out] | ptr to Level 2 table |
| l2_idx[out] | index of entry |
Definition at line 34 of file ARM64FirstTable.cpp.
References assert, L1_IDX, L2_IDX, m_tables_l1, and PAGEMASK.
Referenced by getSecondTable(), map(), mapLarge(), releaseSection(), translate(), and unmap().
|
private |
Retrieve second level page table.
Entry inside the page directory of a given virtual address.
| virt | Virtual address to fetch page table for |
| alloc | Physical memory allocator |
| vaddr | Virtual Address. |
Definition at line 62 of file ARM64FirstTable.cpp.
References get_l2_entry(), IS_PT_PAGE_TBL, PAGEMASK, SplitAllocator::toVirtual(), and ZERO.
Referenced by access(), map(), releaseRange(), releaseSection(), translate(), and unmap().
|
static |
Definition at line 25 of file ARM64FirstTable.cpp.
References GigaByte, L1_BLOCK_SIZE, L1_IDX, m_tables_l1, m_tables_l2, and PT_PAGE.
Referenced by ARM64Paging::initialize().
| MemoryContext::Result ARM64FirstTable::map | ( | Address | virt, |
| Address | phys, | ||
| Memory::Access | access, | ||
| SplitAllocator * | alloc | ||
| ) |
Map a virtual address to a physical address.
| virt | Virtual address. |
| phys | Physical address. |
| access | Memory access flags. |
| alloc | Physical memory allocator for extra page tables. |
Definition at line 77 of file ARM64FirstTable.cpp.
References access(), Allocator::Range::address, Allocator::Range::alignment, SplitAllocator::allocate(), MemoryContext::AlreadyExists, get_l2_entry(), getSecondTable(), IS_PT_BLOCK, ARM64SecondTable::map(), MemoryContext::OutOfMemory, PAGESIZE, PT_PAGE, MemoryBlock::set(), Allocator::Range::size, and Allocator::Success.
Referenced by ARM64Paging::map().
| MemoryContext::Result ARM64FirstTable::mapLarge | ( | Memory::Range | range, |
| SplitAllocator * | alloc | ||
| ) |
Map a contigous range of virtual memory to physical memory.
This function can map at the granularity of 2 megabyte memory chunks.
| range | Virtual to physical memory range. |
| alloc | Physical memory allocator for extra page tables. |
Definition at line 116 of file ARM64FirstTable.cpp.
References Memory::Range::access, MemoryContext::AlreadyExists, flags, get_l2_entry(), MemoryContext::InvalidAddress, MemoryContext::InvalidSize, IS_PT_BLOCK, L2_BLOCK_MASK, L2_BLOCK_RANGE, L2_BLOCK_SIZE, Memory::Range::phys, PT_BLOCK, Memory::Range::size, MemoryContext::Success, and Memory::Range::virt.
Referenced by ARM64Paging::initialize().
|
inlineprivate |
Release a single physical page.
| alloc | Memory allocator to release memory from |
| phys | Physical address to release |
Definition at line 216 of file ARM64FirstTable.cpp.
References Allocator::base(), SplitAllocator::isAllocated(), SplitAllocator::release(), and Allocator::size().
Referenced by releaseRange(), and releaseSection().
| MemoryContext::Result ARM64FirstTable::releaseRange | ( | const Memory::Range | range, |
| SplitAllocator * | alloc | ||
| ) |
Release range of memory.
Definition at line 236 of file ARM64FirstTable.cpp.
References getSecondTable(), MemoryContext::InvalidAddress, PAGESIZE, releasePhysical(), Memory::Range::size, MemoryContext::Success, ARM64SecondTable::translate(), ARM64SecondTable::unmap(), Memory::Range::virt, and ZERO.
Referenced by ARM64Paging::releaseRange().
| MemoryContext::Result ARM64FirstTable::releaseSection | ( | const Memory::Range | range, |
| SplitAllocator * | alloc, | ||
| const bool | tablesOnly | ||
| ) |
Release memory sections.
| range | Memory range of the sections to release |
| alloc | Memory allocator to release memory from |
| tablesOnly | Set to true to only release page tables and not mapped pages. |
Definition at line 262 of file ARM64FirstTable.cpp.
References get_l2_entry(), getSecondTable(), MemoryContext::InvalidAddress, L2_BLOCK_MASK, L2_BLOCK_SIZE, PAGEMASK, PAGESIZE, SplitAllocator::release(), releasePhysical(), Memory::Range::size, MemoryContext::Success, ARM64SecondTable::translate(), and Memory::Range::virt.
Referenced by ARM64Paging::releaseSection().
| MemoryContext::Result ARM64FirstTable::translate | ( | Address | virt, |
| Address * | phys, | ||
| SplitAllocator * | alloc | ||
| ) | const |
Translate virtual address to physical address.
| virt | Virtual address to lookup as input |
| phys | Physical address corresponding to the virtual address |
| alloc | Physical memory allocator |
Definition at line 163 of file ARM64FirstTable.cpp.
References get_l2_entry(), getSecondTable(), MemoryContext::InvalidAddress, IS_PT_BLOCK, L2_BLOCK_RANGE, L2_BLOCK_SIZE, PAGESIZE, MemoryContext::Success, and ARM64SecondTable::translate().
Referenced by ARM64Paging::lookup().
| MemoryContext::Result ARM64FirstTable::unmap | ( | Address | virt, |
| SplitAllocator * | alloc | ||
| ) |
Remove virtual address mapping.
| virt | Virtual address. |
| alloc | Physical memory allocator |
Definition at line 141 of file ARM64FirstTable.cpp.
References get_l2_entry(), getSecondTable(), MemoryContext::InvalidAddress, IS_PT_BLOCK, PT_NONE, MemoryContext::Success, and ARM64SecondTable::unmap().
Referenced by ARM64Paging::initialize(), and ARM64Paging::unmap().
|
private |
Array of page table entries.
Definition at line 185 of file ARM64FirstTable.h.
Referenced by get_l2_entry(), and initialize().
|
private |
Definition at line 186 of file ARM64FirstTable.h.
Referenced by initialize().