iPXE
pci_io.h
Go to the documentation of this file.
00001 #ifndef _IPXE_PCI_IO_H
00002 #define _IPXE_PCI_IO_H
00003 
00004 /** @file
00005  *
00006  * PCI I/O API
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stdint.h>
00013 #include <ipxe/api.h>
00014 #include <config/ioapi.h>
00015 
00016 /**
00017  * Calculate static inline PCI I/O API function name
00018  *
00019  * @v _prefix           Subsystem prefix
00020  * @v _api_func         API function
00021  * @ret _subsys_func    Subsystem API function
00022  */
00023 #define PCIAPI_INLINE( _subsys, _api_func ) \
00024         SINGLE_API_INLINE ( PCIAPI_PREFIX_ ## _subsys, _api_func )
00025 
00026 /**
00027  * Provide a PCI I/O API implementation
00028  *
00029  * @v _prefix           Subsystem prefix
00030  * @v _api_func         API function
00031  * @v _func             Implementing function
00032  */
00033 #define PROVIDE_PCIAPI( _subsys, _api_func, _func ) \
00034         PROVIDE_SINGLE_API ( PCIAPI_PREFIX_ ## _subsys, _api_func, _func )
00035 
00036 /**
00037  * Provide a static inline PCI I/O API implementation
00038  *
00039  * @v _prefix           Subsystem prefix
00040  * @v _api_func         API function
00041  */
00042 #define PROVIDE_PCIAPI_INLINE( _subsys, _api_func ) \
00043         PROVIDE_SINGLE_API_INLINE ( PCIAPI_PREFIX_ ## _subsys, _api_func )
00044 
00045 /* Include all architecture-independent I/O API headers */
00046 #include <ipxe/efi/efi_pci_api.h>
00047 #include <ipxe/linux/linux_pci.h>
00048 
00049 /* Include all architecture-dependent I/O API headers */
00050 #include <bits/pci_io.h>
00051 
00052 /**
00053  * Determine number of PCI buses within system
00054  *
00055  * @ret num_bus         Number of buses
00056  */
00057 int pci_num_bus ( void );
00058 
00059 /**
00060  * Read byte from PCI configuration space
00061  *
00062  * @v pci       PCI device
00063  * @v where     Location within PCI configuration space
00064  * @v value     Value read
00065  * @ret rc      Return status code
00066  */
00067 int pci_read_config_byte ( struct pci_device *pci, unsigned int where,
00068                            uint8_t *value );
00069 
00070 /**
00071  * Read 16-bit word from PCI configuration space
00072  *
00073  * @v pci       PCI device
00074  * @v where     Location within PCI configuration space
00075  * @v value     Value read
00076  * @ret rc      Return status code
00077  */
00078 int pci_read_config_word ( struct pci_device *pci, unsigned int where,
00079                            uint16_t *value );
00080 
00081 /**
00082  * Read 32-bit dword from PCI configuration space
00083  *
00084  * @v pci       PCI device
00085  * @v where     Location within PCI configuration space
00086  * @v value     Value read
00087  * @ret rc      Return status code
00088  */
00089 int pci_read_config_dword ( struct pci_device *pci, unsigned int where,
00090                             uint32_t *value );
00091 
00092 /**
00093  * Write byte to PCI configuration space
00094  *
00095  * @v pci       PCI device
00096  * @v where     Location within PCI configuration space
00097  * @v value     Value to be written
00098  * @ret rc      Return status code
00099  */
00100 int pci_write_config_byte ( struct pci_device *pci, unsigned int where,
00101                             uint8_t value );
00102 
00103 /**
00104  * Write 16-bit word to PCI configuration space
00105  *
00106  * @v pci       PCI device
00107  * @v where     Location within PCI configuration space
00108  * @v value     Value to be written
00109  * @ret rc      Return status code
00110  */
00111 int pci_write_config_word ( struct pci_device *pci, unsigned int where,
00112                             uint16_t value );
00113 
00114 /**
00115  * Write 32-bit dword to PCI configuration space
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 int pci_write_config_dword ( struct pci_device *pci, unsigned int where,
00123                              uint32_t value );
00124 
00125 #endif /* _IPXE_PCI_IO_H */