4 #include "types.h" // u32
6 typedef struct PCIDevice {
11 static inline PCIDevice pci_bd(u8 bus, u8 devfn) {
12 struct PCIDevice d = {bus, devfn};
15 static inline u16 pci_to_bdf(PCIDevice d) {
16 return (d.bus << 8) | d.devfn;
18 static inline u8 pci_bdf_to_bus(u16 bdf) {
21 static inline u8 pci_bdf_to_dev(u16 bdf) {
22 return (bdf >> 3) & 0x1f;
24 static inline u8 pci_bdf_to_fn(u16 bdf) {
28 void pci_config_writel(PCIDevice d, u32 addr, u32 val);
29 void pci_config_writew(PCIDevice d, u32 addr, u16 val);
30 void pci_config_writeb(PCIDevice d, u32 addr, u8 val);
31 u32 pci_config_readl(PCIDevice d, u32 addr);
32 u16 pci_config_readw(PCIDevice d, u32 addr);
33 u8 pci_config_readb(PCIDevice d, u32 addr);
35 int pci_find_device(u16 vendid, u16 devid, int index, PCIDevice *dev);
36 int pci_find_classprog(u32 classprog, int index, PCIDevice *dev);
37 int pci_find_class(u16 classid, int index, PCIDevice *dev);
40 void create_pirtable();
43 /****************************************************************
45 ****************************************************************/
55 struct link_info links[4];
71 struct pir_slot slots[0];
74 #define PIR_SIGNATURE 0x52495024 // $PIR