components/
process_array.rs

1// Licensed under the Apache License, Version 2.0 or the MIT License.
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3// Copyright Tock Contributors 2025.
4
5//! Component for the array of process references used by the kernel.
6
7use core::mem::MaybeUninit;
8use kernel::component::Component;
9
10#[macro_export]
11macro_rules! process_array_component_static {
12    ($NUM_PROCS:ty $(,)?) => {{
13        kernel::static_buf!(kernel::process::ProcessArray<$NUM_PROCS>)
14    };};
15}
16
17pub struct ProcessArrayComponent<const NUM_PROCS: usize> {}
18
19impl<const NUM_PROCS: usize> ProcessArrayComponent<NUM_PROCS> {
20    pub fn new() -> Self {
21        Self {}
22    }
23}
24
25impl<const NUM_PROCS: usize> Component for ProcessArrayComponent<NUM_PROCS> {
26    type StaticInput = &'static mut MaybeUninit<kernel::process::ProcessArray<NUM_PROCS>>;
27    type Output = &'static kernel::process::ProcessArray<NUM_PROCS>;
28
29    fn finalize(self, static_buffer: Self::StaticInput) -> Self::Output {
30        static_buffer.write(kernel::process::ProcessArray::new())
31    }
32}