Struct syscall::io::PhysBox

source ·
pub struct PhysBox { /* private fields */ }
Expand description

An RAII guard of a physical memory allocation. Currently all physically allocated memory are page-aligned and take up at least 4k of space (on x86_64).

Implementations§

source§

impl PhysBox

source

pub unsafe fn from_raw_parts(address: usize, size: usize) -> Self

Construct a PhysBox from an address and a size. The address must be page-aligned, and the size must similarly be a multiple of the page size.

Safety

This function is unsafe because when dropping, Self has to a valid allocation.

source

pub fn address(&self) -> usize

Retrieve the byte address in physical memory, of this allocation.

source

pub fn size(&self) -> usize

Retrieve the size in bytes of the alloc.

source

pub fn new_in_32bit_space(size: usize) -> Result<Self>

Allocate physical memory that must reside in 32-bit space.

source

pub fn new_with_flags(size: usize, flags: PhysallocFlags) -> Result<Self>

source

pub fn new_partial_allocation( size: usize, flags: PhysallocFlags, strategy: Option<PartialAllocStrategy>, min: usize ) -> Result<Self>

“Partially” allocate physical memory, in the sense that the allocation may be smaller than expected, but still with a minimum limit. This is particularly useful when the physical memory space is fragmented, and a device supports scatter-gather I/O. In that case, the driver can optimistically request e.g. 1 alloc of 1 MiB, with the minimum of 512 KiB. If that first allocation only returns half the size, the driver can do another allocation and then let the device use both buffers.

source

pub fn new(size: usize) -> Result<Self>

Trait Implementations§

source§

impl Debug for PhysBox

source§

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

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

impl Drop for PhysBox

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.