4 FILE_LICENCE ( GPL2_OR_LATER );
10 #define PCIAPI_PREFIX_direct
12 #define PCIAPI_PREFIX_direct __direct_
17 * PCI configuration space access via Type 1 accesses
21 #define PCIDIRECT_CONFIG_ADDRESS 0xcf8
22 #define PCIDIRECT_CONFIG_DATA 0xcfc
26 extern void pcidirect_prepare ( struct pci_device *pci, int where );
29 * Determine number of PCI buses within system
31 * @ret num_bus Number of buses
33 static inline __always_inline int
34 PCIAPI_INLINE ( direct, pci_num_bus ) ( void ) {
35 /* No way to work this out via Type 1 accesses */
40 * Read byte from PCI configuration space via Type 1 access
43 * @v where Location within PCI configuration space
45 * @ret rc Return status code
47 static inline __always_inline int
48 PCIAPI_INLINE ( direct, pci_read_config_byte ) ( struct pci_device *pci,
51 pcidirect_prepare ( pci, where );
52 *value = inb ( PCIDIRECT_CONFIG_DATA + ( where & 3 ) );
57 * Read word from PCI configuration space via Type 1 access
60 * @v where Location within PCI configuration space
62 * @ret rc Return status code
64 static inline __always_inline int
65 PCIAPI_INLINE ( direct, pci_read_config_word ) ( struct pci_device *pci,
68 pcidirect_prepare ( pci, where );
69 *value = inw ( PCIDIRECT_CONFIG_DATA + ( where & 2 ) );
74 * Read dword from PCI configuration space via Type 1 access
77 * @v where Location within PCI configuration space
79 * @ret rc Return status code
81 static inline __always_inline int
82 PCIAPI_INLINE ( direct, pci_read_config_dword ) ( struct pci_device *pci,
85 pcidirect_prepare ( pci, where );
86 *value = inl ( PCIDIRECT_CONFIG_DATA );
91 * Write byte to PCI configuration space via Type 1 access
94 * @v where Location within PCI configuration space
95 * @v value Value to be written
96 * @ret rc Return status code
98 static inline __always_inline int
99 PCIAPI_INLINE ( direct, pci_write_config_byte ) ( struct pci_device *pci,
102 pcidirect_prepare ( pci, where );
103 outb ( value, PCIDIRECT_CONFIG_DATA + ( where & 3 ) );
108 * Write word to PCI configuration space via Type 1 access
111 * @v where Location within PCI configuration space
112 * @v value Value to be written
113 * @ret rc Return status code
115 static inline __always_inline int
116 PCIAPI_INLINE ( direct, pci_write_config_word ) ( struct pci_device *pci,
119 pcidirect_prepare ( pci, where );
120 outw ( value, PCIDIRECT_CONFIG_DATA + ( where & 2 ) );
125 * Write dword to PCI configuration space via Type 1 access
128 * @v where Location within PCI configuration space
129 * @v value Value to be written
130 * @ret rc Return status code
132 static inline __always_inline int
133 PCIAPI_INLINE ( direct, pci_write_config_dword ) ( struct pci_device *pci,
136 pcidirect_prepare ( pci, where );
137 outl ( value, PCIDIRECT_CONFIG_DATA );
141 #endif /* _PCIDIRECT_H */