From: Hollis Blanchard <[EMAIL PROTECTED]>

This will allow other architectures to share it, since main.c is x86-only.

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Avi Kivity <[EMAIL PROTECTED]>

diff --git a/user/config-powerpc.mak b/user/config-powerpc.mak
index 0fc7db7..0500bb8 100644
--- a/user/config-powerpc.mak
+++ b/user/config-powerpc.mak
@@ -20,7 +20,7 @@ tests := $(addprefix test/powerpc/, $(testobjs))
 
 all: kvmctl $(tests)
 
-kvmctl_objs = main-ppc.o ../libkvm/libkvm.a
+kvmctl_objs = main-ppc.o iotable.o ../libkvm/libkvm.a
 
 arch_clean:
        rm -f $(tests)
diff --git a/user/config-x86-common.mak b/user/config-x86-common.mak
index e44491c..7aad8d6 100644
--- a/user/config-x86-common.mak
+++ b/user/config-x86-common.mak
@@ -2,7 +2,7 @@
 
 all: kvmctl test_cases
 
-kvmctl_objs= main.o ../libkvm/libkvm.a
+kvmctl_objs= main.o iotable.o ../libkvm/libkvm.a
 
 balloon_ctl: balloon_ctl.o
 
diff --git a/user/iotable.c b/user/iotable.c
new file mode 100644
index 0000000..91a5016
--- /dev/null
+++ b/user/iotable.c
@@ -0,0 +1,53 @@
+/*
+ * Kernel-based Virtual Machine test driver
+ *
+ * This test driver provides a simple way of testing kvm, without a full
+ * device model.
+ *
+ * Copyright (C) 2006 Qumranet
+ *
+ * Authors:
+ *
+ *  Avi Kivity <[EMAIL PROTECTED]>
+ *  Yaniv Kamay <[EMAIL PROTECTED]>
+ *
+ * This work is licensed under the GNU LGPL license, version 2.
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <errno.h>
+
+#include "iotable.h"
+
+struct io_table_entry *io_table_lookup(struct io_table *io_table, uint64_t 
addr)
+{
+       int i;
+
+       for (i = 0; i < io_table->nr_entries; i++) {
+               if (io_table->entries[i].start <= addr &&
+                   addr < io_table->entries[i].end)
+                       return &io_table->entries[i];
+       }
+
+       return NULL;
+}
+
+int io_table_register(struct io_table *io_table, uint64_t start, uint64_t size,
+                     io_table_handler_t *handler, void *opaque)
+{
+       struct io_table_entry *entry;
+
+       if (io_table->nr_entries == MAX_IO_TABLE)
+               return -ENOSPC;
+
+       entry = &io_table->entries[io_table->nr_entries];
+       io_table->nr_entries++;
+
+       entry->start = start;
+       entry->end = start + size;
+       entry->handler = handler;
+       entry->opaque = opaque;
+
+       return 0;
+}
diff --git a/user/iotable.h b/user/iotable.h
new file mode 100644
index 0000000..cb18f23
--- /dev/null
+++ b/user/iotable.h
@@ -0,0 +1,40 @@
+/*
+ * Kernel-based Virtual Machine test driver
+ *
+ * This test driver provides a simple way of testing kvm, without a full
+ * device model.
+ *
+ * Copyright (C) 2006 Qumranet
+ *
+ * Authors:
+ *
+ *  Avi Kivity <[EMAIL PROTECTED]>
+ *  Yaniv Kamay <[EMAIL PROTECTED]>
+ *
+ * This work is licensed under the GNU LGPL license, version 2.
+ */
+
+#include <stdint.h>
+
+#define MAX_IO_TABLE   50
+
+typedef int (io_table_handler_t)(void *, int, int, uint64_t, uint64_t *);
+
+struct io_table_entry
+{
+       uint64_t start;
+       uint64_t end;
+       io_table_handler_t *handler;
+       void *opaque;
+};
+
+struct io_table
+{
+       int nr_entries;
+       struct io_table_entry entries[MAX_IO_TABLE];
+};
+
+struct io_table_entry *io_table_lookup(struct io_table *io_table,
+                                       uint64_t addr);
+int io_table_register(struct io_table *io_table, uint64_t start, uint64_t size,
+                      io_table_handler_t *handler, void *opaque);
diff --git a/user/main.c b/user/main.c
index a2d6b8b..9085899 100644
--- a/user/main.c
+++ b/user/main.c
@@ -36,6 +36,8 @@
 #include <getopt.h>
 #include <stdbool.h>
 
+#include "iotable.h"
+
 static uint8_t ioram[IORAM_LEN];
 
 static int gettid(void)
@@ -54,24 +56,6 @@ kvm_context_t kvm;
 
 #define IPI_SIGNAL (SIGRTMIN + 4)
 
-#define MAX_IO_TABLE   50
-
-typedef int (io_table_handler_t)(void *, int, int, uint64_t, uint64_t *);
-
-struct io_table_entry
-{
-       uint64_t start;
-       uint64_t end;
-       io_table_handler_t *handler;
-       void *opaque;
-};
-
-struct io_table
-{
-       int nr_entries;
-       struct io_table_entry entries[MAX_IO_TABLE];
-};
-
 static int ncpus = 1;
 static sem_t init_sem;
 static __thread int vcpu;
@@ -91,38 +75,6 @@ struct vcpu_info *vcpus;
 
 static uint32_t apic_sipi_addr;
 
-struct io_table_entry *io_table_lookup(struct io_table *io_table, uint64_t 
addr)
-{
-       int i;
-
-       for (i = 0; i < io_table->nr_entries; i++) {
-               if (io_table->entries[i].start <= addr &&
-                   addr < io_table->entries[i].end)
-                       return &io_table->entries[i];
-       }
-
-       return NULL;
-}
-
-int io_table_register(struct io_table *io_table, uint64_t start, uint64_t size,
-                     io_table_handler_t *handler, void *opaque)
-{
-       struct io_table_entry *entry;
-
-       if (io_table->nr_entries == MAX_IO_TABLE)
-               return -ENOSPC;
-
-       entry = &io_table->entries[io_table->nr_entries];
-       io_table->nr_entries++;
-
-       entry->start = start;
-       entry->end = start + size;
-       entry->handler = handler;
-       entry->opaque = opaque;
-
-       return 0;
-}
-
 static void apic_send_sipi(int vcpu)
 {
        sem_post(&vcpus[vcpu].sipi_sem);

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-commits mailing list
kvm-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-commits

Reply via email to