Make legacy_interrupt_line an Option
Drivers don't need to know the exact legacy_interrupt_pin in use. Just if legacy interrupts are enabled and if so which legacy_interrupt_line is used.
This commit is contained in:
@@ -57,10 +57,8 @@ pub struct PciFunction {
|
||||
/// Legacy IRQ line: It's the responsibility of pcid to make sure that it be mapped in either
|
||||
/// the I/O APIC or the 8259 PIC, so that the subdriver can map the interrupt vector directly.
|
||||
/// The vector to map is always this field, plus 32.
|
||||
pub legacy_interrupt_line: u8,
|
||||
|
||||
/// Legacy interrupt pin (INTx#), none if INTx# interrupts aren't supported at all.
|
||||
pub legacy_interrupt_pin: Option<LegacyInterruptPin>,
|
||||
/// If INTx# interrupts aren't supported at all this is `None`.
|
||||
pub legacy_interrupt_line: Option<u8>,
|
||||
|
||||
/// All identifying information of the PCI function.
|
||||
pub full_device_id: FullDeviceId,
|
||||
|
||||
+11
-17
@@ -280,6 +280,16 @@ fn handle_parsed_header(state: Arc<State>, config: &Config, addr: PciAddress, he
|
||||
state.pcie.write(addr, 0x3C, data);
|
||||
};
|
||||
|
||||
let legacy_interrupt_enabled = match interrupt_pin {
|
||||
0 => false,
|
||||
1 | 2 | 3 | 4 => true,
|
||||
|
||||
other => {
|
||||
warn!("pcid: invalid interrupt pin: {}", other);
|
||||
false
|
||||
}
|
||||
};
|
||||
|
||||
let capabilities = if endpoint_header.status(&state.pcie).has_capability_list() {
|
||||
let func = PciFunc {
|
||||
pci: &state.pcie,
|
||||
@@ -291,26 +301,10 @@ fn handle_parsed_header(state: Arc<State>, config: &Config, addr: PciAddress, he
|
||||
};
|
||||
debug!("PCI DEVICE CAPABILITIES for {}: {:?}", args.iter().map(|string| string.as_ref()).nth(0).unwrap_or("[unknown]"), capabilities);
|
||||
|
||||
use driver_interface::LegacyInterruptPin;
|
||||
|
||||
let legacy_interrupt_pin = match interrupt_pin {
|
||||
0 => None,
|
||||
1 => Some(LegacyInterruptPin::IntA),
|
||||
2 => Some(LegacyInterruptPin::IntB),
|
||||
3 => Some(LegacyInterruptPin::IntC),
|
||||
4 => Some(LegacyInterruptPin::IntD),
|
||||
|
||||
other => {
|
||||
warn!("pcid: invalid interrupt pin: {}", other);
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
let func = driver_interface::PciFunction {
|
||||
bars,
|
||||
addr,
|
||||
legacy_interrupt_line: irq,
|
||||
legacy_interrupt_pin,
|
||||
legacy_interrupt_line: if legacy_interrupt_enabled { Some(irq) } else { None },
|
||||
full_device_id: header.full_device_id().clone(),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user