Home | History | Annotate | Download | only in gpxe
      1 #ifndef _GPXE_PCI_IO_H
      2 #define _GPXE_PCI_IO_H
      3 
      4 /** @file
      5  *
      6  * PCI I/O API
      7  *
      8  */
      9 
     10 FILE_LICENCE ( GPL2_OR_LATER );
     11 
     12 #include <stdint.h>
     13 #include <gpxe/api.h>
     14 #include <config/ioapi.h>
     15 
     16 /**
     17  * Calculate static inline PCI I/O API function name
     18  *
     19  * @v _prefix		Subsystem prefix
     20  * @v _api_func		API function
     21  * @ret _subsys_func	Subsystem API function
     22  */
     23 #define PCIAPI_INLINE( _subsys, _api_func ) \
     24 	SINGLE_API_INLINE ( PCIAPI_PREFIX_ ## _subsys, _api_func )
     25 
     26 /**
     27  * Provide a PCI I/O API implementation
     28  *
     29  * @v _prefix		Subsystem prefix
     30  * @v _api_func		API function
     31  * @v _func		Implementing function
     32  */
     33 #define PROVIDE_PCIAPI( _subsys, _api_func, _func ) \
     34 	PROVIDE_SINGLE_API ( PCIAPI_PREFIX_ ## _subsys, _api_func, _func )
     35 
     36 /**
     37  * Provide a static inline PCI I/O API implementation
     38  *
     39  * @v _prefix		Subsystem prefix
     40  * @v _api_func		API function
     41  */
     42 #define PROVIDE_PCIAPI_INLINE( _subsys, _api_func ) \
     43 	PROVIDE_SINGLE_API_INLINE ( PCIAPI_PREFIX_ ## _subsys, _api_func )
     44 
     45 /* Include all architecture-independent I/O API headers */
     46 #include <gpxe/efi/efi_pci.h>
     47 
     48 /* Include all architecture-dependent I/O API headers */
     49 #include <bits/pci_io.h>
     50 
     51 /**
     52  * Determine maximum PCI bus number within system
     53  *
     54  * @ret max_bus		Maximum bus number
     55  */
     56 int pci_max_bus ( void );
     57 
     58 /**
     59  * Read byte from PCI configuration space
     60  *
     61  * @v pci	PCI device
     62  * @v where	Location within PCI configuration space
     63  * @v value	Value read
     64  * @ret rc	Return status code
     65  */
     66 int pci_read_config_byte ( struct pci_device *pci, unsigned int where,
     67 			   uint8_t *value );
     68 
     69 /**
     70  * Read 16-bit word from PCI configuration space
     71  *
     72  * @v pci	PCI device
     73  * @v where	Location within PCI configuration space
     74  * @v value	Value read
     75  * @ret rc	Return status code
     76  */
     77 int pci_read_config_word ( struct pci_device *pci, unsigned int where,
     78 			   uint16_t *value );
     79 
     80 /**
     81  * Read 32-bit dword from PCI configuration space
     82  *
     83  * @v pci	PCI device
     84  * @v where	Location within PCI configuration space
     85  * @v value	Value read
     86  * @ret rc	Return status code
     87  */
     88 int pci_read_config_dword ( struct pci_device *pci, unsigned int where,
     89 			    uint32_t *value );
     90 
     91 /**
     92  * Write byte to PCI configuration space
     93  *
     94  * @v pci	PCI device
     95  * @v where	Location within PCI configuration space
     96  * @v value	Value to be written
     97  * @ret rc	Return status code
     98  */
     99 int pci_write_config_byte ( struct pci_device *pci, unsigned int where,
    100 			    uint8_t value );
    101 
    102 /**
    103  * Write 16-bit word to PCI configuration space
    104  *
    105  * @v pci	PCI device
    106  * @v where	Location within PCI configuration space
    107  * @v value	Value to be written
    108  * @ret rc	Return status code
    109  */
    110 int pci_write_config_word ( struct pci_device *pci, unsigned int where,
    111 			    uint16_t value );
    112 
    113 /**
    114  * Write 32-bit dword to PCI configuration space
    115  *
    116  * @v pci	PCI device
    117  * @v where	Location within PCI configuration space
    118  * @v value	Value to be written
    119  * @ret rc	Return status code
    120  */
    121 int pci_write_config_dword ( struct pci_device *pci, unsigned int where,
    122 			     uint32_t value );
    123 
    124 #endif /* _GPXE_PCI_IO_H */
    125