You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pci_io.h 3.0KB

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