Re: [kvm-unit-tests PATCH 08/14] x86: pci: add pci_config_{read|write}[bw]() helpers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 14, 2016 at 08:40:46PM +0800, Peter Xu wrote:
> And some cleanup on the file.
> 
> Signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
> ---
>  lib/x86/asm/pci.h | 37 ++++++++++++++++++++++++++++++++++---
>  1 file changed, 34 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/x86/asm/pci.h b/lib/x86/asm/pci.h
> index cddde41..ce970e4 100644
> --- a/lib/x86/asm/pci.h
> +++ b/lib/x86/asm/pci.h
> @@ -9,11 +9,42 @@
>  #include "pci.h"
>  #include "x86/asm/io.h"
>  
> +#define PCI_HOST_CONFIG_PORT (0xcf8)
> +#define PCI_HOST_DATA_PORT   (0xcfc)

Thomas wanted to do this to, but I disagreed because CF8/CFC are
effectively the names already.

Alex already has a patch in his series just like this one
"pci: x86: Add remaining PCI configuration space accessors"

drew

> +
> +#define PCI_HOST_INDEX(dev, reg)   (reg | (dev << 8) | (0x1 << 31))
> +
> +#define pci_config_readb(dev, reg) (pci_config_read(dev, reg) & 0xff)
> +#define pci_config_readw(dev, reg) (pci_config_read(dev, reg) & 0xffff)
> +
>  static inline uint32_t pci_config_read(pcidevaddr_t dev, uint8_t reg)
>  {
> -    uint32_t index = reg | (dev << 8) | (0x1 << 31);
> -    outl(index, 0xCF8);
> -    return inl(0xCFC);
> +	uint32_t index = PCI_HOST_INDEX(dev, reg);
> +	outl(index, PCI_HOST_CONFIG_PORT);
> +	return inl(PCI_HOST_DATA_PORT);
> +}
> +
> +static inline void pci_config_write(pcidevaddr_t dev, uint8_t reg,
> +				    uint32_t val)
> +{
> +	uint32_t index = PCI_HOST_INDEX(dev, reg);
> +	outl(index, PCI_HOST_CONFIG_PORT);
> +	outl(val, PCI_HOST_DATA_PORT);
>  }
>  
> +static inline void pci_config_writeb(pcidevaddr_t dev, uint8_t reg,
> +				     uint8_t val)
> +{
> +	uint32_t index = PCI_HOST_INDEX(dev, reg);
> +	outl(index, PCI_HOST_CONFIG_PORT);
> +	outb(val, PCI_HOST_DATA_PORT);
> +}
> +
> +static inline void pci_config_writew(pcidevaddr_t dev, uint8_t reg,
> +				     uint16_t val)
> +{
> +	uint32_t index = PCI_HOST_INDEX(dev, reg);
> +	outl(index, PCI_HOST_CONFIG_PORT);
> +	outw(val, PCI_HOST_DATA_PORT);
> +}
>  #endif
> -- 
> 2.7.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux