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
18 changes: 18 additions & 0 deletions src/aml/pci_routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ pub enum Pin {
IntD,
}

#[derive(Debug, Clone, Copy)]
pub struct InvalidPciInterruptPinError(pub u8);

impl Pin {
/// If the PCI interrupt pin is `0`, that means that the PCI device doesn't use an interrupt pin,
/// and `Ok(None)` will be returned.
pub fn from_pci_interrupt_pin(pin: u8) -> Result<Option<Self>, InvalidPciInterruptPinError> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is a bit confusing if you also read the let pin = match *pin_package[1] { block.

I think it would be worth adding a from_pkg_interrupt_num (or similar) function to show the difference, then using that in the match block.

match pin {
0 => Ok(None),
1 => Ok(Some(Self::IntA)),
2 => Ok(Some(Self::IntB)),
3 => Ok(Some(Self::IntC)),
4 => Ok(Some(Self::IntD)),
pin => Err(InvalidPciInterruptPinError(pin)),
}
}
}

#[derive(Debug)]
pub enum PciRouteType {
/// The interrupt is hard-coded to a specific GSI
Expand Down
Loading