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>where
StaticKernelObject<T>: Wrapped,
impl<T> StaticKernelObject<T>where
StaticKernelObject<T>: Wrapped,
sourcepub const unsafe fn new() -> StaticKernelObject<T>
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.
sourcepub fn init_once(
&self,
args: <Self as Wrapped>::I,
) -> Option<<Self as Wrapped>::T>
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>
impl Wrapped for StaticKernelObject<k_mutex>
source§impl Wrapped for StaticKernelObject<k_queue>
impl Wrapped for StaticKernelObject<k_queue>
source§type T = Queue
type T = Queue
init_once()
on the StaticKernelObject will return after
initialization.source§type I = ()
type I = ()
source§fn get_wrapped(&self, _arg: Self::I) -> Queue
fn get_wrapped(&self, _arg: Self::I) -> Queue
source§impl Wrapped for StaticKernelObject<k_sem>
impl Wrapped for StaticKernelObject<k_sem>
source§type I = (u32, u32)
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
type T = Semaphore
init_once()
on the StaticKernelObject will return after
initialization.source§fn get_wrapped(&self, arg: Self::I) -> Semaphore
fn get_wrapped(&self, arg: Self::I) -> Semaphore
source§impl Wrapped for StaticKernelObject<k_thread>
impl Wrapped for StaticKernelObject<k_thread>
source§type T = Thread
type T = Thread
init_once()
on the StaticKernelObject will return after
initialization.