The Pedigree Project 0.1
Classes | Public Member Functions | Private Types | Private Attributes | List of all members
RangeList< T, Reversed > Class Template Reference

#include <RangeList.h>

+ Inheritance diagram for RangeList< T, Reversed >:
+ Collaboration diagram for RangeList< T, Reversed >:

Classes

struct  Range
 

Public Member Functions

 RangeList ()
 
 RangeList (bool preferUsed)
 
 RangeList (T Address, T Length, bool XXX, bool preferUsed=false)
 
 ~RangeList ()
 
 RangeList (const RangeList &)
 
RangeList & operator= (const RangeList &l)
 
void free (T address, T length, bool merge=true)
 
bool tryFree (T address, T length, bool merge=true)
 
bool freeWithoutAllocation (T address, T length)
 
bool allocateWithoutAllocation (T length, T &address)
 
bool allocateSpecificWithoutAllocation (T address, T length)
 
bool allocate (T length, T &address)
 
bool allocateSpecific (T address, T length)
 
void clear ()
 
void swap (RangeList &other) noexcept
 
size_t size () const
 
bool getRange (size_t index, Range &range) const
 
void sweep ()
 
void dump (void(*emit_line)(const char *s)) const
 

Private Types

typedef decltype(m_List) ::Iterator Iterator
 
typedef decltype(m_List) ::ConstIterator ConstIterator
 
typedef decltype(m_List) ::ReverseIterator ReverseIterator
 
typedef decltype(m_List) ::ConstReverseIterator ConstReverseIterator
 

Private Attributes

Vector< Range > m_List
 
bool m_bPreferUsed
 

Detailed Description

template<typename T, bool Reversed = false>
class RangeList< T, Reversed >

This class manages a List of ranges. It automatically merges adjacent entries in the list.

Parameters
[in]Tthe integer type the range address and length is encoded in

Definition at line 35 of file RangeList.h.

Member Typedef Documentation

◆ ConstIterator

template<typename T , bool Reversed = false>
typedef decltype(m_List) ::ConstIterator RangeList< T, Reversed >::ConstIterator
private

Definition at line 124 of file RangeList.h.

◆ ConstReverseIterator

template<typename T , bool Reversed = false>
typedef decltype(m_List) ::ConstReverseIterator RangeList< T, Reversed >::ConstReverseIterator
private

Definition at line 126 of file RangeList.h.

◆ Iterator

template<typename T , bool Reversed = false>
typedef decltype(m_List) ::Iterator RangeList< T, Reversed >::Iterator
private

Definition at line 123 of file RangeList.h.

◆ ReverseIterator

template<typename T , bool Reversed = false>
typedef decltype(m_List) ::ReverseIterator RangeList< T, Reversed >::ReverseIterator
private

Definition at line 125 of file RangeList.h.

Constructor & Destructor Documentation

◆ RangeList() [1/4]

template<typename T , bool Reversed = false>
RangeList< T, Reversed >::RangeList ( )
inline

Default constructor does nothing

Definition at line 38 of file RangeList.h.

◆ RangeList() [2/4]

template<typename T , bool Reversed = false>
RangeList< T, Reversed >::RangeList ( bool  preferUsed)
inline

Construct with reverse order, without an initial allocation.

Definition at line 40 of file RangeList.h.

◆ RangeList() [3/4]

template<typename T , bool Reversed = false>
RangeList< T, Reversed >::RangeList ( T  Address,
T  Length,
bool  XXX,
bool  preferUsed = false 
)
inline

Construct with a preexisting range

Parameters
[in]Addressbeginning of the range
[in]Lengthlength of the range

Definition at line 44 of file RangeList.h.

◆ ~RangeList()

template<typename T , bool Reversed>
RangeList< T, Reversed >::~RangeList ( )

Destructor frees the list

Definition at line 429 of file RangeList.h.

◆ RangeList() [4/4]

template<typename T , bool Reversed>
RangeList< T, Reversed >::RangeList ( const RangeList< T, Reversed > &  other)

Copy constructor - performs deep copy.

Definition at line 133 of file RangeList.h.

References RangeList< T, Reversed >::m_List.

Member Function Documentation

◆ allocate()

template<typename T , bool Reversed>
bool RangeList< T, Reversed >::allocate ( T  length,
T &  address 
)

Allocate a range of a specific size

Parameters
[in]lengththe requested length
[in,out]addressthe beginning address of the allocated range
Returns
true, if successfully allocated (and address is valid), false otherwise

Definition at line 318 of file RangeList.h.

References RangeList< T, Reversed >::Range::address, and RangeList< T, Reversed >::Range::length.

