Memory

Struct Memory 

Source
pub struct Memory {
    pub ptr: *mut u8,
    pub len: usize,
    /* private fields */
}
Expand description

A managed memory region.

Represents an allocated memory block with pointer, length, and physical frame number (PFN) offset information for address translation.

Fields§

§ptr: *mut u8

Block pointer

§len: usize

Block length in bytes

Implementations§

Source§

impl Memory

Source

pub fn new(ptr: *mut u8, len: usize) -> Self

Creates a new memory block with the given pointer and length.

Source

pub fn new_with_parts(ptr: *mut u8, len: usize, pfn_offset: PfnOffset) -> Self

Creates a new memory block with specified PFN offset.

§Arguments
  • ptr - Pointer to the memory block
  • len - Length in bytes
  • pfn_offset - Physical frame number offset configuration
Source

pub fn mmap(size: usize) -> Result<Self, Error>

Allocates memory using mmap.

Creates a memory-mapped region of the specified size with read/write permissions.

§Errors

Returns an I/O error if mmap fails.

Source

pub fn dealloc(self)

Deallocates the memory block.

Unmaps the memory region using munmap. Consumes self.

Trait Implementations§

Source§

impl BytePointer for Memory

Source§

fn addr(&self, offset: usize) -> *mut u8

Returns a mutable pointer to the byte at the given offset. Read more
Source§

fn ptr(&self) -> *mut u8

Returns a mutable pointer to the start of the memory region.
Source§

fn len(&self) -> usize

Returns the total length of the memory region in bytes.
Source§

fn dump(&self, file: &str) -> Result<()>

Dumps memory contents to a file in hexadecimal format. Read more
Source§

impl Clone for Memory

Source§

fn clone(&self) -> Memory

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Memory

Source§

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

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

impl GetConsecPfns for Memory

Source§

fn consec_pfns(&self) -> Result<Vec<Range<PhysAddr>>, Error>

Returns the consecutive PFN ranges for this memory region. Read more
Source§

fn log_pfns(&self, level: Level)

Logs the PFN ranges at the specified log level.
Source§

impl Send for Memory

Auto Trait Implementations§

§

impl Freeze for Memory

§

impl !RefUnwindSafe for Memory

§

impl !Sync for Memory

§

impl Unpin for Memory

§

impl UnwindSafe for Memory

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> 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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PfnOffsetResolver for T
where T: BytePointer + CachedPfnOffset,

Source§

fn pfn_offset( &self, mem_config: &MemConfiguration, conflict_threshold: u64, timer: &dyn MemoryTupleTimer, progress: Option<&MultiProgress>, ) -> Option<usize>

Find the PFN-VA offset in rows.

This is brute force, simply trying all row offsets from 0…row_offsets (determined using mem_config) There probably is a more sophisticated way to implement this, e.g., by examing the bank orders and filtering for possible “bank periods” after each iteration, but this here should be fast enough for now. WARNING: This function initializes pfn_offset with the provided mem_config. Calling #pfn_offset(…) with different arguments afterward WILL NOT reset the OnceCell, potentially causing unintended behavior.

Source§

impl<T> PfnResolver for T
where T: BytePointer,

Source§

fn pfn(&self) -> Result<PhysAddr, LinuxPageMapError>

Returns the physical frame number for this address. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V