FreeNOS
|
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... | |
IntelPageTable * | getPageTable (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... | |
Intel page directory implementation.
Definition at line 42 of file IntelPageDirectory.h.
MemoryContext::Result IntelPageDirectory::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 | Memory allocator used by the caller |
Definition at line 122 of file IntelPageDirectory.cpp.
References IntelPageTable::access(), getPageTable(), and MemoryContext::InvalidAddress.
Referenced by IntelPaging::access(), flags(), and map().
MemoryContext::Result IntelPageDirectory::copy | ( | IntelPageDirectory * | directory, |
Address | from, | ||
Address | to | ||
) |
Copy mappings from another directory.
directory | Source page directory to copy from |
from | Virtual address to start copy mapping from |
to | End virtual address of mappings to copy |
Definition at line 52 of file IntelPageDirectory.cpp.
References DIRENTRY, m_tables, MegaByte, and MemoryContext::Success.
Referenced by IntelPaging::initialize().
|
private |
Convert Memory::Access to page directory flags.
access | Input memory access flags |
Definition at line 133 of file IntelPageDirectory.cpp.
References access(), PAGE_USER, PAGE_WRITE, Memory::User, and Memory::Writable.
Referenced by map().
|
private |
Retrieve second level page table.
virt | Input virtual address to find second level page table for |
alloc | Memory allocator for high/low translation |
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().
MemoryContext::Result IntelPageDirectory::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 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().
|
inlineprivate |
Release a single physical page.
alloc | Memory allocator to release memory from |
phys | Physical 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().
MemoryContext::Result IntelPageDirectory::releaseRange | ( | const Memory::Range | range, |
SplitAllocator * | alloc | ||
) |
Release range of memory.
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().
MemoryContext::Result IntelPageDirectory::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 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().
MemoryContext::Result IntelPageDirectory::translate | ( | Address | virt, |
Address * | phys, | ||
SplitAllocator * | alloc | ||
) | const |
Translate virtual address to physical address.
virt | Virtual address to lookup on input. |
phys | On output contains the translated physical memory address. |
alloc | Memory allocator used by the caller |
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().
MemoryContext::Result IntelPageDirectory::unmap | ( | Address | virt, |
SplitAllocator * | alloc | ||
) |
Remove virtual address mapping.
virt | Virtual address. |
alloc | Memory allocator used by the caller |
Definition at line 92 of file IntelPageDirectory.cpp.
References getPageTable(), MemoryContext::InvalidAddress, and IntelPageTable::unmap().
Referenced by IntelPaging::unmap().
|
private |
Array of page directory entries.
Definition at line 168 of file IntelPageDirectory.h.
Referenced by copy(), getPageTable(), map(), releaseSection(), and translate().