components/storage_permissions/
null.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 2024.
4
5//! Component for creating a storage permissions policy that provides no storage
6//! permissions.
7
8use core::mem::MaybeUninit;
9use kernel::component::Component;
10use kernel::platform::chip::Chip;
11use kernel::process::ProcessStandardDebug;
12
13#[macro_export]
14macro_rules! storage_permissions_null_component_static {
15    ($C:ty, $D:ty $(,)?) => {{
16        kernel::static_buf!(capsules_system::storage_permissions::null::NullStoragePermissions<$C, $D>)
17    };};
18}
19
20pub type StoragePermissionsNullComponentType<C, D> =
21    capsules_system::storage_permissions::null::NullStoragePermissions<C, D>;
22
23pub struct StoragePermissionsNullComponent<C: Chip, D: ProcessStandardDebug> {
24    _chip: core::marker::PhantomData<C>,
25    _debug: core::marker::PhantomData<D>,
26}
27
28impl<C: Chip, D: ProcessStandardDebug> StoragePermissionsNullComponent<C, D> {
29    pub fn new() -> Self {
30        Self {
31            _chip: core::marker::PhantomData,
32            _debug: core::marker::PhantomData,
33        }
34    }
35}
36
37impl<C: Chip + 'static, D: ProcessStandardDebug + 'static> Component
38    for StoragePermissionsNullComponent<C, D>
39{
40    type StaticInput = &'static mut MaybeUninit<
41        capsules_system::storage_permissions::null::NullStoragePermissions<C, D>,
42    >;
43    type Output = &'static capsules_system::storage_permissions::null::NullStoragePermissions<C, D>;
44
45    fn finalize(self, s: Self::StaticInput) -> Self::Output {
46        s.write(capsules_system::storage_permissions::null::NullStoragePermissions::new())
47    }
48}