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 2.9KB

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