Message ID | 1476448852-30062-9-git-send-email-peterx@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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@redhat.com> > --- > 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 -- 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
On Thu, Oct 20, 2016 at 02:43:21PM +0200, Andrew Jones wrote: > 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@redhat.com> > > --- > > 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" Right. Will drop this patch. I should mention it in the cover letter. Sorry! -- peterx -- 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
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) + +#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
And some cleanup on the file. Signed-off-by: Peter Xu <peterx@redhat.com> --- lib/x86/asm/pci.h | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-)