|
2 | 2 | // SPDX-License-Identifier: Apache-2.0 OR MIT |
3 | 3 | // Copyright Tock Contributors 2022. |
4 | 4 |
|
5 | | -use core::cell::Cell; |
6 | 5 | use core::fmt; |
7 | | -use core::num::NonZeroUsize; |
8 | 6 |
|
9 | 7 | use kernel::memory_management::pages::Page4KiB; |
10 | 8 | use kernel::memory_management::permissions::Permissions; |
11 | 9 | use kernel::memory_management::regions::PhysicalProtectedAllocatedRegion; |
12 | 10 | use kernel::platform::mmu::Asid; |
13 | | -use kernel::utilities::cells::{MapCell, OptionalCell}; |
| 11 | +use kernel::utilities::cells::MapCell; |
14 | 12 | use kernel::utilities::registers::{register_bitfields, LocalRegisterCopy}; |
15 | 13 |
|
16 | 14 | use crate::csr; |
@@ -763,60 +761,6 @@ pub trait TORUserPMP<const MAX_REGIONS: usize> { |
763 | 761 | fn disable_user_pmp(&self); |
764 | 762 | } |
765 | 763 |
|
766 | | -/// Struct storing userspace memory protection regions for the [`PMPUserMPU`]. |
767 | | -pub struct PMPUserMPUConfig<const MAX_REGIONS: usize> { |
768 | | - /// PMP config identifier, as generated by the issuing PMP implementation. |
769 | | - id: NonZeroUsize, |
770 | | - /// Indicates if the configuration has changed since the last time it was |
771 | | - /// written to hardware. |
772 | | - is_dirty: Cell<bool>, |
773 | | - /// Array of MPU regions. Each region requires two physical PMP entries. |
774 | | - regions: [(TORUserPMPCFG, *const u8, *const u8); MAX_REGIONS], |
775 | | - /// Which region index (into the `regions` array above) is used |
776 | | - /// for app memory (if it has been configured). |
777 | | - app_memory_region: OptionalCell<usize>, |
778 | | -} |
779 | | - |
780 | | -impl<const MAX_REGIONS: usize> fmt::Display for PMPUserMPUConfig<MAX_REGIONS> { |
781 | | - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
782 | | - // Ternary operator shortcut function, to avoid bulky formatting... |
783 | | - fn t<T>(cond: bool, a: T, b: T) -> T { |
784 | | - if cond { |
785 | | - a |
786 | | - } else { |
787 | | - b |
788 | | - } |
789 | | - } |
790 | | - |
791 | | - write!( |
792 | | - f, |
793 | | - " PMPUserMPUConfig {{\r\n id: {},\r\n is_dirty: {},\r\n app_memory_region: {:?},\r\n regions:\r\n", |
794 | | - self.id, |
795 | | - self.is_dirty.get(), |
796 | | - self.app_memory_region.get() |
797 | | - )?; |
798 | | - |
799 | | - for (i, (tor_user_pmpcfg, start, end)) in self.regions.iter().enumerate() { |
800 | | - let pmpcfg = tor_user_pmpcfg.get_reg(); |
801 | | - write!( |
802 | | - f, |
803 | | - " #{:02}: start={:#010X}, end={:#010X}, cfg={:#04X} ({}) (-{}{}{})\r\n", |
804 | | - i, |
805 | | - *start as usize, |
806 | | - *end as usize, |
807 | | - pmpcfg.get(), |
808 | | - t(pmpcfg.is_set(pmpcfg_octet::a), "TOR", "OFF"), |
809 | | - t(pmpcfg.is_set(pmpcfg_octet::r), "r", "-"), |
810 | | - t(pmpcfg.is_set(pmpcfg_octet::w), "w", "-"), |
811 | | - t(pmpcfg.is_set(pmpcfg_octet::x), "x", "-"), |
812 | | - )?; |
813 | | - } |
814 | | - |
815 | | - write!(f, " }}\r\n")?; |
816 | | - Ok(()) |
817 | | - } |
818 | | -} |
819 | | - |
820 | 764 | /// Adapter from a generic PMP implementation exposing TOR-type regions to the |
821 | 765 | /// Tock [`mpu::MPU`] trait. See [`TORUserPMP`]. |
822 | 766 | pub struct PMPUserMPU<const MAX_REGIONS: usize, P: TORUserPMP<MAX_REGIONS> + 'static> { |
|
0 commit comments