Use safe-mmio crate for PhysicalInstance.
Change-Id: Id34d4ee2f7bc6ce155a0b5c8aec2f808148ef7f0
Signed-off-by: Andrew Walbran <qwandor@google.com>
diff --git a/src/lib.rs b/src/lib.rs
index 5c67eaa..f1d02d9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -7,51 +7,16 @@
#![no_std]
-use core::{
- fmt::{self, Debug, Formatter},
- marker::PhantomData,
-};
+use core::fmt::Debug;
use arm_gic::GICDRegisters;
use arm_pl011_uart::PL011Registers;
use arm_sp805::SP805Registers;
+pub use safe_mmio::PhysicalInstance;
use spin::mutex::Mutex;
static PERIPHERALS_TAKEN: Mutex<bool> = Mutex::new(false);
-/// The physical instance of some device's MMIO space.
-pub struct PhysicalInstance<T> {
- pa: usize,
- _phantom: PhantomData<T>,
-}
-
-impl<T> Debug for PhysicalInstance<T> {
- fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- f.debug_struct("PhysicalInstance")
- .field("pa", &self.pa)
- .field("size", &size_of::<T>())
- .finish()
- }
-}
-
-impl<T> PhysicalInstance<T> {
- /// # Safety
- ///
- /// This must refer to the physical address of a real set of device registers of type `T`, and
- /// there must only ever be a single `PhysicalInstance` for those device registers.
- pub unsafe fn new(pa: usize) -> Self {
- Self {
- pa,
- _phantom: PhantomData,
- }
- }
-
- /// Returns the physical base address of the device's registers.
- pub fn pa(&self) -> usize {
- self.pa
- }
-}
-
/// FVP peripherals
#[derive(Debug)]
pub struct Peripherals {