iPXE
pcimsix.h
Go to the documentation of this file.
00001 #ifndef _IPXE_PCIMSIX_H
00002 #define _IPXE_PCIMSIX_H
00003 
00004 /** @file
00005  *
00006  * PCI MSI-X interrupts
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <ipxe/pci.h>
00013 
00014 /** MSI-X BAR mapped length */
00015 #define PCI_MSIX_LEN 0x1000
00016 
00017 /** MSI-X vector offset */
00018 #define PCI_MSIX_VECTOR(n) ( (n) * 0x10 )
00019 
00020 /** MSI-X vector address low 32 bits */
00021 #define PCI_MSIX_ADDRESS_LO 0x0
00022 
00023 /** MSI-X vector address high 32 bits */
00024 #define PCI_MSIX_ADDRESS_HI 0x4
00025 
00026 /** MSI-X vector data */
00027 #define PCI_MSIX_DATA 0x8
00028 
00029 /** MSI-X vector control */
00030 #define PCI_MSIX_CONTROL 0xc
00031 #define PCI_MSIX_CONTROL_MASK 0x00000001        /**< Vector is masked */
00032 
00033 /** PCI MSI-X capability */
00034 struct pci_msix {
00035         /** Capability offset */
00036         unsigned int cap;
00037         /** Number of vectors */
00038         unsigned int count;
00039         /** MSI-X table */
00040         void *table;
00041         /** Pending bit array */
00042         void *pba;
00043 };
00044 
00045 extern int pci_msix_enable ( struct pci_device *pci, struct pci_msix *msix );
00046 extern void pci_msix_disable ( struct pci_device *pci, struct pci_msix *msix );
00047 extern void pci_msix_map ( struct pci_msix *msix, unsigned int vector,
00048                            physaddr_t address, uint32_t data );
00049 extern void pci_msix_control ( struct pci_msix *msix, unsigned int vector,
00050                                uint32_t mask );
00051 extern void pci_msix_dump ( struct pci_msix *msix, unsigned int vector );
00052 
00053 /**
00054  * Mask MSI-X interrupt vector
00055  *
00056  * @v msix              MSI-X capability
00057  * @v vector            MSI-X vector
00058  */
00059 static inline __attribute__ (( always_inline )) void
00060 pci_msix_mask ( struct pci_msix *msix, unsigned int vector ) {
00061 
00062         pci_msix_control ( msix, vector, PCI_MSIX_CONTROL_MASK );
00063 }
00064 
00065 /**
00066  * Unmask MSI-X interrupt vector
00067  *
00068  * @v msix              MSI-X capability
00069  * @v vector            MSI-X vector
00070  */
00071 static inline __attribute__ (( always_inline )) void
00072 pci_msix_unmask ( struct pci_msix *msix, unsigned int vector ) {
00073 
00074         pci_msix_control ( msix, vector, 0 );
00075 }
00076 
00077 #endif /* _IPXE_PCIMSIX_H */