summaryrefslogtreecommitdiff
path: root/pci.h
diff options
context:
space:
mode:
authorJason Thorpe <thorpej@me.com>2021-06-02 20:53:13 -0700
committerRichard Henderson <richard.henderson@linaro.org>2021-06-05 17:32:11 -0700
commit0cbd87c2c426c7fd8a27f4d0dc8bd878d488dac0 (patch)
tree5e47c72e048f9b24ffcd64d85e103482eac02b56 /pci.h
parent7accd8de6bdf8efad1b18cb82aba58f691e51213 (diff)
downloadqemu-palcode-0cbd87c2c426c7fd8a27f4d0dc8bd878d488dac0.zip
qemu-palcode-0cbd87c2c426c7fd8a27f4d0dc8bd878d488dac0.tar.gz
qemu-palcode-0cbd87c2c426c7fd8a27f4d0dc8bd878d488dac0.tar.bz2
Make some PCI macros available to other files. NFC.
Move PCI_DEVFN(), PCI_BUS(), PCI_SLOT(), and PCI_FUNC() to pci.h. Signed-off-by: Jason Thorpe <thorpej@me.com> Message-Id: <20210603035317.6814-5-thorpej@me.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'pci.h')
-rw-r--r--pci.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/pci.h b/pci.h
index b751c6f..b4a4f80 100644
--- a/pci.h
+++ b/pci.h
@@ -60,6 +60,11 @@ extern void pci_config_maskw(int bdf, int addr, uint16_t off, uint16_t on);
extern int pci_next(int bdf, int *pmax);
+#define PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))
+#define PCI_BUS(devfn) ((devfn) >> 8)
+#define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f)
+#define PCI_FUNC(devfn) ((devfn) & 0x07)
+
#define foreachpci(BDF, MAX) \
for (MAX = 0x0100, BDF = pci_next(0, &MAX); \
BDF >= 0; \