Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #ifndef _GPXE_EFI_PCI_H
  2. #define _GPXE_EFI_PCI_H
  3. /** @file
  4. *
  5. * gPXE PCI I/O API for EFI
  6. *
  7. */
  8. #ifdef PCIAPI_EFI
  9. #define PCIAPI_PREFIX_efi
  10. #else
  11. #define PCIAPI_PREFIX_efi __efi_
  12. #endif
  13. /* EFI PCI width codes defined by EFI spec */
  14. #define EFIPCI_WIDTH_BYTE 0
  15. #define EFIPCI_WIDTH_WORD 1
  16. #define EFIPCI_WIDTH_DWORD 2
  17. #define EFIPCI_LOCATION( _offset, _width ) \
  18. ( (_offset) | ( (_width) << 16 ) )
  19. #define EFIPCI_OFFSET( _location ) ( (_location) & 0xffff )
  20. #define EFIPCI_WIDTH( _location ) ( (_location) >> 16 )
  21. struct pci_device;
  22. extern int efipci_read ( struct pci_device *pci, unsigned long location,
  23. void *value );
  24. extern int efipci_write ( struct pci_device *pci, unsigned long location,
  25. unsigned long value );
  26. /**
  27. * Determine maximum PCI bus number within system
  28. *
  29. * @ret max_bus Maximum bus number
  30. */
  31. static inline __always_inline int
  32. PCIAPI_INLINE ( efi, pci_max_bus ) ( void ) {
  33. /* No way to work this out via EFI */
  34. return 0xff;
  35. }
  36. /**
  37. * Read byte from PCI configuration space via EFI
  38. *
  39. * @v pci PCI device
  40. * @v where Location within PCI configuration space
  41. * @v value Value read
  42. * @ret rc Return status code
  43. */
  44. static inline __always_inline int
  45. PCIAPI_INLINE ( efi, pci_read_config_byte ) ( struct pci_device *pci,
  46. unsigned int where,
  47. uint8_t *value ) {
  48. return efipci_read ( pci,
  49. EFIPCI_LOCATION ( where, EFIPCI_WIDTH_BYTE ),
  50. value );
  51. }
  52. /**
  53. * Read word from PCI configuration space via EFI
  54. *
  55. * @v pci PCI device
  56. * @v where Location within PCI configuration space
  57. * @v value Value read
  58. * @ret rc Return status code
  59. */
  60. static inline __always_inline int
  61. PCIAPI_INLINE ( efi, pci_read_config_word ) ( struct pci_device *pci,
  62. unsigned int where,
  63. uint16_t *value ) {
  64. return efipci_read ( pci,
  65. EFIPCI_LOCATION ( where, EFIPCI_WIDTH_WORD ),
  66. value );
  67. }
  68. /**
  69. * Read dword from PCI configuration space via EFI
  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. static inline __always_inline int
  77. PCIAPI_INLINE ( efi, pci_read_config_dword ) ( struct pci_device *pci,
  78. unsigned int where,
  79. uint32_t *value ) {
  80. return efipci_read ( pci,
  81. EFIPCI_LOCATION ( where, EFIPCI_WIDTH_DWORD ),
  82. value );
  83. }
  84. /**
  85. * Write byte to PCI configuration space via EFI
  86. *
  87. * @v pci PCI device
  88. * @v where Location within PCI configuration space
  89. * @v value Value to be written
  90. * @ret rc Return status code
  91. */
  92. static inline __always_inline int
  93. PCIAPI_INLINE ( efi, pci_write_config_byte ) ( struct pci_device *pci,
  94. unsigned int where,
  95. uint8_t value ) {
  96. return efipci_write ( pci,
  97. EFIPCI_LOCATION ( where, EFIPCI_WIDTH_BYTE ),
  98. value );
  99. }
  100. /**
  101. * Write word to PCI configuration space via EFI
  102. *
  103. * @v pci PCI device
  104. * @v where Location within PCI configuration space
  105. * @v value Value to be written
  106. * @ret rc Return status code
  107. */
  108. static inline __always_inline int
  109. PCIAPI_INLINE ( efi, pci_write_config_word ) ( struct pci_device *pci,
  110. unsigned int where,
  111. uint16_t value ) {
  112. return efipci_write ( pci,
  113. EFIPCI_LOCATION ( where, EFIPCI_WIDTH_WORD ),
  114. value );
  115. }
  116. /**
  117. * Write dword to PCI configuration space via EFI
  118. *
  119. * @v pci PCI device
  120. * @v where Location within PCI configuration space
  121. * @v value Value to be written
  122. * @ret rc Return status code
  123. */
  124. static inline __always_inline int
  125. PCIAPI_INLINE ( efi, pci_write_config_dword ) ( struct pci_device *pci,
  126. unsigned int where,
  127. uint32_t value ) {
  128. return efipci_write ( pci,
  129. EFIPCI_LOCATION ( where, EFIPCI_WIDTH_DWORD ),
  130. value );
  131. }
  132. #endif /* _GPXE_EFI_PCI_H */