FreeNOS
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
ARM64FirstTable Class Reference

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.
 
ARM64SecondTablegetSecondTable (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]
 

Detailed Description

ARM64 first level page table.

Definition at line 44 of file ARM64FirstTable.h.

Member Function Documentation

◆ access()

MemoryContext::Result ARM64FirstTable::access ( Address  virt,
Memory::Access access,
SplitAllocator alloc 
) const

Get Access flags for a virtual address.

Parameters
virtVirtual address to get Access flags for.
accessMemoryAccess object pointer.
allocPhysical memory allocator
Returns
Result code.

Definition at line 188 of file ARM64FirstTable.cpp.

References ARM64SecondTable::access(), access(), getSecondTable(), and MemoryContext::InvalidAddress.

Referenced by ARM64Paging::access(), access(), flags(), and map().

◆ flags()

u32 ARM64FirstTable::flags ( Memory::Access  access) const
private

Convert Memory::Access to first level page table flags.

Parameters
accessMemory access flags to convert
Returns
Page table access flags

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.

◆ get_l2_entry()

u64 ARM64FirstTable::get_l2_entry ( Address  virt,
SplitAllocator alloc,
u64 **  tbl_l2,
unsigned int *  l2_idx 
) const
private

Get entry of Level 2 table.

Parameters
virtVirtual address to fetch page table for
allocPhysical memory allocator
tbl_l2[out]ptr to Level 2 table
l2_idx[out]index of entry
Returns
entry of Virtual address

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().

◆ getSecondTable()

ARM64SecondTable * ARM64FirstTable::getSecondTable ( Address  virt,
SplitAllocator alloc 
) const
private

Retrieve second level page table.

Entry inside the page directory of a given virtual address.

Parameters
virtVirtual address to fetch page table for
allocPhysical memory allocator
Returns
Second level page table
Parameters
vaddrVirtual Address.
Returns
Index of the corresponding page directory entry.

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().

◆ initialize()

void ARM64FirstTable::initialize ( ARM64FirstTable firstTable)
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().

◆ map()

MemoryContext::Result ARM64FirstTable::map ( Address  virt,
Address  phys,
Memory::Access  access,
SplitAllocator alloc 
)

Map a virtual address to a physical address.

Parameters
virtVirtual address.
physPhysical address.
accessMemory access flags.
allocPhysical memory allocator for extra page tables.
Returns
Result code

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().

◆ mapLarge()

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.

Parameters
rangeVirtual to physical memory range.
allocPhysical memory allocator for extra page tables.
Returns
Result code

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().

◆ releasePhysical()

void ARM64FirstTable::releasePhysical ( SplitAllocator alloc,
const Address  phys 
)
inlineprivate

Release a single physical page.

Parameters
allocMemory allocator to release memory from
physPhysical 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().

◆ releaseRange()

MemoryContext::Result ARM64FirstTable::releaseRange ( const Memory::Range  range,
SplitAllocator alloc 
)

Release range of memory.

Parameters
rangeMemory range input
allocMemory allocator to release memory from
Returns
Result code

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().

◆ releaseSection()

MemoryContext::Result ARM64FirstTable::releaseSection ( const Memory::Range  range,
SplitAllocator alloc,
const bool  tablesOnly 
)

Release memory sections.

Parameters
rangeMemory range of the sections to release
allocMemory allocator to release memory from
tablesOnlySet to true to only release page tables and not mapped pages.
Returns
Result code.

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().

◆ translate()

MemoryContext::Result ARM64FirstTable::translate ( Address  virt,
Address phys,
SplitAllocator alloc 
) const

Translate virtual address to physical address.

Parameters
virtVirtual address to lookup as input
physPhysical address corresponding to the virtual address
allocPhysical memory allocator
Returns
Result code

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().

◆ unmap()

MemoryContext::Result ARM64FirstTable::unmap ( Address  virt,
SplitAllocator alloc 
)

Remove virtual address mapping.

Parameters
virtVirtual address.
allocPhysical memory allocator
Returns
Result code

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().

Field Documentation

◆ m_tables_l1

u64 ARM64FirstTable::m_tables_l1[512]
private

Array of page table entries.

Definition at line 185 of file ARM64FirstTable.h.

Referenced by get_l2_entry(), and initialize().

◆ m_tables_l2

u64 ARM64FirstTable::m_tables_l2[4][512]
private

Definition at line 186 of file ARM64FirstTable.h.

Referenced by initialize().


The documentation for this class was generated from the following files: