Struct mycelium_alloc::buddy::Alloc

source ·
pub struct Alloc<const FREE_LISTS: usize> { /* private fields */ }

Implementations§

source§

impl<const FREE_LISTS: usize> Alloc<FREE_LISTS>

source

pub const fn new(min_size: usize) -> Self

source

pub fn set_vm_offset(&self, offset: VAddr)

source

pub fn min_size(&self) -> usize

Returns the minimum allocatable size, in bytes.

source

pub fn total_size(&self) -> usize

Returns the total size of the allocator (allocated and free), in bytes.

source

pub fn allocated_size(&self) -> usize

Returns the currently allocated size in bytes.

source§

impl<const FREE_LISTS: usize> Alloc<FREE_LISTS>

source

pub fn dump_free_lists(&self)

source

pub unsafe fn add_region(&self, region: Region) -> Result<(), ()>

Adds a memory region to the heap from which pages may be allocated.

Trait Implementations§

source§

impl<S, const FREE_LISTS: usize> Alloc<S> for Alloc<FREE_LISTS>
where S: Size + Display,

source§

fn alloc_range( &self, size: S, len: usize ) -> Result<PageRange<PAddr, S>, AllocErr>

Allocate a range of at least len pages.

If len is not a power of two, the length is rounded up to the next power of two. The returned PageRange struct stores the actual length of the allocated page range.

Returns
  • Ok(PageRange) if a range of pages was successfully allocated
  • Err if the requested range could not be satisfied by this allocator.
source§

fn dealloc_range(&self, range: PageRange<PAddr, S>) -> Result<(), AllocErr>

Deallocate a range of pages.

Returns
  • Ok(()) if a range of pages was successfully deallocated
  • Err if the requested range could not be deallocated.
§

fn alloc(&self, size: S) -> Result<Page<PAddr, S>, AllocErr>

Allocate a single page. Read more
§

fn dealloc(&self, page: Page<PAddr, S>) -> Result<(), AllocErr>

Deallocate a single page. Read more
source§

impl<const FREE_LISTS: usize> Debug for Alloc<FREE_LISTS>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<const FREE_LISTS: usize> GlobalAlloc for Alloc<FREE_LISTS>

source§

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

Allocate memory as described by the given layout. Read more
source§

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

Deallocate the block of memory at the given ptr pointer with the given layout. Read more
1.28.0 · source§

unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8

Behaves like alloc, but also ensures that the contents are set to zero before being returned. Read more
1.28.0 · source§

unsafe fn realloc( &self, ptr: *mut u8, layout: Layout, new_size: usize ) -> *mut u8

Shrink or grow a block of memory to the given new_size in bytes. The block is described by the given ptr pointer and layout. Read more

Auto Trait Implementations§

§

impl<const FREE_LISTS: usize> !RefUnwindSafe for Alloc<FREE_LISTS>

§

impl<const FREE_LISTS: usize> Send for Alloc<FREE_LISTS>

§

impl<const FREE_LISTS: usize> Sync for Alloc<FREE_LISTS>

§

impl<const FREE_LISTS: usize> Unpin for Alloc<FREE_LISTS>

§

impl<const FREE_LISTS: usize> !UnwindSafe for Alloc<FREE_LISTS>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.