aboutsummaryrefslogtreecommitdiff
path: root/include/pci.h
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-05-20 17:09:34 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2015-05-21 11:44:57 +0200
commiteaae11e17f022188755c67e4dd3436875e84110d (patch)
tree35625017b95776f3eb2470705cb3af2b44687548 /include/pci.h
parentedba90fb16ec7224da591ab8f83efe3673853a3f (diff)
downloadqboot-eaae11e17f022188755c67e4dd3436875e84110d.zip
qboot-eaae11e17f022188755c67e4dd3436875e84110d.tar.gz
qboot-eaae11e17f022188755c67e4dd3436875e84110d.tar.bz2
make a bootable BIOS
includes source from kvm-unit-tests Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/pci.h')
-rw-r--r--include/pci.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/include/pci.h b/include/pci.h
new file mode 100644
index 0000000..e6b445c
--- /dev/null
+++ b/include/pci.h
@@ -0,0 +1,44 @@
+#ifndef _PCI_H
+#define _PCI_H
+
+#include "ioport.h"
+
+static inline void pci_config_writel(uint16_t bdf, uint32_t addr, uint32_t val)
+{
+ outl(0xcf8, 0x80000000 | (bdf << 8) | (addr & 0xfc));
+ outl(0xcfc, val);
+}
+
+void pci_config_writew(uint16_t bdf, uint32_t addr, uint16_t val)
+{
+ outl(0xcf8, 0x80000000 | (bdf << 8) | (addr & 0xfc));
+ outw(0xcfc | (addr & 2), val);
+}
+
+void pci_config_writeb(uint16_t bdf, uint32_t addr, uint8_t val)
+{
+ outl(0xcf8, 0x80000000 | (bdf << 8) | (addr & 0xfc));
+ outb(0xcfc | (addr & 3), val);
+}
+
+uint32_t pci_config_readl(uint16_t bdf, uint32_t addr)
+{
+ outl(0xcf8, 0x80000000 | (bdf << 8) | (addr & 0xfc));
+ return inl(0xcfc);
+}
+
+uint16_t pci_config_readw(uint16_t bdf, uint32_t addr)
+{
+ outl(0xcf8, 0x80000000 | (bdf << 8) | (addr & 0xfc));
+ return inw(0xcfc | (addr & 2));
+}
+
+uint8_t pci_config_readb(uint16_t bdf, uint32_t addr)
+{
+ outl(0xcf8, 0x80000000 | (bdf << 8) | (addr & 0xfc));
+ return inb(0xcfc | (addr & 3));
+}
+
+#define PCI_VENDOR_ID 0
+
+#endif