pub struct Pages<const ORDER: u32> { /* private fields */ }
Expand description
A set of physical pages.
Pages
holds a reference to a set of pages of order ORDER
. Having the order as a generic
const allows the struct to have the same size as a pointer.
Invariants
The pointer Pages::pages
is valid and points to 2^ORDER pages.
Implementations
sourceimpl<const ORDER: u32> Pages<ORDER>
impl<const ORDER: u32> Pages<ORDER>
sourcepub fn copy_into_page(
&self,
reader: &mut UserSlicePtrReader,
offset: usize,
len: usize
) -> Result
pub fn copy_into_page(
&self,
reader: &mut UserSlicePtrReader,
offset: usize,
len: usize
) -> Result
Copies data from the given UserSlicePtrReader
into the pages.
sourcepub unsafe fn read(&self, dest: *mut u8, offset: usize, len: usize) -> Result
pub unsafe fn read(&self, dest: *mut u8, offset: usize, len: usize) -> Result
Maps the pages and reads from them into the given buffer.
Safety
Callers must ensure that the destination buffer is valid for the given length.
Additionally, if the raw buffer is intended to be recast, they must ensure that the data
can be safely cast; crate::io_buffer::ReadableFromBytes
has more details about it.
sourcepub unsafe fn write(&self, src: *const u8, offset: usize, len: usize) -> Result
pub unsafe fn write(&self, src: *const u8, offset: usize, len: usize) -> Result
Maps the pages and writes into them from the given buffer.
Safety
Callers must ensure that the buffer is valid for the given length. Additionally, if the
page is (or will be) mapped by userspace, they must ensure that no kernel data is leaked
through padding if it was cast from another type; crate::io_buffer::WritableToBytes
has
more details about it.