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

The Stack of pages (below4GB, below64GB, no constraint). More...

+ Collaboration diagram for X86CommonPhysicalMemoryManager::PageStack:

Public Member Functions

 PageStack () INITIALISATION_ONLY
 
physical_uintptr_t allocate (size_t constraints)
 
void free (uint64_t physicalAddress, size_t length)
 
 ~PageStack ()
 
size_t freePages () const
 
void setCapacity (size_t newCapacity)
 
void increaseCapacity (size_t by)
 

Protected Member Functions

void markAbove4GReady ()
 
void markBelow4GReady ()
 

Private Member Functions

 PageStack (const PageStack &)
 
PageStackoperator= (const PageStack &)
 
bool maybeMap (size_t index, uint64_t physicalAddress)
 

Private Attributes

void * m_Stack [StackCount]
 
size_t m_StackMax [StackCount]
 
size_t m_StackSize [StackCount]
 
size_t m_FreePages
 
size_t m_Capacity
 
size_t m_DesiredCapacity
 
Atomic< bool > m_StackReady [StackCount]
 

Static Private Attributes

static const size_t StackCount = 3
 

Friends

class X86CommonPhysicalMemoryManager
 

Detailed Description

The Stack of pages (below4GB, below64GB, no constraint).

The actual page stack contains is a Stack of the pages with the constraints below4GB and below64GB and those pages without address size constraints.

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

Constructor & Destructor Documentation

X86CommonPhysicalMemoryManager::PageStack::PageStack ( )

Default constructor does nothing

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

Referenced by ~PageStack().

+ Here is the caller graph for this function:

X86CommonPhysicalMemoryManager::PageStack::~PageStack ( )
inline
X86CommonPhysicalMemoryManager::PageStack::PageStack ( const PageStack )
private

The copy-constructor

Note
Not implemented

Member Function Documentation

physical_uintptr_t X86CommonPhysicalMemoryManager::PageStack::allocate ( size_t  constraints)

Allocate a page with certain constraints

Parameters
[in]constraintseither below4GB or below64GB or 0
Returns
The physical address of the allocated page or 0
Note
Testing.

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

References PhysicalMemoryManager::below4GB, PhysicalMemoryManager::below64GB, g_FreePages, PhysicalMemoryManager::getPageSize(), Processor::pause(), and physicalAddress().

void X86CommonPhysicalMemoryManager::PageStack::free ( uint64_t  physicalAddress,
size_t  length 
)

Free a physical page

Parameters
[in]physicalAddressphysical address of the page
Todo:
make sure callers split any regions that cross over before calling
Note
Testing.

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

References g_FreePages, PhysicalMemoryManager::getPageSize(), physicalAddress(), and UNLIKELY.

Referenced by X86CommonPhysicalMemoryManager::unmapRegion().

+ Here is the caller graph for this function:

void X86CommonPhysicalMemoryManager::PageStack::markAbove4GReady ( )
protected

Mark all stacks tracking pages above 4GB mark ready.

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

Referenced by ~PageStack().

+ Here is the caller graph for this function:

void X86CommonPhysicalMemoryManager::PageStack::markBelow4GReady ( )
protected

Mark stacks tracking pages below 4GB mark ready.

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

Referenced by ~PageStack().

+ Here is the caller graph for this function:

bool X86CommonPhysicalMemoryManager::PageStack::maybeMap ( size_t  index,
uint64_t  physicalAddress 
)
private

Potentially use the given page to map paging structures for future stack frees.

Returns
true if the page was consumed, false otherwise.

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

References FATAL, VirtualAddressSpace::getKernelAddressSpace(), PhysicalMemoryManager::getPageSize(), X64VirtualAddressSpace::isMapped(), VirtualAddressSpace::KernelMode, X64VirtualAddressSpace::mapPageStructures(), and VirtualAddressSpace::Write.

Referenced by ~PageStack().

+ Here is the caller graph for this function:

PageStack& X86CommonPhysicalMemoryManager::PageStack::operator= ( const PageStack )
private

The copy-constructor

Note
Not implemented

Referenced by ~PageStack().

+ Here is the caller graph for this function:

Member Data Documentation

size_t X86CommonPhysicalMemoryManager::PageStack::m_Capacity
private

Current capacity (i.e. mapped pages).

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

size_t X86CommonPhysicalMemoryManager::PageStack::m_DesiredCapacity
private

Desired capacity. New pages will be mapped until demand is met.

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

Referenced by ~PageStack().

size_t X86CommonPhysicalMemoryManager::PageStack::m_FreePages
private

Current pages available.

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

Referenced by ~PageStack().

void* X86CommonPhysicalMemoryManager::PageStack::m_Stack[StackCount]
private

Pointer to the base address of the stack. The stack grows upwards.

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

size_t X86CommonPhysicalMemoryManager::PageStack::m_StackMax[StackCount]
private

Size of the currently mapped stack

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

Atomic<bool> X86CommonPhysicalMemoryManager::PageStack::m_StackReady[StackCount]
private

Whether or not a particular stack is ready for use.

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

size_t X86CommonPhysicalMemoryManager::PageStack::m_StackSize[StackCount]
private

Currently used size of the stack

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

const size_t X86CommonPhysicalMemoryManager::PageStack::StackCount = 3
staticprivate

The number of Stacks

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

Referenced by ~PageStack().


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