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.

pcimsix.h 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef _IPXE_PCIMSIX_H
  2. #define _IPXE_PCIMSIX_H
  3. /** @file
  4. *
  5. * PCI MSI-X interrupts
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <ipxe/pci.h>
  10. /** MSI-X BAR mapped length */
  11. #define PCI_MSIX_LEN 0x1000
  12. /** MSI-X vector offset */
  13. #define PCI_MSIX_VECTOR(n) ( (n) * 0x10 )
  14. /** MSI-X vector address low 32 bits */
  15. #define PCI_MSIX_ADDRESS_LO 0x0
  16. /** MSI-X vector address high 32 bits */
  17. #define PCI_MSIX_ADDRESS_HI 0x4
  18. /** MSI-X vector data */
  19. #define PCI_MSIX_DATA 0x8
  20. /** MSI-X vector control */
  21. #define PCI_MSIX_CONTROL 0xc
  22. #define PCI_MSIX_CONTROL_MASK 0x00000001 /**< Vector is masked */
  23. /** PCI MSI-X capability */
  24. struct pci_msix {
  25. /** Capability offset */
  26. unsigned int cap;
  27. /** Number of vectors */
  28. unsigned int count;
  29. /** MSI-X table */
  30. void *table;
  31. /** Pending bit array */
  32. void *pba;
  33. };
  34. extern int pci_msix_enable ( struct pci_device *pci, struct pci_msix *msix );
  35. extern void pci_msix_disable ( struct pci_device *pci, struct pci_msix *msix );
  36. extern void pci_msix_map ( struct pci_msix *msix, unsigned int vector,
  37. physaddr_t address, uint32_t data );
  38. extern void pci_msix_control ( struct pci_msix *msix, unsigned int vector,
  39. uint32_t mask );
  40. extern void pci_msix_dump ( struct pci_msix *msix, unsigned int vector );
  41. /**
  42. * Mask MSI-X interrupt vector
  43. *
  44. * @v msix MSI-X capability
  45. * @v vector MSI-X vector
  46. */
  47. static inline __attribute__ (( always_inline )) void
  48. pci_msix_mask ( struct pci_msix *msix, unsigned int vector ) {
  49. pci_msix_control ( msix, vector, PCI_MSIX_CONTROL_MASK );
  50. }
  51. /**
  52. * Unmask MSI-X interrupt vector
  53. *
  54. * @v msix MSI-X capability
  55. * @v vector MSI-X vector
  56. */
  57. static inline __attribute__ (( always_inline )) void
  58. pci_msix_unmask ( struct pci_msix *msix, unsigned int vector ) {
  59. pci_msix_control ( msix, vector, 0 );
  60. }
  61. #endif /* _IPXE_PCIMSIX_H */