pub struct PagedSegment<'a> { /* private fields */ }Expand description
Memory segment that allows customized page fault handling in user space.
Implementations§
Source§impl<'a> PagedSegment<'a>
impl<'a> PagedSegment<'a>
Sourcepub unsafe fn from_raw<S: PageStore + Send + 'static>(
base: *mut u8,
size: usize,
store: S,
page_size: Option<usize>,
) -> Result<PagedSegment<'static>, Error>
pub unsafe fn from_raw<S: PageStore + Send + 'static>( base: *mut u8, size: usize, store: S, page_size: Option<usize>, ) -> Result<PagedSegment<'static>, Error>
Make the user-space paged segement at an existing memory location.
Note that the range of addresses should be valid throughout the lifetime of PagedSegment and no access should be made to the memory unless it is wrapped in [PagedSegment::run].
Sourcepub fn new<S: PageStore + Send + 'static>(
length: usize,
store: S,
page_size: Option<usize>,
) -> Result<PagedSegment<'static>, Error>
pub fn new<S: PageStore + Send + 'static>( length: usize, store: S, page_size: Option<usize>, ) -> Result<PagedSegment<'static>, Error>
Allocate new memory to be user-space paged.
pub fn as_slice_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_slice(&self) -> &[u8] ⓘ
pub fn as_raw_parts(&self) -> (*mut u8, usize)
Sourcepub fn reset_write_detection(
&self,
offset: usize,
size: usize,
) -> Result<(), Error>
pub fn reset_write_detection( &self, offset: usize, size: usize, ) -> Result<(), Error>
Mark the entire PagedSegment to be aware of all subsequent writes, this will trigger write-access page faults again when write operation is made in the future, even though the location was previously written.
Sourcepub fn release_page(&self, page_offset: usize) -> Result<(), Error>
pub fn release_page(&self, page_offset: usize) -> Result<(), Error>
Release the page content loaded from PageStore. The next access to an address within this
page will trigger a page fault. page_offset must be one of the offset that may pass to
page fault handler in PageStore (thus it has to be aligned to the beginning of a page).
pub fn release_all_pages(&self) -> Result<(), Error>
Patch a SharedMemory to a part of this memory segment. The given shm will start with an
offset from the beginning of Segment, and cannot overrun the end of the segment. The
given SharedMemory outlives this object once patched (even if it is over-shadowed by
subsequent patching).