Referenced by HostedPhysicalMemoryManager::allocateRegion(), X86CommonPhysicalMemoryManager::allocateRegion(), Cache::insert(), Cache::insert(), and KernelElf::prepareRuntimeModules().

+ Here is the caller graph for this function:

◆ allocateSpecific()

template<typename T , bool Reversed>
bool RangeList< T, Reversed >::allocateSpecific ( T  address,
T  length 
)

Allocate a range of specific size and beginning address

Parameters
[in]addressthe beginning address
[in]lengththe length
Returns
true, if successfully allocated, false otherwise

Definition at line 363 of file RangeList.h.

References RangeList< T, Reversed >::Range::address, and RangeList< T, Reversed >::Range::length.

Referenced by IoPortManager::allocate(), HostedPhysicalMemoryManager::allocateRegion(), X86CommonPhysicalMemoryManager::allocateRegion(), HostedPhysicalMemoryManager::initialise(), X86CommonPhysicalMemoryManager::initialise(), and X86CommonPhysicalMemoryManager::initialise64().

+ Here is the caller graph for this function:

◆ allocateSpecificWithoutAllocation()

template<typename T , bool Reversed>
bool RangeList< T, Reversed >::allocateSpecificWithoutAllocation ( T  address,
T  length 
)

Definition at line 280 of file RangeList.h.

◆ allocateWithoutAllocation()

template<typename T , bool Reversed>
bool RangeList< T, Reversed >::allocateWithoutAllocation ( T  length,
T &  address 
)

Definition at line 260 of file RangeList.h.

◆ clear()

template<typename T , bool Reversed>
void RangeList< T, Reversed >::clear ( )

Definition at line 434 of file RangeList.h.

◆ dump()

template<typename T , bool Reversed>
void RangeList< T, Reversed >::dump ( void(*)(const char *s)  emit_line) const

Render the RangeList, emitting each range using the given callback.

Definition at line 467 of file RangeList.h.

References RangeList< T, Reversed >::Range::address, and RangeList< T, Reversed >::Range::length.

◆ free()

template<typename T , bool Reversed>
void RangeList< T, Reversed >::free ( T  address,
T  length,
bool  merge = true 
)

◆ freeWithoutAllocation()

template<typename T , bool Reversed>
bool RangeList< T, Reversed >::freeWithoutAllocation ( T  address,
T  length 
)

Retain exhausted entries as reusable storage; these never allocate.

Definition at line 228 of file RangeList.h.

References RangeList< T, Reversed >::Range::address, and RangeList< T, Reversed >::Range::length.

◆ getRange()

template<typename T , bool Reversed>
bool RangeList< T, Reversed >::getRange ( size_t  index,
Range &  range 
) const

Get a range at a specific index.

Definition at line 419 of file RangeList.h.

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

+ Here is the caller graph for this function:

◆ operator=()

template<typename T , bool Reversed>
RangeList< T, Reversed > & RangeList< T, Reversed >::operator= ( const RangeList< T, Reversed > &  l)

Definition at line 141 of file RangeList.h.

◆ size()

template<typename T , bool Reversed = false>
size_t RangeList< T, Reversed >::size ( ) const
inline

Get the number of ranges in the list

Returns
the number of ranges in the list

Definition at line 104 of file RangeList.h.

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

+ Here is the caller graph for this function:

◆ swap()

template<typename T , bool Reversed = false>
void RangeList< T, Reversed >::swap ( RangeList< T, Reversed > &  other)
inlinenoexcept

Exchange range storage without allocating or freeing it.

Definition at line 95 of file RangeList.h.

Referenced by Process::commitUserReservations().

+ Here is the caller graph for this function:

◆ sweep()

template<typename T , bool Reversed>
void RangeList< T, Reversed >::sweep ( )

Sweep the RangeList and re-merge items.

Definition at line 439 of file RangeList.h.

References RangeList< T, Reversed >::Range::address, and RangeList< T, Reversed >::Range::length.

◆ tryFree()

template<typename T , bool Reversed>
bool RangeList< T, Reversed >::tryFree ( T  address,
T  length,
bool  merge = true 
)

Definition at line 211 of file RangeList.h.

Member Data Documentation

◆ m_bPreferUsed

template<typename T , bool Reversed = false>
bool RangeList< T, Reversed >::m_bPreferUsed
private

Should we prefer previously-used ranges where possible?

Definition at line 121 of file RangeList.h.

◆ m_List

template<typename T , bool Reversed = false>
Vector<Range> RangeList< T, Reversed >::m_List
private

List of ranges

Definition at line 118 of file RangeList.h.

Referenced by RangeList< T, Reversed >::RangeList().


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