Trait Impl

Source
pub trait Impl {
    // Required methods
    fn map(addr: NonNull<u8>, size: usize, direction: Direction) -> u64;
    fn unmap(addr: NonNull<u8>, size: usize);
    fn flush(addr: NonNull<u8>, size: usize);
    fn invalidate(addr: NonNull<u8>, size: usize);

    // Provided methods
    unsafe fn alloc(layout: Layout) -> *mut u8 { ... }
    unsafe fn dealloc(ptr: *mut u8, layout: Layout) { ... }
}

Required Methods§

Source

fn map(addr: NonNull<u8>, size: usize, direction: Direction) -> u64

map virt address to physical address

Source

fn unmap(addr: NonNull<u8>, size: usize)

unmap virt address

Source

fn flush(addr: NonNull<u8>, size: usize)

write cache back to memory

Source

fn invalidate(addr: NonNull<u8>, size: usize)

invalidate cache

Provided Methods§

Source

unsafe fn alloc(layout: Layout) -> *mut u8

alloc memory.

§Safety

layout must have non-zero size. Attempting to allocate for a zero-sized layout may result in undefined behavior.

Source

unsafe fn dealloc(ptr: *mut u8, layout: Layout)

Deallocates the block of memory at the given ptr pointer with the given layout.

§Safety

The caller must ensure:

  • ptr is a block of memory currently allocated via this allocator and,

  • layout is the same layout that was used to allocate that block of memory.

Otherwise undefined behavior can result.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§