class Pow2RangeAllocator
Defined at line 30 of file ../../zircon/kernel/lib/pow2_range_allocator/include/lib/pow2_range_allocator.h
Pow2RangeAllocator is a small utility class which partitions a set of
ranges of integers into sub-ranges which are power of 2 in length and power
of 2 aligned and then manages allocating and freeing the subranges for
clients. It is responsible for breaking larger sub-regions into smaller ones
as needed for allocation, and for merging sub-regions into larger sub-regions
as needed during free operations.
Its primary use is as a utility library for plaforms who need to manage
allocating blocks MSI IRQ IDs on behalf of the PCI bus driver, but could (in
theory) be used for other things).
Public Methods
void Pow2RangeAllocator ()
Defined at line 32 of file ../../zircon/kernel/lib/pow2_range_allocator/include/lib/pow2_range_allocator.h
void Pow2RangeAllocator (const Pow2RangeAllocator & )
Pow2RangeAllocators cannot be copied or moved.
Defined at line 35 of file ../../zircon/kernel/lib/pow2_range_allocator/include/lib/pow2_range_allocator.h
void Pow2RangeAllocator (Pow2RangeAllocator && )
Defined at line 36 of file ../../zircon/kernel/lib/pow2_range_allocator/include/lib/pow2_range_allocator.h
Pow2RangeAllocator & operator= (const Pow2RangeAllocator & )
Defined at line 37 of file ../../zircon/kernel/lib/pow2_range_allocator/include/lib/pow2_range_allocator.h
Pow2RangeAllocator & operator= (Pow2RangeAllocator && )
Defined at line 38 of file ../../zircon/kernel/lib/pow2_range_allocator/include/lib/pow2_range_allocator.h
zx_status_t Init (uint32_t max_alloc_size)
Initialize the state of a pow2 range allocator.
Parameters
Returns
A status code indicating the success or failure of the operation.
Defined at line 122 of file ../../zircon/kernel/lib/pow2_range_allocator/pow2_range_allocator.cc
void Free ()
Free all of the state associated with a previously initialized pow2 range
allocator.
Defined at line 140 of file ../../zircon/kernel/lib/pow2_range_allocator/pow2_range_allocator.cc
zx_status_t AddRange (uint32_t range_start, uint32_t range_len)
Add a range of uint32_ts to the pool of ranges to be allocated.
Parameters
Returns
A status code incidcating the success or failure of the operation.
Possible return values include
++ ZX_ERR_INVALID_ARGS range_len is zero, or would cause the range to wrap the
maximum range of a uint32_t.
++ ZX_ERR_ALREADY_EXISTS the specified range overlaps with a range already added
to the allocator.
++ ZX_ERR_NO_MEMORY Not enough memory to allocate the bookkeeping required for
managing the range.
Defined at line 152 of file ../../zircon/kernel/lib/pow2_range_allocator/pow2_range_allocator.cc
zx_status_t AllocateRange (uint32_t size, uint32_t * out_range_start)
Attempt to allocate a range of uint32_ts from the available sub-ranges. The
sizeo the allocated range must be a power of 2, and if the allocation
succeeds, it is guaranteed to be aligned on a power of 2 boundary matching it
size.
Parameters
Returns
A status code indicating the success or failure of the operation.
Possible return values include
++ ZX_ERR_INVALID_ARGS Multiple reasons, including...
++ size is zero.
++ size is not a power of two.
++ out_range_start is NULL.
++ ZX_ERR_NO_RESOURCES No contiguous, aligned region could be found to satisfy
the allocation request.
++ ZX_ERR_NO_MEMORY A region could be found, but memory required for bookkeeping
could not be allocated.
Defined at line 245 of file ../../zircon/kernel/lib/pow2_range_allocator/pow2_range_allocator.cc
void FreeRange (uint32_t range_start, uint32_t size)
Free a range previously allocated using AllocateRange.
Parameters
Defined at line 321 of file ../../zircon/kernel/lib/pow2_range_allocator/pow2_range_allocator.cc