[PATCH kvm-unit-tests 09/17] pci: add pci_config_write[wb]()

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

 



We have writel() for 4 bytes but still missing 2/1 bytes accessors.

Signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
---
 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

--
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