FreeNOS
Public Member Functions | Private Member Functions | Private Attributes
ARMFirstTable Class Reference

ARM first level page table. More...

#include <ARMFirstTable.h>

Public Member Functions

MemoryContext::Result map (Address virt, Address phys, Memory::Access access, SplitAllocator *alloc)
 Map a virtual address to a physical address. More...
 
MemoryContext::Result mapLarge (Memory::Range range, SplitAllocator *alloc)
 Map a contigous range of virtual memory to physical memory. More...
 
MemoryContext::Result unmap (Address virt, SplitAllocator *alloc)
 Remove virtual address mapping. More...
 
MemoryContext::Result translate (Address virt, Address *phys, SplitAllocator *alloc) const
 Translate virtual address to physical address. More...
 
MemoryContext::Result access (Address virt, Memory::Access *access, SplitAllocator *alloc) const
 Get Access flags for a virtual address. More...
 
MemoryContext::Result releaseSection (const Memory::Range range, SplitAllocator *alloc, const bool tablesOnly)
 Release memory sections. More...
 
MemoryContext::Result releaseRange (const Memory::Range range, SplitAllocator *alloc)
 Release range of memory. More...
 

Private Member Functions

void releasePhysical (SplitAllocator *alloc, const Address phys)
 Release a single physical page. More...
 
ARMSecondTablegetSecondTable (Address virt, SplitAllocator *alloc) const
 Retrieve second level page table. More...
 
u32 flags (Memory::Access access) const
 Convert Memory::Access to first level page table flags. More...
 

Private Attributes

u32 m_tables [4096]
 Array of page table entries. More...
 

Detailed Description

ARM first level page table.

Definition at line 43 of file ARMFirstTable.h.

Member Function Documentation

◆ access()

MemoryContext::Result ARMFirstTable::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 221 of file ARMFirstTable.cpp.

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

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

◆ flags()

u32 ARMFirstTable::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 232 of file ARMFirstTable.cpp.

References access(), Memory::Device, Memory::Executable, PAGE1_AP_SYS, PAGE1_AP_USER, PAGE1_APX, PAGE1_CACHE_WRITEBACK, PAGE1_DEVICE_SHARED, PAGE1_NOEXEC, PAGE1_UNCACHED, Memory::Uncached, Memory::User, and Memory::Writable.

Referenced by mapLarge().

◆ getSecondTable()

ARMSecondTable * ARMFirstTable::getSecondTable ( Address  virt,
SplitAllocator alloc 
) const
private

Retrieve second level page table.

Parameters
virtVirtual address to fetch page table for
allocPhysical memory allocator
Returns
Second level page table

Definition at line 113 of file ARMFirstTable.cpp.

References DIRENTRY, entry, m_tables, PAGE1_TABLE, PAGEMASK, SplitAllocator::toVirtual(), and ZERO.

Referenced by access(), map(), releaseRange(), releaseSection(), translate(), and unmap().

◆ map()

MemoryContext::Result ARMFirstTable::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 124 of file ARMFirstTable.cpp.

References access(), Allocator::Range::address, Allocator::Range::alignment, SplitAllocator::allocate(), MemoryContext::AlreadyExists, Cache::cleanData(), DIRENTRY, getSecondTable(), m_tables, ARMSecondTable::map(), MemoryContext::OutOfMemory, PAGE1_SECTION, PAGE1_TABLE, PAGESIZE, MemoryBlock::set(), Allocator::Range::size, and Allocator::Success.

Referenced by ARMPaging::map().

◆ mapLarge()

MemoryContext::Result ARMFirstTable::mapLarge ( Memory::Range  range,
SplitAllocator alloc 
)

Map a contigous range of virtual memory to physical memory.

This function can map at the granularity of 1 megabyte memory chunks.

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

Definition at line 158 of file ARMFirstTable.cpp.

References Memory::Range::access, MemoryContext::AlreadyExists, Cache::cleanData(), DIRENTRY, flags(), MemoryContext::InvalidAddress, MemoryContext::InvalidSize, m_tables, MegaByte, PAGE1_SECTION, PAGE1_TABLE, PAGEMASK, Memory::Range::phys, Memory::Range::size, MemoryContext::Success, and Memory::Range::virt.

Referenced by ARMPaging::initialize().

◆ releasePhysical()

void ARMFirstTable::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 249 of file ARMFirstTable.cpp.

References Allocator::base(), SplitAllocator::isAllocated(), SplitAllocator::release(), and Allocator::size().

Referenced by releaseRange(), and releaseSection().

◆ releaseRange()

MemoryContext::Result ARMFirstTable::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 269 of file ARMFirstTable.cpp.

References getSecondTable(), MemoryContext::InvalidAddress, PAGESIZE, releasePhysical(), Memory::Range::size, MemoryContext::Success, ARMSecondTable::translate(), ARMSecondTable::unmap(), Memory::Range::virt, and ZERO.

Referenced by ARMPaging::releaseRange().

◆ releaseSection()

MemoryContext::Result ARMFirstTable::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 295 of file ARMFirstTable.cpp.

References DIRENTRY, getSecondTable(), MemoryContext::InvalidAddress, m_tables, MegaByte, PAGEMASK, PAGESIZE, SplitAllocator::release(), releasePhysical(), SECTIONMASK, Memory::Range::size, MemoryContext::Success, ARMSecondTable::translate(), and Memory::Range::virt.

Referenced by ARMPaging::releaseSection().

◆ translate()

MemoryContext::Result ARMFirstTable::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 200 of file ARMFirstTable.cpp.

References DIRENTRY, getSecondTable(), MemoryContext::InvalidAddress, m_tables, MegaByte, PAGE1_SECTION, PAGESIZE, SECTIONMASK, MemoryContext::Success, and ARMSecondTable::translate().

Referenced by ARMPaging::lookup().

◆ unmap()

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

Remove virtual address mapping.

Parameters
virtVirtual address.
allocPhysical memory allocator
Returns
Result code

Definition at line 180 of file ARMFirstTable.cpp.

References Cache::cleanData(), DIRENTRY, getSecondTable(), MemoryContext::InvalidAddress, m_tables, PAGE1_NONE, PAGE1_SECTION, MemoryContext::Success, and ARMSecondTable::unmap().

Referenced by ARMPaging::initialize(), and ARMPaging::unmap().

Field Documentation

◆ m_tables

u32 ARMFirstTable::m_tables[4096]
private

Array of page table entries.

Definition at line 170 of file ARMFirstTable.h.

Referenced by getSecondTable(), map(), mapLarge(), releaseSection(), translate(), and unmap().


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