Skip to content

Commit 4fae63b

Browse files
committed
doc(core): document r3::kernel::raw_cfg
1 parent 0d6a2e0 commit 4fae63b

File tree

1 file changed

+127
-7
lines changed

1 file changed

+127
-7
lines changed

src/r3_core/src/kernel/raw_cfg.rs

Lines changed: 127 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
//!
44
//! # General Structure
55
//!
6-
//! TODO
6+
//! This module includes the traits for a kernel-specific low-level configurator
7+
//! type, which is used by [the kernel static configuration process][1] to
8+
//! receive the specificiations of defined kernel objects and assign their IDs.
9+
//! [`CfgBase`][] is the supertrait of all these traits and must be implemented
10+
//! by the configurator type. It can optionally can implement other traits as
11+
//! well if they can be supported.
712
//!
8-
//! The `Cfg${TY}` traits extend [`CfgBase`] by providing a
9-
//! method to define a kernel object of the corresponding type (`${TY}`). The
10-
//! method takes two parameters: `${TY}Descriptor` containing mandatory
11-
//! properties and `impl `[`Bag`] containing additional, implementation-specific
12-
//! properties.
13+
//! The `Cfg${Ty}` traits extend [`CfgBase`] by providing a
14+
//! method named `${ty}_define` to define a kernel object of the corresponding
15+
//! type (`${Ty}`). The method takes two parameters: `${Ty}Descriptor`
16+
//! containing mandatory properties and `impl `[`Bag`] containing additional,
17+
//! implementation-specific properties.
1318
//!
14-
//! The `${TY}Descriptor` types contain mandatory (both for the consumers and
19+
//! The `${Ty}Descriptor` types contain mandatory (both for the consumers and
1520
//! the implementors) properties of a kernel object to be created. They all
1621
//! contain a `phantom: `[`PhantomInvariant`]`<System>` field to ensure they are
1722
//! always parameterized and invariant over `System`.
@@ -21,8 +26,33 @@
2126
//! Most traits in this method are `unsafe trait` because they have to be
2227
//! trustworthy to be able to build sound memory-safe abstractions on top of
2328
//! them.
29+
//!
30+
//! # Stability
31+
//!
32+
//! This module is covered by the kernel-side API stability guarantee.
33+
//!
34+
//! The trait paths in this module are covered by the application-side API
35+
//! stability guarantee. Application code should only use these traits in trait
36+
//! bounds and, to access the provided functionalities, should use the the
37+
//! stable wrapper [outside this module](../index.html) instead.
38+
//!
39+
//! [1]: crate::kernel::cfg::KernelStatic
2440
use crate::{bag::Bag, closure::Closure, kernel::raw, time::Duration, utils::PhantomInvariant};
2541

