MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / register_mapping

Method register_mapping

pci/src/bus.rs:148–170  ·  view source on GitHub ↗
(
        &self,
        dev: Arc<dyn BusDeviceSync>,
        io_bus: &Bus,
        mmio_bus: &Bus,
        bars: Vec<PciBarConfiguration>,
    )

Source from the content-addressed store, hash-verified

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);

Callers 1

add_pci_deviceMethod · 0.80

Calls 5

region_typeMethod · 0.80
insertMethod · 0.45
cloneMethod · 0.45
addrMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected