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

Method allocate_bars

devices/src/pvmemcontrol.rs:727–759  ·  view source on GitHub ↗
(
        &mut self,
        _allocator: &mut SystemAllocator,
        mmio32_allocator: &mut AddressAllocator,
        _mmio64_allocator: &mut AddressAllocator,
        resources: Option<Vec<Resource

Source from the content-addressed store, hash-verified

725 }
726
727 fn allocate_bars(
728 &mut self,
729 _allocator: &mut SystemAllocator,
730 mmio32_allocator: &mut AddressAllocator,
731 _mmio64_allocator: &mut AddressAllocator,
732 resources: Option<Vec<Resource>>,
733 ) -> Result<Vec<PciBarConfiguration>, PciDeviceError> {
734 let mut bars = Vec::new();
735 let region_type = PciBarRegionType::Memory32BitRegion;
736 let bar_id = 0;
737 let region_size = PVMEMCONTROL_DEVICE_MMIO_SIZE;
738 let restoring = resources.is_some();
739 let bar_addr = mmio32_allocator
740 .allocate(None, region_size, Some(PVMEMCONTROL_DEVICE_MMIO_ALIGN))
741 .ok_or(PciDeviceError::IoAllocationFailed(region_size))?;
742
743 let bar = PciBarConfiguration::default()
744 .set_index(bar_id as usize)
745 .set_address(bar_addr.raw_value())
746 .set_size(region_size)
747 .set_region_type(region_type)
748 .set_prefetchable(PciBarPrefetchable::NotPrefetchable);
749
750 if !restoring {
751 self.configuration
752 .add_pci_bar(&bar)
753 .map_err(|e| PciDeviceError::IoRegistrationFailed(bar_addr.raw_value(), e))?;
754 }
755
756 bars.push(bar);
757 self.bar_regions.clone_from(&bars);
758 Ok(bars)
759 }
760
761 fn free_bars(
762 &mut self,

Callers

nothing calls this directly

Calls 9

newFunction · 0.85
allocateMethod · 0.80
set_prefetchableMethod · 0.80
set_region_typeMethod · 0.80
set_sizeMethod · 0.80
set_addressMethod · 0.80
set_indexMethod · 0.80
add_pci_barMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected