use machina_core::address::GPA;
use machina_memory::region::MemoryRegion;
use crate::qdev::Device;
pub trait BusDevice: Device {
fn read(&self, offset: u64, size: u32) -> u64;
fn write(&mut self, offset: u64, size: u32, val: u64);
}
pub struct SysBusMapping {
pub region: MemoryRegion,
pub base: GPA,
}
pub struct SysBus {
pub name: String,
mappings: Vec<SysBusMapping>,
}
impl SysBus {
pub fn new(name: &str) -> Self {
Self {
name: name.to_string(),
mappings: Vec::new(),
}
}
pub fn add_mapping(&mut self, region: MemoryRegion, base: GPA) {
self.mappings.push(SysBusMapping { region, base });
}
pub fn mappings(&self) -> &[SysBusMapping] {
&self.mappings
}
}