ADC Home > Reference Library > Reference > Darwin > Kernel Framework Reference
|
IORangeAllocator |
Inherits from: | |
Declared In: |
A utility class to manage allocations from a range.
The IORangeAllocator class provides functions for allocating ranges, at a fixed or any offset, and freeing them back to a free list. It is useful for describing ranges of memory or address space without requiring storage in the memory - information describing the free elements is kept elsewhere. Ranges are described by a start offset and a size. IORangeAllocator is optionally protected against multithreaded access.
Allocates from the free list, at any offset.
Allocates from the free list, at a set offset.
Deallocates a range to the free list.
Accessor to return the number of free fragments in the range.
Accessor to return the number of free fragments in the range.
Totals the sizes of the free fragments.
Standard initializer for IORangeAllocator.
Sets the count of fragments the free list will increase by when full.
Standard factory method for IORangeAllocator.
allocate |
Allocates from the free list, at any offset.
public
virtual bool allocate( IORangeScalar size, IORangeScalar *result, IORangeScalar alignment = 0 );
size
The size of the range requested.
result
The beginning of the range allocated is returned here on success.
alignment
If zero is passed, default to the allocators alignment, otherwise pass an alignment required for the allocation, for example 4096 to page align.
Returns true if the allocation was successful, else false.
This method allocates a range from the free list. The alignment will default to the alignment set when the allocator was created or may be set here.
allocateRange |
Allocates from the free list, at a set offset.
public
virtual bool allocateRange( IORangeScalar start, IORangeScalar size );
start
The beginning of the range requested.
size
The size of the range requested.
Returns true if the allocation was successful, else false.
This method allocates a range from the free list, given a set offset passed in.
deallocate |
Deallocates a range to the free list.
public
virtual void deallocate( IORangeScalar start, IORangeScalar size );
start
The beginning of the range requested.
size
Returns the size of the range requested.
This method deallocates a range to the free list, given a the start offset and length passed in.
getFragmentCapacity |
Accessor to return the number of free fragments in the range.
public
virtual UInt32 getFragmentCapacity( void );
Returns the current capacity of free fragment list.
This method returns the current capacity of the free fragment list.
getFragmentCount |
Accessor to return the number of free fragments in the range.
public
virtual UInt32 getFragmentCount( void );
Returns the count of free fragments.
This method returns a count of free fragments. Each fragment describes a non-contiguous free range - deallocations will merge contiguous fragments together.
getFreeCount |
Totals the sizes of the free fragments.
public
virtual IORangeScalar getFreeCount( void );
Returns the total of the free fragments sizes.
This method returns the total of the sizes of the fragments on the free list.
init |
Standard initializer for IORangeAllocator.
public
virtual bool init( IORangeScalar endOfRange, IORangeScalar defaultAlignment, UInt32 capacity, IOOptionBits options );
endOfRange
If the free list is to contain an initial fragment, set endOfRange to the last offset in the range, ie. size - 1, to create a free fragment for the range zero to endOfRange inclusive. If zero is passed, the free list will be initialized empty, and can be populated with calls to the deallocate method.
defaultAlignment
If this parameter is non-zero it specifies a required alignment for all allocations, for example pass 256 to align allocations on 256 byte boundaries. Zero or one specify unaligned allocations.
capacity
Sets the initial size of the free list in number of noncontiguous fragments. This value is also used for the capacityIncrement.
options
Pass kLocking if the instance can be used by multiple threads.
Returns true if the instance is successfully initialized, false on failure.
This method initializes an IORangeAllocator and optionally sets the free list to contain one fragment, from zero to an endOfRange parameter. The capacity in terms of free fragments and locking options are set for the instance.
setFragmentCapacityIncrement |
Sets the count of fragments the free list will increase by when full.
public
virtual void setFragmentCapacityIncrement( UInt32 count );
count
The number of fragments to increment the capacity by when the free list is full.
This method sets the number of extra fragments the free list will expand to when full. It defaults to the initial capacity.
withRange |
Standard factory method for IORangeAllocator.
public
static IORangeAllocator * withRange( IORangeScalar endOfRange, IORangeScalar defaultAlignment = 0, UInt32 capacity = 0, IOOptionBits options = 0 );
endOfRange
If the free list is to contain an initial fragment, set endOfRange to the last offset in the range, ie. size - 1, to create a free fragment for the range zero to endOfRange inclusive. If zero is passed the free list will be initialized empty, and can be populated with calls to the deallocate method.
defaultAlignment
If this parameter is non-zero it specifies a required alignment for all allocations, for example pass 256 to align allocations on 256 byte boundaries. Zero or one specify unaligned allocations.
capacity
Sets the initial size of the free list in number of non-contiguous fragments. This value is also used for the capacityIncrement.
options
Pass kLocking if the instance can be used by multiple threads.
Returns the new IORangeAllocator instance, to be released by the caller, or zero on failure.
This method allocates and initializes an IORangeAllocator and optionally sets the free list to contain one fragment, from zero to an endOfRange parameter. The capacity in terms of free fragments and locking options are set for the instance.
|
Last Updated: 2008-12-19