(
&self,
dev: Arc<dyn BusDeviceSync>,
io_bus: &Bus,
mmio_bus: &Bus,
bars: Vec<PciBarConfiguration>,
)
| 146 | |
| 147 | #[allow(clippy::needless_pass_by_value)] |
| 148 | pub fn register_mapping( |
| 149 | &self, |
| 150 | dev: Arc<dyn BusDeviceSync>, |
| 151 | io_bus: &Bus, |
| 152 | mmio_bus: &Bus, |
| 153 | bars: Vec<PciBarConfiguration>, |
| 154 | ) -> Result<()> { |
| 155 | for bar in bars { |
| 156 | match bar.region_type() { |
| 157 | PciBarRegionType::IoRegion => { |
| 158 | io_bus |
| 159 | .insert(dev.clone(), bar.addr(), bar.size()) |
| 160 | .map_err(PciRootError::PioInsert)?; |
| 161 | } |
| 162 | PciBarRegionType::Memory32BitRegion | PciBarRegionType::Memory64BitRegion => { |
| 163 | mmio_bus |
| 164 | .insert(dev.clone(), bar.addr(), bar.size()) |
| 165 | .map_err(PciRootError::MmioInsert)?; |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | Ok(()) |
| 170 | } |
| 171 | |
| 172 | pub fn add_device(&mut self, device_id: u8, device: Arc<Mutex<dyn PciDevice>>) -> Result<()> { |
| 173 | self.devices.insert(device_id, device); |
no test coverage detected