]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm: Initial PCI probe emulation
authorPekka Enberg <penberg@cs.helsinki.fi>
Sat, 31 Jul 2010 12:52:43 +0000 (15:52 +0300)
committerPekka Enberg <penberg@cs.helsinki.fi>
Sat, 31 Jul 2010 13:11:18 +0000 (16:11 +0300)
This patch adds simple PCI Configuration Mechanism 1 probing emulation. It
doesn't expose any actual PCI devices yet.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
tools/kvm/Makefile
tools/kvm/include/kvm/pci.h [new file with mode: 0644]
tools/kvm/main.c
tools/kvm/pci.c [new file with mode: 0644]

index ae5589e52c6cc576ba74f76dd8ddbbb6349d18a4..67193b32578a6bd831107440f5ba42b7304b6a9b 100644 (file)
@@ -16,6 +16,7 @@ OBJS  += ioport.o
 OBJS   += kvm.o
 OBJS   += main.o
 OBJS   += mmio.o
+OBJS   += pci.o
 OBJS   += util.o
 
 DEPS   := $(patsubst %.o,%.d,$(OBJS))
diff --git a/tools/kvm/include/kvm/pci.h b/tools/kvm/include/kvm/pci.h
new file mode 100644 (file)
index 0000000..6f0c05a
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef KVM__PCI_H
+#define KVM__PCI_H
+
+void pci__init(void);
+
+#endif /* KVM__PCI_H */
index 295f65dd115f6a497676158adeadcab20a29b905..d55194a96811e4f9b57c2e48aa94569092ad8d0b 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "kvm/early_printk.h"
 #include "kvm/util.h"
+#include "kvm/pci.h"
 
 #include <inttypes.h>
 #include <signal.h>
@@ -110,6 +111,7 @@ int main(int argc, char *argv[])
                kvm__enable_singlestep(kvm);
 
        early_printk__init();
+       pci__init();
 
        for (;;) {
                kvm__run(kvm);
diff --git a/tools/kvm/pci.c b/tools/kvm/pci.c
new file mode 100644 (file)
index 0000000..2c49df9
--- /dev/null
@@ -0,0 +1,51 @@
+#include "kvm/pci.h"
+
+#include "kvm/ioport.h"
+
+#include <stdint.h>
+
+static uint32_t pci_cse;       /* PCI configuration space enable */
+
+static bool pci_cse_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+{
+       uint32_t *p = data;
+
+       pci_cse         = *p;
+
+       return true;
+}
+
+static bool pci_cse_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+{
+       uint32_t *p = data;
+
+       *p              = pci_cse;
+
+       return true;
+}
+
+static struct ioport_operations pci_cse_ops = {
+       .io_in          = pci_cse_in,
+       .io_out         = pci_cse_out,
+};
+
+static bool pci_mechanism_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+{
+       return true;
+}
+
+static bool pci_mechanism_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+{
+       return true;
+}
+
+static struct ioport_operations pci_mechanism_ops = {
+       .io_in          = pci_mechanism_in,
+       .io_out         = pci_mechanism_out,
+};
+
+void pci__init(void)
+{
+       ioport__register(0xcfb, &pci_mechanism_ops);
+       ioport__register(0xcf8, &pci_cse_ops);
+}