1 #ifndef _IPXE_LINUX_PCI_H
2 #define _IPXE_LINUX_PCI_H
6 * iPXE PCI API for Linux
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
13 #define PCIAPI_PREFIX_linux
15 #define PCIAPI_PREFIX_linux __linux_
20 extern int linux_pci_read ( struct pci_device *pci, unsigned long where,
21 unsigned long *value, size_t len );
22 extern int linux_pci_write ( struct pci_device *pci, unsigned long where,
23 unsigned long value, size_t len );
26 * Read byte from PCI configuration space
29 * @v where Location within PCI configuration space
31 * @ret rc Return status code
33 static inline __always_inline int
34 PCIAPI_INLINE ( linux, pci_read_config_byte ) ( struct pci_device *pci,
40 rc = linux_pci_read ( pci, where, &tmp, sizeof ( *value ) );
46 * Read word from PCI configuration space
49 * @v where Location within PCI configuration space
51 * @ret rc Return status code
53 static inline __always_inline int
54 PCIAPI_INLINE ( linux, pci_read_config_word ) ( struct pci_device *pci,
60 rc = linux_pci_read ( pci, where, &tmp, sizeof ( *value ) );
66 * Read dword from PCI configuration space
69 * @v where Location within PCI configuration space
71 * @ret rc Return status code
73 static inline __always_inline int
74 PCIAPI_INLINE ( linux, pci_read_config_dword ) ( struct pci_device *pci,
80 rc = linux_pci_read ( pci, where, &tmp, sizeof ( *value ) );
86 * Write byte to PCI configuration space
89 * @v where Location within PCI configuration space
90 * @v value Value to be written
91 * @ret rc Return status code
93 static inline __always_inline int
94 PCIAPI_INLINE ( linux, pci_write_config_byte ) ( struct pci_device *pci,
97 return linux_pci_write ( pci, where, value, sizeof ( value ) );
101 * Write word to PCI configuration space
104 * @v where Location within PCI configuration space
105 * @v value Value to be written
106 * @ret rc Return status code
108 static inline __always_inline int
109 PCIAPI_INLINE ( linux, pci_write_config_word ) ( struct pci_device *pci,
112 return linux_pci_write ( pci, where, value, sizeof ( value ) );
116 * Write dword to PCI configuration space
119 * @v where Location within PCI configuration space
120 * @v value Value to be written
121 * @ret rc Return status code
123 static inline __always_inline int
124 PCIAPI_INLINE ( linux, pci_write_config_dword ) ( struct pci_device *pci,
127 return linux_pci_write ( pci, where, value, sizeof ( value ) );
130 #endif /* _IPXE_LINUX_PCI_H */