add platform dependent implementations

this allows us to get rid of traits. woo!
This commit is contained in:
bunnie 2024-05-02 22:16:55 +08:00
parent b4d1b4e5bb
commit 433cc7dfb7
5 changed files with 43 additions and 0 deletions

View file

@ -0,0 +1,14 @@
/// This is an implementation for SMTs that are accessible only through a SPI
/// register interface. The base and bounds must be translated to SPI accesses
/// in a hardware-specific manner.
pub struct SwapMac {
pub base: usize,
pub bounds: usize,
}
impl SwapMac {
pub fn new(base: usize, bounds: usize) -> Self { SwapMac { base, bounds } }
pub fn lookup_mac(&self, swap_page_offset: usize) -> [u8; 16] { todo!() }
pub fn store_mac(&mut self, swap_page_offset: usize, mac: &[u8; 16]) { todo!() }
}

View file

@ -0,0 +1 @@
pub mod hw;

View file

@ -0,0 +1,9 @@
#[cfg(any(feature = "cramium-soc"))]
pub mod cramium;
#[cfg(any(feature = "cramium-soc"))]
pub use cramium::hw::*;
#[cfg(any(feature = "precursor", feature = "renode"))]
pub mod precursor;
#[cfg(any(feature = "precursor", feature = "renode"))]
pub use precursor::hw::*;

View file

@ -0,0 +1,18 @@
/// This defines a set of functions to get and receive MACs (message
/// authentication codes, also referred to as the tag in AES-GCM-SIV.
pub struct SwapMac {
pub macs: &'static mut [[u8; 16]],
}
impl SwapMac {
pub fn new(base: usize, bounds: usize) -> Self {
SwapMac {
// safety: this is only safe because the loader guarantees memory-mapped SMT is initialized and
// aligned and properly mapped into the swapper's memory space.
macs: unsafe { core::slice::from_raw_parts_mut(base as *mut [u8; 16], bounds as usize / 16) },
}
}
pub fn lookup_mac(&self, swap_page_offset: usize) -> [u8; 16] { todo!() }
pub fn store_mac(&mut self, swap_page_offset: usize, mac: &[u8; 16]) { todo!() }
}

View file

@ -0,0 +1 @@
pub mod hw;