diff options
author | Quinn Stephens <quinn@osmora.org> | 2025-02-14 23:35:04 -0500 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-02-14 23:36:33 -0500 |
commit | e7cf7a914a4835cc8d29af79a2e3b5fad220bd3d (patch) | |
tree | 03bae3bbc09514d292a635fa228f9a722e428d71 /sys/include/dev/pci/pciregs.h | |
parent | 97fa59f389778fb7257a71ad1015a3eb2234a084 (diff) |
kernel: pci: Optimize PCI bus scanning
From fe1beed19be88e0c43ff2a68994d6abc04a52f54 Mon Sep 17 00:00:00 2001
From: Quinn Stephens <quinn@osmora.org>
Date: Fri, 14 Feb 2025 23:30:03 -0500
Subject: [PATCH] kernel: pci: Optimize PCI bus scanning
Uses recursive bus/bridge scanning, skips nonexistent devices, and only
scans for multiple functions on multifunction devices. This may result
in PCI scanning being up to 100x as fast.
Signed-off-by: Quinn Stephens <quinn@osmora.org>
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/include/dev/pci/pciregs.h')
-rw-r--r-- | sys/include/dev/pci/pciregs.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sys/include/dev/pci/pciregs.h b/sys/include/dev/pci/pciregs.h index f0ed4d2..888d12f 100644 --- a/sys/include/dev/pci/pciregs.h +++ b/sys/include/dev/pci/pciregs.h @@ -35,8 +35,10 @@ #define PCIREG_VENDOR_ID 0x00 /* 16 bits */ #define PCIREG_DEVICE_ID 0x02 /* 16 bits */ #define PCIREG_CLASSREV 0x08 /* 32 bits */ +#define PCIREG_HDRTYPE 0x0e /* 8 bits */ #define PCIREG_BAR0 0x10 /* 32 bits */ #define PCIREG_BAR1 0x14 /* 32 bits */ +#define PCIREG_BUSES 0x18 /* 24 bits */ #define PCIREG_BAR2 0x18 /* 32 bits */ #define PCIREG_BAR3 0x1C /* 32 bits */ #define PCIREG_BAR4 0x20 /* 32 bits */ @@ -51,6 +53,11 @@ #define PCIREG_REVID(CLASSREV) (CLASSREV & 0xFF) #define PCIREG_PROGIF(CLASSREV) ((CLASSREV >> 8) & 0xFF) +/* Macros to extract PCI_BUSES bits */ +#define PCIREG_PRIBUS(BUSES) (BUSES & 0xFF) +#define PCIREG_SECBUS(BUSES) ((BUSES >> 8) & 0xFF) +#define PCIREG_SUBBUS(BUSES) ((BUSES >> 16) & 0xFF) + /* Macros to extract PCIREG_CMDSTATUS bits */ #define PCIREG_COMMAND(CMDSTATUS) (CMDSTATUS & 0xFFFF) #define PCIREG_STATUS(CMDSTATUS) (CMDSTATUS >> 16) @@ -74,4 +81,8 @@ #define PCI_BAR_32(BAR) (PCI_BAR_TYPE(BAR) == 0x0) #define PCI_BAR_64(BAR) (PCI_BAR_TYPE(BAR) == 0x2) +/* PCI header types */ +#define PCI_HDRTYPE_NORMAL 0x00 +#define PCI_HDRTYPE_BRIDGE 0x01 + #endif /* _PCI_PCIREGS_H_ */ |