9 * PCI configuration space access via Type 1 accesses
13 #define PCIDIRECT_CONFIG_ADDRESS 0xcf8
14 #define PCIDIRECT_CONFIG_DATA 0xcfc
18 extern void pcidirect_prepare ( struct pci_device *pci, int where );
21 * Determine maximum PCI bus number within system
23 * @ret max_bus Maximum bus number
25 static inline int pcidirect_max_bus ( void ) {
26 /* No way to work this out via Type 1 accesses */
31 * Read byte from PCI configuration space via Type 1 access
34 * @v where Location within PCI configuration space
36 * @ret rc Return status code
38 static inline __attribute__ (( always_inline )) int
39 pcidirect_read_config_byte ( struct pci_device *pci, unsigned int where,
41 pcidirect_prepare ( pci, where );
42 *value = inb ( PCIDIRECT_CONFIG_DATA + ( where & 3 ) );
47 * Read word from PCI configuration space via Type 1 access
50 * @v where Location within PCI configuration space
52 * @ret rc Return status code
54 static inline __attribute__ (( always_inline )) int
55 pcidirect_read_config_word ( struct pci_device *pci, unsigned int where,
57 pcidirect_prepare ( pci, where );
58 *value = inw ( PCIDIRECT_CONFIG_DATA + ( where & 2 ) );
63 * Read dword from PCI configuration space via Type 1 access
66 * @v where Location within PCI configuration space
68 * @ret rc Return status code
70 static inline __attribute__ (( always_inline )) int
71 pcidirect_read_config_dword ( struct pci_device *pci, unsigned int where,
73 pcidirect_prepare ( pci, where );
74 *value = inl ( PCIDIRECT_CONFIG_DATA );
79 * Write byte to PCI configuration space via Type 1 access
82 * @v where Location within PCI configuration space
83 * @v value Value to be written
84 * @ret rc Return status code
86 static inline __attribute__ (( always_inline )) int
87 pcidirect_write_config_byte ( struct pci_device *pci, unsigned int where,
89 pcidirect_prepare ( pci, where );
90 outb ( value, PCIDIRECT_CONFIG_DATA + ( where & 3 ) );
95 * Write word to PCI configuration space via Type 1 access
98 * @v where Location within PCI configuration space
99 * @v value Value to be written
100 * @ret rc Return status code
102 static inline __attribute__ (( always_inline )) int
103 pcidirect_write_config_word ( struct pci_device *pci, unsigned int where,
105 pcidirect_prepare ( pci, where );
106 outw ( value, PCIDIRECT_CONFIG_DATA + ( where & 2 ) );
111 * Write dword to PCI configuration space via Type 1 access
114 * @v where Location within PCI configuration space
115 * @v value Value to be written
116 * @ret rc Return status code
118 static inline __attribute__ (( always_inline )) int
119 pcidirect_write_config_dword ( struct pci_device *pci, unsigned int where,
121 pcidirect_prepare ( pci, where );
122 outl ( value, PCIDIRECT_CONFIG_DATA );
126 #endif /* _PCIDIRECT_H */