42+
/// The trait for all kernel-specific low-level configurator types, used by
43+
/// [the kernel static configuration process][2].
44+
///
45+
/// # Safety
46+
///
47+
/// See [the module documentation][4].
48+
///
49+
/// # Stability
50+
///
51+
/// See [the module documentation][3].
52+
///
53+
/// [2]: crate::kernel::cfg::KernelStatic
54+
/// [3]: self#stability
55+
/// [4]: self#safety
2656
pub unsafe trait CfgBase {
2757
type System: raw::KernelBase;
2858
fn num_task_priority_levels(&mut self, new_value: usize);
@@ -35,6 +65,21 @@ pub unsafe trait CfgBase {
3565
fn startup_hook_define(&mut self, func: fn());
3666
}
3767

68+
/// A low-level configurator trait providing a method to define a
69+
/// [task][1] in [the kernel static configuration process][2].
70+
///
71+
/// # Safety
72+
///
73+
/// See [the module documentation][4].
74+
///
75+
/// # Stability
76+
///
77+
/// See [the module documentation][3].
78+
///
79+
/// [1]: crate::kernel::StaticTask
80+
/// [2]: crate::kernel::cfg::KernelStatic
81+
/// [3]: self#stability
82+
/// [4]: self#safety
3883
// The supertrait can't be `~const` due to [ref:const_supertraits]
3984
pub unsafe trait CfgTask: CfgBase {
4085
fn task_define<Properties: ~const Bag>(
@@ -54,6 +99,21 @@ pub struct TaskDescriptor<System> {
5499
pub stack_size: Option<usize>,
55100
}
56101

102+
/// A low-level configurator trait providing a method to define an
103+
/// [event group][2] in [the kernel static configuration process][1].
104+
///
105+
/// # Safety
106+
///
107+
/// See [the module documentation][4].
108+
///
109+
/// # Stability
110+
///
111+
/// See [the module documentation][3].
112+
///
113+
/// [1]: crate::kernel::StaticEventGroup
114+
/// [2]: crate::kernel::cfg::KernelStatic
115+
/// [3]: self#stability
116+
/// [4]: self#safety
57117
// The supertrait can't be `~const` due to [ref:const_supertraits]
58118
pub unsafe trait CfgEventGroup: CfgBase
59119
where
@@ -74,6 +134,21 @@ pub struct EventGroupDescriptor<System> {
74134
pub queue_order: raw::QueueOrder,
75135
}
76136

137+
/// A low-level configurator trait providing a method to define a
138+
/// [mutex][2] in [the kernel static configuration process][1].
139+
///
140+
/// # Safety
141+
///
142+
/// See [the module documentation][4].
143+
///
144+
/// # Stability
145+
///
146+
/// See [the module documentation][3].
147+
///
148+
/// [1]: crate::kernel::StaticMutex
149+
/// [2]: crate::kernel::cfg::KernelStatic
150+
/// [3]: self#stability
151+
/// [4]: self#safety
77152
// The supertrait can't be `~const` due to [ref:const_supertraits]
78153
pub unsafe trait CfgMutex: CfgBase
79154
where
@@ -93,6 +168,21 @@ pub struct MutexDescriptor<System> {
93168
pub protocol: raw::MutexProtocol,
94169
}
95170

171+
/// A low-level configurator trait providing a method to define a
172+
/// [semaphore][2] in [the kernel static configuration process][1].
173+
///
174+
/// # Safety
175+
///
176+
/// See [the module documentation][4].
177+
///
178+
/// # Stability
179+
///
180+
/// See [the module documentation][3].
181+
///
182+
/// [1]: crate::kernel::StaticSemaphore
183+
/// [2]: crate::kernel::cfg::KernelStatic
184+
/// [3]: self#stability
185+
/// [4]: self#safety
96186
// The supertrait can't be `~const` due to [ref:const_supertraits]
97187
pub unsafe trait CfgSemaphore: CfgBase
98188
where
@@ -114,6 +204,21 @@ pub struct SemaphoreDescriptor<System> {
114204
pub queue_order: raw::QueueOrder,
115205
}
116206

207+
/// A low-level configurator trait providing a method to define a
208+
/// [timwer][2] in [the kernel static configuration process][1].
209+
///
210+
/// # Safety
211+
///
212+
/// See [the module documentation][4].
213+
///
214+
/// # Stability
215+
///
216+
/// See [the module documentation][3].
217+
///
218+
/// [1]: crate::kernel::StaticTimer
219+
/// [2]: crate::kernel::cfg::KernelStatic
220+
/// [3]: self#stability
221+
/// [4]: self#safety
117222
// The supertrait can't be `~const` due to [ref:const_supertraits]
118223
pub unsafe trait CfgTimer: CfgBase
119224
where
@@ -136,6 +241,21 @@ pub struct TimerDescriptor<System> {
136241
pub period: Option<Duration>,
137242
}
138243

244+
/// A low-level configurator trait providing a method to define an
245+
/// [interrupt line][2] in [the kernel static configuration process][1].
246+
///
247+
/// # Safety
248+
///
249+
/// See [the module documentation][4].
250+
///
251+
/// # Stability
252+
///
253+
/// See [the module documentation][3].
254+
///
255+
/// [1]: crate::kernel::InterruptLine
256+
/// [2]: crate::kernel::cfg::KernelStatic
257+
/// [3]: self#stability
258+
/// [4]: self#safety
139259
// The supertrait can't be `~const` due to [ref:const_supertraits]
140260
pub unsafe trait CfgInterruptLine: CfgBase
141261
where

0 commit comments

Comments
 (0)