1 #ifndef _IPXE_PCI_IO_H 2 #define _IPXE_PCI_IO_H 3 4 /** @file 5 * 6 * PCI I/O API 7 * 8 */ 9 10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); 11 12 #include <stdint.h> 13 #include <ipxe/api.h> 14 #include <config/ioapi.h> 15 16 /** 17 * Calculate static inline PCI I/O API function name 18 * 19 * @v _prefix Subsystem prefix 20 * @v _api_func API function 21 * @ret _subsys_func Subsystem API function 22 */ 23 #define PCIAPI_INLINE( _subsys, _api_func ) \ 24 SINGLE_API_INLINE ( PCIAPI_PREFIX_ ## _subsys, _api_func ) 25 26 /** 27 * Provide a PCI I/O API implementation 28 * 29 * @v _prefix Subsystem prefix 30 * @v _api_func API function 31 * @v _func Implementing function 32 */ 33 #define PROVIDE_PCIAPI( _subsys, _api_func, _func ) \ 34 PROVIDE_SINGLE_API ( PCIAPI_PREFIX_ ## _subsys, _api_func, _func ) 35 36 /** 37 * Provide a static inline PCI I/O API implementation 38 * 39 * @v _prefix Subsystem prefix 40 * @v _api_func API function 41 */ 42 #define PROVIDE_PCIAPI_INLINE( _subsys, _api_func ) \ 43 PROVIDE_SINGLE_API_INLINE ( PCIAPI_PREFIX_ ## _subsys, _api_func ) 44 45 /* Include all architecture-independent I/O API headers */ 46 #include <ipxe/efi/efi_pci_api.h> 47 #include <ipxe/linux/linux_pci.h> 48 49 /* Include all architecture-dependent I/O API headers */ 50 #include <bits/pci_io.h> 51 52 /** 53 * Determine number of PCI buses within system 54 * 55 * @ret num_bus Number of buses 56 */ 57 int pci_num_bus ( void ); 58 59 /** 60 * Read byte from PCI configuration space 61 * 62 * @v pci PCI device 63 * @v where Location within PCI configuration space 64 * @v value Value read 65 * @ret rc Return status code 66 */ 67 int pci_read_config_byte ( struct pci_device *pci, unsigned int where, 68 uint8_t *value ); 69 70 /** 71 * Read 16-bit word from PCI configuration space 72 * 73 * @v pci PCI device 74 * @v where Location within PCI configuration space 75 * @v value Value read 76 * @ret rc Return status code 77 */ 78 int pci_read_config_word ( struct pci_device *pci, unsigned int where, 79 uint16_t *value ); 80 81 /** 82 * Read 32-bit dword from PCI configuration space 83 * 84 * @v pci PCI device 85 * @v where Location within PCI configuration space 86 * @v value Value read 87 * @ret rc Return status code 88 */ 89 int pci_read_config_dword ( struct pci_device *pci, unsigned int where, 90 uint32_t *value ); 91 92 /** 93 * Write byte to PCI configuration space 94 * 95 * @v pci PCI device 96 * @v where Location within PCI configuration space 97 * @v value Value to be written 98 * @ret rc Return status code 99 */ 100 int pci_write_config_byte ( struct pci_device *pci, unsigned int where, 101 uint8_t value ); 102 103 /** 104 * Write 16-bit word to PCI configuration space 105 * 106 * @v pci PCI device 107 * @v where Location within PCI configuration space 108 * @v value Value to be written 109 * @ret rc Return status code 110 */ 111 int pci_write_config_word ( struct pci_device *pci, unsigned int where, 112 uint16_t value ); 113 114 /** 115 * Write 32-bit dword to PCI configuration space 116 * 117 * @v pci PCI device 118 * @v where Location within PCI configuration space 119 * @v value Value to be written 120 * @ret rc Return status code 121 */ 122 int pci_write_config_dword ( struct pci_device *pci, unsigned int where, 123 uint32_t value ); 124 125 #endif /* _IPXE_PCI_IO_H */ 126