pcidirect.h
Go to the documentation of this file.00001 #ifndef _PCIDIRECT_H
00002 #define _PCIDIRECT_H
00003
00004 FILE_LICENCE ( GPL2_OR_LATER );
00005
00006 #include <stdint.h>
00007 #include <gpxe/io.h>
00008
00009 #ifdef PCIAPI_DIRECT
00010 #define PCIAPI_PREFIX_direct
00011 #else
00012 #define PCIAPI_PREFIX_direct __direct_
00013 #endif
00014
00015
00016
00017
00018
00019
00020
00021 #define PCIDIRECT_CONFIG_ADDRESS 0xcf8
00022 #define PCIDIRECT_CONFIG_DATA 0xcfc
00023
00024 struct pci_device;
00025
00026 extern void pcidirect_prepare ( struct pci_device *pci, int where );
00027
00028
00029
00030
00031
00032
00033 static inline __always_inline int
00034 PCIAPI_INLINE ( direct, pci_max_bus ) ( void ) {
00035
00036 return 0xff;
00037 }
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 static inline __always_inline int
00048 PCIAPI_INLINE ( direct, pci_read_config_byte ) ( struct pci_device *pci,
00049 unsigned int where,
00050 uint8_t *value ) {
00051 pcidirect_prepare ( pci, where );
00052 *value = inb ( PCIDIRECT_CONFIG_DATA + ( where & 3 ) );
00053 return 0;
00054 }
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 static inline __always_inline int
00065 PCIAPI_INLINE ( direct, pci_read_config_word ) ( struct pci_device *pci,
00066 unsigned int where,
00067 uint16_t *value ) {
00068 pcidirect_prepare ( pci, where );
00069 *value = inw ( PCIDIRECT_CONFIG_DATA + ( where & 2 ) );
00070 return 0;
00071 }
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 static inline __always_inline int
00082 PCIAPI_INLINE ( direct, pci_read_config_dword ) ( struct pci_device *pci,
00083 unsigned int where,
00084 uint32_t *value ) {
00085 pcidirect_prepare ( pci, where );
00086 *value = inl ( PCIDIRECT_CONFIG_DATA );
00087 return 0;
00088 }
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 static inline __always_inline int
00099 PCIAPI_INLINE ( direct, pci_write_config_byte ) ( struct pci_device *pci,
00100 unsigned int where,
00101 uint8_t value ) {
00102 pcidirect_prepare ( pci, where );
00103 outb ( value, PCIDIRECT_CONFIG_DATA + ( where & 3 ) );
00104 return 0;
00105 }
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 static inline __always_inline int
00116 PCIAPI_INLINE ( direct, pci_write_config_word ) ( struct pci_device *pci,
00117 unsigned int where,
00118 uint16_t value ) {
00119 pcidirect_prepare ( pci, where );
00120 outw ( value, PCIDIRECT_CONFIG_DATA + ( where & 2 ) );
00121 return 0;
00122 }
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 static inline __always_inline int
00133 PCIAPI_INLINE ( direct, pci_write_config_dword ) ( struct pci_device *pci,
00134 unsigned int where,
00135 uint32_t value ) {
00136 pcidirect_prepare ( pci, where );
00137 outl ( value, PCIDIRECT_CONFIG_DATA );
00138 return 0;
00139 }
00140
00141 #endif