hardware 0.0.7

A no_std bare-metal hardware abstraction layer — all port I/O, memory and swap allocations are guarded at runtime. Do not consider this dependency stable before x.1.x
Documentation
use crate::gpu::GpuDevice;

pub struct Device {
    pub info: GpuDevice,
    pub mmio_base: Option<usize>,
}

impl Device {
    pub fn new(info: GpuDevice) -> Self {
        let mmio_base = if info.bar0 != 0 {
            Some(info.bar0 as usize)
        } else {
            None
        };
        Device { info, mmio_base }
    }

    pub fn read_mmio32(&self, off: usize) -> Option<u32> {
        if let Some(base) = self.mmio_base {
            crate::hardware_access::mmio_read32(base + off)
        } else {
            None
        }
    }

    pub fn write_mmio32(&self, off: usize, val: u32) -> bool {
        if let Some(base) = self.mmio_base {
            crate::hardware_access::mmio_write32(base + off, val)
        } else {
            false
        }
    }

    pub fn bar0_base(&self) -> Option<usize> {
        self.mmio_base
    }

    pub fn gpu_clock_mhz(&self) -> u64 {
        0
    }

    pub fn gpu_temp_millideg(&self) -> u32 {
        0
    }

    pub fn power_state(&self) -> u64 {
        0
    }
}