Skip to content

Commit 32c0944

Browse files
committed
uefi: Fix broken bridge recursion in PCI enumeration
1 parent 039429b commit 32c0944

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

uefi/src/proto/pci/enumeration.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ struct PciRegister3 {
3737
#[allow(unused)]
3838
#[derive(Clone, Copy, Debug)]
3939
struct PciHeader1Register6 {
40-
secondary_latency_timer: u8,
41-
subordinate_bus: u8,
42-
secondary_bus: u8,
4340
primary_bus: u8,
41+
secondary_bus: u8,
42+
subordinate_bus: u8,
43+
secondary_latency_timer: u8,
4444
}
4545

4646
/// Read the 4byte pci register with the given `addr` and cast it into the given structured representation.
@@ -93,7 +93,8 @@ fn visit_function(
9393
}
9494
queue.insert(FullPciIoAddress::new(proto.segment_nr(), addr));
9595
let (base_class, sub_class) = get_classes(proto, addr)?;
96-
if base_class == 0x6 && sub_class == 0x4 && get_header_type(proto, addr)? == 0x01 {
96+
let header_type = get_header_type(proto, addr)? & 0b01111111;
97+
if base_class == 0x6 && sub_class == 0x4 && header_type == 0x01 {
9798
// This is a PCI-to-PCI bridge controller. The current `addr` is the address with which it's
9899
// mounted in the PCI tree we are currently traversing. Now we query its header, where
99100
// the bridge tells us a range of addresses [secondary;subordinate], with which the other

0 commit comments

Comments
 (0)