Skip to content

Commit

Permalink
[fix] PCI irq map
Browse files Browse the repository at this point in the history
  • Loading branch information
ZR233 committed Feb 7, 2025
1 parent 0901f5b commit 150f34e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
Binary file added dtb/qemu_pci.dtb
Binary file not shown.
2 changes: 1 addition & 1 deletion fdt-parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fdt-parser"
version = "0.4.7"
version = "0.4.8"
authors = ["周睿 <zrufo747@outlook.com>"]
edition = "2021"
repository = "https://github.com/qclic/fdt-parser"
Expand Down
6 changes: 3 additions & 3 deletions fdt-parser/src/pci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ impl<'a> Pci<'a> {

let want0 = (bus as u32) << 16 | (device as u32) << 11 | (func as u32) << 8;

let mut want = mask;
let mut want = [0; 4];

want[0] = want0 | mask[0];
want[3] = irq_pin;
want[0] = want0 & mask[0];
want[3] = irq_pin & mask[3];

let mut prop = self
.node
Expand Down
18 changes: 18 additions & 0 deletions fdt-parser/tests/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod test {

const TEST_FDT: &[u8] = include_bytes!("../../dtb/bcm2711-rpi-4-b.dtb");
const TEST_PHYTIUM_FDT: &[u8] = include_bytes!("../../dtb/phytium.dtb");
const TEST_QEMU_FDT: &[u8] = include_bytes!("../../dtb/qemu_pci.dtb");

#[test]
fn test_find_compatible() {
Expand Down Expand Up @@ -202,4 +203,21 @@ mod test {
println!("one: {:?}", one);
}
}

#[test]
fn test_pci_irq_map2() {
let fdt = Fdt::from_bytes(TEST_QEMU_FDT).unwrap();
let pci = fdt
.find_compatible(&["pci-host-ecam-generic"])
.next()
.unwrap()
.into_pci()
.unwrap();

let irq = pci.child_interrupts(0, 2, 0, 1).unwrap();

for one in irq.irqs {
println!("one: {:?}", one);
}
}
}

0 comments on commit 150f34e

Please sign in to comment.