|
@@ -115,6 +115,7 @@ impl PciTransport {
|
|
|
/// - `device` - The PCI device structure for the VirtIO device.
|
|
|
/// - `irq_handler` - An optional handler for the device's interrupt. If `None`, a default
|
|
|
/// handler `DefaultVirtioIrqHandler` will be used.
|
|
|
+ /// - `irq_number_offset` - Currently, this parameter is just simple make a offset to the irq number, cause it's not be allowed to have the same irq number within different device
|
|
|
#[allow(clippy::extra_unused_type_parameters)]
|
|
|
pub fn new<H: Hal>(
|
|
|
device: &mut PciDeviceStructureGeneralDevice,
|
|
@@ -140,8 +141,8 @@ impl PciTransport {
|
|
|
let irq_vector = standard_device.irq_vector_mut().unwrap();
|
|
|
irq_vector.push(irq);
|
|
|
standard_device
|
|
|
- .irq_init(IRQ::PCI_IRQ_MSIX)
|
|
|
- .expect("IRQ init failed");
|
|
|
+ .irq_init(IRQ::PCI_IRQ_MSIX | IRQ::PCI_IRQ_MSI)
|
|
|
+ .ok_or(VirtioPciError::UnableToInitIrq)?;
|
|
|
// 中断相关信息
|
|
|
let msg = PciIrqMsg {
|
|
|
irq_common_message: IrqCommonMsg::init_from(
|
|
@@ -445,6 +446,8 @@ pub enum VirtioPciError {
|
|
|
/// `VIRTIO_PCI_CAP_NOTIFY_CFG` capability has a `notify_off_multiplier` that is not a multiple
|
|
|
/// of 2.
|
|
|
InvalidNotifyOffMultiplier(u32),
|
|
|
+ /// Unable to find capability such as MSIX or MSI.
|
|
|
+ UnableToInitIrq,
|
|
|
/// No valid `VIRTIO_PCI_CAP_ISR_CFG` capability was found.
|
|
|
MissingIsrConfig,
|
|
|
/// An IO BAR was provided rather than a memory BAR.
|
|
@@ -474,6 +477,7 @@ impl Display for VirtioPciError {
|
|
|
"PCI device vender ID {:#06x} was not the VirtIO vendor ID {:#06x}.",
|
|
|
vendor_id, VIRTIO_VENDOR_ID
|
|
|
),
|
|
|
+ Self::UnableToInitIrq => write!(f, "Unable to find capability such as MSIX or MSI."),
|
|
|
Self::MissingCommonConfig => write!(
|
|
|
f,
|
|
|
"No valid `VIRTIO_PCI_CAP_COMMON_CFG` capability was found."
|