zephyr::object

Struct StaticKernelObject

source
pub struct StaticKernelObject<T> {
    pub value: UnsafeCell<T>,
    pub init: AtomicUsize,
}
Expand description

A kernel object represented statically in Rust code.

These should not be declared directly by the user, as they generally need linker decorations to be properly registered in Zephyr as kernel objects. The object has the underlying Zephyr type T, and the wrapper type W.

Kernel objects will have their StaticThing implemented as StaticKernelObject<kobj> where kobj is the type of the underlying Zephyr object. Thing will usually be a struct with a single field, which is a *mut kobj.

TODO: Can we avoid the public fields with a const new method?

TODO: Handling const-defined alignment for these.

Fields§

§value: UnsafeCell<T>

The underlying zephyr kernel object.

§init: AtomicUsize

Initialization status of this object. Most objects will start uninitialized and be initialized manually.

Implementations§

source§

impl<T> StaticKernelObject<T>

source

pub const unsafe fn new() -> StaticKernelObject<T>

Construct an empty of these objects, with the zephyr data zero-filled. This is safe in the sense that Zephyr we track the initialization, they start in the uninitialized state, and the zero value of the initialize atomic indicates that it is uninitialized.

source

pub fn init_once( &self, args: <Self as Wrapped>::I, ) -> Option<<Self as Wrapped>::T>

Get the instance of the kernel object.

Will return a single wrapped instance of this object. This will invoke the initialization, and return Some<Wrapped> for the wrapped containment type.

If it is called an additional time, it will return None.

Trait Implementations§

source§

impl Wrapped for StaticKernelObject<k_mutex>

source§

type I = ()

Mutex initializers take no argument.

source§

type T = Mutex

The wrapped type. This is what init_once() on the StaticKernelObject will return after initialization.
source§

fn get_wrapped(&self, _arg: Self::I) -> Mutex

Initialize this kernel object, and return the wrapped pointer.
source§

impl Wrapped for StaticKernelObject<k_queue>

source§

type T = Queue

The wrapped type. This is what init_once() on the StaticKernelObject will return after initialization.
source§

type I = ()

The wrapped type also requires zero or more initializers. Which are represented by this type.
source§

fn get_wrapped(&self, _arg: Self::I) -> Queue

Initialize this kernel object, and return the wrapped pointer.
source§

impl Wrapped for StaticKernelObject<k_sem>

source§

type I = (u32, u32)

The initializer for Semaphores is the initial count, and the count limit (which can be K_SEM_MAX_LIMIT, re-exported here.

source§

type T = Semaphore

The wrapped type. This is what init_once() on the StaticKernelObject will return after initialization.
source§

fn get_wrapped(&self, arg: Self::I) -> Semaphore

Initialize this kernel object, and return the wrapped pointer.
source§

impl Wrapped for StaticKernelObject<k_thread>

source§

type T = Thread

The wrapped type. This is what init_once() on the StaticKernelObject will return after initialization.
source§

type I = ThreadStack

The wrapped type also requires zero or more initializers. Which are represented by this type.
source§

fn get_wrapped(&self, stack: Self::I) -> Self::T

Initialize this kernel object, and return the wrapped pointer.
source§

impl Sync for StaticKernelObject<k_condvar>

source§

impl Sync for StaticKernelObject<k_queue>

Auto Trait Implementations§

§

impl<T> !Freeze for StaticKernelObject<T>

§

impl<T> !RefUnwindSafe for StaticKernelObject<T>

§

impl<T> !Send for StaticKernelObject<T>

§

impl<T> !Sync for StaticKernelObject<T>

§

impl<T> Unpin for StaticKernelObject<T>
where T: Unpin,

§

impl<T> UnwindSafe for StaticKernelObject<T>
where T: UnwindSafe,

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> 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<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

source§

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>,

source§

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.