diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-10-09 12:47:31 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-10-09 12:47:31 +0100 |
commit | b79e6e11f8aee9491f6cf60ae21669ce66d4b4e4 (patch) | |
tree | 4639a38cc62af9e8844a56dc3412e193a85f3ed5 /xen/drivers/pci | |
parent | aa2c2fc5085c008e6401037eca683a55be374ec5 (diff) | |
download | xen-b79e6e11f8aee9491f6cf60ae21669ce66d4b4e4.tar.gz xen-b79e6e11f8aee9491f6cf60ae21669ce66d4b4e4.tar.bz2 xen-b79e6e11f8aee9491f6cf60ae21669ce66d4b4e4.zip |
vtd: Make some pci access functions architecture independent.
Signed-off-by: Anthony Xu <anthony.xu@intel.com>
Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
Diffstat (limited to 'xen/drivers/pci')
-rw-r--r-- | xen/drivers/pci/Makefile | 1 | ||||
-rw-r--r-- | xen/drivers/pci/pci.c | 64 |
2 files changed, 65 insertions, 0 deletions
diff --git a/xen/drivers/pci/Makefile b/xen/drivers/pci/Makefile new file mode 100644 index 0000000000..a98035df4c --- /dev/null +++ b/xen/drivers/pci/Makefile @@ -0,0 +1 @@ +obj-y += pci.o diff --git a/xen/drivers/pci/pci.c b/xen/drivers/pci/pci.c new file mode 100644 index 0000000000..278f6b536d --- /dev/null +++ b/xen/drivers/pci/pci.c @@ -0,0 +1,64 @@ +/****************************************************************************** + * pci.c + * + * Architecture-independent PCI access functions. + */ + +#include <xen/pci.h> +#include <xen/pci_regs.h> + +int pci_find_cap_offset(u8 bus, u8 dev, u8 func, u8 cap) +{ + u8 id; + int max_cap = 48; + u8 pos = PCI_CAPABILITY_LIST; + u16 status; + + status = pci_conf_read16(bus, dev, func, PCI_STATUS); + if ( (status & PCI_STATUS_CAP_LIST) == 0 ) + return 0; + + while ( max_cap-- ) + { + pos = pci_conf_read8(bus, dev, func, pos); + if ( pos < 0x40 ) + break; + + pos &= ~3; + id = pci_conf_read8(bus, dev, func, pos + PCI_CAP_LIST_ID); + + if ( id == 0xff ) + break; + else if ( id == cap ) + return pos; + + pos += PCI_CAP_LIST_NEXT; + } + + return 0; +} + +int pci_find_next_cap(u8 bus, unsigned int devfn, u8 pos, int cap) +{ + u8 id; + int ttl = 48; + + while ( ttl-- ) + { + pos = pci_conf_read8(bus, PCI_SLOT(devfn), PCI_FUNC(devfn), pos); + if ( pos < 0x40 ) + break; + + pos &= ~3; + id = pci_conf_read8(bus, PCI_SLOT(devfn), PCI_FUNC(devfn), + pos + PCI_CAP_LIST_ID); + + if ( id == 0xff ) + break; + if ( id == cap ) + return pos; + + pos += PCI_CAP_LIST_NEXT; + } + return 0; +} |