pcibios.h
Go to the documentation of this file.00001 #ifndef _GPXE_PCIBIOS_H
00002 #define _GPXE_PCIBIOS_H
00003
00004 #include <stdint.h>
00005
00006
00007
00008
00009
00010
00011
00012 FILE_LICENCE ( GPL2_OR_LATER );
00013
00014 #ifdef PCIAPI_PCBIOS
00015 #define PCIAPI_PREFIX_pcbios
00016 #else
00017 #define PCIAPI_PREFIX_pcbios __pcbios_
00018 #endif
00019
00020 struct pci_device;
00021
00022 #define PCIBIOS_INSTALLATION_CHECK 0xb1010000
00023 #define PCIBIOS_READ_CONFIG_BYTE 0xb1080000
00024 #define PCIBIOS_READ_CONFIG_WORD 0xb1090000
00025 #define PCIBIOS_READ_CONFIG_DWORD 0xb10a0000
00026 #define PCIBIOS_WRITE_CONFIG_BYTE 0xb10b0000
00027 #define PCIBIOS_WRITE_CONFIG_WORD 0xb10c0000
00028 #define PCIBIOS_WRITE_CONFIG_DWORD 0xb10d0000
00029
00030 extern int pcibios_read ( struct pci_device *pci, uint32_t command,
00031 uint32_t *value );
00032 extern int pcibios_write ( struct pci_device *pci, uint32_t command,
00033 uint32_t value );
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 static inline __always_inline int
00044 PCIAPI_INLINE ( pcbios, pci_read_config_byte ) ( struct pci_device *pci,
00045 unsigned int where,
00046 uint8_t *value ) {
00047 uint32_t tmp;
00048 int rc;
00049
00050 rc = pcibios_read ( pci, PCIBIOS_READ_CONFIG_BYTE | where, &tmp );
00051 *value = tmp;
00052 return rc;
00053 }
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 static inline __always_inline int
00064 PCIAPI_INLINE ( pcbios, pci_read_config_word ) ( struct pci_device *pci,
00065 unsigned int where,
00066 uint16_t *value ) {
00067 uint32_t tmp;
00068 int rc;
00069
00070 rc = pcibios_read ( pci, PCIBIOS_READ_CONFIG_WORD | where, &tmp );
00071 *value = tmp;
00072 return rc;
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 static inline __always_inline int
00084 PCIAPI_INLINE ( pcbios, pci_read_config_dword ) ( struct pci_device *pci,
00085 unsigned int where,
00086 uint32_t *value ) {
00087 return pcibios_read ( pci, PCIBIOS_READ_CONFIG_DWORD | where, value );
00088 }
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 static inline __always_inline int
00099 PCIAPI_INLINE ( pcbios, pci_write_config_byte ) ( struct pci_device *pci,
00100 unsigned int where,
00101 uint8_t value ) {
00102 return pcibios_write ( pci, PCIBIOS_WRITE_CONFIG_BYTE | where, value );
00103 }
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 static inline __always_inline int
00114 PCIAPI_INLINE ( pcbios, pci_write_config_word ) ( struct pci_device *pci,
00115 unsigned int where,
00116 uint16_t value ) {
00117 return pcibios_write ( pci, PCIBIOS_WRITE_CONFIG_WORD | where, value );
00118 }
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 static inline __always_inline int
00129 PCIAPI_INLINE ( pcbios, pci_write_config_dword ) ( struct pci_device *pci,
00130 unsigned int where,
00131 uint32_t value ) {
00132 return pcibios_write ( pci, PCIBIOS_WRITE_CONFIG_DWORD | where, value);
00133 }
00134
00135 #endif