1 #ifndef _IPXE_PCIBIOS_H
2 #define _IPXE_PCIBIOS_H
8 * PCI configuration space access via PCI BIOS
12 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
15 #define PCIAPI_PREFIX_pcbios
17 #define PCIAPI_PREFIX_pcbios __pcbios_
22 #define PCIBIOS_INSTALLATION_CHECK 0xb1010000
23 #define PCIBIOS_READ_CONFIG_BYTE 0xb1080000
24 #define PCIBIOS_READ_CONFIG_WORD 0xb1090000
25 #define PCIBIOS_READ_CONFIG_DWORD 0xb10a0000
26 #define PCIBIOS_WRITE_CONFIG_BYTE 0xb10b0000
27 #define PCIBIOS_WRITE_CONFIG_WORD 0xb10c0000
28 #define PCIBIOS_WRITE_CONFIG_DWORD 0xb10d0000
30 extern int pcibios_read ( struct pci_device *pci, uint32_t command,
32 extern int pcibios_write ( struct pci_device *pci, uint32_t command,
36 * Read byte from PCI configuration space via PCI BIOS
39 * @v where Location within PCI configuration space
41 * @ret rc Return status code
43 static inline __always_inline int
44 PCIAPI_INLINE ( pcbios, pci_read_config_byte ) ( struct pci_device *pci,
50 rc = pcibios_read ( pci, PCIBIOS_READ_CONFIG_BYTE | where, &tmp );
56 * Read word from PCI configuration space via PCI BIOS
59 * @v where Location within PCI configuration space
61 * @ret rc Return status code
63 static inline __always_inline int
64 PCIAPI_INLINE ( pcbios, pci_read_config_word ) ( struct pci_device *pci,
70 rc = pcibios_read ( pci, PCIBIOS_READ_CONFIG_WORD | where, &tmp );
76 * Read dword from PCI configuration space via PCI BIOS
79 * @v where Location within PCI configuration space
81 * @ret rc Return status code
83 static inline __always_inline int
84 PCIAPI_INLINE ( pcbios, pci_read_config_dword ) ( struct pci_device *pci,
87 return pcibios_read ( pci, PCIBIOS_READ_CONFIG_DWORD | where, value );
91 * Write byte to PCI configuration space via PCI BIOS
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 ( pcbios, pci_write_config_byte ) ( struct pci_device *pci,
102 return pcibios_write ( pci, PCIBIOS_WRITE_CONFIG_BYTE | where, value );
106 * Write word to PCI configuration space via PCI BIOS
109 * @v where Location within PCI configuration space
110 * @v value Value to be written
111 * @ret rc Return status code
113 static inline __always_inline int
114 PCIAPI_INLINE ( pcbios, pci_write_config_word ) ( struct pci_device *pci,
117 return pcibios_write ( pci, PCIBIOS_WRITE_CONFIG_WORD | where, value );
121 * Write dword to PCI configuration space via PCI BIOS
124 * @v where Location within PCI configuration space
125 * @v value Value to be written
126 * @ret rc Return status code
128 static inline __always_inline int
129 PCIAPI_INLINE ( pcbios, pci_write_config_dword ) ( struct pci_device *pci,
132 return pcibios_write ( pci, PCIBIOS_WRITE_CONFIG_DWORD | where, value);
135 #endif /* _IPXE_PCIBIOS_H */