# HG changeset patch # User Hollis Blanchard <[EMAIL PROTECTED]> # Date 1200436754 21600 # Node ID c6e8bf3f9f7c9705a0ad29f44fa148fe80a365ff # Parent f22e390c06b78ffbcec4738112309f66267e3582 This will allow other architectures to share it, since main.c is x86-only.
Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> --- 5 files changed, 97 insertions(+), 52 deletions(-) user/config-powerpc.mak | 2 - user/config-x86-common.mak | 2 - user/iotable.c | 53 ++++++++++++++++++++++++++++++++++++++++++++ user/iotable.h | 40 +++++++++++++++++++++++++++++++++ user/main.c | 52 +------------------------------------------ diff --git a/user/config-powerpc.mak b/user/config-powerpc.mak --- a/user/config-powerpc.mak +++ b/user/config-powerpc.mak @@ -20,7 +20,7 @@ tests := $(addprefix test/powerpc/, $(te 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 --- 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 --- /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 --- /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 --- 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) @@ -53,24 +55,6 @@ kvm_context_t kvm; #define MAX_VCPUS 4 #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; @@ -90,38 +74,6 @@ struct vcpu_info *vcpus; 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) { ------------------------------------------------------------------------- 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-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel