pub trait AllocatorOps {
Show 14 methods
// Required methods
fn name(&self) -> &'static str;
fn init(&self, start_vaddr: usize, size: usize) -> AllocResult;
fn add_memory(&self, start_vaddr: usize, size: usize) -> AllocResult;
fn alloc(&self, layout: Layout) -> AllocResult<NonNull<u8>>;
fn dealloc(&self, pos: NonNull<u8>, layout: Layout);
fn alloc_pages(
&self,
num_pages: usize,
align: usize,
kind: UsageKind,
) -> AllocResult<usize>;
fn alloc_dma32_pages(
&self,
num_pages: usize,
align: usize,
kind: UsageKind,
) -> AllocResult<usize>;
fn alloc_pages_at(
&self,
start: usize,
num_pages: usize,
align: usize,
kind: UsageKind,
) -> AllocResult<usize>;
fn dealloc_pages(&self, pos: usize, num_pages: usize, kind: UsageKind);
fn used_bytes(&self) -> usize;
fn available_bytes(&self) -> usize;
fn used_pages(&self) -> usize;
fn available_pages(&self) -> usize;
fn usages(&self) -> Usages;
}Expand description
Unified allocator operations provided by all ax-alloc backends.
Required Methods§
Sourcefn init(&self, start_vaddr: usize, size: usize) -> AllocResult
fn init(&self, start_vaddr: usize, size: usize) -> AllocResult
Initializes the allocator with the given region.
Sourcefn add_memory(&self, start_vaddr: usize, size: usize) -> AllocResult
fn add_memory(&self, start_vaddr: usize, size: usize) -> AllocResult
Adds an extra memory region to the allocator.
Sourcefn alloc_pages(
&self,
num_pages: usize,
align: usize,
kind: UsageKind,
) -> AllocResult<usize>
fn alloc_pages( &self, num_pages: usize, align: usize, kind: UsageKind, ) -> AllocResult<usize>
Allocates contiguous pages.
align is the requested byte alignment, not a log2/exponent.
It must be a power-of-two byte alignment accepted by the backend page allocator.
Sourcefn alloc_dma32_pages(
&self,
num_pages: usize,
align: usize,
kind: UsageKind,
) -> AllocResult<usize>
fn alloc_dma32_pages( &self, num_pages: usize, align: usize, kind: UsageKind, ) -> AllocResult<usize>
Allocates contiguous DMA32 pages.
align is the requested byte alignment, not a log2/exponent.
It must be a power-of-two byte alignment accepted by the backend page allocator.
Sourcefn alloc_pages_at(
&self,
start: usize,
num_pages: usize,
align: usize,
kind: UsageKind,
) -> AllocResult<usize>
fn alloc_pages_at( &self, start: usize, num_pages: usize, align: usize, kind: UsageKind, ) -> AllocResult<usize>
Allocates contiguous pages starting from the given address.
align is the requested byte alignment, not a log2/exponent.
It must be a power-of-two byte alignment accepted by the backend page allocator.
Sourcefn dealloc_pages(&self, pos: usize, num_pages: usize, kind: UsageKind)
fn dealloc_pages(&self, pos: usize, num_pages: usize, kind: UsageKind)
Deallocates a prior page allocation.
Sourcefn used_bytes(&self) -> usize
fn used_bytes(&self) -> usize
Returns used byte count.
Sourcefn available_bytes(&self) -> usize
fn available_bytes(&self) -> usize
Returns available byte count.
Sourcefn used_pages(&self) -> usize
fn used_pages(&self) -> usize
Returns used page count.
Sourcefn available_pages(&self) -> usize
fn available_pages(&self) -> usize
Returns available page count.