Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions src/drivers/pci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,31 @@ impl<T: ConfigRegionAccess> PciDevice<T> {

pub fn get_irq(&self) -> Option<InterruptLine> {
let header = self.header();
if let Some(endpoint) = EndpointHeader::from_header(header, &self.access) {
let (_pin, line) = endpoint.interrupt(&self.access);
Some(line)
} else {
None
let endpoint = EndpointHeader::from_header(header, &self.access)?;
let (pin, line) = endpoint.interrupt(&self.access);
// PCIe specification v5 section 7.5.1.1.13 (Interrupt Pin Register)
match pin {
0 => {
warn!("The function uses no legacy interrupt message(s).");
None
}
1..=4 => {
// PCI specification v3 footnote 43
#[cfg(target_arch = "x86_64")]
if matches!(line, 16..254) {
warn!("Reserved IRQ number");
return None;
} else if line == 255 {
warn!("Unknown IRQ line or no connection to the interrupt controller");
return None;
}

Some(line)
}
5.. => {
warn!("Reserved interrupt pin value returned.");
None
}
}
}

Expand Down