|
1 | 1 | //! Kernel configuration
|
2 | 2 | use crate::{
|
3 | 3 | kernel::{hook, interrupt, raw, raw_cfg},
|
4 |
| - utils::{ComptimeVec, ConstAllocator, Init, PhantomInvariant}, |
| 4 | + utils::{ComptimeVec, ConstAllocator, Frozen, Init, PhantomInvariant}, |
5 | 5 | };
|
6 | 6 |
|
7 | 7 | macro overview_ref() {
|
@@ -29,15 +29,15 @@ enum CfgSt {
|
29 | 29 |
|
30 | 30 | impl<'c, C: raw_cfg::CfgBase> Cfg<'c, C> {
|
31 | 31 | /// Construct `Cfg`.
|
32 |
| - const fn new(raw: &'c mut C, _allocator: &'c ConstAllocator, st: CfgSt) -> Self { |
| 32 | + const fn new(raw: &'c mut C, allocator: &'c ConstAllocator, st: CfgSt) -> Self { |
33 | 33 | Self {
|
34 | 34 | raw,
|
35 | 35 | st,
|
36 |
| - startup_hooks: ComptimeVec::new(), |
| 36 | + startup_hooks: ComptimeVec::new_in(allocator.clone()), |
37 | 37 | hunk_pool_len: 0,
|
38 | 38 | hunk_pool_align: 1,
|
39 |
| - interrupt_lines: ComptimeVec::new(), |
40 |
| - interrupt_handlers: ComptimeVec::new(), |
| 39 | + interrupt_lines: ComptimeVec::new_in(allocator.clone()), |
| 40 | + interrupt_handlers: ComptimeVec::new_in(allocator.clone()), |
41 | 41 | }
|
42 | 42 | }
|
43 | 43 |
|
@@ -116,10 +116,12 @@ impl<'c, C: raw_cfg::CfgBase> Cfg<'c, C> {
|
116 | 116 |
|
117 | 117 | CfgPhase1Data {
|
118 | 118 | _phantom: Init::INIT,
|
119 |
| - startup_hooks: self.startup_hooks.map(hook::CfgStartupHook::to_attr), |
| 119 | + startup_hooks: Frozen::leak_slice( |
| 120 | + &self.startup_hooks.map(hook::CfgStartupHook::to_attr), |
| 121 | + ), |
120 | 122 | hunk_pool_len: self.hunk_pool_len,
|
121 | 123 | hunk_pool_align: self.hunk_pool_align,
|
122 |
| - interrupt_handlers: self.interrupt_handlers, |
| 124 | + interrupt_handlers: Frozen::leak_slice(&self.interrupt_handlers), |
123 | 125 | }
|
124 | 126 | }
|
125 | 127 |
|
@@ -198,8 +200,8 @@ impl<'c, C: raw_cfg::CfgBase> Cfg<'c, C> {
|
198 | 200 |
|
199 | 201 | // Clear these fields to indicate that this method has been called
|
200 | 202 | // as required
|
201 |
| - self.interrupt_lines = ComptimeVec::new(); |
202 |
| - self.interrupt_handlers = ComptimeVec::new(); |
| 203 | + self.interrupt_lines.clear(); |
| 204 | + self.interrupt_handlers.clear(); |
203 | 205 | }
|
204 | 206 |
|
205 | 207 | /// Finalize `self` for the phase 3 configuration.
|
@@ -250,10 +252,10 @@ impl<'c, C: raw_cfg::CfgBase> Cfg<'c, C> {
|
250 | 252 | #[doc = overview_ref!()]
|
251 | 253 | pub struct CfgPhase1Data<System> {
|
252 | 254 | _phantom: PhantomInvariant<System>,
|
253 |
| - pub startup_hooks: ComptimeVec<hook::StartupHookAttr>, |
| 255 | + pub startup_hooks: &'static [Frozen<hook::StartupHookAttr>], |
254 | 256 | pub hunk_pool_len: usize,
|
255 | 257 | pub hunk_pool_align: usize,
|
256 |
| - pub interrupt_handlers: ComptimeVec<interrupt::CfgInterruptHandler>, |
| 258 | + pub interrupt_handlers: &'static [Frozen<interrupt::CfgInterruptHandler>], |
257 | 259 | }
|
258 | 260 |
|
259 | 261 | /// The inputs to [`attach_phase2!`].
|
@@ -619,13 +621,15 @@ pub macro attach_phase1($params:expr, impl CfgPhase1<$System:ty> for $Ty:ty $(,)
|
619 | 621 | array_item_from_fn! {
|
620 | 622 | const STARTUP_HOOKS: [hook::StartupHookAttr; _] =
|
621 | 623 | (0..STATIC_PARAMS.startup_hooks.len())
|
622 |
| - .map(|i| STATIC_PARAMS.startup_hooks[i]); |
| 624 | + .map(|i| STATIC_PARAMS.startup_hooks[i].get()); |
623 | 625 | }
|
624 | 626 |
|
625 | 627 | // Consturct a table of combined second-level interrupt handlers
|
626 |
| - const INTERRUPT_HANDLERS: [interrupt::CfgInterruptHandler; { |
627 |
| - STATIC_PARAMS.interrupt_handlers.len() |
628 |
| - }] = STATIC_PARAMS.interrupt_handlers.to_array(); |
| 628 | + array_item_from_fn! { |
| 629 | + const INTERRUPT_HANDLERS: [interrupt::CfgInterruptHandler; _] = |
| 630 | + (0..STATIC_PARAMS.interrupt_handlers.len()) |
| 631 | + .map(|i| STATIC_PARAMS.interrupt_handlers[i].get()); |
| 632 | + } |
629 | 633 | const NUM_INTERRUPT_HANDLERS: usize = INTERRUPT_HANDLERS.len();
|
630 | 634 | const NUM_INTERRUPT_LINES: usize =
|
631 | 635 | interrupt::num_required_interrupt_line_slots(&INTERRUPT_HANDLERS);
|
|
0 commit comments