The Pedigree Project  0.1
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
X86CommonPhysicalMemoryManager Class Reference

Implementation of the PhysicalMemoryManager for common x86. More...

#include <PhysicalMemoryManager.h>

+ Inheritance diagram for X86CommonPhysicalMemoryManager:
+ Collaboration diagram for X86CommonPhysicalMemoryManager:

Classes

struct  page
 
class  PageHashable
 
class  PageStack
 The Stack of pages (below4GB, below64GB, no constraint). More...
 

Public Member Functions

virtual physical_uintptr_t allocatePage (size_t pageConstraints=0)
 
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 initialise64 (const BootstrapStruct_t &Info) INITIALISATION_ONLY
 
void initialisationDone ()
 
void shutdown ()
 
virtual size_t freePageCount () const
 
- Public Member Functions inherited from PhysicalMemoryManager
void allocateMemoryRegionList (Vector< MemoryRegionInfo * > &MemoryRegions)
 
void freeMemoryRegionList (Vector< MemoryRegionInfo * > &MemoryRegions)
 

Static Public Member Functions

static X86CommonPhysicalMemoryManagerinstance ()
 
- Static Public Member Functions inherited from PhysicalMemoryManager
static PhysicalMemoryManagerinstance ()
 
static size_t getPageSize () PURE
 

Protected Member Functions

 X86CommonPhysicalMemoryManager () INITIALISATION_ONLY
 
virtual ~X86CommonPhysicalMemoryManager ()
 
- Protected Member Functions inherited from PhysicalMemoryManager
 PhysicalMemoryManager ()
 
virtual ~PhysicalMemoryManager ()
 

Private Types

typedef HashTable< PageHashable, struct pageMetadataTable
 

Private Member Functions

 X86CommonPhysicalMemoryManager (const X86CommonPhysicalMemoryManager &)
 
X86CommonPhysicalMemoryManageroperator= (const X86CommonPhysicalMemoryManager &)
 
void unmapRegion (MemoryRegion *pRegion)
 
virtual void freePageUnlocked (physical_uintptr_t page)
 

Private Attributes

PageStack m_PageStack
 
RangeList< uint32_t > m_RangeBelow1MB
 
RangeList< uint32_t > m_RangeBelow16MB
 
RangeList< uint64_t > m_PhysicalRanges
 
RangeList< uintptr_t > m_MemoryRegions
 
Spinlock m_Lock
 
Spinlock m_RegionLock
 
HashTable< PageHashable, struct pagem_PageMetadata
 

Static Private Attributes

static X86CommonPhysicalMemoryManager m_Instance
 

Friends

class CacheManager
 
class Cache
 

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
 

Detailed Description

Implementation of the PhysicalMemoryManager for common x86.

The common x86 implementation of the PhysicalMemoryManager

Definition at line 43 of file kernel/core/processor/x86_common/PhysicalMemoryManager.h.

Constructor & Destructor Documentation

X86CommonPhysicalMemoryManager::X86CommonPhysicalMemoryManager ( )
protected

The constructor

Definition at line 817 of file x86_common/PhysicalMemoryManager.cc.

Referenced by instance().

+ Here is the caller graph for this function:

X86CommonPhysicalMemoryManager::~X86CommonPhysicalMemoryManager ( )
protectedvirtual

The destructor

Definition at line 826 of file x86_common/PhysicalMemoryManager.cc.

Referenced by instance().

+ Here is the caller graph for this function:

X86CommonPhysicalMemoryManager::X86CommonPhysicalMemoryManager ( const X86CommonPhysicalMemoryManager )
private

The copy-constructor

Note
Not implemented (singleton)

Member Function Documentation

physical_uintptr_t X86CommonPhysicalMemoryManager::allocatePage ( size_t  pageConstraints = 0)
virtual

Allocate a single page with optional constraints.

Returns
physical address of the page or 0 if no page available.

Implements PhysicalMemoryManager.

Definition at line 83 of file x86_common/PhysicalMemoryManager.cc.

References Processor::m_Initialised, and panic().

Referenced by instance().

+ Here is the caller graph for this function:

bool X86CommonPhysicalMemoryManager::allocateRegion ( MemoryRegion Region,
size_t  cPages,
size_t  pageConstraints,
size_t  Flags,
physical_uintptr_t  start = -1 
)
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

Implements PhysicalMemoryManager.

Definition at line 236 of file x86_common/PhysicalMemoryManager.cc.

References PhysicalMemoryManager::addressConstraints, PhysicalMemoryManager::anonymous, PhysicalMemoryManager::below16MB, PhysicalMemoryManager::below1MB, PhysicalMemoryManager::continuous, ERROR, PhysicalMemoryManager::force, PhysicalMemoryManager::getPageSize(), Hex, Processor::information(), PhysicalMemoryManager::m_MemoryRegions, MemoryRegion::m_PhysicalAddress, MemoryRegion::m_Size, MemoryRegion::m_VirtualAddress, VirtualAddressSpace::map(), PhysicalMemoryManager::nonRamMemory, panic(), Vector< T >::pushBack(), PhysicalMemoryManager::virtualOnly, and WARNING.

Referenced by instance().

+ Here is the caller graph for this function:

void X86CommonPhysicalMemoryManager::freePage ( physical_uintptr_t  page)
virtual

Free a page allocated with the allocatePage() function

Parameters
[in]pagephysical address of the page

Implements PhysicalMemoryManager.

Definition at line 158 of file x86_common/PhysicalMemoryManager.cc.

References PhysicalMemoryManager::freePageUnlocked().

Referenced by instance().

+ Here is the caller graph for this function:

size_t X86CommonPhysicalMemoryManager::freePageCount ( ) const
virtual

