efi_pci.h

Go to the documentation of this file.
00001 #ifndef _GPXE_EFI_PCI_H
00002 #define _GPXE_EFI_PCI_H
00003 
00004 /** @file
00005  *
00006  * gPXE PCI I/O API for EFI
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER );
00011 
00012 #ifdef PCIAPI_EFI
00013 #define PCIAPI_PREFIX_efi
00014 #else
00015 #define PCIAPI_PREFIX_efi __efi_
00016 #endif
00017 
00018 /* EFI PCI width codes defined by EFI spec */
00019 #define EFIPCI_WIDTH_BYTE 0
00020 #define EFIPCI_WIDTH_WORD 1
00021 #define EFIPCI_WIDTH_DWORD 2
00022 
00023 #define EFIPCI_LOCATION( _offset, _width ) \
00024         ( (_offset) | ( (_width) << 16 ) )
00025 #define EFIPCI_OFFSET( _location ) ( (_location) & 0xffff )
00026 #define EFIPCI_WIDTH( _location ) ( (_location) >> 16 )
00027 
00028 struct pci_device;
00029 
00030 extern int efipci_read ( struct pci_device *pci, unsigned long location,
00031                          void *value );
00032 extern int efipci_write ( struct pci_device *pci, unsigned long location,
00033                           unsigned long value );
00034 
00035 /**
00036  * Determine maximum PCI bus number within system
00037  *
00038  * @ret max_bus         Maximum bus number
00039  */
00040 static inline __always_inline int
00041 PCIAPI_INLINE ( efi, pci_max_bus ) ( void ) {
00042         /* No way to work this out via EFI */
00043         return 0xff;
00044 }
00045 
00046 /**
00047  * Read byte from PCI configuration space via EFI
00048  *
00049  * @v pci       PCI device
00050  * @v where     Location within PCI configuration space
00051  * @v value     Value read
00052  * @ret rc      Return status code
00053  */
00054 static inline __always_inline int
00055 PCIAPI_INLINE ( efi, pci_read_config_byte ) ( struct pci_device *pci,
00056                                               unsigned int where,
00057                                               uint8_t *value ) {
00058         return efipci_read ( pci,
00059                              EFIPCI_LOCATION ( where, EFIPCI_WIDTH_BYTE ),
00060                              value );
00061 }
00062 
00063 /**
00064  * Read word from PCI configuration space via EFI
00065  *
00066  * @v pci       PCI device
00067  * @v where     Location within PCI configuration space
00068  * @v value     Value read
00069  * @ret rc      Return status code
00070  */
00071 static inline __always_inline int
00072 PCIAPI_INLINE ( efi, pci_read_config_word ) ( struct pci_device *pci,
00073                                               unsigned int where,
00074                                               uint16_t *value ) {
00075         return efipci_read ( pci,
00076                              EFIPCI_LOCATION ( where, EFIPCI_WIDTH_WORD ),
00077                              value );
00078 }
00079 
00080 /**
00081  * Read dword from PCI configuration space via EFI
00082  *
00083  * @v pci       PCI device
00084  * @v where     Location within PCI configuration space
00085  * @v value     Value read
00086  * @ret rc      Return status code
00087  */
00088 static inline __always_inline int
00089 PCIAPI_INLINE ( efi, pci_read_config_dword ) ( struct pci_device *pci,
00090                                                unsigned int where,
00091                                                uint32_t *value ) {
00092         return efipci_read ( pci,
00093                              EFIPCI_LOCATION ( where, EFIPCI_WIDTH_DWORD ),
00094                              value );
00095 }
00096 
00097 /**
00098  * Write byte to PCI configuration space via EFI
00099  *
00100  * @v pci       PCI device
00101  * @v where     Location within PCI configuration space
00102  * @v value     Value to be written
00103  * @ret rc      Return status code
00104  */
00105 static inline __always_inline int
00106 PCIAPI_INLINE ( efi, pci_write_config_byte ) ( struct pci_device *pci,
00107                                                unsigned int where,
00108                                                uint8_t value ) {
00109         return efipci_write ( pci,
00110                               EFIPCI_LOCATION ( where, EFIPCI_WIDTH_BYTE ),
00111                               value );
00112 }
00113 
00114 /**
00115  * Write word to PCI configuration space via EFI
00116  *
00117  * @v pci       PCI device
00118  * @v where     Location within PCI configuration space
00119  * @v value     Value to be written
00120  * @ret rc      Return status code
00121  */
00122 static inline __always_inline int
00123 PCIAPI_INLINE ( efi, pci_write_config_word ) ( struct pci_device *pci,
00124                                                unsigned int where,
00125                                                uint16_t value ) {
00126         return efipci_write ( pci,
00127                               EFIPCI_LOCATION ( where, EFIPCI_WIDTH_WORD ),
00128                               value );
00129 }
00130 
00131 /**
00132  * Write dword to PCI configuration space via EFI
00133  *
00134  * @v pci       PCI device
00135  * @v where     Location within PCI configuration space
00136  * @v value     Value to be written
00137  * @ret rc      Return status code
00138  */
00139 static inline __always_inline int
00140 PCIAPI_INLINE ( efi, pci_write_config_dword ) ( struct pci_device *pci,
00141                                                 unsigned int where,
00142                                                 uint32_t value ) {
00143         return efipci_write ( pci,
00144                               EFIPCI_LOCATION ( where, EFIPCI_WIDTH_DWORD ),
00145                               value );
00146 }
00147 
00148 #endif /* _GPXE_EFI_PCI_H */

Generated on Tue Apr 6 20:01:06 2010 for gPXE by  doxygen 1.5.7.1