devices, vm-device: Move BusDevice and Bus into vm-device

This removes the dependency of the pci crate on the devices crate which
now only contains the device implementations themselves.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2020-09-09 15:30:31 +01:00
parent f24a12913a
commit 15025d71b1
22 changed files with 56 additions and 95 deletions

View File

@@ -7,11 +7,11 @@ use crate::configuration::{
};
use crate::device::{DeviceRelocation, Error as PciDeviceError, PciDevice};
use byteorder::{ByteOrder, LittleEndian};
use devices::BusDevice;
use std::any::Any;
use std::collections::HashMap;
use std::ops::DerefMut;
use std::sync::{Arc, Mutex};
use vm_device::{Bus, BusDevice};
use vm_memory::{Address, GuestAddress, GuestUsize};
const VENDOR_ID_INTEL: u16 = 0x8086;
@@ -26,9 +26,9 @@ pub enum PciRootError {
/// Could not allocate an IRQ number.
AllocateIrq,
/// Could not add a device to the port io bus.
PioInsert(devices::BusError),
PioInsert(vm_device::BusError),
/// Could not add a device to the mmio bus.
MmioInsert(devices::BusError),
MmioInsert(vm_device::BusError),
/// Could not find an available device slot on the PCI bus.
NoPciDeviceSlotAvailable,
/// Invalid PCI device identifier provided.
@@ -110,8 +110,8 @@ impl PciBus {
pub fn register_mapping(
&self,
dev: Arc<Mutex<dyn BusDevice>>,
#[cfg(target_arch = "x86_64")] io_bus: &devices::Bus,
mmio_bus: &devices::Bus,
#[cfg(target_arch = "x86_64")] io_bus: &Bus,
mmio_bus: &Bus,
bars: Vec<(GuestAddress, GuestUsize, PciBarRegionType)>,
) -> Result<()> {
for (address, size, type_) in bars {

View File

@@ -3,11 +3,11 @@
// found in the LICENSE-BSD-3-Clause file.
use crate::configuration::{self, PciBarRegionType};
use devices::BusDevice;
use std::any::Any;
use std::fmt::{self, Display};
use std::{self, io, result};
use vm_allocator::SystemAllocator;
use vm_device::BusDevice;
use vm_memory::{GuestAddress, GuestUsize};
#[derive(Debug)]

View File

@@ -5,7 +5,6 @@
//! Implements pci devices and busses.
#[macro_use]
extern crate log;
extern crate devices;
extern crate hypervisor;
extern crate serde;
#[macro_use]

View File

@@ -3,7 +3,6 @@
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
//
extern crate devices;
extern crate vm_allocator;
use crate::{
@@ -12,7 +11,6 @@ use crate::{
PciDevice, PciDeviceError, PciHeaderType, PciSubclass, MSIX_TABLE_ENTRY_SIZE,
};
use byteorder::{ByteOrder, LittleEndian};
use devices::BusDevice;
use std::any::Any;
use std::ops::Deref;
use std::os::unix::io::AsRawFd;
@@ -25,6 +23,7 @@ use vm_allocator::SystemAllocator;
use vm_device::interrupt::{
InterruptIndex, InterruptManager, InterruptSourceGroup, MsiIrqGroupConfig,
};
use vm_device::BusDevice;
use vm_memory::{
Address, GuestAddress, GuestAddressSpace, GuestMemoryAtomic, GuestMemoryMmap, GuestRegionMmap,
GuestUsize,