public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: [PATCH 1 of 6] Move IO handling code to a separate file
Date: Tue, 15 Jan 2008 16:43:39 -0600	[thread overview]
Message-ID: <c6e8bf3f9f7c9705a0ad.1200437019@basalt> (raw)
In-Reply-To: <patchbomb.1200437018@basalt>

# HG changeset patch
# User Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
# 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 <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

---
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 <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
+ *  Yaniv Kamay <yaniv-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
+ *
+ * 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 <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
+ *  Yaniv Kamay <yaniv-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
+ *
+ * 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/

  reply	other threads:[~2008-01-15 22:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-15 22:43 [PATCH 0 of 6] Enhance PowerPC unit tests Hollis Blanchard
2008-01-15 22:43 ` Hollis Blanchard [this message]
2008-01-16  8:16   ` [PATCH 1 of 6] Move IO handling code to a separate file Avi Kivity
2008-01-15 22:43 ` [PATCH 2 of 6] Register a debug MMIO handler, and implement putc() and exit() with it Hollis Blanchard
2008-01-15 22:43 ` [PATCH 3 of 6] Move FLATLIBS to config-x86-common.mak Hollis Blanchard
2008-01-15 22:43 ` [PATCH 4 of 6] Use "$(CC)" instead of "gcc" to find libgcc Hollis Blanchard
2008-01-15 22:43 ` [PATCH 5 of 6] Create libcflat for PowerPC Hollis Blanchard
2008-01-15 22:43 ` [PATCH 6 of 6] Reorganize PowerPC makefiles and add an "exit" test that uses libcflat Hollis Blanchard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c6e8bf3f9f7c9705a0ad.1200437019@basalt \
    --to=hollisb-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
    --cc=avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox