(
&mut self,
_allocator: &mut SystemAllocator,
mmio32_allocator: &mut AddressAllocator,
_mmio64_allocator: &mut AddressAllocator,
resources: Option<Vec<Resource
| 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, |
nothing calls this directly
no test coverage detected