[][src]Struct sunrise_kernel::paging::bookkeeping::UserspaceBookkeeping

pub struct UserspaceBookkeeping {
    mappings: BTreeMap<VirtualAddress, Mapping>,
}

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]

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]

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]

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]

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]

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]

Adds a mapping to the list of tracked mappings

Errors

  • InvalidAddress:
    • range is not vacant.

pub fn remove_mapping(
    &mut self,
    address: VirtualAddress,
    length: usize
) -> Result<Mapping, KernelError>
[src]

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]

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]

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

impl Debug for UserspaceBookkeeping[src]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.