4 #include "types.h" // u32
6 typedef struct PCIDevice {
11 static inline PCIDevice
12 pci_bd(u8 bus, u8 devfn)
14 struct PCIDevice d = {bus, devfn};
18 void pci_config_writel(PCIDevice d, u32 addr, u32 val);
19 void pci_config_writew(PCIDevice d, u32 addr, u16 val);
20 void pci_config_writeb(PCIDevice d, u32 addr, u8 val);
21 u32 pci_config_readl(PCIDevice d, u32 addr);
22 u16 pci_config_readw(PCIDevice d, u32 addr);
23 u8 pci_config_readb(PCIDevice d, u32 addr);
25 int pci_find_device(u16 vendid, u16 devid, int index, PCIDevice *dev);
26 int pci_find_class(u32 classid, int index, PCIDevice *dev);
29 void create_pirtable();
32 /****************************************************************
34 ****************************************************************/
36 #define PCI_VENDOR_ID 0x00 /* 16 bits */
37 #define PCI_DEVICE_ID 0x02 /* 16 bits */
38 #define PCI_COMMAND 0x04 /* 16 bits */
39 #define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */
40 #define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */
41 #define PCI_CLASS_DEVICE 0x0a /* Device class */
42 #define PCI_INTERRUPT_LINE 0x3c /* 8 bits */
43 #define PCI_INTERRUPT_PIN 0x3d /* 8 bits */
44 #define PCI_MIN_GNT 0x3e /* 8 bits */
45 #define PCI_MAX_LAT 0x3f /* 8 bits */
48 /****************************************************************
50 ****************************************************************/
60 struct link_info links[4];
76 struct pir_slot slots[0];
79 #define PIR_SIGNATURE 0x52495024 // $PIR