Skip to content

Commit 4cee279

Browse files
arch/riscv/pmp: Removed unnecessary PMPUserMPUConfig
Signed-off-by: Ioan-Cristian CÎRSTEA <ioan.cirstea@oxidos.io>
1 parent 614e9b0 commit 4cee279

1 file changed

Lines changed: 1 addition & 57 deletions

File tree

arch/riscv/src/pmp.rs

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33
// Copyright Tock Contributors 2022.
44

5-
use core::cell::Cell;
65
use core::fmt;
7-
use core::num::NonZeroUsize;
86

97
use kernel::memory_management::pages::Page4KiB;
108
use kernel::memory_management::permissions::Permissions;
119
use kernel::memory_management::regions::PhysicalProtectedAllocatedRegion;
1210
use kernel::platform::mmu::Asid;
13-
use kernel::utilities::cells::{MapCell, OptionalCell};
11+
use kernel::utilities::cells::MapCell;
1412
use kernel::utilities::registers::{register_bitfields, LocalRegisterCopy};
1513

1614
use crate::csr;
@@ -763,60 +761,6 @@ pub trait TORUserPMP<const MAX_REGIONS: usize> {
763761
fn disable_user_pmp(&self);
764762
}
765763

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-
820764
/// Adapter from a generic PMP implementation exposing TOR-type regions to the
821765
/// Tock [`mpu::MPU`] trait. See [`TORUserPMP`].
822766
pub struct PMPUserMPU<const MAX_REGIONS: usize, P: TORUserPMP<MAX_REGIONS> + 'static> {

0 commit comments

Comments
 (0)