|
FreeNOS
|
Intel virtual memory implementation. More...
#include <IntelPaging.h>
Public Member Functions | |
| IntelPaging (MemoryMap *map, SplitAllocator *alloc) | |
| Constructor. More... | |
| IntelPaging (MemoryMap *map, Address pageDirectory, SplitAllocator *alloc) | |
| Constructor. More... | |
| virtual | ~IntelPaging () |
| Destructor. More... | |
| virtual Result | initialize () |
| Initialize the MemoryContext. More... | |
| virtual Result | activate (bool initializeMMU=false) |
| Activate the MemoryContext. More... | |
| virtual Result | map (Address virt, Address phys, Memory::Access access) |
| Map a physical page to a virtual address. More... | |
| virtual Result | unmap (Address virt) |
| Unmap a virtual address. More... | |
| virtual Result | lookup (Address virt, Address *phys) const |
| Translate virtual address to physical address. More... | |
| virtual Result | access (Address virt, Memory::Access *access) const |
| Get Access flags for a virtual address. More... | |
| virtual Result | releaseSection (const Memory::Range &range, const bool tablesOnly=false) |
| Release memory sections. More... | |
| virtual Result | releaseRange (Memory::Range *range) |
| Release range of memory. More... | |
Public Member Functions inherited from MemoryContext | |
| MemoryContext (MemoryMap *map, SplitAllocator *alloc) | |
| Constructor. More... | |
| virtual | ~MemoryContext () |
| Destructor. More... | |
| virtual Result | mapRangeContiguous (Memory::Range *range) |
| Map a range of contiguous physical pages to virtual addresses. More... | |
| virtual Result | mapRangeSparse (Memory::Range *range) |
| Map and allocate a range of sparse (non-contiguous) physical pages to virtual addresses. More... | |
| virtual Result | unmapRange (Memory::Range *range) |
| Unmaps a range of virtual memory. More... | |
| virtual Result | release (Address virt) |
| Release a memory page mapping. More... | |
| virtual Result | findFree (Size size, MemoryMap::Region region, Address *virt) const |
| Find unused memory. More... | |
| virtual void | mapRangeSparseCallback (Address *phys) |
| Callback to provide intermediate Range object during mapRangeSparse() More... | |
Private Attributes | |
| IntelPageDirectory * | m_pageDirectory |
| Pointer to page directory in kernel's virtual memory. More... | |
| Address | m_pageDirectoryAddr |
| Physical address of the page directory. More... | |
| bool | m_pageDirectoryAllocated |
| Set to true if page directory was allocated by this class. More... | |
Additional Inherited Members | |
Public Types inherited from MemoryContext | |
| enum | Result { Success, InvalidAddress, InvalidSize, AlreadyExists, OutOfMemory } |
| Result codes. More... | |
| typedef enum MemoryContext::Result | Result |
| Result codes. More... | |
Static Public Member Functions inherited from MemoryContext | |
| static MemoryContext * | getCurrent () |
| Get currently active MemoryContext. More... | |
Protected Attributes inherited from MemoryContext | |
| SplitAllocator * | m_alloc |
| Physical memory allocator. More... | |
| MemoryMap * | m_map |
| Virtual memory layout. More... | |
| Callback< MemoryContext, Address > | m_mapRangeSparseCallback |
| Callback object for mapRangeSparseCallback function. More... | |
| Memory::Range * | m_savedRange |
| Saved range input for use in the mapRangeSparse Callback. More... | |
| Size | m_numSparsePages |
| Number of pages allocated via mapRangeSparse Callback. More... | |
Static Protected Attributes inherited from MemoryContext | |
| static MemoryContext * | m_current = 0 |
| The currently active MemoryContext. More... | |
Intel virtual memory implementation.
Definition at line 43 of file IntelPaging.h.
| IntelPaging::IntelPaging | ( | MemoryMap * | map, |
| SplitAllocator * | alloc | ||
| ) |
Constructor.
Allocates new page tables for the paged memory context.
| map | Virtual memory map. |
| alloc | Allocator for physical memory page allocations. |
Definition at line 23 of file IntelPaging.cpp.
| IntelPaging::IntelPaging | ( | MemoryMap * | map, |
| Address | pageDirectory, | ||
| SplitAllocator * | alloc | ||
| ) |
Constructor.
Assign the given page directory to this paged memory context. This constructor does not allocate new page tables.
| map | Virtual memory map. |
| pageDirectory | Physical address of the page directory to use. |
| alloc | Allocator for physical memory page allocations. |
Definition at line 31 of file IntelPaging.cpp.
|
virtual |
Destructor.
Definition at line 39 of file IntelPaging.cpp.
References MemoryContext::m_alloc, m_pageDirectoryAddr, m_pageDirectoryAllocated, and SplitAllocator::release().
|
virtual |
Get Access flags for a virtual address.
| virt | Virtual address to get Access flags for. |
| access | MemoryAccess object pointer. |
Implements MemoryContext.
Definition at line 130 of file IntelPaging.cpp.
References IntelPageDirectory::access(), MemoryContext::m_alloc, and m_pageDirectory.
|
virtual |
Activate the MemoryContext.
This function applies this MemoryContext on the hardware MMU.
| initializeMMU | If true perform (re)initialization of the MMU |
Implements MemoryContext.
Definition at line 95 of file IntelPaging.cpp.
References MemoryContext::m_current, m_pageDirectoryAddr, MemoryContext::Success, and IntelCore::writeCR3().
Referenced by IntelKernel::IntelKernel().
|
virtual |
Initialize the MemoryContext.
Implements MemoryContext.
Definition at line 47 of file IntelPaging.cpp.
References Allocator::Range::address, Allocator::Range::alignment, SplitAllocator::allocate(), IntelPageDirectory::copy(), MemoryMap::KernelData, MemoryMap::KernelPrivate, MemoryContext::m_alloc, MemoryContext::m_map, m_pageDirectory, m_pageDirectoryAddr, m_pageDirectoryAllocated, MemoryContext::OutOfMemory, MemoryMap::range(), IntelCore::readCR3(), MemoryBlock::set(), Memory::Range::size, Allocator::Range::size, MemoryContext::Success, Allocator::Success, SplitAllocator::toVirtual(), and Memory::Range::virt.
Referenced by IntelKernel::IntelKernel().
|
virtual |
Translate virtual address to physical address.
| virt | Virtual address to lookup |
| phys | Translated physical memory address on output |
Implements MemoryContext.
Definition at line 125 of file IntelPaging.cpp.
References MemoryContext::m_alloc, m_pageDirectory, and IntelPageDirectory::translate().
|
virtual |
Map a physical page to a virtual address.
| virt | Virtual address. |
| phys | Physical address. |
| access | Memory access flags. |
Implements MemoryContext.
Definition at line 103 of file IntelPaging.cpp.
References MemoryContext::m_alloc, MemoryContext::m_current, m_pageDirectory, IntelPageDirectory::map(), MemoryContext::Success, and tlb_flush.
|
virtual |
Release range of memory.
| range | Memory range input |
Implements MemoryContext.
Definition at line 141 of file IntelPaging.cpp.
References MemoryContext::m_alloc, m_pageDirectory, and IntelPageDirectory::releaseRange().
|
virtual |
Release memory sections.
Deallocate all associated physical memory which resides in the given memory section range.
| range | Range of memory sections to release |
| tablesOnly | True to only release associated page tables and do not release the actual mapped pages |
Implements MemoryContext.
Definition at line 135 of file IntelPaging.cpp.
References MemoryContext::m_alloc, m_pageDirectory, and IntelPageDirectory::releaseSection().
|
virtual |
Unmap a virtual address.
This function removes a virtual to physical memory mapping without deallocating any physical memory.
| virt | Virtual address to unmap. |
Implements MemoryContext.
Definition at line 114 of file IntelPaging.cpp.
References MemoryContext::m_alloc, MemoryContext::m_current, m_pageDirectory, MemoryContext::Success, tlb_flush, and IntelPageDirectory::unmap().
|
private |
Pointer to page directory in kernel's virtual memory.
Definition at line 162 of file IntelPaging.h.
Referenced by access(), initialize(), lookup(), map(), releaseRange(), releaseSection(), and unmap().
|
private |
Physical address of the page directory.
Definition at line 165 of file IntelPaging.h.
Referenced by activate(), initialize(), and ~IntelPaging().
|
private |
Set to true if page directory was allocated by this class.
Definition at line 168 of file IntelPaging.h.
Referenced by initialize(), and ~IntelPaging().
1.8.17