Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

pcibios.h 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #ifndef _PCIBIOS_H
  2. #define _PCIBIOS_H
  3. #include <stdint.h>
  4. /** @file
  5. *
  6. * PCI configuration space access via PCI BIOS
  7. *
  8. */
  9. struct pci_device;
  10. #define PCIBIOS_INSTALLATION_CHECK 0xb1010000
  11. #define PCIBIOS_READ_CONFIG_BYTE 0xb1080000
  12. #define PCIBIOS_READ_CONFIG_WORD 0xb1090000
  13. #define PCIBIOS_READ_CONFIG_DWORD 0xb10a0000
  14. #define PCIBIOS_WRITE_CONFIG_BYTE 0xb10b0000
  15. #define PCIBIOS_WRITE_CONFIG_WORD 0xb10c0000
  16. #define PCIBIOS_WRITE_CONFIG_DWORD 0xb10d0000
  17. extern int pcibios_max_bus ( void );
  18. extern int pcibios_read ( struct pci_device *pci, uint32_t command,
  19. uint32_t *value );
  20. extern int pcibios_write ( struct pci_device *pci, uint32_t command,
  21. uint32_t value );
  22. /**
  23. * Read byte from PCI configuration space via PCI BIOS
  24. *
  25. * @v pci PCI device
  26. * @v where Location within PCI configuration space
  27. * @v value Value read
  28. * @ret rc Return status code
  29. */
  30. static inline __attribute__ (( always_inline )) int
  31. pcibios_read_config_byte ( struct pci_device *pci, unsigned int where,
  32. uint8_t *value ) {
  33. uint32_t tmp;
  34. int rc;
  35. rc = pcibios_read ( pci, PCIBIOS_READ_CONFIG_BYTE | where, &tmp );
  36. *value = tmp;
  37. return rc;
  38. }
  39. /**
  40. * Read word from PCI configuration space via PCI BIOS
  41. *
  42. * @v pci PCI device
  43. * @v where Location within PCI configuration space
  44. * @v value Value read
  45. * @ret rc Return status code
  46. */
  47. static inline __attribute__ (( always_inline )) int
  48. pcibios_read_config_word ( struct pci_device *pci, unsigned int where,
  49. uint16_t *value ) {
  50. uint32_t tmp;
  51. int rc;
  52. rc = pcibios_read ( pci, PCIBIOS_READ_CONFIG_WORD | where, &tmp );
  53. *value = tmp;
  54. return rc;
  55. }
  56. /**
  57. * Read dword from PCI configuration space via PCI BIOS
  58. *
  59. * @v pci PCI device
  60. * @v where Location within PCI configuration space
  61. * @v value Value read
  62. * @ret rc Return status code
  63. */
  64. static inline __attribute__ (( always_inline )) int
  65. pcibios_read_config_dword ( struct pci_device *pci, unsigned int where,
  66. uint32_t *value ) {
  67. return pcibios_read ( pci, PCIBIOS_READ_CONFIG_DWORD | where, value );
  68. }
  69. /**
  70. * Write byte to PCI configuration space via PCI BIOS
  71. *
  72. * @v pci PCI device
  73. * @v where Location within PCI configuration space
  74. * @v value Value to be written
  75. * @ret rc Return status code
  76. */
  77. static inline __attribute__ (( always_inline )) int
  78. pcibios_write_config_byte ( struct pci_device *pci, unsigned int where,
  79. uint8_t value ) {
  80. return pcibios_write ( pci, PCIBIOS_WRITE_CONFIG_BYTE | where, value );
  81. }
  82. /**
  83. * Write word to PCI configuration space via PCI BIOS
  84. *
  85. * @v pci PCI device
  86. * @v where Location within PCI configuration space
  87. * @v value Value to be written
  88. * @ret rc Return status code
  89. */
  90. static inline __attribute__ (( always_inline )) int
  91. pcibios_write_config_word ( struct pci_device *pci, unsigned int where,
  92. uint16_t value ) {
  93. return pcibios_write ( pci, PCIBIOS_WRITE_CONFIG_WORD | where, value );
  94. }
  95. /**
  96. * Write dword to PCI configuration space via PCI BIOS
  97. *
  98. * @v pci PCI device
  99. * @v where Location within PCI configuration space
  100. * @v value Value to be written
  101. * @ret rc Return status code
  102. */
  103. static inline __attribute__ (( always_inline )) int
  104. pcibios_write_config_dword ( struct pci_device *pci, unsigned int where,
  105. uint32_t value ) {
  106. return pcibios_write ( pci, PCIBIOS_WRITE_CONFIG_DWORD | where, value);
  107. }
  108. #endif /* _PCIBIOS_H */