Skip to content

Commit fe42a4a

Browse files
committed
pci: clearer intersection code
1 parent 603f9dd commit fe42a4a

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

src/arch/x86_64/kernel/pci.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ pub(crate) fn init() {
9494
}
9595

9696
// For Hermit, we currently limit scanning to the first 32 buses.
97-
const PCI_MAX_BUS_NUMBER: u8 = 32;
9897
scan_bus(
9998
0..PCI_MAX_BUS_NUMBER,
10099
PciConfigRegion::Pci(LegacyPciConfigRegion::new()),
@@ -205,11 +204,7 @@ mod pcie {
205204
let region_start = u64::try_from(mem_region.starting_address.addr()).unwrap();
206205
let region_end = region_start + u64::try_from(mem_region.size.expect("found a memory region with no declared size")).unwrap();
207206

208-
if
209-
(pci_start >= region_start && pci_start <= region_end) // PCI region starts within the memory region
210-
|| (pci_end >= region_start && pci_end <= region_end) // PCI region ends within the memory region
211-
|| (pci_start <= region_start && pci_end >= region_end) // PCI region contains the memory region
212-
{
207+
if pci_start < region_end && pci_end > region_start {
213208
error!("The declared PCI region {pci_start:x}-{pci_end:x} may overlap with physical memory region {region_start:x}-{region_end:x}");
214209
return false;
215210
}

0 commit comments

Comments
 (0)