6 #if !(defined(PCI_CONFIG_1) || defined(PCI_CONFIG_2))
7 #define PCI_CONFIG_1 1 /* default */
12 /* PCI Configuration Mechanism #1 */
14 #define PCI_ADDR(bus, dev, fn) \
15 (((pci_addr) (uint32_t) (bus) << 16 \
16 | (uint32_t) (dev) << 11 \
17 | (uint32_t) (fn) << 8))
19 #define PCI_BUS(pcidev) ((uint8_t) ((pcidev) >> 16) & 0xff)
20 #define PCI_DEV(pcidev) ((uint8_t) ((pcidev) >> 11) & 0x1f)
21 #define PCI_FN(pcidev) ((uint8_t) ((pcidev) >> 8) & 7)
23 #define PCI_CONFIG(dev) (arch->cfg_addr \
24 + (unsigned long)PCI_ADDR(PCI_BUS(dev), \
28 static inline uint8_t pci_config_read8(pci_addr dev, uint8_t reg)
31 res = in_8((unsigned char*)(PCI_CONFIG(dev) + reg));
35 static inline uint16_t pci_config_read16(pci_addr dev, uint8_t reg)
38 res = in_be16((uint16_t *)(PCI_CONFIG(dev) + reg));
42 static inline uint32_t pci_config_read32(pci_addr dev, uint8_t reg)
45 res = in_be32((uint32_t *)(PCI_CONFIG(dev) + reg));
49 static inline void pci_config_write8(pci_addr dev, uint8_t reg, uint8_t val)
51 out_8((unsigned char*)(PCI_CONFIG(dev) + reg), val);
54 static inline void pci_config_write16(pci_addr dev, uint8_t reg, uint16_t val)
56 out_be16((uint16_t *)(PCI_CONFIG(dev) + reg), val);
59 static inline void pci_config_write32(pci_addr dev, uint8_t reg, uint32_t val)
61 out_be32((uint32_t *)(PCI_CONFIG(dev) + reg), val);
63 #else /* !PCI_CONFIG_1 */
64 #error PCI Configuration Mechanism is not specified or implemented
67 #endif /* SPARC64_PCI_H */