Skip to main content

AllocatorOps

Trait AllocatorOps 

Source
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§

Source

fn name(&self) -> &'static str

Returns the allocator name.

Source

fn init(&self, start_vaddr: usize, size: usize) -> AllocResult

Initializes the allocator with the given region.

Source

fn add_memory(&self, start_vaddr: usize, size: usize) -> AllocResult

Adds an extra memory region to the allocator.

Source

fn alloc(&self, layout: Layout) -> AllocResult<NonNull<u8>>

Allocates arbitrary bytes.

Source

fn dealloc(&self, pos: NonNull<u8>, layout: Layout)

Deallocates a prior byte allocation.

Source

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.

Source

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.

Source

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.

Source

fn dealloc_pages(&self, pos: usize, num_pages: usize, kind: UsageKind)

Deallocates a prior page allocation.

Source

fn used_bytes(&self) -> usize

Returns used byte count.

Source

fn available_bytes(&self) -> usize

Returns available byte count.

Source

fn used_pages(&self) -> usize

Returns used page count.

Source

fn available_pages(&self) -> usize

Returns available page count.

Source

fn usages(&self) -> Usages

Returns usage statistics.

Implementors§