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, bool waitForReady=true)
 
void free (uint64_t physicalAddress, size_t length, bool newMemory=false)
 
 ~PageStack ()
 
size_t freePages () const
 
size_t totalPages () const
 

Protected Member Functions

void markAbove4GReady ()
 
void markBelow4GReady ()
 

Private Member Functions

 PageStack (const PageStack &)
 
PageStack & operator= (const PageStack &)
 
void initialise ()
 
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_TotalPages
 
size_t m_DesiredCapacity [StackCount]
 
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

◆ PageStack() [1/2]

X86CommonPhysicalMemoryManager::PageStack::PageStack ( )

Default constructor does nothing

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

◆ ~PageStack()

X86CommonPhysicalMemoryManager::PageStack::~PageStack ( )
inline

The destructor does nothing

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

◆ PageStack() [2/2]

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

The copy-constructor

Note
Not implemented

Member Function Documentation

◆ allocate()

physical_uintptr_t X86CommonPhysicalMemoryManager::PageStack::allocate ( size_t  constraints,
bool  waitForReady = true 
)

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 876 of file x86_common/PhysicalMemoryManager.cc.

References PhysicalMemoryManager::below4GB, PhysicalMemoryManager::below64GB, g_FreePages, initialise(), m_FreePages, m_Stack, m_StackReady, m_StackSize, and ProcessorBase::pause().

Referenced by HostedPhysicalMemoryManager::allocatePage(), and X86CommonPhysicalMemoryManager::allocatePage().

+ Here is the caller graph for this function:

◆ free()

void X86CommonPhysicalMemoryManager::PageStack::free ( uint64_t  physicalAddress,
size_t  length,
bool  newMemory = false 
)

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 949 of file x86_common/PhysicalMemoryManager.cc.

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

Referenced by HostedPhysicalMemoryManager::freePageUnlocked(), X86CommonPhysicalMemoryManager::freePageUnlocked(), HostedPhysicalMemoryManager::initialise(), X86CommonPhysicalMemoryManager::initialise(), and X86CommonPhysicalMemoryManager::initialise64().

+ Here is the caller graph for this function:

◆ freePages()

size_t X86CommonPhysicalMemoryManager::PageStack::freePages ( ) const
inline

◆ initialise()

void X86CommonPhysicalMemoryManager::PageStack::initialise ( )
private

Initialize the stacks if needed. This is needed to avoid a dependency on the order of construction of VirtualAddressSpace objects for the kernel address space. Otherwise we can try to get page stack addresses from an unconstructed VirtualAddressSpace object.

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

References VirtualAddressSpace::getKernelAddressSpace(), VirtualAddressSpace::getKernelVirtualPagestack(), VirtualAddressSpace::getKernelVirtualPagestackAdd1(), VirtualAddressSpace::getKernelVirtualPagestackAdd2(), and LIKELY.

Referenced by allocate().

+ Here is the caller graph for this function:

◆ markAbove4GReady()

void X86CommonPhysicalMemoryManager::PageStack::markAbove4GReady ( )
protected

Mark all stacks tracking pages above 4GB mark ready.

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

Referenced by X86CommonPhysicalMemoryManager::initialise64().

+ Here is the caller graph for this function:

◆ markBelow4GReady()

void X86CommonPhysicalMemoryManager::PageStack::markBelow4GReady ( )
protected

Mark stacks tracking pages below 4GB mark ready.

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

Referenced by HostedPhysicalMemoryManager::initialise(), and X86CommonPhysicalMemoryManager::initialise().

+ Here is the caller graph for this function:

◆ maybeMap()

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

◆ operator=()

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

The copy-constructor

Note
Not implemented

◆ totalPages()

size_t X86CommonPhysicalMemoryManager::PageStack::totalPages ( ) const
inline

Friends And Related Symbol Documentation

◆ X86CommonPhysicalMemoryManager

friend class X86CommonPhysicalMemoryManager
friend

Member Data Documentation

◆ m_DesiredCapacity

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

Each physical-address class needs its own backing storage.

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

◆ m_FreePages

size_t X86CommonPhysicalMemoryManager::PageStack::m_FreePages
private

Current pages available.

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

Referenced by allocate().

◆ m_Stack

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

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

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

Referenced by allocate().

◆ m_StackMax

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

Size of the currently mapped stack

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

◆ m_StackReady

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

Whether or not a particular stack is ready for use.

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

Referenced by allocate().

◆ m_StackSize

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

Currently used size of the stack

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

Referenced by allocate().

◆ m_TotalPages

size_t X86CommonPhysicalMemoryManager::PageStack::m_TotalPages
private

◆ StackCount

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

The number of Stacks

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


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