From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Xu Subject: [PATCH kvm-unit-tests 09/17] pci: add pci_config_write[wb]() Date: Wed, 26 Oct 2016 15:47:12 +0800 Message-ID: <1477468040-21034-10-git-send-email-peterx@redhat.com> References: <1477468040-21034-1-git-send-email-peterx@redhat.com> Cc: drjones@redhat.com, rkrcmar@redhat.com, peterx@redhat.com, agordeev@redhat.com, jan.kiszka@web.de, pbonzini@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:53282 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753599AbcJZHsF (ORCPT ); Wed, 26 Oct 2016 03:48:05 -0400 In-Reply-To: <1477468040-21034-1-git-send-email-peterx@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: We have writel() for 4 bytes but still missing 2/1 bytes accessors. Signed-off-by: Peter Xu --- lib/pci-host-generic.c | 12 ++++++++++++ lib/x86/asm/pci.h | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/pci-host-generic.c b/lib/pci-host-generic.c index be3f9e7..c04e4f5 100644 --- a/lib/pci-host-generic.c +++ b/lib/pci-host-generic.c @@ -291,6 +291,18 @@ u32 pci_config_readl(pcidevaddr_t dev, u8 off) return readl(conf + off); } +void pci_config_writeb(pcidevaddr_t dev, u8 off, u8 val) +{ + void __iomem *conf = pci_get_dev_conf(pci_host_bridge, dev); + writeb(val, conf + off); +} + +void pci_config_writew(pcidevaddr_t dev, u8 off, u16 val) +{ + void __iomem *conf = pci_get_dev_conf(pci_host_bridge, dev); + writew(val, conf + off); +} + void pci_config_writel(pcidevaddr_t dev, u8 off, u32 val) { void __iomem *conf = pci_get_dev_conf(pci_host_bridge, dev); diff --git a/lib/x86/asm/pci.h b/lib/x86/asm/pci.h index 7384b91..abfe5d1 100644 --- a/lib/x86/asm/pci.h +++ b/lib/x86/asm/pci.h @@ -29,6 +29,20 @@ static inline uint32_t pci_config_readl(pcidevaddr_t dev, uint8_t reg) return inl(0xCFC); } +static inline void pci_config_writeb(pcidevaddr_t dev, uint8_t reg, + uint8_t val) +{ + outl(PCI_CONF1_ADDRESS(dev, reg), 0xCF8); + outb(val, 0xCFC); +} + +static inline void pci_config_writew(pcidevaddr_t dev, uint8_t reg, + uint32_t val) +{ + outl(PCI_CONF1_ADDRESS(dev, reg), 0xCF8); + outw(val, 0xCFC); +} + static inline void pci_config_writel(pcidevaddr_t dev, uint8_t reg, uint32_t val) { outl(PCI_CONF1_ADDRESS(dev, reg), 0xCF8); -- 2.7.4