1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// this module is mostly not yet implemented...
#![allow(dead_code)]
use crate::{
    device::{self, CardBusDetails, PciBridgeDetails, StandardDetails},
    register,
};
use volatile::Volatile;

pub struct MemoryMappedDevice<'device> {
    header: Volatile<&'device mut device::Header>,
    details: MmKind<'device>,
}

enum MmKind<'device> {
    Standard(Volatile<&'device mut StandardDetails>),
    CardBusBridge(Volatile<&'device mut CardBusDetails>),
    PciBridge(Volatile<&'device mut PciBridgeDetails>),
}

impl<'device> MemoryMappedDevice<'device> {
    pub fn header(&self) -> device::Header {
        self.header.read()
    }

    pub fn send_command(&mut self, command: register::Command) {
        // suppress unused warning
        let _ = command;
        todo!()
    }
}

#[cfg(test)]
mod tests {
    // use super::Device;
    // use core::mem;

    // #[test]
    // fn device_is_256_bytes() {
    //     assert_eq!(mem::size_of::<Device>(), 256);
    // }
}