From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: Re: [kvm-unit-tests PATCH 08/14] x86: pci: add pci_config_{read|write}[bw]() helpers Date: Thu, 20 Oct 2016 14:43:21 +0200 Message-ID: <20161020124321.d2foxg3mszy2miuj@kamzik.brq.redhat.com> References: <1476448852-30062-1-git-send-email-peterx@redhat.com> <1476448852-30062-9-git-send-email-peterx@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, jan.kiszka@web.de, agordeev@redhat.com, rkrcmar@redhat.com, pbonzini@redhat.com To: Peter Xu Return-path: Received: from mx1.redhat.com ([209.132.183.28]:56604 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933043AbcJTMn0 (ORCPT ); Thu, 20 Oct 2016 08:43:26 -0400 Content-Disposition: inline In-Reply-To: <1476448852-30062-9-git-send-email-peterx@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Fri, Oct 14, 2016 at 08:40:46PM +0800, Peter Xu wrote: > And some cleanup on the file. > > Signed-off-by: Peter Xu > --- > 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@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html