[−][src]Struct sunrise_kernel::paging::bookkeeping::UserspaceBookkeeping
A bookkeeping is just a list of Mappings
We store them in a BTreeMap where the address is the key, to obtain O(log(n)) search time for the closest mapping of a given address.
We do not store Available mappings in it, as it would require a lot of splitting overhead, and instead consider holes as Available mappings.
Fields
mappings: BTreeMap<VirtualAddress, Mapping>
The list of mappings of this process.
Implementations
impl UserspaceBookkeeping
[src]
pub fn new() -> Self
[src]
Constructs a UserspaceBookkeeping
Initially contains only SystemReserved regions for KernelLand and RecursiveTableLand
pub fn mapping_at_or_following(
&self,
address: VirtualAddress
) -> Option<&Mapping>
[src]
&self,
address: VirtualAddress
) -> Option<&Mapping>
Returns the mapping address
falls into, or if it is available,
the first following mapping.
If no mapping follows address
, returns None
pub fn mapping_at_or_preceding(
&self,
address: VirtualAddress
) -> Option<&Mapping>
[src]
&self,
address: VirtualAddress
) -> Option<&Mapping>
Returns the mapping address
falls into, or if it is available,
the first preceding mapping.
If no mapping precedes address
, returns None
pub fn mapping_at(&self, address: VirtualAddress) -> QueryMemory
[src]
Returns the mapping address
falls into.
pub fn occupied_mapping_at(
&self,
address: VirtualAddress
) -> Result<&Mapping, KernelError>
[src]
&self,
address: VirtualAddress
) -> Result<&Mapping, KernelError>
Returns the mapping address
falls into.
Fails if there is no occupied mapping at address
.
Errors
InvalidAddress
:- mapping pointed to by address is vacant.
pub fn is_vacant(
&self,
address: VirtualAddress,
length: usize
) -> Result<bool, KernelError>
[src]
&self,
address: VirtualAddress,
length: usize
) -> Result<bool, KernelError>
Checks that a given range is unoccupied.
Errors
InvalidAddress
:address + length - 1
would overflow
InvalidSize
:length
is 0.
pub fn check_vacant(
&self,
address: VirtualAddress,
length: usize
) -> Result<(), KernelError>
[src]
&self,
address: VirtualAddress,
length: usize
) -> Result<(), KernelError>
Asserts that a given range is unoccupied
Errors
InvalidAddress
:- range is occupied.
address + length - 1
would overflow
InvalidSize
:length
is 0.
pub fn add_mapping(&mut self, mapping: Mapping) -> Result<(), KernelError>
[src]
pub fn remove_mapping(
&mut self,
address: VirtualAddress,
length: usize
) -> Result<Mapping, KernelError>
[src]
&mut self,
address: VirtualAddress,
length: usize
) -> Result<Mapping, KernelError>
Removes a mapping from the tracked mappings, and returns it.
This function will never split an existing tracked mapping.
Errors
InvalidAddress
:
* address
does not correspond to the start of a mapping.
InvalidSize
:
* length
is not the size of the mapping at address
.
pub fn remove_mapping_split(
&mut self,
_address: VirtualAddress,
_length: usize
) -> Result<Mapping, KernelError>
[src]
&mut self,
_address: VirtualAddress,
_length: usize
) -> Result<Mapping, KernelError>
Removes part of a mapping from the tracked mappings, and returns it.
If the range given by address-length falls inside an existing mapping, and this region is bigger than the range, the region is splitted in parts, and the part corresponding to the requested range is removed and returned.
Error
Returns a KernelError if address falls in an available mapping. Returns a KernelError if the range spans multiple mappings. Returns a KernelError if the range falls in a Shared mapping, as it cannot be splitted.
pub fn find_available_space(
&self,
length: usize
) -> Result<VirtualAddress, KernelError>
[src]
&self,
length: usize
) -> Result<VirtualAddress, KernelError>
Finds a hole in virtual space at least length
long.
Error
Returns a KernelError if no sufficiently big hole was found.
Returns a KernelError if length
is 0.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for UserspaceBookkeeping
impl Send for UserspaceBookkeeping
impl Sync for UserspaceBookkeeping
impl Unpin for UserspaceBookkeeping
impl !UnwindSafe for UserspaceBookkeeping
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,