[][src]Struct sunrise_kernel::process::HandleTable

pub struct HandleTable {
    table: BTreeMap<u32, Arc<Handle>>,
    counter: u32,
}

Holds the table associating userspace handle numbers to a kernel Handle.

Each process holds a table associating a number to a kernel Handle. This number is unique to that process, handles are not shared between processes.

Handle numbers hold two guarantees.

Technically, a Horizon/NX handle is composed of two parts: The top 16 bits are randomized, while the top 16 bits are an auto-incrementing counters. Because of this, it is impossible to have more than 65535 handles.

In Sunrise, we do not yet have randomness, so the counter just starts from 1 and goes up.

There exists two "meta-handles": 0xFFFF8000 and 0xFFFF8001, which always point to the current process and thread, respectively. Those handles are not actually stored in the handle table to avoid creating a reference cycle. Instead, they are retrieved dynamically at runtime by the get_handle function.

Fields

table: BTreeMap<u32, Arc<Handle>>

Internal mapping from a handle number to a Kernel Object.

counter: u32

The next handle's ID.

Implementations

impl HandleTable[src]

pub fn add_handle(&mut self, handle: Arc<Handle>) -> u32[src]

Add a handle to the handle table, returning the userspace handle number associated to the given handle.

pub fn get_handle(&self, handle: u32) -> Result<Arc<Handle>, UserspaceError>[src]

Gets the Kernel Handle associated with the given userspace handle number.

Errors

  • InvalidHandle
    • The provided handle does not exist in the handle table.

pub fn get_handle_no_alias(
    &self,
    handle: u32
) -> Result<Arc<Handle>, UserspaceError>
[src]

Gets the Kernel Handle associated with the given userspace handle number.

Does not interpret 0xFFFF8000 and 0xFFFF8001.

Errors

  • InvalidHandle
    • The provided handle does not exist in the handle table.

pub fn delete_handle(
    &mut self,
    handle: u32
) -> Result<Arc<Handle>, UserspaceError>
[src]

Deletes the mapping from the given userspace handle number. Returns the underlying Kernel Handle, in case it needs to be used (e.g. for sending to another process in an IPC move).

Trait Implementations

impl Debug for HandleTable[src]

impl Default for HandleTable[src]

fn default() -> Self[src]

Creates an empty handle table. Note that an empty handle table still implicitly contains the meta-handles 0xFFFF8000 and 0xFFFF8001.

Auto Trait Implementations

impl !RefUnwindSafe for HandleTable

impl Send for HandleTable

impl Sync for HandleTable

impl Unpin for HandleTable

impl !UnwindSafe for HandleTable

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.