The Pedigree Project  0.1
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
PhysicalMemoryManager Class Referenceabstract

#include <PhysicalMemoryManager.h>

+ Inheritance diagram for PhysicalMemoryManager:
+ Collaboration diagram for PhysicalMemoryManager:

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 PhysicalMemoryManagerinstance ()
 
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 &)
 
PhysicalMemoryManageroperator= (const PhysicalMemoryManager &)
 
virtual void freePageUnlocked (physical_uintptr_t page)=0
 
virtual void unmapRegion (MemoryRegion *pRegion)=0
 

Friends

class CacheManager
 
class Cache
 
class MemoryRegion
 

Detailed Description

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.

Constructor & Destructor Documentation

PhysicalMemoryManager::PhysicalMemoryManager ( )
protected

The constructor

Definition at line 24 of file PhysicalMemoryManager.cc.

PhysicalMemoryManager::~PhysicalMemoryManager ( )
protectedvirtual

The destructor

Definition at line 28 of file PhysicalMemoryManager.cc.

PhysicalMemoryManager::PhysicalMemoryManager ( const PhysicalMemoryManager )
private

The copy-constructor

Note
Not implemented (singleton)

Member Function Documentation

void PhysicalMemoryManager::allocateMemoryRegionList ( Vector< MemoryRegionInfo * > &  MemoryRegions)

Copy the memory region list

Parameters
[in,out]MemoryRegionscontainer 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().

+ Here is the caller graph for this function:

virtual physical_uintptr_t PhysicalMemoryManager::allocatePage ( size_t  pageConstraints = 0)
pure virtual
virtual bool PhysicalMemoryManager::allocateRegion ( MemoryRegion Region,
size_t  cPages,
size_t  pageConstraints,
size_t  Flags,
physical_uintptr_t  start = -1 
)
pure virtual

Allocate a memory-region with specific constraints the pages need to fullfill.

Parameters
[in]Regionreference to the MemoryRegion object
[in]cPagesthe number of pages to allocate for the MemoryRegion object
[in]pageConstraintsthe constraints the pages have to fullfill
[in]Flagsflags from the VirtualAddressSpace class namespace
[in]startthe physical address of the beginning of the region (optional)
Returns
true, if a valid MemoryRegion object is created, false otherwise

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().

+ Here is the caller graph for this function:

void PhysicalMemoryManager::freeMemoryRegionList ( Vector< MemoryRegionInfo * > &  MemoryRegions)

Free the memory region list created with allocateMemoryRegionList.

Parameters
[in,out]MemoryRegionscontainer of the copy of the memory regions

Definition at line 50 of file PhysicalMemoryManager.cc.

References Vector< T >::count(), and Vector< T >::popBack().

virtual void PhysicalMemoryManager::freePage ( physical_uintptr_t  page)
pure virtual
size_t PhysicalMemoryManager::freePageCount ( ) const
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().

+ Here is the caller graph for this function:

virtual void PhysicalMemoryManager::freePageUnlocked ( physical_uintptr_t  page)
privatepure virtual

Same as freePage, but without the lock. Will panic if the lock is unlocked.

Note
Use in the wrong place and you die.

Implemented in X86CommonPhysicalMemoryManager, HostedPhysicalMemoryManager, and ArmV7PhysicalMemoryManager.

Referenced by X86CommonPhysicalMemoryManager::freePage().

+ Here is the caller graph for this function:

static size_t PhysicalMemoryManager::getPageSize ( )
inlinestatic

Get the size of one page

Returns
size of one page in bytes

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().

PhysicalMemoryManager & PhysicalMemoryManager::instance ( )
static

Get the PhysicalMemoryManager instance

Returns
instance of the PhysicalMemoryManager

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().

PhysicalMemoryManager& PhysicalMemoryManager::operator= ( const PhysicalMemoryManager )
private

The copy-constructor

Note
Not implemented (singleton)
virtual void PhysicalMemoryManager::pin ( physical_uintptr_t  page)
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().

+ Here is the caller graph for this function:

virtual void PhysicalMemoryManager::unmapRegion ( MemoryRegion pRegion)
privatepure virtual

Unmaps a memory region - called ONLY from MemoryRegion's destructor.

Implemented in X86CommonPhysicalMemoryManager, HostedPhysicalMemoryManager, ArmV7PhysicalMemoryManager, and PpcCommonPhysicalMemoryManager.

Referenced by MemoryRegion::~MemoryRegion().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend class MemoryRegion
friend

MemoryRegion can access our unmapRegion function.

Definition at line 41 of file include/pedigree/kernel/processor/PhysicalMemoryManager.h.

Member Data Documentation

const size_t PhysicalMemoryManager::addressConstraints
static
Initial value:

All address size constraints

Definition at line 66 of file include/pedigree/kernel/processor/PhysicalMemoryManager.h.

Referenced by X86CommonPhysicalMemoryManager::allocateRegion().

const size_t PhysicalMemoryManager::anonymous = 1 << 8
static

Don't track the memory region.

Definition at line 70 of file include/pedigree/kernel/processor/PhysicalMemoryManager.h.

Referenced by X86CommonPhysicalMemoryManager::allocateRegion().

const size_t PhysicalMemoryManager::below16MB = 1 << 5
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().

const size_t PhysicalMemoryManager::below1MB = 1 << 4
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().

const size_t PhysicalMemoryManager::below4GB = 1 << 6
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().

const size_t PhysicalMemoryManager::below64GB = 1 << 7
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().

const size_t PhysicalMemoryManager::continuous = 1 << 0
static
const size_t PhysicalMemoryManager::force = 1 << 2
static
Vector<MemoryRegion *> PhysicalMemoryManager::m_MemoryRegions
protected
const size_t PhysicalMemoryManager::nonRamMemory = 1 << 1
static
const size_t PhysicalMemoryManager::virtualOnly = 1 << 3
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().


The documentation for this class was generated from the following files: