Files
cloud-hypervisor/vm-device/src/lib.rs
Songqian Li bd17c84d3c virtio-devices: move userspace mapping to vm-device
Move UserspaceMapping to vm-device to avoid redefinition since
UserspaceMapping is used by both `virtio-devices` and `device`
crate.

Signed-off-by: Songqian Li <sionli@tencent.com>
2025-08-14 22:14:34 +00:00

71 lines
1.5 KiB
Rust

// Copyright © 2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
use serde::{Deserialize, Serialize};
use vm_memory::{GuestAddress, GuestUsize};
mod bus;
pub mod dma_mapping;
pub mod interrupt;
pub use self::bus::{Bus, BusDevice, BusDeviceSync, Error as BusError};
/// Type of Message Signalled Interrupt
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum MsiIrqType {
/// PCI MSI IRQ numbers.
PciMsi,
/// PCI MSIx IRQ numbers.
PciMsix,
/// Generic MSI IRQ numbers.
GenericMsi,
}
#[derive(Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
pub enum PciBarType {
Io,
Mmio32,
Mmio64,
}
/// Enumeration for device resources.
#[allow(missing_docs)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum Resource {
/// IO Port address range.
PioAddressRange { base: u16, size: u16 },
/// Memory Mapped IO address range.
MmioAddressRange { base: u64, size: u64 },
/// PCI BAR
PciBar {
index: usize,
base: u64,
size: u64,
type_: PciBarType,
prefetchable: bool,
},
/// Legacy IRQ number.
LegacyIrq(u32),
/// Message Signaled Interrupt
MsiIrq {
ty: MsiIrqType,
base: u32,
size: u32,
},
/// Network Interface Card MAC address.
MacAddress(String),
/// KVM memslot index.
KvmMemSlot(u32),
}
#[derive(Clone)]
pub struct UserspaceMapping {
pub host_addr: u64,
pub mem_slot: u32,
pub addr: GuestAddress,
pub len: GuestUsize,
pub mergeable: bool,
}