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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #ifndef _IPXE_PCI_IO_H
  2. #define _IPXE_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 <ipxe/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 <ipxe/efi/efi_pci_api.h>
  40. #include <ipxe/linux/linux_pci.h>
  41. /* Include all architecture-dependent I/O API headers */
  42. #include <bits/pci_io.h>
  43. /**
  44. * Determine number of PCI buses within system
  45. *
  46. * @ret num_bus Number of buses
  47. */
  48. int pci_num_bus ( void );
  49. /**
  50. * Read byte from PCI configuration space
  51. *
  52. * @v pci PCI device
  53. * @v where Location within PCI configuration space
  54. * @v value Value read
  55. * @ret rc Return status code
  56. */
  57. int pci_read_config_byte ( struct pci_device *pci, unsigned int where,
  58. uint8_t *value );
  59. /**
  60. * Read 16-bit word from PCI configuration space
  61. *
  62. * @v pci PCI device
  63. * @v where Location within PCI configuration space
  64. * @v value Value read
  65. * @ret rc Return status code
  66. */
  67. int pci_read_config_word ( struct pci_device *pci, unsigned int where,
  68. uint16_t *value );
  69. /**
  70. * Read 32-bit dword 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_dword ( struct pci_device *pci, unsigned int where,
  78. uint32_t *value );
  79. /**
  80. * Write byte to PCI configuration space
  81. *
  82. * @v pci PCI device
  83. * @v where Location within PCI configuration space
  84. * @v value Value to be written
  85. * @ret rc Return status code
  86. */
  87. int pci_write_config_byte ( struct pci_device *pci, unsigned int where,
  88. uint8_t value );
  89. /**
  90. * Write 16-bit word to PCI configuration space
  91. *
  92. * @v pci PCI device
  93. * @v where Location within PCI configuration space
  94. * @v value Value to be written
  95. * @ret rc Return status code
  96. */
  97. int pci_write_config_word ( struct pci_device *pci, unsigned int where,
  98. uint16_t value );
  99. /**
  100. * Write 32-bit dword to PCI configuration space
  101. *
  102. * @v pci PCI device
  103. * @v where Location within PCI configuration space
  104. * @v value Value to be written
  105. * @ret rc Return status code
  106. */
  107. int pci_write_config_dword ( struct pci_device *pci, unsigned int where,
  108. uint32_t value );
  109. #endif /* _IPXE_PCI_IO_H */