aboutsummaryrefslogtreecommitdiffstats
path: root/src/pci.h
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2008-11-09 15:33:47 -0500
committerKevin O'Connor <kevin@koconnor.net>2008-11-09 15:33:47 -0500
commitbe19cdc4dce80711fad94e6db0ab428761f3170d (patch)
tree17e4d7ae41c11f268a735f00d69852b0bb701a0f /src/pci.h
parentceea03c235f337062b3ded69cc658ea759e254f6 (diff)
downloadseabios-be19cdc4dce80711fad94e6db0ab428761f3170d.tar.gz
Overhaul PCI config functions.
Remove PCIDevice struct and replace with a "u16" with BDF - Bus/Device/Function. This simplifies the code in several places. Also, scan for and store the maximum PCI bus found during startup. The previous config option CONFIG_PCI_BUS_COUNT is no longer needed and has been removed.
Diffstat (limited to 'src/pci.h')
-rw-r--r--src/pci.h36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/pci.h b/src/pci.h
index cb3b7868..a18cfb7e 100644
--- a/src/pci.h
+++ b/src/pci.h
@@ -3,21 +3,12 @@
#include "types.h" // u32
-typedef struct PCIDevice {
- u8 bus;
- u8 devfn;
-} PCIDevice;
-
-static inline PCIDevice pci_bd(u8 bus, u8 devfn) {
- struct PCIDevice d = {bus, devfn};
- return d;
-}
-static inline u16 pci_to_bdf(PCIDevice d) {
- return (d.bus << 8) | d.devfn;
-}
static inline u8 pci_bdf_to_bus(u16 bdf) {
return bdf >> 8;
}
+static inline u8 pci_bdf_to_devfn(u16 bdf) {
+ return bdf & 0xff;
+}
static inline u8 pci_bdf_to_dev(u16 bdf) {
return (bdf >> 3) & 0x1f;
}
@@ -25,16 +16,19 @@ static inline u8 pci_bdf_to_fn(u16 bdf) {
return bdf & 0x07;
}
-void pci_config_writel(PCIDevice d, u32 addr, u32 val);
-void pci_config_writew(PCIDevice d, u32 addr, u16 val);
-void pci_config_writeb(PCIDevice d, u32 addr, u8 val);
-u32 pci_config_readl(PCIDevice d, u32 addr);
-u16 pci_config_readw(PCIDevice d, u32 addr);
-u8 pci_config_readb(PCIDevice d, u32 addr);
+void pci_config_writel(u16 bdf, u32 addr, u32 val);
+void pci_config_writew(u16 bdf, u32 addr, u16 val);
+void pci_config_writeb(u16 bdf, u32 addr, u8 val);
+u32 pci_config_readl(u16 bdf, u32 addr);
+u16 pci_config_readw(u16 bdf, u32 addr);
+u8 pci_config_readb(u16 bdf, u32 addr);
+
+void pci_bus_setup();
+int pci_find_device(u16 vendid, u16 devid, int start_bdf);
+int pci_find_classprog(u32 classprog, int start_bdf);
+int pci_find_class(u16 classid, int start_bdf);
-int pci_find_device(u16 vendid, u16 devid, int index, PCIDevice *dev);
-int pci_find_classprog(u32 classprog, int index, PCIDevice *dev);
-int pci_find_class(u16 classid, int index, PCIDevice *dev);
+extern int MaxBDF;
// pirtable.c
void create_pirtable();