use inspect::Inspect;
use thiserror::Error;
#[derive(Debug, Copy, Clone, PartialEq, Eq, Inspect)]
pub struct MsiAddressData {
#[inspect(hex)]
pub address: u64,
#[inspect(hex)]
pub data: u32,
}
pub struct VpciInterruptParameters<'a> {
pub vector: u32,
pub multicast: bool,
pub target_processors: &'a [u32],
}
pub trait VpciInterruptMapper: Send + Sync {
fn register_interrupt(
&self,
vector_count: u32,
params: &VpciInterruptParameters<'_>,
) -> Result<MsiAddressData, RegisterInterruptError>;
fn unregister_interrupt(&self, address: u64, data: u32);
}
#[derive(Debug, Error)]
#[error("failed to register an interrupt")]
pub struct RegisterInterruptError(#[source] Box<dyn std::error::Error + Send + Sync>);
impl RegisterInterruptError {
pub fn new(err: impl Into<Box<dyn std::error::Error + Send + Sync>>) -> Self {
Self(err.into())
}
}