|
The Pedigree Project 0.1
|
Implementation of the PhysicalMemoryManager for common x86. More...
#include <PhysicalMemoryManager.h>
Inheritance diagram for HostedPhysicalMemoryManager:
Collaboration diagram for HostedPhysicalMemoryManager:Classes | |
| struct | page |
| class | PageHashable |
Public Member Functions | |
| virtual physical_uintptr_t | allocatePage (size_t pageConstraints=0) override |
| physical_uintptr_t | tryAllocatePage () override |
| bool | copyPhysicalPageToBuffer (physical_uintptr_t page, void *buffer) override |
| bool | copyPhysicalPageFromBuffer (physical_uintptr_t page, const void *buffer) override |
| MemorySnapshot | memorySnapshot () const override |
| virtual void | freePage (physical_uintptr_t page) override |
| virtual bool | allocateRegion (MemoryRegion &Region, size_t cPages, size_t pageConstraints, size_t Flags, physical_uintptr_t start=-1) override |
| virtual void | pin (physical_uintptr_t page) override |
| void | initialise (const BootstrapStruct_t &Info) INITIALISATION_ONLY |
| void | initialisationDone () |
| const RangeList< uint64_t > & | getAcpiRanges () const |
Public Member Functions inherited from PhysicalMemoryManager | |
| 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 constexpr size_t | getPageSize () PURE |
Protected Member Functions | |
| HostedPhysicalMemoryManager () INITIALISATION_ONLY | |
| virtual | ~HostedPhysicalMemoryManager () override |
Protected Member Functions inherited from PhysicalMemoryManager | |
| PhysicalMemoryManager () | |
| virtual | ~PhysicalMemoryManager () |
Private Types | |
| using | PageStack = X86CommonPhysicalMemoryManager::PageStack |
| typedef HashTable< PageHashable, struct page > | MetadataTable |
Private Member Functions | |
| HostedPhysicalMemoryManager (const HostedPhysicalMemoryManager &) | |
| HostedPhysicalMemoryManager & | operator= (const HostedPhysicalMemoryManager &) |
| int | getBackingFile () const |
| void | unmapRegion (MemoryRegion *pRegion) override |
| virtual void | freePageUnlocked (physical_uintptr_t page) override |
Private Attributes | |
| PageStack | m_PageStack |
| RangeList< uint64_t > | m_PhysicalRanges |
| RangeList< uintptr_t > | m_MemoryRegions |
| RangeList< uint64_t > | m_AcpiRanges |
| Spinlock | m_Lock |
| Spinlock | m_RegionLock |
| HashTable< PageHashable, struct page > | m_PageMetadata |
| int | m_BackingFile |
Static Private Attributes | |
| static HostedPhysicalMemoryManager * | m_Instance = nullptr |
Friends | |
| class | CacheManager |
| class | Cache |
| class | PhysicalMemoryManager |
| 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 = below1MB | below16MB | below4GB | below64GB |
| 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 40 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
|
private |
Definition at line 156 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
Definition at line 105 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
|
protected |
The constructor
Definition at line 465 of file hosted/PhysicalMemoryManager.cc.
References m_BackingFile.
Referenced by instance().
Here is the caller graph for this function:
|
overrideprotectedvirtual |
The destructor
Definition at line 480 of file hosted/PhysicalMemoryManager.cc.
References Vector< T >::clear(), m_BackingFile, and PhysicalMemoryManager::m_MemoryRegions.
|
private |
The copy-constructor
|
overridevirtual |
Allocate a single page with optional constraints.
Implements PhysicalMemoryManager.
Definition at line 65 of file hosted/PhysicalMemoryManager.cc.
References Spinlock::acquire(), X86CommonPhysicalMemoryManager::PageStack::allocate(), MemoryPressureManager::compact(), MemoryPressureManager::compactingForCurrentExecution(), PhysicalMemoryManager::getPageSize(), ProcessorBase::m_Initialised, m_Lock, m_PageStack, panic(), and Spinlock::release().
Referenced by allocateRegion().
Here is the caller graph for this function:
|
overridevirtual |
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 286 of file hosted/PhysicalMemoryManager.cc.
References PhysicalMemoryManager::addressConstraints, RangeList< T, Reversed >::allocate(), allocatePage(), RangeList< T, Reversed >::allocateSpecific(), PhysicalMemoryManager::anonymous, PhysicalMemoryManager::continuous, PhysicalMemoryManager::force, RangeList< T, Reversed >::free(), freePage(), VirtualAddressSpace::getMapping(), PhysicalMemoryManager::getPageSize(), ProcessorBase::information(), PhysicalMemoryManager::m_MemoryRegions, m_MemoryRegions, MemoryRegion::m_PhysicalAddress, m_PhysicalRanges, MemoryRegion::m_Size, MemoryRegion::m_VirtualAddress, VirtualAddressSpace::map(), PhysicalMemoryManager::nonRamMemory, panic(), Vector< T >::pushBack(), VirtualAddressSpace::unmap(), and PhysicalMemoryManager::virtualOnly.
Referenced by initialisationDone().
Here is the caller graph for this function:
|
overridevirtual |
Reimplemented from PhysicalMemoryManager.
Definition at line 192 of file hosted/PhysicalMemoryManager.cc.
|
overridevirtual |
Reimplemented from PhysicalMemoryManager.
Definition at line 188 of file hosted/PhysicalMemoryManager.cc.
|
overridevirtual |
Free a page allocated with the allocatePage() function
| [in] | page | physical address of the page |
Implements PhysicalMemoryManager.
Definition at line 198 of file hosted/PhysicalMemoryManager.cc.
References freePageUnlocked(), and m_Lock.
Referenced by allocateRegion(), and unmapRegion().
Here is the caller graph for this function:
|
overrideprivatevirtual |
Same as freePage, but without the lock. Will panic if the lock is unlocked.
Implements PhysicalMemoryManager.
Definition at line 203 of file hosted/PhysicalMemoryManager.cc.
References X86CommonPhysicalMemoryManager::PageStack::free(), PhysicalMemoryManager::getPageSize(), ProcessorBase::m_Initialised, m_Lock, m_PageMetadata, m_PageStack, and Spinlock::release().
Referenced by freePage().
Here is the caller graph for this function:
|
inline |
Definition at line 73 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
|
inlineprivate |
Definition at line 91 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
| void HostedPhysicalMemoryManager::initialisationDone | ( | ) |
Unmap & free the .init section
Definition at line 426 of file hosted/PhysicalMemoryManager.cc.
References allocateRegion(), PhysicalMemoryManager::anonymous, Vector< T >::count(), VirtualAddressSpace::getKernelAddressSpace(), VirtualAddressSpace::isMapped(), VirtualAddressSpace::KernelMode, PhysicalMemoryManager::m_MemoryRegions, and MemoryRegion::virtualAddress().
| void HostedPhysicalMemoryManager::initialise | ( | const BootstrapStruct_t & | Info | ) |
Initialise the page stack
| [in] | Info | reference to the multiboot information structure |
Definition at line 392 of file hosted/PhysicalMemoryManager.cc.
References RangeList< T, Reversed >::Range::address, RangeList< T, Reversed >::allocateSpecific(), RangeList< T, Reversed >::free(), X86CommonPhysicalMemoryManager::PageStack::free(), PhysicalMemoryManager::getPageSize(), RangeList< T, Reversed >::getRange(), Hex, RangeList< T, Reversed >::Range::length, m_MemoryRegions, m_PageMetadata, m_PageStack, m_PhysicalRanges, X86CommonPhysicalMemoryManager::PageStack::markBelow4GReady(), and RangeList< T, Reversed >::size().
|
static |
Get the HostedPhysicalMemoryManager instance
Definition at line 58 of file hosted/PhysicalMemoryManager.cc.
References HostedPhysicalMemoryManager(), and m_Instance.
Referenced by HostedVirtualAddressSpace::handleCopyOnWriteFault(), HostedVirtualAddressSpace::map(), HostedVirtualAddressSpace::switchAddressSpace(), and HostedVirtualAddressSpace::tryWriteUser32().
Here is the caller graph for this function:
|
overridevirtual |
Reimplemented from PhysicalMemoryManager.
Definition at line 182 of file hosted/PhysicalMemoryManager.cc.
|
private |
|
overridevirtual |
"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 243 of file hosted/PhysicalMemoryManager.cc.
References m_Lock, and m_PageMetadata.
|
overridevirtual |
Reimplemented from PhysicalMemoryManager.
Definition at line 135 of file hosted/PhysicalMemoryManager.cc.
|
overrideprivatevirtual |
Unmaps a memory region - called ONLY from MemoryRegion's destructor.
Implements PhysicalMemoryManager.
Definition at line 489 of file hosted/PhysicalMemoryManager.cc.
References Vector< T >::end(), Vector< T >::erase(), RangeList< T, Reversed >::free(), freePage(), VirtualAddressSpace::getKernelAddressSpace(), VirtualAddressSpace::getMapping(), PhysicalMemoryManager::getPageSize(), VirtualAddressSpace::isMapped(), PhysicalMemoryManager::m_MemoryRegions, m_MemoryRegions, m_PhysicalRanges, MemoryRegion::physicalAddress(), MemoryRegion::size(), VirtualAddressSpace::unmap(), and MemoryRegion::virtualAddress().
|
friend |
Definition at line 42 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
|
friend |
Definition at line 41 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
|
friend |
For getBackingFile()
Definition at line 45 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
|
friend |
Definition at line 43 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
|
private |
Definition at line 118 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
|
private |
Hosted: backing file for physical memory.
Definition at line 162 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
Referenced by HostedPhysicalMemoryManager(), operator=(), and ~HostedPhysicalMemoryManager().
|
staticprivate |
Static instance.
Definition at line 165 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
Referenced by instance().
|
private |
To guard against multiprocessor reentrancy.
Definition at line 121 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
Referenced by allocatePage(), freePage(), freePageUnlocked(), and pin().
|
private |
Virtual-memory available for MemoryRegions
Definition at line 116 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
Referenced by allocateRegion(), initialise(), and unmapRegion().
|
private |
Page metadata table
Definition at line 159 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
Referenced by freePageUnlocked(), initialise(), and pin().
|
private |
The page stack
Definition at line 108 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
Referenced by allocatePage(), freePageUnlocked(), and initialise().
|
private |
RangeList of free physical memory
Definition at line 111 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.
Referenced by allocateRegion(), initialise(), and unmapRegion().
|
private |
Definition at line 121 of file kernel/core/processor/hosted/PhysicalMemoryManager.h.