The Pedigree Project
0.1
|
Implementation of the PhysicalMemoryManager for common x86. More...
#include <PhysicalMemoryManager.h>
Classes | |
struct | page |
class | PageHashable |
class | PageStack |
The Stack of pages (below4GB, below64GB, no constraint). More... | |
Public Member Functions | |
virtual physical_uintptr_t | allocatePage () |
virtual void | freePage (physical_uintptr_t page) |
virtual bool | allocateRegion (MemoryRegion &Region, size_t cPages, size_t pageConstraints, size_t Flags, physical_uintptr_t start=-1) |
virtual void | pin (physical_uintptr_t page) |
void | initialise (const BootstrapStruct_t &Info) INITIALISATION_ONLY |
void | initialisationDone () |
Public Member Functions inherited from PhysicalMemoryManager | |
virtual physical_uintptr_t | allocatePage (size_t pageConstraints=0)=0 |
void | allocateMemoryRegionList (Vector< MemoryRegionInfo * > &MemoryRegions) |
void | freeMemoryRegionList (Vector< MemoryRegionInfo * > &MemoryRegions) |
virtual size_t | freePageCount () const |
Static Public Member Functions | |
static HostedPhysicalMemoryManager & | instance () |
Static Public Member Functions inherited from PhysicalMemoryManager | |
static PhysicalMemoryManager & | instance () |
static size_t | getPageSize () PURE |
Protected Member Functions | |
HostedPhysicalMemoryManager () INITIALISATION_ONLY | |
virtual | ~HostedPhysicalMemoryManager () |
Protected Member Functions inherited from PhysicalMemoryManager | |
PhysicalMemoryManager () | |
virtual | ~PhysicalMemoryManager () |
Private Member Functions | |
HostedPhysicalMemoryManager (const HostedPhysicalMemoryManager &) | |
HostedPhysicalMemoryManager & | operator= (const HostedPhysicalMemoryManager &) |
int | getBackingFile () const |
void | unmapRegion (MemoryRegion *pRegion) |
virtual void | freePageUnlocked (physical_uintptr_t page) |
Private Attributes | |
PageStack | m_PageStack |
RangeList< uint64_t > | m_PhysicalRanges |
RangeList< uintptr_t > | m_MemoryRegions |
Spinlock | m_Lock |
Spinlock | m_RegionLock |
struct page * | m_PageMetadata |
int | m_BackingFile |
Static Private Attributes | |
static HostedPhysicalMemoryManager | m_Instance |
Friends | |
class | CacheManager |
class | Cache |
class | HostedVirtualAddressSpace |
Additional Inherited Members | |
Static Public Attributes inherited from PhysicalMemoryManager | |
static const size_t | continuous = 1 << 0 |
static const size_t | nonRamMemory = 1 << 1 |
static const size_t | force = 1 << 2 |
static const size_t | virtualOnly = 1 << 3 |
static const size_t | below1MB = 1 << 4 |
static const size_t | below16MB = 1 << 5 |
static const size_t | below4GB = 1 << 6 |
static const size_t | below64GB = 1 << 7 |
static const size_t | addressConstraints |
static const size_t | anonymous = 1 << 8 |
Protected Attributes inherited from PhysicalMemoryManager | |
Vector< MemoryRegion * > | m_MemoryRegions |
Implementation of the PhysicalMemoryManager for common x86.
The common x86 implementation of the PhysicalMemoryManager
Definition at line 37 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
|
protected |
The constructor
Definition at line 353 of file hosted/PhysicalMemoryManager.cc.
References m_BackingFile.
Referenced by instance().
|
protectedvirtual |
The destructor
Definition at line 363 of file hosted/PhysicalMemoryManager.cc.
References Vector< T >::clear(), m_BackingFile, PhysicalMemoryManager::m_MemoryRegions, and m_PageMetadata.
Referenced by instance().
|
private |
The copy-constructor
|
virtual |
Allocate a memory-region with specific constraints the pages need to fullfill.
[in] | Region | reference to the MemoryRegion object |
[in] | cPages | the number of pages to allocate for the MemoryRegion object |
[in] | pageConstraints | the constraints the pages have to fullfill |
[in] | Flags | flags from the VirtualAddressSpace class namespace |
[in] | start | the physical address of the beginning of the region (optional) |
Implements PhysicalMemoryManager.
Definition at line 198 of file hosted/PhysicalMemoryManager.cc.
References PhysicalMemoryManager::getPageSize(), Processor::information(), PhysicalMemoryManager::m_MemoryRegions, MemoryRegion::m_PhysicalAddress, MemoryRegion::m_Size, MemoryRegion::m_VirtualAddress, VirtualAddressSpace::map(), panic(), Vector< T >::pushBack(), and WARNING.
Referenced by instance().
|
virtual |
Free a page allocated with the allocatePage() function
[in] | page | physical address of the page |
Implements PhysicalMemoryManager.
Definition at line 132 of file hosted/PhysicalMemoryManager.cc.
Referenced by instance().
|
privatevirtual |
Same as freePage, but without the lock. Will panic if the lock is unlocked.
Implements PhysicalMemoryManager.
Definition at line 138 of file hosted/PhysicalMemoryManager.cc.
References FATAL.
Referenced by instance().
void HostedPhysicalMemoryManager::initialisationDone | ( | ) |
Unmap & free the .init section
Definition at line 348 of file hosted/PhysicalMemoryManager.cc.
References NOTICE.
Referenced by Processor::initialisationDone(), and instance().
void HostedPhysicalMemoryManager::initialise | ( | const BootstrapStruct_t & | Info | ) |
Initialise the page stack
[in] | Info | reference to the multiboot information structure |
Definition at line 314 of file hosted/PhysicalMemoryManager.cc.
Referenced by Processor::initialisationDone(), and instance().
|
inlinestatic |
Get the HostedPhysicalMemoryManager instance
Definition at line 47 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
References allocateRegion(), freePage(), freePageUnlocked(), HostedPhysicalMemoryManager(), INITIALISATION_ONLY, initialisationDone(), initialise(), m_BackingFile, m_Instance, operator=(), pin(), unmapRegion(), and ~HostedPhysicalMemoryManager().
Referenced by Processor::initialisationDone(), HostedVirtualAddressSpace::map(), and HostedVirtualAddressSpace::switchAddressSpace().
|
private |
The copy-constructor
Referenced by instance().
|
virtual |
"Pin" a page, increasing its refcount.
Every time a pinned page is passed to freePage, its refcount is decreased, and the page is only freed once the refcount hits zero.
Note that an unpin function is not provided, as freePage offers the right semantics.
Implements PhysicalMemoryManager.
Definition at line 176 of file hosted/PhysicalMemoryManager.cc.
Referenced by instance().
|
privatevirtual |
Unmaps a memory region - called ONLY from MemoryRegion's destructor.
Implements PhysicalMemoryManager.
Definition at line 373 of file hosted/PhysicalMemoryManager.cc.
References Vector< T >::end(), Vector< T >::erase(), FATAL, RangeList< T, Reversed >::free(), HostedPhysicalMemoryManager::PageStack::free(), VirtualAddressSpace::getKernelAddressSpace(), VirtualAddressSpace::getMapping(), PhysicalMemoryManager::getPageSize(), VirtualAddressSpace::isMapped(), PhysicalMemoryManager::m_MemoryRegions, m_MemoryRegions, m_PageStack, m_PhysicalRanges, MemoryRegion::physicalAddress(), MemoryRegion::size(), VirtualAddressSpace::unmap(), and MemoryRegion::virtualAddress().
Referenced by instance().
|
friend |
For getBackingFile()
Definition at line 42 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
|
private |
Hosted: backing file for physical memory.
Definition at line 209 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
Referenced by HostedPhysicalMemoryManager(), instance(), and ~HostedPhysicalMemoryManager().
|
staticprivate |
Static instance.
Definition at line 212 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
Referenced by instance().
|
private |
To guard against multiprocessor reentrancy.
Definition at line 162 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
|
private |
Virtual-memory available for MemoryRegions
Definition at line 159 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
Referenced by unmapRegion().
|
private |
Page metadata table
Definition at line 206 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
Referenced by ~HostedPhysicalMemoryManager().
|
private |
The page stack
Definition at line 151 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
Referenced by unmapRegion().
|
private |
RangeList of free physical memory
Definition at line 154 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
Referenced by unmapRegion().