[−][src]Struct sunrise_kernel::process::HandleTable
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.
- It will not be reused ever. If a userspace attempts to use a handle after closing it, it will be guaranteed to receive an InvalidHandle error.
- It will always be above 0, and under 0xFFFF0000.
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]
&self,
handle: u32
) -> Result<Arc<Handle>, UserspaceError>
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]
&mut self,
handle: u32
) -> Result<Arc<Handle>, UserspaceError>
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]
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]
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>,