(
&mut self,
_allocator: &mut SystemAllocator,
mmio32_allocator: &mut AddressAllocator,
_mmio64_allocator: &mut AddressAllocator,
resources: Option<Vec<Resource
| 173 | } |
| 174 | |
| 175 | fn allocate_bars( |
| 176 | &mut self, |
| 177 | _allocator: &mut SystemAllocator, |
| 178 | mmio32_allocator: &mut AddressAllocator, |
| 179 | _mmio64_allocator: &mut AddressAllocator, |
| 180 | resources: Option<Vec<Resource>>, |
| 181 | ) -> std::result::Result<Vec<PciBarConfiguration>, PciDeviceError> { |
| 182 | let mut bars = Vec::new(); |
| 183 | let region_type = PciBarRegionType::Memory32BitRegion; |
| 184 | let bar_id = 0; |
| 185 | let region_size = PVPANIC_DEVICE_MMIO_SIZE; |
| 186 | let restoring = resources.is_some(); |
| 187 | let bar_addr = mmio32_allocator |
| 188 | .allocate(None, region_size, Some(PVPANIC_DEVICE_MMIO_ALIGNMENT)) |
| 189 | .ok_or(PciDeviceError::IoAllocationFailed(region_size))?; |
| 190 | |
| 191 | let bar = PciBarConfiguration::default() |
| 192 | .set_index(bar_id as usize) |
| 193 | .set_address(bar_addr.raw_value()) |
| 194 | .set_size(region_size) |
| 195 | .set_region_type(region_type) |
| 196 | .set_prefetchable(PciBarPrefetchable::NotPrefetchable); |
| 197 | |
| 198 | debug!("pvpanic bar address 0x{:x}", bar_addr.0); |
| 199 | if !restoring { |
| 200 | self.configuration |
| 201 | .add_pci_bar(&bar) |
| 202 | .map_err(|e| PciDeviceError::IoRegistrationFailed(bar_addr.raw_value(), e))?; |
| 203 | } |
| 204 | |
| 205 | bars.push(bar); |
| 206 | self.bar_regions.clone_from(&bars); |
| 207 | |
| 208 | Ok(bars) |
| 209 | } |
| 210 | |
| 211 | fn free_bars( |
| 212 | &mut self, |
nothing calls this directly
no test coverage detected