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

Intel page directory implementation. More...

#include <IntelPageDirectory.h>

Public Member Functions

MemoryContext::Result copy (IntelPageDirectory *directory, Address from, Address to)
 Copy mappings from another directory. More...
 
MemoryContext::Result map (Address virt, Address phys, Memory::Access access, SplitAllocator *alloc)
 Map a virtual address to a physical address. 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...
 
IntelPageTablegetPageTable (Address virt, SplitAllocator *alloc) const
 Retrieve second level page table. More...
 
u32 flags (Memory::Access access) const
 Convert Memory::Access to page directory flags. More...
 

Private Attributes

u32 m_tables [1024]
 Array of page directory entries. More...
 

Detailed Description

Intel page directory implementation.

Definition at line 42 of file IntelPageDirectory.h.

Member Function Documentation

◆ access()

MemoryContext::Result IntelPageDirectory::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.
allocMemory allocator used by the caller
Returns
Result code.

Definition at line 122 of file IntelPageDirectory.cpp.

References IntelPageTable::access(), getPageTable(), and MemoryContext::InvalidAddress.

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

◆ copy()

MemoryContext::Result IntelPageDirectory::copy ( IntelPageDirectory directory,
Address  from,
Address  to 
)

Copy mappings from another directory.

Parameters
directorySource page directory to copy from
fromVirtual address to start copy mapping from
toEnd virtual address of mappings to copy
Returns
Result code

Definition at line 52 of file IntelPageDirectory.cpp.

References DIRENTRY, m_tables, MegaByte, and MemoryContext::Success.

Referenced by IntelPaging::initialize().

◆ flags()

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

Convert Memory::Access to page directory flags.

Parameters
accessInput memory access flags
Returns
Page directory flags

Definition at line 133 of file IntelPageDirectory.cpp.

References access(), PAGE_USER, PAGE_WRITE, Memory::User, and Memory::Writable.

Referenced by map().

◆ getPageTable()

IntelPageTable * IntelPageDirectory::getPageTable ( Address  virt,
SplitAllocator alloc 
) const
private

Retrieve second level page table.

Parameters
virtInput virtual address to find second level page table for
allocMemory allocator for high/low translation
Returns
Pointer to second level page table

Definition at line 41 of file IntelPageDirectory.cpp.

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

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

◆ map()

MemoryContext::Result IntelPageDirectory::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 64 of file IntelPageDirectory.cpp.

References access(), Allocator::Range::address, Allocator::Range::alignment, SplitAllocator::allocate(), DIRENTRY, flags(), getPageTable(), m_tables, IntelPageTable::map(), MemoryContext::OutOfMemory, PAGE_PRESENT, PAGE_WRITE, PAGESIZE, MemoryBlock::set(), Allocator::Range::size, and Allocator::Success.

Referenced by IntelPaging::map().

◆ releasePhysical()

void IntelPageDirectory::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 143 of file IntelPageDirectory.cpp.

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

Referenced by releaseRange(), and releaseSection().

◆ releaseRange()

MemoryContext::Result IntelPageDirectory::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 163 of file IntelPageDirectory.cpp.

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

Referenced by IntelPaging::releaseRange().

◆ releaseSection()

MemoryContext::Result IntelPageDirectory::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 189 of file IntelPageDirectory.cpp.

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

Referenced by IntelPaging::releaseSection().

◆ translate()

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

Translate virtual address to physical address.

Parameters
virtVirtual address to lookup on input.
physOn output contains the translated physical memory address.
allocMemory allocator used by the caller
Returns
Result code

Definition at line 101 of file IntelPageDirectory.cpp.

References DIRENTRY, getPageTable(), MemoryContext::InvalidAddress, m_tables, MegaByte, PAGE_SECTION, PAGESIZE, SECTIONMASK, MemoryContext::Success, and IntelPageTable::translate().

Referenced by IntelPaging::lookup().

◆ unmap()

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

Remove virtual address mapping.

Parameters
virtVirtual address.
allocMemory allocator used by the caller
Returns
Result code

Definition at line 92 of file IntelPageDirectory.cpp.

References getPageTable(), MemoryContext::InvalidAddress, and IntelPageTable::unmap().

Referenced by IntelPaging::unmap().

Field Documentation

◆ m_tables

u32 IntelPageDirectory::m_tables[1024]
private

Array of page directory entries.

Definition at line 168 of file IntelPageDirectory.h.

Referenced by copy(), getPageTable(), map(), releaseSection(), and translate().


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