Struct kernel::registry::Registry

source ·
pub struct Registry {
    items: RwLock<FixedVec<RegistryItem>>,
    counter: AtomicU32,
    service_added: WaitQueue,
}
Expand description

The driver registry used by the kernel.

Fields§

§items: RwLock<FixedVec<RegistryItem>>§counter: AtomicU32§service_added: WaitQueue

Implementations§

source§

impl Registry

source

pub fn new(max_items: usize) -> Self

Create a new registry with room for up to max_items registered drivers.

source

pub async fn bind_konly<RD>( &self, capacity: usize, ) -> Result<Listener<RD>, RegistrationError>
where RD: RegisteredDriver,

Bind a kernel-only Listener for a driver service of type RD.

This is a helper method which creates a Listener using Listener::new and then registers that Listener’s listener::Registration with the registry using Registry::register_konly.

Driver services registered with Registry::bind_konly can NOT be queried or interfaced with from Userspace. If a registered service has request and response types that are serializable, it can instead be registered with Registry::bind which allows for userspace access.

source

pub async fn bind<RD>( &self, capacity: usize, ) -> Result<Listener<RD>, RegistrationError>

Bind a Listener for a driver service of type RD.

This is a helper method which creates a Listener using Listener::new and then registers that Listener’s listener::Registration with the registry using Registry::register.

Driver services registered with Registry::bind can be accessed both by the kernel and by userspace. This requires that the RegisteredDriver’s message types implement Serialize and DeserializeOwned. Driver services whose message types are not serializable may still bind listeners using Registry::bind_konly, but these listeners will not be accessible from userspace.

source

pub async fn register_konly<RD: RegisteredDriver>( &self, registration: Registration<RD>, ) -> Result<(), RegistrationError>

Register a driver service ONLY for use in the kernel, including drivers.

Driver services registered with Registry::register_konly can NOT be queried or interfaced with from Userspace. If a registered service has request and response types that are serializable, it can instead be registered with Registry::register which allows for userspace access.

source

pub async fn register<RD>( &self, registration: Registration<RD>, ) -> Result<(), RegistrationError>

Register a driver service for use in the kernel (including drivers) as well as in userspace.

See Registry::register_konly if the request and response types are not serializable.

source

pub async fn try_connect<RD: RegisteredDriver>( &self, hello: RD::Hello, ) -> Result<KernelHandle<RD>, ConnectError<RD>>

Attempt to get a kernelspace (including drivers) handle of a given driver service, which does not require sending a RegisteredDriver::Hello message.

This can be used by drivers and tasks to interface with a registered driver service.

The driver service MUST have already been registered using Registry::register or Registry::register_konly prior to making this call, otherwise no handle will be returned. To wait until a driver is registered, use Registry::connect instead.

§Returns
source

pub async fn connect<RD>( &self, hello: RD::Hello, ) -> Result<KernelHandle<RD>, ConnectError<RD>>
where RD: RegisteredDriver,

Get a kernelspace (including drivers) handle of a given driver service, waiting until the service is registered if it does not already exist.

This can be used by drivers and tasks to interface with a registered driver service.

If no service matching the requested RegisteredDriver type has been registered, this method will wait until that service is added to the registry, unless the registry becomes full.

§Returns
source

pub async fn connect_userspace<RD>( &self, scheduler: &LocalScheduler, user_hello: &[u8], ) -> Result<UserspaceHandle, UserConnectError<RD>>

Get a kernelspace (including drivers) handle of a given driver service, waiting until the service is registered if it does not already exist.

This can be used by drivers and tasks to interface with a registered driver service.

§Returns
  • Ok([KernelHandle])` if the requested service was found and a connection was successfully established.

  • Err(ConnectError) if the requested service was not found in the registry, or if the service rejected the incoming connection. Note that ConnectError::NotFound is not returned unless the registry is full and no more services will be added.

source

pub async fn try_connect_userspace<RD>( &self, scheduler: &LocalScheduler, user_hello: &[u8], ) -> Result<UserspaceHandle, UserConnectError<RD>>

Try to get a handle capable of processing serialized userspace messages to a registered driver service, given a byte buffer for the userspace RegisteredDriver::Hello message.

The driver service MUST have already been registered using Registry::register or prior to making this call, otherwise no handle will be returned.

Driver services registered with Registry::register_konly cannot be retrieved via a call to Registry::try_connect_userspace.

source

async fn insert_item(&self, item: RegistryItem) -> Result<(), RegistrationError>

source

fn get<RD: RegisteredDriver>( items: &FixedVec<RegistryItem>, ) -> Option<&RegistryItem>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.