Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

efi_pci.h 3.7KB

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