Specifies the number of pages that remain free on the system.

Reimplemented from PhysicalMemoryManager.

Definition at line 77 of file x86_common/PhysicalMemoryManager.cc.

Referenced by instance().

+ Here is the caller graph for this function:

void X86CommonPhysicalMemoryManager::freePageUnlocked ( physical_uintptr_t  page)
privatevirtual

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

Note
Use in the wrong place and you die.

Implements PhysicalMemoryManager.

Definition at line 164 of file x86_common/PhysicalMemoryManager.cc.

References FATAL, and PhysicalMemoryManager::getPageSize().

Referenced by instance().

+ Here is the caller graph for this function:

void X86CommonPhysicalMemoryManager::initialisationDone ( )

Unmap & free the .init section

Definition at line 778 of file x86_common/PhysicalMemoryManager.cc.

References Dec, VirtualAddressSpace::getKernelAddressSpace(), VirtualAddressSpace::getMapping(), PhysicalMemoryManager::getPageSize(), Hex, NOTICE, and VirtualAddressSpace::unmap().

Referenced by instance().

+ Here is the caller graph for this function:

void X86CommonPhysicalMemoryManager::initialise ( const BootstrapStruct_t Info)

Initialise the page stack

Parameters
[in]Inforeference to the multiboot information structure
Todo:
do this in initialise64 too, copying any existing entries.

Definition at line 462 of file x86_common/PhysicalMemoryManager.cc.

References PhysicalMemoryManager::getPageSize(), Hex, PhysicalMemoryManager::m_MemoryRegions, NOTICE, panic(), and WARNING.

Referenced by instance().

+ Here is the caller graph for this function:

void X86CommonPhysicalMemoryManager::initialise64 ( const BootstrapStruct_t Info)

Initialise the page stack, with ranges above 4 GB. Requires ranges below 4 GB to be available (call initialise first).

Parameters
[in]Inforeference to the multiboot information structure
Todo:
this will break if there's over 64 TiB of RAM on the machine.

Definition at line 652 of file x86_common/PhysicalMemoryManager.cc.

References FATAL, VirtualAddressSpace::getKernelAddressSpace(), PhysicalMemoryManager::getPageSize(), Hex, VirtualAddressSpace::KernelMode, VirtualAddressSpace::mapHuge(), NOTICE, panic(), WARNING, and VirtualAddressSpace::Write.

Referenced by instance().

+ Here is the caller graph for this function:

static X86CommonPhysicalMemoryManager& X86CommonPhysicalMemoryManager::instance ( )
inlinestatic
X86CommonPhysicalMemoryManager& X86CommonPhysicalMemoryManager::operator= ( const X86CommonPhysicalMemoryManager )
private

The copy-constructor

Note
Not implemented (singleton)

Referenced by instance().

+ Here is the caller graph for this function:

void X86CommonPhysicalMemoryManager::pin ( physical_uintptr_t  page)
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 215 of file x86_common/PhysicalMemoryManager.cc.

Referenced by instance().

+ Here is the caller graph for this function:

void X86CommonPhysicalMemoryManager::shutdown ( )

Clean up tracking structures.

Definition at line 455 of file x86_common/PhysicalMemoryManager.cc.

References Vector< T >::clear(), PhysicalMemoryManager::m_MemoryRegions, and NOTICE.

Referenced by instance().

+ Here is the caller graph for this function:

void X86CommonPhysicalMemoryManager::unmapRegion ( MemoryRegion pRegion)
privatevirtual

Member Data Documentation

X86CommonPhysicalMemoryManager X86CommonPhysicalMemoryManager::m_Instance
staticprivate

The X86CommonPhysicalMemoryManager class instance

Definition at line 222 of file kernel/core/processor/x86_common/PhysicalMemoryManager.h.

Referenced by instance().

Spinlock X86CommonPhysicalMemoryManager::m_Lock
private

To guard against multiprocessor reentrancy.

Definition at line 225 of file kernel/core/processor/x86_common/PhysicalMemoryManager.h.

RangeList<uintptr_t> X86CommonPhysicalMemoryManager::m_MemoryRegions
private

Virtual-memory available for MemoryRegions

Todo:
rename this member (conflicts with PhysicalMemoryManager::m_MemoryRegions)

Definition at line 219 of file kernel/core/processor/x86_common/PhysicalMemoryManager.h.

Referenced by unmapRegion().

HashTable<PageHashable, struct page> X86CommonPhysicalMemoryManager::m_PageMetadata
private

Page metadata table

Definition at line 271 of file kernel/core/processor/x86_common/PhysicalMemoryManager.h.

PageStack X86CommonPhysicalMemoryManager::m_PageStack
private

The page stack

Definition at line 201 of file kernel/core/processor/x86_common/PhysicalMemoryManager.h.

Referenced by unmapRegion().

RangeList<uint64_t> X86CommonPhysicalMemoryManager::m_PhysicalRanges
private

RangeList of free physical memory

Definition at line 209 of file kernel/core/processor/x86_common/PhysicalMemoryManager.h.

Referenced by unmapRegion().

RangeList<uint32_t> X86CommonPhysicalMemoryManager::m_RangeBelow16MB
private

RangeList for the usable memory below 16MB

Definition at line 206 of file kernel/core/processor/x86_common/PhysicalMemoryManager.h.

Referenced by unmapRegion().

RangeList<uint32_t> X86CommonPhysicalMemoryManager::m_RangeBelow1MB
private

RangeList for the usable memory below 1MB

Definition at line 204 of file kernel/core/processor/x86_common/PhysicalMemoryManager.h.

Referenced by unmapRegion().


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