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.
§Safety
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_thread>
impl Wrapped for StaticKernelObject<k_thread>
Source§type T = Thread
type T = Thread
init_once()
on the StaticKernelObject will return after
initialization.Source§type I = ThreadStack
type I = ThreadStack
Source§fn get_wrapped(&self, stack: Self::I) -> Self::T
fn get_wrapped(&self, stack: Self::I) -> Self::T
Source§impl Wrapped for StaticKernelObject<k_timer>
impl Wrapped for StaticKernelObject<k_timer>
Source§type T = StoppedTimer
type T = StoppedTimer
init_once()
on the StaticKernelObject will return after
initialization.