[sundance] Add reset completion check
[gpxe.git] / src / include / gpxe / pci_io.h
blob365166c8d13d371694affacc06af1a91592fa357
1 #ifndef _GPXE_PCI_IO_H
2 #define _GPXE_PCI_IO_H
4 /** @file
6 * PCI I/O API
8 */
10 #include <stdint.h>
11 #include <gpxe/api.h>
12 #include <config/ioapi.h>
14 /**
15 * Calculate static inline PCI I/O API function name
17 * @v _prefix Subsystem prefix
18 * @v _api_func API function
19 * @ret _subsys_func Subsystem API function
21 #define PCIAPI_INLINE( _subsys, _api_func ) \
22 SINGLE_API_INLINE ( PCIAPI_PREFIX_ ## _subsys, _api_func )
24 /**
25 * Provide a PCI I/O API implementation
27 * @v _prefix Subsystem prefix
28 * @v _api_func API function
29 * @v _func Implementing function
31 #define PROVIDE_PCIAPI( _subsys, _api_func, _func ) \
32 PROVIDE_SINGLE_API ( PCIAPI_PREFIX_ ## _subsys, _api_func, _func )
34 /**
35 * Provide a static inline PCI I/O API implementation
37 * @v _prefix Subsystem prefix
38 * @v _api_func API function
40 #define PROVIDE_PCIAPI_INLINE( _subsys, _api_func ) \
41 PROVIDE_SINGLE_API_INLINE ( PCIAPI_PREFIX_ ## _subsys, _api_func )
43 /* Include all architecture-independent I/O API headers */
44 #include <gpxe/efi/efi_pci.h>
46 /* Include all architecture-dependent I/O API headers */
47 #include <bits/pci_io.h>
49 /**
50 * Determine maximum PCI bus number within system
52 * @ret max_bus Maximum bus number
54 int pci_max_bus ( void );
56 /**
57 * Read byte from PCI configuration space
59 * @v pci PCI device
60 * @v where Location within PCI configuration space
61 * @v value Value read
62 * @ret rc Return status code
64 int pci_read_config_byte ( struct pci_device *pci, unsigned int where,
65 uint8_t *value );
67 /**
68 * Read 16-bit word from PCI configuration space
70 * @v pci PCI device
71 * @v where Location within PCI configuration space
72 * @v value Value read
73 * @ret rc Return status code
75 int pci_read_config_word ( struct pci_device *pci, unsigned int where,
76 uint16_t *value );
78 /**
79 * Read 32-bit dword from PCI configuration space
81 * @v pci PCI device
82 * @v where Location within PCI configuration space
83 * @v value Value read
84 * @ret rc Return status code
86 int pci_read_config_dword ( struct pci_device *pci, unsigned int where,
87 uint32_t *value );
89 /**
90 * Write byte to PCI configuration space
92 * @v pci PCI device
93 * @v where Location within PCI configuration space
94 * @v value Value to be written
95 * @ret rc Return status code
97 int pci_write_config_byte ( struct pci_device *pci, unsigned int where,
98 uint8_t value );
101 * Write 16-bit word to PCI configuration space
103 * @v pci PCI device
104 * @v where Location within PCI configuration space
105 * @v value Value to be written
106 * @ret rc Return status code
108 int pci_write_config_word ( struct pci_device *pci, unsigned int where,
109 uint16_t value );
112 * Write 32-bit dword to PCI configuration space
114 * @v pci PCI device
115 * @v where Location within PCI configuration space
116 * @v value Value to be written
117 * @ret rc Return status code
119 int pci_write_config_dword ( struct pci_device *pci, unsigned int where,
120 uint32_t value );
122 #endif /* _GPXE_PCI_IO_H */