The Pedigree Project
0.1
|
#include <PhysicalMemoryManager.h>
Classes | |
struct | MemoryRegionInfo |
Public Member Functions | |
virtual physical_uintptr_t | allocatePage (size_t pageConstraints=0)=0 |
virtual void | freePage (physical_uintptr_t page)=0 |
virtual void | pin (physical_uintptr_t page)=0 |
virtual bool | allocateRegion (MemoryRegion &Region, size_t cPages, size_t pageConstraints, size_t Flags, physical_uintptr_t start=-1)=0 |
void | allocateMemoryRegionList (Vector< MemoryRegionInfo * > &MemoryRegions) |
void | freeMemoryRegionList (Vector< MemoryRegionInfo * > &MemoryRegions) |
virtual size_t | freePageCount () const |
Static Public Member Functions | |
static PhysicalMemoryManager & | instance () |
static size_t | getPageSize () PURE |
Static Public Attributes | |
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 Member Functions | |
PhysicalMemoryManager () | |
virtual | ~PhysicalMemoryManager () |
Protected Attributes | |
Vector< MemoryRegion * > | m_MemoryRegions |
Private Member Functions | |
PhysicalMemoryManager (const PhysicalMemoryManager &) | |
PhysicalMemoryManager & | operator= (const PhysicalMemoryManager &) |
virtual void | freePageUnlocked (physical_uintptr_t page)=0 |
virtual void | unmapRegion (MemoryRegion *pRegion)=0 |
Friends | |
class | CacheManager |
class | Cache |
class | MemoryRegion |
The PhysicalMemoryManager manages the physical address space. That means it provides functions to allocate and free pages.
Definition at line 34 of file include/pedigree/kernel/processor/PhysicalMemoryManager.h.
|
protected |
The constructor
Definition at line 24 of file PhysicalMemoryManager.cc.
|
protectedvirtual |
The destructor
Definition at line 28 of file PhysicalMemoryManager.cc.
|
private |
The copy-constructor
void PhysicalMemoryManager::allocateMemoryRegionList | ( | Vector< MemoryRegionInfo * > & | MemoryRegions | ) |
Copy the memory region list
[in,out] | MemoryRegions | container for the copy of the memory regions |
Definition at line 38 of file PhysicalMemoryManager.cc.
References Vector< T >::count(), m_MemoryRegions, physicalAddress(), and Vector< T >::pushBack().
Referenced by IoCommand::execute().
|
pure virtual |
Allocate a single page with optional constraints.
Implemented in X86CommonPhysicalMemoryManager.
Referenced by Elf::allocate(), ArmV7VirtualAddressSpace::allocateStack(), PerProcessorScheduler::checkEventState(), PPC32VirtualAddressSpace::clone(), X64VirtualAddressSpace::conditionalTableEntryAllocation(), HostedVirtualAddressSpace::doAllocateStack(), X64VirtualAddressSpace::doAllocateStack(), ArmV7VirtualAddressSpace::doMap(), VirtualAddressSpace::expandHeap(), MIPS32VirtualAddressSpace::generateNullChunk(), Thread::getTlsBase(), DynamicLinker::initPlt(), Elf::loadModule(), Cache::map(), X86VirtualAddressSpace::mapCrossSpace(), DynamicLinker::trap(), AnonymousMemoryMap::trap(), MemoryMappedFile::trap(), X64VirtualAddressSpace::X64VirtualAddressSpace(), and X86VirtualAddressSpace::X86VirtualAddressSpace().
|
pure 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) |
Implemented in X86CommonPhysicalMemoryManager, HostedPhysicalMemoryManager, PpcCommonPhysicalMemoryManager, ArmV7PhysicalMemoryManager, and MipsCommonPhysicalMemoryManager.
Referenced by PPCVga::initialise(), MemoryPool::initialise(), BusMasterIde::initialise(), KernelElf::initialise(), Device::Address::map(), X86Vga::moveCursor(), and Framebuffer::swCreateBuffer().
void PhysicalMemoryManager::freeMemoryRegionList | ( | Vector< MemoryRegionInfo * > & | MemoryRegions | ) |
Free the memory region list created with allocateMemoryRegionList.
[in,out] | MemoryRegions | container of the copy of the memory regions |
Definition at line 50 of file PhysicalMemoryManager.cc.
References Vector< T >::count(), and Vector< T >::popBack().
|
pure virtual |
Free a page allocated with the allocatePage() function
[in] | page | physical address of the page |
Implemented in X86CommonPhysicalMemoryManager, HostedPhysicalMemoryManager, PpcCommonPhysicalMemoryManager, MipsCommonPhysicalMemoryManager, and ArmV7PhysicalMemoryManager.
Referenced by MemoryMappedFile::compact(), Cache::evict(), VirtualAddressSpace::expandHeap(), HostedVirtualAddressSpace::freeStack(), X64VirtualAddressSpace::freeStack(), MemoryMappedFile::invalidate(), X64VirtualAddressSpace::maybeFreeTables(), AnonymousMemoryMap::remove(), MemoryMappedFile::remove(), X86VirtualAddressSpace::revertToKernelAddressSpace(), HostedVirtualAddressSpace::revertToKernelAddressSpace(), X64VirtualAddressSpace::revertToKernelAddressSpace(), VirtualAddressSpace::rollbackHeapExpansion(), AnonymousMemoryMap::trap(), KernelElf::unloadModule(), MIPS32VirtualAddressSpace::~MIPS32VirtualAddressSpace(), Thread::~Thread(), X64VirtualAddressSpace::~X64VirtualAddressSpace(), and X86VirtualAddressSpace::~X86VirtualAddressSpace().
|
virtual |
Specifies the number of pages that remain free on the system.
Reimplemented in X86CommonPhysicalMemoryManager.
Definition at line 32 of file PhysicalMemoryManager.cc.
Referenced by CacheManager::executeRequest().
|
privatepure virtual |
Same as freePage, but without the lock. Will panic if the lock is unlocked.
Implemented in X86CommonPhysicalMemoryManager, HostedPhysicalMemoryManager, and ArmV7PhysicalMemoryManager.
Referenced by X86CommonPhysicalMemoryManager::freePage().
|
inlinestatic |
Get the size of one page
Definition at line 78 of file include/pedigree/kernel/processor/PhysicalMemoryManager.h.
References PAGE_SIZE.
Referenced by Device::Address::Address(), X86CommonPhysicalMemoryManager::PageStack::allocate(), Elf::allocate(), ArmV7PhysicalMemoryManager::allocateRegion(), HostedPhysicalMemoryManager::allocateRegion(), PpcCommonPhysicalMemoryManager::allocateRegion(), X86CommonPhysicalMemoryManager::allocateRegion(), ArmV7VirtualAddressSpace::allocateStack(), Archive::Archive(), PosixSubsystem::checkAddress(), PerProcessorScheduler::checkEventState(), MemoryMappedFile::compact(), X64VirtualAddressSpace::conditionalTableEntryAllocation(), X64VirtualAddressSpace::conditionalTableEntryMapping(), MemoryMapManager::contains(), HostedVirtualAddressSpace::doAllocateStack(), X64VirtualAddressSpace::doAllocateStack(), MappingCommand::execute(), VirtualAddressSpace::expandHeap(), Elf::finaliseModule(), ArmV7PhysicalMemoryManager::PageStack::free(), HostedPhysicalMemoryManager::PageStack::free(), X86CommonPhysicalMemoryManager::PageStack::free(), X86CommonPhysicalMemoryManager::freePageUnlocked(), HostedVirtualAddressSpace::freeStack(), X64VirtualAddressSpace::freeStack(), File::getBlockSize(), HostedVirtualAddressSpace::getMapping(), File::getPhysicalPage(), VbeFramebuffer::hwRedraw(), X86CommonPhysicalMemoryManager::initialisationDone(), X86CommonPhysicalMemoryManager::initialise(), MemoryPool::initialise(), KernelElf::initialise(), X86CommonPhysicalMemoryManager::initialise64(), PosixSubsystem::invoke(), CdiIrqHandler::irq(), HostedVirtualAddressSpace::isMapped(), PosixSubsystem::loadElf(), Elf::loadModule(), Device::Address::map(), HostedVirtualAddressSpace::map(), MemoryMapManager::mapAnon(), X86VirtualAddressSpace::mapCrossSpace(), MemoryMapManager::mapFile(), X64VirtualAddressSpace::mapHuge(), VirtualAddressSpace::mapHuge(), X86VirtualAddressSpace::mapPageStructures(), X86CommonPhysicalMemoryManager::PageStack::maybeMap(), VbeDisplay::newBuffer(), page_align(), File::read(), File::readIntoCache(), AnonymousMemoryMap::remove(), MemoryMappedFile::remove(), MemoryMapManager::remove(), File::returnPhysicalPage(), HostedVirtualAddressSpace::revertToKernelAddressSpace(), VirtualAddressSpace::rollbackHeapExpansion(), MemoryMapManager::sanitiseAddress(), HostedVirtualAddressSpace::setFlags(), MemoryMappedFile::setPermissions(), MemoryMapManager::setPermissions(), MemoryMappedFile::split(), HostedVirtualAddressSpace::switchAddressSpace(), DynamicLinker::trap(), AnonymousMemoryMap::trap(), MemoryMappedFile::trap(), MemoryMapManager::trap(), MemoryPool::trim(), KernelElf::unloadModule(), HostedVirtualAddressSpace::unmap(), PpcCommonPhysicalMemoryManager::unmapRegion(), HostedPhysicalMemoryManager::unmapRegion(), X86CommonPhysicalMemoryManager::unmapRegion(), File::useFillCache(), File::writeCallback(), X86VirtualAddressSpace::X86VirtualAddressSpace(), and PpcCommonPhysicalMemoryManager::~PpcCommonPhysicalMemoryManager().
|
static |
Get the PhysicalMemoryManager instance
Definition at line 29 of file armv7/PhysicalMemoryManager.cc.
References ArmV7PhysicalMemoryManager::instance().
Referenced by Elf::allocate(), ArmV7VirtualAddressSpace::allocateStack(), Archive::Archive(), PerProcessorScheduler::checkEventState(), PPC32VirtualAddressSpace::clone(), HostedVirtualAddressSpace::clone(), X64VirtualAddressSpace::clone(), MemoryMappedFile::compact(), X64VirtualAddressSpace::conditionalTableEntryAllocation(), HostedVirtualAddressSpace::doAllocateStack(), X64VirtualAddressSpace::doAllocateStack(), ArmV7VirtualAddressSpace::doMap(), Cache::evict(), IoCommand::execute(), CacheManager::executeRequest(), VirtualAddressSpace::expandHeap(), HostedVirtualAddressSpace::freeStack(), X64VirtualAddressSpace::freeStack(), X86VirtualAddressSpace::fromFlags(), MIPS32VirtualAddressSpace::generateNullChunk(), Thread::getTlsBase(), VbeFramebuffer::hwRedraw(), UsbUlpi::initialise(), PPCVga::initialise(), MemoryPool::initialise(), GPTimer::initialise(), Prcm::initialise(), BusMasterIde::initialise(), KernelElf::initialise(), Ehci::initialiseController(), ARMV7InterruptManager::initialiseProcessor(), DynamicLinker::initPlt(), MemoryMappedFile::invalidate(), Ipc::IpcMessage::IpcMessage(), CdiIrqHandler::irq(), Elf::loadModule(), Cache::lruEvict(), Device::Address::map(), Cache::map(), X86VirtualAddressSpace::mapCrossSpace(), X64VirtualAddressSpace::maybeFreeTables(), X86Vga::moveCursor(), VbeDisplay::newBuffer(), Nic3C90x::Nic3C90x(), AnonymousMemoryMap::remove(), MemoryMappedFile::remove(), X86VirtualAddressSpace::revertToKernelAddressSpace(), HostedVirtualAddressSpace::revertToKernelAddressSpace(), X64VirtualAddressSpace::revertToKernelAddressSpace(), VirtualAddressSpace::rollbackHeapExpansion(), ArmBeagleSerial::setBase(), Framebuffer::swCreateBuffer(), DynamicLinker::trap(), AnonymousMemoryMap::trap(), MemoryMappedFile::trap(), KernelElf::unloadModule(), X64VirtualAddressSpace::X64VirtualAddressSpace(), X86VirtualAddressSpace::X86VirtualAddressSpace(), MemoryRegion::~MemoryRegion(), MIPS32VirtualAddressSpace::~MIPS32VirtualAddressSpace(), Thread::~Thread(), X64VirtualAddressSpace::~X64VirtualAddressSpace(), and X86VirtualAddressSpace::~X86VirtualAddressSpace().
|
private |
The copy-constructor
|
pure 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.
Implemented in X86CommonPhysicalMemoryManager, HostedPhysicalMemoryManager, and ArmV7PhysicalMemoryManager.
Referenced by HostedVirtualAddressSpace::clone(), X64VirtualAddressSpace::clone(), HostedVirtualAddressSpace::doAllocateStack(), X64VirtualAddressSpace::doAllocateStack(), VirtualAddressSpace::expandHeap(), X86VirtualAddressSpace::fromFlags(), and AnonymousMemoryMap::trap().
|
privatepure virtual |
Unmaps a memory region - called ONLY from MemoryRegion's destructor.
Implemented in X86CommonPhysicalMemoryManager, HostedPhysicalMemoryManager, ArmV7PhysicalMemoryManager, and PpcCommonPhysicalMemoryManager.
Referenced by MemoryRegion::~MemoryRegion().
|
friend |
MemoryRegion can access our unmapRegion function.
Definition at line 41 of file include/pedigree/kernel/processor/PhysicalMemoryManager.h.
|
static |
All address size constraints
Definition at line 66 of file include/pedigree/kernel/processor/PhysicalMemoryManager.h.
Referenced by X86CommonPhysicalMemoryManager::allocateRegion().
|
static |
Don't track the memory region.
Definition at line 70 of file include/pedigree/kernel/processor/PhysicalMemoryManager.h.
Referenced by X86CommonPhysicalMemoryManager::allocateRegion().
|
static |
The allocated pages should be below the 16MB mark
Definition at line 59 of file include/pedigree/kernel/processor/PhysicalMemoryManager.h.
Referenced by X86CommonPhysicalMemoryManager::allocateRegion().
|
static |
The allocated pages should be below the 1MB mark
Definition at line 57 of file include/pedigree/kernel/processor/PhysicalMemoryManager.h.
Referenced by X86CommonPhysicalMemoryManager::allocateRegion().
|
static |
The allocated pages should be below the 4GB mark
Definition at line 61 of file include/pedigree/kernel/processor/PhysicalMemoryManager.h.
Referenced by X86CommonPhysicalMemoryManager::PageStack::allocate().
|
static |
The allocated pages should be below the 64GB mark
Definition at line 63 of file include/pedigree/kernel/processor/PhysicalMemoryManager.h.
Referenced by X86CommonPhysicalMemoryManager::PageStack::allocate().
|
static |
If this flag is set the pages are physically continuous
Definition at line 44 of file include/pedigree/kernel/processor/PhysicalMemoryManager.h.
Referenced by ArmV7PhysicalMemoryManager::allocateRegion(), PpcCommonPhysicalMemoryManager::allocateRegion(), X86CommonPhysicalMemoryManager::allocateRegion(), Archive::Archive(), VbeFramebuffer::hwRedraw(), UsbUlpi::initialise(), PPCVga::initialise(), GPTimer::initialise(), Prcm::initialise(), BusMasterIde::initialise(), KernelElf::initialise(), Ehci::initialiseController(), ARMV7InterruptManager::initialiseProcessor(), Ipc::IpcMessage::IpcMessage(), CdiIrqHandler::irq(), Device::Address::map(), X86Vga::moveCursor(), Nic3C90x::Nic3C90x(), and ArmBeagleSerial::setBase().
|
static |
If this flag is set we try to remove the range from the PhysicalMemoryManager, but if that fails, we still map the physical memory region
Definition at line 50 of file include/pedigree/kernel/processor/PhysicalMemoryManager.h.
Referenced by ArmV7PhysicalMemoryManager::allocateRegion(), PpcCommonPhysicalMemoryManager::allocateRegion(), X86CommonPhysicalMemoryManager::allocateRegion(), UsbUlpi::initialise(), PPCVga::initialise(), and Device::Address::map().
|
protected |
List of memory-regions
Definition at line 158 of file include/pedigree/kernel/processor/PhysicalMemoryManager.h.
Referenced by allocateMemoryRegionList(), ArmV7PhysicalMemoryManager::allocateRegion(), HostedPhysicalMemoryManager::allocateRegion(), PpcCommonPhysicalMemoryManager::allocateRegion(), X86CommonPhysicalMemoryManager::allocateRegion(), X86CommonPhysicalMemoryManager::initialise(), X86CommonPhysicalMemoryManager::shutdown(), PpcCommonPhysicalMemoryManager::unmapRegion(), HostedPhysicalMemoryManager::unmapRegion(), X86CommonPhysicalMemoryManager::unmapRegion(), and HostedPhysicalMemoryManager::~HostedPhysicalMemoryManager().
|
static |
If this flag is set we allocate pages that are not in RAM
Definition at line 46 of file include/pedigree/kernel/processor/PhysicalMemoryManager.h.
Referenced by PpcCommonPhysicalMemoryManager::allocateRegion(), X86CommonPhysicalMemoryManager::allocateRegion(), PPCVga::initialise(), Device::Address::map(), and X86Vga::moveCursor().
|
static |
Only allocate virtual address space for the region.
Definition at line 52 of file include/pedigree/kernel/processor/PhysicalMemoryManager.h.
Referenced by X86CommonPhysicalMemoryManager::allocateRegion(), and MemoryPool::initialise().